@xata.io/client 0.26.0 → 0.26.2
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 +16 -0
- package/dist/index.cjs +47 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -11
- package/dist/index.mjs +47 -18
- 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.26.
|
2
|
+
> @xata.io/client@0.26.2 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.3s[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 [1m964ms[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 [
|
13
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m6.8s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.26.2
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#1147](https://github.com/xataio/client-ts/pull/1147) [`22fccb51`](https://github.com/xataio/client-ts/commit/22fccb51709749c319897702c15749b74ce4b820) Thanks [@SferaDev](https://github.com/SferaDev)! - Expose metadataSignedUrl
|
8
|
+
|
9
|
+
## 0.26.1
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- [#1139](https://github.com/xataio/client-ts/pull/1139) [`922e6e54`](https://github.com/xataio/client-ts/commit/922e6e54e8b31641770a36b6b4ff8f4fa65d304d) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix scenario with merging existing transformations
|
14
|
+
|
15
|
+
- [#1140](https://github.com/xataio/client-ts/pull/1140) [`13f6f3e4`](https://github.com/xataio/client-ts/commit/13f6f3e4b1a2f925d50a5380b62ef1057f5c3893) Thanks [@SferaDev](https://github.com/SferaDev)! - Add metadata url for transformations
|
16
|
+
|
17
|
+
- [#1136](https://github.com/xataio/client-ts/pull/1136) [`f02fc165`](https://github.com/xataio/client-ts/commit/f02fc165bf6558e4377eb9f8e1d0f4222f004c70) Thanks [@SferaDev](https://github.com/SferaDev)! - Fixes for Blob files in binary APIs
|
18
|
+
|
3
19
|
## 0.26.0
|
4
20
|
|
5
21
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
@@ -33,7 +33,7 @@ function compactObject(obj) {
|
|
33
33
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
34
34
|
}
|
35
35
|
function isObject(value) {
|
36
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
36
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
|
37
37
|
}
|
38
38
|
function isDefined(value) {
|
39
39
|
return value !== null && value !== void 0;
|
@@ -529,7 +529,7 @@ function defaultOnOpen(response) {
|
|
529
529
|
}
|
530
530
|
}
|
531
531
|
|
532
|
-
const VERSION = "0.26.
|
532
|
+
const VERSION = "0.26.2";
|
533
533
|
|
534
534
|
var __defProp$7 = Object.defineProperty;
|
535
535
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
@@ -615,11 +615,14 @@ function hostHeader(url) {
|
|
615
615
|
const { groups } = pattern.exec(url) ?? {};
|
616
616
|
return groups?.host ? { Host: groups.host } : {};
|
617
617
|
}
|
618
|
-
function parseBody(body, headers) {
|
618
|
+
async function parseBody(body, headers) {
|
619
619
|
if (!isDefined(body))
|
620
620
|
return void 0;
|
621
|
+
if (body instanceof Blob || typeof body.text === "function") {
|
622
|
+
return body;
|
623
|
+
}
|
621
624
|
const { "Content-Type": contentType } = headers ?? {};
|
622
|
-
if (String(contentType).toLowerCase() === "application/json") {
|
625
|
+
if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
|
623
626
|
return JSON.stringify(body);
|
624
627
|
}
|
625
628
|
return body;
|
@@ -676,7 +679,7 @@ async function fetch$1({
|
|
676
679
|
const response = await pool.request(url, {
|
677
680
|
...fetchOptions,
|
678
681
|
method: method.toUpperCase(),
|
679
|
-
body: parseBody(body, headers),
|
682
|
+
body: await parseBody(body, headers),
|
680
683
|
headers,
|
681
684
|
signal
|
682
685
|
});
|
@@ -2632,7 +2635,9 @@ class FilesPlugin extends XataPlugin {
|
|
2632
2635
|
},
|
2633
2636
|
upload: async (location, file) => {
|
2634
2637
|
const { table, record, column, fileId = "" } = location ?? {};
|
2638
|
+
const contentType = getContentType(file);
|
2635
2639
|
return await putFileItem({
|
2640
|
+
...pluginOptions,
|
2636
2641
|
pathParams: {
|
2637
2642
|
workspace: "{workspaceId}",
|
2638
2643
|
dbBranchName: "{dbBranch}",
|
@@ -2643,7 +2648,7 @@ class FilesPlugin extends XataPlugin {
|
|
2643
2648
|
fileId
|
2644
2649
|
},
|
2645
2650
|
body: file,
|
2646
|
-
|
2651
|
+
headers: { "Content-Type": contentType }
|
2647
2652
|
});
|
2648
2653
|
},
|
2649
2654
|
delete: async (location) => {
|
@@ -2664,6 +2669,19 @@ class FilesPlugin extends XataPlugin {
|
|
2664
2669
|
};
|
2665
2670
|
}
|
2666
2671
|
}
|
2672
|
+
function getContentType(file) {
|
2673
|
+
if (typeof file === "string") {
|
2674
|
+
return "text/plain";
|
2675
|
+
}
|
2676
|
+
if (file instanceof Blob) {
|
2677
|
+
return file.type;
|
2678
|
+
}
|
2679
|
+
try {
|
2680
|
+
return file.type;
|
2681
|
+
} catch (e) {
|
2682
|
+
}
|
2683
|
+
return "application/octet-stream";
|
2684
|
+
}
|
2667
2685
|
|
2668
2686
|
function buildTransformString(transformations) {
|
2669
2687
|
return transformations.flatMap(
|
@@ -2683,9 +2701,14 @@ function buildTransformString(transformations) {
|
|
2683
2701
|
function transformImage(url, ...transformations) {
|
2684
2702
|
if (!isDefined(url))
|
2685
2703
|
return void 0;
|
2686
|
-
const
|
2704
|
+
const newTransformations = buildTransformString(transformations);
|
2687
2705
|
const { hostname, pathname, search } = new URL(url);
|
2688
|
-
|
2706
|
+
const pathParts = pathname.split("/");
|
2707
|
+
const transformIndex = pathParts.findIndex((part) => part === "transform");
|
2708
|
+
const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
|
2709
|
+
const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
|
2710
|
+
const path = pathParts.join("/");
|
2711
|
+
return `https://${hostname}${transform}${path}${search}`;
|
2689
2712
|
}
|
2690
2713
|
|
2691
2714
|
var __defProp$6 = Object.defineProperty;
|
@@ -2736,16 +2759,16 @@ class XataFile {
|
|
2736
2759
|
* Attributes of this file.
|
2737
2760
|
*/
|
2738
2761
|
__publicField$6(this, "attributes");
|
2739
|
-
this.name = file.name;
|
2762
|
+
this.name = file.name || "";
|
2740
2763
|
this.mediaType = file.mediaType || "application/octet-stream";
|
2741
2764
|
this.base64Content = file.base64Content;
|
2742
|
-
this.enablePublicUrl = file.enablePublicUrl;
|
2743
|
-
this.signedUrlTimeout = file.signedUrlTimeout;
|
2744
|
-
this.size = file.size;
|
2745
|
-
this.version = file.version;
|
2746
|
-
this.url = file.url;
|
2765
|
+
this.enablePublicUrl = file.enablePublicUrl ?? false;
|
2766
|
+
this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
|
2767
|
+
this.size = file.size ?? 0;
|
2768
|
+
this.version = file.version ?? 1;
|
2769
|
+
this.url = file.url || "";
|
2747
2770
|
this.signedUrl = file.signedUrl;
|
2748
|
-
this.attributes = file.attributes;
|
2771
|
+
this.attributes = file.attributes || {};
|
2749
2772
|
}
|
2750
2773
|
static fromBuffer(buffer, options = {}) {
|
2751
2774
|
const base64Content = buffer.toString("base64");
|
@@ -2797,8 +2820,12 @@ class XataFile {
|
|
2797
2820
|
if (!this.base64Content) {
|
2798
2821
|
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2799
2822
|
}
|
2800
|
-
const
|
2801
|
-
|
2823
|
+
const binary = atob(this.base64Content);
|
2824
|
+
const uint8Array = new Uint8Array(binary.length);
|
2825
|
+
for (let i = 0; i < binary.length; i++) {
|
2826
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2827
|
+
}
|
2828
|
+
return new Blob([uint8Array], { type: this.mediaType });
|
2802
2829
|
}
|
2803
2830
|
static fromString(string, options = {}) {
|
2804
2831
|
const base64Content = btoa(string);
|
@@ -2822,7 +2849,9 @@ class XataFile {
|
|
2822
2849
|
transform(...options) {
|
2823
2850
|
return {
|
2824
2851
|
url: transformImage(this.url, ...options),
|
2825
|
-
signedUrl: transformImage(this.signedUrl, ...options)
|
2852
|
+
signedUrl: transformImage(this.signedUrl, ...options),
|
2853
|
+
metadataUrl: transformImage(this.url, ...options, { format: "json" }),
|
2854
|
+
metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
|
2826
2855
|
};
|
2827
2856
|
}
|
2828
2857
|
}
|