@settlemint/sdk-minio 2.1.4 → 2.1.5-pr0a4990f2
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 +269 -2
- package/dist/minio.cjs +248 -10
- package/dist/minio.cjs.map +1 -1
- package/dist/minio.d.cts +168 -6
- package/dist/minio.d.ts +168 -6
- package/dist/minio.mjs +241 -9
- package/dist/minio.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,7 +29,16 @@
|
|
|
29
29
|
- [About](#about)
|
|
30
30
|
- [API Reference](#api-reference)
|
|
31
31
|
- [Functions](#functions)
|
|
32
|
+
- [createPresignedUploadUrl()](#createpresigneduploadurl)
|
|
32
33
|
- [createServerMinioClient()](#createserverminioclient)
|
|
34
|
+
- [deleteFile()](#deletefile)
|
|
35
|
+
- [getFileById()](#getfilebyid)
|
|
36
|
+
- [getFilesList()](#getfileslist)
|
|
37
|
+
- [uploadFile()](#uploadfile)
|
|
38
|
+
- [Interfaces](#interfaces)
|
|
39
|
+
- [FileMetadata](#filemetadata)
|
|
40
|
+
- [Variables](#variables)
|
|
41
|
+
- [DEFAULT\_BUCKET](#default_bucket)
|
|
33
42
|
- [Contributing](#contributing)
|
|
34
43
|
- [License](#license)
|
|
35
44
|
|
|
@@ -43,11 +52,68 @@ For detailed information about using MinIO with the SettleMint platform, check o
|
|
|
43
52
|
|
|
44
53
|
### Functions
|
|
45
54
|
|
|
55
|
+
#### createPresignedUploadUrl()
|
|
56
|
+
|
|
57
|
+
> **createPresignedUploadUrl**(`client`, `fileName`, `path`, `bucket`, `expirySeconds`): `Promise`\<`string`\>
|
|
58
|
+
|
|
59
|
+
Defined in: [sdk/minio/src/helpers/functions.ts:243](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/functions.ts#L243)
|
|
60
|
+
|
|
61
|
+
Creates a presigned upload URL for direct browser uploads
|
|
62
|
+
|
|
63
|
+
##### Parameters
|
|
64
|
+
|
|
65
|
+
| Parameter | Type | Default value | Description |
|
|
66
|
+
| ------ | ------ | ------ | ------ |
|
|
67
|
+
| `client` | `Client` | `undefined` | The MinIO client to use |
|
|
68
|
+
| `fileName` | `string` | `undefined` | The file name to use |
|
|
69
|
+
| `path` | `string` | `""` | Optional path/folder |
|
|
70
|
+
| `bucket` | `string` | `DEFAULT_BUCKET` | Optional bucket name (defaults to DEFAULT_BUCKET) |
|
|
71
|
+
| `expirySeconds` | `number` | `3600` | How long the URL should be valid for |
|
|
72
|
+
|
|
73
|
+
##### Returns
|
|
74
|
+
|
|
75
|
+
`Promise`\<`string`\>
|
|
76
|
+
|
|
77
|
+
Presigned URL for PUT operation
|
|
78
|
+
|
|
79
|
+
##### Throws
|
|
80
|
+
|
|
81
|
+
Will throw an error if URL creation fails or client initialization fails
|
|
82
|
+
|
|
83
|
+
##### Example
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { createServerMinioClient, createPresignedUploadUrl } from "@settlemint/sdk-minio";
|
|
87
|
+
|
|
88
|
+
const { client } = createServerMinioClient({
|
|
89
|
+
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
|
90
|
+
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
|
91
|
+
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Generate the presigned URL on the server
|
|
95
|
+
const url = await createPresignedUploadUrl(client, "report.pdf", "documents/");
|
|
96
|
+
|
|
97
|
+
// Send the URL to the client/browser via HTTP response
|
|
98
|
+
return Response.json({ uploadUrl: url });
|
|
99
|
+
|
|
100
|
+
// Then in the browser:
|
|
101
|
+
const response = await fetch('/api/get-upload-url');
|
|
102
|
+
const { uploadUrl } = await response.json();
|
|
103
|
+
await fetch(uploadUrl, {
|
|
104
|
+
method: 'PUT',
|
|
105
|
+
headers: { 'Content-Type': 'application/pdf' },
|
|
106
|
+
body: pdfFile
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
***
|
|
111
|
+
|
|
46
112
|
#### createServerMinioClient()
|
|
47
113
|
|
|
48
114
|
> **createServerMinioClient**(`options`): `object`
|
|
49
115
|
|
|
50
|
-
Defined in: [sdk/minio/src/minio.ts:23](https://github.com/settlemint/sdk/blob/v2.1.
|
|
116
|
+
Defined in: [sdk/minio/src/minio.ts:23](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/minio.ts#L23)
|
|
51
117
|
|
|
52
118
|
Creates a MinIO client for server-side use with authentication.
|
|
53
119
|
|
|
@@ -68,7 +134,7 @@ An object containing the initialized MinIO client
|
|
|
68
134
|
|
|
69
135
|
| Name | Type | Defined in |
|
|
70
136
|
| ------ | ------ | ------ |
|
|
71
|
-
| `client` | `Client` | [sdk/minio/src/minio.ts:23](https://github.com/settlemint/sdk/blob/v2.1.
|
|
137
|
+
| `client` | `Client` | [sdk/minio/src/minio.ts:23](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/minio.ts#L23) |
|
|
72
138
|
|
|
73
139
|
##### Throws
|
|
74
140
|
|
|
@@ -87,6 +153,207 @@ const { client } = createServerMinioClient({
|
|
|
87
153
|
client.listBuckets();
|
|
88
154
|
```
|
|
89
155
|
|
|
156
|
+
***
|
|
157
|
+
|
|
158
|
+
#### deleteFile()
|
|
159
|
+
|
|
160
|
+
> **deleteFile**(`client`, `fileId`, `bucket`): `Promise`\<`boolean`\>
|
|
161
|
+
|
|
162
|
+
Defined in: [sdk/minio/src/helpers/functions.ts:196](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/functions.ts#L196)
|
|
163
|
+
|
|
164
|
+
Deletes a file from storage
|
|
165
|
+
|
|
166
|
+
##### Parameters
|
|
167
|
+
|
|
168
|
+
| Parameter | Type | Default value | Description |
|
|
169
|
+
| ------ | ------ | ------ | ------ |
|
|
170
|
+
| `client` | `Client` | `undefined` | The MinIO client to use |
|
|
171
|
+
| `fileId` | `string` | `undefined` | The file identifier/path |
|
|
172
|
+
| `bucket` | `string` | `DEFAULT_BUCKET` | Optional bucket name (defaults to DEFAULT_BUCKET) |
|
|
173
|
+
|
|
174
|
+
##### Returns
|
|
175
|
+
|
|
176
|
+
`Promise`\<`boolean`\>
|
|
177
|
+
|
|
178
|
+
Success status
|
|
179
|
+
|
|
180
|
+
##### Throws
|
|
181
|
+
|
|
182
|
+
Will throw an error if deletion fails or client initialization fails
|
|
183
|
+
|
|
184
|
+
##### Example
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { createServerMinioClient, deleteFile } from "@settlemint/sdk-minio";
|
|
188
|
+
|
|
189
|
+
const { client } = createServerMinioClient({
|
|
190
|
+
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
|
191
|
+
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
|
192
|
+
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
await deleteFile(client, "documents/report.pdf");
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
***
|
|
199
|
+
|
|
200
|
+
#### getFileById()
|
|
201
|
+
|
|
202
|
+
> **getFileById**(`client`, `fileId`, `bucket`): `Promise`\<[`FileMetadata`](#filemetadata)\>
|
|
203
|
+
|
|
204
|
+
Defined in: [sdk/minio/src/helpers/functions.ts:123](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/functions.ts#L123)
|
|
205
|
+
|
|
206
|
+
Gets a single file by its object name
|
|
207
|
+
|
|
208
|
+
##### Parameters
|
|
209
|
+
|
|
210
|
+
| Parameter | Type | Default value | Description |
|
|
211
|
+
| ------ | ------ | ------ | ------ |
|
|
212
|
+
| `client` | `Client` | `undefined` | The MinIO client to use |
|
|
213
|
+
| `fileId` | `string` | `undefined` | The file identifier/path |
|
|
214
|
+
| `bucket` | `string` | `DEFAULT_BUCKET` | Optional bucket name (defaults to DEFAULT_BUCKET) |
|
|
215
|
+
|
|
216
|
+
##### Returns
|
|
217
|
+
|
|
218
|
+
`Promise`\<[`FileMetadata`](#filemetadata)\>
|
|
219
|
+
|
|
220
|
+
File metadata with presigned URL
|
|
221
|
+
|
|
222
|
+
##### Throws
|
|
223
|
+
|
|
224
|
+
Will throw an error if the file doesn't exist or client initialization fails
|
|
225
|
+
|
|
226
|
+
##### Example
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import { createServerMinioClient, getFileByObjectName } from "@settlemint/sdk-minio";
|
|
230
|
+
|
|
231
|
+
const { client } = createServerMinioClient({
|
|
232
|
+
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
|
233
|
+
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
|
234
|
+
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const file = await getFileByObjectName(client, "documents/report.pdf");
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
***
|
|
241
|
+
|
|
242
|
+
#### getFilesList()
|
|
243
|
+
|
|
244
|
+
> **getFilesList**(`client`, `prefix`, `bucket`): `Promise`\<[`FileMetadata`](#filemetadata)[]\>
|
|
245
|
+
|
|
246
|
+
Defined in: [sdk/minio/src/helpers/functions.ts:62](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/functions.ts#L62)
|
|
247
|
+
|
|
248
|
+
Gets a list of files with optional prefix filter
|
|
249
|
+
|
|
250
|
+
##### Parameters
|
|
251
|
+
|
|
252
|
+
| Parameter | Type | Default value | Description |
|
|
253
|
+
| ------ | ------ | ------ | ------ |
|
|
254
|
+
| `client` | `Client` | `undefined` | The MinIO client to use |
|
|
255
|
+
| `prefix` | `string` | `""` | Optional prefix to filter files (like a folder path) |
|
|
256
|
+
| `bucket` | `string` | `DEFAULT_BUCKET` | Optional bucket name (defaults to DEFAULT_BUCKET) |
|
|
257
|
+
|
|
258
|
+
##### Returns
|
|
259
|
+
|
|
260
|
+
`Promise`\<[`FileMetadata`](#filemetadata)[]\>
|
|
261
|
+
|
|
262
|
+
Array of file metadata objects
|
|
263
|
+
|
|
264
|
+
##### Throws
|
|
265
|
+
|
|
266
|
+
Will throw an error if the operation fails or client initialization fails
|
|
267
|
+
|
|
268
|
+
##### Example
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
import { createServerMinioClient, getFilesList } from "@settlemint/sdk-minio";
|
|
272
|
+
|
|
273
|
+
const { client } = createServerMinioClient({
|
|
274
|
+
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
|
275
|
+
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
|
276
|
+
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
const files = await getFilesList(client, "documents/");
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
***
|
|
283
|
+
|
|
284
|
+
#### uploadFile()
|
|
285
|
+
|
|
286
|
+
> **uploadFile**(`client`, `buffer`, `objectName`, `contentType`, `bucket`): `Promise`\<[`FileMetadata`](#filemetadata)\>
|
|
287
|
+
|
|
288
|
+
Defined in: [sdk/minio/src/helpers/functions.ts:293](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/functions.ts#L293)
|
|
289
|
+
|
|
290
|
+
Uploads a buffer directly to storage
|
|
291
|
+
|
|
292
|
+
##### Parameters
|
|
293
|
+
|
|
294
|
+
| Parameter | Type | Default value | Description |
|
|
295
|
+
| ------ | ------ | ------ | ------ |
|
|
296
|
+
| `client` | `Client` | `undefined` | The MinIO client to use |
|
|
297
|
+
| `buffer` | `Buffer` | `undefined` | The buffer to upload |
|
|
298
|
+
| `objectName` | `string` | `undefined` | The full object name/path |
|
|
299
|
+
| `contentType` | `string` | `undefined` | The content type of the file |
|
|
300
|
+
| `bucket` | `string` | `DEFAULT_BUCKET` | Optional bucket name (defaults to DEFAULT_BUCKET) |
|
|
301
|
+
|
|
302
|
+
##### Returns
|
|
303
|
+
|
|
304
|
+
`Promise`\<[`FileMetadata`](#filemetadata)\>
|
|
305
|
+
|
|
306
|
+
The uploaded file metadata
|
|
307
|
+
|
|
308
|
+
##### Throws
|
|
309
|
+
|
|
310
|
+
Will throw an error if upload fails or client initialization fails
|
|
311
|
+
|
|
312
|
+
##### Example
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
import { createServerMinioClient, uploadBuffer } from "@settlemint/sdk-minio";
|
|
316
|
+
|
|
317
|
+
const { client } = createServerMinioClient({
|
|
318
|
+
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
|
319
|
+
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
|
320
|
+
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
const buffer = Buffer.from("Hello, world!");
|
|
324
|
+
const uploadedFile = await uploadFile(client, buffer, "documents/hello.txt", "text/plain");
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Interfaces
|
|
328
|
+
|
|
329
|
+
#### FileMetadata
|
|
330
|
+
|
|
331
|
+
Defined in: [sdk/minio/src/helpers/schema.ts:29](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L29)
|
|
332
|
+
|
|
333
|
+
Type representing file metadata after validation.
|
|
334
|
+
|
|
335
|
+
##### Properties
|
|
336
|
+
|
|
337
|
+
| Property | Type | Description | Defined in |
|
|
338
|
+
| ------ | ------ | ------ | ------ |
|
|
339
|
+
| <a id="contenttype"></a> `contentType` | `string` | The content type of the file. | [sdk/minio/src/helpers/schema.ts:41](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L41) |
|
|
340
|
+
| <a id="etag"></a> `etag` | `string` | The ETag of the file. | [sdk/minio/src/helpers/schema.ts:56](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L56) |
|
|
341
|
+
| <a id="id"></a> `id` | `string` | The unique identifier for the file. | [sdk/minio/src/helpers/schema.ts:33](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L33) |
|
|
342
|
+
| <a id="name"></a> `name` | `string` | The name of the file. | [sdk/minio/src/helpers/schema.ts:37](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L37) |
|
|
343
|
+
| <a id="size"></a> `size` | `number` | The size of the file in bytes. | [sdk/minio/src/helpers/schema.ts:46](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L46) |
|
|
344
|
+
| <a id="uploadedat"></a> `uploadedAt` | `string` | The date and time the file was uploaded. | [sdk/minio/src/helpers/schema.ts:51](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L51) |
|
|
345
|
+
| <a id="url"></a> `url?` | `string` | The URL of the file. | [sdk/minio/src/helpers/schema.ts:61](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L61) |
|
|
346
|
+
|
|
347
|
+
### Variables
|
|
348
|
+
|
|
349
|
+
#### DEFAULT\_BUCKET
|
|
350
|
+
|
|
351
|
+
> `const` **DEFAULT\_BUCKET**: `"uploads"` = `"uploads"`
|
|
352
|
+
|
|
353
|
+
Defined in: [sdk/minio/src/helpers/schema.ts:67](https://github.com/settlemint/sdk/blob/v2.1.5/sdk/minio/src/helpers/schema.ts#L67)
|
|
354
|
+
|
|
355
|
+
Default bucket name to use for file storage when none is specified.
|
|
356
|
+
|
|
90
357
|
## Contributing
|
|
91
358
|
|
|
92
359
|
We welcome contributions from the community! Please check out our [Contributing](https://github.com/settlemint/sdk/blob/main/.github/CONTRIBUTING.md) guide to learn how you can help improve the SettleMint SDK through bug reports, feature requests, documentation updates, or code contributions.
|
package/dist/minio.cjs
CHANGED
|
@@ -20,31 +20,263 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/minio.ts
|
|
21
21
|
var minio_exports = {};
|
|
22
22
|
__export(minio_exports, {
|
|
23
|
-
|
|
23
|
+
DEFAULT_BUCKET: () => DEFAULT_BUCKET,
|
|
24
|
+
createPresignedUploadUrl: () => createPresignedUploadUrl,
|
|
25
|
+
createServerMinioClient: () => createServerMinioClient,
|
|
26
|
+
deleteFile: () => deleteFile,
|
|
27
|
+
getFileById: () => getFileById,
|
|
28
|
+
getFilesList: () => getFilesList,
|
|
29
|
+
uploadFile: () => uploadFile
|
|
24
30
|
});
|
|
25
31
|
module.exports = __toCommonJS(minio_exports);
|
|
26
|
-
var
|
|
27
|
-
var
|
|
32
|
+
var import_runtime3 = require("@settlemint/sdk-utils/runtime");
|
|
33
|
+
var import_validation3 = require("@settlemint/sdk-utils/validation");
|
|
28
34
|
var import_minio = require("minio");
|
|
29
35
|
|
|
30
36
|
// src/helpers/client-options.schema.ts
|
|
31
37
|
var import_validation = require("@settlemint/sdk-utils/validation");
|
|
32
38
|
var import_zod = require("zod");
|
|
33
|
-
var
|
|
39
|
+
var ServerClientOptionsSchema = import_zod.z.object({
|
|
34
40
|
/** The URL of the MinIO instance to connect to */
|
|
35
|
-
instance: import_validation.UrlSchema
|
|
36
|
-
});
|
|
37
|
-
var ServerClientOptionsSchema = ClientOptionsSchema.extend({
|
|
41
|
+
instance: import_validation.UrlSchema,
|
|
38
42
|
/** The MinIO access key used to authenticate with the MinIO server */
|
|
39
43
|
accessKey: import_zod.z.string(),
|
|
40
44
|
/** The MinIO secret key used to authenticate with the MinIO server */
|
|
41
45
|
secretKey: import_zod.z.string()
|
|
42
46
|
});
|
|
43
47
|
|
|
48
|
+
// src/helpers/schema.ts
|
|
49
|
+
var import_zod2 = require("zod");
|
|
50
|
+
var FileMetadataSchema = import_zod2.z.object({
|
|
51
|
+
id: import_zod2.z.string(),
|
|
52
|
+
name: import_zod2.z.string(),
|
|
53
|
+
contentType: import_zod2.z.string(),
|
|
54
|
+
size: import_zod2.z.number(),
|
|
55
|
+
uploadedAt: import_zod2.z.string().datetime(),
|
|
56
|
+
etag: import_zod2.z.string(),
|
|
57
|
+
url: import_zod2.z.string().url().optional()
|
|
58
|
+
});
|
|
59
|
+
var DEFAULT_BUCKET = "uploads";
|
|
60
|
+
|
|
61
|
+
// src/helpers/functions.ts
|
|
62
|
+
var import_runtime2 = require("@settlemint/sdk-utils/runtime");
|
|
63
|
+
var import_validation2 = require("@settlemint/sdk-utils/validation");
|
|
64
|
+
|
|
65
|
+
// src/helpers/executor.ts
|
|
66
|
+
var import_runtime = require("@settlemint/sdk-utils/runtime");
|
|
67
|
+
async function executeMinioOperation(client, operation) {
|
|
68
|
+
(0, import_runtime.ensureServer)();
|
|
69
|
+
return operation.execute(client);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/helpers/operations.ts
|
|
73
|
+
function createListObjectsOperation(bucket, prefix = "") {
|
|
74
|
+
return {
|
|
75
|
+
execute: async (client) => {
|
|
76
|
+
const objectsStream = client.listObjects(bucket, prefix, true);
|
|
77
|
+
const objects = [];
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
objectsStream.on("data", (obj) => {
|
|
80
|
+
if (obj.name && typeof obj.size === "number" && obj.etag && obj.lastModified) {
|
|
81
|
+
objects.push({
|
|
82
|
+
name: obj.name,
|
|
83
|
+
prefix: obj.prefix,
|
|
84
|
+
size: obj.size,
|
|
85
|
+
etag: obj.etag,
|
|
86
|
+
lastModified: obj.lastModified
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
objectsStream.on("error", (err) => {
|
|
91
|
+
reject(err);
|
|
92
|
+
});
|
|
93
|
+
objectsStream.on("end", () => {
|
|
94
|
+
resolve(objects);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function createStatObjectOperation(bucket, objectName) {
|
|
101
|
+
return {
|
|
102
|
+
execute: async (client) => {
|
|
103
|
+
return client.statObject(bucket, objectName);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function createDeleteOperation(bucket, objectName) {
|
|
108
|
+
return {
|
|
109
|
+
execute: async (client) => {
|
|
110
|
+
return client.removeObject(bucket, objectName);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function createPresignedUrlOperation(bucket, objectName, expirySeconds) {
|
|
115
|
+
return {
|
|
116
|
+
execute: async (client) => {
|
|
117
|
+
return client.presignedGetObject(bucket, objectName, expirySeconds);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function createPresignedPutOperation(bucket, objectName, expirySeconds) {
|
|
122
|
+
return {
|
|
123
|
+
execute: async (client) => {
|
|
124
|
+
return client.presignedPutObject(bucket, objectName, expirySeconds);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function createSimpleUploadOperation(client) {
|
|
129
|
+
return async (buffer, bucket, objectName, metadata) => {
|
|
130
|
+
return client.putObject(bucket, objectName, buffer, void 0, metadata);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/helpers/functions.ts
|
|
135
|
+
function normalizePath(path, fileName) {
|
|
136
|
+
if (path.length > 1e3) {
|
|
137
|
+
throw new Error("Path is too long");
|
|
138
|
+
}
|
|
139
|
+
const cleanPath = path.replace(/\/+$/, "");
|
|
140
|
+
if (!cleanPath) {
|
|
141
|
+
return fileName;
|
|
142
|
+
}
|
|
143
|
+
return `${cleanPath}/${fileName}`;
|
|
144
|
+
}
|
|
145
|
+
async function getFilesList(client, prefix = "", bucket = DEFAULT_BUCKET) {
|
|
146
|
+
(0, import_runtime2.ensureServer)();
|
|
147
|
+
console.log(`Listing files with prefix: "${prefix}" in bucket: "${bucket}"`);
|
|
148
|
+
try {
|
|
149
|
+
const listOperation = createListObjectsOperation(bucket, prefix);
|
|
150
|
+
const objects = await executeMinioOperation(client, listOperation);
|
|
151
|
+
console.log(`Found ${objects.length} files in MinIO`);
|
|
152
|
+
const fileObjects = await Promise.all(
|
|
153
|
+
objects.map(async (obj) => {
|
|
154
|
+
const presignedUrlOperation = createPresignedUrlOperation(
|
|
155
|
+
bucket,
|
|
156
|
+
obj.name,
|
|
157
|
+
3600
|
|
158
|
+
// 1 hour expiry
|
|
159
|
+
);
|
|
160
|
+
const url = await executeMinioOperation(client, presignedUrlOperation);
|
|
161
|
+
return {
|
|
162
|
+
id: obj.name,
|
|
163
|
+
name: obj.name.split("/").pop() || obj.name,
|
|
164
|
+
contentType: "application/octet-stream",
|
|
165
|
+
// Default type
|
|
166
|
+
size: obj.size,
|
|
167
|
+
uploadedAt: obj.lastModified.toISOString(),
|
|
168
|
+
etag: obj.etag,
|
|
169
|
+
url
|
|
170
|
+
};
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
return (0, import_validation2.validate)(FileMetadataSchema.array(), fileObjects);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error("Failed to list files:", error);
|
|
176
|
+
throw new Error(`Failed to list files: ${error instanceof Error ? error.message : String(error)}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async function getFileById(client, fileId, bucket = DEFAULT_BUCKET) {
|
|
180
|
+
(0, import_runtime2.ensureServer)();
|
|
181
|
+
console.log(`Getting file details for: ${fileId} in bucket: ${bucket}`);
|
|
182
|
+
try {
|
|
183
|
+
const statOperation = createStatObjectOperation(bucket, fileId);
|
|
184
|
+
const statResult = await executeMinioOperation(client, statOperation);
|
|
185
|
+
const presignedUrlOperation = createPresignedUrlOperation(
|
|
186
|
+
bucket,
|
|
187
|
+
fileId,
|
|
188
|
+
3600
|
|
189
|
+
// 1 hour expiry
|
|
190
|
+
);
|
|
191
|
+
const url = await executeMinioOperation(client, presignedUrlOperation);
|
|
192
|
+
let size = 0;
|
|
193
|
+
if (statResult.metaData["content-length"]) {
|
|
194
|
+
const parsedSize = Number.parseInt(statResult.metaData["content-length"], 10);
|
|
195
|
+
if (!Number.isNaN(parsedSize)) {
|
|
196
|
+
size = parsedSize;
|
|
197
|
+
}
|
|
198
|
+
} else if (typeof statResult.size === "number" && !Number.isNaN(statResult.size)) {
|
|
199
|
+
size = statResult.size;
|
|
200
|
+
}
|
|
201
|
+
const fileMetadata = {
|
|
202
|
+
id: fileId,
|
|
203
|
+
name: fileId.split("/").pop() || fileId,
|
|
204
|
+
contentType: statResult.metaData["content-type"] || "application/octet-stream",
|
|
205
|
+
size,
|
|
206
|
+
uploadedAt: statResult.lastModified.toISOString(),
|
|
207
|
+
etag: statResult.etag,
|
|
208
|
+
url
|
|
209
|
+
};
|
|
210
|
+
return (0, import_validation2.validate)(FileMetadataSchema, fileMetadata);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error(`Failed to get file ${fileId}:`, error);
|
|
213
|
+
throw new Error(`Failed to get file ${fileId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function deleteFile(client, fileId, bucket = DEFAULT_BUCKET) {
|
|
217
|
+
(0, import_runtime2.ensureServer)();
|
|
218
|
+
try {
|
|
219
|
+
const deleteOperation = createDeleteOperation(bucket, fileId);
|
|
220
|
+
await executeMinioOperation(client, deleteOperation);
|
|
221
|
+
return true;
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error(`Failed to delete file ${fileId}:`, error);
|
|
224
|
+
throw new Error(`Failed to delete file ${fileId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async function createPresignedUploadUrl(client, fileName, path = "", bucket = DEFAULT_BUCKET, expirySeconds = 3600) {
|
|
228
|
+
(0, import_runtime2.ensureServer)();
|
|
229
|
+
try {
|
|
230
|
+
const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
231
|
+
const objectName = normalizePath(path, safeFileName);
|
|
232
|
+
const presignedPutOperation = createPresignedPutOperation(bucket, objectName, expirySeconds);
|
|
233
|
+
const url = await executeMinioOperation(client, presignedPutOperation);
|
|
234
|
+
if (!url) {
|
|
235
|
+
throw new Error("Failed to generate presigned upload URL");
|
|
236
|
+
}
|
|
237
|
+
return url;
|
|
238
|
+
} catch (error) {
|
|
239
|
+
console.error("Failed to create presigned upload URL:", error);
|
|
240
|
+
throw new Error(`Failed to create presigned upload URL: ${error instanceof Error ? error.message : String(error)}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async function uploadFile(client, buffer, objectName, contentType, bucket = DEFAULT_BUCKET) {
|
|
244
|
+
(0, import_runtime2.ensureServer)();
|
|
245
|
+
try {
|
|
246
|
+
const metadata = {
|
|
247
|
+
"content-type": contentType,
|
|
248
|
+
"upload-time": (/* @__PURE__ */ new Date()).toISOString()
|
|
249
|
+
};
|
|
250
|
+
const simpleUploadFn = createSimpleUploadOperation(client);
|
|
251
|
+
const result = await simpleUploadFn(buffer, bucket, objectName, metadata);
|
|
252
|
+
const presignedUrlOperation = createPresignedUrlOperation(
|
|
253
|
+
bucket,
|
|
254
|
+
objectName,
|
|
255
|
+
3600
|
|
256
|
+
// 1 hour expiry
|
|
257
|
+
);
|
|
258
|
+
const url = await executeMinioOperation(client, presignedUrlOperation);
|
|
259
|
+
const fileName = objectName.split("/").pop() || objectName;
|
|
260
|
+
const fileMetadata = {
|
|
261
|
+
id: objectName,
|
|
262
|
+
name: fileName,
|
|
263
|
+
contentType,
|
|
264
|
+
size: buffer.length,
|
|
265
|
+
uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
266
|
+
etag: result.etag,
|
|
267
|
+
url
|
|
268
|
+
};
|
|
269
|
+
return (0, import_validation2.validate)(FileMetadataSchema, fileMetadata);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.error("Failed to upload file:", error);
|
|
272
|
+
throw new Error(`Failed to upload file: ${error instanceof Error ? error.message : String(error)}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
44
276
|
// src/minio.ts
|
|
45
277
|
function createServerMinioClient(options) {
|
|
46
|
-
(0,
|
|
47
|
-
const validatedOptions = (0,
|
|
278
|
+
(0, import_runtime3.ensureServer)();
|
|
279
|
+
const validatedOptions = (0, import_validation3.validate)(ServerClientOptionsSchema, options);
|
|
48
280
|
const url = new URL(validatedOptions.instance);
|
|
49
281
|
return {
|
|
50
282
|
client: new import_minio.Client({
|
|
@@ -59,6 +291,12 @@ function createServerMinioClient(options) {
|
|
|
59
291
|
}
|
|
60
292
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
293
|
0 && (module.exports = {
|
|
62
|
-
|
|
294
|
+
DEFAULT_BUCKET,
|
|
295
|
+
createPresignedUploadUrl,
|
|
296
|
+
createServerMinioClient,
|
|
297
|
+
deleteFile,
|
|
298
|
+
getFileById,
|
|
299
|
+
getFilesList,
|
|
300
|
+
uploadFile
|
|
63
301
|
});
|
|
64
302
|
//# sourceMappingURL=minio.cjs.map
|
package/dist/minio.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/minio.ts","../src/helpers/client-options.schema.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport { Client } from \"minio\";\nimport { type ServerClientOptions, ServerClientOptionsSchema } from \"./helpers/client-options.schema.js\";\n\n/**\n * Creates a MinIO client for server-side use with authentication.\n *\n * @param options - The server client options for configuring the MinIO client\n * @returns An object containing the initialized MinIO client\n * @throws Will throw an error if not called on the server or if the options fail validation\n *\n * @example\n * import { createServerMinioClient } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n * client.listBuckets();\n */\nexport function createServerMinioClient(options: ServerClientOptions): { client: Client } {\n ensureServer();\n const validatedOptions = validate(ServerClientOptionsSchema, options);\n\n const url = new URL(validatedOptions.instance);\n return {\n client: new Client({\n endPoint: url.hostname,\n accessKey: validatedOptions.accessKey,\n secretKey: validatedOptions.secretKey,\n useSSL: url.protocol !== \"http:\",\n port: url.port ? Number(url.port) : undefined,\n region: \"eu-central-1\",\n }),\n };\n}\n","import { UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod\";\n\n/**\n * Schema for validating client options for the Portal client.\n */\nexport const ClientOptionsSchema = z.object({\n /** The URL of the MinIO instance to connect to */\n instance: UrlSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Schema for validating server client options for the Portal client.\n * Extends the ClientOptionsSchema with additional server-specific fields.\n */\nexport const ServerClientOptionsSchema = ClientOptionsSchema.extend({\n /** The MinIO access key used to authenticate with the MinIO server */\n accessKey: z.string(),\n /** The MinIO secret key used to authenticate with the MinIO server */\n secretKey: z.string(),\n});\n\n/**\n * Type definition for server client options derived from the ServerClientOptionsSchema.\n */\nexport type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,IAAAA,qBAAyB;AACzB,mBAAuB;;;ACFvB,wBAA0B;AAC1B,iBAAkB;AAKX,IAAM,sBAAsB,aAAE,OAAO;AAAA;AAAA,EAE1C,UAAU;AACZ,CAAC;AAWM,IAAM,4BAA4B,oBAAoB,OAAO;AAAA;AAAA,EAElE,WAAW,aAAE,OAAO;AAAA;AAAA,EAEpB,WAAW,aAAE,OAAO;AACtB,CAAC;;;ADHM,SAAS,wBAAwB,SAAkD;AACxF,mCAAa;AACb,QAAM,uBAAmB,6BAAS,2BAA2B,OAAO;AAEpE,QAAM,MAAM,IAAI,IAAI,iBAAiB,QAAQ;AAC7C,SAAO;AAAA,IACL,QAAQ,IAAI,oBAAO;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,WAAW,iBAAiB;AAAA,MAC5B,WAAW,iBAAiB;AAAA,MAC5B,QAAQ,IAAI,aAAa;AAAA,MACzB,MAAM,IAAI,OAAO,OAAO,IAAI,IAAI,IAAI;AAAA,MACpC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACF;","names":["import_validation"]}
|
|
1
|
+
{"version":3,"sources":["../src/minio.ts","../src/helpers/client-options.schema.ts","../src/helpers/schema.ts","../src/helpers/functions.ts","../src/helpers/executor.ts","../src/helpers/operations.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport { Client } from \"minio\";\nimport { type ServerClientOptions, ServerClientOptionsSchema } from \"./helpers/client-options.schema.js\";\n\n/**\n * Creates a MinIO client for server-side use with authentication.\n *\n * @param options - The server client options for configuring the MinIO client\n * @returns An object containing the initialized MinIO client\n * @throws Will throw an error if not called on the server or if the options fail validation\n *\n * @example\n * import { createServerMinioClient } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n * client.listBuckets();\n */\nexport function createServerMinioClient(options: ServerClientOptions): { client: Client } {\n ensureServer();\n const validatedOptions = validate(ServerClientOptionsSchema, options);\n\n const url = new URL(validatedOptions.instance);\n return {\n client: new Client({\n endPoint: url.hostname,\n accessKey: validatedOptions.accessKey,\n secretKey: validatedOptions.secretKey,\n useSSL: url.protocol !== \"http:\",\n port: url.port ? Number(url.port) : undefined,\n region: \"eu-central-1\",\n }),\n };\n}\n// Export validation utilities and schemas\nexport {\n type FileMetadata,\n DEFAULT_BUCKET,\n} from \"./helpers/schema.js\";\n\n// Export high-level functions\nexport {\n getFilesList,\n getFileById,\n uploadFile,\n deleteFile,\n createPresignedUploadUrl,\n} from \"./helpers/functions.js\";\n\n// Re-export required types from minio\nexport type { Client, ItemBucketMetadata } from \"minio\";\n","import { UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod\";\n\n/**\n * Schema for validating server client options for the MinIO client.\n */\nexport const ServerClientOptionsSchema = z.object({\n /** The URL of the MinIO instance to connect to */\n instance: UrlSchema,\n /** The MinIO access key used to authenticate with the MinIO server */\n accessKey: z.string(),\n /** The MinIO secret key used to authenticate with the MinIO server */\n secretKey: z.string(),\n});\n\n/**\n * Type definition for server client options derived from the ServerClientOptionsSchema.\n */\nexport type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;\n","import { z } from \"zod\";\n\n/**\n * Helper type to extract the inferred type from a Zod schema.\n *\n * @template T - The Zod schema type\n */\nexport type Static<T extends z.ZodType> = z.infer<T>;\n\n// ----- Schema Definitions -----\n\n/**\n * Schema for file metadata stored in MinIO.\n * Defines the structure and validation rules for file information.\n */\nexport const FileMetadataSchema = z.object({\n id: z.string(),\n name: z.string(),\n contentType: z.string(),\n size: z.number(),\n uploadedAt: z.string().datetime(),\n etag: z.string(),\n url: z.string().url().optional(),\n});\n\n/**\n * Type representing file metadata after validation.\n */\nexport interface FileMetadata {\n /**\n * The unique identifier for the file.\n */\n id: string;\n /**\n * The name of the file.\n */\n name: string;\n /**\n * The content type of the file.\n */\n contentType: string;\n\n /**\n * The size of the file in bytes.\n */\n size: number;\n\n /**\n * The date and time the file was uploaded.\n */\n uploadedAt: string;\n\n /**\n * The ETag of the file.\n */\n etag: string;\n\n /**\n * The URL of the file.\n */\n url?: string;\n}\n\n/**\n * Default bucket name to use for file storage when none is specified.\n */\nexport const DEFAULT_BUCKET = \"uploads\";\n","import type { Buffer } from \"node:buffer\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport type { Client } from \"minio\";\nimport { executeMinioOperation } from \"./executor.js\";\nimport {\n createDeleteOperation,\n createListObjectsOperation,\n createPresignedPutOperation,\n createPresignedUrlOperation,\n createSimpleUploadOperation,\n createStatObjectOperation,\n} from \"./operations.js\";\nimport { DEFAULT_BUCKET, FileMetadataSchema } from \"./schema.js\";\nimport type { FileMetadata } from \"./schema.js\";\n\n/**\n * Helper function to normalize paths and prevent double slashes\n *\n * @param path - The path to normalize\n * @param fileName - The filename to append\n * @returns The normalized path with filename\n * @throws Will throw an error if the path is too long (max 1000 characters)\n */\nfunction normalizePath(path: string, fileName: string): string {\n if (path.length > 1_000) {\n throw new Error(\"Path is too long\");\n }\n\n // Remove trailing slashes from path\n const cleanPath = path.replace(/\\/+$/, \"\");\n\n // If path is empty, return just the filename\n if (!cleanPath) {\n return fileName;\n }\n\n // Join with a single slash\n return `${cleanPath}/${fileName}`;\n}\n\n/**\n * Gets a list of files with optional prefix filter\n *\n * @param client - The MinIO client to use\n * @param prefix - Optional prefix to filter files (like a folder path)\n * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)\n * @returns Array of file metadata objects\n * @throws Will throw an error if the operation fails or client initialization fails\n *\n * @example\n * import { createServerMinioClient, getFilesList } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n *\n * const files = await getFilesList(client, \"documents/\");\n */\nexport async function getFilesList(\n client: Client,\n prefix = \"\",\n bucket: string = DEFAULT_BUCKET,\n): Promise<FileMetadata[]> {\n ensureServer();\n console.log(`Listing files with prefix: \"${prefix}\" in bucket: \"${bucket}\"`);\n\n try {\n const listOperation = createListObjectsOperation(bucket, prefix);\n const objects = await executeMinioOperation(client, listOperation);\n console.log(`Found ${objects.length} files in MinIO`);\n\n const fileObjects = await Promise.all(\n objects.map(async (obj): Promise<FileMetadata> => {\n const presignedUrlOperation = createPresignedUrlOperation(\n bucket,\n obj.name,\n 3600, // 1 hour expiry\n );\n const url = await executeMinioOperation(client, presignedUrlOperation);\n\n return {\n id: obj.name,\n name: obj.name.split(\"/\").pop() || obj.name,\n contentType: \"application/octet-stream\", // Default type\n size: obj.size,\n uploadedAt: obj.lastModified.toISOString(),\n etag: obj.etag,\n url,\n };\n }),\n );\n\n return validate(FileMetadataSchema.array(), fileObjects);\n } catch (error) {\n console.error(\"Failed to list files:\", error);\n throw new Error(`Failed to list files: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Gets a single file by its object name\n *\n * @param client - The MinIO client to use\n * @param fileId - The file identifier/path\n * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)\n * @returns File metadata with presigned URL\n * @throws Will throw an error if the file doesn't exist or client initialization fails\n *\n * @example\n * import { createServerMinioClient, getFileByObjectName } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n *\n * const file = await getFileByObjectName(client, \"documents/report.pdf\");\n */\nexport async function getFileById(\n client: Client,\n fileId: string,\n bucket: string = DEFAULT_BUCKET,\n): Promise<FileMetadata> {\n ensureServer();\n console.log(`Getting file details for: ${fileId} in bucket: ${bucket}`);\n\n try {\n // Get the file metadata\n const statOperation = createStatObjectOperation(bucket, fileId);\n const statResult = await executeMinioOperation(client, statOperation);\n\n // Generate a presigned URL for access\n const presignedUrlOperation = createPresignedUrlOperation(\n bucket,\n fileId,\n 3600, // 1 hour expiry\n );\n const url = await executeMinioOperation(client, presignedUrlOperation);\n\n // Try to get size from metadata first, then from stat result\n let size = 0;\n\n // Check for content-length in metadata\n if (statResult.metaData[\"content-length\"]) {\n const parsedSize = Number.parseInt(statResult.metaData[\"content-length\"], 10);\n if (!Number.isNaN(parsedSize)) {\n size = parsedSize;\n }\n }\n // Fallback to statResult.size if available and valid\n else if (typeof statResult.size === \"number\" && !Number.isNaN(statResult.size)) {\n size = statResult.size;\n }\n\n const fileMetadata: FileMetadata = {\n id: fileId,\n name: fileId.split(\"/\").pop() || fileId,\n contentType: statResult.metaData[\"content-type\"] || \"application/octet-stream\",\n size,\n uploadedAt: statResult.lastModified.toISOString(),\n etag: statResult.etag,\n url,\n };\n\n return validate(FileMetadataSchema, fileMetadata);\n } catch (error) {\n console.error(`Failed to get file ${fileId}:`, error);\n throw new Error(`Failed to get file ${fileId}: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Deletes a file from storage\n *\n * @param client - The MinIO client to use\n * @param fileId - The file identifier/path\n * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)\n * @returns Success status\n * @throws Will throw an error if deletion fails or client initialization fails\n *\n * @example\n * import { createServerMinioClient, deleteFile } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n *\n * await deleteFile(client, \"documents/report.pdf\");\n */\nexport async function deleteFile(client: Client, fileId: string, bucket: string = DEFAULT_BUCKET): Promise<boolean> {\n ensureServer();\n try {\n const deleteOperation = createDeleteOperation(bucket, fileId);\n await executeMinioOperation(client, deleteOperation);\n return true;\n } catch (error) {\n console.error(`Failed to delete file ${fileId}:`, error);\n throw new Error(`Failed to delete file ${fileId}: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Creates a presigned upload URL for direct browser uploads\n *\n * @param client - The MinIO client to use\n * @param fileName - The file name to use\n * @param path - Optional path/folder\n * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)\n * @param expirySeconds - How long the URL should be valid for\n * @returns Presigned URL for PUT operation\n * @throws Will throw an error if URL creation fails or client initialization fails\n *\n * @example\n * import { createServerMinioClient, createPresignedUploadUrl } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n *\n * // Generate the presigned URL on the server\n * const url = await createPresignedUploadUrl(client, \"report.pdf\", \"documents/\");\n *\n * // Send the URL to the client/browser via HTTP response\n * return Response.json({ uploadUrl: url });\n *\n * // Then in the browser:\n * const response = await fetch('/api/get-upload-url');\n * const { uploadUrl } = await response.json();\n * await fetch(uploadUrl, {\n * method: 'PUT',\n * headers: { 'Content-Type': 'application/pdf' },\n * body: pdfFile\n * });\n */\nexport async function createPresignedUploadUrl(\n client: Client,\n fileName: string,\n path = \"\",\n bucket: string = DEFAULT_BUCKET,\n expirySeconds = 3600,\n): Promise<string> {\n ensureServer();\n try {\n const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n const objectName = normalizePath(path, safeFileName);\n\n // Create operation for presigned PUT URL\n const presignedPutOperation = createPresignedPutOperation(bucket, objectName, expirySeconds);\n\n const url = await executeMinioOperation(client, presignedPutOperation);\n if (!url) {\n throw new Error(\"Failed to generate presigned upload URL\");\n }\n\n return url;\n } catch (error) {\n console.error(\"Failed to create presigned upload URL:\", error);\n throw new Error(`Failed to create presigned upload URL: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Uploads a buffer directly to storage\n *\n * @param client - The MinIO client to use\n * @param buffer - The buffer to upload\n * @param objectName - The full object name/path\n * @param contentType - The content type of the file\n * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)\n * @returns The uploaded file metadata\n * @throws Will throw an error if upload fails or client initialization fails\n *\n * @example\n * import { createServerMinioClient, uploadBuffer } from \"@settlemint/sdk-minio\";\n *\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n *\n * const buffer = Buffer.from(\"Hello, world!\");\n * const uploadedFile = await uploadFile(client, buffer, \"documents/hello.txt\", \"text/plain\");\n */\nexport async function uploadFile(\n client: Client,\n buffer: Buffer,\n objectName: string,\n contentType: string,\n bucket: string = DEFAULT_BUCKET,\n): Promise<FileMetadata> {\n ensureServer();\n try {\n // Add file metadata\n const metadata = {\n \"content-type\": contentType,\n \"upload-time\": new Date().toISOString(),\n };\n\n // Use the createSimpleUploadOperation\n const simpleUploadFn = createSimpleUploadOperation(client);\n const result = await simpleUploadFn(buffer, bucket, objectName, metadata);\n\n // Generate a presigned URL for immediate access\n const presignedUrlOperation = createPresignedUrlOperation(\n bucket,\n objectName,\n 3600, // 1 hour expiry\n );\n const url = await executeMinioOperation(client, presignedUrlOperation);\n\n const fileName = objectName.split(\"/\").pop() || objectName;\n\n const fileMetadata: FileMetadata = {\n id: objectName,\n name: fileName,\n contentType,\n size: buffer.length,\n uploadedAt: new Date().toISOString(),\n etag: result.etag,\n url,\n };\n\n return validate(FileMetadataSchema, fileMetadata);\n } catch (error) {\n console.error(\"Failed to upload file:\", error);\n throw new Error(`Failed to upload file: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n","import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport type { Client } from \"minio\";\nimport type { MinioOperation } from \"./operations.js\";\n\n/**\n * Executes a MinIO operation using the provided client\n *\n * @param client - MinIO client to use\n * @param operation - The operation to execute\n * @returns The result of the operation execution\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createServerMinioClient, createListObjectsOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n * const { client } = createServerMinioClient({\n * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,\n * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,\n * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!\n * });\n * const listOperation = createListObjectsOperation(\"my-bucket\", \"prefix/\");\n * const result = await executeMinioOperation(client, listOperation);\n */\nexport async function executeMinioOperation<T>(client: Client, operation: MinioOperation<T>): Promise<T> {\n ensureServer();\n\n return operation.execute(client);\n}\n","import type { Buffer } from \"node:buffer\";\nimport type { Client, ItemBucketMetadata } from \"minio\";\n\n/**\n * Base interface for all MinIO operations\n *\n * @template T The return type of the operation\n */\nexport interface MinioOperation<T> {\n execute: (client: Client) => Promise<T>;\n}\n\n/**\n * Creates an operation to list objects in a bucket\n *\n * @param bucket - The bucket name to list objects from\n * @param prefix - Optional prefix to filter objects (like a folder path)\n * @returns A MinioOperation that lists objects when executed\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createListObjectsOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n *\n * const listOperation = createListObjectsOperation(\"my-bucket\", \"folder/\");\n * const objects = await executeMinioOperation(client, listOperation);\n */\nexport function createListObjectsOperation(\n bucket: string,\n prefix = \"\",\n): MinioOperation<\n Array<{\n name: string;\n prefix?: string;\n size: number;\n etag: string;\n lastModified: Date;\n }>\n> {\n return {\n execute: async (client: Client) => {\n const objectsStream = client.listObjects(bucket, prefix, true);\n const objects: Array<{\n name: string;\n prefix?: string;\n size: number;\n etag: string;\n lastModified: Date;\n }> = [];\n\n return new Promise((resolve, reject) => {\n objectsStream.on(\"data\", (obj) => {\n // Ensure required properties are not undefined before adding to the array\n if (obj.name && typeof obj.size === \"number\" && obj.etag && obj.lastModified) {\n objects.push({\n name: obj.name,\n prefix: obj.prefix,\n size: obj.size,\n etag: obj.etag,\n lastModified: obj.lastModified,\n });\n }\n });\n\n objectsStream.on(\"error\", (err) => {\n reject(err);\n });\n\n objectsStream.on(\"end\", () => {\n resolve(objects);\n });\n });\n },\n };\n}\n\n/**\n * Creates an operation to get an object's metadata\n *\n * @param bucket - The bucket name containing the object\n * @param objectName - The object name/path\n * @returns A MinioOperation that gets object stats when executed\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createStatObjectOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n *\n * const statOperation = createStatObjectOperation(\"my-bucket\", \"folder/file.txt\");\n * const stats = await executeMinioOperation(client, statOperation);\n */\nexport function createStatObjectOperation(\n bucket: string,\n objectName: string,\n): MinioOperation<{\n size: number;\n etag: string;\n metaData: Record<string, string>;\n lastModified: Date;\n}> {\n return {\n execute: async (client: Client) => {\n return client.statObject(bucket, objectName);\n },\n };\n}\n\n/**\n * Creates an operation to upload a buffer to MinIO\n *\n * @param bucket - The bucket name to upload to\n * @param objectName - The object name/path to create\n * @param buffer - The buffer containing the file data\n * @param metadata - Optional metadata to attach to the object\n * @returns A MinioOperation that uploads the buffer when executed\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createUploadOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n *\n * const buffer = Buffer.from(\"file content\");\n * const uploadOperation = createUploadOperation(\"my-bucket\", \"folder/file.txt\", buffer, { \"content-type\": \"text/plain\" });\n * const result = await executeMinioOperation(client, uploadOperation);\n */\nexport function createUploadOperation(\n bucket: string,\n objectName: string,\n buffer: Buffer,\n metadata?: ItemBucketMetadata,\n): MinioOperation<{ etag: string }> {\n return {\n execute: async (client: Client) => {\n return client.putObject(bucket, objectName, buffer, undefined, metadata);\n },\n };\n}\n\n/**\n * Creates an operation to delete an object from MinIO\n *\n * @param bucket - The bucket name containing the object\n * @param objectName - The object name/path to delete\n * @returns A MinioOperation that deletes the object when executed\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createDeleteOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n *\n * const deleteOperation = createDeleteOperation(\"my-bucket\", \"folder/file.txt\");\n * await executeMinioOperation(client, deleteOperation);\n */\nexport function createDeleteOperation(bucket: string, objectName: string): MinioOperation<void> {\n return {\n execute: async (client: Client) => {\n return client.removeObject(bucket, objectName);\n },\n };\n}\n\n/**\n * Creates an operation to generate a presigned URL for an object\n *\n * @param bucket - The bucket name containing the object\n * @param objectName - The object name/path\n * @param expirySeconds - How long the URL should be valid for in seconds\n * @returns A MinioOperation that creates a presigned URL when executed\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createPresignedUrlOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n *\n * const urlOperation = createPresignedUrlOperation(\"my-bucket\", \"folder/file.txt\", 3600);\n * const url = await executeMinioOperation(client, urlOperation);\n */\nexport function createPresignedUrlOperation(\n bucket: string,\n objectName: string,\n expirySeconds: number,\n): MinioOperation<string> {\n return {\n execute: async (client: Client) => {\n return client.presignedGetObject(bucket, objectName, expirySeconds);\n },\n };\n}\n\n/**\n * Creates an operation to generate a presigned PUT URL for direct uploads\n *\n * @param bucket - The bucket name to upload to\n * @param objectName - The object name/path to create\n * @param expirySeconds - How long the URL should be valid for in seconds\n * @returns A MinioOperation that creates a presigned PUT URL when executed\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createPresignedPutOperation, executeMinioOperation } from \"@settlemint/sdk-minio\";\n *\n * const putUrlOperation = createPresignedPutOperation(\"my-bucket\", \"folder/file.txt\", 3600);\n * const url = await executeMinioOperation(client, putUrlOperation);\n */\nexport function createPresignedPutOperation(\n bucket: string,\n objectName: string,\n expirySeconds: number,\n): MinioOperation<string> {\n return {\n execute: async (client: Client) => {\n // The MinIO client only accepts the first three parameters for presignedPutObject\n // Metadata needs to be applied when actually uploading via the presigned URL\n return client.presignedPutObject(bucket, objectName, expirySeconds);\n },\n };\n}\n\n/**\n * Creates a simplified upload function bound to a specific client\n *\n * @param client - The MinIO client to use for uploads\n * @returns A function that uploads buffers to MinIO\n * @throws Will throw an error if the operation fails\n *\n * @example\n * import { createSimpleUploadOperation, getMinioClient } from \"@settlemint/sdk-minio\";\n *\n * const client = await getMinioClient();\n * const uploadFn = createSimpleUploadOperation(client);\n * const result = await uploadFn(buffer, \"my-bucket\", \"folder/file.txt\", { \"content-type\": \"text/plain\" });\n */\nexport function createSimpleUploadOperation(client: Client) {\n return async (\n buffer: Buffer,\n bucket: string,\n objectName: string,\n metadata?: ItemBucketMetadata,\n ): Promise<{ etag: string }> => {\n return client.putObject(bucket, objectName, buffer, undefined, metadata);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,kBAA6B;AAC7B,IAAAC,qBAAyB;AACzB,mBAAuB;;;ACFvB,wBAA0B;AAC1B,iBAAkB;AAKX,IAAM,4BAA4B,aAAE,OAAO;AAAA;AAAA,EAEhD,UAAU;AAAA;AAAA,EAEV,WAAW,aAAE,OAAO;AAAA;AAAA,EAEpB,WAAW,aAAE,OAAO;AACtB,CAAC;;;ACbD,IAAAC,cAAkB;AAeX,IAAM,qBAAqB,cAAE,OAAO;AAAA,EACzC,IAAI,cAAE,OAAO;AAAA,EACb,MAAM,cAAE,OAAO;AAAA,EACf,aAAa,cAAE,OAAO;AAAA,EACtB,MAAM,cAAE,OAAO;AAAA,EACf,YAAY,cAAE,OAAO,EAAE,SAAS;AAAA,EAChC,MAAM,cAAE,OAAO;AAAA,EACf,KAAK,cAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACjC,CAAC;AA2CM,IAAM,iBAAiB;;;ACjE9B,IAAAC,kBAA6B;AAC7B,IAAAC,qBAAyB;;;ACFzB,qBAA6B;AAsB7B,eAAsB,sBAAyB,QAAgB,WAA0C;AACvG,mCAAa;AAEb,SAAO,UAAU,QAAQ,MAAM;AACjC;;;ACAO,SAAS,2BACd,QACA,SAAS,IAST;AACA,SAAO;AAAA,IACL,SAAS,OAAO,WAAmB;AACjC,YAAM,gBAAgB,OAAO,YAAY,QAAQ,QAAQ,IAAI;AAC7D,YAAM,UAMD,CAAC;AAEN,aAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,sBAAc,GAAG,QAAQ,CAAC,QAAQ;AAEhC,cA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