@xata.io/client 0.0.0-alpha.vfa1407e → 0.0.0-alpha.vfa28b1a26eb487667b028e1c2059dcef8e362bdb
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 +83 -1
- package/dist/index.cjs +288 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3164 -2558
- package/dist/index.mjs +276 -311
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -244,12 +244,6 @@ function getPreviewBranch() {
|
|
244
244
|
}
|
245
245
|
}
|
246
246
|
|
247
|
-
var __defProp$8 = Object.defineProperty;
|
248
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
249
|
-
var __publicField$8 = (obj, key, value) => {
|
250
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
251
|
-
return value;
|
252
|
-
};
|
253
247
|
var __accessCheck$8 = (obj, member, msg) => {
|
254
248
|
if (!member.has(obj))
|
255
249
|
throw TypeError("Cannot " + msg);
|
@@ -289,8 +283,6 @@ class ApiRequestPool {
|
|
289
283
|
__privateAdd$8(this, _fetch, void 0);
|
290
284
|
__privateAdd$8(this, _queue, void 0);
|
291
285
|
__privateAdd$8(this, _concurrency, void 0);
|
292
|
-
__publicField$8(this, "running");
|
293
|
-
__publicField$8(this, "started");
|
294
286
|
__privateSet$8(this, _queue, []);
|
295
287
|
__privateSet$8(this, _concurrency, concurrency);
|
296
288
|
this.running = 0;
|
@@ -536,26 +528,16 @@ function defaultOnOpen(response) {
|
|
536
528
|
}
|
537
529
|
}
|
538
530
|
|
539
|
-
const VERSION = "0.
|
531
|
+
const VERSION = "0.28.4";
|
540
532
|
|
541
|
-
var __defProp$7 = Object.defineProperty;
|
542
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
543
|
-
var __publicField$7 = (obj, key, value) => {
|
544
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
545
|
-
return value;
|
546
|
-
};
|
547
533
|
class ErrorWithCause extends Error {
|
548
534
|
constructor(message, options) {
|
549
535
|
super(message, options);
|
550
|
-
__publicField$7(this, "cause");
|
551
536
|
}
|
552
537
|
}
|
553
538
|
class FetcherError extends ErrorWithCause {
|
554
539
|
constructor(status, data, requestId) {
|
555
540
|
super(getMessage(data));
|
556
|
-
__publicField$7(this, "status");
|
557
|
-
__publicField$7(this, "requestId");
|
558
|
-
__publicField$7(this, "errors");
|
559
541
|
this.status = status;
|
560
542
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
561
543
|
this.requestId = requestId;
|
@@ -589,6 +571,67 @@ function getMessage(data) {
|
|
589
571
|
}
|
590
572
|
}
|
591
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
|
+
|
592
635
|
const pool = new ApiRequestPool();
|
593
636
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
594
637
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -604,6 +647,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
604
647
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
605
648
|
};
|
606
649
|
function buildBaseUrl({
|
650
|
+
method,
|
607
651
|
endpoint,
|
608
652
|
path,
|
609
653
|
workspacesApiUrl,
|
@@ -611,7 +655,24 @@ function buildBaseUrl({
|
|
611
655
|
pathParams = {}
|
612
656
|
}) {
|
613
657
|
if (endpoint === "dataPlane") {
|
614
|
-
|
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
|
+
}
|
615
676
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
616
677
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
617
678
|
}
|
@@ -660,9 +721,9 @@ async function fetch$1({
|
|
660
721
|
return await trace(
|
661
722
|
`${method.toUpperCase()} ${path}`,
|
662
723
|
async ({ setAttributes }) => {
|
663
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
724
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
664
725
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
665
|
-
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
726
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
|
666
727
|
setAttributes({
|
667
728
|
[TraceAttributes.HTTP_URL]: url,
|
668
729
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
@@ -743,7 +804,7 @@ function fetchSSERequest({
|
|
743
804
|
clientName,
|
744
805
|
xataAgentExtra
|
745
806
|
}) {
|
746
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
807
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
747
808
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
748
809
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
749
810
|
void fetchEventSource(url, {
|
@@ -786,6 +847,20 @@ function parseUrl(url) {
|
|
786
847
|
|
787
848
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
788
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 });
|
789
864
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
790
865
|
url: "/dbs/{dbName}",
|
791
866
|
method: "get",
|
@@ -805,6 +880,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
805
880
|
...variables,
|
806
881
|
signal
|
807
882
|
});
|
883
|
+
const getSchema = (variables, signal) => dataPlaneFetch({
|
884
|
+
url: "/db/{dbBranchName}/schema",
|
885
|
+
method: "get",
|
886
|
+
...variables,
|
887
|
+
signal
|
888
|
+
});
|
808
889
|
const copyBranch = (variables, signal) => dataPlaneFetch({
|
809
890
|
url: "/db/{dbBranchName}/copy",
|
810
891
|
method: "post",
|
@@ -986,6 +1067,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
986
1067
|
...variables,
|
987
1068
|
signal
|
988
1069
|
});
|
1070
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1071
|
+
url: "/file/{fileId}",
|
1072
|
+
method: "put",
|
1073
|
+
...variables,
|
1074
|
+
signal
|
1075
|
+
});
|
989
1076
|
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
990
1077
|
url: "/db/{dbBranchName}/sql",
|
991
1078
|
method: "post",
|
@@ -994,6 +1081,10 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
994
1081
|
});
|
995
1082
|
const operationsByTag$2 = {
|
996
1083
|
branch: {
|
1084
|
+
applyMigration,
|
1085
|
+
pgRollStatus,
|
1086
|
+
pgRollJobStatus,
|
1087
|
+
pgRollMigrationHistory,
|
997
1088
|
getBranchList,
|
998
1089
|
getBranchDetails,
|
999
1090
|
createBranch,
|
@@ -1008,6 +1099,7 @@ const operationsByTag$2 = {
|
|
1008
1099
|
resolveBranch
|
1009
1100
|
},
|
1010
1101
|
migrations: {
|
1102
|
+
getSchema,
|
1011
1103
|
getBranchMigrationHistory,
|
1012
1104
|
getBranchMigrationPlan,
|
1013
1105
|
executeBranchMigrationPlan,
|
@@ -1051,7 +1143,7 @@ const operationsByTag$2 = {
|
|
1051
1143
|
deleteRecord,
|
1052
1144
|
bulkInsertTableRecords
|
1053
1145
|
},
|
1054
|
-
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1146
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1055
1147
|
searchAndFilter: {
|
1056
1148
|
queryTable,
|
1057
1149
|
searchBranch,
|
@@ -1173,6 +1265,15 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
1173
1265
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1174
1266
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1175
1267
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1268
|
+
const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
|
1269
|
+
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1270
|
+
const getCluster = (variables, signal) => controlPlaneFetch({
|
1271
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
1272
|
+
method: "get",
|
1273
|
+
...variables,
|
1274
|
+
signal
|
1275
|
+
});
|
1276
|
+
const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
|
1176
1277
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
1177
1278
|
url: "/workspaces/{workspaceId}/dbs",
|
1178
1279
|
method: "get",
|
@@ -1227,6 +1328,7 @@ const operationsByTag$1 = {
|
|
1227
1328
|
acceptWorkspaceMemberInvite,
|
1228
1329
|
resendWorkspaceMemberInvite
|
1229
1330
|
},
|
1331
|
+
xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
|
1230
1332
|
databases: {
|
1231
1333
|
getDatabaseList,
|
1232
1334
|
createDatabase,
|
@@ -1243,61 +1345,6 @@ const operationsByTag$1 = {
|
|
1243
1345
|
|
1244
1346
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1245
1347
|
|
1246
|
-
function getHostUrl(provider, type) {
|
1247
|
-
if (isHostProviderAlias(provider)) {
|
1248
|
-
return providers[provider][type];
|
1249
|
-
} else if (isHostProviderBuilder(provider)) {
|
1250
|
-
return provider[type];
|
1251
|
-
}
|
1252
|
-
throw new Error("Invalid API provider");
|
1253
|
-
}
|
1254
|
-
const providers = {
|
1255
|
-
production: {
|
1256
|
-
main: "https://api.xata.io",
|
1257
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
1258
|
-
},
|
1259
|
-
staging: {
|
1260
|
-
main: "https://api.staging-xata.dev",
|
1261
|
-
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1262
|
-
},
|
1263
|
-
dev: {
|
1264
|
-
main: "https://api.dev-xata.dev",
|
1265
|
-
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1266
|
-
}
|
1267
|
-
};
|
1268
|
-
function isHostProviderAlias(alias) {
|
1269
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
1270
|
-
}
|
1271
|
-
function isHostProviderBuilder(builder) {
|
1272
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
1273
|
-
}
|
1274
|
-
function parseProviderString(provider = "production") {
|
1275
|
-
if (isHostProviderAlias(provider)) {
|
1276
|
-
return provider;
|
1277
|
-
}
|
1278
|
-
const [main, workspaces] = provider.split(",");
|
1279
|
-
if (!main || !workspaces)
|
1280
|
-
return null;
|
1281
|
-
return { main, workspaces };
|
1282
|
-
}
|
1283
|
-
function buildProviderString(provider) {
|
1284
|
-
if (isHostProviderAlias(provider))
|
1285
|
-
return provider;
|
1286
|
-
return `${provider.main},${provider.workspaces}`;
|
1287
|
-
}
|
1288
|
-
function parseWorkspacesUrlParts(url) {
|
1289
|
-
if (!isString(url))
|
1290
|
-
return null;
|
1291
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1292
|
-
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1293
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1294
|
-
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1295
|
-
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1296
|
-
if (!match)
|
1297
|
-
return null;
|
1298
|
-
return { workspace: match[1], region: match[2] };
|
1299
|
-
}
|
1300
|
-
|
1301
1348
|
var __accessCheck$7 = (obj, member, msg) => {
|
1302
1349
|
if (!member.has(obj))
|
1303
1350
|
throw TypeError("Cannot " + msg);
|
@@ -2622,75 +2669,6 @@ class XataApiPlugin {
|
|
2622
2669
|
class XataPlugin {
|
2623
2670
|
}
|
2624
2671
|
|
2625
|
-
class FilesPlugin extends XataPlugin {
|
2626
|
-
build(pluginOptions) {
|
2627
|
-
return {
|
2628
|
-
download: async (location) => {
|
2629
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2630
|
-
return await getFileItem({
|
2631
|
-
pathParams: {
|
2632
|
-
workspace: "{workspaceId}",
|
2633
|
-
dbBranchName: "{dbBranch}",
|
2634
|
-
region: "{region}",
|
2635
|
-
tableName: table ?? "",
|
2636
|
-
recordId: record ?? "",
|
2637
|
-
columnName: column ?? "",
|
2638
|
-
fileId
|
2639
|
-
},
|
2640
|
-
...pluginOptions,
|
2641
|
-
rawResponse: true
|
2642
|
-
});
|
2643
|
-
},
|
2644
|
-
upload: async (location, file) => {
|
2645
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2646
|
-
const contentType = getContentType(file);
|
2647
|
-
return await putFileItem({
|
2648
|
-
...pluginOptions,
|
2649
|
-
pathParams: {
|
2650
|
-
workspace: "{workspaceId}",
|
2651
|
-
dbBranchName: "{dbBranch}",
|
2652
|
-
region: "{region}",
|
2653
|
-
tableName: table ?? "",
|
2654
|
-
recordId: record ?? "",
|
2655
|
-
columnName: column ?? "",
|
2656
|
-
fileId
|
2657
|
-
},
|
2658
|
-
body: file,
|
2659
|
-
headers: { "Content-Type": contentType }
|
2660
|
-
});
|
2661
|
-
},
|
2662
|
-
delete: async (location) => {
|
2663
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2664
|
-
return await deleteFileItem({
|
2665
|
-
pathParams: {
|
2666
|
-
workspace: "{workspaceId}",
|
2667
|
-
dbBranchName: "{dbBranch}",
|
2668
|
-
region: "{region}",
|
2669
|
-
tableName: table ?? "",
|
2670
|
-
recordId: record ?? "",
|
2671
|
-
columnName: column ?? "",
|
2672
|
-
fileId
|
2673
|
-
},
|
2674
|
-
...pluginOptions
|
2675
|
-
});
|
2676
|
-
}
|
2677
|
-
};
|
2678
|
-
}
|
2679
|
-
}
|
2680
|
-
function getContentType(file) {
|
2681
|
-
if (typeof file === "string") {
|
2682
|
-
return "text/plain";
|
2683
|
-
}
|
2684
|
-
if (isBlob(file)) {
|
2685
|
-
return file.type;
|
2686
|
-
}
|
2687
|
-
try {
|
2688
|
-
return file.type;
|
2689
|
-
} catch (e) {
|
2690
|
-
}
|
2691
|
-
return "application/octet-stream";
|
2692
|
-
}
|
2693
|
-
|
2694
2672
|
function buildTransformString(transformations) {
|
2695
2673
|
return transformations.flatMap(
|
2696
2674
|
(t) => Object.entries(t).map(([key, value]) => {
|
@@ -2719,69 +2697,21 @@ function transformImage(url, ...transformations) {
|
|
2719
2697
|
return `https://${hostname}${transform}${path}${search}`;
|
2720
2698
|
}
|
2721
2699
|
|
2722
|
-
var __defProp$6 = Object.defineProperty;
|
2723
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2724
|
-
var __publicField$6 = (obj, key, value) => {
|
2725
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2726
|
-
return value;
|
2727
|
-
};
|
2728
2700
|
class XataFile {
|
2729
2701
|
constructor(file) {
|
2730
|
-
/**
|
2731
|
-
* Identifier of the file.
|
2732
|
-
*/
|
2733
|
-
__publicField$6(this, "id");
|
2734
|
-
/**
|
2735
|
-
* Name of the file.
|
2736
|
-
*/
|
2737
|
-
__publicField$6(this, "name");
|
2738
|
-
/**
|
2739
|
-
* Media type of the file.
|
2740
|
-
*/
|
2741
|
-
__publicField$6(this, "mediaType");
|
2742
|
-
/**
|
2743
|
-
* Base64 encoded content of the file.
|
2744
|
-
*/
|
2745
|
-
__publicField$6(this, "base64Content");
|
2746
|
-
/**
|
2747
|
-
* Whether to enable public url for the file.
|
2748
|
-
*/
|
2749
|
-
__publicField$6(this, "enablePublicUrl");
|
2750
|
-
/**
|
2751
|
-
* Timeout for the signed url.
|
2752
|
-
*/
|
2753
|
-
__publicField$6(this, "signedUrlTimeout");
|
2754
|
-
/**
|
2755
|
-
* Size of the file.
|
2756
|
-
*/
|
2757
|
-
__publicField$6(this, "size");
|
2758
|
-
/**
|
2759
|
-
* Version of the file.
|
2760
|
-
*/
|
2761
|
-
__publicField$6(this, "version");
|
2762
|
-
/**
|
2763
|
-
* Url of the file.
|
2764
|
-
*/
|
2765
|
-
__publicField$6(this, "url");
|
2766
|
-
/**
|
2767
|
-
* Signed url of the file.
|
2768
|
-
*/
|
2769
|
-
__publicField$6(this, "signedUrl");
|
2770
|
-
/**
|
2771
|
-
* Attributes of the file.
|
2772
|
-
*/
|
2773
|
-
__publicField$6(this, "attributes");
|
2774
2702
|
this.id = file.id;
|
2775
|
-
this.name = file.name
|
2776
|
-
this.mediaType = file.mediaType
|
2703
|
+
this.name = file.name;
|
2704
|
+
this.mediaType = file.mediaType;
|
2777
2705
|
this.base64Content = file.base64Content;
|
2778
|
-
this.enablePublicUrl = file.enablePublicUrl
|
2779
|
-
this.signedUrlTimeout = file.signedUrlTimeout
|
2780
|
-
this.
|
2781
|
-
this.
|
2782
|
-
this.
|
2706
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2707
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2708
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2709
|
+
this.size = file.size;
|
2710
|
+
this.version = file.version;
|
2711
|
+
this.url = file.url;
|
2783
2712
|
this.signedUrl = file.signedUrl;
|
2784
|
-
this.
|
2713
|
+
this.uploadUrl = file.uploadUrl;
|
2714
|
+
this.attributes = file.attributes;
|
2785
2715
|
}
|
2786
2716
|
static fromBuffer(buffer, options = {}) {
|
2787
2717
|
const base64Content = buffer.toString("base64");
|
@@ -2871,7 +2801,7 @@ class XataFile {
|
|
2871
2801
|
const parseInputFileEntry = async (entry) => {
|
2872
2802
|
if (!isDefined(entry))
|
2873
2803
|
return null;
|
2874
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2804
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2875
2805
|
return compactObject({
|
2876
2806
|
id,
|
2877
2807
|
// Name cannot be an empty string in our API
|
@@ -2879,7 +2809,8 @@ const parseInputFileEntry = async (entry) => {
|
|
2879
2809
|
mediaType,
|
2880
2810
|
base64Content,
|
2881
2811
|
enablePublicUrl,
|
2882
|
-
signedUrlTimeout
|
2812
|
+
signedUrlTimeout,
|
2813
|
+
uploadUrlTimeout
|
2883
2814
|
});
|
2884
2815
|
};
|
2885
2816
|
|
@@ -2929,12 +2860,6 @@ function parseJson(value) {
|
|
2929
2860
|
}
|
2930
2861
|
}
|
2931
2862
|
|
2932
|
-
var __defProp$5 = Object.defineProperty;
|
2933
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2934
|
-
var __publicField$5 = (obj, key, value) => {
|
2935
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2936
|
-
return value;
|
2937
|
-
};
|
2938
2863
|
var __accessCheck$6 = (obj, member, msg) => {
|
2939
2864
|
if (!member.has(obj))
|
2940
2865
|
throw TypeError("Cannot " + msg);
|
@@ -2957,14 +2882,6 @@ var _query, _page;
|
|
2957
2882
|
class Page {
|
2958
2883
|
constructor(query, meta, records = []) {
|
2959
2884
|
__privateAdd$6(this, _query, void 0);
|
2960
|
-
/**
|
2961
|
-
* Page metadata, required to retrieve additional records.
|
2962
|
-
*/
|
2963
|
-
__publicField$5(this, "meta");
|
2964
|
-
/**
|
2965
|
-
* The set of results for this page.
|
2966
|
-
*/
|
2967
|
-
__publicField$5(this, "records");
|
2968
2885
|
__privateSet$6(this, _query, query);
|
2969
2886
|
this.meta = meta;
|
2970
2887
|
this.records = new RecordArray(this, records);
|
@@ -3014,9 +2931,9 @@ class Page {
|
|
3014
2931
|
}
|
3015
2932
|
}
|
3016
2933
|
_query = new WeakMap();
|
3017
|
-
const PAGINATION_MAX_SIZE =
|
2934
|
+
const PAGINATION_MAX_SIZE = 1e3;
|
3018
2935
|
const PAGINATION_DEFAULT_SIZE = 20;
|
3019
|
-
const PAGINATION_MAX_OFFSET =
|
2936
|
+
const PAGINATION_MAX_OFFSET = 49e3;
|
3020
2937
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
3021
2938
|
function isCursorPaginationOptions(options) {
|
3022
2939
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
@@ -3095,12 +3012,6 @@ const _RecordArray = class _RecordArray extends Array {
|
|
3095
3012
|
_page = new WeakMap();
|
3096
3013
|
let RecordArray = _RecordArray;
|
3097
3014
|
|
3098
|
-
var __defProp$4 = Object.defineProperty;
|
3099
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3100
|
-
var __publicField$4 = (obj, key, value) => {
|
3101
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3102
|
-
return value;
|
3103
|
-
};
|
3104
3015
|
var __accessCheck$5 = (obj, member, msg) => {
|
3105
3016
|
if (!member.has(obj))
|
3106
3017
|
throw TypeError("Cannot " + msg);
|
@@ -3131,8 +3042,8 @@ const _Query = class _Query {
|
|
3131
3042
|
__privateAdd$5(this, _repository, void 0);
|
3132
3043
|
__privateAdd$5(this, _data, { filter: {} });
|
3133
3044
|
// Implements pagination
|
3134
|
-
|
3135
|
-
|
3045
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3046
|
+
this.records = new RecordArray(this, []);
|
3136
3047
|
__privateSet$5(this, _table$1, table);
|
3137
3048
|
if (repository) {
|
3138
3049
|
__privateSet$5(this, _repository, repository);
|
@@ -3383,7 +3294,6 @@ const RecordColumnTypes = [
|
|
3383
3294
|
"email",
|
3384
3295
|
"multiple",
|
3385
3296
|
"link",
|
3386
|
-
"object",
|
3387
3297
|
"datetime",
|
3388
3298
|
"vector",
|
3389
3299
|
"file[]",
|
@@ -3770,7 +3680,7 @@ class RestRepository extends Query {
|
|
3770
3680
|
}
|
3771
3681
|
async search(query, options = {}) {
|
3772
3682
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
3773
|
-
const { records } = await searchTable({
|
3683
|
+
const { records, totalCount } = await searchTable({
|
3774
3684
|
pathParams: {
|
3775
3685
|
workspace: "{workspaceId}",
|
3776
3686
|
dbBranchName: "{dbBranch}",
|
@@ -3790,12 +3700,15 @@ class RestRepository extends Query {
|
|
3790
3700
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3791
3701
|
});
|
3792
3702
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3793
|
-
return
|
3703
|
+
return {
|
3704
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3705
|
+
totalCount
|
3706
|
+
};
|
3794
3707
|
});
|
3795
3708
|
}
|
3796
3709
|
async vectorSearch(column, query, options) {
|
3797
3710
|
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3798
|
-
const { records } = await vectorSearchTable({
|
3711
|
+
const { records, totalCount } = await vectorSearchTable({
|
3799
3712
|
pathParams: {
|
3800
3713
|
workspace: "{workspaceId}",
|
3801
3714
|
dbBranchName: "{dbBranch}",
|
@@ -3812,7 +3725,10 @@ class RestRepository extends Query {
|
|
3812
3725
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3813
3726
|
});
|
3814
3727
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3815
|
-
return
|
3728
|
+
return {
|
3729
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3730
|
+
totalCount
|
3731
|
+
};
|
3816
3732
|
});
|
3817
3733
|
}
|
3818
3734
|
async aggregate(aggs, filter) {
|
@@ -3888,7 +3804,13 @@ class RestRepository extends Query {
|
|
3888
3804
|
},
|
3889
3805
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3890
3806
|
});
|
3891
|
-
|
3807
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3808
|
+
return {
|
3809
|
+
...result,
|
3810
|
+
summaries: result.summaries.map(
|
3811
|
+
(summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
|
3812
|
+
)
|
3813
|
+
};
|
3892
3814
|
});
|
3893
3815
|
}
|
3894
3816
|
ask(question, options) {
|
@@ -4176,13 +4098,6 @@ transformObjectToApi_fn = async function(object) {
|
|
4176
4098
|
}
|
4177
4099
|
return result;
|
4178
4100
|
};
|
4179
|
-
const removeLinksFromObject = (object) => {
|
4180
|
-
return Object.entries(object).reduce((acc, [key, value]) => {
|
4181
|
-
if (key === "xata")
|
4182
|
-
return acc;
|
4183
|
-
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
4184
|
-
}, {});
|
4185
|
-
};
|
4186
4101
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
4187
4102
|
const data = {};
|
4188
4103
|
const { xata, ...rest } = object ?? {};
|
@@ -4249,7 +4164,6 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4249
4164
|
}
|
4250
4165
|
}
|
4251
4166
|
const record = { ...data };
|
4252
|
-
const serializable = { xata, ...removeLinksFromObject(data) };
|
4253
4167
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
4254
4168
|
record.read = function(columns2) {
|
4255
4169
|
return db[table].read(record["id"], columns2);
|
@@ -4267,15 +4181,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4267
4181
|
record.delete = function() {
|
4268
4182
|
return db[table].delete(record["id"]);
|
4269
4183
|
};
|
4270
|
-
|
4184
|
+
if (metadata !== void 0) {
|
4185
|
+
record.xata = Object.freeze(metadata);
|
4186
|
+
}
|
4271
4187
|
record.getMetadata = function() {
|
4272
4188
|
return record.xata;
|
4273
4189
|
};
|
4274
4190
|
record.toSerializable = function() {
|
4275
|
-
return JSON.parse(JSON.stringify(
|
4191
|
+
return JSON.parse(JSON.stringify(record));
|
4276
4192
|
};
|
4277
4193
|
record.toString = function() {
|
4278
|
-
return JSON.stringify(
|
4194
|
+
return JSON.stringify(record);
|
4279
4195
|
};
|
4280
4196
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
4281
4197
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -4304,12 +4220,6 @@ function parseIfVersion(...args) {
|
|
4304
4220
|
return void 0;
|
4305
4221
|
}
|
4306
4222
|
|
4307
|
-
var __defProp$3 = Object.defineProperty;
|
4308
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4309
|
-
var __publicField$3 = (obj, key, value) => {
|
4310
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4311
|
-
return value;
|
4312
|
-
};
|
4313
4223
|
var __accessCheck$3 = (obj, member, msg) => {
|
4314
4224
|
if (!member.has(obj))
|
4315
4225
|
throw TypeError("Cannot " + msg);
|
@@ -4332,8 +4242,6 @@ var _map;
|
|
4332
4242
|
class SimpleCache {
|
4333
4243
|
constructor(options = {}) {
|
4334
4244
|
__privateAdd$3(this, _map, void 0);
|
4335
|
-
__publicField$3(this, "capacity");
|
4336
|
-
__publicField$3(this, "defaultQueryTTL");
|
4337
4245
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
4338
4246
|
this.capacity = options.max ?? 500;
|
4339
4247
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -4378,10 +4286,12 @@ const notExists = (column) => ({ $notExists: column });
|
|
4378
4286
|
const startsWith = (value) => ({ $startsWith: value });
|
4379
4287
|
const endsWith = (value) => ({ $endsWith: value });
|
4380
4288
|
const pattern = (value) => ({ $pattern: value });
|
4289
|
+
const iPattern = (value) => ({ $iPattern: value });
|
4381
4290
|
const is = (value) => ({ $is: value });
|
4382
4291
|
const equals = is;
|
4383
4292
|
const isNot = (value) => ({ $isNot: value });
|
4384
4293
|
const contains = (value) => ({ $contains: value });
|
4294
|
+
const iContains = (value) => ({ $iContains: value });
|
4385
4295
|
const includes = (value) => ({ $includes: value });
|
4386
4296
|
const includesAll = (value) => ({ $includesAll: value });
|
4387
4297
|
const includesNone = (value) => ({ $includesNone: value });
|
@@ -4437,6 +4347,80 @@ class SchemaPlugin extends XataPlugin {
|
|
4437
4347
|
_tables = new WeakMap();
|
4438
4348
|
_schemaTables$1 = new WeakMap();
|
4439
4349
|
|
4350
|
+
class FilesPlugin extends XataPlugin {
|
4351
|
+
build(pluginOptions) {
|
4352
|
+
return {
|
4353
|
+
download: async (location) => {
|
4354
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4355
|
+
return await getFileItem({
|
4356
|
+
pathParams: {
|
4357
|
+
workspace: "{workspaceId}",
|
4358
|
+
dbBranchName: "{dbBranch}",
|
4359
|
+
region: "{region}",
|
4360
|
+
tableName: table ?? "",
|
4361
|
+
recordId: record ?? "",
|
4362
|
+
columnName: column ?? "",
|
4363
|
+
fileId
|
4364
|
+
},
|
4365
|
+
...pluginOptions,
|
4366
|
+
rawResponse: true
|
4367
|
+
});
|
4368
|
+
},
|
4369
|
+
upload: async (location, file, options) => {
|
4370
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4371
|
+
const resolvedFile = await file;
|
4372
|
+
const contentType = options?.mediaType || getContentType(resolvedFile);
|
4373
|
+
const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
|
4374
|
+
return await putFileItem({
|
4375
|
+
...pluginOptions,
|
4376
|
+
pathParams: {
|
4377
|
+
workspace: "{workspaceId}",
|
4378
|
+
dbBranchName: "{dbBranch}",
|
4379
|
+
region: "{region}",
|
4380
|
+
tableName: table ?? "",
|
4381
|
+
recordId: record ?? "",
|
4382
|
+
columnName: column ?? "",
|
4383
|
+
fileId
|
4384
|
+
},
|
4385
|
+
body,
|
4386
|
+
headers: { "Content-Type": contentType }
|
4387
|
+
});
|
4388
|
+
},
|
4389
|
+
delete: async (location) => {
|
4390
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4391
|
+
return await deleteFileItem({
|
4392
|
+
pathParams: {
|
4393
|
+
workspace: "{workspaceId}",
|
4394
|
+
dbBranchName: "{dbBranch}",
|
4395
|
+
region: "{region}",
|
4396
|
+
tableName: table ?? "",
|
4397
|
+
recordId: record ?? "",
|
4398
|
+
columnName: column ?? "",
|
4399
|
+
fileId
|
4400
|
+
},
|
4401
|
+
...pluginOptions
|
4402
|
+
});
|
4403
|
+
}
|
4404
|
+
};
|
4405
|
+
}
|
4406
|
+
}
|
4407
|
+
function getContentType(file) {
|
4408
|
+
if (typeof file === "string") {
|
4409
|
+
return "text/plain";
|
4410
|
+
}
|
4411
|
+
if ("mediaType" in file && file.mediaType !== void 0) {
|
4412
|
+
return file.mediaType;
|
4413
|
+
}
|
4414
|
+
if (isBlob(file)) {
|
4415
|
+
return file.type;
|
4416
|
+
}
|
4417
|
+
try {
|
4418
|
+
return file.type;
|
4419
|
+
} catch (e) {
|
4420
|
+
}
|
4421
|
+
return "application/octet-stream";
|
4422
|
+
}
|
4423
|
+
|
4440
4424
|
var __accessCheck$1 = (obj, member, msg) => {
|
4441
4425
|
if (!member.has(obj))
|
4442
4426
|
throw TypeError("Cannot " + msg);
|
@@ -4472,22 +4456,26 @@ class SearchPlugin extends XataPlugin {
|
|
4472
4456
|
build(pluginOptions) {
|
4473
4457
|
return {
|
4474
4458
|
all: async (query, options = {}) => {
|
4475
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4459
|
+
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4476
4460
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4477
|
-
return
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4461
|
+
return {
|
4462
|
+
totalCount,
|
4463
|
+
records: records.map((record) => {
|
4464
|
+
const { table = "orphan" } = record.xata;
|
4465
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
4466
|
+
})
|
4467
|
+
};
|
4481
4468
|
},
|
4482
4469
|
byTable: async (query, options = {}) => {
|
4483
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4470
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4484
4471
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4485
|
-
|
4472
|
+
const records = rawRecords.reduce((acc, record) => {
|
4486
4473
|
const { table = "orphan" } = record.xata;
|
4487
4474
|
const items = acc[table] ?? [];
|
4488
4475
|
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
4489
4476
|
return { ...acc, [table]: [...items, item] };
|
4490
4477
|
}, {});
|
4478
|
+
return { totalCount, records };
|
4491
4479
|
}
|
4492
4480
|
};
|
4493
4481
|
}
|
@@ -4496,13 +4484,13 @@ _schemaTables = new WeakMap();
|
|
4496
4484
|
_search = new WeakSet();
|
4497
4485
|
search_fn = async function(query, options, pluginOptions) {
|
4498
4486
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4499
|
-
const { records } = await searchBranch({
|
4487
|
+
const { records, totalCount } = await searchBranch({
|
4500
4488
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4501
4489
|
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
4502
4490
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4503
4491
|
...pluginOptions
|
4504
4492
|
});
|
4505
|
-
return records;
|
4493
|
+
return { records, totalCount };
|
4506
4494
|
};
|
4507
4495
|
_getSchemaTables = new WeakSet();
|
4508
4496
|
getSchemaTables_fn = async function(pluginOptions) {
|
@@ -4576,17 +4564,33 @@ function prepareParams(param1, param2) {
|
|
4576
4564
|
|
4577
4565
|
class SQLPlugin extends XataPlugin {
|
4578
4566
|
build(pluginOptions) {
|
4579
|
-
|
4580
|
-
const { statement, params, consistency } = prepareParams(
|
4581
|
-
const { records, warning } = await sqlQuery({
|
4567
|
+
const query = async (query2, ...parameters) => {
|
4568
|
+
const { statement, params, consistency } = prepareParams(query2, parameters);
|
4569
|
+
const { records, warning, columns } = await sqlQuery({
|
4582
4570
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4583
4571
|
body: { statement, params, consistency },
|
4584
4572
|
...pluginOptions
|
4585
4573
|
});
|
4586
|
-
return { records, warning };
|
4574
|
+
return { records, warning, columns };
|
4587
4575
|
};
|
4576
|
+
const result = async (param1, ...param2) => {
|
4577
|
+
if (!isParamsObject(param1) && (!isTemplateStringsArray(param1) || !Array.isArray(param2))) {
|
4578
|
+
throw new Error(
|
4579
|
+
"Calling `xata.sql` as a function is not safe. Make sure to use it as a tagged template or with an object."
|
4580
|
+
);
|
4581
|
+
}
|
4582
|
+
return await query(param1, ...param2);
|
4583
|
+
};
|
4584
|
+
result.rawUnsafeQuery = query;
|
4585
|
+
return result;
|
4588
4586
|
}
|
4589
4587
|
}
|
4588
|
+
function isTemplateStringsArray(strings) {
|
4589
|
+
return Array.isArray(strings) && "raw" in strings && Array.isArray(strings.raw);
|
4590
|
+
}
|
4591
|
+
function isParamsObject(params) {
|
4592
|
+
return isObject(params) && "statement" in params;
|
4593
|
+
}
|
4590
4594
|
|
4591
4595
|
class TransactionPlugin extends XataPlugin {
|
4592
4596
|
build(pluginOptions) {
|
@@ -4603,12 +4607,6 @@ class TransactionPlugin extends XataPlugin {
|
|
4603
4607
|
}
|
4604
4608
|
}
|
4605
4609
|
|
4606
|
-
var __defProp$2 = Object.defineProperty;
|
4607
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4608
|
-
var __publicField$2 = (obj, key, value) => {
|
4609
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4610
|
-
return value;
|
4611
|
-
};
|
4612
4610
|
var __accessCheck = (obj, member, msg) => {
|
4613
4611
|
if (!member.has(obj))
|
4614
4612
|
throw TypeError("Cannot " + msg);
|
@@ -4638,11 +4636,6 @@ const buildClient = (plugins) => {
|
|
4638
4636
|
__privateAdd(this, _parseOptions);
|
4639
4637
|
__privateAdd(this, _getFetchProps);
|
4640
4638
|
__privateAdd(this, _options, void 0);
|
4641
|
-
__publicField$2(this, "db");
|
4642
|
-
__publicField$2(this, "search");
|
4643
|
-
__publicField$2(this, "transactions");
|
4644
|
-
__publicField$2(this, "sql");
|
4645
|
-
__publicField$2(this, "files");
|
4646
4639
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4647
4640
|
__privateSet(this, _options, safeOptions);
|
4648
4641
|
const pluginOptions = {
|
@@ -4756,17 +4749,11 @@ const buildClient = (plugins) => {
|
|
4756
4749
|
class BaseClient extends buildClient() {
|
4757
4750
|
}
|
4758
4751
|
|
4759
|
-
var __defProp$1 = Object.defineProperty;
|
4760
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4761
|
-
var __publicField$1 = (obj, key, value) => {
|
4762
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4763
|
-
return value;
|
4764
|
-
};
|
4765
4752
|
const META = "__";
|
4766
4753
|
const VALUE = "___";
|
4767
4754
|
class Serializer {
|
4768
4755
|
constructor() {
|
4769
|
-
|
4756
|
+
this.classes = {};
|
4770
4757
|
}
|
4771
4758
|
add(clazz) {
|
4772
4759
|
this.classes[clazz.name] = clazz;
|
@@ -4829,31 +4816,9 @@ const deserialize = (json) => {
|
|
4829
4816
|
return defaultSerializer.fromJSON(json);
|
4830
4817
|
};
|
4831
4818
|
|
4832
|
-
function buildWorkerRunner(config) {
|
4833
|
-
return function xataWorker(name, worker) {
|
4834
|
-
return async (...args) => {
|
4835
|
-
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
4836
|
-
const result = await fetch(url, {
|
4837
|
-
method: "POST",
|
4838
|
-
headers: { "Content-Type": "application/json" },
|
4839
|
-
body: serialize({ args })
|
4840
|
-
});
|
4841
|
-
const text = await result.text();
|
4842
|
-
return deserialize(text);
|
4843
|
-
};
|
4844
|
-
};
|
4845
|
-
}
|
4846
|
-
|
4847
|
-
var __defProp = Object.defineProperty;
|
4848
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4849
|
-
var __publicField = (obj, key, value) => {
|
4850
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4851
|
-
return value;
|
4852
|
-
};
|
4853
4819
|
class XataError extends Error {
|
4854
4820
|
constructor(message, status) {
|
4855
4821
|
super(message);
|
4856
|
-
__publicField(this, "status");
|
4857
4822
|
this.status = status;
|
4858
4823
|
}
|
4859
4824
|
}
|
@@ -4877,6 +4842,7 @@ exports.SchemaPlugin = SchemaPlugin;
|
|
4877
4842
|
exports.SearchPlugin = SearchPlugin;
|
4878
4843
|
exports.Serializer = Serializer;
|
4879
4844
|
exports.SimpleCache = SimpleCache;
|
4845
|
+
exports.TransactionPlugin = TransactionPlugin;
|
4880
4846
|
exports.XataApiClient = XataApiClient;
|
4881
4847
|
exports.XataApiPlugin = XataApiPlugin;
|
4882
4848
|
exports.XataError = XataError;
|
@@ -4887,13 +4853,13 @@ exports.addGitBranchesEntry = addGitBranchesEntry;
|
|
4887
4853
|
exports.addTableColumn = addTableColumn;
|
4888
4854
|
exports.aggregateTable = aggregateTable;
|
4889
4855
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4856
|
+
exports.applyMigration = applyMigration;
|
4890
4857
|
exports.askTable = askTable;
|
4891
4858
|
exports.askTableSession = askTableSession;
|
4892
4859
|
exports.branchTransaction = branchTransaction;
|
4893
4860
|
exports.buildClient = buildClient;
|
4894
4861
|
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4895
4862
|
exports.buildProviderString = buildProviderString;
|
4896
|
-
exports.buildWorkerRunner = buildWorkerRunner;
|
4897
4863
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
4898
4864
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
4899
4865
|
exports.compareBranchSchemas = compareBranchSchemas;
|
@@ -4902,6 +4868,7 @@ exports.compareMigrationRequest = compareMigrationRequest;
|
|
4902
4868
|
exports.contains = contains;
|
4903
4869
|
exports.copyBranch = copyBranch;
|
4904
4870
|
exports.createBranch = createBranch;
|
4871
|
+
exports.createCluster = createCluster;
|
4905
4872
|
exports.createDatabase = createDatabase;
|
4906
4873
|
exports.createMigrationRequest = createMigrationRequest;
|
4907
4874
|
exports.createTable = createTable;
|
@@ -4926,6 +4893,7 @@ exports.equals = equals;
|
|
4926
4893
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
4927
4894
|
exports.exists = exists;
|
4928
4895
|
exports.fileAccess = fileAccess;
|
4896
|
+
exports.fileUpload = fileUpload;
|
4929
4897
|
exports.ge = ge;
|
4930
4898
|
exports.getAPIKey = getAPIKey;
|
4931
4899
|
exports.getAuthorizationCode = getAuthorizationCode;
|
@@ -4937,6 +4905,7 @@ exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
|
4937
4905
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
4938
4906
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
4939
4907
|
exports.getBranchStats = getBranchStats;
|
4908
|
+
exports.getCluster = getCluster;
|
4940
4909
|
exports.getColumn = getColumn;
|
4941
4910
|
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
4942
4911
|
exports.getDatabaseList = getDatabaseList;
|
@@ -4950,6 +4919,7 @@ exports.getMigrationRequest = getMigrationRequest;
|
|
4950
4919
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
4951
4920
|
exports.getPreviewBranch = getPreviewBranch;
|
4952
4921
|
exports.getRecord = getRecord;
|
4922
|
+
exports.getSchema = getSchema;
|
4953
4923
|
exports.getTableColumns = getTableColumns;
|
4954
4924
|
exports.getTableSchema = getTableSchema;
|
4955
4925
|
exports.getUser = getUser;
|
@@ -4965,6 +4935,8 @@ exports.greaterThan = greaterThan;
|
|
4965
4935
|
exports.greaterThanEquals = greaterThanEquals;
|
4966
4936
|
exports.gt = gt;
|
4967
4937
|
exports.gte = gte;
|
4938
|
+
exports.iContains = iContains;
|
4939
|
+
exports.iPattern = iPattern;
|
4968
4940
|
exports.includes = includes;
|
4969
4941
|
exports.includesAll = includesAll;
|
4970
4942
|
exports.includesAny = includesAny;
|
@@ -4985,6 +4957,7 @@ exports.le = le;
|
|
4985
4957
|
exports.lessEquals = lessEquals;
|
4986
4958
|
exports.lessThan = lessThan;
|
4987
4959
|
exports.lessThanEquals = lessThanEquals;
|
4960
|
+
exports.listClusters = listClusters;
|
4988
4961
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
4989
4962
|
exports.listRegions = listRegions;
|
4990
4963
|
exports.lt = lt;
|
@@ -4995,6 +4968,9 @@ exports.operationsByTag = operationsByTag;
|
|
4995
4968
|
exports.parseProviderString = parseProviderString;
|
4996
4969
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
4997
4970
|
exports.pattern = pattern;
|
4971
|
+
exports.pgRollJobStatus = pgRollJobStatus;
|
4972
|
+
exports.pgRollMigrationHistory = pgRollMigrationHistory;
|
4973
|
+
exports.pgRollStatus = pgRollStatus;
|
4998
4974
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4999
4975
|
exports.pushBranchMigrations = pushBranchMigrations;
|
5000
4976
|
exports.putFile = putFile;
|
@@ -5016,6 +4992,7 @@ exports.summarizeTable = summarizeTable;
|
|
5016
4992
|
exports.transformImage = transformImage;
|
5017
4993
|
exports.updateBranchMetadata = updateBranchMetadata;
|
5018
4994
|
exports.updateBranchSchema = updateBranchSchema;
|
4995
|
+
exports.updateCluster = updateCluster;
|
5019
4996
|
exports.updateColumn = updateColumn;
|
5020
4997
|
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
5021
4998
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|