@xata.io/client 0.26.3 → 0.26.5

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/dist/index.d.ts CHANGED
@@ -7052,6 +7052,11 @@ interface ImageTransformations {
7052
7052
  * ignored.
7053
7053
  */
7054
7054
  contrast?: number;
7055
+ /**
7056
+ * Download file. Forces browser to download the image.
7057
+ * Value is used for the download file name. Extension is optional.
7058
+ */
7059
+ download?: string;
7055
7060
  /**
7056
7061
  * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
7057
7062
  * easier to specify higher-DPI sizes in <img srcset>.
@@ -7173,19 +7178,23 @@ declare function transformImage(url: string | undefined, ...transformations: Ima
7173
7178
  type XataFileEditableFields = Partial<Pick<XataArrayFile, keyof InputFileEntry>>;
7174
7179
  declare class XataFile {
7175
7180
  /**
7176
- * Name of this file.
7181
+ * Identifier of the file.
7182
+ */
7183
+ id?: string;
7184
+ /**
7185
+ * Name of the file.
7177
7186
  */
7178
7187
  name: string;
7179
7188
  /**
7180
- * Media type of this file.
7189
+ * Media type of the file.
7181
7190
  */
7182
7191
  mediaType: string;
7183
7192
  /**
7184
- * Base64 encoded content of this file.
7193
+ * Base64 encoded content of the file.
7185
7194
  */
7186
7195
  base64Content?: string;
7187
7196
  /**
7188
- * Whether to enable public url for this file.
7197
+ * Whether to enable public url for the file.
7189
7198
  */
7190
7199
  enablePublicUrl: boolean;
7191
7200
  /**
@@ -7193,23 +7202,23 @@ declare class XataFile {
7193
7202
  */
7194
7203
  signedUrlTimeout: number;
7195
7204
  /**
7196
- * Size of this file.
7205
+ * Size of the file.
7197
7206
  */
7198
7207
  size?: number;
7199
7208
  /**
7200
- * Version of this file.
7209
+ * Version of the file.
7201
7210
  */
7202
7211
  version: number;
7203
7212
  /**
7204
- * Url of this file.
7213
+ * Url of the file.
7205
7214
  */
7206
7215
  url: string;
7207
7216
  /**
7208
- * Signed url of this file.
7217
+ * Signed url of the file.
7209
7218
  */
7210
7219
  signedUrl?: string;
7211
7220
  /**
7212
- * Attributes of this file.
7221
+ * Attributes of the file.
7213
7222
  */
7214
7223
  attributes: Record<string, any>;
7215
7224
  constructor(file: Partial<XataFile>);
package/dist/index.mjs CHANGED
@@ -18,7 +18,8 @@ const TraceAttributes = {
18
18
  HTTP_METHOD: "http.method",
19
19
  HTTP_URL: "http.url",
20
20
  HTTP_ROUTE: "http.route",
21
- HTTP_TARGET: "http.target"
21
+ HTTP_TARGET: "http.target",
22
+ CLOUDFLARE_RAY_ID: "cf.ray"
22
23
  };
23
24
 
24
25
  function notEmpty(value) {
@@ -30,8 +31,15 @@ function compact(arr) {
30
31
  function compactObject(obj) {
31
32
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
32
33
  }
34
+ function isBlob(value) {
35
+ try {
36
+ return value instanceof Blob;
37
+ } catch (error) {
38
+ return false;
39
+ }
40
+ }
33
41
  function isObject(value) {
34
- return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
42
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
35
43
  }
36
44
  function isDefined(value) {
37
45
  return value !== null && value !== void 0;
@@ -263,14 +271,13 @@ var __privateMethod$4 = (obj, member, method) => {
263
271
  return method;
264
272
  };
265
273
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
266
- const REQUEST_TIMEOUT = 3e4;
274
+ const REQUEST_TIMEOUT = 5 * 60 * 1e3;
267
275
  function getFetchImplementation(userFetch) {
268
276
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
269
- const fetchImpl = userFetch ?? globalFetch;
277
+ const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
278
+ const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
270
279
  if (!fetchImpl) {
271
- throw new Error(
272
- `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
273
- );
280
+ throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
274
281
  }
275
282
  return fetchImpl;
276
283
  }
@@ -527,7 +534,7 @@ function defaultOnOpen(response) {
527
534
  }
528
535
  }
529
536
 
530
- const VERSION = "0.26.3";
537
+ const VERSION = "0.26.5";
531
538
 
532
539
  var __defProp$7 = Object.defineProperty;
533
540
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -616,7 +623,7 @@ function hostHeader(url) {
616
623
  async function parseBody(body, headers) {
617
624
  if (!isDefined(body))
618
625
  return void 0;
619
- if (body instanceof Blob || typeof body.text === "function") {
626
+ if (isBlob(body) || typeof body.text === "function") {
620
627
  return body;
621
628
  }
622
629
  const { "Content-Type": contentType } = headers ?? {};
@@ -688,7 +695,8 @@ async function fetch$1({
688
695
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
689
696
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
690
697
  [TraceAttributes.HTTP_HOST]: host,
691
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
698
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
699
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
692
700
  });
693
701
  const message = response.headers?.get("x-xata-message");
694
702
  if (message)
@@ -2671,7 +2679,7 @@ function getContentType(file) {
2671
2679
  if (typeof file === "string") {
2672
2680
  return "text/plain";
2673
2681
  }
2674
- if (file instanceof Blob) {
2682
+ if (isBlob(file)) {
2675
2683
  return file.type;
2676
2684
  }
2677
2685
  try {
@@ -2718,19 +2726,23 @@ var __publicField$6 = (obj, key, value) => {
2718
2726
  class XataFile {
2719
2727
  constructor(file) {
2720
2728
  /**
2721
- * Name of this file.
2729
+ * Identifier of the file.
2730
+ */
2731
+ __publicField$6(this, "id");
2732
+ /**
2733
+ * Name of the file.
2722
2734
  */
2723
2735
  __publicField$6(this, "name");
2724
2736
  /**
2725
- * Media type of this file.
2737
+ * Media type of the file.
2726
2738
  */
2727
2739
  __publicField$6(this, "mediaType");
2728
2740
  /**
2729
- * Base64 encoded content of this file.
2741
+ * Base64 encoded content of the file.
2730
2742
  */
2731
2743
  __publicField$6(this, "base64Content");
2732
2744
  /**
2733
- * Whether to enable public url for this file.
2745
+ * Whether to enable public url for the file.
2734
2746
  */
2735
2747
  __publicField$6(this, "enablePublicUrl");
2736
2748
  /**
@@ -2738,25 +2750,26 @@ class XataFile {
2738
2750
  */
2739
2751
  __publicField$6(this, "signedUrlTimeout");
2740
2752
  /**
2741
- * Size of this file.
2753
+ * Size of the file.
2742
2754
  */
2743
2755
  __publicField$6(this, "size");
2744
2756
  /**
2745
- * Version of this file.
2757
+ * Version of the file.
2746
2758
  */
2747
2759
  __publicField$6(this, "version");
2748
2760
  /**
2749
- * Url of this file.
2761
+ * Url of the file.
2750
2762
  */
2751
2763
  __publicField$6(this, "url");
2752
2764
  /**
2753
- * Signed url of this file.
2765
+ * Signed url of the file.
2754
2766
  */
2755
2767
  __publicField$6(this, "signedUrl");
2756
2768
  /**
2757
- * Attributes of this file.
2769
+ * Attributes of the file.
2758
2770
  */
2759
2771
  __publicField$6(this, "attributes");
2772
+ this.id = file.id;
2760
2773
  this.name = file.name || "";
2761
2774
  this.mediaType = file.mediaType || "application/octet-stream";
2762
2775
  this.base64Content = file.base64Content;
@@ -2857,7 +2870,15 @@ const parseInputFileEntry = async (entry) => {
2857
2870
  if (!isDefined(entry))
2858
2871
  return null;
2859
2872
  const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2860
- return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
2873
+ return compactObject({
2874
+ id,
2875
+ // Name cannot be an empty string in our API
2876
+ name: name ? name : void 0,
2877
+ mediaType,
2878
+ base64Content,
2879
+ enablePublicUrl,
2880
+ signedUrlTimeout
2881
+ });
2861
2882
  };
2862
2883
 
2863
2884
  function cleanFilter(filter) {