Skip to content

Commit

Permalink
release: Amplify JS release (aws-amplify#13569)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinkumar6 authored Jul 8, 2024
2 parents 8cc3fd5 + 0a07393 commit 1d353e7
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 39 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,13 @@ module.exports = {
'setupTests.ts',
'jest.setup.*',
'jest.config.*',
// 'packages/adapter-nextjs/__tests__',
// 'packages/analytics/__tests__',
'packages/api/__tests__',
'packages/api-graphql/__tests__',
// 'packages/api-rest/__tests__',
// 'packages/auth/__tests__',
// 'packages/aws-amplify/__tests__',
// 'packages/core/__tests__',
'packages/datastore/__tests__',
'packages/datastore-storage-adapter/__tests__',
// 'packages/geo/__tests__',
'packages/interactions/__tests__',
// 'packages/notifications/__tests__',
'packages/predictions/__tests__',
'packages/pubsub/__tests__',
'packages/react-native/__tests__',
'packages/rtn-push-notification/__tests__',
'packages/rtn-web-browser/__tests__',
// 'packages/storage/__tests__',
],
rules: {
camelcase: [
Expand Down
11 changes: 9 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ the requirements below.

- [ ] PR description included
- [ ] `yarn test` passes
- [ ] Tests are [changed or added](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#steps-towards-contributions)
- [ ] Unit Tests are [changed or added](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#steps-towards-contributions)
- [ ] Relevant documentation is changed or added (and PR referenced)



#### Checklist for repo maintainers
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [ ] Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
- [ ] New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
9 changes: 8 additions & 1 deletion .github/integ-config/integ-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,14 @@ tests:
sample_name: [storage-gen2]
spec: storage-gen2
browser: *minimal_browser_list

- test_name: storage-guest-access
desc: 'Next Storage guest access'
framework: next
category: storage
sample_name: [guest-access]
spec: storage-client-server
browser: *minimal_browser_list

# INAPPMESSAGING
- test_name: integ_in_app_messaging
desc: 'React InApp Messaging'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/callable-npm-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: |
yarn run docs
git add ./docs/api/
git commit -m "chore(release): update API docs [skip release]"
git commit -m "chore(release): Update API docs [skip release]"
- name: Push post release changes to the release branch
working-directory: ./amplify-js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"publish:release": "yarn generate-metadata && lerna publish --conventional-commits --message 'chore(release): Publish [skip release]' --yes",
"publish:v5-stable": "lerna publish --conventional-commits --yes --dist-tag=stable-5 --message 'chore(release): Publish [ci skip]' --no-verify-access",
"publish:verdaccio": "lerna publish --canary --force-publish --no-push --dist-tag=unstable --preid=unstable --yes",
"generate-metadata": "git rev-parse --short HEAD > packages/core/metadata && git commit -am 'chore: set core metadata [skip release]'",
"generate-metadata": "git rev-parse --short HEAD > packages/core/metadata && git commit -am 'chore(release): Set core metadata [skip release]'",
"ts-coverage": "lerna run ts-coverage",
"prepare": "husky && ./scripts/set-preid-versions.sh"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"name": "[Storage] list (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ list }",
"limit": "14.94 kB"
"limit": "15.04 kB"
},
{
"name": "[Storage] remove (S3)",
Expand Down
28 changes: 28 additions & 0 deletions packages/datastore/__tests__/subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@ describe('sync engine subscription module', () => {
),
).toEqual(authInfo);
});
test('owner authorization with no token(expired)', () => {
const authRules = [
{
provider: 'userPools',
ownerField: 'owner',
allow: 'owner',
identityClaim: 'cognito:username',
operations: ['create', 'update', 'delete'],
},
];
const model = generateModelWithAuth(authRules);

const authInfo = {
authMode: 'userPool',
isOwner: false,
};

expect(
// @ts-ignore
SubscriptionProcessor.prototype.getAuthorizationInfo(
model,
USER_CREDENTIALS.auth,
'userPool',
undefined,
'userPool',
),
).toEqual(authInfo);
});
test('owner authorization with public subscription', () => {
const authRules = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/datastore/src/sync/processors/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class SubscriptionProcessor {
: [];

oidcOwnerAuthRules.forEach(ownerAuthRule => {
const ownerValue = oidcTokenPayload[ownerAuthRule.identityClaim];
const ownerValue = oidcTokenPayload?.[ownerAuthRule.identityClaim];
const singleOwner =
model.fields[ownerAuthRule.ownerField]?.isArray !== true;
const isOwnerArgRequired =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('getPermissionStatus', () => {
beforeAll(() => {
mockGetPermissionStatusNative.mockResolvedValue(status);
mockNormalizeNativePermissionStatus.mockImplementation(
status => `normalized-${status}`,
statusParam => `normalized-${statusParam}`,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { AppRegistry } from 'react-native';

import { getConstants } from '../../src/apis/getConstants';
import { registerHeadlessTask } from '../../src/apis/registerHeadlessTask';
import { normalizeNativeMessage } from '../../src/utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/rtn-push-notification/__tests__/testUtils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const fcmMessageOptions = {
export const fcmMessagePayload = {
title: 'fcm-title',
body: 'fcm-body',
imageUrl: imageUrl,
imageUrl,
action: {},
rawData: pushNotificationAdhocData,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
apnsMessage,
apnsMessagePayload,
fcmMessage,
fcmMessagePayload,
fcmMessageOptions,
fcmMessagePayload,
imageUrl,
pushNotificationAdhocData,
pushNotificationDeeplinkUrl,
Expand All @@ -23,7 +23,7 @@ describe('normalizeNativeMessage', () => {
expect(normalizeNativeMessage(apnsMessage)).toStrictEqual({
title,
body,
imageUrl: imageUrl,
imageUrl,
data: {
...pushNotificationAdhocData,
'media-url': imageUrl,
Expand Down Expand Up @@ -72,12 +72,17 @@ describe('normalizeNativeMessage', () => {

describe('fcm messages', () => {
it('normalizes typical messages', () => {
const { body, rawData, imageUrl, title } = fcmMessagePayload;
const {
body,
rawData,
imageUrl: imageUrlFromPayload,
title,
} = fcmMessagePayload;

expect(normalizeNativeMessage(fcmMessage)).toStrictEqual({
body,
data: rawData,
imageUrl,
imageUrl: imageUrlFromPayload,
title,
fcmOptions: {
...fcmMessageOptions,
Expand Down
163 changes: 163 additions & 0 deletions packages/storage/__tests__/providers/s3/apis/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,167 @@ describe('list API', () => {
}
});
});

describe('with delimiter', () => {
const mockedContents = [
{
Key: 'photos/',
...listObjectClientBaseResultItem,
},
{
Key: 'photos/2023.png',
...listObjectClientBaseResultItem,
},
{
Key: 'photos/2024.png',
...listObjectClientBaseResultItem,
},
];
const mockedCommonPrefixes = [
{ Prefix: 'photos/2023/' },
{ Prefix: 'photos/2024/' },
{ Prefix: 'photos/2025/' },
];

const expectedExcludedSubpaths = mockedCommonPrefixes.map(
({ Prefix }) => Prefix,
);

const mockedPath = 'photos/';

beforeEach(() => {
mockListObject.mockResolvedValueOnce({
Contents: mockedContents,
CommonPrefixes: mockedCommonPrefixes,
});
});
afterEach(() => {
jest.clearAllMocks();
mockListObject.mockClear();
});

it('should return excludedSubpaths when "exclude" strategy is passed in the request', async () => {
const { items, excludedSubpaths } = await list({
path: mockedPath,
options: {
subpathStrategy: { strategy: 'exclude' },
},
});
expect(items).toHaveLength(3);
expect(excludedSubpaths).toEqual(expectedExcludedSubpaths);
expect(listObjectsV2).toHaveBeenCalledTimes(1);
await expect(listObjectsV2).toBeLastCalledWithConfigAndInput(
listObjectClientConfig,
{
Bucket: bucket,
MaxKeys: 1000,
Prefix: mockedPath,
Delimiter: '/',
},
);
});

it('should return excludedSubpaths when "exclude" strategy and listAll are passed in the request', async () => {
const { items, excludedSubpaths } = await list({
path: mockedPath,
options: {
subpathStrategy: { strategy: 'exclude' },
listAll: true,
},
});
expect(items).toHaveLength(3);
expect(excludedSubpaths).toEqual(expectedExcludedSubpaths);
expect(listObjectsV2).toHaveBeenCalledTimes(1);
await expect(listObjectsV2).toBeLastCalledWithConfigAndInput(
listObjectClientConfig,
{
Bucket: bucket,
MaxKeys: 1000,
Prefix: mockedPath,
Delimiter: '/',
},
);
});

it('should return excludedSubpaths when "exclude" strategy and pageSize are passed in the request', async () => {
const { items, excludedSubpaths } = await list({
path: mockedPath,
options: {
subpathStrategy: { strategy: 'exclude' },
pageSize: 3,
},
});
expect(items).toHaveLength(3);
expect(excludedSubpaths).toEqual(expectedExcludedSubpaths);
expect(listObjectsV2).toHaveBeenCalledTimes(1);
await expect(listObjectsV2).toBeLastCalledWithConfigAndInput(
listObjectClientConfig,
{
Bucket: bucket,
MaxKeys: 3,
Prefix: mockedPath,
Delimiter: '/',
},
);
});

it('should listObjectsV2 contain a custom Delimiter when "exclude" with delimiter is passed', async () => {
await list({
path: mockedPath,
options: {
subpathStrategy: {
strategy: 'exclude',
delimiter: '-',
},
},
});
expect(listObjectsV2).toHaveBeenCalledTimes(1);
await expect(listObjectsV2).toBeLastCalledWithConfigAndInput(
listObjectClientConfig,
{
Bucket: bucket,
MaxKeys: 1000,
Prefix: mockedPath,
Delimiter: '-',
},
);
});

it('should listObjectsV2 contain an undefined Delimiter when "include" strategy is passed', async () => {
await list({
path: mockedPath,
options: {
subpathStrategy: {
strategy: 'include',
},
},
});
expect(listObjectsV2).toHaveBeenCalledTimes(1);
await expect(listObjectsV2).toBeLastCalledWithConfigAndInput(
listObjectClientConfig,
{
Bucket: bucket,
MaxKeys: 1000,
Prefix: mockedPath,
Delimiter: undefined,
},
);
});

it('should listObjectsV2 contain an undefined Delimiter when no options are passed', async () => {
await list({
path: mockedPath,
});
expect(listObjectsV2).toHaveBeenCalledTimes(1);
await expect(listObjectsV2).toBeLastCalledWithConfigAndInput(
listObjectClientConfig,
{
Bucket: bucket,
MaxKeys: 1000,
Prefix: mockedPath,
Delimiter: undefined,
},
);
});
});
});
Loading

0 comments on commit 1d353e7

Please sign in to comment.