@settlemint/sdk-minio
Version:
MinIO integration module for SettleMint SDK, providing S3-compatible object storage capabilities
1 lines • 3.3 kB
Source Map (JSON)
{"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 * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,\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 return {\n client: new Client({\n endPoint: new URL(validatedOptions.instance).host,\n accessKey: validatedOptions.accessKey,\n secretKey: validatedOptions.secretKey,\n region: \"eu-central-1\",\n }),\n };\n}\n","import { ApplicationAccessTokenSchema, 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 access token used to authenticate with the SettleMint platform */\n accessToken: ApplicationAccessTokenSchema,\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,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,cAAc;;;ACFvB,SAAS,8BAA8B,iBAAiB;AACxD,SAAS,SAAS;AAKX,IAAM,sBAAsB,EAAE,OAAO;AAAA;AAAA,EAE1C,UAAU;AACZ,CAAC;AAWM,IAAM,4BAA4B,oBAAoB,OAAO;AAAA;AAAA,EAElE,aAAa;AAAA;AAAA,EAEb,WAAW,EAAE,OAAO;AAAA;AAAA,EAEpB,WAAW,EAAE,OAAO;AACtB,CAAC;;;ADJM,SAAS,wBAAwB,SAAkD;AACxF,eAAa;AACb,QAAM,mBAAmB,SAAS,2BAA2B,OAAO;AAEpE,SAAO;AAAA,IACL,QAAQ,IAAI,OAAO;AAAA,MACjB,UAAU,IAAI,IAAI,iBAAiB,QAAQ,EAAE;AAAA,MAC7C,WAAW,iBAAiB;AAAA,MAC5B,WAAW,iBAAiB;AAAA,MAC5B,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACF;","names":[]}