@xata.io/client 0.0.0-alpha.vfdc5c07 → 0.0.0-alpha.vfdd84a8886de0780cc9d446ebf507207840c325b
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 +4 -4
- package/CHANGELOG.md +64 -2
- package/dist/index.cjs +420 -364
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3047 -2748
- package/dist/index.mjs +416 -364
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -248,7 +248,7 @@ var __accessCheck$8 = (obj, member, msg) => {
|
|
248
248
|
if (!member.has(obj))
|
249
249
|
throw TypeError("Cannot " + msg);
|
250
250
|
};
|
251
|
-
var __privateGet$
|
251
|
+
var __privateGet$7 = (obj, member, getter) => {
|
252
252
|
__accessCheck$8(obj, member, "read from private field");
|
253
253
|
return getter ? getter.call(obj) : member.get(obj);
|
254
254
|
};
|
@@ -257,7 +257,7 @@ var __privateAdd$8 = (obj, member, value) => {
|
|
257
257
|
throw TypeError("Cannot add the same private member more than once");
|
258
258
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
259
259
|
};
|
260
|
-
var __privateSet$
|
260
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
261
261
|
__accessCheck$8(obj, member, "write to private field");
|
262
262
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
263
263
|
return value;
|
@@ -283,19 +283,19 @@ class ApiRequestPool {
|
|
283
283
|
__privateAdd$8(this, _fetch, void 0);
|
284
284
|
__privateAdd$8(this, _queue, void 0);
|
285
285
|
__privateAdd$8(this, _concurrency, void 0);
|
286
|
-
__privateSet$
|
287
|
-
__privateSet$
|
286
|
+
__privateSet$6(this, _queue, []);
|
287
|
+
__privateSet$6(this, _concurrency, concurrency);
|
288
288
|
this.running = 0;
|
289
289
|
this.started = 0;
|
290
290
|
}
|
291
291
|
setFetch(fetch2) {
|
292
|
-
__privateSet$
|
292
|
+
__privateSet$6(this, _fetch, fetch2);
|
293
293
|
}
|
294
294
|
getFetch() {
|
295
|
-
if (!__privateGet$
|
295
|
+
if (!__privateGet$7(this, _fetch)) {
|
296
296
|
throw new Error("Fetch not set");
|
297
297
|
}
|
298
|
-
return __privateGet$
|
298
|
+
return __privateGet$7(this, _fetch);
|
299
299
|
}
|
300
300
|
request(url, options) {
|
301
301
|
const start = /* @__PURE__ */ new Date();
|
@@ -327,19 +327,19 @@ _queue = new WeakMap();
|
|
327
327
|
_concurrency = new WeakMap();
|
328
328
|
_enqueue = new WeakSet();
|
329
329
|
enqueue_fn = function(task) {
|
330
|
-
const promise = new Promise((resolve) => __privateGet$
|
330
|
+
const promise = new Promise((resolve) => __privateGet$7(this, _queue).push(resolve)).finally(() => {
|
331
331
|
this.started--;
|
332
332
|
this.running++;
|
333
333
|
}).then(() => task()).finally(() => {
|
334
334
|
this.running--;
|
335
|
-
const next = __privateGet$
|
335
|
+
const next = __privateGet$7(this, _queue).shift();
|
336
336
|
if (next !== void 0) {
|
337
337
|
this.started++;
|
338
338
|
next();
|
339
339
|
}
|
340
340
|
});
|
341
|
-
if (this.running + this.started < __privateGet$
|
342
|
-
const next = __privateGet$
|
341
|
+
if (this.running + this.started < __privateGet$7(this, _concurrency)) {
|
342
|
+
const next = __privateGet$7(this, _queue).shift();
|
343
343
|
if (next !== void 0) {
|
344
344
|
this.started++;
|
345
345
|
next();
|
@@ -528,7 +528,7 @@ function defaultOnOpen(response) {
|
|
528
528
|
}
|
529
529
|
}
|
530
530
|
|
531
|
-
const VERSION = "0.
|
531
|
+
const VERSION = "0.29.0";
|
532
532
|
|
533
533
|
class ErrorWithCause extends Error {
|
534
534
|
constructor(message, options) {
|
@@ -571,6 +571,67 @@ function getMessage(data) {
|
|
571
571
|
}
|
572
572
|
}
|
573
573
|
|
574
|
+
function getHostUrl(provider, type) {
|
575
|
+
if (isHostProviderAlias(provider)) {
|
576
|
+
return providers[provider][type];
|
577
|
+
} else if (isHostProviderBuilder(provider)) {
|
578
|
+
return provider[type];
|
579
|
+
}
|
580
|
+
throw new Error("Invalid API provider");
|
581
|
+
}
|
582
|
+
const providers = {
|
583
|
+
production: {
|
584
|
+
main: "https://api.xata.io",
|
585
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
586
|
+
},
|
587
|
+
staging: {
|
588
|
+
main: "https://api.staging-xata.dev",
|
589
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
590
|
+
},
|
591
|
+
dev: {
|
592
|
+
main: "https://api.dev-xata.dev",
|
593
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
594
|
+
},
|
595
|
+
local: {
|
596
|
+
main: "http://localhost:6001",
|
597
|
+
workspaces: "http://{workspaceId}.{region}.localhost:6001"
|
598
|
+
}
|
599
|
+
};
|
600
|
+
function isHostProviderAlias(alias) {
|
601
|
+
return isString(alias) && Object.keys(providers).includes(alias);
|
602
|
+
}
|
603
|
+
function isHostProviderBuilder(builder) {
|
604
|
+
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
605
|
+
}
|
606
|
+
function parseProviderString(provider = "production") {
|
607
|
+
if (isHostProviderAlias(provider)) {
|
608
|
+
return provider;
|
609
|
+
}
|
610
|
+
const [main, workspaces] = provider.split(",");
|
611
|
+
if (!main || !workspaces)
|
612
|
+
return null;
|
613
|
+
return { main, workspaces };
|
614
|
+
}
|
615
|
+
function buildProviderString(provider) {
|
616
|
+
if (isHostProviderAlias(provider))
|
617
|
+
return provider;
|
618
|
+
return `${provider.main},${provider.workspaces}`;
|
619
|
+
}
|
620
|
+
function parseWorkspacesUrlParts(url) {
|
621
|
+
if (!isString(url))
|
622
|
+
return null;
|
623
|
+
const matches = {
|
624
|
+
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/),
|
625
|
+
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/),
|
626
|
+
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/),
|
627
|
+
local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(\d+)/)
|
628
|
+
};
|
629
|
+
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
630
|
+
if (!isHostProviderAlias(host) || !match)
|
631
|
+
return null;
|
632
|
+
return { workspace: match[1], region: match[2], host };
|
633
|
+
}
|
634
|
+
|
574
635
|
const pool = new ApiRequestPool();
|
575
636
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
576
637
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -586,6 +647,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
586
647
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
587
648
|
};
|
588
649
|
function buildBaseUrl({
|
650
|
+
method,
|
589
651
|
endpoint,
|
590
652
|
path,
|
591
653
|
workspacesApiUrl,
|
@@ -593,7 +655,24 @@ function buildBaseUrl({
|
|
593
655
|
pathParams = {}
|
594
656
|
}) {
|
595
657
|
if (endpoint === "dataPlane") {
|
596
|
-
|
658
|
+
let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
659
|
+
if (method.toUpperCase() === "PUT" && [
|
660
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
661
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
|
662
|
+
].includes(path)) {
|
663
|
+
const { host } = parseWorkspacesUrlParts(url) ?? {};
|
664
|
+
switch (host) {
|
665
|
+
case "production":
|
666
|
+
url = url.replace("xata.sh", "upload.xata.sh");
|
667
|
+
break;
|
668
|
+
case "staging":
|
669
|
+
url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
|
670
|
+
break;
|
671
|
+
case "dev":
|
672
|
+
url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
|
673
|
+
break;
|
674
|
+
}
|
675
|
+
}
|
597
676
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
598
677
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
599
678
|
}
|
@@ -642,9 +721,9 @@ async function fetch$1({
|
|
642
721
|
return await trace(
|
643
722
|
`${method.toUpperCase()} ${path}`,
|
644
723
|
async ({ setAttributes }) => {
|
645
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
724
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
646
725
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
647
|
-
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
726
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
|
648
727
|
setAttributes({
|
649
728
|
[TraceAttributes.HTTP_URL]: url,
|
650
729
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
@@ -725,7 +804,7 @@ function fetchSSERequest({
|
|
725
804
|
clientName,
|
726
805
|
xataAgentExtra
|
727
806
|
}) {
|
728
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
807
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
729
808
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
730
809
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
731
810
|
void fetchEventSource(url, {
|
@@ -768,6 +847,20 @@ function parseUrl(url) {
|
|
768
847
|
|
769
848
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
770
849
|
|
850
|
+
const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
|
851
|
+
const pgRollStatus = (variables, signal) => dataPlaneFetch({
|
852
|
+
url: "/db/{dbBranchName}/pgroll/status",
|
853
|
+
method: "get",
|
854
|
+
...variables,
|
855
|
+
signal
|
856
|
+
});
|
857
|
+
const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
|
858
|
+
url: "/db/{dbBranchName}/pgroll/jobs/{jobId}",
|
859
|
+
method: "get",
|
860
|
+
...variables,
|
861
|
+
signal
|
862
|
+
});
|
863
|
+
const pgRollMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/migrations", method: "get", ...variables, signal });
|
771
864
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
772
865
|
url: "/dbs/{dbName}",
|
773
866
|
method: "get",
|
@@ -974,6 +1067,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
974
1067
|
...variables,
|
975
1068
|
signal
|
976
1069
|
});
|
1070
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1071
|
+
url: "/file/{fileId}",
|
1072
|
+
method: "put",
|
1073
|
+
...variables,
|
1074
|
+
signal
|
1075
|
+
});
|
977
1076
|
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
978
1077
|
url: "/db/{dbBranchName}/sql",
|
979
1078
|
method: "post",
|
@@ -982,6 +1081,10 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
982
1081
|
});
|
983
1082
|
const operationsByTag$2 = {
|
984
1083
|
branch: {
|
1084
|
+
applyMigration,
|
1085
|
+
pgRollStatus,
|
1086
|
+
pgRollJobStatus,
|
1087
|
+
pgRollMigrationHistory,
|
985
1088
|
getBranchList,
|
986
1089
|
getBranchDetails,
|
987
1090
|
createBranch,
|
@@ -1040,7 +1143,7 @@ const operationsByTag$2 = {
|
|
1040
1143
|
deleteRecord,
|
1041
1144
|
bulkInsertTableRecords
|
1042
1145
|
},
|
1043
|
-
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1146
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1044
1147
|
searchAndFilter: {
|
1045
1148
|
queryTable,
|
1046
1149
|
searchBranch,
|
@@ -1162,12 +1265,7 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
1162
1265
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1163
1266
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1164
1267
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1165
|
-
const listClusters = (variables, signal) => controlPlaneFetch({
|
1166
|
-
url: "/workspaces/{workspaceId}/clusters",
|
1167
|
-
method: "get",
|
1168
|
-
...variables,
|
1169
|
-
signal
|
1170
|
-
});
|
1268
|
+
const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
|
1171
1269
|
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1172
1270
|
const getCluster = (variables, signal) => controlPlaneFetch({
|
1173
1271
|
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
@@ -1247,66 +1345,11 @@ const operationsByTag$1 = {
|
|
1247
1345
|
|
1248
1346
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1249
1347
|
|
1250
|
-
function getHostUrl(provider, type) {
|
1251
|
-
if (isHostProviderAlias(provider)) {
|
1252
|
-
return providers[provider][type];
|
1253
|
-
} else if (isHostProviderBuilder(provider)) {
|
1254
|
-
return provider[type];
|
1255
|
-
}
|
1256
|
-
throw new Error("Invalid API provider");
|
1257
|
-
}
|
1258
|
-
const providers = {
|
1259
|
-
production: {
|
1260
|
-
main: "https://api.xata.io",
|
1261
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
1262
|
-
},
|
1263
|
-
staging: {
|
1264
|
-
main: "https://api.staging-xata.dev",
|
1265
|
-
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1266
|
-
},
|
1267
|
-
dev: {
|
1268
|
-
main: "https://api.dev-xata.dev",
|
1269
|
-
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1270
|
-
}
|
1271
|
-
};
|
1272
|
-
function isHostProviderAlias(alias) {
|
1273
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
1274
|
-
}
|
1275
|
-
function isHostProviderBuilder(builder) {
|
1276
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
1277
|
-
}
|
1278
|
-
function parseProviderString(provider = "production") {
|
1279
|
-
if (isHostProviderAlias(provider)) {
|
1280
|
-
return provider;
|
1281
|
-
}
|
1282
|
-
const [main, workspaces] = provider.split(",");
|
1283
|
-
if (!main || !workspaces)
|
1284
|
-
return null;
|
1285
|
-
return { main, workspaces };
|
1286
|
-
}
|
1287
|
-
function buildProviderString(provider) {
|
1288
|
-
if (isHostProviderAlias(provider))
|
1289
|
-
return provider;
|
1290
|
-
return `${provider.main},${provider.workspaces}`;
|
1291
|
-
}
|
1292
|
-
function parseWorkspacesUrlParts(url) {
|
1293
|
-
if (!isString(url))
|
1294
|
-
return null;
|
1295
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1296
|
-
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1297
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1298
|
-
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1299
|
-
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1300
|
-
if (!match)
|
1301
|
-
return null;
|
1302
|
-
return { workspace: match[1], region: match[2] };
|
1303
|
-
}
|
1304
|
-
|
1305
1348
|
var __accessCheck$7 = (obj, member, msg) => {
|
1306
1349
|
if (!member.has(obj))
|
1307
1350
|
throw TypeError("Cannot " + msg);
|
1308
1351
|
};
|
1309
|
-
var __privateGet$
|
1352
|
+
var __privateGet$6 = (obj, member, getter) => {
|
1310
1353
|
__accessCheck$7(obj, member, "read from private field");
|
1311
1354
|
return getter ? getter.call(obj) : member.get(obj);
|
1312
1355
|
};
|
@@ -1315,7 +1358,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
1315
1358
|
throw TypeError("Cannot add the same private member more than once");
|
1316
1359
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1317
1360
|
};
|
1318
|
-
var __privateSet$
|
1361
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
1319
1362
|
__accessCheck$7(obj, member, "write to private field");
|
1320
1363
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1321
1364
|
return value;
|
@@ -1332,7 +1375,7 @@ class XataApiClient {
|
|
1332
1375
|
if (!apiKey) {
|
1333
1376
|
throw new Error("Could not resolve a valid apiKey");
|
1334
1377
|
}
|
1335
|
-
__privateSet$
|
1378
|
+
__privateSet$5(this, _extraProps, {
|
1336
1379
|
apiUrl: getHostUrl(provider, "main"),
|
1337
1380
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
1338
1381
|
fetch: getFetchImplementation(options.fetch),
|
@@ -1344,64 +1387,64 @@ class XataApiClient {
|
|
1344
1387
|
});
|
1345
1388
|
}
|
1346
1389
|
get user() {
|
1347
|
-
if (!__privateGet$
|
1348
|
-
__privateGet$
|
1349
|
-
return __privateGet$
|
1390
|
+
if (!__privateGet$6(this, _namespaces).user)
|
1391
|
+
__privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
|
1392
|
+
return __privateGet$6(this, _namespaces).user;
|
1350
1393
|
}
|
1351
1394
|
get authentication() {
|
1352
|
-
if (!__privateGet$
|
1353
|
-
__privateGet$
|
1354
|
-
return __privateGet$
|
1395
|
+
if (!__privateGet$6(this, _namespaces).authentication)
|
1396
|
+
__privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
|
1397
|
+
return __privateGet$6(this, _namespaces).authentication;
|
1355
1398
|
}
|
1356
1399
|
get workspaces() {
|
1357
|
-
if (!__privateGet$
|
1358
|
-
__privateGet$
|
1359
|
-
return __privateGet$
|
1400
|
+
if (!__privateGet$6(this, _namespaces).workspaces)
|
1401
|
+
__privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
|
1402
|
+
return __privateGet$6(this, _namespaces).workspaces;
|
1360
1403
|
}
|
1361
1404
|
get invites() {
|
1362
|
-
if (!__privateGet$
|
1363
|
-
__privateGet$
|
1364
|
-
return __privateGet$
|
1405
|
+
if (!__privateGet$6(this, _namespaces).invites)
|
1406
|
+
__privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
|
1407
|
+
return __privateGet$6(this, _namespaces).invites;
|
1365
1408
|
}
|
1366
1409
|
get database() {
|
1367
|
-
if (!__privateGet$
|
1368
|
-
__privateGet$
|
1369
|
-
return __privateGet$
|
1410
|
+
if (!__privateGet$6(this, _namespaces).database)
|
1411
|
+
__privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
|
1412
|
+
return __privateGet$6(this, _namespaces).database;
|
1370
1413
|
}
|
1371
1414
|
get branches() {
|
1372
|
-
if (!__privateGet$
|
1373
|
-
__privateGet$
|
1374
|
-
return __privateGet$
|
1415
|
+
if (!__privateGet$6(this, _namespaces).branches)
|
1416
|
+
__privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
|
1417
|
+
return __privateGet$6(this, _namespaces).branches;
|
1375
1418
|
}
|
1376
1419
|
get migrations() {
|
1377
|
-
if (!__privateGet$
|
1378
|
-
__privateGet$
|
1379
|
-
return __privateGet$
|
1420
|
+
if (!__privateGet$6(this, _namespaces).migrations)
|
1421
|
+
__privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
|
1422
|
+
return __privateGet$6(this, _namespaces).migrations;
|
1380
1423
|
}
|
1381
1424
|
get migrationRequests() {
|
1382
|
-
if (!__privateGet$
|
1383
|
-
__privateGet$
|
1384
|
-
return __privateGet$
|
1425
|
+
if (!__privateGet$6(this, _namespaces).migrationRequests)
|
1426
|
+
__privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
|
1427
|
+
return __privateGet$6(this, _namespaces).migrationRequests;
|
1385
1428
|
}
|
1386
1429
|
get tables() {
|
1387
|
-
if (!__privateGet$
|
1388
|
-
__privateGet$
|
1389
|
-
return __privateGet$
|
1430
|
+
if (!__privateGet$6(this, _namespaces).tables)
|
1431
|
+
__privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
|
1432
|
+
return __privateGet$6(this, _namespaces).tables;
|
1390
1433
|
}
|
1391
1434
|
get records() {
|
1392
|
-
if (!__privateGet$
|
1393
|
-
__privateGet$
|
1394
|
-
return __privateGet$
|
1435
|
+
if (!__privateGet$6(this, _namespaces).records)
|
1436
|
+
__privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
|
1437
|
+
return __privateGet$6(this, _namespaces).records;
|
1395
1438
|
}
|
1396
1439
|
get files() {
|
1397
|
-
if (!__privateGet$
|
1398
|
-
__privateGet$
|
1399
|
-
return __privateGet$
|
1440
|
+
if (!__privateGet$6(this, _namespaces).files)
|
1441
|
+
__privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
|
1442
|
+
return __privateGet$6(this, _namespaces).files;
|
1400
1443
|
}
|
1401
1444
|
get searchAndFilter() {
|
1402
|
-
if (!__privateGet$
|
1403
|
-
__privateGet$
|
1404
|
-
return __privateGet$
|
1445
|
+
if (!__privateGet$6(this, _namespaces).searchAndFilter)
|
1446
|
+
__privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
|
1447
|
+
return __privateGet$6(this, _namespaces).searchAndFilter;
|
1405
1448
|
}
|
1406
1449
|
}
|
1407
1450
|
_extraProps = new WeakMap();
|
@@ -1703,6 +1746,30 @@ class BranchApi {
|
|
1703
1746
|
...this.extraProps
|
1704
1747
|
});
|
1705
1748
|
}
|
1749
|
+
pgRollMigrationHistory({
|
1750
|
+
workspace,
|
1751
|
+
region,
|
1752
|
+
database,
|
1753
|
+
branch
|
1754
|
+
}) {
|
1755
|
+
return operationsByTag.branch.pgRollMigrationHistory({
|
1756
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1757
|
+
...this.extraProps
|
1758
|
+
});
|
1759
|
+
}
|
1760
|
+
applyMigration({
|
1761
|
+
workspace,
|
1762
|
+
region,
|
1763
|
+
database,
|
1764
|
+
branch,
|
1765
|
+
migration
|
1766
|
+
}) {
|
1767
|
+
return operationsByTag.branch.applyMigration({
|
1768
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1769
|
+
body: migration,
|
1770
|
+
...this.extraProps
|
1771
|
+
});
|
1772
|
+
}
|
1706
1773
|
}
|
1707
1774
|
class TableApi {
|
1708
1775
|
constructor(extraProps) {
|
@@ -2516,6 +2583,17 @@ class MigrationsApi {
|
|
2516
2583
|
...this.extraProps
|
2517
2584
|
});
|
2518
2585
|
}
|
2586
|
+
getSchema({
|
2587
|
+
workspace,
|
2588
|
+
region,
|
2589
|
+
database,
|
2590
|
+
branch
|
2591
|
+
}) {
|
2592
|
+
return operationsByTag.migrations.getSchema({
|
2593
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2594
|
+
...this.extraProps
|
2595
|
+
});
|
2596
|
+
}
|
2519
2597
|
}
|
2520
2598
|
class DatabaseApi {
|
2521
2599
|
constructor(extraProps) {
|
@@ -2657,16 +2735,18 @@ function transformImage(url, ...transformations) {
|
|
2657
2735
|
class XataFile {
|
2658
2736
|
constructor(file) {
|
2659
2737
|
this.id = file.id;
|
2660
|
-
this.name = file.name
|
2661
|
-
this.mediaType = file.mediaType
|
2738
|
+
this.name = file.name;
|
2739
|
+
this.mediaType = file.mediaType;
|
2662
2740
|
this.base64Content = file.base64Content;
|
2663
|
-
this.enablePublicUrl = file.enablePublicUrl
|
2664
|
-
this.signedUrlTimeout = file.signedUrlTimeout
|
2665
|
-
this.
|
2666
|
-
this.
|
2667
|
-
this.
|
2741
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2742
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2743
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2744
|
+
this.size = file.size;
|
2745
|
+
this.version = file.version;
|
2746
|
+
this.url = file.url;
|
2668
2747
|
this.signedUrl = file.signedUrl;
|
2669
|
-
this.
|
2748
|
+
this.uploadUrl = file.uploadUrl;
|
2749
|
+
this.attributes = file.attributes;
|
2670
2750
|
}
|
2671
2751
|
static fromBuffer(buffer, options = {}) {
|
2672
2752
|
const base64Content = buffer.toString("base64");
|
@@ -2756,7 +2836,7 @@ class XataFile {
|
|
2756
2836
|
const parseInputFileEntry = async (entry) => {
|
2757
2837
|
if (!isDefined(entry))
|
2758
2838
|
return null;
|
2759
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2839
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2760
2840
|
return compactObject({
|
2761
2841
|
id,
|
2762
2842
|
// Name cannot be an empty string in our API
|
@@ -2764,7 +2844,8 @@ const parseInputFileEntry = async (entry) => {
|
|
2764
2844
|
mediaType,
|
2765
2845
|
base64Content,
|
2766
2846
|
enablePublicUrl,
|
2767
|
-
signedUrlTimeout
|
2847
|
+
signedUrlTimeout,
|
2848
|
+
uploadUrlTimeout
|
2768
2849
|
});
|
2769
2850
|
};
|
2770
2851
|
|
@@ -2818,7 +2899,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
2818
2899
|
if (!member.has(obj))
|
2819
2900
|
throw TypeError("Cannot " + msg);
|
2820
2901
|
};
|
2821
|
-
var __privateGet$
|
2902
|
+
var __privateGet$5 = (obj, member, getter) => {
|
2822
2903
|
__accessCheck$6(obj, member, "read from private field");
|
2823
2904
|
return getter ? getter.call(obj) : member.get(obj);
|
2824
2905
|
};
|
@@ -2827,7 +2908,7 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
2827
2908
|
throw TypeError("Cannot add the same private member more than once");
|
2828
2909
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2829
2910
|
};
|
2830
|
-
var __privateSet$
|
2911
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
2831
2912
|
__accessCheck$6(obj, member, "write to private field");
|
2832
2913
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
2833
2914
|
return value;
|
@@ -2836,7 +2917,7 @@ var _query, _page;
|
|
2836
2917
|
class Page {
|
2837
2918
|
constructor(query, meta, records = []) {
|
2838
2919
|
__privateAdd$6(this, _query, void 0);
|
2839
|
-
__privateSet$
|
2920
|
+
__privateSet$4(this, _query, query);
|
2840
2921
|
this.meta = meta;
|
2841
2922
|
this.records = new RecordArray(this, records);
|
2842
2923
|
}
|
@@ -2847,7 +2928,7 @@ class Page {
|
|
2847
2928
|
* @returns The next page or results.
|
2848
2929
|
*/
|
2849
2930
|
async nextPage(size, offset) {
|
2850
|
-
return __privateGet$
|
2931
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
2851
2932
|
}
|
2852
2933
|
/**
|
2853
2934
|
* Retrieves the previous page of results.
|
@@ -2856,7 +2937,7 @@ class Page {
|
|
2856
2937
|
* @returns The previous page or results.
|
2857
2938
|
*/
|
2858
2939
|
async previousPage(size, offset) {
|
2859
|
-
return __privateGet$
|
2940
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
2860
2941
|
}
|
2861
2942
|
/**
|
2862
2943
|
* Retrieves the start page of results.
|
@@ -2865,7 +2946,7 @@ class Page {
|
|
2865
2946
|
* @returns The start page or results.
|
2866
2947
|
*/
|
2867
2948
|
async startPage(size, offset) {
|
2868
|
-
return __privateGet$
|
2949
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
2869
2950
|
}
|
2870
2951
|
/**
|
2871
2952
|
* Retrieves the end page of results.
|
@@ -2874,7 +2955,7 @@ class Page {
|
|
2874
2955
|
* @returns The end page or results.
|
2875
2956
|
*/
|
2876
2957
|
async endPage(size, offset) {
|
2877
|
-
return __privateGet$
|
2958
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
2878
2959
|
}
|
2879
2960
|
/**
|
2880
2961
|
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
@@ -2896,7 +2977,7 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2896
2977
|
constructor(...args) {
|
2897
2978
|
super(..._RecordArray.parseConstructorParams(...args));
|
2898
2979
|
__privateAdd$6(this, _page, void 0);
|
2899
|
-
__privateSet$
|
2980
|
+
__privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
2900
2981
|
}
|
2901
2982
|
static parseConstructorParams(...args) {
|
2902
2983
|
if (args.length === 1 && typeof args[0] === "number") {
|
@@ -2926,7 +3007,7 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2926
3007
|
* @returns A new array of objects
|
2927
3008
|
*/
|
2928
3009
|
async nextPage(size, offset) {
|
2929
|
-
const newPage = await __privateGet$
|
3010
|
+
const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
|
2930
3011
|
return new _RecordArray(newPage);
|
2931
3012
|
}
|
2932
3013
|
/**
|
@@ -2935,7 +3016,7 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2935
3016
|
* @returns A new array of objects
|
2936
3017
|
*/
|
2937
3018
|
async previousPage(size, offset) {
|
2938
|
-
const newPage = await __privateGet$
|
3019
|
+
const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
|
2939
3020
|
return new _RecordArray(newPage);
|
2940
3021
|
}
|
2941
3022
|
/**
|
@@ -2944,7 +3025,7 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2944
3025
|
* @returns A new array of objects
|
2945
3026
|
*/
|
2946
3027
|
async startPage(size, offset) {
|
2947
|
-
const newPage = await __privateGet$
|
3028
|
+
const newPage = await __privateGet$5(this, _page).startPage(size, offset);
|
2948
3029
|
return new _RecordArray(newPage);
|
2949
3030
|
}
|
2950
3031
|
/**
|
@@ -2953,14 +3034,14 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2953
3034
|
* @returns A new array of objects
|
2954
3035
|
*/
|
2955
3036
|
async endPage(size, offset) {
|
2956
|
-
const newPage = await __privateGet$
|
3037
|
+
const newPage = await __privateGet$5(this, _page).endPage(size, offset);
|
2957
3038
|
return new _RecordArray(newPage);
|
2958
3039
|
}
|
2959
3040
|
/**
|
2960
3041
|
* @returns Boolean indicating if there is a next page
|
2961
3042
|
*/
|
2962
3043
|
hasNextPage() {
|
2963
|
-
return __privateGet$
|
3044
|
+
return __privateGet$5(this, _page).meta.page.more;
|
2964
3045
|
}
|
2965
3046
|
};
|
2966
3047
|
_page = new WeakMap();
|
@@ -2970,7 +3051,7 @@ var __accessCheck$5 = (obj, member, msg) => {
|
|
2970
3051
|
if (!member.has(obj))
|
2971
3052
|
throw TypeError("Cannot " + msg);
|
2972
3053
|
};
|
2973
|
-
var __privateGet$
|
3054
|
+
var __privateGet$4 = (obj, member, getter) => {
|
2974
3055
|
__accessCheck$5(obj, member, "read from private field");
|
2975
3056
|
return getter ? getter.call(obj) : member.get(obj);
|
2976
3057
|
};
|
@@ -2979,7 +3060,7 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
2979
3060
|
throw TypeError("Cannot add the same private member more than once");
|
2980
3061
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2981
3062
|
};
|
2982
|
-
var __privateSet$
|
3063
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
2983
3064
|
__accessCheck$5(obj, member, "write to private field");
|
2984
3065
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
2985
3066
|
return value;
|
@@ -2998,24 +3079,24 @@ const _Query = class _Query {
|
|
2998
3079
|
// Implements pagination
|
2999
3080
|
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3000
3081
|
this.records = new RecordArray(this, []);
|
3001
|
-
__privateSet$
|
3082
|
+
__privateSet$3(this, _table$1, table);
|
3002
3083
|
if (repository) {
|
3003
|
-
__privateSet$
|
3084
|
+
__privateSet$3(this, _repository, repository);
|
3004
3085
|
} else {
|
3005
|
-
__privateSet$
|
3086
|
+
__privateSet$3(this, _repository, this);
|
3006
3087
|
}
|
3007
3088
|
const parent = cleanParent(data, rawParent);
|
3008
|
-
__privateGet$
|
3009
|
-
__privateGet$
|
3010
|
-
__privateGet$
|
3011
|
-
__privateGet$
|
3012
|
-
__privateGet$
|
3013
|
-
__privateGet$
|
3014
|
-
__privateGet$
|
3015
|
-
__privateGet$
|
3016
|
-
__privateGet$
|
3017
|
-
__privateGet$
|
3018
|
-
__privateGet$
|
3089
|
+
__privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
3090
|
+
__privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
3091
|
+
__privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
3092
|
+
__privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
3093
|
+
__privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
3094
|
+
__privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
|
3095
|
+
__privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
|
3096
|
+
__privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
|
3097
|
+
__privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
|
3098
|
+
__privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
|
3099
|
+
__privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
3019
3100
|
this.any = this.any.bind(this);
|
3020
3101
|
this.all = this.all.bind(this);
|
3021
3102
|
this.not = this.not.bind(this);
|
@@ -3026,10 +3107,10 @@ const _Query = class _Query {
|
|
3026
3107
|
Object.defineProperty(this, "repository", { enumerable: false });
|
3027
3108
|
}
|
3028
3109
|
getQueryOptions() {
|
3029
|
-
return __privateGet$
|
3110
|
+
return __privateGet$4(this, _data);
|
3030
3111
|
}
|
3031
3112
|
key() {
|
3032
|
-
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$
|
3113
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
|
3033
3114
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
3034
3115
|
return toBase64(key);
|
3035
3116
|
}
|
@@ -3040,7 +3121,7 @@ const _Query = class _Query {
|
|
3040
3121
|
*/
|
3041
3122
|
any(...queries) {
|
3042
3123
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3043
|
-
return new _Query(__privateGet$
|
3124
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
|
3044
3125
|
}
|
3045
3126
|
/**
|
3046
3127
|
* Builds a new query object representing a logical AND between the given subqueries.
|
@@ -3049,7 +3130,7 @@ const _Query = class _Query {
|
|
3049
3130
|
*/
|
3050
3131
|
all(...queries) {
|
3051
3132
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3052
|
-
return new _Query(__privateGet$
|
3133
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3053
3134
|
}
|
3054
3135
|
/**
|
3055
3136
|
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
@@ -3058,7 +3139,7 @@ const _Query = class _Query {
|
|
3058
3139
|
*/
|
3059
3140
|
not(...queries) {
|
3060
3141
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3061
|
-
return new _Query(__privateGet$
|
3142
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
|
3062
3143
|
}
|
3063
3144
|
/**
|
3064
3145
|
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
@@ -3067,25 +3148,25 @@ const _Query = class _Query {
|
|
3067
3148
|
*/
|
3068
3149
|
none(...queries) {
|
3069
3150
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3070
|
-
return new _Query(__privateGet$
|
3151
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
|
3071
3152
|
}
|
3072
3153
|
filter(a, b) {
|
3073
3154
|
if (arguments.length === 1) {
|
3074
3155
|
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
3075
3156
|
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
3076
3157
|
}));
|
3077
|
-
const $all = compact([__privateGet$
|
3078
|
-
return new _Query(__privateGet$
|
3158
|
+
const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
|
3159
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3079
3160
|
} else {
|
3080
3161
|
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
3081
|
-
const $all = compact([__privateGet$
|
3082
|
-
return new _Query(__privateGet$
|
3162
|
+
const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
|
3163
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3083
3164
|
}
|
3084
3165
|
}
|
3085
3166
|
sort(column, direction = "asc") {
|
3086
|
-
const originalSort = [__privateGet$
|
3167
|
+
const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
|
3087
3168
|
const sort = [...originalSort, { column, direction }];
|
3088
|
-
return new _Query(__privateGet$
|
3169
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
|
3089
3170
|
}
|
3090
3171
|
/**
|
3091
3172
|
* Builds a new query specifying the set of columns to be returned in the query response.
|
@@ -3094,15 +3175,15 @@ const _Query = class _Query {
|
|
3094
3175
|
*/
|
3095
3176
|
select(columns) {
|
3096
3177
|
return new _Query(
|
3097
|
-
__privateGet$
|
3098
|
-
__privateGet$
|
3178
|
+
__privateGet$4(this, _repository),
|
3179
|
+
__privateGet$4(this, _table$1),
|
3099
3180
|
{ columns },
|
3100
|
-
__privateGet$
|
3181
|
+
__privateGet$4(this, _data)
|
3101
3182
|
);
|
3102
3183
|
}
|
3103
3184
|
getPaginated(options = {}) {
|
3104
|
-
const query = new _Query(__privateGet$
|
3105
|
-
return __privateGet$
|
3185
|
+
const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
|
3186
|
+
return __privateGet$4(this, _repository).query(query);
|
3106
3187
|
}
|
3107
3188
|
/**
|
3108
3189
|
* Get results in an iterator
|
@@ -3163,12 +3244,12 @@ const _Query = class _Query {
|
|
3163
3244
|
async summarize(params = {}) {
|
3164
3245
|
const { summaries, summariesFilter, ...options } = params;
|
3165
3246
|
const query = new _Query(
|
3166
|
-
__privateGet$
|
3167
|
-
__privateGet$
|
3247
|
+
__privateGet$4(this, _repository),
|
3248
|
+
__privateGet$4(this, _table$1),
|
3168
3249
|
options,
|
3169
|
-
__privateGet$
|
3250
|
+
__privateGet$4(this, _data)
|
3170
3251
|
);
|
3171
|
-
return __privateGet$
|
3252
|
+
return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
3172
3253
|
}
|
3173
3254
|
/**
|
3174
3255
|
* Builds a new query object adding a cache TTL in milliseconds.
|
@@ -3176,7 +3257,7 @@ const _Query = class _Query {
|
|
3176
3257
|
* @returns A new Query object.
|
3177
3258
|
*/
|
3178
3259
|
cache(ttl) {
|
3179
|
-
return new _Query(__privateGet$
|
3260
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
|
3180
3261
|
}
|
3181
3262
|
/**
|
3182
3263
|
* Retrieve next page of records
|
@@ -3222,7 +3303,7 @@ _repository = new WeakMap();
|
|
3222
3303
|
_data = new WeakMap();
|
3223
3304
|
_cleanFilterConstraint = new WeakSet();
|
3224
3305
|
cleanFilterConstraint_fn = function(column, value) {
|
3225
|
-
const columnType = __privateGet$
|
3306
|
+
const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
3226
3307
|
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
3227
3308
|
return { $includes: value };
|
3228
3309
|
}
|
@@ -3248,7 +3329,6 @@ const RecordColumnTypes = [
|
|
3248
3329
|
"email",
|
3249
3330
|
"multiple",
|
3250
3331
|
"link",
|
3251
|
-
"object",
|
3252
3332
|
"datetime",
|
3253
3333
|
"vector",
|
3254
3334
|
"file[]",
|
@@ -3313,7 +3393,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
3313
3393
|
if (!member.has(obj))
|
3314
3394
|
throw TypeError("Cannot " + msg);
|
3315
3395
|
};
|
3316
|
-
var __privateGet$
|
3396
|
+
var __privateGet$3 = (obj, member, getter) => {
|
3317
3397
|
__accessCheck$4(obj, member, "read from private field");
|
3318
3398
|
return getter ? getter.call(obj) : member.get(obj);
|
3319
3399
|
};
|
@@ -3322,7 +3402,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
3322
3402
|
throw TypeError("Cannot add the same private member more than once");
|
3323
3403
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3324
3404
|
};
|
3325
|
-
var __privateSet$
|
3405
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
3326
3406
|
__accessCheck$4(obj, member, "write to private field");
|
3327
3407
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
3328
3408
|
return value;
|
@@ -3331,7 +3411,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
3331
3411
|
__accessCheck$4(obj, member, "access private method");
|
3332
3412
|
return method;
|
3333
3413
|
};
|
3334
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables
|
3414
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables, getSchemaTables_fn, _transformObjectToApi, transformObjectToApi_fn;
|
3335
3415
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
3336
3416
|
class Repository extends Query {
|
3337
3417
|
}
|
@@ -3352,31 +3432,31 @@ class RestRepository extends Query {
|
|
3352
3432
|
__privateAdd$4(this, _deleteRecords);
|
3353
3433
|
__privateAdd$4(this, _setCacheQuery);
|
3354
3434
|
__privateAdd$4(this, _getCacheQuery);
|
3355
|
-
__privateAdd$4(this, _getSchemaTables
|
3435
|
+
__privateAdd$4(this, _getSchemaTables);
|
3356
3436
|
__privateAdd$4(this, _transformObjectToApi);
|
3357
3437
|
__privateAdd$4(this, _table, void 0);
|
3358
3438
|
__privateAdd$4(this, _getFetchProps, void 0);
|
3359
3439
|
__privateAdd$4(this, _db, void 0);
|
3360
3440
|
__privateAdd$4(this, _cache, void 0);
|
3361
|
-
__privateAdd$4(this, _schemaTables
|
3441
|
+
__privateAdd$4(this, _schemaTables, void 0);
|
3362
3442
|
__privateAdd$4(this, _trace, void 0);
|
3363
|
-
__privateSet$
|
3364
|
-
__privateSet$
|
3365
|
-
__privateSet$
|
3366
|
-
__privateSet$
|
3367
|
-
__privateSet$
|
3443
|
+
__privateSet$2(this, _table, options.table);
|
3444
|
+
__privateSet$2(this, _db, options.db);
|
3445
|
+
__privateSet$2(this, _cache, options.pluginOptions.cache);
|
3446
|
+
__privateSet$2(this, _schemaTables, options.schemaTables);
|
3447
|
+
__privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
3368
3448
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
3369
|
-
__privateSet$
|
3449
|
+
__privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
|
3370
3450
|
return trace(name, fn, {
|
3371
3451
|
...options2,
|
3372
|
-
[TraceAttributes.TABLE]: __privateGet$
|
3452
|
+
[TraceAttributes.TABLE]: __privateGet$3(this, _table),
|
3373
3453
|
[TraceAttributes.KIND]: "sdk-operation",
|
3374
3454
|
[TraceAttributes.VERSION]: VERSION
|
3375
3455
|
});
|
3376
3456
|
});
|
3377
3457
|
}
|
3378
3458
|
async create(a, b, c, d) {
|
3379
|
-
return __privateGet$
|
3459
|
+
return __privateGet$3(this, _trace).call(this, "create", async () => {
|
3380
3460
|
const ifVersion = parseIfVersion(b, c, d);
|
3381
3461
|
if (Array.isArray(a)) {
|
3382
3462
|
if (a.length === 0)
|
@@ -3406,7 +3486,7 @@ class RestRepository extends Query {
|
|
3406
3486
|
});
|
3407
3487
|
}
|
3408
3488
|
async read(a, b) {
|
3409
|
-
return __privateGet$
|
3489
|
+
return __privateGet$3(this, _trace).call(this, "read", async () => {
|
3410
3490
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3411
3491
|
if (Array.isArray(a)) {
|
3412
3492
|
if (a.length === 0)
|
@@ -3427,17 +3507,17 @@ class RestRepository extends Query {
|
|
3427
3507
|
workspace: "{workspaceId}",
|
3428
3508
|
dbBranchName: "{dbBranch}",
|
3429
3509
|
region: "{region}",
|
3430
|
-
tableName: __privateGet$
|
3510
|
+
tableName: __privateGet$3(this, _table),
|
3431
3511
|
recordId: id
|
3432
3512
|
},
|
3433
3513
|
queryParams: { columns },
|
3434
|
-
...__privateGet$
|
3514
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3435
3515
|
});
|
3436
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3516
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3437
3517
|
return initObject(
|
3438
|
-
__privateGet$
|
3518
|
+
__privateGet$3(this, _db),
|
3439
3519
|
schemaTables,
|
3440
|
-
__privateGet$
|
3520
|
+
__privateGet$3(this, _table),
|
3441
3521
|
response,
|
3442
3522
|
columns
|
3443
3523
|
);
|
@@ -3452,7 +3532,7 @@ class RestRepository extends Query {
|
|
3452
3532
|
});
|
3453
3533
|
}
|
3454
3534
|
async readOrThrow(a, b) {
|
3455
|
-
return __privateGet$
|
3535
|
+
return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
|
3456
3536
|
const result = await this.read(a, b);
|
3457
3537
|
if (Array.isArray(result)) {
|
3458
3538
|
const missingIds = compact(
|
@@ -3471,7 +3551,7 @@ class RestRepository extends Query {
|
|
3471
3551
|
});
|
3472
3552
|
}
|
3473
3553
|
async update(a, b, c, d) {
|
3474
|
-
return __privateGet$
|
3554
|
+
return __privateGet$3(this, _trace).call(this, "update", async () => {
|
3475
3555
|
const ifVersion = parseIfVersion(b, c, d);
|
3476
3556
|
if (Array.isArray(a)) {
|
3477
3557
|
if (a.length === 0)
|
@@ -3504,7 +3584,7 @@ class RestRepository extends Query {
|
|
3504
3584
|
});
|
3505
3585
|
}
|
3506
3586
|
async updateOrThrow(a, b, c, d) {
|
3507
|
-
return __privateGet$
|
3587
|
+
return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
|
3508
3588
|
const result = await this.update(a, b, c, d);
|
3509
3589
|
if (Array.isArray(result)) {
|
3510
3590
|
const missingIds = compact(
|
@@ -3523,7 +3603,7 @@ class RestRepository extends Query {
|
|
3523
3603
|
});
|
3524
3604
|
}
|
3525
3605
|
async createOrUpdate(a, b, c, d) {
|
3526
|
-
return __privateGet$
|
3606
|
+
return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
|
3527
3607
|
const ifVersion = parseIfVersion(b, c, d);
|
3528
3608
|
if (Array.isArray(a)) {
|
3529
3609
|
if (a.length === 0)
|
@@ -3558,7 +3638,7 @@ class RestRepository extends Query {
|
|
3558
3638
|
});
|
3559
3639
|
}
|
3560
3640
|
async createOrReplace(a, b, c, d) {
|
3561
|
-
return __privateGet$
|
3641
|
+
return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
|
3562
3642
|
const ifVersion = parseIfVersion(b, c, d);
|
3563
3643
|
if (Array.isArray(a)) {
|
3564
3644
|
if (a.length === 0)
|
@@ -3590,7 +3670,7 @@ class RestRepository extends Query {
|
|
3590
3670
|
});
|
3591
3671
|
}
|
3592
3672
|
async delete(a, b) {
|
3593
|
-
return __privateGet$
|
3673
|
+
return __privateGet$3(this, _trace).call(this, "delete", async () => {
|
3594
3674
|
if (Array.isArray(a)) {
|
3595
3675
|
if (a.length === 0)
|
3596
3676
|
return [];
|
@@ -3616,7 +3696,7 @@ class RestRepository extends Query {
|
|
3616
3696
|
});
|
3617
3697
|
}
|
3618
3698
|
async deleteOrThrow(a, b) {
|
3619
|
-
return __privateGet$
|
3699
|
+
return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
|
3620
3700
|
const result = await this.delete(a, b);
|
3621
3701
|
if (Array.isArray(result)) {
|
3622
3702
|
const missingIds = compact(
|
@@ -3634,13 +3714,13 @@ class RestRepository extends Query {
|
|
3634
3714
|
});
|
3635
3715
|
}
|
3636
3716
|
async search(query, options = {}) {
|
3637
|
-
return __privateGet$
|
3638
|
-
const { records } = await searchTable({
|
3717
|
+
return __privateGet$3(this, _trace).call(this, "search", async () => {
|
3718
|
+
const { records, totalCount } = await searchTable({
|
3639
3719
|
pathParams: {
|
3640
3720
|
workspace: "{workspaceId}",
|
3641
3721
|
dbBranchName: "{dbBranch}",
|
3642
3722
|
region: "{region}",
|
3643
|
-
tableName: __privateGet$
|
3723
|
+
tableName: __privateGet$3(this, _table)
|
3644
3724
|
},
|
3645
3725
|
body: {
|
3646
3726
|
query,
|
@@ -3652,20 +3732,23 @@ class RestRepository extends Query {
|
|
3652
3732
|
page: options.page,
|
3653
3733
|
target: options.target
|
3654
3734
|
},
|
3655
|
-
...__privateGet$
|
3735
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3656
3736
|
});
|
3657
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3658
|
-
return
|
3737
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3738
|
+
return {
|
3739
|
+
records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
|
3740
|
+
totalCount
|
3741
|
+
};
|
3659
3742
|
});
|
3660
3743
|
}
|
3661
3744
|
async vectorSearch(column, query, options) {
|
3662
|
-
return __privateGet$
|
3663
|
-
const { records } = await vectorSearchTable({
|
3745
|
+
return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
|
3746
|
+
const { records, totalCount } = await vectorSearchTable({
|
3664
3747
|
pathParams: {
|
3665
3748
|
workspace: "{workspaceId}",
|
3666
3749
|
dbBranchName: "{dbBranch}",
|
3667
3750
|
region: "{region}",
|
3668
|
-
tableName: __privateGet$
|
3751
|
+
tableName: __privateGet$3(this, _table)
|
3669
3752
|
},
|
3670
3753
|
body: {
|
3671
3754
|
column,
|
@@ -3674,29 +3757,32 @@ class RestRepository extends Query {
|
|
3674
3757
|
size: options?.size,
|
3675
3758
|
filter: options?.filter
|
3676
3759
|
},
|
3677
|
-
...__privateGet$
|
3760
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3678
3761
|
});
|
3679
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3680
|
-
return
|
3762
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3763
|
+
return {
|
3764
|
+
records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
|
3765
|
+
totalCount
|
3766
|
+
};
|
3681
3767
|
});
|
3682
3768
|
}
|
3683
3769
|
async aggregate(aggs, filter) {
|
3684
|
-
return __privateGet$
|
3770
|
+
return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
|
3685
3771
|
const result = await aggregateTable({
|
3686
3772
|
pathParams: {
|
3687
3773
|
workspace: "{workspaceId}",
|
3688
3774
|
dbBranchName: "{dbBranch}",
|
3689
3775
|
region: "{region}",
|
3690
|
-
tableName: __privateGet$
|
3776
|
+
tableName: __privateGet$3(this, _table)
|
3691
3777
|
},
|
3692
3778
|
body: { aggs, filter },
|
3693
|
-
...__privateGet$
|
3779
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3694
3780
|
});
|
3695
3781
|
return result;
|
3696
3782
|
});
|
3697
3783
|
}
|
3698
3784
|
async query(query) {
|
3699
|
-
return __privateGet$
|
3785
|
+
return __privateGet$3(this, _trace).call(this, "query", async () => {
|
3700
3786
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
3701
3787
|
if (cacheQuery)
|
3702
3788
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
@@ -3706,7 +3792,7 @@ class RestRepository extends Query {
|
|
3706
3792
|
workspace: "{workspaceId}",
|
3707
3793
|
dbBranchName: "{dbBranch}",
|
3708
3794
|
region: "{region}",
|
3709
|
-
tableName: __privateGet$
|
3795
|
+
tableName: __privateGet$3(this, _table)
|
3710
3796
|
},
|
3711
3797
|
body: {
|
3712
3798
|
filter: cleanFilter(data.filter),
|
@@ -3716,14 +3802,14 @@ class RestRepository extends Query {
|
|
3716
3802
|
consistency: data.consistency
|
3717
3803
|
},
|
3718
3804
|
fetchOptions: data.fetchOptions,
|
3719
|
-
...__privateGet$
|
3805
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3720
3806
|
});
|
3721
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3807
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3722
3808
|
const records = objects.map(
|
3723
3809
|
(record) => initObject(
|
3724
|
-
__privateGet$
|
3810
|
+
__privateGet$3(this, _db),
|
3725
3811
|
schemaTables,
|
3726
|
-
__privateGet$
|
3812
|
+
__privateGet$3(this, _table),
|
3727
3813
|
record,
|
3728
3814
|
data.columns ?? ["*"]
|
3729
3815
|
)
|
@@ -3733,14 +3819,14 @@ class RestRepository extends Query {
|
|
3733
3819
|
});
|
3734
3820
|
}
|
3735
3821
|
async summarizeTable(query, summaries, summariesFilter) {
|
3736
|
-
return __privateGet$
|
3822
|
+
return __privateGet$3(this, _trace).call(this, "summarize", async () => {
|
3737
3823
|
const data = query.getQueryOptions();
|
3738
3824
|
const result = await summarizeTable({
|
3739
3825
|
pathParams: {
|
3740
3826
|
workspace: "{workspaceId}",
|
3741
3827
|
dbBranchName: "{dbBranch}",
|
3742
3828
|
region: "{region}",
|
3743
|
-
tableName: __privateGet$
|
3829
|
+
tableName: __privateGet$3(this, _table)
|
3744
3830
|
},
|
3745
3831
|
body: {
|
3746
3832
|
filter: cleanFilter(data.filter),
|
@@ -3751,13 +3837,13 @@ class RestRepository extends Query {
|
|
3751
3837
|
summaries,
|
3752
3838
|
summariesFilter
|
3753
3839
|
},
|
3754
|
-
...__privateGet$
|
3840
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3755
3841
|
});
|
3756
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3842
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3757
3843
|
return {
|
3758
3844
|
...result,
|
3759
3845
|
summaries: result.summaries.map(
|
3760
|
-
(summary) => initObject(__privateGet$
|
3846
|
+
(summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
|
3761
3847
|
)
|
3762
3848
|
};
|
3763
3849
|
});
|
@@ -3769,7 +3855,7 @@ class RestRepository extends Query {
|
|
3769
3855
|
workspace: "{workspaceId}",
|
3770
3856
|
dbBranchName: "{dbBranch}",
|
3771
3857
|
region: "{region}",
|
3772
|
-
tableName: __privateGet$
|
3858
|
+
tableName: __privateGet$3(this, _table),
|
3773
3859
|
sessionId: options?.sessionId
|
3774
3860
|
},
|
3775
3861
|
body: {
|
@@ -3779,7 +3865,7 @@ class RestRepository extends Query {
|
|
3779
3865
|
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3780
3866
|
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3781
3867
|
},
|
3782
|
-
...__privateGet$
|
3868
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3783
3869
|
};
|
3784
3870
|
if (options?.onMessage) {
|
3785
3871
|
fetchSSERequest({
|
@@ -3800,7 +3886,7 @@ _table = new WeakMap();
|
|
3800
3886
|
_getFetchProps = new WeakMap();
|
3801
3887
|
_db = new WeakMap();
|
3802
3888
|
_cache = new WeakMap();
|
3803
|
-
_schemaTables
|
3889
|
+
_schemaTables = new WeakMap();
|
3804
3890
|
_trace = new WeakMap();
|
3805
3891
|
_insertRecordWithoutId = new WeakSet();
|
3806
3892
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
@@ -3810,14 +3896,14 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
3810
3896
|
workspace: "{workspaceId}",
|
3811
3897
|
dbBranchName: "{dbBranch}",
|
3812
3898
|
region: "{region}",
|
3813
|
-
tableName: __privateGet$
|
3899
|
+
tableName: __privateGet$3(this, _table)
|
3814
3900
|
},
|
3815
3901
|
queryParams: { columns },
|
3816
3902
|
body: record,
|
3817
|
-
...__privateGet$
|
3903
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3818
3904
|
});
|
3819
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3820
|
-
return initObject(__privateGet$
|
3905
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3906
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3821
3907
|
};
|
3822
3908
|
_insertRecordWithId = new WeakSet();
|
3823
3909
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
@@ -3829,21 +3915,21 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
3829
3915
|
workspace: "{workspaceId}",
|
3830
3916
|
dbBranchName: "{dbBranch}",
|
3831
3917
|
region: "{region}",
|
3832
|
-
tableName: __privateGet$
|
3918
|
+
tableName: __privateGet$3(this, _table),
|
3833
3919
|
recordId
|
3834
3920
|
},
|
3835
3921
|
body: record,
|
3836
3922
|
queryParams: { createOnly, columns, ifVersion },
|
3837
|
-
...__privateGet$
|
3923
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3838
3924
|
});
|
3839
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3840
|
-
return initObject(__privateGet$
|
3925
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3926
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3841
3927
|
};
|
3842
3928
|
_insertRecords = new WeakSet();
|
3843
3929
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3844
3930
|
const operations = await promiseMap(objects, async (object) => {
|
3845
3931
|
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3846
|
-
return { insert: { table: __privateGet$
|
3932
|
+
return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
|
3847
3933
|
});
|
3848
3934
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3849
3935
|
const ids = [];
|
@@ -3855,7 +3941,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3855
3941
|
region: "{region}"
|
3856
3942
|
},
|
3857
3943
|
body: { operations: operations2 },
|
3858
|
-
...__privateGet$
|
3944
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3859
3945
|
});
|
3860
3946
|
for (const result of results) {
|
3861
3947
|
if (result.operation === "insert") {
|
@@ -3878,15 +3964,15 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3878
3964
|
workspace: "{workspaceId}",
|
3879
3965
|
dbBranchName: "{dbBranch}",
|
3880
3966
|
region: "{region}",
|
3881
|
-
tableName: __privateGet$
|
3967
|
+
tableName: __privateGet$3(this, _table),
|
3882
3968
|
recordId
|
3883
3969
|
},
|
3884
3970
|
queryParams: { columns, ifVersion },
|
3885
3971
|
body: record,
|
3886
|
-
...__privateGet$
|
3972
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3887
3973
|
});
|
3888
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3889
|
-
return initObject(__privateGet$
|
3974
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3975
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3890
3976
|
} catch (e) {
|
3891
3977
|
if (isObject(e) && e.status === 404) {
|
3892
3978
|
return null;
|
@@ -3898,7 +3984,7 @@ _updateRecords = new WeakSet();
|
|
3898
3984
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3899
3985
|
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3900
3986
|
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3901
|
-
return { update: { table: __privateGet$
|
3987
|
+
return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
|
3902
3988
|
});
|
3903
3989
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3904
3990
|
const ids = [];
|
@@ -3910,7 +3996,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3910
3996
|
region: "{region}"
|
3911
3997
|
},
|
3912
3998
|
body: { operations: operations2 },
|
3913
|
-
...__privateGet$
|
3999
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3914
4000
|
});
|
3915
4001
|
for (const result of results) {
|
3916
4002
|
if (result.operation === "update") {
|
@@ -3931,15 +4017,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3931
4017
|
workspace: "{workspaceId}",
|
3932
4018
|
dbBranchName: "{dbBranch}",
|
3933
4019
|
region: "{region}",
|
3934
|
-
tableName: __privateGet$
|
4020
|
+
tableName: __privateGet$3(this, _table),
|
3935
4021
|
recordId
|
3936
4022
|
},
|
3937
4023
|
queryParams: { columns, ifVersion },
|
3938
4024
|
body: object,
|
3939
|
-
...__privateGet$
|
4025
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3940
4026
|
});
|
3941
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3942
|
-
return initObject(__privateGet$
|
4027
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4028
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3943
4029
|
};
|
3944
4030
|
_deleteRecord = new WeakSet();
|
3945
4031
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
@@ -3951,14 +4037,14 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
3951
4037
|
workspace: "{workspaceId}",
|
3952
4038
|
dbBranchName: "{dbBranch}",
|
3953
4039
|
region: "{region}",
|
3954
|
-
tableName: __privateGet$
|
4040
|
+
tableName: __privateGet$3(this, _table),
|
3955
4041
|
recordId
|
3956
4042
|
},
|
3957
4043
|
queryParams: { columns },
|
3958
|
-
...__privateGet$
|
4044
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3959
4045
|
});
|
3960
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3961
|
-
return initObject(__privateGet$
|
4046
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4047
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3962
4048
|
} catch (e) {
|
3963
4049
|
if (isObject(e) && e.status === 404) {
|
3964
4050
|
return null;
|
@@ -3969,7 +4055,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
3969
4055
|
_deleteRecords = new WeakSet();
|
3970
4056
|
deleteRecords_fn = async function(recordIds) {
|
3971
4057
|
const chunkedOperations = chunk(
|
3972
|
-
compact(recordIds).map((id) => ({ delete: { table: __privateGet$
|
4058
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
|
3973
4059
|
BULK_OPERATION_MAX_SIZE
|
3974
4060
|
);
|
3975
4061
|
for (const operations of chunkedOperations) {
|
@@ -3980,44 +4066,44 @@ deleteRecords_fn = async function(recordIds) {
|
|
3980
4066
|
region: "{region}"
|
3981
4067
|
},
|
3982
4068
|
body: { operations },
|
3983
|
-
...__privateGet$
|
4069
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3984
4070
|
});
|
3985
4071
|
}
|
3986
4072
|
};
|
3987
4073
|
_setCacheQuery = new WeakSet();
|
3988
4074
|
setCacheQuery_fn = async function(query, meta, records) {
|
3989
|
-
await __privateGet$
|
4075
|
+
await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
3990
4076
|
};
|
3991
4077
|
_getCacheQuery = new WeakSet();
|
3992
4078
|
getCacheQuery_fn = async function(query) {
|
3993
|
-
const key = `query_${__privateGet$
|
3994
|
-
const result = await __privateGet$
|
4079
|
+
const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
|
4080
|
+
const result = await __privateGet$3(this, _cache)?.get(key);
|
3995
4081
|
if (!result)
|
3996
4082
|
return null;
|
3997
|
-
const defaultTTL = __privateGet$
|
4083
|
+
const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
|
3998
4084
|
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
3999
4085
|
if (ttl < 0)
|
4000
4086
|
return null;
|
4001
4087
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
4002
4088
|
return hasExpired ? null : result;
|
4003
4089
|
};
|
4004
|
-
_getSchemaTables
|
4005
|
-
getSchemaTables_fn
|
4006
|
-
if (__privateGet$
|
4007
|
-
return __privateGet$
|
4090
|
+
_getSchemaTables = new WeakSet();
|
4091
|
+
getSchemaTables_fn = async function() {
|
4092
|
+
if (__privateGet$3(this, _schemaTables))
|
4093
|
+
return __privateGet$3(this, _schemaTables);
|
4008
4094
|
const { schema } = await getBranchDetails({
|
4009
4095
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4010
|
-
...__privateGet$
|
4096
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4011
4097
|
});
|
4012
|
-
__privateSet$
|
4098
|
+
__privateSet$2(this, _schemaTables, schema.tables);
|
4013
4099
|
return schema.tables;
|
4014
4100
|
};
|
4015
4101
|
_transformObjectToApi = new WeakSet();
|
4016
4102
|
transformObjectToApi_fn = async function(object) {
|
4017
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
4018
|
-
const schema = schemaTables.find((table) => table.name === __privateGet$
|
4103
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4104
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
|
4019
4105
|
if (!schema)
|
4020
|
-
throw new Error(`Table ${__privateGet$
|
4106
|
+
throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
|
4021
4107
|
const result = {};
|
4022
4108
|
for (const [key, value] of Object.entries(object)) {
|
4023
4109
|
if (key === "xata")
|
@@ -4173,7 +4259,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
4173
4259
|
if (!member.has(obj))
|
4174
4260
|
throw TypeError("Cannot " + msg);
|
4175
4261
|
};
|
4176
|
-
var __privateGet$
|
4262
|
+
var __privateGet$2 = (obj, member, getter) => {
|
4177
4263
|
__accessCheck$3(obj, member, "read from private field");
|
4178
4264
|
return getter ? getter.call(obj) : member.get(obj);
|
4179
4265
|
};
|
@@ -4182,7 +4268,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
4182
4268
|
throw TypeError("Cannot add the same private member more than once");
|
4183
4269
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4184
4270
|
};
|
4185
|
-
var __privateSet$
|
4271
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
4186
4272
|
__accessCheck$3(obj, member, "write to private field");
|
4187
4273
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
4188
4274
|
return value;
|
@@ -4191,29 +4277,29 @@ var _map;
|
|
4191
4277
|
class SimpleCache {
|
4192
4278
|
constructor(options = {}) {
|
4193
4279
|
__privateAdd$3(this, _map, void 0);
|
4194
|
-
__privateSet$
|
4280
|
+
__privateSet$1(this, _map, /* @__PURE__ */ new Map());
|
4195
4281
|
this.capacity = options.max ?? 500;
|
4196
4282
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
4197
4283
|
}
|
4198
4284
|
async getAll() {
|
4199
|
-
return Object.fromEntries(__privateGet$
|
4285
|
+
return Object.fromEntries(__privateGet$2(this, _map));
|
4200
4286
|
}
|
4201
4287
|
async get(key) {
|
4202
|
-
return __privateGet$
|
4288
|
+
return __privateGet$2(this, _map).get(key) ?? null;
|
4203
4289
|
}
|
4204
4290
|
async set(key, value) {
|
4205
4291
|
await this.delete(key);
|
4206
|
-
__privateGet$
|
4207
|
-
if (__privateGet$
|
4208
|
-
const leastRecentlyUsed = __privateGet$
|
4292
|
+
__privateGet$2(this, _map).set(key, value);
|
4293
|
+
if (__privateGet$2(this, _map).size > this.capacity) {
|
4294
|
+
const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
|
4209
4295
|
await this.delete(leastRecentlyUsed);
|
4210
4296
|
}
|
4211
4297
|
}
|
4212
4298
|
async delete(key) {
|
4213
|
-
__privateGet$
|
4299
|
+
__privateGet$2(this, _map).delete(key);
|
4214
4300
|
}
|
4215
4301
|
async clear() {
|
4216
|
-
return __privateGet$
|
4302
|
+
return __privateGet$2(this, _map).clear();
|
4217
4303
|
}
|
4218
4304
|
}
|
4219
4305
|
_map = new WeakMap();
|
@@ -4250,7 +4336,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
4250
4336
|
if (!member.has(obj))
|
4251
4337
|
throw TypeError("Cannot " + msg);
|
4252
4338
|
};
|
4253
|
-
var __privateGet$
|
4339
|
+
var __privateGet$1 = (obj, member, getter) => {
|
4254
4340
|
__accessCheck$2(obj, member, "read from private field");
|
4255
4341
|
return getter ? getter.call(obj) : member.get(obj);
|
4256
4342
|
};
|
@@ -4259,18 +4345,11 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
4259
4345
|
throw TypeError("Cannot add the same private member more than once");
|
4260
4346
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4261
4347
|
};
|
4262
|
-
var
|
4263
|
-
__accessCheck$2(obj, member, "write to private field");
|
4264
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
4265
|
-
return value;
|
4266
|
-
};
|
4267
|
-
var _tables, _schemaTables$1;
|
4348
|
+
var _tables;
|
4268
4349
|
class SchemaPlugin extends XataPlugin {
|
4269
|
-
constructor(
|
4350
|
+
constructor() {
|
4270
4351
|
super();
|
4271
4352
|
__privateAdd$2(this, _tables, {});
|
4272
|
-
__privateAdd$2(this, _schemaTables$1, void 0);
|
4273
|
-
__privateSet$2(this, _schemaTables$1, schemaTables);
|
4274
4353
|
}
|
4275
4354
|
build(pluginOptions) {
|
4276
4355
|
const db = new Proxy(
|
@@ -4279,22 +4358,21 @@ class SchemaPlugin extends XataPlugin {
|
|
4279
4358
|
get: (_target, table) => {
|
4280
4359
|
if (!isString(table))
|
4281
4360
|
throw new Error("Invalid table name");
|
4282
|
-
if (__privateGet$
|
4283
|
-
__privateGet$
|
4361
|
+
if (__privateGet$1(this, _tables)[table] === void 0) {
|
4362
|
+
__privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4284
4363
|
}
|
4285
|
-
return __privateGet$
|
4364
|
+
return __privateGet$1(this, _tables)[table];
|
4286
4365
|
}
|
4287
4366
|
}
|
4288
4367
|
);
|
4289
|
-
const tableNames =
|
4368
|
+
const tableNames = pluginOptions.tables?.map(({ name }) => name) ?? [];
|
4290
4369
|
for (const table of tableNames) {
|
4291
|
-
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables:
|
4370
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4292
4371
|
}
|
4293
4372
|
return db;
|
4294
4373
|
}
|
4295
4374
|
}
|
4296
4375
|
_tables = new WeakMap();
|
4297
|
-
_schemaTables$1 = new WeakMap();
|
4298
4376
|
|
4299
4377
|
class FilesPlugin extends XataPlugin {
|
4300
4378
|
build(pluginOptions) {
|
@@ -4357,7 +4435,7 @@ function getContentType(file) {
|
|
4357
4435
|
if (typeof file === "string") {
|
4358
4436
|
return "text/plain";
|
4359
4437
|
}
|
4360
|
-
if ("mediaType" in file) {
|
4438
|
+
if ("mediaType" in file && file.mediaType !== void 0) {
|
4361
4439
|
return file.mediaType;
|
4362
4440
|
}
|
4363
4441
|
if (isBlob(file)) {
|
@@ -4374,79 +4452,57 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
4374
4452
|
if (!member.has(obj))
|
4375
4453
|
throw TypeError("Cannot " + msg);
|
4376
4454
|
};
|
4377
|
-
var __privateGet$1 = (obj, member, getter) => {
|
4378
|
-
__accessCheck$1(obj, member, "read from private field");
|
4379
|
-
return getter ? getter.call(obj) : member.get(obj);
|
4380
|
-
};
|
4381
4455
|
var __privateAdd$1 = (obj, member, value) => {
|
4382
4456
|
if (member.has(obj))
|
4383
4457
|
throw TypeError("Cannot add the same private member more than once");
|
4384
4458
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4385
4459
|
};
|
4386
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
4387
|
-
__accessCheck$1(obj, member, "write to private field");
|
4388
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
4389
|
-
return value;
|
4390
|
-
};
|
4391
4460
|
var __privateMethod$1 = (obj, member, method) => {
|
4392
4461
|
__accessCheck$1(obj, member, "access private method");
|
4393
4462
|
return method;
|
4394
4463
|
};
|
4395
|
-
var
|
4464
|
+
var _search, search_fn;
|
4396
4465
|
class SearchPlugin extends XataPlugin {
|
4397
|
-
constructor(db
|
4466
|
+
constructor(db) {
|
4398
4467
|
super();
|
4399
4468
|
this.db = db;
|
4400
4469
|
__privateAdd$1(this, _search);
|
4401
|
-
__privateAdd$1(this, _getSchemaTables);
|
4402
|
-
__privateAdd$1(this, _schemaTables, void 0);
|
4403
|
-
__privateSet$1(this, _schemaTables, schemaTables);
|
4404
4470
|
}
|
4405
4471
|
build(pluginOptions) {
|
4406
4472
|
return {
|
4407
4473
|
all: async (query, options = {}) => {
|
4408
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4409
|
-
|
4410
|
-
|
4411
|
-
|
4412
|
-
|
4413
|
-
|
4474
|
+
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4475
|
+
return {
|
4476
|
+
totalCount,
|
4477
|
+
records: records.map((record) => {
|
4478
|
+
const { table = "orphan" } = record.xata;
|
4479
|
+
return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
|
4480
|
+
})
|
4481
|
+
};
|
4414
4482
|
},
|
4415
4483
|
byTable: async (query, options = {}) => {
|
4416
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4417
|
-
const
|
4418
|
-
return records.reduce((acc, record) => {
|
4484
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4485
|
+
const records = rawRecords.reduce((acc, record) => {
|
4419
4486
|
const { table = "orphan" } = record.xata;
|
4420
4487
|
const items = acc[table] ?? [];
|
4421
|
-
const item = initObject(this.db,
|
4488
|
+
const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
|
4422
4489
|
return { ...acc, [table]: [...items, item] };
|
4423
4490
|
}, {});
|
4491
|
+
return { totalCount, records };
|
4424
4492
|
}
|
4425
4493
|
};
|
4426
4494
|
}
|
4427
4495
|
}
|
4428
|
-
_schemaTables = new WeakMap();
|
4429
4496
|
_search = new WeakSet();
|
4430
4497
|
search_fn = async function(query, options, pluginOptions) {
|
4431
4498
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4432
|
-
const { records } = await searchBranch({
|
4499
|
+
const { records, totalCount } = await searchBranch({
|
4433
4500
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4434
|
-
// @ts-
|
4501
|
+
// @ts-expect-error Filter properties do not match inferred type
|
4435
4502
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4436
4503
|
...pluginOptions
|
4437
4504
|
});
|
4438
|
-
return records;
|
4439
|
-
};
|
4440
|
-
_getSchemaTables = new WeakSet();
|
4441
|
-
getSchemaTables_fn = async function(pluginOptions) {
|
4442
|
-
if (__privateGet$1(this, _schemaTables))
|
4443
|
-
return __privateGet$1(this, _schemaTables);
|
4444
|
-
const { schema } = await getBranchDetails({
|
4445
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4446
|
-
...pluginOptions
|
4447
|
-
});
|
4448
|
-
__privateSet$1(this, _schemaTables, schema.tables);
|
4449
|
-
return schema.tables;
|
4505
|
+
return { records, totalCount };
|
4450
4506
|
};
|
4451
4507
|
|
4452
4508
|
function escapeElement(elementRepresentation) {
|
@@ -4509,17 +4565,26 @@ function prepareParams(param1, param2) {
|
|
4509
4565
|
|
4510
4566
|
class SQLPlugin extends XataPlugin {
|
4511
4567
|
build(pluginOptions) {
|
4512
|
-
return async (
|
4513
|
-
|
4514
|
-
|
4568
|
+
return async (query, ...parameters) => {
|
4569
|
+
if (!isParamsObject(query) && (!isTemplateStringsArray(query) || !Array.isArray(parameters))) {
|
4570
|
+
throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
|
4571
|
+
}
|
4572
|
+
const { statement, params, consistency } = prepareParams(query, parameters);
|
4573
|
+
const { records, warning, columns } = await sqlQuery({
|
4515
4574
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4516
4575
|
body: { statement, params, consistency },
|
4517
4576
|
...pluginOptions
|
4518
4577
|
});
|
4519
|
-
return { records, warning };
|
4578
|
+
return { records, warning, columns };
|
4520
4579
|
};
|
4521
4580
|
}
|
4522
4581
|
}
|
4582
|
+
function isTemplateStringsArray(strings) {
|
4583
|
+
return Array.isArray(strings) && "raw" in strings && Array.isArray(strings.raw);
|
4584
|
+
}
|
4585
|
+
function isParamsObject(params) {
|
4586
|
+
return isObject(params) && "statement" in params;
|
4587
|
+
}
|
4523
4588
|
|
4524
4589
|
class TransactionPlugin extends XataPlugin {
|
4525
4590
|
build(pluginOptions) {
|
@@ -4561,7 +4626,7 @@ var __privateMethod = (obj, member, method) => {
|
|
4561
4626
|
const buildClient = (plugins) => {
|
4562
4627
|
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
4563
4628
|
return _a = class {
|
4564
|
-
constructor(options = {},
|
4629
|
+
constructor(options = {}, tables) {
|
4565
4630
|
__privateAdd(this, _parseOptions);
|
4566
4631
|
__privateAdd(this, _getFetchProps);
|
4567
4632
|
__privateAdd(this, _options, void 0);
|
@@ -4570,13 +4635,15 @@ const buildClient = (plugins) => {
|
|
4570
4635
|
const pluginOptions = {
|
4571
4636
|
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
4572
4637
|
cache: safeOptions.cache,
|
4573
|
-
host: safeOptions.host
|
4638
|
+
host: safeOptions.host,
|
4639
|
+
tables
|
4574
4640
|
};
|
4575
|
-
const db = new SchemaPlugin(
|
4576
|
-
const search = new SearchPlugin(db
|
4641
|
+
const db = new SchemaPlugin().build(pluginOptions);
|
4642
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
4577
4643
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4578
4644
|
const sql = new SQLPlugin().build(pluginOptions);
|
4579
4645
|
const files = new FilesPlugin().build(pluginOptions);
|
4646
|
+
this.schema = { tables };
|
4580
4647
|
this.db = db;
|
4581
4648
|
this.search = search;
|
4582
4649
|
this.transactions = transactions;
|
@@ -4745,21 +4812,6 @@ const deserialize = (json) => {
|
|
4745
4812
|
return defaultSerializer.fromJSON(json);
|
4746
4813
|
};
|
4747
4814
|
|
4748
|
-
function buildWorkerRunner(config) {
|
4749
|
-
return function xataWorker(name, worker) {
|
4750
|
-
return async (...args) => {
|
4751
|
-
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
4752
|
-
const result = await fetch(url, {
|
4753
|
-
method: "POST",
|
4754
|
-
headers: { "Content-Type": "application/json" },
|
4755
|
-
body: serialize({ args })
|
4756
|
-
});
|
4757
|
-
const text = await result.text();
|
4758
|
-
return deserialize(text);
|
4759
|
-
};
|
4760
|
-
};
|
4761
|
-
}
|
4762
|
-
|
4763
4815
|
class XataError extends Error {
|
4764
4816
|
constructor(message, status) {
|
4765
4817
|
super(message);
|
@@ -4797,13 +4849,13 @@ exports.addGitBranchesEntry = addGitBranchesEntry;
|
|
4797
4849
|
exports.addTableColumn = addTableColumn;
|
4798
4850
|
exports.aggregateTable = aggregateTable;
|
4799
4851
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4852
|
+
exports.applyMigration = applyMigration;
|
4800
4853
|
exports.askTable = askTable;
|
4801
4854
|
exports.askTableSession = askTableSession;
|
4802
4855
|
exports.branchTransaction = branchTransaction;
|
4803
4856
|
exports.buildClient = buildClient;
|
4804
4857
|
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4805
4858
|
exports.buildProviderString = buildProviderString;
|
4806
|
-
exports.buildWorkerRunner = buildWorkerRunner;
|
4807
4859
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
4808
4860
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
4809
4861
|
exports.compareBranchSchemas = compareBranchSchemas;
|
@@ -4837,6 +4889,7 @@ exports.equals = equals;
|
|
4837
4889
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
4838
4890
|
exports.exists = exists;
|
4839
4891
|
exports.fileAccess = fileAccess;
|
4892
|
+
exports.fileUpload = fileUpload;
|
4840
4893
|
exports.ge = ge;
|
4841
4894
|
exports.getAPIKey = getAPIKey;
|
4842
4895
|
exports.getAuthorizationCode = getAuthorizationCode;
|
@@ -4911,6 +4964,9 @@ exports.operationsByTag = operationsByTag;
|
|
4911
4964
|
exports.parseProviderString = parseProviderString;
|
4912
4965
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
4913
4966
|
exports.pattern = pattern;
|
4967
|
+
exports.pgRollJobStatus = pgRollJobStatus;
|
4968
|
+
exports.pgRollMigrationHistory = pgRollMigrationHistory;
|
4969
|
+
exports.pgRollStatus = pgRollStatus;
|
4914
4970
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4915
4971
|
exports.pushBranchMigrations = pushBranchMigrations;
|
4916
4972
|
exports.putFile = putFile;
|