naystack 1.5.13 → 1.5.15

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.
@@ -77,11 +77,12 @@ function getEnv(key, skipCheck) {
77
77
  // src/file/client.ts
78
78
  var useFileUpload = () => {
79
79
  const token = (0, import_client.useToken)();
80
- return (file, type, data) => {
80
+ return (file, type, config) => {
81
81
  const formData = new FormData();
82
82
  formData.append("type", type);
83
83
  formData.append("file", file);
84
- if (data) formData.append("data", JSON.stringify(data));
84
+ if (config?.async) formData.append("async", "true");
85
+ if (config?.data) formData.append("data", JSON.stringify(config.data));
85
86
  return fetch(getEnv("NEXT_PUBLIC_FILE_ENDPOINT" /* NEXT_PUBLIC_FILE_ENDPOINT */), {
86
87
  method: "PUT",
87
88
  body: formData,
@@ -42,7 +42,10 @@
42
42
  *
43
43
  * @category File
44
44
  */
45
- declare const useFileUpload: () => (file: File | Blob, type: string, data?: object) => Promise<FileUploadResponseType>;
45
+ declare const useFileUpload: () => (file: File | Blob, type: string, config?: {
46
+ data?: object;
47
+ async?: boolean;
48
+ }) => Promise<FileUploadResponseType>;
46
49
  /**
47
50
  * Shape of the JSON response from the file upload PUT endpoint.
48
51
  *
@@ -53,7 +56,7 @@ declare const useFileUpload: () => (file: File | Blob, type: string, data?: obje
53
56
  */
54
57
  interface FileUploadResponseType {
55
58
  url?: string;
56
- onUploadResponse?: object;
59
+ data?: object | null;
57
60
  }
58
61
 
59
62
  export { type FileUploadResponseType, useFileUpload };
@@ -42,7 +42,10 @@
42
42
  *
43
43
  * @category File
44
44
  */
45
- declare const useFileUpload: () => (file: File | Blob, type: string, data?: object) => Promise<FileUploadResponseType>;
45
+ declare const useFileUpload: () => (file: File | Blob, type: string, config?: {
46
+ data?: object;
47
+ async?: boolean;
48
+ }) => Promise<FileUploadResponseType>;
46
49
  /**
47
50
  * Shape of the JSON response from the file upload PUT endpoint.
48
51
  *
@@ -53,7 +56,7 @@ declare const useFileUpload: () => (file: File | Blob, type: string, data?: obje
53
56
  */
54
57
  interface FileUploadResponseType {
55
58
  url?: string;
56
- onUploadResponse?: object;
59
+ data?: object | null;
57
60
  }
58
61
 
59
62
  export { type FileUploadResponseType, useFileUpload };
@@ -53,11 +53,12 @@ function getEnv(key, skipCheck) {
53
53
  // src/file/client.ts
54
54
  var useFileUpload = () => {
55
55
  const token = useToken();
56
- return (file, type, data) => {
56
+ return (file, type, config) => {
57
57
  const formData = new FormData();
58
58
  formData.append("type", type);
59
59
  formData.append("file", file);
60
- if (data) formData.append("data", JSON.stringify(data));
60
+ if (config?.async) formData.append("async", "true");
61
+ if (config?.data) formData.append("data", JSON.stringify(config.data));
61
62
  return fetch(getEnv("NEXT_PUBLIC_FILE_ENDPOINT" /* NEXT_PUBLIC_FILE_ENDPOINT */), {
62
63
  method: "PUT",
63
64
  body: formData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.5.13",
3
+ "version": "1.5.15",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",