@xata.io/client 0.0.0-alpha.vf8b86c5 → 0.0.0-alpha.vf90263d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-add-version.log +1 -1
- package/.turbo/turbo-build.log +3 -8
- package/CHANGELOG.md +123 -1
- package/dist/index.cjs +473 -281
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +869 -301
- package/dist/index.mjs +452 -281
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -18,7 +18,8 @@ const TraceAttributes = {
|
|
18
18
|
HTTP_METHOD: "http.method",
|
19
19
|
HTTP_URL: "http.url",
|
20
20
|
HTTP_ROUTE: "http.route",
|
21
|
-
HTTP_TARGET: "http.target"
|
21
|
+
HTTP_TARGET: "http.target",
|
22
|
+
CLOUDFLARE_RAY_ID: "cf.ray"
|
22
23
|
};
|
23
24
|
|
24
25
|
function notEmpty(value) {
|
@@ -30,8 +31,15 @@ function compact(arr) {
|
|
30
31
|
function compactObject(obj) {
|
31
32
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
32
33
|
}
|
34
|
+
function isBlob(value) {
|
35
|
+
try {
|
36
|
+
return value instanceof Blob;
|
37
|
+
} catch (error) {
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
}
|
33
41
|
function isObject(value) {
|
34
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
42
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
|
35
43
|
}
|
36
44
|
function isDefined(value) {
|
37
45
|
return value !== null && value !== void 0;
|
@@ -86,6 +94,18 @@ function chunk(array, chunkSize) {
|
|
86
94
|
async function timeout(ms) {
|
87
95
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
88
96
|
}
|
97
|
+
function timeoutWithCancel(ms) {
|
98
|
+
let timeoutId;
|
99
|
+
const promise = new Promise((resolve) => {
|
100
|
+
timeoutId = setTimeout(() => {
|
101
|
+
resolve();
|
102
|
+
}, ms);
|
103
|
+
});
|
104
|
+
return {
|
105
|
+
cancel: () => clearTimeout(timeoutId),
|
106
|
+
promise
|
107
|
+
};
|
108
|
+
}
|
89
109
|
function promiseMap(inputValues, mapper) {
|
90
110
|
const reducer = (acc$, inputValue) => acc$.then(
|
91
111
|
(acc) => mapper(inputValue).then((result) => {
|
@@ -194,7 +214,7 @@ function getAPIKey() {
|
|
194
214
|
function getBranch() {
|
195
215
|
try {
|
196
216
|
const { branch } = getEnvironment();
|
197
|
-
return branch
|
217
|
+
return branch;
|
198
218
|
} catch (err) {
|
199
219
|
return void 0;
|
200
220
|
}
|
@@ -222,12 +242,6 @@ function getPreviewBranch() {
|
|
222
242
|
}
|
223
243
|
}
|
224
244
|
|
225
|
-
var __defProp$8 = Object.defineProperty;
|
226
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
227
|
-
var __publicField$8 = (obj, key, value) => {
|
228
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
229
|
-
return value;
|
230
|
-
};
|
231
245
|
var __accessCheck$8 = (obj, member, msg) => {
|
232
246
|
if (!member.has(obj))
|
233
247
|
throw TypeError("Cannot " + msg);
|
@@ -251,13 +265,13 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
251
265
|
return method;
|
252
266
|
};
|
253
267
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
268
|
+
const REQUEST_TIMEOUT = 5 * 60 * 1e3;
|
254
269
|
function getFetchImplementation(userFetch) {
|
255
270
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
256
|
-
const
|
271
|
+
const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
|
272
|
+
const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
|
257
273
|
if (!fetchImpl) {
|
258
|
-
throw new Error(
|
259
|
-
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
260
|
-
);
|
274
|
+
throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
|
261
275
|
}
|
262
276
|
return fetchImpl;
|
263
277
|
}
|
@@ -267,8 +281,6 @@ class ApiRequestPool {
|
|
267
281
|
__privateAdd$8(this, _fetch, void 0);
|
268
282
|
__privateAdd$8(this, _queue, void 0);
|
269
283
|
__privateAdd$8(this, _concurrency, void 0);
|
270
|
-
__publicField$8(this, "running");
|
271
|
-
__publicField$8(this, "started");
|
272
284
|
__privateSet$8(this, _queue, []);
|
273
285
|
__privateSet$8(this, _concurrency, concurrency);
|
274
286
|
this.running = 0;
|
@@ -285,9 +297,13 @@ class ApiRequestPool {
|
|
285
297
|
}
|
286
298
|
request(url, options) {
|
287
299
|
const start = /* @__PURE__ */ new Date();
|
288
|
-
const
|
300
|
+
const fetchImpl = this.getFetch();
|
289
301
|
const runRequest = async (stalled = false) => {
|
290
|
-
const
|
302
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
303
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
304
|
+
if (!response) {
|
305
|
+
throw new Error("Request timed out");
|
306
|
+
}
|
291
307
|
if (response.status === 429) {
|
292
308
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
293
309
|
await timeout(rateLimitReset * 1e3);
|
@@ -295,7 +311,7 @@ class ApiRequestPool {
|
|
295
311
|
}
|
296
312
|
if (stalled) {
|
297
313
|
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
298
|
-
console.warn(`A request to Xata hit
|
314
|
+
console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
|
299
315
|
}
|
300
316
|
return response;
|
301
317
|
};
|
@@ -510,26 +526,16 @@ function defaultOnOpen(response) {
|
|
510
526
|
}
|
511
527
|
}
|
512
528
|
|
513
|
-
const VERSION = "0.
|
529
|
+
const VERSION = "0.27.0";
|
514
530
|
|
515
|
-
var __defProp$7 = Object.defineProperty;
|
516
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
517
|
-
var __publicField$7 = (obj, key, value) => {
|
518
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
519
|
-
return value;
|
520
|
-
};
|
521
531
|
class ErrorWithCause extends Error {
|
522
532
|
constructor(message, options) {
|
523
533
|
super(message, options);
|
524
|
-
__publicField$7(this, "cause");
|
525
534
|
}
|
526
535
|
}
|
527
536
|
class FetcherError extends ErrorWithCause {
|
528
537
|
constructor(status, data, requestId) {
|
529
538
|
super(getMessage(data));
|
530
|
-
__publicField$7(this, "status");
|
531
|
-
__publicField$7(this, "requestId");
|
532
|
-
__publicField$7(this, "errors");
|
533
539
|
this.status = status;
|
534
540
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
535
541
|
this.requestId = requestId;
|
@@ -596,11 +602,14 @@ function hostHeader(url) {
|
|
596
602
|
const { groups } = pattern.exec(url) ?? {};
|
597
603
|
return groups?.host ? { Host: groups.host } : {};
|
598
604
|
}
|
599
|
-
function parseBody(body, headers) {
|
605
|
+
async function parseBody(body, headers) {
|
600
606
|
if (!isDefined(body))
|
601
607
|
return void 0;
|
608
|
+
if (isBlob(body) || typeof body.text === "function") {
|
609
|
+
return body;
|
610
|
+
}
|
602
611
|
const { "Content-Type": contentType } = headers ?? {};
|
603
|
-
if (String(contentType).toLowerCase() === "application/json") {
|
612
|
+
if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
|
604
613
|
return JSON.stringify(body);
|
605
614
|
}
|
606
615
|
return body;
|
@@ -657,7 +666,7 @@ async function fetch$1({
|
|
657
666
|
const response = await pool.request(url, {
|
658
667
|
...fetchOptions,
|
659
668
|
method: method.toUpperCase(),
|
660
|
-
body: parseBody(body, headers),
|
669
|
+
body: await parseBody(body, headers),
|
661
670
|
headers,
|
662
671
|
signal
|
663
672
|
});
|
@@ -668,7 +677,8 @@ async function fetch$1({
|
|
668
677
|
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
669
678
|
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
670
679
|
[TraceAttributes.HTTP_HOST]: host,
|
671
|
-
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
680
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
|
681
|
+
[TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
|
672
682
|
});
|
673
683
|
const message = response.headers?.get("x-xata-message");
|
674
684
|
if (message)
|
@@ -756,6 +766,12 @@ function parseUrl(url) {
|
|
756
766
|
|
757
767
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
758
768
|
|
769
|
+
const applyMigration = (variables, signal) => dataPlaneFetch({
|
770
|
+
url: "/db/{dbBranchName}/pgroll/apply",
|
771
|
+
method: "post",
|
772
|
+
...variables,
|
773
|
+
signal
|
774
|
+
});
|
759
775
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
760
776
|
url: "/dbs/{dbName}",
|
761
777
|
method: "get",
|
@@ -775,6 +791,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
775
791
|
...variables,
|
776
792
|
signal
|
777
793
|
});
|
794
|
+
const getSchema = (variables, signal) => dataPlaneFetch({
|
795
|
+
url: "/db/{dbBranchName}/schema",
|
796
|
+
method: "get",
|
797
|
+
...variables,
|
798
|
+
signal
|
799
|
+
});
|
778
800
|
const copyBranch = (variables, signal) => dataPlaneFetch({
|
779
801
|
url: "/db/{dbBranchName}/copy",
|
780
802
|
method: "post",
|
@@ -940,12 +962,6 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
940
962
|
...variables,
|
941
963
|
signal
|
942
964
|
});
|
943
|
-
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
944
|
-
url: "/db/{dbBranchName}/sql",
|
945
|
-
method: "post",
|
946
|
-
...variables,
|
947
|
-
signal
|
948
|
-
});
|
949
965
|
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
950
966
|
const askTable = (variables, signal) => dataPlaneFetch({
|
951
967
|
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
@@ -953,7 +969,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
953
969
|
...variables,
|
954
970
|
signal
|
955
971
|
});
|
956
|
-
const
|
972
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
957
973
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
958
974
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
959
975
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
@@ -962,8 +978,15 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
962
978
|
...variables,
|
963
979
|
signal
|
964
980
|
});
|
981
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
982
|
+
url: "/db/{dbBranchName}/sql",
|
983
|
+
method: "post",
|
984
|
+
...variables,
|
985
|
+
signal
|
986
|
+
});
|
965
987
|
const operationsByTag$2 = {
|
966
988
|
branch: {
|
989
|
+
applyMigration,
|
967
990
|
getBranchList,
|
968
991
|
getBranchDetails,
|
969
992
|
createBranch,
|
@@ -978,6 +1001,7 @@ const operationsByTag$2 = {
|
|
978
1001
|
resolveBranch
|
979
1002
|
},
|
980
1003
|
migrations: {
|
1004
|
+
getSchema,
|
981
1005
|
getBranchMigrationHistory,
|
982
1006
|
getBranchMigrationPlan,
|
983
1007
|
executeBranchMigrationPlan,
|
@@ -1026,17 +1050,19 @@ const operationsByTag$2 = {
|
|
1026
1050
|
queryTable,
|
1027
1051
|
searchBranch,
|
1028
1052
|
searchTable,
|
1029
|
-
sqlQuery,
|
1030
1053
|
vectorSearchTable,
|
1031
1054
|
askTable,
|
1032
|
-
|
1055
|
+
askTableSession,
|
1033
1056
|
summarizeTable,
|
1034
1057
|
aggregateTable
|
1035
|
-
}
|
1058
|
+
},
|
1059
|
+
sql: { sqlQuery }
|
1036
1060
|
};
|
1037
1061
|
|
1038
1062
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
1039
1063
|
|
1064
|
+
const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
|
1065
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
1040
1066
|
const getUser = (variables, signal) => controlPlaneFetch({
|
1041
1067
|
url: "/user",
|
1042
1068
|
method: "get",
|
@@ -1073,6 +1099,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
1073
1099
|
...variables,
|
1074
1100
|
signal
|
1075
1101
|
});
|
1102
|
+
const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
1103
|
+
url: "/user/oauth/clients",
|
1104
|
+
method: "get",
|
1105
|
+
...variables,
|
1106
|
+
signal
|
1107
|
+
});
|
1108
|
+
const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
|
1109
|
+
url: "/user/oauth/clients/{clientId}",
|
1110
|
+
method: "delete",
|
1111
|
+
...variables,
|
1112
|
+
signal
|
1113
|
+
});
|
1114
|
+
const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
|
1115
|
+
url: "/user/oauth/tokens",
|
1116
|
+
method: "get",
|
1117
|
+
...variables,
|
1118
|
+
signal
|
1119
|
+
});
|
1120
|
+
const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
1121
|
+
url: "/user/oauth/tokens/{token}",
|
1122
|
+
method: "delete",
|
1123
|
+
...variables,
|
1124
|
+
signal
|
1125
|
+
});
|
1126
|
+
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
|
1076
1127
|
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
1077
1128
|
url: "/workspaces",
|
1078
1129
|
method: "get",
|
@@ -1116,6 +1167,20 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
1116
1167
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1117
1168
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1118
1169
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1170
|
+
const listClusters = (variables, signal) => controlPlaneFetch({
|
1171
|
+
url: "/workspaces/{workspaceId}/clusters",
|
1172
|
+
method: "get",
|
1173
|
+
...variables,
|
1174
|
+
signal
|
1175
|
+
});
|
1176
|
+
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1177
|
+
const getCluster = (variables, signal) => controlPlaneFetch({
|
1178
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
1179
|
+
method: "get",
|
1180
|
+
...variables,
|
1181
|
+
signal
|
1182
|
+
});
|
1183
|
+
const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
|
1119
1184
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
1120
1185
|
url: "/workspaces/{workspaceId}/dbs",
|
1121
1186
|
method: "get",
|
@@ -1142,6 +1207,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1142
1207
|
signal
|
1143
1208
|
});
|
1144
1209
|
const operationsByTag$1 = {
|
1210
|
+
oAuth: {
|
1211
|
+
getAuthorizationCode,
|
1212
|
+
grantAuthorizationCode,
|
1213
|
+
getUserOAuthClients,
|
1214
|
+
deleteUserOAuthClient,
|
1215
|
+
getUserOAuthAccessTokens,
|
1216
|
+
deleteOAuthAccessToken,
|
1217
|
+
updateOAuthAccessToken
|
1218
|
+
},
|
1145
1219
|
users: { getUser, updateUser, deleteUser },
|
1146
1220
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1147
1221
|
workspaces: {
|
@@ -1161,6 +1235,7 @@ const operationsByTag$1 = {
|
|
1161
1235
|
acceptWorkspaceMemberInvite,
|
1162
1236
|
resendWorkspaceMemberInvite
|
1163
1237
|
},
|
1238
|
+
xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
|
1164
1239
|
databases: {
|
1165
1240
|
getDatabaseList,
|
1166
1241
|
createDatabase,
|
@@ -2154,7 +2229,7 @@ class SearchAndFilterApi {
|
|
2154
2229
|
...this.extraProps
|
2155
2230
|
});
|
2156
2231
|
}
|
2157
|
-
|
2232
|
+
askTableSession({
|
2158
2233
|
workspace,
|
2159
2234
|
region,
|
2160
2235
|
database,
|
@@ -2163,7 +2238,7 @@ class SearchAndFilterApi {
|
|
2163
2238
|
sessionId,
|
2164
2239
|
message
|
2165
2240
|
}) {
|
2166
|
-
return operationsByTag.searchAndFilter.
|
2241
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2167
2242
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2168
2243
|
body: { message },
|
2169
2244
|
...this.extraProps
|
@@ -2556,60 +2631,6 @@ class XataApiPlugin {
|
|
2556
2631
|
class XataPlugin {
|
2557
2632
|
}
|
2558
2633
|
|
2559
|
-
class FilesPlugin extends XataPlugin {
|
2560
|
-
build(pluginOptions) {
|
2561
|
-
return {
|
2562
|
-
download: async (location) => {
|
2563
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2564
|
-
return await getFileItem({
|
2565
|
-
pathParams: {
|
2566
|
-
workspace: "{workspaceId}",
|
2567
|
-
dbBranchName: "{dbBranch}",
|
2568
|
-
region: "{region}",
|
2569
|
-
tableName: table ?? "",
|
2570
|
-
recordId: record ?? "",
|
2571
|
-
columnName: column ?? "",
|
2572
|
-
fileId
|
2573
|
-
},
|
2574
|
-
...pluginOptions,
|
2575
|
-
rawResponse: true
|
2576
|
-
});
|
2577
|
-
},
|
2578
|
-
upload: async (location, file) => {
|
2579
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2580
|
-
return await putFileItem({
|
2581
|
-
pathParams: {
|
2582
|
-
workspace: "{workspaceId}",
|
2583
|
-
dbBranchName: "{dbBranch}",
|
2584
|
-
region: "{region}",
|
2585
|
-
tableName: table ?? "",
|
2586
|
-
recordId: record ?? "",
|
2587
|
-
columnName: column ?? "",
|
2588
|
-
fileId
|
2589
|
-
},
|
2590
|
-
body: file,
|
2591
|
-
...pluginOptions
|
2592
|
-
});
|
2593
|
-
},
|
2594
|
-
delete: async (location) => {
|
2595
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2596
|
-
return await deleteFileItem({
|
2597
|
-
pathParams: {
|
2598
|
-
workspace: "{workspaceId}",
|
2599
|
-
dbBranchName: "{dbBranch}",
|
2600
|
-
region: "{region}",
|
2601
|
-
tableName: table ?? "",
|
2602
|
-
recordId: record ?? "",
|
2603
|
-
columnName: column ?? "",
|
2604
|
-
fileId
|
2605
|
-
},
|
2606
|
-
...pluginOptions
|
2607
|
-
});
|
2608
|
-
}
|
2609
|
-
};
|
2610
|
-
}
|
2611
|
-
}
|
2612
|
-
|
2613
2634
|
function buildTransformString(transformations) {
|
2614
2635
|
return transformations.flatMap(
|
2615
2636
|
(t) => Object.entries(t).map(([key, value]) => {
|
@@ -2625,74 +2646,34 @@ function buildTransformString(transformations) {
|
|
2625
2646
|
})
|
2626
2647
|
).join(",");
|
2627
2648
|
}
|
2628
|
-
function transformImage(url, transformations) {
|
2649
|
+
function transformImage(url, ...transformations) {
|
2629
2650
|
if (!isDefined(url))
|
2630
2651
|
return void 0;
|
2631
|
-
const
|
2652
|
+
const newTransformations = buildTransformString(transformations);
|
2632
2653
|
const { hostname, pathname, search } = new URL(url);
|
2633
|
-
|
2654
|
+
const pathParts = pathname.split("/");
|
2655
|
+
const transformIndex = pathParts.findIndex((part) => part === "transform");
|
2656
|
+
const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
|
2657
|
+
const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
|
2658
|
+
const path = pathParts.join("/");
|
2659
|
+
return `https://${hostname}${transform}${path}${search}`;
|
2634
2660
|
}
|
2635
2661
|
|
2636
|
-
var __defProp$6 = Object.defineProperty;
|
2637
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2638
|
-
var __publicField$6 = (obj, key, value) => {
|
2639
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2640
|
-
return value;
|
2641
|
-
};
|
2642
2662
|
class XataFile {
|
2643
2663
|
constructor(file) {
|
2644
|
-
|
2645
|
-
|
2646
|
-
*/
|
2647
|
-
__publicField$6(this, "name");
|
2648
|
-
/**
|
2649
|
-
* Media type of this file.
|
2650
|
-
*/
|
2651
|
-
__publicField$6(this, "mediaType");
|
2652
|
-
/**
|
2653
|
-
* Base64 encoded content of this file.
|
2654
|
-
*/
|
2655
|
-
__publicField$6(this, "base64Content");
|
2656
|
-
/**
|
2657
|
-
* Whether to enable public url for this file.
|
2658
|
-
*/
|
2659
|
-
__publicField$6(this, "enablePublicUrl");
|
2660
|
-
/**
|
2661
|
-
* Timeout for the signed url.
|
2662
|
-
*/
|
2663
|
-
__publicField$6(this, "signedUrlTimeout");
|
2664
|
-
/**
|
2665
|
-
* Size of this file.
|
2666
|
-
*/
|
2667
|
-
__publicField$6(this, "size");
|
2668
|
-
/**
|
2669
|
-
* Version of this file.
|
2670
|
-
*/
|
2671
|
-
__publicField$6(this, "version");
|
2672
|
-
/**
|
2673
|
-
* Url of this file.
|
2674
|
-
*/
|
2675
|
-
__publicField$6(this, "url");
|
2676
|
-
/**
|
2677
|
-
* Signed url of this file.
|
2678
|
-
*/
|
2679
|
-
__publicField$6(this, "signedUrl");
|
2680
|
-
/**
|
2681
|
-
* Attributes of this file.
|
2682
|
-
*/
|
2683
|
-
__publicField$6(this, "attributes");
|
2684
|
-
this.name = file.name;
|
2664
|
+
this.id = file.id;
|
2665
|
+
this.name = file.name || "";
|
2685
2666
|
this.mediaType = file.mediaType || "application/octet-stream";
|
2686
2667
|
this.base64Content = file.base64Content;
|
2687
|
-
this.enablePublicUrl = file.enablePublicUrl;
|
2688
|
-
this.signedUrlTimeout = file.signedUrlTimeout;
|
2689
|
-
this.size = file.size;
|
2690
|
-
this.version = file.version;
|
2691
|
-
this.url = file.url;
|
2668
|
+
this.enablePublicUrl = file.enablePublicUrl ?? false;
|
2669
|
+
this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
|
2670
|
+
this.size = file.size ?? 0;
|
2671
|
+
this.version = file.version ?? 1;
|
2672
|
+
this.url = file.url || "";
|
2692
2673
|
this.signedUrl = file.signedUrl;
|
2693
|
-
this.attributes = file.attributes;
|
2674
|
+
this.attributes = file.attributes || {};
|
2694
2675
|
}
|
2695
|
-
static
|
2676
|
+
static fromBuffer(buffer, options = {}) {
|
2696
2677
|
const base64Content = buffer.toString("base64");
|
2697
2678
|
return new XataFile({ ...options, base64Content });
|
2698
2679
|
}
|
@@ -2702,9 +2683,9 @@ class XataFile {
|
|
2702
2683
|
}
|
2703
2684
|
return Buffer.from(this.base64Content, "base64");
|
2704
2685
|
}
|
2705
|
-
static
|
2686
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2706
2687
|
const uint8Array = new Uint8Array(arrayBuffer);
|
2707
|
-
return
|
2688
|
+
return this.fromUint8Array(uint8Array, options);
|
2708
2689
|
}
|
2709
2690
|
toArrayBuffer() {
|
2710
2691
|
if (!this.base64Content) {
|
@@ -2713,7 +2694,7 @@ class XataFile {
|
|
2713
2694
|
const binary = atob(this.base64Content);
|
2714
2695
|
return new ArrayBuffer(binary.length);
|
2715
2696
|
}
|
2716
|
-
static
|
2697
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2717
2698
|
let binary = "";
|
2718
2699
|
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2719
2700
|
binary += String.fromCharCode(uint8Array[i]);
|
@@ -2736,16 +2717,20 @@ class XataFile {
|
|
2736
2717
|
const name = options.name ?? file.name;
|
2737
2718
|
const mediaType = file.type;
|
2738
2719
|
const arrayBuffer = await file.arrayBuffer();
|
2739
|
-
return
|
2720
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2740
2721
|
}
|
2741
2722
|
toBlob() {
|
2742
2723
|
if (!this.base64Content) {
|
2743
2724
|
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2744
2725
|
}
|
2745
|
-
const
|
2746
|
-
|
2726
|
+
const binary = atob(this.base64Content);
|
2727
|
+
const uint8Array = new Uint8Array(binary.length);
|
2728
|
+
for (let i = 0; i < binary.length; i++) {
|
2729
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2730
|
+
}
|
2731
|
+
return new Blob([uint8Array], { type: this.mediaType });
|
2747
2732
|
}
|
2748
|
-
static
|
2733
|
+
static fromString(string, options = {}) {
|
2749
2734
|
const base64Content = btoa(string);
|
2750
2735
|
return new XataFile({ ...options, base64Content });
|
2751
2736
|
}
|
@@ -2755,7 +2740,7 @@ class XataFile {
|
|
2755
2740
|
}
|
2756
2741
|
return atob(this.base64Content);
|
2757
2742
|
}
|
2758
|
-
static
|
2743
|
+
static fromBase64(base64Content, options = {}) {
|
2759
2744
|
return new XataFile({ ...options, base64Content });
|
2760
2745
|
}
|
2761
2746
|
toBase64() {
|
@@ -2766,16 +2751,26 @@ class XataFile {
|
|
2766
2751
|
}
|
2767
2752
|
transform(...options) {
|
2768
2753
|
return {
|
2769
|
-
url: transformImage(this.url, options),
|
2770
|
-
signedUrl: transformImage(this.signedUrl, options)
|
2754
|
+
url: transformImage(this.url, ...options),
|
2755
|
+
signedUrl: transformImage(this.signedUrl, ...options),
|
2756
|
+
metadataUrl: transformImage(this.url, ...options, { format: "json" }),
|
2757
|
+
metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
|
2771
2758
|
};
|
2772
2759
|
}
|
2773
2760
|
}
|
2774
|
-
const parseInputFileEntry = (entry) => {
|
2761
|
+
const parseInputFileEntry = async (entry) => {
|
2775
2762
|
if (!isDefined(entry))
|
2776
2763
|
return null;
|
2777
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = entry;
|
2778
|
-
return compactObject({
|
2764
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2765
|
+
return compactObject({
|
2766
|
+
id,
|
2767
|
+
// Name cannot be an empty string in our API
|
2768
|
+
name: name ? name : void 0,
|
2769
|
+
mediaType,
|
2770
|
+
base64Content,
|
2771
|
+
enablePublicUrl,
|
2772
|
+
signedUrlTimeout
|
2773
|
+
});
|
2779
2774
|
};
|
2780
2775
|
|
2781
2776
|
function cleanFilter(filter) {
|
@@ -2805,12 +2800,25 @@ function cleanFilter(filter) {
|
|
2805
2800
|
return Object.keys(values).length > 0 ? values : void 0;
|
2806
2801
|
}
|
2807
2802
|
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2803
|
+
function stringifyJson(value) {
|
2804
|
+
if (!isDefined(value))
|
2805
|
+
return value;
|
2806
|
+
if (isString(value))
|
2807
|
+
return value;
|
2808
|
+
try {
|
2809
|
+
return JSON.stringify(value);
|
2810
|
+
} catch (e) {
|
2811
|
+
return value;
|
2812
|
+
}
|
2813
|
+
}
|
2814
|
+
function parseJson(value) {
|
2815
|
+
try {
|
2816
|
+
return JSON.parse(value);
|
2817
|
+
} catch (e) {
|
2818
|
+
return value;
|
2819
|
+
}
|
2820
|
+
}
|
2821
|
+
|
2814
2822
|
var __accessCheck$6 = (obj, member, msg) => {
|
2815
2823
|
if (!member.has(obj))
|
2816
2824
|
throw TypeError("Cannot " + msg);
|
@@ -2833,14 +2841,6 @@ var _query, _page;
|
|
2833
2841
|
class Page {
|
2834
2842
|
constructor(query, meta, records = []) {
|
2835
2843
|
__privateAdd$6(this, _query, void 0);
|
2836
|
-
/**
|
2837
|
-
* Page metadata, required to retrieve additional records.
|
2838
|
-
*/
|
2839
|
-
__publicField$5(this, "meta");
|
2840
|
-
/**
|
2841
|
-
* The set of results for this page.
|
2842
|
-
*/
|
2843
|
-
__publicField$5(this, "records");
|
2844
2844
|
__privateSet$6(this, _query, query);
|
2845
2845
|
this.meta = meta;
|
2846
2846
|
this.records = new RecordArray(this, records);
|
@@ -2890,9 +2890,9 @@ class Page {
|
|
2890
2890
|
}
|
2891
2891
|
}
|
2892
2892
|
_query = new WeakMap();
|
2893
|
-
const PAGINATION_MAX_SIZE =
|
2893
|
+
const PAGINATION_MAX_SIZE = 1e3;
|
2894
2894
|
const PAGINATION_DEFAULT_SIZE = 20;
|
2895
|
-
const PAGINATION_MAX_OFFSET =
|
2895
|
+
const PAGINATION_MAX_OFFSET = 49e3;
|
2896
2896
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
2897
2897
|
function isCursorPaginationOptions(options) {
|
2898
2898
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
@@ -2971,12 +2971,6 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2971
2971
|
_page = new WeakMap();
|
2972
2972
|
let RecordArray = _RecordArray;
|
2973
2973
|
|
2974
|
-
var __defProp$4 = Object.defineProperty;
|
2975
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2976
|
-
var __publicField$4 = (obj, key, value) => {
|
2977
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2978
|
-
return value;
|
2979
|
-
};
|
2980
2974
|
var __accessCheck$5 = (obj, member, msg) => {
|
2981
2975
|
if (!member.has(obj))
|
2982
2976
|
throw TypeError("Cannot " + msg);
|
@@ -3007,8 +3001,8 @@ const _Query = class _Query {
|
|
3007
3001
|
__privateAdd$5(this, _repository, void 0);
|
3008
3002
|
__privateAdd$5(this, _data, { filter: {} });
|
3009
3003
|
// Implements pagination
|
3010
|
-
|
3011
|
-
|
3004
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3005
|
+
this.records = new RecordArray(this, []);
|
3012
3006
|
__privateSet$5(this, _table$1, table);
|
3013
3007
|
if (repository) {
|
3014
3008
|
__privateSet$5(this, _repository, repository);
|
@@ -3263,7 +3257,8 @@ const RecordColumnTypes = [
|
|
3263
3257
|
"datetime",
|
3264
3258
|
"vector",
|
3265
3259
|
"file[]",
|
3266
|
-
"file"
|
3260
|
+
"file",
|
3261
|
+
"json"
|
3267
3262
|
];
|
3268
3263
|
function isIdentifiable(x) {
|
3269
3264
|
return isObject(x) && isString(x?.id);
|
@@ -3274,6 +3269,24 @@ function isXataRecord(x) {
|
|
3274
3269
|
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
3275
3270
|
}
|
3276
3271
|
|
3272
|
+
function isValidExpandedColumn(column) {
|
3273
|
+
return isObject(column) && isString(column.name);
|
3274
|
+
}
|
3275
|
+
function isValidSelectableColumns(columns) {
|
3276
|
+
if (!Array.isArray(columns)) {
|
3277
|
+
return false;
|
3278
|
+
}
|
3279
|
+
return columns.every((column) => {
|
3280
|
+
if (typeof column === "string") {
|
3281
|
+
return true;
|
3282
|
+
}
|
3283
|
+
if (typeof column === "object") {
|
3284
|
+
return isValidExpandedColumn(column);
|
3285
|
+
}
|
3286
|
+
return false;
|
3287
|
+
});
|
3288
|
+
}
|
3289
|
+
|
3277
3290
|
function isSortFilterString(value) {
|
3278
3291
|
return isString(value);
|
3279
3292
|
}
|
@@ -3374,24 +3387,24 @@ class RestRepository extends Query {
|
|
3374
3387
|
if (a.length === 0)
|
3375
3388
|
return [];
|
3376
3389
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
3377
|
-
const columns =
|
3390
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3378
3391
|
const result = await this.read(ids, columns);
|
3379
3392
|
return result;
|
3380
3393
|
}
|
3381
3394
|
if (isString(a) && isObject(b)) {
|
3382
3395
|
if (a === "")
|
3383
3396
|
throw new Error("The id can't be empty");
|
3384
|
-
const columns =
|
3397
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3385
3398
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
3386
3399
|
}
|
3387
3400
|
if (isObject(a) && isString(a.id)) {
|
3388
3401
|
if (a.id === "")
|
3389
3402
|
throw new Error("The id can't be empty");
|
3390
|
-
const columns =
|
3403
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3391
3404
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
3392
3405
|
}
|
3393
3406
|
if (isObject(a)) {
|
3394
|
-
const columns =
|
3407
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3395
3408
|
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
3396
3409
|
}
|
3397
3410
|
throw new Error("Invalid arguments for create method");
|
@@ -3399,7 +3412,7 @@ class RestRepository extends Query {
|
|
3399
3412
|
}
|
3400
3413
|
async read(a, b) {
|
3401
3414
|
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
3402
|
-
const columns =
|
3415
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3403
3416
|
if (Array.isArray(a)) {
|
3404
3417
|
if (a.length === 0)
|
3405
3418
|
return [];
|
@@ -3426,7 +3439,13 @@ class RestRepository extends Query {
|
|
3426
3439
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3427
3440
|
});
|
3428
3441
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3429
|
-
return initObject(
|
3442
|
+
return initObject(
|
3443
|
+
__privateGet$4(this, _db),
|
3444
|
+
schemaTables,
|
3445
|
+
__privateGet$4(this, _table),
|
3446
|
+
response,
|
3447
|
+
columns
|
3448
|
+
);
|
3430
3449
|
} catch (e) {
|
3431
3450
|
if (isObject(e) && e.status === 404) {
|
3432
3451
|
return null;
|
@@ -3468,17 +3487,17 @@ class RestRepository extends Query {
|
|
3468
3487
|
ifVersion,
|
3469
3488
|
upsert: false
|
3470
3489
|
});
|
3471
|
-
const columns =
|
3490
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3472
3491
|
const result = await this.read(a, columns);
|
3473
3492
|
return result;
|
3474
3493
|
}
|
3475
3494
|
try {
|
3476
3495
|
if (isString(a) && isObject(b)) {
|
3477
|
-
const columns =
|
3496
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3478
3497
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3479
3498
|
}
|
3480
3499
|
if (isObject(a) && isString(a.id)) {
|
3481
|
-
const columns =
|
3500
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3482
3501
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3483
3502
|
}
|
3484
3503
|
} catch (error) {
|
@@ -3518,20 +3537,20 @@ class RestRepository extends Query {
|
|
3518
3537
|
ifVersion,
|
3519
3538
|
upsert: true
|
3520
3539
|
});
|
3521
|
-
const columns =
|
3540
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3522
3541
|
const result = await this.read(a, columns);
|
3523
3542
|
return result;
|
3524
3543
|
}
|
3525
3544
|
if (isString(a) && isObject(b)) {
|
3526
3545
|
if (a === "")
|
3527
3546
|
throw new Error("The id can't be empty");
|
3528
|
-
const columns =
|
3547
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3529
3548
|
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3530
3549
|
}
|
3531
3550
|
if (isObject(a) && isString(a.id)) {
|
3532
3551
|
if (a.id === "")
|
3533
3552
|
throw new Error("The id can't be empty");
|
3534
|
-
const columns =
|
3553
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3535
3554
|
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3536
3555
|
}
|
3537
3556
|
if (!isDefined(a) && isObject(b)) {
|
@@ -3550,20 +3569,20 @@ class RestRepository extends Query {
|
|
3550
3569
|
if (a.length === 0)
|
3551
3570
|
return [];
|
3552
3571
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
3553
|
-
const columns =
|
3572
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3554
3573
|
const result = await this.read(ids, columns);
|
3555
3574
|
return result;
|
3556
3575
|
}
|
3557
3576
|
if (isString(a) && isObject(b)) {
|
3558
3577
|
if (a === "")
|
3559
3578
|
throw new Error("The id can't be empty");
|
3560
|
-
const columns =
|
3579
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3561
3580
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3562
3581
|
}
|
3563
3582
|
if (isObject(a) && isString(a.id)) {
|
3564
3583
|
if (a.id === "")
|
3565
3584
|
throw new Error("The id can't be empty");
|
3566
|
-
const columns =
|
3585
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3567
3586
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3568
3587
|
}
|
3569
3588
|
if (!isDefined(a) && isObject(b)) {
|
@@ -3587,7 +3606,7 @@ class RestRepository extends Query {
|
|
3587
3606
|
return o.id;
|
3588
3607
|
throw new Error("Invalid arguments for delete method");
|
3589
3608
|
});
|
3590
|
-
const columns =
|
3609
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3591
3610
|
const result = await this.read(a, columns);
|
3592
3611
|
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
3593
3612
|
return result;
|
@@ -3621,7 +3640,7 @@ class RestRepository extends Query {
|
|
3621
3640
|
}
|
3622
3641
|
async search(query, options = {}) {
|
3623
3642
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
3624
|
-
const { records } = await searchTable({
|
3643
|
+
const { records, totalCount } = await searchTable({
|
3625
3644
|
pathParams: {
|
3626
3645
|
workspace: "{workspaceId}",
|
3627
3646
|
dbBranchName: "{dbBranch}",
|
@@ -3641,12 +3660,15 @@ class RestRepository extends Query {
|
|
3641
3660
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3642
3661
|
});
|
3643
3662
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3644
|
-
return
|
3663
|
+
return {
|
3664
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3665
|
+
totalCount
|
3666
|
+
};
|
3645
3667
|
});
|
3646
3668
|
}
|
3647
3669
|
async vectorSearch(column, query, options) {
|
3648
3670
|
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3649
|
-
const { records } = await vectorSearchTable({
|
3671
|
+
const { records, totalCount } = await vectorSearchTable({
|
3650
3672
|
pathParams: {
|
3651
3673
|
workspace: "{workspaceId}",
|
3652
3674
|
dbBranchName: "{dbBranch}",
|
@@ -3663,7 +3685,10 @@ class RestRepository extends Query {
|
|
3663
3685
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3664
3686
|
});
|
3665
3687
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3666
|
-
return
|
3688
|
+
return {
|
3689
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3690
|
+
totalCount
|
3691
|
+
};
|
3667
3692
|
});
|
3668
3693
|
}
|
3669
3694
|
async aggregate(aggs, filter) {
|
@@ -3706,7 +3731,13 @@ class RestRepository extends Query {
|
|
3706
3731
|
});
|
3707
3732
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3708
3733
|
const records = objects.map(
|
3709
|
-
(record) => initObject(
|
3734
|
+
(record) => initObject(
|
3735
|
+
__privateGet$4(this, _db),
|
3736
|
+
schemaTables,
|
3737
|
+
__privateGet$4(this, _table),
|
3738
|
+
record,
|
3739
|
+
data.columns ?? ["*"]
|
3740
|
+
)
|
3710
3741
|
);
|
3711
3742
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
3712
3743
|
return new Page(query, meta, records);
|
@@ -3733,27 +3764,38 @@ class RestRepository extends Query {
|
|
3733
3764
|
},
|
3734
3765
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3735
3766
|
});
|
3736
|
-
|
3767
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3768
|
+
return {
|
3769
|
+
...result,
|
3770
|
+
summaries: result.summaries.map(
|
3771
|
+
(summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
|
3772
|
+
)
|
3773
|
+
};
|
3737
3774
|
});
|
3738
3775
|
}
|
3739
3776
|
ask(question, options) {
|
3777
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3740
3778
|
const params = {
|
3741
3779
|
pathParams: {
|
3742
3780
|
workspace: "{workspaceId}",
|
3743
3781
|
dbBranchName: "{dbBranch}",
|
3744
3782
|
region: "{region}",
|
3745
|
-
tableName: __privateGet$4(this, _table)
|
3783
|
+
tableName: __privateGet$4(this, _table),
|
3784
|
+
sessionId: options?.sessionId
|
3746
3785
|
},
|
3747
3786
|
body: {
|
3748
|
-
|
3749
|
-
|
3787
|
+
...questionParam,
|
3788
|
+
rules: options?.rules,
|
3789
|
+
searchType: options?.searchType,
|
3790
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3791
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3750
3792
|
},
|
3751
3793
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3752
3794
|
};
|
3753
3795
|
if (options?.onMessage) {
|
3754
3796
|
fetchSSERequest({
|
3755
3797
|
endpoint: "dataPlane",
|
3756
|
-
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3798
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3757
3799
|
method: "POST",
|
3758
3800
|
onMessage: (message) => {
|
3759
3801
|
options.onMessage?.({ answer: message.text, records: message.records });
|
@@ -3761,7 +3803,7 @@ class RestRepository extends Query {
|
|
3761
3803
|
...params
|
3762
3804
|
});
|
3763
3805
|
} else {
|
3764
|
-
return
|
3806
|
+
return askTableSession(params);
|
3765
3807
|
}
|
3766
3808
|
}
|
3767
3809
|
}
|
@@ -4002,10 +4044,13 @@ transformObjectToApi_fn = async function(object) {
|
|
4002
4044
|
break;
|
4003
4045
|
}
|
4004
4046
|
case `file`:
|
4005
|
-
result[key] = parseInputFileEntry(value);
|
4047
|
+
result[key] = await parseInputFileEntry(value);
|
4006
4048
|
break;
|
4007
4049
|
case "file[]":
|
4008
|
-
result[key] = value
|
4050
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4051
|
+
break;
|
4052
|
+
case "json":
|
4053
|
+
result[key] = stringifyJson(value);
|
4009
4054
|
break;
|
4010
4055
|
default:
|
4011
4056
|
result[key] = value;
|
@@ -4013,13 +4058,6 @@ transformObjectToApi_fn = async function(object) {
|
|
4013
4058
|
}
|
4014
4059
|
return result;
|
4015
4060
|
};
|
4016
|
-
const removeLinksFromObject = (object) => {
|
4017
|
-
return Object.entries(object).reduce((acc, [key, value]) => {
|
4018
|
-
if (key === "xata")
|
4019
|
-
return acc;
|
4020
|
-
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
4021
|
-
}, {});
|
4022
|
-
};
|
4023
4061
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
4024
4062
|
const data = {};
|
4025
4063
|
const { xata, ...rest } = object ?? {};
|
@@ -4050,13 +4088,19 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4050
4088
|
if (item === column.name) {
|
4051
4089
|
return [...acc, "*"];
|
4052
4090
|
}
|
4053
|
-
if (item.startsWith(`${column.name}.`)) {
|
4091
|
+
if (isString(item) && item.startsWith(`${column.name}.`)) {
|
4054
4092
|
const [, ...path] = item.split(".");
|
4055
4093
|
return [...acc, path.join(".")];
|
4056
4094
|
}
|
4057
4095
|
return acc;
|
4058
4096
|
}, []);
|
4059
|
-
data[column.name] = initObject(
|
4097
|
+
data[column.name] = initObject(
|
4098
|
+
db,
|
4099
|
+
schemaTables,
|
4100
|
+
linkTable,
|
4101
|
+
value,
|
4102
|
+
selectedLinkColumns
|
4103
|
+
);
|
4060
4104
|
} else {
|
4061
4105
|
data[column.name] = null;
|
4062
4106
|
}
|
@@ -4068,6 +4112,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4068
4112
|
case "file[]":
|
4069
4113
|
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4070
4114
|
break;
|
4115
|
+
case "json":
|
4116
|
+
data[column.name] = parseJson(value);
|
4117
|
+
break;
|
4071
4118
|
default:
|
4072
4119
|
data[column.name] = value ?? null;
|
4073
4120
|
if (column.notNull === true && value === null) {
|
@@ -4077,33 +4124,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4077
4124
|
}
|
4078
4125
|
}
|
4079
4126
|
const record = { ...data };
|
4080
|
-
const serializable = { xata, ...removeLinksFromObject(data) };
|
4081
4127
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
4082
4128
|
record.read = function(columns2) {
|
4083
4129
|
return db[table].read(record["id"], columns2);
|
4084
4130
|
};
|
4085
4131
|
record.update = function(data2, b, c) {
|
4086
|
-
const columns2 =
|
4132
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
4087
4133
|
const ifVersion = parseIfVersion(b, c);
|
4088
4134
|
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
4089
4135
|
};
|
4090
4136
|
record.replace = function(data2, b, c) {
|
4091
|
-
const columns2 =
|
4137
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
4092
4138
|
const ifVersion = parseIfVersion(b, c);
|
4093
4139
|
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
4094
4140
|
};
|
4095
4141
|
record.delete = function() {
|
4096
4142
|
return db[table].delete(record["id"]);
|
4097
4143
|
};
|
4098
|
-
|
4144
|
+
if (metadata !== void 0) {
|
4145
|
+
record.xata = Object.freeze(metadata);
|
4146
|
+
}
|
4099
4147
|
record.getMetadata = function() {
|
4100
4148
|
return record.xata;
|
4101
4149
|
};
|
4102
4150
|
record.toSerializable = function() {
|
4103
|
-
return JSON.parse(JSON.stringify(
|
4151
|
+
return JSON.parse(JSON.stringify(record));
|
4104
4152
|
};
|
4105
4153
|
record.toString = function() {
|
4106
|
-
return JSON.stringify(
|
4154
|
+
return JSON.stringify(record);
|
4107
4155
|
};
|
4108
4156
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
4109
4157
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -4121,7 +4169,7 @@ function extractId(value) {
|
|
4121
4169
|
function isValidColumn(columns, column) {
|
4122
4170
|
if (columns.includes("*"))
|
4123
4171
|
return true;
|
4124
|
-
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
4172
|
+
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
4125
4173
|
}
|
4126
4174
|
function parseIfVersion(...args) {
|
4127
4175
|
for (const arg of args) {
|
@@ -4132,12 +4180,6 @@ function parseIfVersion(...args) {
|
|
4132
4180
|
return void 0;
|
4133
4181
|
}
|
4134
4182
|
|
4135
|
-
var __defProp$3 = Object.defineProperty;
|
4136
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4137
|
-
var __publicField$3 = (obj, key, value) => {
|
4138
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4139
|
-
return value;
|
4140
|
-
};
|
4141
4183
|
var __accessCheck$3 = (obj, member, msg) => {
|
4142
4184
|
if (!member.has(obj))
|
4143
4185
|
throw TypeError("Cannot " + msg);
|
@@ -4160,8 +4202,6 @@ var _map;
|
|
4160
4202
|
class SimpleCache {
|
4161
4203
|
constructor(options = {}) {
|
4162
4204
|
__privateAdd$3(this, _map, void 0);
|
4163
|
-
__publicField$3(this, "capacity");
|
4164
|
-
__publicField$3(this, "defaultQueryTTL");
|
4165
4205
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
4166
4206
|
this.capacity = options.max ?? 500;
|
4167
4207
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -4206,10 +4246,12 @@ const notExists = (column) => ({ $notExists: column });
|
|
4206
4246
|
const startsWith = (value) => ({ $startsWith: value });
|
4207
4247
|
const endsWith = (value) => ({ $endsWith: value });
|
4208
4248
|
const pattern = (value) => ({ $pattern: value });
|
4249
|
+
const iPattern = (value) => ({ $iPattern: value });
|
4209
4250
|
const is = (value) => ({ $is: value });
|
4210
4251
|
const equals = is;
|
4211
4252
|
const isNot = (value) => ({ $isNot: value });
|
4212
4253
|
const contains = (value) => ({ $contains: value });
|
4254
|
+
const iContains = (value) => ({ $iContains: value });
|
4213
4255
|
const includes = (value) => ({ $includes: value });
|
4214
4256
|
const includesAll = (value) => ({ $includesAll: value });
|
4215
4257
|
const includesNone = (value) => ({ $includesNone: value });
|
@@ -4265,6 +4307,80 @@ class SchemaPlugin extends XataPlugin {
|
|
4265
4307
|
_tables = new WeakMap();
|
4266
4308
|
_schemaTables$1 = new WeakMap();
|
4267
4309
|
|
4310
|
+
class FilesPlugin extends XataPlugin {
|
4311
|
+
build(pluginOptions) {
|
4312
|
+
return {
|
4313
|
+
download: async (location) => {
|
4314
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4315
|
+
return await getFileItem({
|
4316
|
+
pathParams: {
|
4317
|
+
workspace: "{workspaceId}",
|
4318
|
+
dbBranchName: "{dbBranch}",
|
4319
|
+
region: "{region}",
|
4320
|
+
tableName: table ?? "",
|
4321
|
+
recordId: record ?? "",
|
4322
|
+
columnName: column ?? "",
|
4323
|
+
fileId
|
4324
|
+
},
|
4325
|
+
...pluginOptions,
|
4326
|
+
rawResponse: true
|
4327
|
+
});
|
4328
|
+
},
|
4329
|
+
upload: async (location, file, options) => {
|
4330
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4331
|
+
const resolvedFile = await file;
|
4332
|
+
const contentType = options?.mediaType || getContentType(resolvedFile);
|
4333
|
+
const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
|
4334
|
+
return await putFileItem({
|
4335
|
+
...pluginOptions,
|
4336
|
+
pathParams: {
|
4337
|
+
workspace: "{workspaceId}",
|
4338
|
+
dbBranchName: "{dbBranch}",
|
4339
|
+
region: "{region}",
|
4340
|
+
tableName: table ?? "",
|
4341
|
+
recordId: record ?? "",
|
4342
|
+
columnName: column ?? "",
|
4343
|
+
fileId
|
4344
|
+
},
|
4345
|
+
body,
|
4346
|
+
headers: { "Content-Type": contentType }
|
4347
|
+
});
|
4348
|
+
},
|
4349
|
+
delete: async (location) => {
|
4350
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4351
|
+
return await deleteFileItem({
|
4352
|
+
pathParams: {
|
4353
|
+
workspace: "{workspaceId}",
|
4354
|
+
dbBranchName: "{dbBranch}",
|
4355
|
+
region: "{region}",
|
4356
|
+
tableName: table ?? "",
|
4357
|
+
recordId: record ?? "",
|
4358
|
+
columnName: column ?? "",
|
4359
|
+
fileId
|
4360
|
+
},
|
4361
|
+
...pluginOptions
|
4362
|
+
});
|
4363
|
+
}
|
4364
|
+
};
|
4365
|
+
}
|
4366
|
+
}
|
4367
|
+
function getContentType(file) {
|
4368
|
+
if (typeof file === "string") {
|
4369
|
+
return "text/plain";
|
4370
|
+
}
|
4371
|
+
if ("mediaType" in file) {
|
4372
|
+
return file.mediaType;
|
4373
|
+
}
|
4374
|
+
if (isBlob(file)) {
|
4375
|
+
return file.type;
|
4376
|
+
}
|
4377
|
+
try {
|
4378
|
+
return file.type;
|
4379
|
+
} catch (e) {
|
4380
|
+
}
|
4381
|
+
return "application/octet-stream";
|
4382
|
+
}
|
4383
|
+
|
4268
4384
|
var __accessCheck$1 = (obj, member, msg) => {
|
4269
4385
|
if (!member.has(obj))
|
4270
4386
|
throw TypeError("Cannot " + msg);
|
@@ -4300,22 +4416,26 @@ class SearchPlugin extends XataPlugin {
|
|
4300
4416
|
build(pluginOptions) {
|
4301
4417
|
return {
|
4302
4418
|
all: async (query, options = {}) => {
|
4303
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4419
|
+
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4304
4420
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4305
|
-
return
|
4306
|
-
|
4307
|
-
|
4308
|
-
|
4421
|
+
return {
|
4422
|
+
totalCount,
|
4423
|
+
records: records.map((record) => {
|
4424
|
+
const { table = "orphan" } = record.xata;
|
4425
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
4426
|
+
})
|
4427
|
+
};
|
4309
4428
|
},
|
4310
4429
|
byTable: async (query, options = {}) => {
|
4311
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4430
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4312
4431
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4313
|
-
|
4432
|
+
const records = rawRecords.reduce((acc, record) => {
|
4314
4433
|
const { table = "orphan" } = record.xata;
|
4315
4434
|
const items = acc[table] ?? [];
|
4316
4435
|
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
4317
4436
|
return { ...acc, [table]: [...items, item] };
|
4318
4437
|
}, {});
|
4438
|
+
return { totalCount, records };
|
4319
4439
|
}
|
4320
4440
|
};
|
4321
4441
|
}
|
@@ -4324,13 +4444,13 @@ _schemaTables = new WeakMap();
|
|
4324
4444
|
_search = new WeakSet();
|
4325
4445
|
search_fn = async function(query, options, pluginOptions) {
|
4326
4446
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4327
|
-
const { records } = await searchBranch({
|
4447
|
+
const { records, totalCount } = await searchBranch({
|
4328
4448
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4329
4449
|
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
4330
4450
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4331
4451
|
...pluginOptions
|
4332
4452
|
});
|
4333
|
-
return records;
|
4453
|
+
return { records, totalCount };
|
4334
4454
|
};
|
4335
4455
|
_getSchemaTables = new WeakSet();
|
4336
4456
|
getSchemaTables_fn = async function(pluginOptions) {
|
@@ -4344,6 +4464,78 @@ getSchemaTables_fn = async function(pluginOptions) {
|
|
4344
4464
|
return schema.tables;
|
4345
4465
|
};
|
4346
4466
|
|
4467
|
+
function escapeElement(elementRepresentation) {
|
4468
|
+
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
4469
|
+
return '"' + escaped + '"';
|
4470
|
+
}
|
4471
|
+
function arrayString(val) {
|
4472
|
+
let result = "{";
|
4473
|
+
for (let i = 0; i < val.length; i++) {
|
4474
|
+
if (i > 0) {
|
4475
|
+
result = result + ",";
|
4476
|
+
}
|
4477
|
+
if (val[i] === null || typeof val[i] === "undefined") {
|
4478
|
+
result = result + "NULL";
|
4479
|
+
} else if (Array.isArray(val[i])) {
|
4480
|
+
result = result + arrayString(val[i]);
|
4481
|
+
} else if (val[i] instanceof Buffer) {
|
4482
|
+
result += "\\\\x" + val[i].toString("hex");
|
4483
|
+
} else {
|
4484
|
+
result += escapeElement(prepareValue(val[i]));
|
4485
|
+
}
|
4486
|
+
}
|
4487
|
+
result = result + "}";
|
4488
|
+
return result;
|
4489
|
+
}
|
4490
|
+
function prepareValue(value) {
|
4491
|
+
if (!isDefined(value))
|
4492
|
+
return null;
|
4493
|
+
if (value instanceof Date) {
|
4494
|
+
return value.toISOString();
|
4495
|
+
}
|
4496
|
+
if (Array.isArray(value)) {
|
4497
|
+
return arrayString(value);
|
4498
|
+
}
|
4499
|
+
if (isObject(value)) {
|
4500
|
+
return JSON.stringify(value);
|
4501
|
+
}
|
4502
|
+
try {
|
4503
|
+
return value.toString();
|
4504
|
+
} catch (e) {
|
4505
|
+
return value;
|
4506
|
+
}
|
4507
|
+
}
|
4508
|
+
function prepareParams(param1, param2) {
|
4509
|
+
if (isString(param1)) {
|
4510
|
+
return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
|
4511
|
+
}
|
4512
|
+
if (isStringArray(param1)) {
|
4513
|
+
const statement = param1.reduce((acc, curr, index) => {
|
4514
|
+
return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
|
4515
|
+
}, "");
|
4516
|
+
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
4517
|
+
}
|
4518
|
+
if (isObject(param1)) {
|
4519
|
+
const { statement, params, consistency } = param1;
|
4520
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
4521
|
+
}
|
4522
|
+
throw new Error("Invalid query");
|
4523
|
+
}
|
4524
|
+
|
4525
|
+
class SQLPlugin extends XataPlugin {
|
4526
|
+
build(pluginOptions) {
|
4527
|
+
return async (param1, ...param2) => {
|
4528
|
+
const { statement, params, consistency } = prepareParams(param1, param2);
|
4529
|
+
const { records, warning } = await sqlQuery({
|
4530
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4531
|
+
body: { statement, params, consistency },
|
4532
|
+
...pluginOptions
|
4533
|
+
});
|
4534
|
+
return { records, warning };
|
4535
|
+
};
|
4536
|
+
}
|
4537
|
+
}
|
4538
|
+
|
4347
4539
|
class TransactionPlugin extends XataPlugin {
|
4348
4540
|
build(pluginOptions) {
|
4349
4541
|
return {
|
@@ -4359,12 +4551,6 @@ class TransactionPlugin extends XataPlugin {
|
|
4359
4551
|
}
|
4360
4552
|
}
|
4361
4553
|
|
4362
|
-
var __defProp$2 = Object.defineProperty;
|
4363
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4364
|
-
var __publicField$2 = (obj, key, value) => {
|
4365
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4366
|
-
return value;
|
4367
|
-
};
|
4368
4554
|
var __accessCheck = (obj, member, msg) => {
|
4369
4555
|
if (!member.has(obj))
|
4370
4556
|
throw TypeError("Cannot " + msg);
|
@@ -4394,10 +4580,6 @@ const buildClient = (plugins) => {
|
|
4394
4580
|
__privateAdd(this, _parseOptions);
|
4395
4581
|
__privateAdd(this, _getFetchProps);
|
4396
4582
|
__privateAdd(this, _options, void 0);
|
4397
|
-
__publicField$2(this, "db");
|
4398
|
-
__publicField$2(this, "search");
|
4399
|
-
__publicField$2(this, "transactions");
|
4400
|
-
__publicField$2(this, "files");
|
4401
4583
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4402
4584
|
__privateSet(this, _options, safeOptions);
|
4403
4585
|
const pluginOptions = {
|
@@ -4408,10 +4590,12 @@ const buildClient = (plugins) => {
|
|
4408
4590
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
4409
4591
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
4410
4592
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4593
|
+
const sql = new SQLPlugin().build(pluginOptions);
|
4411
4594
|
const files = new FilesPlugin().build(pluginOptions);
|
4412
4595
|
this.db = db;
|
4413
4596
|
this.search = search;
|
4414
4597
|
this.transactions = transactions;
|
4598
|
+
this.sql = sql;
|
4415
4599
|
this.files = files;
|
4416
4600
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
4417
4601
|
if (namespace === void 0)
|
@@ -4509,17 +4693,11 @@ const buildClient = (plugins) => {
|
|
4509
4693
|
class BaseClient extends buildClient() {
|
4510
4694
|
}
|
4511
4695
|
|
4512
|
-
var __defProp$1 = Object.defineProperty;
|
4513
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4514
|
-
var __publicField$1 = (obj, key, value) => {
|
4515
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4516
|
-
return value;
|
4517
|
-
};
|
4518
4696
|
const META = "__";
|
4519
4697
|
const VALUE = "___";
|
4520
4698
|
class Serializer {
|
4521
4699
|
constructor() {
|
4522
|
-
|
4700
|
+
this.classes = {};
|
4523
4701
|
}
|
4524
4702
|
add(clazz) {
|
4525
4703
|
this.classes[clazz.name] = clazz;
|
@@ -4597,19 +4775,12 @@ function buildWorkerRunner(config) {
|
|
4597
4775
|
};
|
4598
4776
|
}
|
4599
4777
|
|
4600
|
-
var __defProp = Object.defineProperty;
|
4601
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4602
|
-
var __publicField = (obj, key, value) => {
|
4603
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4604
|
-
return value;
|
4605
|
-
};
|
4606
4778
|
class XataError extends Error {
|
4607
4779
|
constructor(message, status) {
|
4608
4780
|
super(message);
|
4609
|
-
__publicField(this, "status");
|
4610
4781
|
this.status = status;
|
4611
4782
|
}
|
4612
4783
|
}
|
4613
4784
|
|
4614
|
-
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite,
|
4785
|
+
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4615
4786
|
//# sourceMappingURL=index.mjs.map
|