@xata.io/client 0.0.0-alpha.vfd071d9 → 0.0.0-alpha.vfe4ae98
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 +419 -223
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +457 -141
- package/dist/index.mjs +417 -224
- 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.vfe4ae98";
|
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$7 = (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$7(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$6 = (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$6(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(...args) {
|
994
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
995
|
+
__privateAdd$6(this, _page, void 0);
|
996
|
+
__privateSet$6(this, _page, args[0]);
|
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$5 = (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$5(this, _table$1, table);
|
981
1058
|
if (repository) {
|
982
|
-
__privateSet$
|
1059
|
+
__privateSet$5(this, _repository, repository);
|
983
1060
|
} else {
|
984
|
-
__privateSet$
|
1061
|
+
__privateSet$5(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$4 = (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, _schemaTables$2, _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, _getSchemaTables$1, getSchemaTables_fn$1;
|
1157
1248
|
class Repository extends Query {
|
1158
1249
|
}
|
1159
1250
|
class RestRepository extends Query {
|
@@ -1170,18 +1261,21 @@ 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, _getSchemaTables$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, _schemaTables$2, void 0);
|
1269
|
+
__privateSet$4(this, _table, options.table);
|
1270
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1180
1271
|
this.db = options.db;
|
1181
|
-
__privateSet$
|
1272
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1273
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
1182
1274
|
}
|
1183
1275
|
async create(a, b) {
|
1184
1276
|
if (Array.isArray(a)) {
|
1277
|
+
if (a.length === 0)
|
1278
|
+
return [];
|
1185
1279
|
const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
|
1186
1280
|
await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
|
1187
1281
|
return records;
|
@@ -1207,26 +1301,38 @@ class RestRepository extends Query {
|
|
1207
1301
|
}
|
1208
1302
|
throw new Error("Invalid arguments for create method");
|
1209
1303
|
}
|
1210
|
-
async read(
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1304
|
+
async read(a) {
|
1305
|
+
if (Array.isArray(a)) {
|
1306
|
+
if (a.length === 0)
|
1307
|
+
return [];
|
1308
|
+
const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
|
1309
|
+
return this.getAll({ filter: { id: { $any: ids } } });
|
1310
|
+
}
|
1311
|
+
const id = isString(a) ? a : a.id;
|
1312
|
+
if (isString(id)) {
|
1313
|
+
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
|
1314
|
+
if (cacheRecord)
|
1315
|
+
return cacheRecord;
|
1316
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1317
|
+
try {
|
1318
|
+
const response = await getRecord({
|
1319
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
|
1320
|
+
...fetchProps
|
1321
|
+
});
|
1322
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1323
|
+
return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
|
1324
|
+
} catch (e) {
|
1325
|
+
if (isObject(e) && e.status === 404) {
|
1326
|
+
return null;
|
1327
|
+
}
|
1328
|
+
throw e;
|
1224
1329
|
}
|
1225
|
-
throw e;
|
1226
1330
|
}
|
1227
1331
|
}
|
1228
1332
|
async update(a, b) {
|
1229
1333
|
if (Array.isArray(a)) {
|
1334
|
+
if (a.length === 0)
|
1335
|
+
return [];
|
1230
1336
|
if (a.length > 100) {
|
1231
1337
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1232
1338
|
}
|
@@ -1248,6 +1354,8 @@ class RestRepository extends Query {
|
|
1248
1354
|
}
|
1249
1355
|
async createOrUpdate(a, b) {
|
1250
1356
|
if (Array.isArray(a)) {
|
1357
|
+
if (a.length === 0)
|
1358
|
+
return [];
|
1251
1359
|
if (a.length > 100) {
|
1252
1360
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1253
1361
|
}
|
@@ -1269,6 +1377,8 @@ class RestRepository extends Query {
|
|
1269
1377
|
}
|
1270
1378
|
async delete(a) {
|
1271
1379
|
if (Array.isArray(a)) {
|
1380
|
+
if (a.length === 0)
|
1381
|
+
return;
|
1272
1382
|
if (a.length > 100) {
|
1273
1383
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1274
1384
|
}
|
@@ -1288,13 +1398,19 @@ class RestRepository extends Query {
|
|
1288
1398
|
throw new Error("Invalid arguments for delete method");
|
1289
1399
|
}
|
1290
1400
|
async search(query, options = {}) {
|
1291
|
-
const fetchProps = await __privateGet$
|
1292
|
-
const { records } = await
|
1293
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1294
|
-
body: {
|
1401
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1402
|
+
const { records } = await searchTable({
|
1403
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1404
|
+
body: {
|
1405
|
+
query,
|
1406
|
+
fuzziness: options.fuzziness,
|
1407
|
+
highlight: options.highlight,
|
1408
|
+
filter: options.filter
|
1409
|
+
},
|
1295
1410
|
...fetchProps
|
1296
1411
|
});
|
1297
|
-
|
1412
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1413
|
+
return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
|
1298
1414
|
}
|
1299
1415
|
async query(query) {
|
1300
1416
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
@@ -1303,34 +1419,35 @@ class RestRepository extends Query {
|
|
1303
1419
|
const data = query.getQueryOptions();
|
1304
1420
|
const body = {
|
1305
1421
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1306
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1307
|
-
page: data.
|
1422
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1423
|
+
page: data.pagination,
|
1308
1424
|
columns: data.columns
|
1309
1425
|
};
|
1310
|
-
const fetchProps = await __privateGet$
|
1426
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1311
1427
|
const { meta, records: objects } = await queryTable({
|
1312
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1428
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1313
1429
|
body,
|
1314
1430
|
...fetchProps
|
1315
1431
|
});
|
1316
|
-
const
|
1432
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1433
|
+
const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
|
1317
1434
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1318
1435
|
return new Page(query, meta, records);
|
1319
1436
|
}
|
1320
1437
|
}
|
1321
1438
|
_table = new WeakMap();
|
1322
|
-
_links = new WeakMap();
|
1323
1439
|
_getFetchProps = new WeakMap();
|
1324
1440
|
_cache = new WeakMap();
|
1441
|
+
_schemaTables$2 = new WeakMap();
|
1325
1442
|
_insertRecordWithoutId = new WeakSet();
|
1326
1443
|
insertRecordWithoutId_fn = async function(object) {
|
1327
|
-
const fetchProps = await __privateGet$
|
1444
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1328
1445
|
const record = transformObjectLinks(object);
|
1329
1446
|
const response = await insertRecord({
|
1330
1447
|
pathParams: {
|
1331
1448
|
workspace: "{workspaceId}",
|
1332
1449
|
dbBranchName: "{dbBranch}",
|
1333
|
-
tableName: __privateGet$
|
1450
|
+
tableName: __privateGet$4(this, _table)
|
1334
1451
|
},
|
1335
1452
|
body: record,
|
1336
1453
|
...fetchProps
|
@@ -1343,13 +1460,13 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1343
1460
|
};
|
1344
1461
|
_insertRecordWithId = new WeakSet();
|
1345
1462
|
insertRecordWithId_fn = async function(recordId, object) {
|
1346
|
-
const fetchProps = await __privateGet$
|
1463
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1347
1464
|
const record = transformObjectLinks(object);
|
1348
1465
|
const response = await insertRecordWithID({
|
1349
1466
|
pathParams: {
|
1350
1467
|
workspace: "{workspaceId}",
|
1351
1468
|
dbBranchName: "{dbBranch}",
|
1352
|
-
tableName: __privateGet$
|
1469
|
+
tableName: __privateGet$4(this, _table),
|
1353
1470
|
recordId
|
1354
1471
|
},
|
1355
1472
|
body: record,
|
@@ -1364,25 +1481,29 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1364
1481
|
};
|
1365
1482
|
_bulkInsertTableRecords = new WeakSet();
|
1366
1483
|
bulkInsertTableRecords_fn = async function(objects) {
|
1367
|
-
const fetchProps = await __privateGet$
|
1484
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1368
1485
|
const records = objects.map((object) => transformObjectLinks(object));
|
1369
|
-
const
|
1370
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1486
|
+
const { recordIDs } = await bulkInsertTableRecords({
|
1487
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1371
1488
|
body: { records },
|
1372
1489
|
...fetchProps
|
1373
1490
|
});
|
1374
|
-
const finalObjects = await this.
|
1491
|
+
const finalObjects = await this.read(recordIDs);
|
1375
1492
|
if (finalObjects.length !== objects.length) {
|
1376
1493
|
throw new Error("The server failed to save some records");
|
1377
1494
|
}
|
1378
|
-
|
1495
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
1496
|
+
acc[object.id] = object;
|
1497
|
+
return acc;
|
1498
|
+
}, {});
|
1499
|
+
return recordIDs.map((id) => dictionary[id]);
|
1379
1500
|
};
|
1380
1501
|
_updateRecordWithID = new WeakSet();
|
1381
1502
|
updateRecordWithID_fn = async function(recordId, object) {
|
1382
|
-
const fetchProps = await __privateGet$
|
1503
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1383
1504
|
const record = transformObjectLinks(object);
|
1384
1505
|
const response = await updateRecordWithID({
|
1385
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1506
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1386
1507
|
body: record,
|
1387
1508
|
...fetchProps
|
1388
1509
|
});
|
@@ -1393,9 +1514,9 @@ updateRecordWithID_fn = async function(recordId, object) {
|
|
1393
1514
|
};
|
1394
1515
|
_upsertRecordWithID = new WeakSet();
|
1395
1516
|
upsertRecordWithID_fn = async function(recordId, object) {
|
1396
|
-
const fetchProps = await __privateGet$
|
1517
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1397
1518
|
const response = await upsertRecordWithID({
|
1398
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1519
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1399
1520
|
body: object,
|
1400
1521
|
...fetchProps
|
1401
1522
|
});
|
@@ -1406,51 +1527,63 @@ upsertRecordWithID_fn = async function(recordId, object) {
|
|
1406
1527
|
};
|
1407
1528
|
_deleteRecord = new WeakSet();
|
1408
1529
|
deleteRecord_fn = async function(recordId) {
|
1409
|
-
const fetchProps = await __privateGet$
|
1530
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1410
1531
|
await deleteRecord({
|
1411
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1532
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1412
1533
|
...fetchProps
|
1413
1534
|
});
|
1414
1535
|
};
|
1415
1536
|
_invalidateCache = new WeakSet();
|
1416
1537
|
invalidateCache_fn = async function(recordId) {
|
1417
|
-
await __privateGet$
|
1418
|
-
const cacheItems = await __privateGet$
|
1538
|
+
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1539
|
+
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1419
1540
|
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1420
1541
|
for (const [key, value] of queries) {
|
1421
1542
|
const ids = getIds(value);
|
1422
1543
|
if (ids.includes(recordId))
|
1423
|
-
await __privateGet$
|
1544
|
+
await __privateGet$4(this, _cache).delete(key);
|
1424
1545
|
}
|
1425
1546
|
};
|
1426
1547
|
_setCacheRecord = new WeakSet();
|
1427
1548
|
setCacheRecord_fn = async function(record) {
|
1428
|
-
if (!__privateGet$
|
1549
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1429
1550
|
return;
|
1430
|
-
await __privateGet$
|
1551
|
+
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1431
1552
|
};
|
1432
1553
|
_getCacheRecord = new WeakSet();
|
1433
1554
|
getCacheRecord_fn = async function(recordId) {
|
1434
|
-
if (!__privateGet$
|
1555
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1435
1556
|
return null;
|
1436
|
-
return __privateGet$
|
1557
|
+
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1437
1558
|
};
|
1438
1559
|
_setCacheQuery = new WeakSet();
|
1439
1560
|
setCacheQuery_fn = async function(query, meta, records) {
|
1440
|
-
await __privateGet$
|
1561
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1441
1562
|
};
|
1442
1563
|
_getCacheQuery = new WeakSet();
|
1443
1564
|
getCacheQuery_fn = async function(query) {
|
1444
|
-
const key = `query_${__privateGet$
|
1445
|
-
const result = await __privateGet$
|
1565
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1566
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1446
1567
|
if (!result)
|
1447
1568
|
return null;
|
1448
|
-
const { cache: ttl = __privateGet$
|
1449
|
-
if (
|
1450
|
-
return
|
1569
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1570
|
+
if (ttl < 0)
|
1571
|
+
return null;
|
1451
1572
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1452
1573
|
return hasExpired ? null : result;
|
1453
1574
|
};
|
1575
|
+
_getSchemaTables$1 = new WeakSet();
|
1576
|
+
getSchemaTables_fn$1 = async function() {
|
1577
|
+
if (__privateGet$4(this, _schemaTables$2))
|
1578
|
+
return __privateGet$4(this, _schemaTables$2);
|
1579
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1580
|
+
const { schema } = await getBranchDetails({
|
1581
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1582
|
+
...fetchProps
|
1583
|
+
});
|
1584
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
1585
|
+
return schema.tables;
|
1586
|
+
};
|
1454
1587
|
const transformObjectLinks = (object) => {
|
1455
1588
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1456
1589
|
if (key === "xata")
|
@@ -1458,15 +1591,34 @@ const transformObjectLinks = (object) => {
|
|
1458
1591
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1459
1592
|
}, {});
|
1460
1593
|
};
|
1461
|
-
const initObject = (db,
|
1594
|
+
const initObject = (db, schemaTables, table, object) => {
|
1462
1595
|
const result = {};
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1596
|
+
const { xata, ...rest } = object ?? {};
|
1597
|
+
Object.assign(result, rest);
|
1598
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1599
|
+
if (!columns)
|
1600
|
+
console.error(`Table ${table} not found in schema`);
|
1601
|
+
for (const column of columns ?? []) {
|
1602
|
+
const value = result[column.name];
|
1603
|
+
switch (column.type) {
|
1604
|
+
case "datetime": {
|
1605
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1606
|
+
if (date && isNaN(date.getTime())) {
|
1607
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1608
|
+
} else if (date) {
|
1609
|
+
result[column.name] = date;
|
1610
|
+
}
|
1611
|
+
break;
|
1612
|
+
}
|
1613
|
+
case "link": {
|
1614
|
+
const linkTable = column.link?.table;
|
1615
|
+
if (!linkTable) {
|
1616
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
1617
|
+
} else if (isObject(value)) {
|
1618
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
1619
|
+
}
|
1620
|
+
break;
|
1621
|
+
}
|
1470
1622
|
}
|
1471
1623
|
}
|
1472
1624
|
result.read = function() {
|
@@ -1478,7 +1630,10 @@ const initObject = (db, links, table, object) => {
|
|
1478
1630
|
result.delete = function() {
|
1479
1631
|
return db[table].delete(result["id"]);
|
1480
1632
|
};
|
1481
|
-
|
1633
|
+
result.getMetadata = function() {
|
1634
|
+
return xata;
|
1635
|
+
};
|
1636
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1482
1637
|
Object.defineProperty(result, prop, { enumerable: false });
|
1483
1638
|
}
|
1484
1639
|
Object.freeze(result);
|
@@ -1498,7 +1653,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
1498
1653
|
if (!member.has(obj))
|
1499
1654
|
throw TypeError("Cannot " + msg);
|
1500
1655
|
};
|
1501
|
-
var __privateGet$
|
1656
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1502
1657
|
__accessCheck$3(obj, member, "read from private field");
|
1503
1658
|
return getter ? getter.call(obj) : member.get(obj);
|
1504
1659
|
};
|
@@ -1507,7 +1662,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1507
1662
|
throw TypeError("Cannot add the same private member more than once");
|
1508
1663
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1509
1664
|
};
|
1510
|
-
var __privateSet$
|
1665
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1511
1666
|
__accessCheck$3(obj, member, "write to private field");
|
1512
1667
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1513
1668
|
return value;
|
@@ -1516,30 +1671,30 @@ var _map;
|
|
1516
1671
|
class SimpleCache {
|
1517
1672
|
constructor(options = {}) {
|
1518
1673
|
__privateAdd$3(this, _map, void 0);
|
1519
|
-
__privateSet$
|
1674
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1520
1675
|
this.capacity = options.max ?? 500;
|
1521
1676
|
this.cacheRecords = options.cacheRecords ?? true;
|
1522
1677
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1523
1678
|
}
|
1524
1679
|
async getAll() {
|
1525
|
-
return Object.fromEntries(__privateGet$
|
1680
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1526
1681
|
}
|
1527
1682
|
async get(key) {
|
1528
|
-
return __privateGet$
|
1683
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1529
1684
|
}
|
1530
1685
|
async set(key, value) {
|
1531
1686
|
await this.delete(key);
|
1532
|
-
__privateGet$
|
1533
|
-
if (__privateGet$
|
1534
|
-
const leastRecentlyUsed = __privateGet$
|
1687
|
+
__privateGet$3(this, _map).set(key, value);
|
1688
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
1689
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1535
1690
|
await this.delete(leastRecentlyUsed);
|
1536
1691
|
}
|
1537
1692
|
}
|
1538
1693
|
async delete(key) {
|
1539
|
-
__privateGet$
|
1694
|
+
__privateGet$3(this, _map).delete(key);
|
1540
1695
|
}
|
1541
1696
|
async clear() {
|
1542
|
-
return __privateGet$
|
1697
|
+
return __privateGet$3(this, _map).clear();
|
1543
1698
|
}
|
1544
1699
|
}
|
1545
1700
|
_map = new WeakMap();
|
@@ -1567,7 +1722,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1567
1722
|
if (!member.has(obj))
|
1568
1723
|
throw TypeError("Cannot " + msg);
|
1569
1724
|
};
|
1570
|
-
var __privateGet$
|
1725
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1571
1726
|
__accessCheck$2(obj, member, "read from private field");
|
1572
1727
|
return getter ? getter.call(obj) : member.get(obj);
|
1573
1728
|
};
|
@@ -1576,87 +1731,119 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1576
1731
|
throw TypeError("Cannot add the same private member more than once");
|
1577
1732
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1578
1733
|
};
|
1579
|
-
var
|
1734
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1735
|
+
__accessCheck$2(obj, member, "write to private field");
|
1736
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1737
|
+
return value;
|
1738
|
+
};
|
1739
|
+
var _tables, _schemaTables$1;
|
1580
1740
|
class SchemaPlugin extends XataPlugin {
|
1581
|
-
constructor(
|
1741
|
+
constructor(schemaTables) {
|
1582
1742
|
super();
|
1583
|
-
this.links = links;
|
1584
|
-
this.tableNames = tableNames;
|
1585
1743
|
__privateAdd$2(this, _tables, {});
|
1744
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
1745
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1586
1746
|
}
|
1587
1747
|
build(pluginOptions) {
|
1588
|
-
const links = this.links;
|
1589
1748
|
const db = new Proxy({}, {
|
1590
1749
|
get: (_target, table) => {
|
1591
1750
|
if (!isString(table))
|
1592
1751
|
throw new Error("Invalid table name");
|
1593
|
-
if (
|
1594
|
-
__privateGet$
|
1752
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1753
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1595
1754
|
}
|
1596
|
-
return __privateGet$
|
1755
|
+
return __privateGet$2(this, _tables)[table];
|
1597
1756
|
}
|
1598
1757
|
});
|
1599
|
-
|
1600
|
-
|
1758
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
1759
|
+
for (const table of tableNames) {
|
1760
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1601
1761
|
}
|
1602
1762
|
return db;
|
1603
1763
|
}
|
1604
1764
|
}
|
1605
1765
|
_tables = new WeakMap();
|
1766
|
+
_schemaTables$1 = new WeakMap();
|
1606
1767
|
|
1607
1768
|
var __accessCheck$1 = (obj, member, msg) => {
|
1608
1769
|
if (!member.has(obj))
|
1609
1770
|
throw TypeError("Cannot " + msg);
|
1610
1771
|
};
|
1772
|
+
var __privateGet$1 = (obj, member, getter) => {
|
1773
|
+
__accessCheck$1(obj, member, "read from private field");
|
1774
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1775
|
+
};
|
1611
1776
|
var __privateAdd$1 = (obj, member, value) => {
|
1612
1777
|
if (member.has(obj))
|
1613
1778
|
throw TypeError("Cannot add the same private member more than once");
|
1614
1779
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1615
1780
|
};
|
1781
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
1782
|
+
__accessCheck$1(obj, member, "write to private field");
|
1783
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1784
|
+
return value;
|
1785
|
+
};
|
1616
1786
|
var __privateMethod$1 = (obj, member, method) => {
|
1617
1787
|
__accessCheck$1(obj, member, "access private method");
|
1618
1788
|
return method;
|
1619
1789
|
};
|
1620
|
-
var _search, search_fn;
|
1790
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1621
1791
|
class SearchPlugin extends XataPlugin {
|
1622
|
-
constructor(db,
|
1792
|
+
constructor(db, schemaTables) {
|
1623
1793
|
super();
|
1624
1794
|
this.db = db;
|
1625
|
-
this.links = links;
|
1626
1795
|
__privateAdd$1(this, _search);
|
1796
|
+
__privateAdd$1(this, _getSchemaTables);
|
1797
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
1798
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1627
1799
|
}
|
1628
1800
|
build({ getFetchProps }) {
|
1629
1801
|
return {
|
1630
1802
|
all: async (query, options = {}) => {
|
1631
1803
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1804
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1632
1805
|
return records.map((record) => {
|
1633
1806
|
const { table = "orphan" } = record.xata;
|
1634
|
-
return { table, record: initObject(this.db,
|
1807
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
1635
1808
|
});
|
1636
1809
|
},
|
1637
1810
|
byTable: async (query, options = {}) => {
|
1638
1811
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1812
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1639
1813
|
return records.reduce((acc, record) => {
|
1640
1814
|
const { table = "orphan" } = record.xata;
|
1641
1815
|
const items = acc[table] ?? [];
|
1642
|
-
const item = initObject(this.db,
|
1816
|
+
const item = initObject(this.db, schemaTables, table, record);
|
1643
1817
|
return { ...acc, [table]: [...items, item] };
|
1644
1818
|
}, {});
|
1645
1819
|
}
|
1646
1820
|
};
|
1647
1821
|
}
|
1648
1822
|
}
|
1823
|
+
_schemaTables = new WeakMap();
|
1649
1824
|
_search = new WeakSet();
|
1650
1825
|
search_fn = async function(query, options, getFetchProps) {
|
1651
1826
|
const fetchProps = await getFetchProps();
|
1652
|
-
const { tables, fuzziness } = options ?? {};
|
1827
|
+
const { tables, fuzziness, highlight } = options ?? {};
|
1653
1828
|
const { records } = await searchBranch({
|
1654
1829
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1655
|
-
body: { tables, query, fuzziness },
|
1830
|
+
body: { tables, query, fuzziness, highlight },
|
1656
1831
|
...fetchProps
|
1657
1832
|
});
|
1658
1833
|
return records;
|
1659
1834
|
};
|
1835
|
+
_getSchemaTables = new WeakSet();
|
1836
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
1837
|
+
if (__privateGet$1(this, _schemaTables))
|
1838
|
+
return __privateGet$1(this, _schemaTables);
|
1839
|
+
const fetchProps = await getFetchProps();
|
1840
|
+
const { schema } = await getBranchDetails({
|
1841
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1842
|
+
...fetchProps
|
1843
|
+
});
|
1844
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
1845
|
+
return schema.tables;
|
1846
|
+
};
|
1660
1847
|
|
1661
1848
|
const isBranchStrategyBuilder = (strategy) => {
|
1662
1849
|
return typeof strategy === "function";
|
@@ -1668,30 +1855,39 @@ const envBranchNames = [
|
|
1668
1855
|
"CF_PAGES_BRANCH",
|
1669
1856
|
"BRANCH"
|
1670
1857
|
];
|
1671
|
-
const defaultBranch = "main";
|
1672
1858
|
async function getCurrentBranchName(options) {
|
1673
|
-
const env =
|
1674
|
-
if (env)
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
return defaultBranch;
|
1859
|
+
const env = getBranchByEnvVariable();
|
1860
|
+
if (env) {
|
1861
|
+
const details = await getDatabaseBranch(env, options);
|
1862
|
+
if (details)
|
1863
|
+
return env;
|
1864
|
+
console.warn(`Branch ${env} not found in Xata. Ignoring...`);
|
1865
|
+
}
|
1866
|
+
const gitBranch = await getGitBranch();
|
1867
|
+
return resolveXataBranch(gitBranch, options);
|
1683
1868
|
}
|
1684
1869
|
async function getCurrentBranchDetails(options) {
|
1685
|
-
const
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1870
|
+
const branch = await getCurrentBranchName(options);
|
1871
|
+
return getDatabaseBranch(branch, options);
|
1872
|
+
}
|
1873
|
+
async function resolveXataBranch(gitBranch, options) {
|
1874
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1875
|
+
const apiKey = options?.apiKey || getAPIKey();
|
1876
|
+
if (!databaseURL)
|
1877
|
+
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
1878
|
+
if (!apiKey)
|
1879
|
+
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
1880
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1881
|
+
const [workspace] = host.split(".");
|
1882
|
+
const { branch } = await resolveBranch({
|
1883
|
+
apiKey,
|
1884
|
+
apiUrl: databaseURL,
|
1885
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1886
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
1887
|
+
pathParams: { dbName, workspace },
|
1888
|
+
queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
|
1889
|
+
});
|
1890
|
+
return branch;
|
1695
1891
|
}
|
1696
1892
|
async function getDatabaseBranch(branch, options) {
|
1697
1893
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
@@ -1709,10 +1905,7 @@ async function getDatabaseBranch(branch, options) {
|
|
1709
1905
|
apiUrl: databaseURL,
|
1710
1906
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1711
1907
|
workspacesApiUrl: `${protocol}//${host}`,
|
1712
|
-
pathParams: {
|
1713
|
-
dbBranchName,
|
1714
|
-
workspace
|
1715
|
-
}
|
1908
|
+
pathParams: { dbBranchName, workspace }
|
1716
1909
|
});
|
1717
1910
|
} catch (err) {
|
1718
1911
|
if (isObject(err) && err.status === 404)
|
@@ -1765,7 +1958,7 @@ var __privateMethod = (obj, member, method) => {
|
|
1765
1958
|
const buildClient = (plugins) => {
|
1766
1959
|
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1767
1960
|
return _a = class {
|
1768
|
-
constructor(options = {},
|
1961
|
+
constructor(options = {}, schemaTables) {
|
1769
1962
|
__privateAdd(this, _parseOptions);
|
1770
1963
|
__privateAdd(this, _getFetchProps);
|
1771
1964
|
__privateAdd(this, _evaluateBranch);
|
@@ -1775,12 +1968,12 @@ const buildClient = (plugins) => {
|
|
1775
1968
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1776
1969
|
cache: safeOptions.cache
|
1777
1970
|
};
|
1778
|
-
const db = new SchemaPlugin(
|
1779
|
-
const search = new SearchPlugin(db,
|
1971
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
1972
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1780
1973
|
this.db = db;
|
1781
1974
|
this.search = search;
|
1782
1975
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1783
|
-
if (
|
1976
|
+
if (namespace === void 0)
|
1784
1977
|
continue;
|
1785
1978
|
const result = namespace.build(pluginOptions);
|
1786
1979
|
if (result instanceof Promise) {
|
@@ -1797,7 +1990,7 @@ const buildClient = (plugins) => {
|
|
1797
1990
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1798
1991
|
const apiKey = options?.apiKey || getAPIKey();
|
1799
1992
|
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 });
|
1993
|
+
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
1994
|
if (!databaseURL || !apiKey) {
|
1802
1995
|
throw new Error("Options databaseURL and apiKey are required");
|
1803
1996
|
}
|
@@ -1824,7 +2017,7 @@ const buildClient = (plugins) => {
|
|
1824
2017
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1825
2018
|
if (__privateGet(this, _branch))
|
1826
2019
|
return __privateGet(this, _branch);
|
1827
|
-
if (
|
2020
|
+
if (param === void 0)
|
1828
2021
|
return void 0;
|
1829
2022
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1830
2023
|
const evaluateBranch = async (strategy) => {
|
@@ -1849,5 +2042,5 @@ class XataError extends Error {
|
|
1849
2042
|
}
|
1850
2043
|
}
|
1851
2044
|
|
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 };
|
2045
|
+
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
2046
|
//# sourceMappingURL=index.mjs.map
|