@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.mjs
CHANGED
@@ -242,12 +242,6 @@ function getPreviewBranch() {
|
|
242
242
|
}
|
243
243
|
}
|
244
244
|
|
245
|
-
var __defProp$8 = Object.defineProperty;
|
246
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
247
|
-
var __publicField$8 = (obj, key, value) => {
|
248
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
249
|
-
return value;
|
250
|
-
};
|
251
245
|
var __accessCheck$8 = (obj, member, msg) => {
|
252
246
|
if (!member.has(obj))
|
253
247
|
throw TypeError("Cannot " + msg);
|
@@ -287,8 +281,6 @@ class ApiRequestPool {
|
|
287
281
|
__privateAdd$8(this, _fetch, void 0);
|
288
282
|
__privateAdd$8(this, _queue, void 0);
|
289
283
|
__privateAdd$8(this, _concurrency, void 0);
|
290
|
-
__publicField$8(this, "running");
|
291
|
-
__publicField$8(this, "started");
|
292
284
|
__privateSet$8(this, _queue, []);
|
293
285
|
__privateSet$8(this, _concurrency, concurrency);
|
294
286
|
this.running = 0;
|
@@ -534,26 +526,16 @@ function defaultOnOpen(response) {
|
|
534
526
|
}
|
535
527
|
}
|
536
528
|
|
537
|
-
const VERSION = "0.
|
529
|
+
const VERSION = "0.28.4";
|
538
530
|
|
539
|
-
var __defProp$7 = Object.defineProperty;
|
540
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
541
|
-
var __publicField$7 = (obj, key, value) => {
|
542
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
543
|
-
return value;
|
544
|
-
};
|
545
531
|
class ErrorWithCause extends Error {
|
546
532
|
constructor(message, options) {
|
547
533
|
super(message, options);
|
548
|
-
__publicField$7(this, "cause");
|
549
534
|
}
|
550
535
|
}
|
551
536
|
class FetcherError extends ErrorWithCause {
|
552
537
|
constructor(status, data, requestId) {
|
553
538
|
super(getMessage(data));
|
554
|
-
__publicField$7(this, "status");
|
555
|
-
__publicField$7(this, "requestId");
|
556
|
-
__publicField$7(this, "errors");
|
557
539
|
this.status = status;
|
558
540
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
559
541
|
this.requestId = requestId;
|
@@ -587,6 +569,67 @@ function getMessage(data) {
|
|
587
569
|
}
|
588
570
|
}
|
589
571
|
|
572
|
+
function getHostUrl(provider, type) {
|
573
|
+
if (isHostProviderAlias(provider)) {
|
574
|
+
return providers[provider][type];
|
575
|
+
} else if (isHostProviderBuilder(provider)) {
|
576
|
+
return provider[type];
|
577
|
+
}
|
578
|
+
throw new Error("Invalid API provider");
|
579
|
+
}
|
580
|
+
const providers = {
|
581
|
+
production: {
|
582
|
+
main: "https://api.xata.io",
|
583
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
584
|
+
},
|
585
|
+
staging: {
|
586
|
+
main: "https://api.staging-xata.dev",
|
587
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
588
|
+
},
|
589
|
+
dev: {
|
590
|
+
main: "https://api.dev-xata.dev",
|
591
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
592
|
+
},
|
593
|
+
local: {
|
594
|
+
main: "http://localhost:6001",
|
595
|
+
workspaces: "http://{workspaceId}.{region}.localhost:6001"
|
596
|
+
}
|
597
|
+
};
|
598
|
+
function isHostProviderAlias(alias) {
|
599
|
+
return isString(alias) && Object.keys(providers).includes(alias);
|
600
|
+
}
|
601
|
+
function isHostProviderBuilder(builder) {
|
602
|
+
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
603
|
+
}
|
604
|
+
function parseProviderString(provider = "production") {
|
605
|
+
if (isHostProviderAlias(provider)) {
|
606
|
+
return provider;
|
607
|
+
}
|
608
|
+
const [main, workspaces] = provider.split(",");
|
609
|
+
if (!main || !workspaces)
|
610
|
+
return null;
|
611
|
+
return { main, workspaces };
|
612
|
+
}
|
613
|
+
function buildProviderString(provider) {
|
614
|
+
if (isHostProviderAlias(provider))
|
615
|
+
return provider;
|
616
|
+
return `${provider.main},${provider.workspaces}`;
|
617
|
+
}
|
618
|
+
function parseWorkspacesUrlParts(url) {
|
619
|
+
if (!isString(url))
|
620
|
+
return null;
|
621
|
+
const matches = {
|
622
|
+
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/),
|
623
|
+
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/),
|
624
|
+
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/),
|
625
|
+
local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(\d+)/)
|
626
|
+
};
|
627
|
+
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
628
|
+
if (!isHostProviderAlias(host) || !match)
|
629
|
+
return null;
|
630
|
+
return { workspace: match[1], region: match[2], host };
|
631
|
+
}
|
632
|
+
|
590
633
|
const pool = new ApiRequestPool();
|
591
634
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
592
635
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -602,6 +645,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
602
645
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
603
646
|
};
|
604
647
|
function buildBaseUrl({
|
648
|
+
method,
|
605
649
|
endpoint,
|
606
650
|
path,
|
607
651
|
workspacesApiUrl,
|
@@ -609,7 +653,24 @@ function buildBaseUrl({
|
|
609
653
|
pathParams = {}
|
610
654
|
}) {
|
611
655
|
if (endpoint === "dataPlane") {
|
612
|
-
|
656
|
+
let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
657
|
+
if (method.toUpperCase() === "PUT" && [
|
658
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
659
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
|
660
|
+
].includes(path)) {
|
661
|
+
const { host } = parseWorkspacesUrlParts(url) ?? {};
|
662
|
+
switch (host) {
|
663
|
+
case "production":
|
664
|
+
url = url.replace("xata.sh", "upload.xata.sh");
|
665
|
+
break;
|
666
|
+
case "staging":
|
667
|
+
url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
|
668
|
+
break;
|
669
|
+
case "dev":
|
670
|
+
url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
|
671
|
+
break;
|
672
|
+
}
|
673
|
+
}
|
613
674
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
614
675
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
615
676
|
}
|
@@ -658,9 +719,9 @@ async function fetch$1({
|
|
658
719
|
return await trace(
|
659
720
|
`${method.toUpperCase()} ${path}`,
|
660
721
|
async ({ setAttributes }) => {
|
661
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
722
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
662
723
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
663
|
-
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
724
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
|
664
725
|
setAttributes({
|
665
726
|
[TraceAttributes.HTTP_URL]: url,
|
666
727
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
@@ -741,7 +802,7 @@ function fetchSSERequest({
|
|
741
802
|
clientName,
|
742
803
|
xataAgentExtra
|
743
804
|
}) {
|
744
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
805
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
745
806
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
746
807
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
747
808
|
void fetchEventSource(url, {
|
@@ -784,6 +845,20 @@ function parseUrl(url) {
|
|
784
845
|
|
785
846
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
786
847
|
|
848
|
+
const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
|
849
|
+
const pgRollStatus = (variables, signal) => dataPlaneFetch({
|
850
|
+
url: "/db/{dbBranchName}/pgroll/status",
|
851
|
+
method: "get",
|
852
|
+
...variables,
|
853
|
+
signal
|
854
|
+
});
|
855
|
+
const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
|
856
|
+
url: "/db/{dbBranchName}/pgroll/jobs/{jobId}",
|
857
|
+
method: "get",
|
858
|
+
...variables,
|
859
|
+
signal
|
860
|
+
});
|
861
|
+
const pgRollMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/migrations", method: "get", ...variables, signal });
|
787
862
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
788
863
|
url: "/dbs/{dbName}",
|
789
864
|
method: "get",
|
@@ -803,6 +878,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
803
878
|
...variables,
|
804
879
|
signal
|
805
880
|
});
|
881
|
+
const getSchema = (variables, signal) => dataPlaneFetch({
|
882
|
+
url: "/db/{dbBranchName}/schema",
|
883
|
+
method: "get",
|
884
|
+
...variables,
|
885
|
+
signal
|
886
|
+
});
|
806
887
|
const copyBranch = (variables, signal) => dataPlaneFetch({
|
807
888
|
url: "/db/{dbBranchName}/copy",
|
808
889
|
method: "post",
|
@@ -984,6 +1065,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
984
1065
|
...variables,
|
985
1066
|
signal
|
986
1067
|
});
|
1068
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1069
|
+
url: "/file/{fileId}",
|
1070
|
+
method: "put",
|
1071
|
+
...variables,
|
1072
|
+
signal
|
1073
|
+
});
|
987
1074
|
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
988
1075
|
url: "/db/{dbBranchName}/sql",
|
989
1076
|
method: "post",
|
@@ -992,6 +1079,10 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
992
1079
|
});
|
993
1080
|
const operationsByTag$2 = {
|
994
1081
|
branch: {
|
1082
|
+
applyMigration,
|
1083
|
+
pgRollStatus,
|
1084
|
+
pgRollJobStatus,
|
1085
|
+
pgRollMigrationHistory,
|
995
1086
|
getBranchList,
|
996
1087
|
getBranchDetails,
|
997
1088
|
createBranch,
|
@@ -1006,6 +1097,7 @@ const operationsByTag$2 = {
|
|
1006
1097
|
resolveBranch
|
1007
1098
|
},
|
1008
1099
|
migrations: {
|
1100
|
+
getSchema,
|
1009
1101
|
getBranchMigrationHistory,
|
1010
1102
|
getBranchMigrationPlan,
|
1011
1103
|
executeBranchMigrationPlan,
|
@@ -1049,7 +1141,7 @@ const operationsByTag$2 = {
|
|
1049
1141
|
deleteRecord,
|
1050
1142
|
bulkInsertTableRecords
|
1051
1143
|
},
|
1052
|
-
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1144
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1053
1145
|
searchAndFilter: {
|
1054
1146
|
queryTable,
|
1055
1147
|
searchBranch,
|
@@ -1171,6 +1263,15 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
1171
1263
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1172
1264
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1173
1265
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1266
|
+
const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
|
1267
|
+
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1268
|
+
const getCluster = (variables, signal) => controlPlaneFetch({
|
1269
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
1270
|
+
method: "get",
|
1271
|
+
...variables,
|
1272
|
+
signal
|
1273
|
+
});
|
1274
|
+
const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
|
1174
1275
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
1175
1276
|
url: "/workspaces/{workspaceId}/dbs",
|
1176
1277
|
method: "get",
|
@@ -1225,6 +1326,7 @@ const operationsByTag$1 = {
|
|
1225
1326
|
acceptWorkspaceMemberInvite,
|
1226
1327
|
resendWorkspaceMemberInvite
|
1227
1328
|
},
|
1329
|
+
xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
|
1228
1330
|
databases: {
|
1229
1331
|
getDatabaseList,
|
1230
1332
|
createDatabase,
|
@@ -1241,61 +1343,6 @@ const operationsByTag$1 = {
|
|
1241
1343
|
|
1242
1344
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1243
1345
|
|
1244
|
-
function getHostUrl(provider, type) {
|
1245
|
-
if (isHostProviderAlias(provider)) {
|
1246
|
-
return providers[provider][type];
|
1247
|
-
} else if (isHostProviderBuilder(provider)) {
|
1248
|
-
return provider[type];
|
1249
|
-
}
|
1250
|
-
throw new Error("Invalid API provider");
|
1251
|
-
}
|
1252
|
-
const providers = {
|
1253
|
-
production: {
|
1254
|
-
main: "https://api.xata.io",
|
1255
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
1256
|
-
},
|
1257
|
-
staging: {
|
1258
|
-
main: "https://api.staging-xata.dev",
|
1259
|
-
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1260
|
-
},
|
1261
|
-
dev: {
|
1262
|
-
main: "https://api.dev-xata.dev",
|
1263
|
-
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1264
|
-
}
|
1265
|
-
};
|
1266
|
-
function isHostProviderAlias(alias) {
|
1267
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
1268
|
-
}
|
1269
|
-
function isHostProviderBuilder(builder) {
|
1270
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
1271
|
-
}
|
1272
|
-
function parseProviderString(provider = "production") {
|
1273
|
-
if (isHostProviderAlias(provider)) {
|
1274
|
-
return provider;
|
1275
|
-
}
|
1276
|
-
const [main, workspaces] = provider.split(",");
|
1277
|
-
if (!main || !workspaces)
|
1278
|
-
return null;
|
1279
|
-
return { main, workspaces };
|
1280
|
-
}
|
1281
|
-
function buildProviderString(provider) {
|
1282
|
-
if (isHostProviderAlias(provider))
|
1283
|
-
return provider;
|
1284
|
-
return `${provider.main},${provider.workspaces}`;
|
1285
|
-
}
|
1286
|
-
function parseWorkspacesUrlParts(url) {
|
1287
|
-
if (!isString(url))
|
1288
|
-
return null;
|
1289
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1290
|
-
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1291
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1292
|
-
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1293
|
-
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1294
|
-
if (!match)
|
1295
|
-
return null;
|
1296
|
-
return { workspace: match[1], region: match[2] };
|
1297
|
-
}
|
1298
|
-
|
1299
1346
|
var __accessCheck$7 = (obj, member, msg) => {
|
1300
1347
|
if (!member.has(obj))
|
1301
1348
|
throw TypeError("Cannot " + msg);
|
@@ -2620,75 +2667,6 @@ class XataApiPlugin {
|
|
2620
2667
|
class XataPlugin {
|
2621
2668
|
}
|
2622
2669
|
|
2623
|
-
class FilesPlugin extends XataPlugin {
|
2624
|
-
build(pluginOptions) {
|
2625
|
-
return {
|
2626
|
-
download: async (location) => {
|
2627
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2628
|
-
return await getFileItem({
|
2629
|
-
pathParams: {
|
2630
|
-
workspace: "{workspaceId}",
|
2631
|
-
dbBranchName: "{dbBranch}",
|
2632
|
-
region: "{region}",
|
2633
|
-
tableName: table ?? "",
|
2634
|
-
recordId: record ?? "",
|
2635
|
-
columnName: column ?? "",
|
2636
|
-
fileId
|
2637
|
-
},
|
2638
|
-
...pluginOptions,
|
2639
|
-
rawResponse: true
|
2640
|
-
});
|
2641
|
-
},
|
2642
|
-
upload: async (location, file) => {
|
2643
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2644
|
-
const contentType = getContentType(file);
|
2645
|
-
return await putFileItem({
|
2646
|
-
...pluginOptions,
|
2647
|
-
pathParams: {
|
2648
|
-
workspace: "{workspaceId}",
|
2649
|
-
dbBranchName: "{dbBranch}",
|
2650
|
-
region: "{region}",
|
2651
|
-
tableName: table ?? "",
|
2652
|
-
recordId: record ?? "",
|
2653
|
-
columnName: column ?? "",
|
2654
|
-
fileId
|
2655
|
-
},
|
2656
|
-
body: file,
|
2657
|
-
headers: { "Content-Type": contentType }
|
2658
|
-
});
|
2659
|
-
},
|
2660
|
-
delete: async (location) => {
|
2661
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2662
|
-
return await deleteFileItem({
|
2663
|
-
pathParams: {
|
2664
|
-
workspace: "{workspaceId}",
|
2665
|
-
dbBranchName: "{dbBranch}",
|
2666
|
-
region: "{region}",
|
2667
|
-
tableName: table ?? "",
|
2668
|
-
recordId: record ?? "",
|
2669
|
-
columnName: column ?? "",
|
2670
|
-
fileId
|
2671
|
-
},
|
2672
|
-
...pluginOptions
|
2673
|
-
});
|
2674
|
-
}
|
2675
|
-
};
|
2676
|
-
}
|
2677
|
-
}
|
2678
|
-
function getContentType(file) {
|
2679
|
-
if (typeof file === "string") {
|
2680
|
-
return "text/plain";
|
2681
|
-
}
|
2682
|
-
if (isBlob(file)) {
|
2683
|
-
return file.type;
|
2684
|
-
}
|
2685
|
-
try {
|
2686
|
-
return file.type;
|
2687
|
-
} catch (e) {
|
2688
|
-
}
|
2689
|
-
return "application/octet-stream";
|
2690
|
-
}
|
2691
|
-
|
2692
2670
|
function buildTransformString(transformations) {
|
2693
2671
|
return transformations.flatMap(
|
2694
2672
|
(t) => Object.entries(t).map(([key, value]) => {
|
@@ -2717,69 +2695,21 @@ function transformImage(url, ...transformations) {
|
|
2717
2695
|
return `https://${hostname}${transform}${path}${search}`;
|
2718
2696
|
}
|
2719
2697
|
|
2720
|
-
var __defProp$6 = Object.defineProperty;
|
2721
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2722
|
-
var __publicField$6 = (obj, key, value) => {
|
2723
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2724
|
-
return value;
|
2725
|
-
};
|
2726
2698
|
class XataFile {
|
2727
2699
|
constructor(file) {
|
2728
|
-
/**
|
2729
|
-
* Identifier of the file.
|
2730
|
-
*/
|
2731
|
-
__publicField$6(this, "id");
|
2732
|
-
/**
|
2733
|
-
* Name of the file.
|
2734
|
-
*/
|
2735
|
-
__publicField$6(this, "name");
|
2736
|
-
/**
|
2737
|
-
* Media type of the file.
|
2738
|
-
*/
|
2739
|
-
__publicField$6(this, "mediaType");
|
2740
|
-
/**
|
2741
|
-
* Base64 encoded content of the file.
|
2742
|
-
*/
|
2743
|
-
__publicField$6(this, "base64Content");
|
2744
|
-
/**
|
2745
|
-
* Whether to enable public url for the file.
|
2746
|
-
*/
|
2747
|
-
__publicField$6(this, "enablePublicUrl");
|
2748
|
-
/**
|
2749
|
-
* Timeout for the signed url.
|
2750
|
-
*/
|
2751
|
-
__publicField$6(this, "signedUrlTimeout");
|
2752
|
-
/**
|
2753
|
-
* Size of the file.
|
2754
|
-
*/
|
2755
|
-
__publicField$6(this, "size");
|
2756
|
-
/**
|
2757
|
-
* Version of the file.
|
2758
|
-
*/
|
2759
|
-
__publicField$6(this, "version");
|
2760
|
-
/**
|
2761
|
-
* Url of the file.
|
2762
|
-
*/
|
2763
|
-
__publicField$6(this, "url");
|
2764
|
-
/**
|
2765
|
-
* Signed url of the file.
|
2766
|
-
*/
|
2767
|
-
__publicField$6(this, "signedUrl");
|
2768
|
-
/**
|
2769
|
-
* Attributes of the file.
|
2770
|
-
*/
|
2771
|
-
__publicField$6(this, "attributes");
|
2772
2700
|
this.id = file.id;
|
2773
|
-
this.name = file.name
|
2774
|
-
this.mediaType = file.mediaType
|
2701
|
+
this.name = file.name;
|
2702
|
+
this.mediaType = file.mediaType;
|
2775
2703
|
this.base64Content = file.base64Content;
|
2776
|
-
this.enablePublicUrl = file.enablePublicUrl
|
2777
|
-
this.signedUrlTimeout = file.signedUrlTimeout
|
2778
|
-
this.
|
2779
|
-
this.
|
2780
|
-
this.
|
2704
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2705
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2706
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2707
|
+
this.size = file.size;
|
2708
|
+
this.version = file.version;
|
2709
|
+
this.url = file.url;
|
2781
2710
|
this.signedUrl = file.signedUrl;
|
2782
|
-
this.
|
2711
|
+
this.uploadUrl = file.uploadUrl;
|
2712
|
+
this.attributes = file.attributes;
|
2783
2713
|
}
|
2784
2714
|
static fromBuffer(buffer, options = {}) {
|
2785
2715
|
const base64Content = buffer.toString("base64");
|
@@ -2869,7 +2799,7 @@ class XataFile {
|
|
2869
2799
|
const parseInputFileEntry = async (entry) => {
|
2870
2800
|
if (!isDefined(entry))
|
2871
2801
|
return null;
|
2872
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2802
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2873
2803
|
return compactObject({
|
2874
2804
|
id,
|
2875
2805
|
// Name cannot be an empty string in our API
|
@@ -2877,7 +2807,8 @@ const parseInputFileEntry = async (entry) => {
|
|
2877
2807
|
mediaType,
|
2878
2808
|
base64Content,
|
2879
2809
|
enablePublicUrl,
|
2880
|
-
signedUrlTimeout
|
2810
|
+
signedUrlTimeout,
|
2811
|
+
uploadUrlTimeout
|
2881
2812
|
});
|
2882
2813
|
};
|
2883
2814
|
|
@@ -2927,12 +2858,6 @@ function parseJson(value) {
|
|
2927
2858
|
}
|
2928
2859
|
}
|
2929
2860
|
|
2930
|
-
var __defProp$5 = Object.defineProperty;
|
2931
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2932
|
-
var __publicField$5 = (obj, key, value) => {
|
2933
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2934
|
-
return value;
|
2935
|
-
};
|
2936
2861
|
var __accessCheck$6 = (obj, member, msg) => {
|
2937
2862
|
if (!member.has(obj))
|
2938
2863
|
throw TypeError("Cannot " + msg);
|
@@ -2955,14 +2880,6 @@ var _query, _page;
|
|
2955
2880
|
class Page {
|
2956
2881
|
constructor(query, meta, records = []) {
|
2957
2882
|
__privateAdd$6(this, _query, void 0);
|
2958
|
-
/**
|
2959
|
-
* Page metadata, required to retrieve additional records.
|
2960
|
-
*/
|
2961
|
-
__publicField$5(this, "meta");
|
2962
|
-
/**
|
2963
|
-
* The set of results for this page.
|
2964
|
-
*/
|
2965
|
-
__publicField$5(this, "records");
|
2966
2883
|
__privateSet$6(this, _query, query);
|
2967
2884
|
this.meta = meta;
|
2968
2885
|
this.records = new RecordArray(this, records);
|
@@ -3012,9 +2929,9 @@ class Page {
|
|
3012
2929
|
}
|
3013
2930
|
}
|
3014
2931
|
_query = new WeakMap();
|
3015
|
-
const PAGINATION_MAX_SIZE =
|
2932
|
+
const PAGINATION_MAX_SIZE = 1e3;
|
3016
2933
|
const PAGINATION_DEFAULT_SIZE = 20;
|
3017
|
-
const PAGINATION_MAX_OFFSET =
|
2934
|
+
const PAGINATION_MAX_OFFSET = 49e3;
|
3018
2935
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
3019
2936
|
function isCursorPaginationOptions(options) {
|
3020
2937
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
@@ -3093,12 +3010,6 @@ const _RecordArray = class _RecordArray extends Array {
|
|
3093
3010
|
_page = new WeakMap();
|
3094
3011
|
let RecordArray = _RecordArray;
|
3095
3012
|
|
3096
|
-
var __defProp$4 = Object.defineProperty;
|
3097
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3098
|
-
var __publicField$4 = (obj, key, value) => {
|
3099
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3100
|
-
return value;
|
3101
|
-
};
|
3102
3013
|
var __accessCheck$5 = (obj, member, msg) => {
|
3103
3014
|
if (!member.has(obj))
|
3104
3015
|
throw TypeError("Cannot " + msg);
|
@@ -3129,8 +3040,8 @@ const _Query = class _Query {
|
|
3129
3040
|
__privateAdd$5(this, _repository, void 0);
|
3130
3041
|
__privateAdd$5(this, _data, { filter: {} });
|
3131
3042
|
// Implements pagination
|
3132
|
-
|
3133
|
-
|
3043
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3044
|
+
this.records = new RecordArray(this, []);
|
3134
3045
|
__privateSet$5(this, _table$1, table);
|
3135
3046
|
if (repository) {
|
3136
3047
|
__privateSet$5(this, _repository, repository);
|
@@ -3381,7 +3292,6 @@ const RecordColumnTypes = [
|
|
3381
3292
|
"email",
|
3382
3293
|
"multiple",
|
3383
3294
|
"link",
|
3384
|
-
"object",
|
3385
3295
|
"datetime",
|
3386
3296
|
"vector",
|
3387
3297
|
"file[]",
|
@@ -3768,7 +3678,7 @@ class RestRepository extends Query {
|
|
3768
3678
|
}
|
3769
3679
|
async search(query, options = {}) {
|
3770
3680
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
3771
|
-
const { records } = await searchTable({
|
3681
|
+
const { records, totalCount } = await searchTable({
|
3772
3682
|
pathParams: {
|
3773
3683
|
workspace: "{workspaceId}",
|
3774
3684
|
dbBranchName: "{dbBranch}",
|
@@ -3788,12 +3698,15 @@ class RestRepository extends Query {
|
|
3788
3698
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3789
3699
|
});
|
3790
3700
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3791
|
-
return
|
3701
|
+
return {
|
3702
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3703
|
+
totalCount
|
3704
|
+
};
|
3792
3705
|
});
|
3793
3706
|
}
|
3794
3707
|
async vectorSearch(column, query, options) {
|
3795
3708
|
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3796
|
-
const { records } = await vectorSearchTable({
|
3709
|
+
const { records, totalCount } = await vectorSearchTable({
|
3797
3710
|
pathParams: {
|
3798
3711
|
workspace: "{workspaceId}",
|
3799
3712
|
dbBranchName: "{dbBranch}",
|
@@ -3810,7 +3723,10 @@ class RestRepository extends Query {
|
|
3810
3723
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3811
3724
|
});
|
3812
3725
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3813
|
-
return
|
3726
|
+
return {
|
3727
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3728
|
+
totalCount
|
3729
|
+
};
|
3814
3730
|
});
|
3815
3731
|
}
|
3816
3732
|
async aggregate(aggs, filter) {
|
@@ -3886,7 +3802,13 @@ class RestRepository extends Query {
|
|
3886
3802
|
},
|
3887
3803
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3888
3804
|
});
|
3889
|
-
|
3805
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3806
|
+
return {
|
3807
|
+
...result,
|
3808
|
+
summaries: result.summaries.map(
|
3809
|
+
(summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
|
3810
|
+
)
|
3811
|
+
};
|
3890
3812
|
});
|
3891
3813
|
}
|
3892
3814
|
ask(question, options) {
|
@@ -4174,13 +4096,6 @@ transformObjectToApi_fn = async function(object) {
|
|
4174
4096
|
}
|
4175
4097
|
return result;
|
4176
4098
|
};
|
4177
|
-
const removeLinksFromObject = (object) => {
|
4178
|
-
return Object.entries(object).reduce((acc, [key, value]) => {
|
4179
|
-
if (key === "xata")
|
4180
|
-
return acc;
|
4181
|
-
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
4182
|
-
}, {});
|
4183
|
-
};
|
4184
4099
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
4185
4100
|
const data = {};
|
4186
4101
|
const { xata, ...rest } = object ?? {};
|
@@ -4247,7 +4162,6 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4247
4162
|
}
|
4248
4163
|
}
|
4249
4164
|
const record = { ...data };
|
4250
|
-
const serializable = { xata, ...removeLinksFromObject(data) };
|
4251
4165
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
4252
4166
|
record.read = function(columns2) {
|
4253
4167
|
return db[table].read(record["id"], columns2);
|
@@ -4265,15 +4179,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4265
4179
|
record.delete = function() {
|
4266
4180
|
return db[table].delete(record["id"]);
|
4267
4181
|
};
|
4268
|
-
|
4182
|
+
if (metadata !== void 0) {
|
4183
|
+
record.xata = Object.freeze(metadata);
|
4184
|
+
}
|
4269
4185
|
record.getMetadata = function() {
|
4270
4186
|
return record.xata;
|
4271
4187
|
};
|
4272
4188
|
record.toSerializable = function() {
|
4273
|
-
return JSON.parse(JSON.stringify(
|
4189
|
+
return JSON.parse(JSON.stringify(record));
|
4274
4190
|
};
|
4275
4191
|
record.toString = function() {
|
4276
|
-
return JSON.stringify(
|
4192
|
+
return JSON.stringify(record);
|
4277
4193
|
};
|
4278
4194
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
4279
4195
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -4302,12 +4218,6 @@ function parseIfVersion(...args) {
|
|
4302
4218
|
return void 0;
|
4303
4219
|
}
|
4304
4220
|
|
4305
|
-
var __defProp$3 = Object.defineProperty;
|
4306
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4307
|
-
var __publicField$3 = (obj, key, value) => {
|
4308
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4309
|
-
return value;
|
4310
|
-
};
|
4311
4221
|
var __accessCheck$3 = (obj, member, msg) => {
|
4312
4222
|
if (!member.has(obj))
|
4313
4223
|
throw TypeError("Cannot " + msg);
|
@@ -4330,8 +4240,6 @@ var _map;
|
|
4330
4240
|
class SimpleCache {
|
4331
4241
|
constructor(options = {}) {
|
4332
4242
|
__privateAdd$3(this, _map, void 0);
|
4333
|
-
__publicField$3(this, "capacity");
|
4334
|
-
__publicField$3(this, "defaultQueryTTL");
|
4335
4243
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
4336
4244
|
this.capacity = options.max ?? 500;
|
4337
4245
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -4376,10 +4284,12 @@ const notExists = (column) => ({ $notExists: column });
|
|
4376
4284
|
const startsWith = (value) => ({ $startsWith: value });
|
4377
4285
|
const endsWith = (value) => ({ $endsWith: value });
|
4378
4286
|
const pattern = (value) => ({ $pattern: value });
|
4287
|
+
const iPattern = (value) => ({ $iPattern: value });
|
4379
4288
|
const is = (value) => ({ $is: value });
|
4380
4289
|
const equals = is;
|
4381
4290
|
const isNot = (value) => ({ $isNot: value });
|
4382
4291
|
const contains = (value) => ({ $contains: value });
|
4292
|
+
const iContains = (value) => ({ $iContains: value });
|
4383
4293
|
const includes = (value) => ({ $includes: value });
|
4384
4294
|
const includesAll = (value) => ({ $includesAll: value });
|
4385
4295
|
const includesNone = (value) => ({ $includesNone: value });
|
@@ -4435,6 +4345,80 @@ class SchemaPlugin extends XataPlugin {
|
|
4435
4345
|
_tables = new WeakMap();
|
4436
4346
|
_schemaTables$1 = new WeakMap();
|
4437
4347
|
|
4348
|
+
class FilesPlugin extends XataPlugin {
|
4349
|
+
build(pluginOptions) {
|
4350
|
+
return {
|
4351
|
+
download: async (location) => {
|
4352
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4353
|
+
return await getFileItem({
|
4354
|
+
pathParams: {
|
4355
|
+
workspace: "{workspaceId}",
|
4356
|
+
dbBranchName: "{dbBranch}",
|
4357
|
+
region: "{region}",
|
4358
|
+
tableName: table ?? "",
|
4359
|
+
recordId: record ?? "",
|
4360
|
+
columnName: column ?? "",
|
4361
|
+
fileId
|
4362
|
+
},
|
4363
|
+
...pluginOptions,
|
4364
|
+
rawResponse: true
|
4365
|
+
});
|
4366
|
+
},
|
4367
|
+
upload: async (location, file, options) => {
|
4368
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4369
|
+
const resolvedFile = await file;
|
4370
|
+
const contentType = options?.mediaType || getContentType(resolvedFile);
|
4371
|
+
const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
|
4372
|
+
return await putFileItem({
|
4373
|
+
...pluginOptions,
|
4374
|
+
pathParams: {
|
4375
|
+
workspace: "{workspaceId}",
|
4376
|
+
dbBranchName: "{dbBranch}",
|
4377
|
+
region: "{region}",
|
4378
|
+
tableName: table ?? "",
|
4379
|
+
recordId: record ?? "",
|
4380
|
+
columnName: column ?? "",
|
4381
|
+
fileId
|
4382
|
+
},
|
4383
|
+
body,
|
4384
|
+
headers: { "Content-Type": contentType }
|
4385
|
+
});
|
4386
|
+
},
|
4387
|
+
delete: async (location) => {
|
4388
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4389
|
+
return await deleteFileItem({
|
4390
|
+
pathParams: {
|
4391
|
+
workspace: "{workspaceId}",
|
4392
|
+
dbBranchName: "{dbBranch}",
|
4393
|
+
region: "{region}",
|
4394
|
+
tableName: table ?? "",
|
4395
|
+
recordId: record ?? "",
|
4396
|
+
columnName: column ?? "",
|
4397
|
+
fileId
|
4398
|
+
},
|
4399
|
+
...pluginOptions
|
4400
|
+
});
|
4401
|
+
}
|
4402
|
+
};
|
4403
|
+
}
|
4404
|
+
}
|
4405
|
+
function getContentType(file) {
|
4406
|
+
if (typeof file === "string") {
|
4407
|
+
return "text/plain";
|
4408
|
+
}
|
4409
|
+
if ("mediaType" in file && file.mediaType !== void 0) {
|
4410
|
+
return file.mediaType;
|
4411
|
+
}
|
4412
|
+
if (isBlob(file)) {
|
4413
|
+
return file.type;
|
4414
|
+
}
|
4415
|
+
try {
|
4416
|
+
return file.type;
|
4417
|
+
} catch (e) {
|
4418
|
+
}
|
4419
|
+
return "application/octet-stream";
|
4420
|
+
}
|
4421
|
+
|
4438
4422
|
var __accessCheck$1 = (obj, member, msg) => {
|
4439
4423
|
if (!member.has(obj))
|
4440
4424
|
throw TypeError("Cannot " + msg);
|
@@ -4470,22 +4454,26 @@ class SearchPlugin extends XataPlugin {
|
|
4470
4454
|
build(pluginOptions) {
|
4471
4455
|
return {
|
4472
4456
|
all: async (query, options = {}) => {
|
4473
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4457
|
+
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4474
4458
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4475
|
-
return
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4459
|
+
return {
|
4460
|
+
totalCount,
|
4461
|
+
records: records.map((record) => {
|
4462
|
+
const { table = "orphan" } = record.xata;
|
4463
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
4464
|
+
})
|
4465
|
+
};
|
4479
4466
|
},
|
4480
4467
|
byTable: async (query, options = {}) => {
|
4481
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4468
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4482
4469
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4483
|
-
|
4470
|
+
const records = rawRecords.reduce((acc, record) => {
|
4484
4471
|
const { table = "orphan" } = record.xata;
|
4485
4472
|
const items = acc[table] ?? [];
|
4486
4473
|
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
4487
4474
|
return { ...acc, [table]: [...items, item] };
|
4488
4475
|
}, {});
|
4476
|
+
return { totalCount, records };
|
4489
4477
|
}
|
4490
4478
|
};
|
4491
4479
|
}
|
@@ -4494,13 +4482,13 @@ _schemaTables = new WeakMap();
|
|
4494
4482
|
_search = new WeakSet();
|
4495
4483
|
search_fn = async function(query, options, pluginOptions) {
|
4496
4484
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4497
|
-
const { records } = await searchBranch({
|
4485
|
+
const { records, totalCount } = await searchBranch({
|
4498
4486
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4499
4487
|
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
4500
4488
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4501
4489
|
...pluginOptions
|
4502
4490
|
});
|
4503
|
-
return records;
|
4491
|
+
return { records, totalCount };
|
4504
4492
|
};
|
4505
4493
|
_getSchemaTables = new WeakSet();
|
4506
4494
|
getSchemaTables_fn = async function(pluginOptions) {
|
@@ -4574,17 +4562,33 @@ function prepareParams(param1, param2) {
|
|
4574
4562
|
|
4575
4563
|
class SQLPlugin extends XataPlugin {
|
4576
4564
|
build(pluginOptions) {
|
4577
|
-
|
4578
|
-
const { statement, params, consistency } = prepareParams(
|
4579
|
-
const { records, warning } = await sqlQuery({
|
4565
|
+
const query = async (query2, ...parameters) => {
|
4566
|
+
const { statement, params, consistency } = prepareParams(query2, parameters);
|
4567
|
+
const { records, warning, columns } = await sqlQuery({
|
4580
4568
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4581
4569
|
body: { statement, params, consistency },
|
4582
4570
|
...pluginOptions
|
4583
4571
|
});
|
4584
|
-
return { records, warning };
|
4572
|
+
return { records, warning, columns };
|
4585
4573
|
};
|
4574
|
+
const result = async (param1, ...param2) => {
|
4575
|
+
if (!isParamsObject(param1) && (!isTemplateStringsArray(param1) || !Array.isArray(param2))) {
|
4576
|
+
throw new Error(
|
4577
|
+
"Calling `xata.sql` as a function is not safe. Make sure to use it as a tagged template or with an object."
|
4578
|
+
);
|
4579
|
+
}
|
4580
|
+
return await query(param1, ...param2);
|
4581
|
+
};
|
4582
|
+
result.rawUnsafeQuery = query;
|
4583
|
+
return result;
|
4586
4584
|
}
|
4587
4585
|
}
|
4586
|
+
function isTemplateStringsArray(strings) {
|
4587
|
+
return Array.isArray(strings) && "raw" in strings && Array.isArray(strings.raw);
|
4588
|
+
}
|
4589
|
+
function isParamsObject(params) {
|
4590
|
+
return isObject(params) && "statement" in params;
|
4591
|
+
}
|
4588
4592
|
|
4589
4593
|
class TransactionPlugin extends XataPlugin {
|
4590
4594
|
build(pluginOptions) {
|
@@ -4601,12 +4605,6 @@ class TransactionPlugin extends XataPlugin {
|
|
4601
4605
|
}
|
4602
4606
|
}
|
4603
4607
|
|
4604
|
-
var __defProp$2 = Object.defineProperty;
|
4605
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4606
|
-
var __publicField$2 = (obj, key, value) => {
|
4607
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4608
|
-
return value;
|
4609
|
-
};
|
4610
4608
|
var __accessCheck = (obj, member, msg) => {
|
4611
4609
|
if (!member.has(obj))
|
4612
4610
|
throw TypeError("Cannot " + msg);
|
@@ -4636,11 +4634,6 @@ const buildClient = (plugins) => {
|
|
4636
4634
|
__privateAdd(this, _parseOptions);
|
4637
4635
|
__privateAdd(this, _getFetchProps);
|
4638
4636
|
__privateAdd(this, _options, void 0);
|
4639
|
-
__publicField$2(this, "db");
|
4640
|
-
__publicField$2(this, "search");
|
4641
|
-
__publicField$2(this, "transactions");
|
4642
|
-
__publicField$2(this, "sql");
|
4643
|
-
__publicField$2(this, "files");
|
4644
4637
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4645
4638
|
__privateSet(this, _options, safeOptions);
|
4646
4639
|
const pluginOptions = {
|
@@ -4754,17 +4747,11 @@ const buildClient = (plugins) => {
|
|
4754
4747
|
class BaseClient extends buildClient() {
|
4755
4748
|
}
|
4756
4749
|
|
4757
|
-
var __defProp$1 = Object.defineProperty;
|
4758
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4759
|
-
var __publicField$1 = (obj, key, value) => {
|
4760
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4761
|
-
return value;
|
4762
|
-
};
|
4763
4750
|
const META = "__";
|
4764
4751
|
const VALUE = "___";
|
4765
4752
|
class Serializer {
|
4766
4753
|
constructor() {
|
4767
|
-
|
4754
|
+
this.classes = {};
|
4768
4755
|
}
|
4769
4756
|
add(clazz) {
|
4770
4757
|
this.classes[clazz.name] = clazz;
|
@@ -4827,34 +4814,12 @@ const deserialize = (json) => {
|
|
4827
4814
|
return defaultSerializer.fromJSON(json);
|
4828
4815
|
};
|
4829
4816
|
|
4830
|
-
function buildWorkerRunner(config) {
|
4831
|
-
return function xataWorker(name, worker) {
|
4832
|
-
return async (...args) => {
|
4833
|
-
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
4834
|
-
const result = await fetch(url, {
|
4835
|
-
method: "POST",
|
4836
|
-
headers: { "Content-Type": "application/json" },
|
4837
|
-
body: serialize({ args })
|
4838
|
-
});
|
4839
|
-
const text = await result.text();
|
4840
|
-
return deserialize(text);
|
4841
|
-
};
|
4842
|
-
};
|
4843
|
-
}
|
4844
|
-
|
4845
|
-
var __defProp = Object.defineProperty;
|
4846
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4847
|
-
var __publicField = (obj, key, value) => {
|
4848
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4849
|
-
return value;
|
4850
|
-
};
|
4851
4817
|
class XataError extends Error {
|
4852
4818
|
constructor(message, status) {
|
4853
4819
|
super(message);
|
4854
|
-
__publicField(this, "status");
|
4855
4820
|
this.status = status;
|
4856
4821
|
}
|
4857
4822
|
}
|
4858
4823
|
|
4859
|
-
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString,
|
4824
|
+
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, fileUpload, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, pgRollJobStatus, pgRollMigrationHistory, pgRollStatus, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4860
4825
|
//# sourceMappingURL=index.mjs.map
|