@xata.io/client 0.0.0-alpha.vf54e954 → 0.0.0-alpha.vf55585d9b3ddcdd6254b3a79c108fa99863f7685
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 +117 -1
- package/dist/index.cjs +411 -326
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3169 -2527
- package/dist/index.mjs +397 -326
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -20,7 +20,8 @@ const TraceAttributes = {
|
|
20
20
|
HTTP_METHOD: "http.method",
|
21
21
|
HTTP_URL: "http.url",
|
22
22
|
HTTP_ROUTE: "http.route",
|
23
|
-
HTTP_TARGET: "http.target"
|
23
|
+
HTTP_TARGET: "http.target",
|
24
|
+
CLOUDFLARE_RAY_ID: "cf.ray"
|
24
25
|
};
|
25
26
|
|
26
27
|
function notEmpty(value) {
|
@@ -32,8 +33,15 @@ function compact(arr) {
|
|
32
33
|
function compactObject(obj) {
|
33
34
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
34
35
|
}
|
36
|
+
function isBlob(value) {
|
37
|
+
try {
|
38
|
+
return value instanceof Blob;
|
39
|
+
} catch (error) {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
}
|
35
43
|
function isObject(value) {
|
36
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
44
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
|
37
45
|
}
|
38
46
|
function isDefined(value) {
|
39
47
|
return value !== null && value !== void 0;
|
@@ -236,12 +244,6 @@ function getPreviewBranch() {
|
|
236
244
|
}
|
237
245
|
}
|
238
246
|
|
239
|
-
var __defProp$8 = Object.defineProperty;
|
240
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
241
|
-
var __publicField$8 = (obj, key, value) => {
|
242
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
243
|
-
return value;
|
244
|
-
};
|
245
247
|
var __accessCheck$8 = (obj, member, msg) => {
|
246
248
|
if (!member.has(obj))
|
247
249
|
throw TypeError("Cannot " + msg);
|
@@ -265,14 +267,13 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
265
267
|
return method;
|
266
268
|
};
|
267
269
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
268
|
-
const REQUEST_TIMEOUT =
|
270
|
+
const REQUEST_TIMEOUT = 5 * 60 * 1e3;
|
269
271
|
function getFetchImplementation(userFetch) {
|
270
272
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
271
|
-
const
|
273
|
+
const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
|
274
|
+
const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
|
272
275
|
if (!fetchImpl) {
|
273
|
-
throw new Error(
|
274
|
-
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
275
|
-
);
|
276
|
+
throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
|
276
277
|
}
|
277
278
|
return fetchImpl;
|
278
279
|
}
|
@@ -282,8 +283,6 @@ class ApiRequestPool {
|
|
282
283
|
__privateAdd$8(this, _fetch, void 0);
|
283
284
|
__privateAdd$8(this, _queue, void 0);
|
284
285
|
__privateAdd$8(this, _concurrency, void 0);
|
285
|
-
__publicField$8(this, "running");
|
286
|
-
__publicField$8(this, "started");
|
287
286
|
__privateSet$8(this, _queue, []);
|
288
287
|
__privateSet$8(this, _concurrency, concurrency);
|
289
288
|
this.running = 0;
|
@@ -529,26 +528,16 @@ function defaultOnOpen(response) {
|
|
529
528
|
}
|
530
529
|
}
|
531
530
|
|
532
|
-
const VERSION = "0.
|
531
|
+
const VERSION = "0.28.4";
|
533
532
|
|
534
|
-
var __defProp$7 = Object.defineProperty;
|
535
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
536
|
-
var __publicField$7 = (obj, key, value) => {
|
537
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
538
|
-
return value;
|
539
|
-
};
|
540
533
|
class ErrorWithCause extends Error {
|
541
534
|
constructor(message, options) {
|
542
535
|
super(message, options);
|
543
|
-
__publicField$7(this, "cause");
|
544
536
|
}
|
545
537
|
}
|
546
538
|
class FetcherError extends ErrorWithCause {
|
547
539
|
constructor(status, data, requestId) {
|
548
540
|
super(getMessage(data));
|
549
|
-
__publicField$7(this, "status");
|
550
|
-
__publicField$7(this, "requestId");
|
551
|
-
__publicField$7(this, "errors");
|
552
541
|
this.status = status;
|
553
542
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
554
543
|
this.requestId = requestId;
|
@@ -582,6 +571,67 @@ function getMessage(data) {
|
|
582
571
|
}
|
583
572
|
}
|
584
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
|
+
|
585
635
|
const pool = new ApiRequestPool();
|
586
636
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
587
637
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -597,6 +647,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
597
647
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
598
648
|
};
|
599
649
|
function buildBaseUrl({
|
650
|
+
method,
|
600
651
|
endpoint,
|
601
652
|
path,
|
602
653
|
workspacesApiUrl,
|
@@ -604,7 +655,24 @@ function buildBaseUrl({
|
|
604
655
|
pathParams = {}
|
605
656
|
}) {
|
606
657
|
if (endpoint === "dataPlane") {
|
607
|
-
|
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
|
+
}
|
608
676
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
609
677
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
610
678
|
}
|
@@ -615,11 +683,14 @@ function hostHeader(url) {
|
|
615
683
|
const { groups } = pattern.exec(url) ?? {};
|
616
684
|
return groups?.host ? { Host: groups.host } : {};
|
617
685
|
}
|
618
|
-
function parseBody(body, headers) {
|
686
|
+
async function parseBody(body, headers) {
|
619
687
|
if (!isDefined(body))
|
620
688
|
return void 0;
|
689
|
+
if (isBlob(body) || typeof body.text === "function") {
|
690
|
+
return body;
|
691
|
+
}
|
621
692
|
const { "Content-Type": contentType } = headers ?? {};
|
622
|
-
if (String(contentType).toLowerCase() === "application/json") {
|
693
|
+
if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
|
623
694
|
return JSON.stringify(body);
|
624
695
|
}
|
625
696
|
return body;
|
@@ -650,9 +721,9 @@ async function fetch$1({
|
|
650
721
|
return await trace(
|
651
722
|
`${method.toUpperCase()} ${path}`,
|
652
723
|
async ({ setAttributes }) => {
|
653
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
724
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
654
725
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
655
|
-
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
726
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
|
656
727
|
setAttributes({
|
657
728
|
[TraceAttributes.HTTP_URL]: url,
|
658
729
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
@@ -676,7 +747,7 @@ async function fetch$1({
|
|
676
747
|
const response = await pool.request(url, {
|
677
748
|
...fetchOptions,
|
678
749
|
method: method.toUpperCase(),
|
679
|
-
body: parseBody(body, headers),
|
750
|
+
body: await parseBody(body, headers),
|
680
751
|
headers,
|
681
752
|
signal
|
682
753
|
});
|
@@ -687,7 +758,8 @@ async function fetch$1({
|
|
687
758
|
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
688
759
|
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
689
760
|
[TraceAttributes.HTTP_HOST]: host,
|
690
|
-
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
761
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
|
762
|
+
[TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
|
691
763
|
});
|
692
764
|
const message = response.headers?.get("x-xata-message");
|
693
765
|
if (message)
|
@@ -732,7 +804,7 @@ function fetchSSERequest({
|
|
732
804
|
clientName,
|
733
805
|
xataAgentExtra
|
734
806
|
}) {
|
735
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
807
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
736
808
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
737
809
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
738
810
|
void fetchEventSource(url, {
|
@@ -775,6 +847,20 @@ function parseUrl(url) {
|
|
775
847
|
|
776
848
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
777
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 });
|
778
864
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
779
865
|
url: "/dbs/{dbName}",
|
780
866
|
method: "get",
|
@@ -794,6 +880,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
794
880
|
...variables,
|
795
881
|
signal
|
796
882
|
});
|
883
|
+
const getSchema = (variables, signal) => dataPlaneFetch({
|
884
|
+
url: "/db/{dbBranchName}/schema",
|
885
|
+
method: "get",
|
886
|
+
...variables,
|
887
|
+
signal
|
888
|
+
});
|
797
889
|
const copyBranch = (variables, signal) => dataPlaneFetch({
|
798
890
|
url: "/db/{dbBranchName}/copy",
|
799
891
|
method: "post",
|
@@ -975,6 +1067,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
975
1067
|
...variables,
|
976
1068
|
signal
|
977
1069
|
});
|
1070
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1071
|
+
url: "/file/{fileId}",
|
1072
|
+
method: "put",
|
1073
|
+
...variables,
|
1074
|
+
signal
|
1075
|
+
});
|
978
1076
|
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
979
1077
|
url: "/db/{dbBranchName}/sql",
|
980
1078
|
method: "post",
|
@@ -983,6 +1081,10 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
983
1081
|
});
|
984
1082
|
const operationsByTag$2 = {
|
985
1083
|
branch: {
|
1084
|
+
applyMigration,
|
1085
|
+
pgRollStatus,
|
1086
|
+
pgRollJobStatus,
|
1087
|
+
pgRollMigrationHistory,
|
986
1088
|
getBranchList,
|
987
1089
|
getBranchDetails,
|
988
1090
|
createBranch,
|
@@ -997,6 +1099,7 @@ const operationsByTag$2 = {
|
|
997
1099
|
resolveBranch
|
998
1100
|
},
|
999
1101
|
migrations: {
|
1102
|
+
getSchema,
|
1000
1103
|
getBranchMigrationHistory,
|
1001
1104
|
getBranchMigrationPlan,
|
1002
1105
|
executeBranchMigrationPlan,
|
@@ -1040,7 +1143,7 @@ const operationsByTag$2 = {
|
|
1040
1143
|
deleteRecord,
|
1041
1144
|
bulkInsertTableRecords
|
1042
1145
|
},
|
1043
|
-
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1146
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1044
1147
|
searchAndFilter: {
|
1045
1148
|
queryTable,
|
1046
1149
|
searchBranch,
|
@@ -1162,6 +1265,15 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
1162
1265
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1163
1266
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1164
1267
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
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 });
|
1165
1277
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
1166
1278
|
url: "/workspaces/{workspaceId}/dbs",
|
1167
1279
|
method: "get",
|
@@ -1216,6 +1328,7 @@ const operationsByTag$1 = {
|
|
1216
1328
|
acceptWorkspaceMemberInvite,
|
1217
1329
|
resendWorkspaceMemberInvite
|
1218
1330
|
},
|
1331
|
+
xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
|
1219
1332
|
databases: {
|
1220
1333
|
getDatabaseList,
|
1221
1334
|
createDatabase,
|
@@ -1232,61 +1345,6 @@ const operationsByTag$1 = {
|
|
1232
1345
|
|
1233
1346
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1234
1347
|
|
1235
|
-
function getHostUrl(provider, type) {
|
1236
|
-
if (isHostProviderAlias(provider)) {
|
1237
|
-
return providers[provider][type];
|
1238
|
-
} else if (isHostProviderBuilder(provider)) {
|
1239
|
-
return provider[type];
|
1240
|
-
}
|
1241
|
-
throw new Error("Invalid API provider");
|
1242
|
-
}
|
1243
|
-
const providers = {
|
1244
|
-
production: {
|
1245
|
-
main: "https://api.xata.io",
|
1246
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
1247
|
-
},
|
1248
|
-
staging: {
|
1249
|
-
main: "https://api.staging-xata.dev",
|
1250
|
-
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1251
|
-
},
|
1252
|
-
dev: {
|
1253
|
-
main: "https://api.dev-xata.dev",
|
1254
|
-
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1255
|
-
}
|
1256
|
-
};
|
1257
|
-
function isHostProviderAlias(alias) {
|
1258
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
1259
|
-
}
|
1260
|
-
function isHostProviderBuilder(builder) {
|
1261
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
1262
|
-
}
|
1263
|
-
function parseProviderString(provider = "production") {
|
1264
|
-
if (isHostProviderAlias(provider)) {
|
1265
|
-
return provider;
|
1266
|
-
}
|
1267
|
-
const [main, workspaces] = provider.split(",");
|
1268
|
-
if (!main || !workspaces)
|
1269
|
-
return null;
|
1270
|
-
return { main, workspaces };
|
1271
|
-
}
|
1272
|
-
function buildProviderString(provider) {
|
1273
|
-
if (isHostProviderAlias(provider))
|
1274
|
-
return provider;
|
1275
|
-
return `${provider.main},${provider.workspaces}`;
|
1276
|
-
}
|
1277
|
-
function parseWorkspacesUrlParts(url) {
|
1278
|
-
if (!isString(url))
|
1279
|
-
return null;
|
1280
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1281
|
-
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1282
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1283
|
-
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1284
|
-
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1285
|
-
if (!match)
|
1286
|
-
return null;
|
1287
|
-
return { workspace: match[1], region: match[2] };
|
1288
|
-
}
|
1289
|
-
|
1290
1348
|
var __accessCheck$7 = (obj, member, msg) => {
|
1291
1349
|
if (!member.has(obj))
|
1292
1350
|
throw TypeError("Cannot " + msg);
|
@@ -2611,60 +2669,6 @@ class XataApiPlugin {
|
|
2611
2669
|
class XataPlugin {
|
2612
2670
|
}
|
2613
2671
|
|
2614
|
-
class FilesPlugin extends XataPlugin {
|
2615
|
-
build(pluginOptions) {
|
2616
|
-
return {
|
2617
|
-
download: async (location) => {
|
2618
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2619
|
-
return await getFileItem({
|
2620
|
-
pathParams: {
|
2621
|
-
workspace: "{workspaceId}",
|
2622
|
-
dbBranchName: "{dbBranch}",
|
2623
|
-
region: "{region}",
|
2624
|
-
tableName: table ?? "",
|
2625
|
-
recordId: record ?? "",
|
2626
|
-
columnName: column ?? "",
|
2627
|
-
fileId
|
2628
|
-
},
|
2629
|
-
...pluginOptions,
|
2630
|
-
rawResponse: true
|
2631
|
-
});
|
2632
|
-
},
|
2633
|
-
upload: async (location, file) => {
|
2634
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2635
|
-
return await putFileItem({
|
2636
|
-
pathParams: {
|
2637
|
-
workspace: "{workspaceId}",
|
2638
|
-
dbBranchName: "{dbBranch}",
|
2639
|
-
region: "{region}",
|
2640
|
-
tableName: table ?? "",
|
2641
|
-
recordId: record ?? "",
|
2642
|
-
columnName: column ?? "",
|
2643
|
-
fileId
|
2644
|
-
},
|
2645
|
-
body: file,
|
2646
|
-
...pluginOptions
|
2647
|
-
});
|
2648
|
-
},
|
2649
|
-
delete: async (location) => {
|
2650
|
-
const { table, record, column, fileId = "" } = location ?? {};
|
2651
|
-
return await deleteFileItem({
|
2652
|
-
pathParams: {
|
2653
|
-
workspace: "{workspaceId}",
|
2654
|
-
dbBranchName: "{dbBranch}",
|
2655
|
-
region: "{region}",
|
2656
|
-
tableName: table ?? "",
|
2657
|
-
recordId: record ?? "",
|
2658
|
-
columnName: column ?? "",
|
2659
|
-
fileId
|
2660
|
-
},
|
2661
|
-
...pluginOptions
|
2662
|
-
});
|
2663
|
-
}
|
2664
|
-
};
|
2665
|
-
}
|
2666
|
-
}
|
2667
|
-
|
2668
2672
|
function buildTransformString(transformations) {
|
2669
2673
|
return transformations.flatMap(
|
2670
2674
|
(t) => Object.entries(t).map(([key, value]) => {
|
@@ -2683,69 +2687,31 @@ function buildTransformString(transformations) {
|
|
2683
2687
|
function transformImage(url, ...transformations) {
|
2684
2688
|
if (!isDefined(url))
|
2685
2689
|
return void 0;
|
2686
|
-
const
|
2690
|
+
const newTransformations = buildTransformString(transformations);
|
2687
2691
|
const { hostname, pathname, search } = new URL(url);
|
2688
|
-
|
2692
|
+
const pathParts = pathname.split("/");
|
2693
|
+
const transformIndex = pathParts.findIndex((part) => part === "transform");
|
2694
|
+
const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
|
2695
|
+
const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
|
2696
|
+
const path = pathParts.join("/");
|
2697
|
+
return `https://${hostname}${transform}${path}${search}`;
|
2689
2698
|
}
|
2690
2699
|
|
2691
|
-
var __defProp$6 = Object.defineProperty;
|
2692
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2693
|
-
var __publicField$6 = (obj, key, value) => {
|
2694
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2695
|
-
return value;
|
2696
|
-
};
|
2697
2700
|
class XataFile {
|
2698
2701
|
constructor(file) {
|
2699
|
-
|
2700
|
-
|
2701
|
-
|
2702
|
-
__publicField$6(this, "name");
|
2703
|
-
/**
|
2704
|
-
* Media type of this file.
|
2705
|
-
*/
|
2706
|
-
__publicField$6(this, "mediaType");
|
2707
|
-
/**
|
2708
|
-
* Base64 encoded content of this file.
|
2709
|
-
*/
|
2710
|
-
__publicField$6(this, "base64Content");
|
2711
|
-
/**
|
2712
|
-
* Whether to enable public url for this file.
|
2713
|
-
*/
|
2714
|
-
__publicField$6(this, "enablePublicUrl");
|
2715
|
-
/**
|
2716
|
-
* Timeout for the signed url.
|
2717
|
-
*/
|
2718
|
-
__publicField$6(this, "signedUrlTimeout");
|
2719
|
-
/**
|
2720
|
-
* Size of this file.
|
2721
|
-
*/
|
2722
|
-
__publicField$6(this, "size");
|
2723
|
-
/**
|
2724
|
-
* Version of this file.
|
2725
|
-
*/
|
2726
|
-
__publicField$6(this, "version");
|
2727
|
-
/**
|
2728
|
-
* Url of this file.
|
2729
|
-
*/
|
2730
|
-
__publicField$6(this, "url");
|
2731
|
-
/**
|
2732
|
-
* Signed url of this file.
|
2733
|
-
*/
|
2734
|
-
__publicField$6(this, "signedUrl");
|
2735
|
-
/**
|
2736
|
-
* Attributes of this file.
|
2737
|
-
*/
|
2738
|
-
__publicField$6(this, "attributes");
|
2739
|
-
this.name = file.name || "";
|
2740
|
-
this.mediaType = file.mediaType || "application/octet-stream";
|
2702
|
+
this.id = file.id;
|
2703
|
+
this.name = file.name;
|
2704
|
+
this.mediaType = file.mediaType;
|
2741
2705
|
this.base64Content = file.base64Content;
|
2742
|
-
this.enablePublicUrl = file.enablePublicUrl
|
2743
|
-
this.signedUrlTimeout = file.signedUrlTimeout
|
2744
|
-
this.
|
2745
|
-
this.
|
2746
|
-
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;
|
2747
2712
|
this.signedUrl = file.signedUrl;
|
2748
|
-
this.
|
2713
|
+
this.uploadUrl = file.uploadUrl;
|
2714
|
+
this.attributes = file.attributes;
|
2749
2715
|
}
|
2750
2716
|
static fromBuffer(buffer, options = {}) {
|
2751
2717
|
const base64Content = buffer.toString("base64");
|
@@ -2797,8 +2763,12 @@ class XataFile {
|
|
2797
2763
|
if (!this.base64Content) {
|
2798
2764
|
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2799
2765
|
}
|
2800
|
-
const
|
2801
|
-
|
2766
|
+
const binary = atob(this.base64Content);
|
2767
|
+
const uint8Array = new Uint8Array(binary.length);
|
2768
|
+
for (let i = 0; i < binary.length; i++) {
|
2769
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2770
|
+
}
|
2771
|
+
return new Blob([uint8Array], { type: this.mediaType });
|
2802
2772
|
}
|
2803
2773
|
static fromString(string, options = {}) {
|
2804
2774
|
const base64Content = btoa(string);
|
@@ -2822,15 +2792,26 @@ class XataFile {
|
|
2822
2792
|
transform(...options) {
|
2823
2793
|
return {
|
2824
2794
|
url: transformImage(this.url, ...options),
|
2825
|
-
signedUrl: transformImage(this.signedUrl, ...options)
|
2795
|
+
signedUrl: transformImage(this.signedUrl, ...options),
|
2796
|
+
metadataUrl: transformImage(this.url, ...options, { format: "json" }),
|
2797
|
+
metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
|
2826
2798
|
};
|
2827
2799
|
}
|
2828
2800
|
}
|
2829
2801
|
const parseInputFileEntry = async (entry) => {
|
2830
2802
|
if (!isDefined(entry))
|
2831
2803
|
return null;
|
2832
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2833
|
-
return compactObject({
|
2804
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2805
|
+
return compactObject({
|
2806
|
+
id,
|
2807
|
+
// Name cannot be an empty string in our API
|
2808
|
+
name: name ? name : void 0,
|
2809
|
+
mediaType,
|
2810
|
+
base64Content,
|
2811
|
+
enablePublicUrl,
|
2812
|
+
signedUrlTimeout,
|
2813
|
+
uploadUrlTimeout
|
2814
|
+
});
|
2834
2815
|
};
|
2835
2816
|
|
2836
2817
|
function cleanFilter(filter) {
|
@@ -2860,12 +2841,25 @@ function cleanFilter(filter) {
|
|
2860
2841
|
return Object.keys(values).length > 0 ? values : void 0;
|
2861
2842
|
}
|
2862
2843
|
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2844
|
+
function stringifyJson(value) {
|
2845
|
+
if (!isDefined(value))
|
2846
|
+
return value;
|
2847
|
+
if (isString(value))
|
2848
|
+
return value;
|
2849
|
+
try {
|
2850
|
+
return JSON.stringify(value);
|
2851
|
+
} catch (e) {
|
2852
|
+
return value;
|
2853
|
+
}
|
2854
|
+
}
|
2855
|
+
function parseJson(value) {
|
2856
|
+
try {
|
2857
|
+
return JSON.parse(value);
|
2858
|
+
} catch (e) {
|
2859
|
+
return value;
|
2860
|
+
}
|
2861
|
+
}
|
2862
|
+
|
2869
2863
|
var __accessCheck$6 = (obj, member, msg) => {
|
2870
2864
|
if (!member.has(obj))
|
2871
2865
|
throw TypeError("Cannot " + msg);
|
@@ -2888,14 +2882,6 @@ var _query, _page;
|
|
2888
2882
|
class Page {
|
2889
2883
|
constructor(query, meta, records = []) {
|
2890
2884
|
__privateAdd$6(this, _query, void 0);
|
2891
|
-
/**
|
2892
|
-
* Page metadata, required to retrieve additional records.
|
2893
|
-
*/
|
2894
|
-
__publicField$5(this, "meta");
|
2895
|
-
/**
|
2896
|
-
* The set of results for this page.
|
2897
|
-
*/
|
2898
|
-
__publicField$5(this, "records");
|
2899
2885
|
__privateSet$6(this, _query, query);
|
2900
2886
|
this.meta = meta;
|
2901
2887
|
this.records = new RecordArray(this, records);
|
@@ -2945,9 +2931,9 @@ class Page {
|
|
2945
2931
|
}
|
2946
2932
|
}
|
2947
2933
|
_query = new WeakMap();
|
2948
|
-
const PAGINATION_MAX_SIZE =
|
2934
|
+
const PAGINATION_MAX_SIZE = 1e3;
|
2949
2935
|
const PAGINATION_DEFAULT_SIZE = 20;
|
2950
|
-
const PAGINATION_MAX_OFFSET =
|
2936
|
+
const PAGINATION_MAX_OFFSET = 49e3;
|
2951
2937
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
2952
2938
|
function isCursorPaginationOptions(options) {
|
2953
2939
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
@@ -3026,12 +3012,6 @@ const _RecordArray = class _RecordArray extends Array {
|
|
3026
3012
|
_page = new WeakMap();
|
3027
3013
|
let RecordArray = _RecordArray;
|
3028
3014
|
|
3029
|
-
var __defProp$4 = Object.defineProperty;
|
3030
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3031
|
-
var __publicField$4 = (obj, key, value) => {
|
3032
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3033
|
-
return value;
|
3034
|
-
};
|
3035
3015
|
var __accessCheck$5 = (obj, member, msg) => {
|
3036
3016
|
if (!member.has(obj))
|
3037
3017
|
throw TypeError("Cannot " + msg);
|
@@ -3062,8 +3042,8 @@ const _Query = class _Query {
|
|
3062
3042
|
__privateAdd$5(this, _repository, void 0);
|
3063
3043
|
__privateAdd$5(this, _data, { filter: {} });
|
3064
3044
|
// Implements pagination
|
3065
|
-
|
3066
|
-
|
3045
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3046
|
+
this.records = new RecordArray(this, []);
|
3067
3047
|
__privateSet$5(this, _table$1, table);
|
3068
3048
|
if (repository) {
|
3069
3049
|
__privateSet$5(this, _repository, repository);
|
@@ -3314,7 +3294,6 @@ const RecordColumnTypes = [
|
|
3314
3294
|
"email",
|
3315
3295
|
"multiple",
|
3316
3296
|
"link",
|
3317
|
-
"object",
|
3318
3297
|
"datetime",
|
3319
3298
|
"vector",
|
3320
3299
|
"file[]",
|
@@ -3330,6 +3309,24 @@ function isXataRecord(x) {
|
|
3330
3309
|
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
3331
3310
|
}
|
3332
3311
|
|
3312
|
+
function isValidExpandedColumn(column) {
|
3313
|
+
return isObject(column) && isString(column.name);
|
3314
|
+
}
|
3315
|
+
function isValidSelectableColumns(columns) {
|
3316
|
+
if (!Array.isArray(columns)) {
|
3317
|
+
return false;
|
3318
|
+
}
|
3319
|
+
return columns.every((column) => {
|
3320
|
+
if (typeof column === "string") {
|
3321
|
+
return true;
|
3322
|
+
}
|
3323
|
+
if (typeof column === "object") {
|
3324
|
+
return isValidExpandedColumn(column);
|
3325
|
+
}
|
3326
|
+
return false;
|
3327
|
+
});
|
3328
|
+
}
|
3329
|
+
|
3333
3330
|
function isSortFilterString(value) {
|
3334
3331
|
return isString(value);
|
3335
3332
|
}
|
@@ -3430,24 +3427,24 @@ class RestRepository extends Query {
|
|
3430
3427
|
if (a.length === 0)
|
3431
3428
|
return [];
|
3432
3429
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
3433
|
-
const columns =
|
3430
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3434
3431
|
const result = await this.read(ids, columns);
|
3435
3432
|
return result;
|
3436
3433
|
}
|
3437
3434
|
if (isString(a) && isObject(b)) {
|
3438
3435
|
if (a === "")
|
3439
3436
|
throw new Error("The id can't be empty");
|
3440
|
-
const columns =
|
3437
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3441
3438
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
3442
3439
|
}
|
3443
3440
|
if (isObject(a) && isString(a.id)) {
|
3444
3441
|
if (a.id === "")
|
3445
3442
|
throw new Error("The id can't be empty");
|
3446
|
-
const columns =
|
3443
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3447
3444
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
3448
3445
|
}
|
3449
3446
|
if (isObject(a)) {
|
3450
|
-
const columns =
|
3447
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3451
3448
|
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
3452
3449
|
}
|
3453
3450
|
throw new Error("Invalid arguments for create method");
|
@@ -3455,7 +3452,7 @@ class RestRepository extends Query {
|
|
3455
3452
|
}
|
3456
3453
|
async read(a, b) {
|
3457
3454
|
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
3458
|
-
const columns =
|
3455
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3459
3456
|
if (Array.isArray(a)) {
|
3460
3457
|
if (a.length === 0)
|
3461
3458
|
return [];
|
@@ -3482,7 +3479,13 @@ class RestRepository extends Query {
|
|
3482
3479
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3483
3480
|
});
|
3484
3481
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3485
|
-
return initObject(
|
3482
|
+
return initObject(
|
3483
|
+
__privateGet$4(this, _db),
|
3484
|
+
schemaTables,
|
3485
|
+
__privateGet$4(this, _table),
|
3486
|
+
response,
|
3487
|
+
columns
|
3488
|
+
);
|
3486
3489
|
} catch (e) {
|
3487
3490
|
if (isObject(e) && e.status === 404) {
|
3488
3491
|
return null;
|
@@ -3524,17 +3527,17 @@ class RestRepository extends Query {
|
|
3524
3527
|
ifVersion,
|
3525
3528
|
upsert: false
|
3526
3529
|
});
|
3527
|
-
const columns =
|
3530
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3528
3531
|
const result = await this.read(a, columns);
|
3529
3532
|
return result;
|
3530
3533
|
}
|
3531
3534
|
try {
|
3532
3535
|
if (isString(a) && isObject(b)) {
|
3533
|
-
const columns =
|
3536
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3534
3537
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3535
3538
|
}
|
3536
3539
|
if (isObject(a) && isString(a.id)) {
|
3537
|
-
const columns =
|
3540
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3538
3541
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3539
3542
|
}
|
3540
3543
|
} catch (error) {
|
@@ -3574,20 +3577,20 @@ class RestRepository extends Query {
|
|
3574
3577
|
ifVersion,
|
3575
3578
|
upsert: true
|
3576
3579
|
});
|
3577
|
-
const columns =
|
3580
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3578
3581
|
const result = await this.read(a, columns);
|
3579
3582
|
return result;
|
3580
3583
|
}
|
3581
3584
|
if (isString(a) && isObject(b)) {
|
3582
3585
|
if (a === "")
|
3583
3586
|
throw new Error("The id can't be empty");
|
3584
|
-
const columns =
|
3587
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3585
3588
|
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3586
3589
|
}
|
3587
3590
|
if (isObject(a) && isString(a.id)) {
|
3588
3591
|
if (a.id === "")
|
3589
3592
|
throw new Error("The id can't be empty");
|
3590
|
-
const columns =
|
3593
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3591
3594
|
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3592
3595
|
}
|
3593
3596
|
if (!isDefined(a) && isObject(b)) {
|
@@ -3606,20 +3609,20 @@ class RestRepository extends Query {
|
|
3606
3609
|
if (a.length === 0)
|
3607
3610
|
return [];
|
3608
3611
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
3609
|
-
const columns =
|
3612
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3610
3613
|
const result = await this.read(ids, columns);
|
3611
3614
|
return result;
|
3612
3615
|
}
|
3613
3616
|
if (isString(a) && isObject(b)) {
|
3614
3617
|
if (a === "")
|
3615
3618
|
throw new Error("The id can't be empty");
|
3616
|
-
const columns =
|
3619
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3617
3620
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3618
3621
|
}
|
3619
3622
|
if (isObject(a) && isString(a.id)) {
|
3620
3623
|
if (a.id === "")
|
3621
3624
|
throw new Error("The id can't be empty");
|
3622
|
-
const columns =
|
3625
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3623
3626
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3624
3627
|
}
|
3625
3628
|
if (!isDefined(a) && isObject(b)) {
|
@@ -3643,7 +3646,7 @@ class RestRepository extends Query {
|
|
3643
3646
|
return o.id;
|
3644
3647
|
throw new Error("Invalid arguments for delete method");
|
3645
3648
|
});
|
3646
|
-
const columns =
|
3649
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3647
3650
|
const result = await this.read(a, columns);
|
3648
3651
|
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
3649
3652
|
return result;
|
@@ -3677,7 +3680,7 @@ class RestRepository extends Query {
|
|
3677
3680
|
}
|
3678
3681
|
async search(query, options = {}) {
|
3679
3682
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
3680
|
-
const { records } = await searchTable({
|
3683
|
+
const { records, totalCount } = await searchTable({
|
3681
3684
|
pathParams: {
|
3682
3685
|
workspace: "{workspaceId}",
|
3683
3686
|
dbBranchName: "{dbBranch}",
|
@@ -3697,12 +3700,15 @@ class RestRepository extends Query {
|
|
3697
3700
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3698
3701
|
});
|
3699
3702
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3700
|
-
return
|
3703
|
+
return {
|
3704
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3705
|
+
totalCount
|
3706
|
+
};
|
3701
3707
|
});
|
3702
3708
|
}
|
3703
3709
|
async vectorSearch(column, query, options) {
|
3704
3710
|
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3705
|
-
const { records } = await vectorSearchTable({
|
3711
|
+
const { records, totalCount } = await vectorSearchTable({
|
3706
3712
|
pathParams: {
|
3707
3713
|
workspace: "{workspaceId}",
|
3708
3714
|
dbBranchName: "{dbBranch}",
|
@@ -3719,7 +3725,10 @@ class RestRepository extends Query {
|
|
3719
3725
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3720
3726
|
});
|
3721
3727
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3722
|
-
return
|
3728
|
+
return {
|
3729
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3730
|
+
totalCount
|
3731
|
+
};
|
3723
3732
|
});
|
3724
3733
|
}
|
3725
3734
|
async aggregate(aggs, filter) {
|
@@ -3762,7 +3771,13 @@ class RestRepository extends Query {
|
|
3762
3771
|
});
|
3763
3772
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3764
3773
|
const records = objects.map(
|
3765
|
-
(record) => initObject(
|
3774
|
+
(record) => initObject(
|
3775
|
+
__privateGet$4(this, _db),
|
3776
|
+
schemaTables,
|
3777
|
+
__privateGet$4(this, _table),
|
3778
|
+
record,
|
3779
|
+
data.columns ?? ["*"]
|
3780
|
+
)
|
3766
3781
|
);
|
3767
3782
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
3768
3783
|
return new Page(query, meta, records);
|
@@ -3789,7 +3804,13 @@ class RestRepository extends Query {
|
|
3789
3804
|
},
|
3790
3805
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3791
3806
|
});
|
3792
|
-
|
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
|
+
};
|
3793
3814
|
});
|
3794
3815
|
}
|
3795
3816
|
ask(question, options) {
|
@@ -4068,19 +4089,15 @@ transformObjectToApi_fn = async function(object) {
|
|
4068
4089
|
case "file[]":
|
4069
4090
|
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4070
4091
|
break;
|
4092
|
+
case "json":
|
4093
|
+
result[key] = stringifyJson(value);
|
4094
|
+
break;
|
4071
4095
|
default:
|
4072
4096
|
result[key] = value;
|
4073
4097
|
}
|
4074
4098
|
}
|
4075
4099
|
return result;
|
4076
4100
|
};
|
4077
|
-
const removeLinksFromObject = (object) => {
|
4078
|
-
return Object.entries(object).reduce((acc, [key, value]) => {
|
4079
|
-
if (key === "xata")
|
4080
|
-
return acc;
|
4081
|
-
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
4082
|
-
}, {});
|
4083
|
-
};
|
4084
4101
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
4085
4102
|
const data = {};
|
4086
4103
|
const { xata, ...rest } = object ?? {};
|
@@ -4111,13 +4128,19 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4111
4128
|
if (item === column.name) {
|
4112
4129
|
return [...acc, "*"];
|
4113
4130
|
}
|
4114
|
-
if (item.startsWith(`${column.name}.`)) {
|
4131
|
+
if (isString(item) && item.startsWith(`${column.name}.`)) {
|
4115
4132
|
const [, ...path] = item.split(".");
|
4116
4133
|
return [...acc, path.join(".")];
|
4117
4134
|
}
|
4118
4135
|
return acc;
|
4119
4136
|
}, []);
|
4120
|
-
data[column.name] = initObject(
|
4137
|
+
data[column.name] = initObject(
|
4138
|
+
db,
|
4139
|
+
schemaTables,
|
4140
|
+
linkTable,
|
4141
|
+
value,
|
4142
|
+
selectedLinkColumns
|
4143
|
+
);
|
4121
4144
|
} else {
|
4122
4145
|
data[column.name] = null;
|
4123
4146
|
}
|
@@ -4129,6 +4152,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4129
4152
|
case "file[]":
|
4130
4153
|
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4131
4154
|
break;
|
4155
|
+
case "json":
|
4156
|
+
data[column.name] = parseJson(value);
|
4157
|
+
break;
|
4132
4158
|
default:
|
4133
4159
|
data[column.name] = value ?? null;
|
4134
4160
|
if (column.notNull === true && value === null) {
|
@@ -4138,33 +4164,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4138
4164
|
}
|
4139
4165
|
}
|
4140
4166
|
const record = { ...data };
|
4141
|
-
const serializable = { xata, ...removeLinksFromObject(data) };
|
4142
4167
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
4143
4168
|
record.read = function(columns2) {
|
4144
4169
|
return db[table].read(record["id"], columns2);
|
4145
4170
|
};
|
4146
4171
|
record.update = function(data2, b, c) {
|
4147
|
-
const columns2 =
|
4172
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
4148
4173
|
const ifVersion = parseIfVersion(b, c);
|
4149
4174
|
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
4150
4175
|
};
|
4151
4176
|
record.replace = function(data2, b, c) {
|
4152
|
-
const columns2 =
|
4177
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
4153
4178
|
const ifVersion = parseIfVersion(b, c);
|
4154
4179
|
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
4155
4180
|
};
|
4156
4181
|
record.delete = function() {
|
4157
4182
|
return db[table].delete(record["id"]);
|
4158
4183
|
};
|
4159
|
-
|
4184
|
+
if (metadata !== void 0) {
|
4185
|
+
record.xata = Object.freeze(metadata);
|
4186
|
+
}
|
4160
4187
|
record.getMetadata = function() {
|
4161
4188
|
return record.xata;
|
4162
4189
|
};
|
4163
4190
|
record.toSerializable = function() {
|
4164
|
-
return JSON.parse(JSON.stringify(
|
4191
|
+
return JSON.parse(JSON.stringify(record));
|
4165
4192
|
};
|
4166
4193
|
record.toString = function() {
|
4167
|
-
return JSON.stringify(
|
4194
|
+
return JSON.stringify(record);
|
4168
4195
|
};
|
4169
4196
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
4170
4197
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -4182,7 +4209,7 @@ function extractId(value) {
|
|
4182
4209
|
function isValidColumn(columns, column) {
|
4183
4210
|
if (columns.includes("*"))
|
4184
4211
|
return true;
|
4185
|
-
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
4212
|
+
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
4186
4213
|
}
|
4187
4214
|
function parseIfVersion(...args) {
|
4188
4215
|
for (const arg of args) {
|
@@ -4193,12 +4220,6 @@ function parseIfVersion(...args) {
|
|
4193
4220
|
return void 0;
|
4194
4221
|
}
|
4195
4222
|
|
4196
|
-
var __defProp$3 = Object.defineProperty;
|
4197
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4198
|
-
var __publicField$3 = (obj, key, value) => {
|
4199
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4200
|
-
return value;
|
4201
|
-
};
|
4202
4223
|
var __accessCheck$3 = (obj, member, msg) => {
|
4203
4224
|
if (!member.has(obj))
|
4204
4225
|
throw TypeError("Cannot " + msg);
|
@@ -4221,8 +4242,6 @@ var _map;
|
|
4221
4242
|
class SimpleCache {
|
4222
4243
|
constructor(options = {}) {
|
4223
4244
|
__privateAdd$3(this, _map, void 0);
|
4224
|
-
__publicField$3(this, "capacity");
|
4225
|
-
__publicField$3(this, "defaultQueryTTL");
|
4226
4245
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
4227
4246
|
this.capacity = options.max ?? 500;
|
4228
4247
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -4267,10 +4286,12 @@ const notExists = (column) => ({ $notExists: column });
|
|
4267
4286
|
const startsWith = (value) => ({ $startsWith: value });
|
4268
4287
|
const endsWith = (value) => ({ $endsWith: value });
|
4269
4288
|
const pattern = (value) => ({ $pattern: value });
|
4289
|
+
const iPattern = (value) => ({ $iPattern: value });
|
4270
4290
|
const is = (value) => ({ $is: value });
|
4271
4291
|
const equals = is;
|
4272
4292
|
const isNot = (value) => ({ $isNot: value });
|
4273
4293
|
const contains = (value) => ({ $contains: value });
|
4294
|
+
const iContains = (value) => ({ $iContains: value });
|
4274
4295
|
const includes = (value) => ({ $includes: value });
|
4275
4296
|
const includesAll = (value) => ({ $includesAll: value });
|
4276
4297
|
const includesNone = (value) => ({ $includesNone: value });
|
@@ -4326,6 +4347,80 @@ class SchemaPlugin extends XataPlugin {
|
|
4326
4347
|
_tables = new WeakMap();
|
4327
4348
|
_schemaTables$1 = new WeakMap();
|
4328
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
|
+
|
4329
4424
|
var __accessCheck$1 = (obj, member, msg) => {
|
4330
4425
|
if (!member.has(obj))
|
4331
4426
|
throw TypeError("Cannot " + msg);
|
@@ -4361,22 +4456,26 @@ class SearchPlugin extends XataPlugin {
|
|
4361
4456
|
build(pluginOptions) {
|
4362
4457
|
return {
|
4363
4458
|
all: async (query, options = {}) => {
|
4364
|
-
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);
|
4365
4460
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4366
|
-
return
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
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
|
+
};
|
4370
4468
|
},
|
4371
4469
|
byTable: async (query, options = {}) => {
|
4372
|
-
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);
|
4373
4471
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4374
|
-
|
4472
|
+
const records = rawRecords.reduce((acc, record) => {
|
4375
4473
|
const { table = "orphan" } = record.xata;
|
4376
4474
|
const items = acc[table] ?? [];
|
4377
4475
|
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
4378
4476
|
return { ...acc, [table]: [...items, item] };
|
4379
4477
|
}, {});
|
4478
|
+
return { totalCount, records };
|
4380
4479
|
}
|
4381
4480
|
};
|
4382
4481
|
}
|
@@ -4385,13 +4484,13 @@ _schemaTables = new WeakMap();
|
|
4385
4484
|
_search = new WeakSet();
|
4386
4485
|
search_fn = async function(query, options, pluginOptions) {
|
4387
4486
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4388
|
-
const { records } = await searchBranch({
|
4487
|
+
const { records, totalCount } = await searchBranch({
|
4389
4488
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4390
4489
|
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
4391
4490
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4392
4491
|
...pluginOptions
|
4393
4492
|
});
|
4394
|
-
return records;
|
4493
|
+
return { records, totalCount };
|
4395
4494
|
};
|
4396
4495
|
_getSchemaTables = new WeakSet();
|
4397
4496
|
getSchemaTables_fn = async function(pluginOptions) {
|
@@ -4466,6 +4565,11 @@ function prepareParams(param1, param2) {
|
|
4466
4565
|
class SQLPlugin extends XataPlugin {
|
4467
4566
|
build(pluginOptions) {
|
4468
4567
|
return async (param1, ...param2) => {
|
4568
|
+
if (!isParamsObject(param1) && (!isTemplateStringsArray(param1) || !Array.isArray(param2))) {
|
4569
|
+
throw new Error(
|
4570
|
+
"Calling `xata.sql` as a function is not safe. Make sure to use it as a tagged template or with an object."
|
4571
|
+
);
|
4572
|
+
}
|
4469
4573
|
const { statement, params, consistency } = prepareParams(param1, param2);
|
4470
4574
|
const { records, warning } = await sqlQuery({
|
4471
4575
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
@@ -4476,6 +4580,12 @@ class SQLPlugin extends XataPlugin {
|
|
4476
4580
|
};
|
4477
4581
|
}
|
4478
4582
|
}
|
4583
|
+
function isTemplateStringsArray(strings) {
|
4584
|
+
return Array.isArray(strings) && "raw" in strings && Array.isArray(strings.raw);
|
4585
|
+
}
|
4586
|
+
function isParamsObject(params) {
|
4587
|
+
return isObject(params) && "statement" in params;
|
4588
|
+
}
|
4479
4589
|
|
4480
4590
|
class TransactionPlugin extends XataPlugin {
|
4481
4591
|
build(pluginOptions) {
|
@@ -4492,12 +4602,6 @@ class TransactionPlugin extends XataPlugin {
|
|
4492
4602
|
}
|
4493
4603
|
}
|
4494
4604
|
|
4495
|
-
var __defProp$2 = Object.defineProperty;
|
4496
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4497
|
-
var __publicField$2 = (obj, key, value) => {
|
4498
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4499
|
-
return value;
|
4500
|
-
};
|
4501
4605
|
var __accessCheck = (obj, member, msg) => {
|
4502
4606
|
if (!member.has(obj))
|
4503
4607
|
throw TypeError("Cannot " + msg);
|
@@ -4527,11 +4631,6 @@ const buildClient = (plugins) => {
|
|
4527
4631
|
__privateAdd(this, _parseOptions);
|
4528
4632
|
__privateAdd(this, _getFetchProps);
|
4529
4633
|
__privateAdd(this, _options, void 0);
|
4530
|
-
__publicField$2(this, "db");
|
4531
|
-
__publicField$2(this, "search");
|
4532
|
-
__publicField$2(this, "transactions");
|
4533
|
-
__publicField$2(this, "sql");
|
4534
|
-
__publicField$2(this, "files");
|
4535
4634
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4536
4635
|
__privateSet(this, _options, safeOptions);
|
4537
4636
|
const pluginOptions = {
|
@@ -4645,17 +4744,11 @@ const buildClient = (plugins) => {
|
|
4645
4744
|
class BaseClient extends buildClient() {
|
4646
4745
|
}
|
4647
4746
|
|
4648
|
-
var __defProp$1 = Object.defineProperty;
|
4649
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4650
|
-
var __publicField$1 = (obj, key, value) => {
|
4651
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4652
|
-
return value;
|
4653
|
-
};
|
4654
4747
|
const META = "__";
|
4655
4748
|
const VALUE = "___";
|
4656
4749
|
class Serializer {
|
4657
4750
|
constructor() {
|
4658
|
-
|
4751
|
+
this.classes = {};
|
4659
4752
|
}
|
4660
4753
|
add(clazz) {
|
4661
4754
|
this.classes[clazz.name] = clazz;
|
@@ -4718,31 +4811,9 @@ const deserialize = (json) => {
|
|
4718
4811
|
return defaultSerializer.fromJSON(json);
|
4719
4812
|
};
|
4720
4813
|
|
4721
|
-
function buildWorkerRunner(config) {
|
4722
|
-
return function xataWorker(name, worker) {
|
4723
|
-
return async (...args) => {
|
4724
|
-
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
4725
|
-
const result = await fetch(url, {
|
4726
|
-
method: "POST",
|
4727
|
-
headers: { "Content-Type": "application/json" },
|
4728
|
-
body: serialize({ args })
|
4729
|
-
});
|
4730
|
-
const text = await result.text();
|
4731
|
-
return deserialize(text);
|
4732
|
-
};
|
4733
|
-
};
|
4734
|
-
}
|
4735
|
-
|
4736
|
-
var __defProp = Object.defineProperty;
|
4737
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4738
|
-
var __publicField = (obj, key, value) => {
|
4739
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4740
|
-
return value;
|
4741
|
-
};
|
4742
4814
|
class XataError extends Error {
|
4743
4815
|
constructor(message, status) {
|
4744
4816
|
super(message);
|
4745
|
-
__publicField(this, "status");
|
4746
4817
|
this.status = status;
|
4747
4818
|
}
|
4748
4819
|
}
|
@@ -4766,6 +4837,7 @@ exports.SchemaPlugin = SchemaPlugin;
|
|
4766
4837
|
exports.SearchPlugin = SearchPlugin;
|
4767
4838
|
exports.Serializer = Serializer;
|
4768
4839
|
exports.SimpleCache = SimpleCache;
|
4840
|
+
exports.TransactionPlugin = TransactionPlugin;
|
4769
4841
|
exports.XataApiClient = XataApiClient;
|
4770
4842
|
exports.XataApiPlugin = XataApiPlugin;
|
4771
4843
|
exports.XataError = XataError;
|
@@ -4776,13 +4848,13 @@ exports.addGitBranchesEntry = addGitBranchesEntry;
|
|
4776
4848
|
exports.addTableColumn = addTableColumn;
|
4777
4849
|
exports.aggregateTable = aggregateTable;
|
4778
4850
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4851
|
+
exports.applyMigration = applyMigration;
|
4779
4852
|
exports.askTable = askTable;
|
4780
4853
|
exports.askTableSession = askTableSession;
|
4781
4854
|
exports.branchTransaction = branchTransaction;
|
4782
4855
|
exports.buildClient = buildClient;
|
4783
4856
|
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4784
4857
|
exports.buildProviderString = buildProviderString;
|
4785
|
-
exports.buildWorkerRunner = buildWorkerRunner;
|
4786
4858
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
4787
4859
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
4788
4860
|
exports.compareBranchSchemas = compareBranchSchemas;
|
@@ -4791,6 +4863,7 @@ exports.compareMigrationRequest = compareMigrationRequest;
|
|
4791
4863
|
exports.contains = contains;
|
4792
4864
|
exports.copyBranch = copyBranch;
|
4793
4865
|
exports.createBranch = createBranch;
|
4866
|
+
exports.createCluster = createCluster;
|
4794
4867
|
exports.createDatabase = createDatabase;
|
4795
4868
|
exports.createMigrationRequest = createMigrationRequest;
|
4796
4869
|
exports.createTable = createTable;
|
@@ -4815,6 +4888,7 @@ exports.equals = equals;
|
|
4815
4888
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
4816
4889
|
exports.exists = exists;
|
4817
4890
|
exports.fileAccess = fileAccess;
|
4891
|
+
exports.fileUpload = fileUpload;
|
4818
4892
|
exports.ge = ge;
|
4819
4893
|
exports.getAPIKey = getAPIKey;
|
4820
4894
|
exports.getAuthorizationCode = getAuthorizationCode;
|
@@ -4826,6 +4900,7 @@ exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
|
4826
4900
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
4827
4901
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
4828
4902
|
exports.getBranchStats = getBranchStats;
|
4903
|
+
exports.getCluster = getCluster;
|
4829
4904
|
exports.getColumn = getColumn;
|
4830
4905
|
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
4831
4906
|
exports.getDatabaseList = getDatabaseList;
|
@@ -4839,6 +4914,7 @@ exports.getMigrationRequest = getMigrationRequest;
|
|
4839
4914
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
4840
4915
|
exports.getPreviewBranch = getPreviewBranch;
|
4841
4916
|
exports.getRecord = getRecord;
|
4917
|
+
exports.getSchema = getSchema;
|
4842
4918
|
exports.getTableColumns = getTableColumns;
|
4843
4919
|
exports.getTableSchema = getTableSchema;
|
4844
4920
|
exports.getUser = getUser;
|
@@ -4854,6 +4930,8 @@ exports.greaterThan = greaterThan;
|
|
4854
4930
|
exports.greaterThanEquals = greaterThanEquals;
|
4855
4931
|
exports.gt = gt;
|
4856
4932
|
exports.gte = gte;
|
4933
|
+
exports.iContains = iContains;
|
4934
|
+
exports.iPattern = iPattern;
|
4857
4935
|
exports.includes = includes;
|
4858
4936
|
exports.includesAll = includesAll;
|
4859
4937
|
exports.includesAny = includesAny;
|
@@ -4867,11 +4945,14 @@ exports.isHostProviderAlias = isHostProviderAlias;
|
|
4867
4945
|
exports.isHostProviderBuilder = isHostProviderBuilder;
|
4868
4946
|
exports.isIdentifiable = isIdentifiable;
|
4869
4947
|
exports.isNot = isNot;
|
4948
|
+
exports.isValidExpandedColumn = isValidExpandedColumn;
|
4949
|
+
exports.isValidSelectableColumns = isValidSelectableColumns;
|
4870
4950
|
exports.isXataRecord = isXataRecord;
|
4871
4951
|
exports.le = le;
|
4872
4952
|
exports.lessEquals = lessEquals;
|
4873
4953
|
exports.lessThan = lessThan;
|
4874
4954
|
exports.lessThanEquals = lessThanEquals;
|
4955
|
+
exports.listClusters = listClusters;
|
4875
4956
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
4876
4957
|
exports.listRegions = listRegions;
|
4877
4958
|
exports.lt = lt;
|
@@ -4882,6 +4963,9 @@ exports.operationsByTag = operationsByTag;
|
|
4882
4963
|
exports.parseProviderString = parseProviderString;
|
4883
4964
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
4884
4965
|
exports.pattern = pattern;
|
4966
|
+
exports.pgRollJobStatus = pgRollJobStatus;
|
4967
|
+
exports.pgRollMigrationHistory = pgRollMigrationHistory;
|
4968
|
+
exports.pgRollStatus = pgRollStatus;
|
4885
4969
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4886
4970
|
exports.pushBranchMigrations = pushBranchMigrations;
|
4887
4971
|
exports.putFile = putFile;
|
@@ -4903,6 +4987,7 @@ exports.summarizeTable = summarizeTable;
|
|
4903
4987
|
exports.transformImage = transformImage;
|
4904
4988
|
exports.updateBranchMetadata = updateBranchMetadata;
|
4905
4989
|
exports.updateBranchSchema = updateBranchSchema;
|
4990
|
+
exports.updateCluster = updateCluster;
|
4906
4991
|
exports.updateColumn = updateColumn;
|
4907
4992
|
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
4908
4993
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|