@xata.io/client 0.28.2 → 0.28.4
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 +14 -0
- package/dist/index.cjs +101 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2849 -2683
- package/dist/index.mjs +100 -70
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
|
-
> @xata.io/client@0.28.
|
2
|
+
> @xata.io/client@0.28.4 build /home/runner/work/client-ts/client-ts/packages/client
|
3
3
|
> rimraf dist && rollup -c
|
4
4
|
|
5
5
|
[36m
|
6
6
|
[1msrc/index.ts[22m → [1mdist/index.cjs[22m...[39m
|
7
|
-
[32mcreated [1mdist/index.cjs[22m in [
|
7
|
+
[32mcreated [1mdist/index.cjs[22m in [1m1.1s[22m[39m
|
8
8
|
[36m
|
9
9
|
[1msrc/index.ts[22m → [1mdist/index.mjs[22m...[39m
|
10
|
-
[32mcreated [1mdist/index.mjs[22m in [
|
10
|
+
[32mcreated [1mdist/index.mjs[22m in [1m767ms[22m[39m
|
11
11
|
[36m
|
12
12
|
[1msrc/index.ts[22m → [1mdist/index.d.ts[22m...[39m
|
13
|
-
[32mcreated [1mdist/index.d.ts[22m in [1m5.
|
13
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m5.3s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.28.4
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#1309](https://github.com/xataio/client-ts/pull/1309) [`adc961b`](https://github.com/xataio/client-ts/commit/adc961b886b789010e6512c17cb2377eceab665a) Thanks [@andrew-farries](https://github.com/andrew-farries)! - Add CLI support for running against local development environments
|
8
|
+
|
9
|
+
- [#1312](https://github.com/xataio/client-ts/pull/1312) [`6031a9d`](https://github.com/xataio/client-ts/commit/6031a9de63c264b7db5b031bb1795258c2bf8150) Thanks [@SferaDev](https://github.com/SferaDev)! - Add get to transactions
|
10
|
+
|
11
|
+
## 0.28.3
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- [#1304](https://github.com/xataio/client-ts/pull/1304) [`b7f3ec9`](https://github.com/xataio/client-ts/commit/b7f3ec9eabe3642929131e244bd774f4d3134482) Thanks [@SferaDev](https://github.com/SferaDev)! - Rewrite upload url path
|
16
|
+
|
3
17
|
## 0.28.2
|
4
18
|
|
5
19
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
@@ -528,7 +528,7 @@ function defaultOnOpen(response) {
|
|
528
528
|
}
|
529
529
|
}
|
530
530
|
|
531
|
-
const VERSION = "0.28.
|
531
|
+
const VERSION = "0.28.4";
|
532
532
|
|
533
533
|
class ErrorWithCause extends Error {
|
534
534
|
constructor(message, options) {
|
@@ -571,6 +571,67 @@ function getMessage(data) {
|
|
571
571
|
}
|
572
572
|
}
|
573
573
|
|
574
|
+
function getHostUrl(provider, type) {
|
575
|
+
if (isHostProviderAlias(provider)) {
|
576
|
+
return providers[provider][type];
|
577
|
+
} else if (isHostProviderBuilder(provider)) {
|
578
|
+
return provider[type];
|
579
|
+
}
|
580
|
+
throw new Error("Invalid API provider");
|
581
|
+
}
|
582
|
+
const providers = {
|
583
|
+
production: {
|
584
|
+
main: "https://api.xata.io",
|
585
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
586
|
+
},
|
587
|
+
staging: {
|
588
|
+
main: "https://api.staging-xata.dev",
|
589
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
590
|
+
},
|
591
|
+
dev: {
|
592
|
+
main: "https://api.dev-xata.dev",
|
593
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
594
|
+
},
|
595
|
+
local: {
|
596
|
+
main: "http://localhost:6001",
|
597
|
+
workspaces: "http://{workspaceId}.{region}.localhost:6001"
|
598
|
+
}
|
599
|
+
};
|
600
|
+
function isHostProviderAlias(alias) {
|
601
|
+
return isString(alias) && Object.keys(providers).includes(alias);
|
602
|
+
}
|
603
|
+
function isHostProviderBuilder(builder) {
|
604
|
+
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
605
|
+
}
|
606
|
+
function parseProviderString(provider = "production") {
|
607
|
+
if (isHostProviderAlias(provider)) {
|
608
|
+
return provider;
|
609
|
+
}
|
610
|
+
const [main, workspaces] = provider.split(",");
|
611
|
+
if (!main || !workspaces)
|
612
|
+
return null;
|
613
|
+
return { main, workspaces };
|
614
|
+
}
|
615
|
+
function buildProviderString(provider) {
|
616
|
+
if (isHostProviderAlias(provider))
|
617
|
+
return provider;
|
618
|
+
return `${provider.main},${provider.workspaces}`;
|
619
|
+
}
|
620
|
+
function parseWorkspacesUrlParts(url) {
|
621
|
+
if (!isString(url))
|
622
|
+
return null;
|
623
|
+
const matches = {
|
624
|
+
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/),
|
625
|
+
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/),
|
626
|
+
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/),
|
627
|
+
local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(\d+)/)
|
628
|
+
};
|
629
|
+
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
630
|
+
if (!isHostProviderAlias(host) || !match)
|
631
|
+
return null;
|
632
|
+
return { workspace: match[1], region: match[2], host };
|
633
|
+
}
|
634
|
+
|
574
635
|
const pool = new ApiRequestPool();
|
575
636
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
576
637
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -586,6 +647,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
586
647
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
587
648
|
};
|
588
649
|
function buildBaseUrl({
|
650
|
+
method,
|
589
651
|
endpoint,
|
590
652
|
path,
|
591
653
|
workspacesApiUrl,
|
@@ -593,7 +655,24 @@ function buildBaseUrl({
|
|
593
655
|
pathParams = {}
|
594
656
|
}) {
|
595
657
|
if (endpoint === "dataPlane") {
|
596
|
-
|
658
|
+
let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
659
|
+
if (method.toUpperCase() === "PUT" && [
|
660
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
661
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
|
662
|
+
].includes(path)) {
|
663
|
+
const { host } = parseWorkspacesUrlParts(url) ?? {};
|
664
|
+
switch (host) {
|
665
|
+
case "production":
|
666
|
+
url = url.replace("xata.sh", "upload.xata.sh");
|
667
|
+
break;
|
668
|
+
case "staging":
|
669
|
+
url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
|
670
|
+
break;
|
671
|
+
case "dev":
|
672
|
+
url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
|
673
|
+
break;
|
674
|
+
}
|
675
|
+
}
|
597
676
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
598
677
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
599
678
|
}
|
@@ -642,9 +721,9 @@ async function fetch$1({
|
|
642
721
|
return await trace(
|
643
722
|
`${method.toUpperCase()} ${path}`,
|
644
723
|
async ({ setAttributes }) => {
|
645
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
724
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
646
725
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
647
|
-
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
726
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
|
648
727
|
setAttributes({
|
649
728
|
[TraceAttributes.HTTP_URL]: url,
|
650
729
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
@@ -725,7 +804,7 @@ function fetchSSERequest({
|
|
725
804
|
clientName,
|
726
805
|
xataAgentExtra
|
727
806
|
}) {
|
728
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
807
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
729
808
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
730
809
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
731
810
|
void fetchEventSource(url, {
|
@@ -781,6 +860,7 @@ const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
|
|
781
860
|
...variables,
|
782
861
|
signal
|
783
862
|
});
|
863
|
+
const pgRollMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/migrations", method: "get", ...variables, signal });
|
784
864
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
785
865
|
url: "/dbs/{dbName}",
|
786
866
|
method: "get",
|
@@ -987,6 +1067,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
987
1067
|
...variables,
|
988
1068
|
signal
|
989
1069
|
});
|
1070
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1071
|
+
url: "/file/{fileId}",
|
1072
|
+
method: "put",
|
1073
|
+
...variables,
|
1074
|
+
signal
|
1075
|
+
});
|
990
1076
|
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
991
1077
|
url: "/db/{dbBranchName}/sql",
|
992
1078
|
method: "post",
|
@@ -998,6 +1084,7 @@ const operationsByTag$2 = {
|
|
998
1084
|
applyMigration,
|
999
1085
|
pgRollStatus,
|
1000
1086
|
pgRollJobStatus,
|
1087
|
+
pgRollMigrationHistory,
|
1001
1088
|
getBranchList,
|
1002
1089
|
getBranchDetails,
|
1003
1090
|
createBranch,
|
@@ -1056,7 +1143,7 @@ const operationsByTag$2 = {
|
|
1056
1143
|
deleteRecord,
|
1057
1144
|
bulkInsertTableRecords
|
1058
1145
|
},
|
1059
|
-
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1146
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1060
1147
|
searchAndFilter: {
|
1061
1148
|
queryTable,
|
1062
1149
|
searchBranch,
|
@@ -1178,12 +1265,7 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
1178
1265
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1179
1266
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1180
1267
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1181
|
-
const listClusters = (variables, signal) => controlPlaneFetch({
|
1182
|
-
url: "/workspaces/{workspaceId}/clusters",
|
1183
|
-
method: "get",
|
1184
|
-
...variables,
|
1185
|
-
signal
|
1186
|
-
});
|
1268
|
+
const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
|
1187
1269
|
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1188
1270
|
const getCluster = (variables, signal) => controlPlaneFetch({
|
1189
1271
|
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
@@ -1263,61 +1345,6 @@ const operationsByTag$1 = {
|
|
1263
1345
|
|
1264
1346
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1265
1347
|
|
1266
|
-
function getHostUrl(provider, type) {
|
1267
|
-
if (isHostProviderAlias(provider)) {
|
1268
|
-
return providers[provider][type];
|
1269
|
-
} else if (isHostProviderBuilder(provider)) {
|
1270
|
-
return provider[type];
|
1271
|
-
}
|
1272
|
-
throw new Error("Invalid API provider");
|
1273
|
-
}
|
1274
|
-
const providers = {
|
1275
|
-
production: {
|
1276
|
-
main: "https://api.xata.io",
|
1277
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
1278
|
-
},
|
1279
|
-
staging: {
|
1280
|
-
main: "https://api.staging-xata.dev",
|
1281
|
-
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1282
|
-
},
|
1283
|
-
dev: {
|
1284
|
-
main: "https://api.dev-xata.dev",
|
1285
|
-
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1286
|
-
}
|
1287
|
-
};
|
1288
|
-
function isHostProviderAlias(alias) {
|
1289
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
1290
|
-
}
|
1291
|
-
function isHostProviderBuilder(builder) {
|
1292
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
1293
|
-
}
|
1294
|
-
function parseProviderString(provider = "production") {
|
1295
|
-
if (isHostProviderAlias(provider)) {
|
1296
|
-
return provider;
|
1297
|
-
}
|
1298
|
-
const [main, workspaces] = provider.split(",");
|
1299
|
-
if (!main || !workspaces)
|
1300
|
-
return null;
|
1301
|
-
return { main, workspaces };
|
1302
|
-
}
|
1303
|
-
function buildProviderString(provider) {
|
1304
|
-
if (isHostProviderAlias(provider))
|
1305
|
-
return provider;
|
1306
|
-
return `${provider.main},${provider.workspaces}`;
|
1307
|
-
}
|
1308
|
-
function parseWorkspacesUrlParts(url) {
|
1309
|
-
if (!isString(url))
|
1310
|
-
return null;
|
1311
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1312
|
-
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1313
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1314
|
-
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1315
|
-
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1316
|
-
if (!match)
|
1317
|
-
return null;
|
1318
|
-
return { workspace: match[1], region: match[2] };
|
1319
|
-
}
|
1320
|
-
|
1321
1348
|
var __accessCheck$7 = (obj, member, msg) => {
|
1322
1349
|
if (!member.has(obj))
|
1323
1350
|
throw TypeError("Cannot " + msg);
|
@@ -2678,10 +2705,12 @@ class XataFile {
|
|
2678
2705
|
this.base64Content = file.base64Content;
|
2679
2706
|
this.enablePublicUrl = file.enablePublicUrl;
|
2680
2707
|
this.signedUrlTimeout = file.signedUrlTimeout;
|
2708
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2681
2709
|
this.size = file.size;
|
2682
2710
|
this.version = file.version;
|
2683
2711
|
this.url = file.url;
|
2684
2712
|
this.signedUrl = file.signedUrl;
|
2713
|
+
this.uploadUrl = file.uploadUrl;
|
2685
2714
|
this.attributes = file.attributes;
|
2686
2715
|
}
|
2687
2716
|
static fromBuffer(buffer, options = {}) {
|
@@ -2772,7 +2801,7 @@ class XataFile {
|
|
2772
2801
|
const parseInputFileEntry = async (entry) => {
|
2773
2802
|
if (!isDefined(entry))
|
2774
2803
|
return null;
|
2775
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2804
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2776
2805
|
return compactObject({
|
2777
2806
|
id,
|
2778
2807
|
// Name cannot be an empty string in our API
|
@@ -2780,7 +2809,8 @@ const parseInputFileEntry = async (entry) => {
|
|
2780
2809
|
mediaType,
|
2781
2810
|
base64Content,
|
2782
2811
|
enablePublicUrl,
|
2783
|
-
signedUrlTimeout
|
2812
|
+
signedUrlTimeout,
|
2813
|
+
uploadUrlTimeout
|
2784
2814
|
});
|
2785
2815
|
};
|
2786
2816
|
|
@@ -4848,6 +4878,7 @@ exports.equals = equals;
|
|
4848
4878
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
4849
4879
|
exports.exists = exists;
|
4850
4880
|
exports.fileAccess = fileAccess;
|
4881
|
+
exports.fileUpload = fileUpload;
|
4851
4882
|
exports.ge = ge;
|
4852
4883
|
exports.getAPIKey = getAPIKey;
|
4853
4884
|
exports.getAuthorizationCode = getAuthorizationCode;
|
@@ -4923,6 +4954,7 @@ exports.parseProviderString = parseProviderString;
|
|
4923
4954
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
4924
4955
|
exports.pattern = pattern;
|
4925
4956
|
exports.pgRollJobStatus = pgRollJobStatus;
|
4957
|
+
exports.pgRollMigrationHistory = pgRollMigrationHistory;
|
4926
4958
|
exports.pgRollStatus = pgRollStatus;
|
4927
4959
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4928
4960
|
exports.pushBranchMigrations = pushBranchMigrations;
|