From b8af26b7a79f606aa9ade337489918ffe97bc8ac Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Sat, 2 Mar 2024 17:12:26 -0800 Subject: [PATCH] Version 0.7.1 - publish on jsr.io --- README.md | 14 +++++++------- client.ts | 8 ++++---- deno.jsonc | 9 ++++++++- deps-tests.ts | 8 ++++---- deps.ts | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index fc7c0af..0fefa53 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# deno-s3-lite-client +# s3-lite-client -This is a lightweight S3 client for Deno, designed to offer all the key features you may need, with no dependencies -outside of the Deno standard library. It does not use any Deno-specific features, so it should work with any modern -JavaScript runtime that supports the `fetch` API and URL imports. +This is a lightweight S3 client for Deno and other modern JavaScript runtimes. It is designed to offer all the key +features you may need, with no dependencies outside of the Deno standard library. It does not use any Deno-specific +features, so it should work with any runtime that supports the `fetch` API, web streams API, and ES modules (ESM). This client is 100% MIT licensed, and is derived from the excellent [MinIO JavaScript Client](https://github.com/minio/minio-js). @@ -39,7 +39,7 @@ Supported functionality: List data files from a public data set on Amazon S3: ```typescript -import { S3Client } from "https://deno.land/x/s3_lite_client@0.7.0/mod.ts"; +import { S3Client } from "@bradenmacdonald/s3-lite-client"; const s3client = new S3Client({ endPoint: "s3.us-east-1.amazonaws.com", @@ -75,7 +75,7 @@ const keys = await Array.fromAsync(s3client.listObjects(), (entry) => entry.key) Uploading and downloading a file using a local MinIO server: ```typescript -import { S3Client } from "https://deno.land/x/s3_lite_client@0.7.0/mod.ts"; +import { S3Client } from "@bradenmacdonald/s3-lite-client"; // Connecting to a local MinIO server: const s3client = new S3Client({ @@ -129,7 +129,7 @@ Then while MinIO is running, run deno test --allow-net integration.ts ``` -To debug what MinIO is seeing, run these two commands: +(If you encounter issues and need to debug what MinIO is seeing, run these two commands:) ```sh mc alias set localdebug http://localhost:9000 AKIA_DEV secretkey diff --git a/client.ts b/client.ts index 8f50b34..3a2d48e 100644 --- a/client.ts +++ b/client.ts @@ -133,7 +133,7 @@ export class Client { readonly sessionToken?: string; readonly defaultBucket: string | undefined; readonly region: string; - readonly userAgent = "deno-s3-lite-client"; + readonly userAgent = "s3-lite-client"; /** Use path-style requests, e.g. https://endpoint/bucket/object-key instead of https://bucket/object-key */ readonly pathStyle: boolean; @@ -173,7 +173,7 @@ export class Client { this.region = params.region; } - protected getBucketName(options: undefined | { bucketName?: string }) { + protected getBucketName(options: undefined | { bucketName?: string }): string { const bucketName = options?.bucketName ?? this.defaultBucket; if (bucketName === undefined || !isValidBucketName(bucketName)) { throw new errors.InvalidBucketNameError( @@ -477,7 +477,7 @@ export class Client { expirySeconds?: number; requestDate?: Date; } = {}, - ) { + ): Promise { const { versionId, responseParams, ...otherOptions } = options; const parameters: Record = { ...responseParams, @@ -714,7 +714,7 @@ export class Client { * - maximum of 10,000 parts per upload * - maximum object size of 5TB */ - protected calculatePartSize(size: number | undefined) { + protected calculatePartSize(size: number | undefined): number { if (size === undefined) { // If we don't know the total size (e.g. we're streaming data), assume it's // the largest allowed object size, so we can guarantee the upload works diff --git a/deno.jsonc b/deno.jsonc index ba454f4..ca032c1 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,6 +1,13 @@ { + "name": "@bradenmacdonald/s3-lite-client", + "version": "0.7.1", + "exports": "./mod.ts", "fmt": { "lineWidth": 120 }, - "lock": false + "lock": false, + "imports": { + "@std/assert": "jsr:@std/assert@^0.218", + "@std/io": "jsr:@std/io@^0.218" + } } diff --git a/deps-tests.ts b/deps-tests.ts index b6f64f5..eac3cac 100644 --- a/deps-tests.ts +++ b/deps-tests.ts @@ -1,4 +1,4 @@ -export { assert } from "https://deno.land/std@0.215.0/assert/assert.ts"; -export { assertEquals } from "https://deno.land/std@0.215.0/assert/assert_equals.ts"; -export { assertInstanceOf } from "https://deno.land/std@0.215.0/assert/assert_instance_of.ts"; -export { assertRejects } from "https://deno.land/std@0.215.0/assert/assert_rejects.ts"; +export { assert } from "@std/assert/assert"; +export { assertEquals } from "@std/assert/assert_equals"; +export { assertInstanceOf } from "@std/assert/assert_instance_of"; +export { assertRejects } from "@std/assert/assert_rejects"; diff --git a/deps.ts b/deps.ts index 76d8318..2c64f1d 100644 --- a/deps.ts +++ b/deps.ts @@ -1 +1 @@ -export { Buffer } from "https://deno.land/std@0.215.0/io/buffer.ts"; +export { Buffer } from "@std/io/buffer";