@nhost/nhost-js 3.2.8 → 5.0.0-beta.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/README.md +73 -37
- package/dist/nhost-js/auth.cjs.js +2 -0
- package/dist/nhost-js/auth.cjs.js.map +1 -0
- package/dist/nhost-js/auth.es.js +589 -0
- package/dist/nhost-js/auth.es.js.map +1 -0
- package/dist/nhost-js/fetch.cjs.js +2 -0
- package/dist/nhost-js/fetch.cjs.js.map +1 -0
- package/dist/nhost-js/fetch.es.js +10 -0
- package/dist/nhost-js/fetch.es.js.map +1 -0
- package/dist/nhost-js/functions.cjs.js +2 -0
- package/dist/nhost-js/functions.cjs.js.map +1 -0
- package/dist/nhost-js/functions.es.js +31 -0
- package/dist/nhost-js/functions.es.js.map +1 -0
- package/dist/nhost-js/graphql.cjs.js +2 -0
- package/dist/nhost-js/graphql.cjs.js.map +1 -0
- package/dist/nhost-js/graphql.es.js +35 -0
- package/dist/nhost-js/graphql.es.js.map +1 -0
- package/dist/nhost-js/storage.cjs.js +2 -0
- package/dist/nhost-js/storage.cjs.js.map +1 -0
- package/dist/nhost-js/storage.es.js +205 -0
- package/dist/nhost-js/storage.es.js.map +1 -0
- package/dist/nhost-js.cjs.js +2 -0
- package/dist/nhost-js.cjs.js.map +1 -0
- package/dist/nhost-js.es.js +497 -0
- package/dist/nhost-js.es.js.map +1 -0
- package/dist/nhost-js.umd.js +2 -0
- package/dist/nhost-js.umd.js.map +1 -0
- package/dist/src/auth/client.d.ts +430 -0
- package/dist/src/auth/client.d.ts.map +1 -0
- package/dist/src/auth/client.js +727 -0
- package/dist/src/auth/client.js.map +1 -0
- package/dist/src/auth/index.d.ts +11 -0
- package/dist/src/auth/index.d.ts.map +1 -0
- package/dist/src/auth/index.js +11 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/interface.d.ts +142 -0
- package/dist/src/auth/interface.d.ts.map +1 -0
- package/dist/src/auth/interface.js +2 -0
- package/dist/src/auth/interface.js.map +1 -0
- package/dist/src/fetch/index.d.ts +53 -0
- package/dist/src/fetch/index.d.ts.map +1 -0
- package/dist/src/fetch/index.js +40 -0
- package/dist/src/fetch/index.js.map +1 -0
- package/dist/src/functions/client.d.ts +47 -0
- package/dist/src/functions/client.d.ts.map +1 -0
- package/dist/src/functions/client.js +62 -0
- package/dist/src/functions/client.js.map +1 -0
- package/dist/src/functions/index.d.ts +10 -0
- package/dist/src/functions/index.d.ts.map +1 -0
- package/dist/src/functions/index.js +10 -0
- package/dist/src/functions/index.js.map +1 -0
- package/dist/src/graphql/client.d.ts +89 -0
- package/dist/src/graphql/client.d.ts.map +1 -0
- package/dist/src/graphql/client.js +49 -0
- package/dist/src/graphql/client.js.map +1 -0
- package/dist/src/graphql/index.d.ts +10 -0
- package/dist/src/graphql/index.d.ts.map +1 -0
- package/dist/src/graphql/index.js +10 -0
- package/dist/src/graphql/index.js.map +1 -0
- package/dist/src/index.d.ts +184 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +251 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/middlewareAttachToken.d.ts +24 -0
- package/dist/src/middlewareAttachToken.d.ts.map +1 -0
- package/dist/src/middlewareAttachToken.js +60 -0
- package/dist/src/middlewareAttachToken.js.map +1 -0
- package/dist/src/middlewareRefreshSession.d.ts +43 -0
- package/dist/src/middlewareRefreshSession.d.ts.map +1 -0
- package/dist/src/middlewareRefreshSession.js +190 -0
- package/dist/src/middlewareRefreshSession.js.map +1 -0
- package/dist/src/middlewareResponseSession.d.ts +26 -0
- package/dist/src/middlewareResponseSession.d.ts.map +1 -0
- package/dist/src/middlewareResponseSession.js +83 -0
- package/dist/src/middlewareResponseSession.js.map +1 -0
- package/dist/src/sessionStorage.d.ts +123 -0
- package/dist/src/sessionStorage.d.ts.map +1 -0
- package/dist/src/sessionStorage.js +165 -0
- package/dist/src/sessionStorage.js.map +1 -0
- package/dist/src/storage/client.d.ts +184 -0
- package/dist/src/storage/client.d.ts.map +1 -0
- package/dist/src/storage/client.js +249 -0
- package/dist/src/storage/client.js.map +1 -0
- package/dist/src/storage/index.d.ts +11 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +11 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interface.d.ts +52 -0
- package/dist/src/storage/interface.d.ts.map +1 -0
- package/dist/src/storage/interface.js +2 -0
- package/dist/src/storage/interface.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +109 -63
- package/LICENSE +0 -21
- package/dist/clients/auth.d.ts +0 -8
- package/dist/clients/auth.d.ts.map +0 -1
- package/dist/clients/functions/index.d.ts +0 -107
- package/dist/clients/functions/index.d.ts.map +0 -1
- package/dist/clients/functions/types.d.ts +0 -28
- package/dist/clients/functions/types.d.ts.map +0 -1
- package/dist/clients/graphql.d.ts +0 -8
- package/dist/clients/graphql.d.ts.map +0 -1
- package/dist/clients/index.d.ts +0 -6
- package/dist/clients/index.d.ts.map +0 -1
- package/dist/clients/nhost.d.ts +0 -83
- package/dist/clients/nhost.d.ts.map +0 -1
- package/dist/clients/storage.d.ts +0 -8
- package/dist/clients/storage.d.ts.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.js +0 -344
- package/dist/index.esm.js.map +0 -1
- package/dist/utils/helpers.d.ts +0 -20
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/types.d.ts +0 -57
- package/dist/utils/types.d.ts.map +0 -1
- package/umd/nhost-js.umd.js +0 -22
- package/umd/nhost-js.umd.js.map +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { ChainFunction } from "../fetch";
|
|
2
|
+
import type { Client } from "./interface";
|
|
3
|
+
/**
|
|
4
|
+
* Contains version information about the storage service.
|
|
5
|
+
*/
|
|
6
|
+
export interface VersionInformation {
|
|
7
|
+
/** The version number of the storage service build. */
|
|
8
|
+
buildVersion?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Basic information about a file in storage.
|
|
12
|
+
*/
|
|
13
|
+
export interface FileSummary {
|
|
14
|
+
/** Unique identifier for the file. */
|
|
15
|
+
id?: string;
|
|
16
|
+
/** Name of the file including extension. */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** ID of the bucket containing the file. */
|
|
19
|
+
bucketId?: string;
|
|
20
|
+
/** Whether the file has been successfully uploaded. */
|
|
21
|
+
isUploaded?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Custom metadata associated with the file.
|
|
25
|
+
*/
|
|
26
|
+
export type FileMetadataMetadata = {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Comprehensive metadata information about a file in storage.
|
|
31
|
+
*/
|
|
32
|
+
export interface FileMetadata {
|
|
33
|
+
/** Unique identifier for the file. */
|
|
34
|
+
id?: string;
|
|
35
|
+
/** Name of the file including extension. */
|
|
36
|
+
name?: string;
|
|
37
|
+
/** Size of the file in bytes. */
|
|
38
|
+
size?: number;
|
|
39
|
+
/** ID of the bucket containing the file. */
|
|
40
|
+
bucketId?: string;
|
|
41
|
+
/** Entity tag for cache validation. */
|
|
42
|
+
etag?: string;
|
|
43
|
+
/** Timestamp when the file was created. */
|
|
44
|
+
createdAt?: string;
|
|
45
|
+
/** Timestamp when the file was last updated. */
|
|
46
|
+
updatedAt?: string;
|
|
47
|
+
/** Whether the file has been successfully uploaded. */
|
|
48
|
+
isUploaded?: boolean;
|
|
49
|
+
/** MIME type of the file. */
|
|
50
|
+
mimeType?: string;
|
|
51
|
+
/** ID of the user who uploaded the file. */
|
|
52
|
+
uploadedByUserId?: string;
|
|
53
|
+
/** Custom metadata associated with the file. */
|
|
54
|
+
metadata?: FileMetadataMetadata;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Custom metadata to associate with the file.
|
|
58
|
+
*/
|
|
59
|
+
export type UploadFileMetadataMetadata = {
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Metadata provided when uploading a new file.
|
|
64
|
+
*/
|
|
65
|
+
export interface UploadFileMetadata {
|
|
66
|
+
/** Optional custom ID for the file. If not provided, a UUID will be generated. */
|
|
67
|
+
id?: string;
|
|
68
|
+
/** Name to assign to the file. If not provided, the original filename will be used. */
|
|
69
|
+
name?: string;
|
|
70
|
+
/** Custom metadata to associate with the file. */
|
|
71
|
+
metadata?: UploadFileMetadataMetadata;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Updated custom metadata to associate with the file.
|
|
75
|
+
*/
|
|
76
|
+
export type UpdateFileMetadataMetadata = {
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Metadata that can be updated for an existing file.
|
|
81
|
+
*/
|
|
82
|
+
export interface UpdateFileMetadata {
|
|
83
|
+
/** New name to assign to the file. */
|
|
84
|
+
name?: string;
|
|
85
|
+
/** Updated custom metadata to associate with the file. */
|
|
86
|
+
metadata?: UpdateFileMetadataMetadata;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Contains a presigned URL for direct file operations.
|
|
90
|
+
*/
|
|
91
|
+
export interface PresignedURLResponse {
|
|
92
|
+
/** The presigned URL for file operations. */
|
|
93
|
+
url?: string;
|
|
94
|
+
/** The time in seconds until the URL expires. */
|
|
95
|
+
expiration?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Error details.
|
|
99
|
+
*/
|
|
100
|
+
export type ErrorError = {
|
|
101
|
+
/** Human-readable error message. */
|
|
102
|
+
message: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Error information returned by the API.
|
|
106
|
+
*/
|
|
107
|
+
export interface Error {
|
|
108
|
+
/** Error details. */
|
|
109
|
+
error?: ErrorError;
|
|
110
|
+
}
|
|
111
|
+
export type GetOpenAPISpec200 = {
|
|
112
|
+
[key: string]: unknown;
|
|
113
|
+
};
|
|
114
|
+
export type UploadFilesBody = {
|
|
115
|
+
/** Target bucket identifier where files will be stored. */
|
|
116
|
+
"bucket-id"?: string;
|
|
117
|
+
/** Optional custom metadata for each uploaded file. Must match the order of the file[] array. */
|
|
118
|
+
"metadata[]"?: UploadFileMetadata[];
|
|
119
|
+
/** Array of files to upload. */
|
|
120
|
+
"file[]"?: Blob[];
|
|
121
|
+
};
|
|
122
|
+
export type UploadFiles201 = {
|
|
123
|
+
/** List of successfully processed files with their metadata. */
|
|
124
|
+
processedFiles?: FileMetadata[];
|
|
125
|
+
};
|
|
126
|
+
export type GetFileMetadataHeadersParams = {
|
|
127
|
+
/**
|
|
128
|
+
* Image quality (1-100). Only applies to JPEG, WebP and PNG files
|
|
129
|
+
*/
|
|
130
|
+
q?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Maximum height to resize image to while maintaining aspect ratio. Only applies to image files
|
|
133
|
+
*/
|
|
134
|
+
h?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Maximum width to resize image to while maintaining aspect ratio. Only applies to image files
|
|
137
|
+
*/
|
|
138
|
+
w?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Blur the image using this sigma value. Only applies to image files
|
|
141
|
+
*/
|
|
142
|
+
b?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Output format for image files. Use 'auto' for content negotiation based on Accept header
|
|
145
|
+
*/
|
|
146
|
+
f?: GetFileMetadataHeadersF;
|
|
147
|
+
};
|
|
148
|
+
export type GetFileMetadataHeadersF = "auto" | "same" | "jpeg" | "webp" | "png" | "avif";
|
|
149
|
+
export type GetFileParams = {
|
|
150
|
+
/**
|
|
151
|
+
* Image quality (1-100). Only applies to JPEG, WebP and PNG files
|
|
152
|
+
*/
|
|
153
|
+
q?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Maximum height to resize image to while maintaining aspect ratio. Only applies to image files
|
|
156
|
+
*/
|
|
157
|
+
h?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Maximum width to resize image to while maintaining aspect ratio. Only applies to image files
|
|
160
|
+
*/
|
|
161
|
+
w?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Blur the image using this sigma value. Only applies to image files
|
|
164
|
+
*/
|
|
165
|
+
b?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Output format for image files. Use 'auto' for content negotiation based on Accept header
|
|
168
|
+
*/
|
|
169
|
+
f?: GetFileF;
|
|
170
|
+
};
|
|
171
|
+
export type GetFileF = "auto" | "same" | "jpeg" | "webp" | "png" | "avif";
|
|
172
|
+
export type ReplaceFileBody = {
|
|
173
|
+
/** Optional metadata to update for the file */
|
|
174
|
+
metadata?: UpdateFileMetadata;
|
|
175
|
+
/** New file content to replace the existing file */
|
|
176
|
+
file?: Blob;
|
|
177
|
+
};
|
|
178
|
+
export type FetchResponse<T> = {
|
|
179
|
+
body: T;
|
|
180
|
+
status: number;
|
|
181
|
+
headers: Headers;
|
|
182
|
+
};
|
|
183
|
+
export declare const createAPIClient: (baseURL: string, chainFunctions?: ChainFunction[]) => Client;
|
|
184
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/storage/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4CAA4C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GACN,KAAK,GACL,MAAM,CAAC;AACX,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,CAAC,CAAC,EAAE,QAAQ,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG;IAC5B,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,oDAAoD;IACpD,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,iBAAgB,aAAa,EAAO,KACnC,MAsUF,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.9.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Nhost Storage API
|
|
5
|
+
* Nhost Storage API - A service for managing and serving files with powerful access control capabilities
|
|
6
|
+
* OpenAPI spec version: 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { createEnhancedFetch } from "../fetch";
|
|
9
|
+
export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
10
|
+
let fetch = createEnhancedFetch(chainFunctions);
|
|
11
|
+
const pushChainFunction = (chainFunction) => {
|
|
12
|
+
chainFunctions.push(chainFunction);
|
|
13
|
+
fetch = createEnhancedFetch(chainFunctions);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Returns the OpenAPI schema definition for this API, allowing clients to understand the available endpoints and models.
|
|
17
|
+
* @summary Get OpenAPI specification
|
|
18
|
+
*/
|
|
19
|
+
const getOpenAPISpec = async (options) => {
|
|
20
|
+
const res = await fetch(getGetOpenAPISpecUrl(), {
|
|
21
|
+
...options,
|
|
22
|
+
method: "GET",
|
|
23
|
+
});
|
|
24
|
+
const body = [204, 205, 304, 412].includes(res.status)
|
|
25
|
+
? null
|
|
26
|
+
: await res.text();
|
|
27
|
+
const payload = body ? JSON.parse(body) : {};
|
|
28
|
+
const response = {
|
|
29
|
+
body: payload,
|
|
30
|
+
status: res.status,
|
|
31
|
+
headers: res.headers,
|
|
32
|
+
};
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
throw response;
|
|
35
|
+
}
|
|
36
|
+
return response;
|
|
37
|
+
};
|
|
38
|
+
const getGetOpenAPISpecUrl = () => {
|
|
39
|
+
return baseURL + `/openapi.yaml`;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves build and version information about the storage service. Useful for monitoring and debugging.
|
|
43
|
+
* @summary Get service version information
|
|
44
|
+
*/
|
|
45
|
+
const getVersion = async (options) => {
|
|
46
|
+
const res = await fetch(getGetVersionUrl(), {
|
|
47
|
+
...options,
|
|
48
|
+
method: "GET",
|
|
49
|
+
});
|
|
50
|
+
const body = [204, 205, 304, 412].includes(res.status)
|
|
51
|
+
? null
|
|
52
|
+
: await res.text();
|
|
53
|
+
const payload = body ? JSON.parse(body) : {};
|
|
54
|
+
const response = {
|
|
55
|
+
body: payload,
|
|
56
|
+
status: res.status,
|
|
57
|
+
headers: res.headers,
|
|
58
|
+
};
|
|
59
|
+
if (!res.ok) {
|
|
60
|
+
throw response;
|
|
61
|
+
}
|
|
62
|
+
return response;
|
|
63
|
+
};
|
|
64
|
+
const getGetVersionUrl = () => {
|
|
65
|
+
return baseURL + `/version`;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Upload one or more files to a specified bucket. Supports batch uploading with optional custom metadata for each file. If uploading multiple files, either provide metadata for all files or none.
|
|
69
|
+
* @summary Upload files
|
|
70
|
+
*/
|
|
71
|
+
const uploadFiles = async (uploadFilesBody, options) => {
|
|
72
|
+
const formData = new FormData();
|
|
73
|
+
if (uploadFilesBody["bucket-id"] !== undefined) {
|
|
74
|
+
formData.append(`bucket-id`, uploadFilesBody["bucket-id"]);
|
|
75
|
+
}
|
|
76
|
+
if (uploadFilesBody["metadata[]"] !== undefined) {
|
|
77
|
+
uploadFilesBody["metadata[]"].forEach((value) => formData.append(`metadata[]`, JSON.stringify(value)));
|
|
78
|
+
}
|
|
79
|
+
if (uploadFilesBody["file[]"] !== undefined) {
|
|
80
|
+
uploadFilesBody["file[]"].forEach((value) => formData.append(`file[]`, value));
|
|
81
|
+
}
|
|
82
|
+
const res = await fetch(getUploadFilesUrl(), {
|
|
83
|
+
...options,
|
|
84
|
+
method: "POST",
|
|
85
|
+
body: formData,
|
|
86
|
+
});
|
|
87
|
+
const body = [204, 205, 304, 412].includes(res.status)
|
|
88
|
+
? null
|
|
89
|
+
: await res.text();
|
|
90
|
+
const payload = body ? JSON.parse(body) : {};
|
|
91
|
+
const response = {
|
|
92
|
+
body: payload,
|
|
93
|
+
status: res.status,
|
|
94
|
+
headers: res.headers,
|
|
95
|
+
};
|
|
96
|
+
if (!res.ok) {
|
|
97
|
+
throw response;
|
|
98
|
+
}
|
|
99
|
+
return response;
|
|
100
|
+
};
|
|
101
|
+
const getUploadFilesUrl = () => {
|
|
102
|
+
return baseURL + `/files/`;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Retrieve file metadata headers without downloading the file content. Supports conditional requests and provides caching information.
|
|
106
|
+
* @summary Check file information
|
|
107
|
+
*/
|
|
108
|
+
const getFileMetadataHeaders = async (id, params, options) => {
|
|
109
|
+
const res = await fetch(getGetFileMetadataHeadersUrl(id, params), {
|
|
110
|
+
...options,
|
|
111
|
+
method: "HEAD",
|
|
112
|
+
});
|
|
113
|
+
const body = [204, 205, 304, 412].includes(res.status)
|
|
114
|
+
? null
|
|
115
|
+
: await res.text();
|
|
116
|
+
const payload = body ? JSON.parse(body) : {};
|
|
117
|
+
const response = {
|
|
118
|
+
body: payload,
|
|
119
|
+
status: res.status,
|
|
120
|
+
headers: res.headers,
|
|
121
|
+
};
|
|
122
|
+
if (!res.ok) {
|
|
123
|
+
throw response;
|
|
124
|
+
}
|
|
125
|
+
return response;
|
|
126
|
+
};
|
|
127
|
+
const getGetFileMetadataHeadersUrl = (id, params) => {
|
|
128
|
+
const normalizedParams = new URLSearchParams();
|
|
129
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
130
|
+
if (value !== undefined) {
|
|
131
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const stringifiedParams = normalizedParams.toString();
|
|
135
|
+
return stringifiedParams.length > 0
|
|
136
|
+
? baseURL + `/files/${id}?${stringifiedParams}`
|
|
137
|
+
: baseURL + `/files/${id}`;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Retrieve and download the complete file content. Supports conditional requests, image transformations, and range requests for partial downloads.
|
|
141
|
+
* @summary Download file
|
|
142
|
+
*/
|
|
143
|
+
const getFile = async (id, params, options) => {
|
|
144
|
+
const res = await fetch(getGetFileUrl(id, params), {
|
|
145
|
+
...options,
|
|
146
|
+
method: "GET",
|
|
147
|
+
});
|
|
148
|
+
const payload = await res.blob();
|
|
149
|
+
const response = {
|
|
150
|
+
body: payload,
|
|
151
|
+
status: res.status,
|
|
152
|
+
headers: res.headers,
|
|
153
|
+
};
|
|
154
|
+
if (!res.ok) {
|
|
155
|
+
throw response;
|
|
156
|
+
}
|
|
157
|
+
return response;
|
|
158
|
+
};
|
|
159
|
+
const getGetFileUrl = (id, params) => {
|
|
160
|
+
const normalizedParams = new URLSearchParams();
|
|
161
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
162
|
+
if (value !== undefined) {
|
|
163
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const stringifiedParams = normalizedParams.toString();
|
|
167
|
+
return stringifiedParams.length > 0
|
|
168
|
+
? baseURL + `/files/${id}?${stringifiedParams}`
|
|
169
|
+
: baseURL + `/files/${id}`;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Replace an existing file with new content while preserving the file ID. The operation follows these steps:
|
|
173
|
+
1. The isUploaded flag is set to false to mark the file as being updated
|
|
174
|
+
2. The file content is replaced in the storage backend
|
|
175
|
+
3. File metadata is updated (size, mime-type, isUploaded, etc.)
|
|
176
|
+
|
|
177
|
+
Each step is atomic, but if a step fails, previous steps will not be automatically rolled back.
|
|
178
|
+
|
|
179
|
+
* @summary Replace file
|
|
180
|
+
*/
|
|
181
|
+
const replaceFile = async (id, replaceFileBody, options) => {
|
|
182
|
+
const formData = new FormData();
|
|
183
|
+
if (replaceFileBody.metadata !== undefined) {
|
|
184
|
+
formData.append(`metadata`, JSON.stringify(replaceFileBody.metadata));
|
|
185
|
+
}
|
|
186
|
+
if (replaceFileBody.file !== undefined) {
|
|
187
|
+
formData.append(`file`, replaceFileBody.file);
|
|
188
|
+
}
|
|
189
|
+
const res = await fetch(getReplaceFileUrl(id), {
|
|
190
|
+
...options,
|
|
191
|
+
method: "PUT",
|
|
192
|
+
body: formData,
|
|
193
|
+
});
|
|
194
|
+
const body = [204, 205, 304, 412].includes(res.status)
|
|
195
|
+
? null
|
|
196
|
+
: await res.text();
|
|
197
|
+
const payload = body ? JSON.parse(body) : {};
|
|
198
|
+
const response = {
|
|
199
|
+
body: payload,
|
|
200
|
+
status: res.status,
|
|
201
|
+
headers: res.headers,
|
|
202
|
+
};
|
|
203
|
+
if (!res.ok) {
|
|
204
|
+
throw response;
|
|
205
|
+
}
|
|
206
|
+
return response;
|
|
207
|
+
};
|
|
208
|
+
const getReplaceFileUrl = (id) => {
|
|
209
|
+
return baseURL + `/files/${id}`;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Permanently delete a file from storage. This removes both the file content and its associated metadata.
|
|
213
|
+
* @summary Delete file
|
|
214
|
+
*/
|
|
215
|
+
const deleteFile = async (id, options) => {
|
|
216
|
+
const res = await fetch(getDeleteFileUrl(id), {
|
|
217
|
+
...options,
|
|
218
|
+
method: "DELETE",
|
|
219
|
+
});
|
|
220
|
+
const body = [204, 205, 304, 412].includes(res.status)
|
|
221
|
+
? null
|
|
222
|
+
: await res.text();
|
|
223
|
+
const payload = body ? JSON.parse(body) : {};
|
|
224
|
+
const response = {
|
|
225
|
+
body: payload,
|
|
226
|
+
status: res.status,
|
|
227
|
+
headers: res.headers,
|
|
228
|
+
};
|
|
229
|
+
if (!res.ok) {
|
|
230
|
+
throw response;
|
|
231
|
+
}
|
|
232
|
+
return response;
|
|
233
|
+
};
|
|
234
|
+
const getDeleteFileUrl = (id) => {
|
|
235
|
+
return baseURL + `/files/${id}`;
|
|
236
|
+
};
|
|
237
|
+
return {
|
|
238
|
+
getOpenAPISpec,
|
|
239
|
+
getVersion,
|
|
240
|
+
uploadFiles,
|
|
241
|
+
getFileMetadataHeaders,
|
|
242
|
+
getFile,
|
|
243
|
+
replaceFile,
|
|
244
|
+
deleteFile,
|
|
245
|
+
pushChainFunction,
|
|
246
|
+
baseURL,
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/storage/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAyM/C,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAe,EACf,iBAAkC,EAAE,EAC5B,EAAE;IACV,IAAI,KAAK,GAAG,mBAAmB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
1
|
+
/**
|
|
2
|
+
* This is the main module to interact with Nhost's Storage service.
|
|
3
|
+
* Typically you would use this modula via the main [Nhost client](main#createclient)
|
|
4
|
+
* but you can also use it directly if you have a specific use case.
|
|
5
|
+
*
|
|
6
|
+
* @module storage
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export * from "./client";
|
|
10
|
+
export * from "./interface";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the main module to interact with Nhost's Storage service.
|
|
3
|
+
* Typically you would use this modula via the main [Nhost client](main#createclient)
|
|
4
|
+
* but you can also use it directly if you have a specific use case.
|
|
5
|
+
*
|
|
6
|
+
* @module storage
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export * from "./client";
|
|
10
|
+
export * from "./interface";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ChainFunction } from "../fetch";
|
|
2
|
+
import type { FetchResponse, GetOpenAPISpec200, VersionInformation, UploadFilesBody, UploadFiles201, GetFileMetadataHeadersParams, GetFileParams, ReplaceFileBody, FileMetadata } from "./client";
|
|
3
|
+
/**
|
|
4
|
+
* Storage client interface providing methods for file operations
|
|
5
|
+
*/
|
|
6
|
+
export interface Client {
|
|
7
|
+
/**
|
|
8
|
+
* Base URL for the storage service
|
|
9
|
+
*/
|
|
10
|
+
baseURL: string;
|
|
11
|
+
/**
|
|
12
|
+
* Add a middleware function to the request chain
|
|
13
|
+
* @param chainFunction - Middleware function to add
|
|
14
|
+
*/
|
|
15
|
+
pushChainFunction: (chainFunction: ChainFunction) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the OpenAPI schema definition for this API
|
|
18
|
+
* @summary Get OpenAPI specification
|
|
19
|
+
*/
|
|
20
|
+
getOpenAPISpec: (options?: RequestInit) => Promise<FetchResponse<GetOpenAPISpec200>>;
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves build and version information about the storage service
|
|
23
|
+
* @summary Get service version information
|
|
24
|
+
*/
|
|
25
|
+
getVersion: (options?: RequestInit) => Promise<FetchResponse<VersionInformation>>;
|
|
26
|
+
/**
|
|
27
|
+
* Upload one or more files to storage
|
|
28
|
+
* @summary Upload files
|
|
29
|
+
*/
|
|
30
|
+
uploadFiles: (uploadFilesBody: UploadFilesBody, options?: RequestInit) => Promise<FetchResponse<UploadFiles201>>;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve file metadata using HTTP HEAD method
|
|
33
|
+
* @summary Get file metadata (HEAD)
|
|
34
|
+
*/
|
|
35
|
+
getFileMetadataHeaders: (id: string, params?: GetFileMetadataHeadersParams, options?: RequestInit) => Promise<FetchResponse<void>>;
|
|
36
|
+
/**
|
|
37
|
+
* Download a file
|
|
38
|
+
* @summary Get file
|
|
39
|
+
*/
|
|
40
|
+
getFile: (id: string, params?: GetFileParams, options?: RequestInit) => Promise<FetchResponse<Blob>>;
|
|
41
|
+
/**
|
|
42
|
+
* Replace an existing file
|
|
43
|
+
* @summary Replace file
|
|
44
|
+
*/
|
|
45
|
+
replaceFile: (id: string, replaceFileBody: ReplaceFileBody, options?: RequestInit) => Promise<FetchResponse<FileMetadata>>;
|
|
46
|
+
/**
|
|
47
|
+
* Delete a file
|
|
48
|
+
* @summary Delete file
|
|
49
|
+
*/
|
|
50
|
+
deleteFile: (id: string, options?: RequestInit) => Promise<FetchResponse<void>>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/storage/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,4BAA4B,EAC5B,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,iBAAiB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IAE1D;;;OAGG;IACH,cAAc,EAAE,CACd,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAE/C;;;OAGG;IACH,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEhD;;;OAGG;IACH,WAAW,EAAE,CACX,eAAe,EAAE,eAAe,EAChC,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAE5C;;;OAGG;IACH,sBAAsB,EAAE,CACtB,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,4BAA4B,EACrC,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAElC;;;OAGG;IACH,OAAO,EAAE,CACP,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CA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