@xata.io/client 0.28.1 → 0.28.3
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 +12 -0
- package/dist/index.cjs +99 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2754 -2653
- package/dist/index.mjs +98 -63
- 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.3 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 [1m742ms[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 [1m472ms[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.2s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.28.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#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
|
8
|
+
|
9
|
+
## 0.28.2
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- [#1288](https://github.com/xataio/client-ts/pull/1288) [`c9178e1`](https://github.com/xataio/client-ts/commit/c9178e1e3f2268513e78dcfce396a99a8fca5dfb) Thanks [@SferaDev](https://github.com/SferaDev)! - Update read to use `ReadonlyArray<Identifier>`
|
14
|
+
|
3
15
|
## 0.28.1
|
4
16
|
|
5
17
|
### 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.3";
|
532
532
|
|
533
533
|
class ErrorWithCause extends Error {
|
534
534
|
constructor(message, options) {
|
@@ -571,6 +571,62 @@ 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
|
+
};
|
596
|
+
function isHostProviderAlias(alias) {
|
597
|
+
return isString(alias) && Object.keys(providers).includes(alias);
|
598
|
+
}
|
599
|
+
function isHostProviderBuilder(builder) {
|
600
|
+
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
601
|
+
}
|
602
|
+
function parseProviderString(provider = "production") {
|
603
|
+
if (isHostProviderAlias(provider)) {
|
604
|
+
return provider;
|
605
|
+
}
|
606
|
+
const [main, workspaces] = provider.split(",");
|
607
|
+
if (!main || !workspaces)
|
608
|
+
return null;
|
609
|
+
return { main, workspaces };
|
610
|
+
}
|
611
|
+
function buildProviderString(provider) {
|
612
|
+
if (isHostProviderAlias(provider))
|
613
|
+
return provider;
|
614
|
+
return `${provider.main},${provider.workspaces}`;
|
615
|
+
}
|
616
|
+
function parseWorkspacesUrlParts(url) {
|
617
|
+
if (!isString(url))
|
618
|
+
return null;
|
619
|
+
const matches = {
|
620
|
+
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/),
|
621
|
+
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/),
|
622
|
+
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/)
|
623
|
+
};
|
624
|
+
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
625
|
+
if (!isHostProviderAlias(host) || !match)
|
626
|
+
return null;
|
627
|
+
return { workspace: match[1], region: match[2], host };
|
628
|
+
}
|
629
|
+
|
574
630
|
const pool = new ApiRequestPool();
|
575
631
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
576
632
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -586,6 +642,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
586
642
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
587
643
|
};
|
588
644
|
function buildBaseUrl({
|
645
|
+
method,
|
589
646
|
endpoint,
|
590
647
|
path,
|
591
648
|
workspacesApiUrl,
|
@@ -593,7 +650,24 @@ function buildBaseUrl({
|
|
593
650
|
pathParams = {}
|
594
651
|
}) {
|
595
652
|
if (endpoint === "dataPlane") {
|
596
|
-
|
653
|
+
let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
654
|
+
if (method.toUpperCase() === "PUT" && [
|
655
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
656
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
|
657
|
+
].includes(path)) {
|
658
|
+
const { host } = parseWorkspacesUrlParts(url) ?? {};
|
659
|
+
switch (host) {
|
660
|
+
case "production":
|
661
|
+
url = url.replace("xata.sh", "upload.xata.sh");
|
662
|
+
break;
|
663
|
+
case "staging":
|
664
|
+
url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
|
665
|
+
break;
|
666
|
+
case "dev":
|
667
|
+
url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
|
668
|
+
break;
|
669
|
+
}
|
670
|
+
}
|
597
671
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
598
672
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
599
673
|
}
|
@@ -642,7 +716,7 @@ async function fetch$1({
|
|
642
716
|
return await trace(
|
643
717
|
`${method.toUpperCase()} ${path}`,
|
644
718
|
async ({ setAttributes }) => {
|
645
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
719
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
646
720
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
647
721
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
648
722
|
setAttributes({
|
@@ -725,7 +799,7 @@ function fetchSSERequest({
|
|
725
799
|
clientName,
|
726
800
|
xataAgentExtra
|
727
801
|
}) {
|
728
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
802
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
729
803
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
730
804
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
731
805
|
void fetchEventSource(url, {
|
@@ -775,6 +849,12 @@ const pgRollStatus = (variables, signal) => dataPlaneFetch({
|
|
775
849
|
...variables,
|
776
850
|
signal
|
777
851
|
});
|
852
|
+
const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
|
853
|
+
url: "/db/{dbBranchName}/pgroll/jobs/{jobId}",
|
854
|
+
method: "get",
|
855
|
+
...variables,
|
856
|
+
signal
|
857
|
+
});
|
778
858
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
779
859
|
url: "/dbs/{dbName}",
|
780
860
|
method: "get",
|
@@ -981,6 +1061,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
981
1061
|
...variables,
|
982
1062
|
signal
|
983
1063
|
});
|
1064
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1065
|
+
url: "/file/{fileId}",
|
1066
|
+
method: "put",
|
1067
|
+
...variables,
|
1068
|
+
signal
|
1069
|
+
});
|
984
1070
|
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
985
1071
|
url: "/db/{dbBranchName}/sql",
|
986
1072
|
method: "post",
|
@@ -991,6 +1077,7 @@ const operationsByTag$2 = {
|
|
991
1077
|
branch: {
|
992
1078
|
applyMigration,
|
993
1079
|
pgRollStatus,
|
1080
|
+
pgRollJobStatus,
|
994
1081
|
getBranchList,
|
995
1082
|
getBranchDetails,
|
996
1083
|
createBranch,
|
@@ -1049,7 +1136,7 @@ const operationsByTag$2 = {
|
|
1049
1136
|
deleteRecord,
|
1050
1137
|
bulkInsertTableRecords
|
1051
1138
|
},
|
1052
|
-
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1139
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1053
1140
|
searchAndFilter: {
|
1054
1141
|
queryTable,
|
1055
1142
|
searchBranch,
|
@@ -1256,61 +1343,6 @@ const operationsByTag$1 = {
|
|
1256
1343
|
|
1257
1344
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1258
1345
|
|
1259
|
-
function getHostUrl(provider, type) {
|
1260
|
-
if (isHostProviderAlias(provider)) {
|
1261
|
-
return providers[provider][type];
|
1262
|
-
} else if (isHostProviderBuilder(provider)) {
|
1263
|
-
return provider[type];
|
1264
|
-
}
|
1265
|
-
throw new Error("Invalid API provider");
|
1266
|
-
}
|
1267
|
-
const providers = {
|
1268
|
-
production: {
|
1269
|
-
main: "https://api.xata.io",
|
1270
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
1271
|
-
},
|
1272
|
-
staging: {
|
1273
|
-
main: "https://api.staging-xata.dev",
|
1274
|
-
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1275
|
-
},
|
1276
|
-
dev: {
|
1277
|
-
main: "https://api.dev-xata.dev",
|
1278
|
-
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1279
|
-
}
|
1280
|
-
};
|
1281
|
-
function isHostProviderAlias(alias) {
|
1282
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
1283
|
-
}
|
1284
|
-
function isHostProviderBuilder(builder) {
|
1285
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
1286
|
-
}
|
1287
|
-
function parseProviderString(provider = "production") {
|
1288
|
-
if (isHostProviderAlias(provider)) {
|
1289
|
-
return provider;
|
1290
|
-
}
|
1291
|
-
const [main, workspaces] = provider.split(",");
|
1292
|
-
if (!main || !workspaces)
|
1293
|
-
return null;
|
1294
|
-
return { main, workspaces };
|
1295
|
-
}
|
1296
|
-
function buildProviderString(provider) {
|
1297
|
-
if (isHostProviderAlias(provider))
|
1298
|
-
return provider;
|
1299
|
-
return `${provider.main},${provider.workspaces}`;
|
1300
|
-
}
|
1301
|
-
function parseWorkspacesUrlParts(url) {
|
1302
|
-
if (!isString(url))
|
1303
|
-
return null;
|
1304
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1305
|
-
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1306
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1307
|
-
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1308
|
-
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1309
|
-
if (!match)
|
1310
|
-
return null;
|
1311
|
-
return { workspace: match[1], region: match[2] };
|
1312
|
-
}
|
1313
|
-
|
1314
1346
|
var __accessCheck$7 = (obj, member, msg) => {
|
1315
1347
|
if (!member.has(obj))
|
1316
1348
|
throw TypeError("Cannot " + msg);
|
@@ -2671,10 +2703,12 @@ class XataFile {
|
|
2671
2703
|
this.base64Content = file.base64Content;
|
2672
2704
|
this.enablePublicUrl = file.enablePublicUrl;
|
2673
2705
|
this.signedUrlTimeout = file.signedUrlTimeout;
|
2706
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2674
2707
|
this.size = file.size;
|
2675
2708
|
this.version = file.version;
|
2676
2709
|
this.url = file.url;
|
2677
2710
|
this.signedUrl = file.signedUrl;
|
2711
|
+
this.uploadUrl = file.uploadUrl;
|
2678
2712
|
this.attributes = file.attributes;
|
2679
2713
|
}
|
2680
2714
|
static fromBuffer(buffer, options = {}) {
|
@@ -2765,7 +2799,7 @@ class XataFile {
|
|
2765
2799
|
const parseInputFileEntry = async (entry) => {
|
2766
2800
|
if (!isDefined(entry))
|
2767
2801
|
return null;
|
2768
|
-
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2802
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2769
2803
|
return compactObject({
|
2770
2804
|
id,
|
2771
2805
|
// Name cannot be an empty string in our API
|
@@ -2773,7 +2807,8 @@ const parseInputFileEntry = async (entry) => {
|
|
2773
2807
|
mediaType,
|
2774
2808
|
base64Content,
|
2775
2809
|
enablePublicUrl,
|
2776
|
-
signedUrlTimeout
|
2810
|
+
signedUrlTimeout,
|
2811
|
+
uploadUrlTimeout
|
2777
2812
|
});
|
2778
2813
|
};
|
2779
2814
|
|
@@ -4841,6 +4876,7 @@ exports.equals = equals;
|
|
4841
4876
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
4842
4877
|
exports.exists = exists;
|
4843
4878
|
exports.fileAccess = fileAccess;
|
4879
|
+
exports.fileUpload = fileUpload;
|
4844
4880
|
exports.ge = ge;
|
4845
4881
|
exports.getAPIKey = getAPIKey;
|
4846
4882
|
exports.getAuthorizationCode = getAuthorizationCode;
|
@@ -4915,6 +4951,7 @@ exports.operationsByTag = operationsByTag;
|
|
4915
4951
|
exports.parseProviderString = parseProviderString;
|
4916
4952
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
4917
4953
|
exports.pattern = pattern;
|
4954
|
+
exports.pgRollJobStatus = pgRollJobStatus;
|
4918
4955
|
exports.pgRollStatus = pgRollStatus;
|
4919
4956
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4920
4957
|
exports.pushBranchMigrations = pushBranchMigrations;
|