Skip to content

Commit

Permalink
fix(core): amplify configure with storage path type issue (#14088)
Browse files Browse the repository at this point in the history
* fix(core): amplify configure with storage path type issue

* increase bundle size

* increase bundle size

---------

Co-authored-by: Ashwin Kumar <[email protected]>
  • Loading branch information
ashwinkumar6 and Ashwin Kumar authored Dec 20, 2024
1 parent f9d4162 commit 0ecded1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
40 changes: 20 additions & 20 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"name": "[Analytics] record (Pinpoint)",
"path": "./dist/esm/analytics/index.mjs",
"import": "{ record }",
"limit": "17.60 kB"
"limit": "17.63 kB"
},
{
"name": "[Analytics] record (Kinesis)",
Expand All @@ -317,7 +317,7 @@
"name": "[Analytics] identifyUser (Pinpoint)",
"path": "./dist/esm/analytics/index.mjs",
"import": "{ identifyUser }",
"limit": "16.10 kB"
"limit": "16.14 kB"
},
{
"name": "[Analytics] enable",
Expand All @@ -335,7 +335,7 @@
"name": "[API] generateClient (AppSync)",
"path": "./dist/esm/api/index.mjs",
"import": "{ generateClient }",
"limit": "44.23 kB"
"limit": "44.26 kB"
},
{
"name": "[API] REST API handlers",
Expand All @@ -353,13 +353,13 @@
"name": "[Auth] resetPassword (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ resetPassword }",
"limit": "12.68 kB"
"limit": "12.71 kB"
},
{
"name": "[Auth] confirmResetPassword (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmResetPassword }",
"limit": "12.63 kB"
"limit": "12.66 kB"
},
{
"name": "[Auth] signIn (Cognito)",
Expand All @@ -371,7 +371,7 @@
"name": "[Auth] resendSignUpCode (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ resendSignUpCode }",
"limit": "12.64 kB"
"limit": "12.68 kB"
},
{
"name": "[Auth] confirmSignUp (Cognito)",
Expand All @@ -383,31 +383,31 @@
"name": "[Auth] confirmSignIn (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmSignIn }",
"limit": "28.60 kB"
"limit": "28.61 kB"
},
{
"name": "[Auth] updateMFAPreference (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ updateMFAPreference }",
"limit": "12.11 kB"
"limit": "12.15 kB"
},
{
"name": "[Auth] fetchMFAPreference (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ fetchMFAPreference }",
"limit": "12.14 kB"
"limit": "12.18 kB"
},
{
"name": "[Auth] verifyTOTPSetup (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ verifyTOTPSetup }",
"limit": "12.99 kB"
"limit": "13.02 kB"
},
{
"name": "[Auth] updatePassword (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ updatePassword }",
"limit": "12.99 kB"
"limit": "13.03 kB"
},
{
"name": "[Auth] setUpTOTP (Cognito)",
Expand All @@ -419,7 +419,7 @@
"name": "[Auth] updateUserAttributes (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ updateUserAttributes }",
"limit": "12.21 kB"
"limit": "12.24 kB"
},
{
"name": "[Auth] getCurrentUser (Cognito)",
Expand All @@ -431,7 +431,7 @@
"name": "[Auth] confirmUserAttribute (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmUserAttribute }",
"limit": "12.98 kB"
"limit": "13.02 kB"
},
{
"name": "[Auth] signInWithRedirect (Cognito)",
Expand All @@ -443,13 +443,13 @@
"name": "[Auth] fetchUserAttributes (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ fetchUserAttributes }",
"limit": "12.03 kB"
"limit": "12.07 kB"
},
{
"name": "[Auth] Basic Auth Flow (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ signIn, signOut, fetchAuthSession, confirmSignIn }",
"limit": "30.87 kB"
"limit": "30.88 kB"
},
{
"name": "[Auth] OAuth Auth Flow (Cognito)",
Expand All @@ -461,19 +461,19 @@
"name": "[Auth] Associate WebAuthN Credential (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ associateWebAuthnCredential }",
"limit": "13.55 kB"
"limit": "13.59 kB"
},
{
"name": "[Auth] List WebAuthN Credentials (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ listWebAuthnCredentials }",
"limit": "12.14 kB"
"limit": "12.18 kB"
},
{
"name": "[Auth] Delete WebAuthN Credential (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ deleteWebAuthnCredential }",
"limit": "12.01 kB"
"limit": "12.04 kB"
},
{
"name": "[Storage] copy (S3)",
Expand Down Expand Up @@ -503,7 +503,7 @@
"name": "[Storage] list (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ list }",
"limit": "16.74 kB"
"limit": "16.77 kB"
},
{
"name": "[Storage] remove (S3)",
Expand All @@ -515,7 +515,7 @@
"name": "[Storage] uploadData (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ uploadData }",
"limit": "22.84 kB"
"limit": "22.87 kB"
}
]
}
21 changes: 21 additions & 0 deletions packages/core/__tests__/parseAmplifyOutputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ describe('parseAmplifyOutputs tests', () => {
},
},
},
{
name: 'bucket-2',
bucket_name: 'storage-bucket-test-2',
aws_region: 'us-west-2',
paths: {
'public/*': {
guest: ['get', 'list', 'write', 'delete'],
authenticated: ['get', 'list', 'write', 'delete'],
},
},
},
],
},
};
Expand All @@ -344,6 +355,16 @@ describe('parseAmplifyOutputs tests', () => {
},
},
},
'bucket-2': {
bucketName: 'storage-bucket-test-2',
region: 'us-west-2',
paths: {
'public/*': {
authenticated: ['get', 'list', 'write', 'delete'],
guest: ['get', 'list', 'write', 'delete'],
},
},
},
},
},
},
Expand Down
14 changes: 13 additions & 1 deletion packages/core/src/parseAmplifyOutputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,22 @@ function createBucketInfoMap(
);
}

const sanitizedPaths = paths
? Object.entries(paths).reduce<
Record<string, Record<string, string[] | undefined>>
>((acc, [key, value]) => {
if (value !== undefined) {
acc[key] = value;
}

return acc;
}, {})
: undefined;

mappedBuckets[name] = {
bucketName,
region,
paths,
paths: sanitizedPaths,
};
},
);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/singleton/AmplifyOutputs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface AmplifyOutputsStorageBucketProperties {
/** Region for the bucket */
aws_region: string;
/** Paths to object with access permissions */
paths?: Record<string, Record<string, string[] | undefined>>;
paths?: Partial<Record<string, Record<string, string[] | undefined>>>;
}
export interface AmplifyOutputsStorageProperties {
/** Default region for Storage */
Expand Down

0 comments on commit 0ecded1

Please sign in to comment.