diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f10341d..57d2a41 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,7 +4,7 @@ To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following: -- [ ] Forked the repo and created your branch from `master` +- [ ] Forked the repo and created your branch from `main` - [ ] Made sure tests pass (run `npm it` from the repo root) - [ ] Expanded test coverage related to your changes: - [ ] Added and/or updated unit tests (if appropriate) diff --git a/plugins/s3/readme.md b/plugins/s3/readme.md index 60870a1..cd33b45 100644 --- a/plugins/s3/readme.md +++ b/plugins/s3/readme.md @@ -1619,89 +1619,6 @@ Properties: - Sets request header: `x-amz-expected-bucket-owner` -### `Upload` - - -Properties: -- **`Bucket` (string) [required]** - - S3 bucket name -- **`Key` (string) [required]** - - S3 key / file name -- **`Body` (buffer, stream, string)** - - String or buffer to be uploaded; per S3, size should be 5MB or greater -- **`File` (string)** - - File path to be read and uploaded from the local filesystem; per S3, size should be 5MB or greater -- **`ChunkSize` (number)** - - Size of each chunk to upload in byes (also aliased to `partSize`); default is 10 MB -- **`Concurrency` (number)** - - Maximum concurrent uploads (also aliased to `queueSize`); default is 5, setting to 1 synchronously, sequentially uploads chunks; memory consumption is (`ChunkSize` + 1) * `Concurrency` -- **`ACL` (string)** - - Sets request header: `x-amz-acl` -- **`BucketKeyEnabled` (string)** - - Sets request header: `x-amz-server-side-encryption-bucket-key-enabled` -- **`CacheControl` (string)** - - Sets request header: `cache-control` -- **`ChecksumAlgorithm` (string)** - - Sets request header: `x-amz-sdk-checksum-algorithm` -- **`ChecksumCRC32` (string)** - - Sets request header: `x-amz-checksum-crc32` -- **`ChecksumCRC32C` (string)** - - Sets request header: `x-amz-checksum-crc32c` -- **`ChecksumSHA1` (string)** - - Sets request header: `x-amz-checksum-sha1` -- **`ChecksumSHA256` (string)** - - Sets request header: `x-amz-checksum-sha256` -- **`ContentDisposition` (string)** - - Sets request header: `content-disposition` -- **`ContentEncoding` (string)** - - Sets request header: `content-encoding` -- **`ContentLanguage` (string)** - - Sets request header: `content-language` -- **`ContentType` (string)** - - Sets request header: `content-type` -- **`ExpectedBucketOwner` (string)** - - Sets request header: `x-amz-expected-bucket-owner` -- **`Expires` (string)** - - Sets request header: `expires` -- **`GrantFullControl` (string)** - - Sets request header: `x-amz-grant-full-control` -- **`GrantRead` (string)** - - Sets request header: `x-amz-grant-read` -- **`GrantReadACP` (string)** - - Sets request header: `x-amz-grant-read-acp` -- **`GrantWriteACP` (string)** - - Sets request header: `x-amz-grant-write-acp` -- **`ObjectLockLegalHoldStatus` (string)** - - Sets request header: `x-amz-object-lock-legal-hold` -- **`ObjectLockMode` (string)** - - Sets request header: `x-amz-object-lock-mode` -- **`ObjectLockRetainUntilDate` (string)** - - Sets request header: `x-amz-object-lock-retain-until-date` -- **`RequestPayer` (string)** - - Sets request header: `x-amz-request-payer` -- **`ServerSideEncryption` (string)** - - Sets request header: `x-amz-server-side-encryption` -- **`SSECustomerAlgorithm` (string)** - - Sets request header: `x-amz-server-side-encryption-customer-algorithm` -- **`SSECustomerKey` (string)** - - Sets request header: `x-amz-server-side-encryption-customer-key` -- **`SSECustomerKeyMD5` (string)** - - Sets request header: `x-amz-server-side-encryption-customer-key-md5` -- **`SSEKMSEncryptionContext` (string)** - - Sets request header: `x-amz-server-side-encryption-context` -- **`SSEKMSKeyId` (string)** - - Sets request header: `x-amz-server-side-encryption-aws-kms-key-id` -- **`StorageClass` (string)** - - Sets request header: `x-amz-storage-class` -- **`Tagging` (string)** - - Sets request header: `x-amz-tagging` -- **`WebsiteRedirectLocation` (string)** - - Sets request header: `x-amz-website-redirect-location` -- **`Metadata` (object)** - - Key / value pairs of object metadata; must conform to S3 metadata guidelines - - [More details (AWS)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html) - - ### `UploadPart` [Canonical AWS API doc](https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html) @@ -1746,6 +1663,7 @@ Properties: > Please help out by [opening a PR](https://github.com/aws-lite/aws-lite#authoring-aws-lite-plugins)! +- `Upload` - [`CreateSession`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateSession.html) - [`GetBucketLifecycle`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycle.html) - [`GetBucketNotification`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketNotification.html) diff --git a/plugins/s3/src/upload.mjs b/plugins/s3/src/upload.mjs index 46516f3..9ebba3e 100644 --- a/plugins/s3/src/upload.mjs +++ b/plugins/s3/src/upload.mjs @@ -10,6 +10,7 @@ const xml = { 'content-type': 'application/xml' } const Upload = { awsDoc: false, + disabled: true, validate: { Bucket: { type: 'string', required, comment: 'S3 bucket name' }, Key: { type: 'string', required, comment: 'S3 key / file name' }, diff --git a/plugins/s3/types/index.d.ts b/plugins/s3/types/index.d.ts index b3c7436..2f4f772 100644 --- a/plugins/s3/types/index.d.ts +++ b/plugins/s3/types/index.d.ts @@ -86,11 +86,12 @@ import { PutObjectTaggingCommandOutput as PutObjectTaggingResponse, PutPublicAccessBlockCommandOutput as PutPublicAccessBlockResponse, RestoreObjectCommandOutput as RestoreObjectResponse, - UploadCommandOutput as UploadResponse, UploadPartCommandOutput as UploadPartResponse, // $IMPORTS_END } from "@aws-sdk/client-s3"; +import { Readable } from 'node:stream'; + declare interface AwsLiteS3 { /* ! Do not remove METHODS_START / METHODS_END ! */ // $METHODS_START @@ -563,7 +564,7 @@ declare interface AwsLiteS3 { * - AWS docs: {@link https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html S3: PutObject} * - aws-lite docs: {@link https://github.com/aws-lite/aws-lite/blob/main/plugins/s3/readme.md#PutObject S3: PutObject} */ - PutObject: (input: { Bucket: string, Key: string, Body?: Buffer | stream | string, File?: string, ApplyChecksum?: boolean, MinChunkSize?: number, ACL?: string, BucketKeyEnabled?: string, CacheControl?: string, ChecksumAlgorithm?: string, ChecksumCRC32?: string, ChecksumCRC32C?: string, ChecksumSHA1?: string, ChecksumSHA256?: string, ContentDisposition?: string, ContentEncoding?: string, ContentLanguage?: string, ContentLength?: string, ContentMD5?: string, ContentType?: string, ExpectedBucketOwner?: string, Expires?: string, GrantFullControl?: string, GrantRead?: string, GrantReadACP?: string, GrantWriteACP?: string, ObjectLockLegalHoldStatus?: string, ObjectLockMode?: string, ObjectLockRetainUntilDate?: string, RequestPayer?: string, ServerSideEncryption?: string, SSECustomerAlgorithm?: string, SSECustomerKey?: string, SSECustomerKeyMD5?: string, SSEKMSEncryptionContext?: string, SSEKMSKeyId?: string, StorageClass?: string, Tagging?: string, WebsiteRedirectLocation?: string, Metadata?: Record }) => Promise + PutObject: (input: { Bucket: string, Key: string, Body?: Buffer | Readable | string, File?: string, ApplyChecksum?: boolean, MinChunkSize?: number, ACL?: string, BucketKeyEnabled?: string, CacheControl?: string, ChecksumAlgorithm?: string, ChecksumCRC32?: string, ChecksumCRC32C?: string, ChecksumSHA1?: string, ChecksumSHA256?: string, ContentDisposition?: string, ContentEncoding?: string, ContentLanguage?: string, ContentLength?: string, ContentMD5?: string, ContentType?: string, ExpectedBucketOwner?: string, Expires?: string, GrantFullControl?: string, GrantRead?: string, GrantReadACP?: string, GrantWriteACP?: string, ObjectLockLegalHoldStatus?: string, ObjectLockMode?: string, ObjectLockRetainUntilDate?: string, RequestPayer?: string, ServerSideEncryption?: string, SSECustomerAlgorithm?: string, SSECustomerKey?: string, SSECustomerKeyMD5?: string, SSEKMSEncryptionContext?: string, SSEKMSKeyId?: string, StorageClass?: string, Tagging?: string, WebsiteRedirectLocation?: string, Metadata?: Record }) => Promise /** * @description * - AWS docs: {@link https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLegalHold.html S3: PutObjectLegalHold} @@ -600,17 +601,12 @@ declare interface AwsLiteS3 { * - aws-lite docs: {@link https://github.com/aws-lite/aws-lite/blob/main/plugins/s3/readme.md#RestoreObject S3: RestoreObject} */ RestoreObject: (input: { Bucket: string, Key: string, RestoreRequest: Record, VersionId?: string, RequestPayer?: string, ChecksumAlgorithm?: string, ExpectedBucketOwner?: string }) => Promise - /** - * @description - * - aws-lite docs: {@link https://github.com/aws-lite/aws-lite/blob/main/plugins/s3/readme.md#Upload S3: Upload} - */ - Upload: (input: { Bucket: string, Key: string, Body?: Buffer | stream | string, File?: string, ChunkSize?: number, Concurrency?: number, ACL?: string, BucketKeyEnabled?: string, CacheControl?: string, ChecksumAlgorithm?: string, ChecksumCRC32?: string, ChecksumCRC32C?: string, ChecksumSHA1?: string, ChecksumSHA256?: string, ContentDisposition?: string, ContentEncoding?: string, ContentLanguage?: string, ContentType?: string, ExpectedBucketOwner?: string, Expires?: string, GrantFullControl?: string, GrantRead?: string, GrantReadACP?: string, GrantWriteACP?: string, ObjectLockLegalHoldStatus?: string, ObjectLockMode?: string, ObjectLockRetainUntilDate?: string, RequestPayer?: string, ServerSideEncryption?: string, SSECustomerAlgorithm?: string, SSECustomerKey?: string, SSECustomerKeyMD5?: string, SSEKMSEncryptionContext?: string, SSEKMSKeyId?: string, StorageClass?: string, Tagging?: string, WebsiteRedirectLocation?: string, Metadata?: Record }) => Promise /** * @description * - AWS docs: {@link https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html S3: UploadPart} * - aws-lite docs: {@link https://github.com/aws-lite/aws-lite/blob/main/plugins/s3/readme.md#UploadPart S3: UploadPart} */ - UploadPart: (input: { Bucket: string, Key: string, PartNumber?: number, Body?: Buffer | stream | string, ContentLength?: string, ContentMD5?: string, ChecksumAlgorithm?: string, ChecksumCRC32?: string, ChecksumCRC32C?: string, ChecksumSHA1?: string, ChecksumSHA256?: string, SSECustomerAlgorithm?: string, SSECustomerKey?: string, SSECustomerKeyMD5?: string, RequestPayer?: string, ExpectedBucketOwner?: string }) => Promise + UploadPart: (input: { Bucket: string, Key: string, PartNumber?: number, Body?: Buffer | Readable | string, ContentLength?: string, ContentMD5?: string, ChecksumAlgorithm?: string, ChecksumCRC32?: string, ChecksumCRC32C?: string, ChecksumSHA1?: string, ChecksumSHA256?: string, SSECustomerAlgorithm?: string, SSECustomerKey?: string, SSECustomerKeyMD5?: string, RequestPayer?: string, ExpectedBucketOwner?: string }) => Promise // $METHODS_END } @@ -709,7 +705,6 @@ export type { PutObjectTaggingResponse, PutPublicAccessBlockResponse, RestoreObjectResponse, - UploadResponse, UploadPartResponse, // $EXPORT_END } diff --git a/readme.md b/readme.md index 48bfd28..9b983fb 100644 --- a/readme.md +++ b/readme.md @@ -176,7 +176,7 @@ Credential and general configuration options for [`aws-lite`](https://aws-lite.o Using [`aws-lite`](https://aws-lite.org/request-response) to make requests and receiving responses -### [Using TypeScript](https://aws-lite.org/using-typeScript) +### [Using TypeScript](https://aws-lite.org/using-typescript) Guide and examples for using TypeScript with `aws-lite` diff --git a/scripts/generate-plugins/_types.mjs b/scripts/generate-plugins/_types.mjs index 059242e..5e6642d 100644 --- a/scripts/generate-plugins/_types.mjs +++ b/scripts/generate-plugins/_types.mjs @@ -17,6 +17,7 @@ function typeFromValidateEntry (value) { case 'object': return 'Record' case 'array': return 'any[]' case 'buffer': return 'Buffer' + case 'stream': return 'Readable' default: return value } } diff --git a/src/index.d.ts b/src/index.d.ts index b5819c5..f64d552 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -48,9 +48,11 @@ interface AwsLiteResponse { statusCode: number; } -// export to allow -types to extend AwsLiteClient -export interface AwsLiteClient { - (payload: AwsLiteRequest): Promise; +// Declared as part of the namespace to allow -types to extend AwsLiteClient +declare namespace CreateAwsLite { // Match the name of your main export + interface AwsLiteClient { + (payload: AwsLiteRequest): Promise; + } } interface AwsLiteBaseMock { @@ -76,10 +78,8 @@ interface AwsLiteTesting { reset: () => void; } -declare module "@aws-lite/client" { - const CreateAwsLite: { - (config?: AwsLiteConfig): Promise; - testing: AwsLiteTesting; - } - export = CreateAwsLite; +declare const CreateAwsLite: { + (config?: AwsLiteConfig): Promise; + testing: AwsLiteTesting; } +export = CreateAwsLite;