@settlemint/sdk-minio 2.3.2-prfd3a56ad → 2.3.3

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/minio.js ADDED
@@ -0,0 +1,520 @@
1
+ import { ensureServer } from "@settlemint/sdk-utils/runtime";
2
+ import { UrlSchema, validate } from "@settlemint/sdk-utils/validation";
3
+ import { Client } from "minio";
4
+ import { z } from "zod/v4";
5
+
6
+ //#region src/helpers/client-options.schema.ts
7
+ /**
8
+ * Schema for validating server client options for the MinIO client.
9
+ */
10
+ const ServerClientOptionsSchema = z.object({
11
+ instance: UrlSchema,
12
+ accessKey: z.string().min(1, "Access key cannot be empty"),
13
+ secretKey: z.string().min(1, "Secret key cannot be empty")
14
+ });
15
+
16
+ //#endregion
17
+ //#region src/helpers/schema.ts
18
+ /**
19
+ * Schema for file metadata stored in MinIO.
20
+ * Defines the structure and validation rules for file information.
21
+ */
22
+ const FileMetadataSchema = z.object({
23
+ id: z.string(),
24
+ name: z.string(),
25
+ contentType: z.string(),
26
+ size: z.number(),
27
+ uploadedAt: z.string().datetime(),
28
+ etag: z.string(),
29
+ url: z.string().url().optional()
30
+ });
31
+ /**
32
+ * Default bucket name to use for file storage when none is specified.
33
+ */
34
+ const DEFAULT_BUCKET = "uploads";
35
+
36
+ //#endregion
37
+ //#region src/helpers/executor.ts
38
+ /**
39
+ * Executes a MinIO operation using the provided client
40
+ *
41
+ * @param client - MinIO client to use
42
+ * @param operation - The operation to execute
43
+ * @returns The result of the operation execution
44
+ * @throws Will throw an error if the operation fails
45
+ *
46
+ * @example
47
+ * import { createServerMinioClient, createListObjectsOperation, executeMinioOperation } from "@settlemint/sdk-minio";
48
+ * const { client } = createServerMinioClient({
49
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
50
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
51
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
52
+ * });
53
+ * const listOperation = createListObjectsOperation("my-bucket", "prefix/");
54
+ * const result = await executeMinioOperation(client, listOperation);
55
+ */
56
+ async function executeMinioOperation(client, operation) {
57
+ ensureServer();
58
+ return operation.execute(client);
59
+ }
60
+
61
+ //#endregion
62
+ //#region src/helpers/operations.ts
63
+ /**
64
+ * Creates an operation to list objects in a bucket
65
+ *
66
+ * @param bucket - The bucket name to list objects from
67
+ * @param prefix - Optional prefix to filter objects (like a folder path)
68
+ * @returns A MinioOperation that lists objects when executed
69
+ * @throws Will throw an error if the operation fails
70
+ *
71
+ * @example
72
+ * import { createListObjectsOperation, executeMinioOperation } from "@settlemint/sdk-minio";
73
+ *
74
+ * const listOperation = createListObjectsOperation("my-bucket", "folder/");
75
+ * const objects = await executeMinioOperation(client, listOperation);
76
+ */
77
+ function createListObjectsOperation(bucket, prefix = "") {
78
+ return { execute: async (client) => {
79
+ const objectsStream = client.listObjects(bucket, prefix, true);
80
+ const objects = [];
81
+ return new Promise((resolve, reject) => {
82
+ objectsStream.on("data", (obj) => {
83
+ if (obj.name && typeof obj.size === "number" && obj.etag && obj.lastModified) {
84
+ objects.push({
85
+ name: obj.name,
86
+ prefix: obj.prefix,
87
+ size: obj.size,
88
+ etag: obj.etag,
89
+ lastModified: obj.lastModified
90
+ });
91
+ }
92
+ });
93
+ objectsStream.on("error", (err) => {
94
+ reject(err);
95
+ });
96
+ objectsStream.on("end", () => {
97
+ resolve(objects);
98
+ });
99
+ });
100
+ } };
101
+ }
102
+ /**
103
+ * Creates an operation to get an object's metadata
104
+ *
105
+ * @param bucket - The bucket name containing the object
106
+ * @param objectName - The object name/path
107
+ * @returns A MinioOperation that gets object stats when executed
108
+ * @throws Will throw an error if the operation fails
109
+ *
110
+ * @example
111
+ * import { createStatObjectOperation, executeMinioOperation } from "@settlemint/sdk-minio";
112
+ *
113
+ * const statOperation = createStatObjectOperation("my-bucket", "folder/file.txt");
114
+ * const stats = await executeMinioOperation(client, statOperation);
115
+ */
116
+ function createStatObjectOperation(bucket, objectName) {
117
+ return { execute: async (client) => {
118
+ return client.statObject(bucket, objectName);
119
+ } };
120
+ }
121
+ /**
122
+ * Creates an operation to upload a buffer to MinIO
123
+ *
124
+ * @param bucket - The bucket name to upload to
125
+ * @param objectName - The object name/path to create
126
+ * @param buffer - The buffer containing the file data
127
+ * @param metadata - Optional metadata to attach to the object
128
+ * @returns A MinioOperation that uploads the buffer when executed
129
+ * @throws Will throw an error if the operation fails
130
+ *
131
+ * @example
132
+ * import { createUploadOperation, executeMinioOperation } from "@settlemint/sdk-minio";
133
+ *
134
+ * const buffer = Buffer.from("file content");
135
+ * const uploadOperation = createUploadOperation("my-bucket", "folder/file.txt", buffer, { "content-type": "text/plain" });
136
+ * const result = await executeMinioOperation(client, uploadOperation);
137
+ */
138
+ function createUploadOperation(bucket, objectName, buffer, metadata) {
139
+ return { execute: async (client) => {
140
+ return client.putObject(bucket, objectName, buffer, undefined, metadata);
141
+ } };
142
+ }
143
+ /**
144
+ * Creates an operation to delete an object from MinIO
145
+ *
146
+ * @param bucket - The bucket name containing the object
147
+ * @param objectName - The object name/path to delete
148
+ * @returns A MinioOperation that deletes the object when executed
149
+ * @throws Will throw an error if the operation fails
150
+ *
151
+ * @example
152
+ * import { createDeleteOperation, executeMinioOperation } from "@settlemint/sdk-minio";
153
+ *
154
+ * const deleteOperation = createDeleteOperation("my-bucket", "folder/file.txt");
155
+ * await executeMinioOperation(client, deleteOperation);
156
+ */
157
+ function createDeleteOperation(bucket, objectName) {
158
+ return { execute: async (client) => {
159
+ return client.removeObject(bucket, objectName);
160
+ } };
161
+ }
162
+ /**
163
+ * Creates an operation to generate a presigned URL for an object
164
+ *
165
+ * @param bucket - The bucket name containing the object
166
+ * @param objectName - The object name/path
167
+ * @param expirySeconds - How long the URL should be valid for in seconds
168
+ * @returns A MinioOperation that creates a presigned URL when executed
169
+ * @throws Will throw an error if the operation fails
170
+ *
171
+ * @example
172
+ * import { createPresignedUrlOperation, executeMinioOperation } from "@settlemint/sdk-minio";
173
+ *
174
+ * const urlOperation = createPresignedUrlOperation("my-bucket", "folder/file.txt", 3600);
175
+ * const url = await executeMinioOperation(client, urlOperation);
176
+ */
177
+ function createPresignedUrlOperation(bucket, objectName, expirySeconds) {
178
+ return { execute: async (client) => {
179
+ return client.presignedGetObject(bucket, objectName, expirySeconds);
180
+ } };
181
+ }
182
+ /**
183
+ * Creates an operation to generate a presigned PUT URL for direct uploads
184
+ *
185
+ * @param bucket - The bucket name to upload to
186
+ * @param objectName - The object name/path to create
187
+ * @param expirySeconds - How long the URL should be valid for in seconds
188
+ * @returns A MinioOperation that creates a presigned PUT URL when executed
189
+ * @throws Will throw an error if the operation fails
190
+ *
191
+ * @example
192
+ * import { createPresignedPutOperation, executeMinioOperation } from "@settlemint/sdk-minio";
193
+ *
194
+ * const putUrlOperation = createPresignedPutOperation("my-bucket", "folder/file.txt", 3600);
195
+ * const url = await executeMinioOperation(client, putUrlOperation);
196
+ */
197
+ function createPresignedPutOperation(bucket, objectName, expirySeconds) {
198
+ return { execute: async (client) => {
199
+ return client.presignedPutObject(bucket, objectName, expirySeconds);
200
+ } };
201
+ }
202
+ /**
203
+ * Creates a simplified upload function bound to a specific client
204
+ *
205
+ * @param client - The MinIO client to use for uploads
206
+ * @returns A function that uploads buffers to MinIO
207
+ * @throws Will throw an error if the operation fails
208
+ *
209
+ * @example
210
+ * import { createSimpleUploadOperation, getMinioClient } from "@settlemint/sdk-minio";
211
+ *
212
+ * const client = await getMinioClient();
213
+ * const uploadFn = createSimpleUploadOperation(client);
214
+ * const result = await uploadFn(buffer, "my-bucket", "folder/file.txt", { "content-type": "text/plain" });
215
+ */
216
+ function createSimpleUploadOperation(client) {
217
+ return async (buffer, bucket, objectName, metadata) => {
218
+ return client.putObject(bucket, objectName, buffer, undefined, metadata);
219
+ };
220
+ }
221
+
222
+ //#endregion
223
+ //#region src/helpers/functions.ts
224
+ /**
225
+ * Helper function to normalize paths and prevent double slashes
226
+ *
227
+ * @param path - The path to normalize
228
+ * @param fileName - The filename to append
229
+ * @returns The normalized path with filename
230
+ * @throws Will throw an error if the path is too long (max 1000 characters)
231
+ */
232
+ function normalizePath(path, fileName) {
233
+ if (path.length > 1e3) {
234
+ throw new Error("Path is too long");
235
+ }
236
+ const cleanPath = path.replace(/\/+$/, "");
237
+ if (!cleanPath) {
238
+ return fileName;
239
+ }
240
+ return `${cleanPath}/${fileName}`;
241
+ }
242
+ /**
243
+ * Gets a list of files with optional prefix filter
244
+ *
245
+ * @param client - The MinIO client to use
246
+ * @param prefix - Optional prefix to filter files (like a folder path)
247
+ * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)
248
+ * @returns Array of file metadata objects
249
+ * @throws Will throw an error if the operation fails or client initialization fails
250
+ *
251
+ * @example
252
+ * import { createServerMinioClient, getFilesList } from "@settlemint/sdk-minio";
253
+ *
254
+ * const { client } = createServerMinioClient({
255
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
256
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
257
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
258
+ * });
259
+ *
260
+ * const files = await getFilesList(client, "documents/");
261
+ */
262
+ async function getFilesList(client, prefix = "", bucket = DEFAULT_BUCKET) {
263
+ ensureServer();
264
+ console.log(`Listing files with prefix: "${prefix}" in bucket: "${bucket}"`);
265
+ try {
266
+ const listOperation = createListObjectsOperation(bucket, prefix);
267
+ const objects = await executeMinioOperation(client, listOperation);
268
+ console.log(`Found ${objects.length} files in MinIO`);
269
+ const fileObjects = await Promise.allSettled(objects.map(async (obj) => {
270
+ try {
271
+ const presignedUrlOperation = createPresignedUrlOperation(bucket, obj.name, 3600);
272
+ const url = await executeMinioOperation(client, presignedUrlOperation);
273
+ return {
274
+ id: obj.name,
275
+ name: obj.name.split("/").pop() || obj.name,
276
+ contentType: "application/octet-stream",
277
+ size: obj.size,
278
+ uploadedAt: obj.lastModified.toISOString(),
279
+ etag: obj.etag,
280
+ url
281
+ };
282
+ } catch (error) {
283
+ console.warn(`Failed to generate presigned URL for ${obj.name}:`, error);
284
+ return {
285
+ id: obj.name,
286
+ name: obj.name.split("/").pop() || obj.name,
287
+ contentType: "application/octet-stream",
288
+ size: obj.size,
289
+ uploadedAt: obj.lastModified.toISOString(),
290
+ etag: obj.etag
291
+ };
292
+ }
293
+ })).then((results) => results.filter((result) => result.status === "fulfilled").map((result) => result.value));
294
+ return validate(FileMetadataSchema.array(), fileObjects);
295
+ } catch (error) {
296
+ console.error("Failed to list files:", error);
297
+ throw new Error(`Failed to list files: ${error instanceof Error ? error.message : String(error)}`);
298
+ }
299
+ }
300
+ /**
301
+ * Gets a single file by its object name
302
+ *
303
+ * @param client - The MinIO client to use
304
+ * @param fileId - The file identifier/path
305
+ * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)
306
+ * @returns File metadata with presigned URL
307
+ * @throws Will throw an error if the file doesn't exist or client initialization fails
308
+ *
309
+ * @example
310
+ * import { createServerMinioClient, getFileByObjectName } from "@settlemint/sdk-minio";
311
+ *
312
+ * const { client } = createServerMinioClient({
313
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
314
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
315
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
316
+ * });
317
+ *
318
+ * const file = await getFileByObjectName(client, "documents/report.pdf");
319
+ */
320
+ async function getFileById(client, fileId, bucket = DEFAULT_BUCKET) {
321
+ ensureServer();
322
+ console.log(`Getting file details for: ${fileId} in bucket: ${bucket}`);
323
+ try {
324
+ const statOperation = createStatObjectOperation(bucket, fileId);
325
+ const statResult = await executeMinioOperation(client, statOperation);
326
+ const presignedUrlOperation = createPresignedUrlOperation(bucket, fileId, 3600);
327
+ const url = await executeMinioOperation(client, presignedUrlOperation);
328
+ let size = 0;
329
+ if (statResult.metaData["content-length"]) {
330
+ const parsedSize = Number.parseInt(statResult.metaData["content-length"], 10);
331
+ if (!Number.isNaN(parsedSize) && parsedSize >= 0 && Number.isFinite(parsedSize)) {
332
+ size = parsedSize;
333
+ }
334
+ } else if (typeof statResult.size === "number" && !Number.isNaN(statResult.size)) {
335
+ size = statResult.size;
336
+ }
337
+ const fileMetadata = {
338
+ id: fileId,
339
+ name: fileId.split("/").pop() || fileId,
340
+ contentType: statResult.metaData["content-type"] || "application/octet-stream",
341
+ size,
342
+ uploadedAt: statResult.lastModified.toISOString(),
343
+ etag: statResult.etag,
344
+ url
345
+ };
346
+ return validate(FileMetadataSchema, fileMetadata);
347
+ } catch (error) {
348
+ console.error(`Failed to get file ${fileId}:`, error);
349
+ throw new Error(`Failed to get file ${fileId}: ${error instanceof Error ? error.message : String(error)}`);
350
+ }
351
+ }
352
+ /**
353
+ * Deletes a file from storage
354
+ *
355
+ * @param client - The MinIO client to use
356
+ * @param fileId - The file identifier/path
357
+ * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)
358
+ * @returns Success status
359
+ * @throws Will throw an error if deletion fails or client initialization fails
360
+ *
361
+ * @example
362
+ * import { createServerMinioClient, deleteFile } from "@settlemint/sdk-minio";
363
+ *
364
+ * const { client } = createServerMinioClient({
365
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
366
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
367
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
368
+ * });
369
+ *
370
+ * await deleteFile(client, "documents/report.pdf");
371
+ */
372
+ async function deleteFile(client, fileId, bucket = DEFAULT_BUCKET) {
373
+ ensureServer();
374
+ try {
375
+ const deleteOperation = createDeleteOperation(bucket, fileId);
376
+ await executeMinioOperation(client, deleteOperation);
377
+ return true;
378
+ } catch (error) {
379
+ console.error(`Failed to delete file ${fileId}:`, error);
380
+ throw new Error(`Failed to delete file ${fileId}: ${error instanceof Error ? error.message : String(error)}`);
381
+ }
382
+ }
383
+ /**
384
+ * Creates a presigned upload URL for direct browser uploads
385
+ *
386
+ * @param client - The MinIO client to use
387
+ * @param fileName - The file name to use
388
+ * @param path - Optional path/folder
389
+ * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)
390
+ * @param expirySeconds - How long the URL should be valid for
391
+ * @returns Presigned URL for PUT operation
392
+ * @throws Will throw an error if URL creation fails or client initialization fails
393
+ *
394
+ * @example
395
+ * import { createServerMinioClient, createPresignedUploadUrl } from "@settlemint/sdk-minio";
396
+ *
397
+ * const { client } = createServerMinioClient({
398
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
399
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
400
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
401
+ * });
402
+ *
403
+ * // Generate the presigned URL on the server
404
+ * const url = await createPresignedUploadUrl(client, "report.pdf", "documents/");
405
+ *
406
+ * // Send the URL to the client/browser via HTTP response
407
+ * return Response.json({ uploadUrl: url });
408
+ *
409
+ * // Then in the browser:
410
+ * const response = await fetch('/api/get-upload-url');
411
+ * const { uploadUrl } = await response.json();
412
+ * await fetch(uploadUrl, {
413
+ * method: 'PUT',
414
+ * headers: { 'Content-Type': 'application/pdf' },
415
+ * body: pdfFile
416
+ * });
417
+ */
418
+ async function createPresignedUploadUrl(client, fileName, path = "", bucket = DEFAULT_BUCKET, expirySeconds = 3600) {
419
+ ensureServer();
420
+ try {
421
+ const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, "_");
422
+ const objectName = normalizePath(path, safeFileName);
423
+ const presignedPutOperation = createPresignedPutOperation(bucket, objectName, expirySeconds);
424
+ const url = await executeMinioOperation(client, presignedPutOperation);
425
+ if (!url) {
426
+ throw new Error("Failed to generate presigned upload URL");
427
+ }
428
+ return url;
429
+ } catch (error) {
430
+ console.error("Failed to create presigned upload URL:", error);
431
+ throw new Error(`Failed to create presigned upload URL: ${error instanceof Error ? error.message : String(error)}`);
432
+ }
433
+ }
434
+ /**
435
+ * Uploads a buffer directly to storage
436
+ *
437
+ * @param client - The MinIO client to use
438
+ * @param buffer - The buffer to upload
439
+ * @param objectName - The full object name/path
440
+ * @param contentType - The content type of the file
441
+ * @param bucket - Optional bucket name (defaults to DEFAULT_BUCKET)
442
+ * @returns The uploaded file metadata
443
+ * @throws Will throw an error if upload fails or client initialization fails
444
+ *
445
+ * @example
446
+ * import { createServerMinioClient, uploadBuffer } from "@settlemint/sdk-minio";
447
+ *
448
+ * const { client } = createServerMinioClient({
449
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
450
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
451
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
452
+ * });
453
+ *
454
+ * const buffer = Buffer.from("Hello, world!");
455
+ * const uploadedFile = await uploadFile(client, buffer, "documents/hello.txt", "text/plain");
456
+ */
457
+ async function uploadFile(client, buffer, objectName, contentType, bucket = DEFAULT_BUCKET) {
458
+ ensureServer();
459
+ try {
460
+ const metadata = {
461
+ "content-type": contentType,
462
+ "upload-time": new Date().toISOString()
463
+ };
464
+ const simpleUploadFn = createSimpleUploadOperation(client);
465
+ const result = await simpleUploadFn(buffer, bucket, objectName, metadata);
466
+ const presignedUrlOperation = createPresignedUrlOperation(bucket, objectName, 3600);
467
+ const url = await executeMinioOperation(client, presignedUrlOperation);
468
+ const fileName = objectName.split("/").pop() || objectName;
469
+ const fileMetadata = {
470
+ id: objectName,
471
+ name: fileName,
472
+ contentType,
473
+ size: buffer.length,
474
+ uploadedAt: new Date().toISOString(),
475
+ etag: result.etag,
476
+ url
477
+ };
478
+ return validate(FileMetadataSchema, fileMetadata);
479
+ } catch (error) {
480
+ console.error("Failed to upload file:", error);
481
+ throw new Error(`Failed to upload file: ${error instanceof Error ? error.message : String(error)}`);
482
+ }
483
+ }
484
+
485
+ //#endregion
486
+ //#region src/minio.ts
487
+ /**
488
+ * Creates a MinIO client for server-side use with authentication.
489
+ *
490
+ * @param options - The server client options for configuring the MinIO client
491
+ * @returns An object containing the initialized MinIO client
492
+ * @throws Will throw an error if not called on the server or if the options fail validation
493
+ *
494
+ * @example
495
+ * import { createServerMinioClient } from "@settlemint/sdk-minio";
496
+ *
497
+ * const { client } = createServerMinioClient({
498
+ * instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
499
+ * accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
500
+ * secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
501
+ * });
502
+ * client.listBuckets();
503
+ */
504
+ function createServerMinioClient(options) {
505
+ ensureServer();
506
+ const validatedOptions = validate(ServerClientOptionsSchema, options);
507
+ const url = new URL(validatedOptions.instance);
508
+ return { client: new Client({
509
+ endPoint: url.hostname,
510
+ accessKey: validatedOptions.accessKey,
511
+ secretKey: validatedOptions.secretKey,
512
+ useSSL: url.protocol !== "http:",
513
+ port: url.port ? Number(url.port) : undefined,
514
+ region: "eu-central-1"
515
+ }) };
516
+ }
517
+
518
+ //#endregion
519
+ export { DEFAULT_BUCKET, createPresignedUploadUrl, createServerMinioClient, deleteFile, getFileById, getFilesList, uploadFile };
520
+ //# sourceMappingURL=minio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minio.js","names":["client: Client","operation: MinioOperation<T>","bucket: string","client: Client","objects: Array<{\n name: string;\n prefix?: string;\n size: number;\n etag: string;\n lastModified: Date;\n }>","objectName: string","buffer: Buffer","metadata?: ItemBucketMetadata","expirySeconds: number","path: string","fileName: string","client: Client","bucket: string","fileId: string","fileMetadata: FileMetadata","buffer: Buffer","objectName: string","contentType: string","options: ServerClientOptions"],"sources":["../src/helpers/client-options.schema.ts","../src/helpers/schema.ts","../src/helpers/executor.ts","../src/helpers/operations.ts","../src/helpers/functions.ts","../src/minio.ts"],"sourcesContent":["import { UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod/v4\";\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().min(1, \"Access key cannot be empty\"),\n /** The MinIO secret key used to authenticate with the MinIO server */\n secretKey: z.string().min(1, \"Secret key cannot be empty\"),\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/v4\";\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 { 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","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.allSettled(\n objects.map(async (obj): Promise<FileMetadata> => {\n try {\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 } catch (error) {\n console.warn(`Failed to generate presigned URL for ${obj.name}:`, error);\n // Return metadata without URL for failed presigned URL operations\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 is omitted for failed operations (undefined)\n };\n }\n }),\n ).then((results) =>\n results\n .filter((result): result is PromiseFulfilledResult<FileMetadata> => result.status === \"fulfilled\")\n .map((result) => result.value),\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) && parsedSize >= 0 && Number.isFinite(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 { 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"],"mappings":";;;;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AAwBI,SAAkD;AACxF,eAAc;CACd,MAAM,mBAAmB,SAAS,2BAA2B,QAAQ;CAErE,MAAM,MAAM,IAAI,IAAI,iBAAiB;AACrC,QAAO,EACL,QAAQ,IAAI,OAAO;EACjB,UAAU,IAAI;EACd,WAAW,iBAAiB;EAC5B,WAAW,iBAAiB;EAC5B,QAAQ,IAAI,aAAa;EACzB,MAAM,IAAI,OAAO,OAAO,IAAI,KAAK,GAAG;EACpC,QAAQ;CACT,GACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@settlemint/sdk-minio",
3
3
  "description": "MinIO integration module for SettleMint SDK, providing S3-compatible object storage capabilities",
