feat: consolidate S3 client factory + presigned URL helpers into s3-utils#1024
Open
pyramation wants to merge 2 commits intomainfrom
Open
feat: consolidate S3 client factory + presigned URL helpers into s3-utils#1024pyramation wants to merge 2 commits intomainfrom
pyramation wants to merge 2 commits intomainfrom
Conversation
…tils - Add createS3Client() factory to @constructive-io/s3-utils as the canonical S3 client creation point for all providers (AWS, MinIO, R2, GCS, DigitalOcean Spaces) - Add presignPutUrl(), presignGetUrl(), headObject() presigned URL helpers - Re-export S3Client and S3ClientConfig from @aws-sdk/client-s3 so consumers don't need a direct dependency - Update s3-streamer to delegate client creation to s3-utils - Update bucket-provisioner to delegate client creation to s3-utils (with backward-compatible ProvisionerError re-throw) - Update graphile-settings presigned-url-resolver to use createS3Client - Update graphql/server create-bucket script to use createS3Client - Add 21 unit tests for client factory + presigned URL helpers
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
Remove S3Client and S3ClientConfig re-exports from s3-utils barrel. Consumers should import these directly from @aws-sdk/client-s3. Updated s3-streamer to import S3Client type from @aws-sdk/client-s3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
@constructive-io/s3-utilsthe canonical, one-import package for S3 operations across the monorepo. Previously, three packages each created their ownS3Clientinstances with duplicated provider-specific logic (path-style for MinIO, endpoint requirements for non-AWS providers, etc.).New in
s3-utils:createS3Client(config)— unified factory supporting AWS S3, MinIO, R2, GCS, and DigitalOcean SpacespresignPutUrl()/presignGetUrl()/headObject()— presigned URL helpers (wraps@aws-sdk/s3-request-presigner)StorageConnectionConfigandStorageProvidertypesS3ConfigErrorstructured error classUpdated packages:
s3-streamer—getS3()now delegates tocreateS3Clientfrom s3-utils; importsS3Clienttype directly from@aws-sdk/client-s3(moved from devDependencies to dependencies)bucket-provisioner—createS3Client()now wraps s3-utils, re-throwingS3ConfigErrorasProvisionerErrorfor backward compatgraphile-settings/presigned-url-resolver.ts— usescreateS3Clientinstead ofnew S3Client(...)graphql/server/scripts/create-bucket.ts— usescreateS3Clientinstead ofnew S3Client(...)21 new unit tests cover the client factory and presigned URL helpers. All 84 existing bucket-provisioner tests continue to pass.
Updates since last revision
export { S3Client }andexport type { S3ClientConfig }re-exports from the s3-utils barrel. Third-party types are not re-exported — consumers that need theS3Clienttype import it directly from@aws-sdk/client-s3.Review & Testing Checklist for Human
as anycasts onclientinpresigned.ts:91,113—client as anywhen callinggetSignedUrl. Likely an AWS SDK version mismatch between@aws-sdk/client-s3and@aws-sdk/s3-request-presigner. Verify these resolve correctly at the locked versionsas anycast oncdn.providerinpresigned-url-resolver.ts:70—(cdn.provider || 'minio') as anybypasses type checking. Verifycdn.providervalues fromgetEnvOptions()are actually validStorageProviderstrings, or add a proper type guarderr.code as ProvisionerErrorCodecast inbucket-provisioner/src/client.ts— assumes S3ConfigError codes map cleanly to ProvisionerErrorCode. Verify the union types aligns3-streamer/s3.ts— oldgetS3()silently created a client with no credentials if keys were empty; new code throwsS3ConfigError. Confirm no caller depends on the old lenient behaviorStorageConnectionConfigandStorageProviderare now defined in boths3-utils/src/client.tsandbucket-provisioner/src/types.ts. They're structurally identical but could drift. Consider whether bucket-provisioner should re-export from s3-utils insteadSuggested test plan: Run the
create-bucketscript against a local MinIO instance to verify client creation still works. If you have the graphile server running, test a presigned upload flow end-to-end to confirm the resolver changes don't regress.Notes
presignPutUrl,presignGetUrl) are new API surface not yet consumed by any code in this PR — they're available for future use (e.g., to consolidategraphile-presigned-url-plugin/s3-signer.ts)@aws-sdk/s3-request-presigneris a new dependency added to s3-utilscreate-bucket.tsstill hascreateS3Bucket(client as any, ...)— separate from the presigned casts, this may indicate a type mismatch between s3-utils'createS3Bucketparam type and theS3Clientreturned bycreateS3ClientLink to Devin session: https://app.devin.ai/sessions/18879be982854a40abe5c9b915aa4a84
Requested by: @pyramation