4
- "version": "2.3.2-prfd3a56ad",
4
+ "version": "2.3.3",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "FSL-1.1-MIT",
@@ -22,14 +22,14 @@
22
22
  },
23
23
  "files": ["dist"],
24
24
  "main": "./dist/minio.cjs",
25
- "module": "./dist/minio.mjs",
25
+ "module": "./dist/minio.js",
26
26
  "types": "./dist/minio.d.ts",
27
27
  "exports": {
28
28
  "./package.json": "./package.json",
29
29
  ".": {
30
30
  "import": {
31
31
  "types": "./dist/minio.d.ts",
32
- "default": "./dist/minio.mjs"
32
+ "default": "./dist/minio.js"
33
33
  },
34
34
  "require": {
35
35
  "types": "./dist/minio.d.cts",
@@ -38,8 +38,8 @@
38
38
  }
39
39
  },
40
40
  "scripts": {
41
- "build": "tsup-node",
42
- "dev": "tsup-node --watch",
41
+ "build": "tsdown",
42
+ "dev": "tsdown --watch",
43
43
  "publint": "publint run --strict",
44
44
  "attw": "attw --pack .",
45
45
  "test": "bun test",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "devDependencies": {},
53
53
  "dependencies": {
54
- "@settlemint/sdk-utils": "2.3.2-prfd3a56ad",
54
+ "@settlemint/sdk-utils": "2.3.3",
55
55
  "minio": "^8",
56
56
  "zod": "^3.25.0"
57
57
  },