Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore]Update aws-sdk dependencies to latest possible #13665

Merged
merged 20 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/push-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
on:
push:
branches:
- replace-with-your-branch
- chore/update-aws-sdk

jobs:
e2e:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unused-imports": "^3.0.0",
"expect": "^29.7.0",
"glob": "^10.3.10",
"glob": "10.3.10",
ashika112 marked this conversation as resolved.
Show resolved Hide resolved
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
Expand Down Expand Up @@ -137,6 +137,6 @@
"nx": "16.7.0",
"xml2js": "0.5.0",
"tar": "6.2.1",
"fast-xml-parser": "4.4.1"
"glob@^10.0.0": "10.3.10"
}
}
6 changes: 3 additions & 3 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@
"personalize"
],
"dependencies": {
"@aws-sdk/client-firehose": "3.398.0",
"@aws-sdk/client-kinesis": "3.398.0",
"@aws-sdk/client-personalize-events": "3.398.0",
"@aws-sdk/client-firehose": "3.621.0",
"@aws-sdk/client-kinesis": "3.621.0",
"@aws-sdk/client-personalize-events": "3.621.0",
"@smithy/util-utf8": "2.0.0",
"tslib": "^2.5.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,91 +142,3 @@ exports[`server generateClient with cookies can list with nextToken 1`] = `
],
]
`;

exports[`server generateClient with cookies can list with sort direction (ascending) 1`] = `
[
[
"AmplifyClassV6",
{
"abortController": AbortController {},
"options": {
"body": {
"query": "query ($filter: ModelTodoFilterInput, $limit: Int, $nextToken: String) {
listTodos(filter: $filter, limit: $limit, nextToken: $nextToken) {
items {
id
name
description
status
tags
createdAt
updatedAt
todoMetaId
owner
}
nextToken
__typename
}
}
",
"variables": {
"id": "some-id",
"sortDirection": "ASC",
},
},
"headers": {
"X-Api-Key": "FAKE-KEY",
"x-amz-user-agent": "aws-amplify/latest api/latest framework/latest",
},
"signingServiceInfo": undefined,
"withCredentials": undefined,
},
"url": "https://localhost/graphql",
},
],
]
`;

exports[`server generateClient with cookies can list with sort direction (descending) 1`] = `
[
[
"AmplifyClassV6",
{
"abortController": AbortController {},
"options": {
"body": {
"query": "query ($filter: ModelTodoFilterInput, $limit: Int, $nextToken: String) {
listTodos(filter: $filter, limit: $limit, nextToken: $nextToken) {
items {
id
name
description
status
tags
createdAt
updatedAt
todoMetaId
owner
}
nextToken
__typename
}
}
",
"variables": {
"id": "some-id",
"sortDirection": "DESC",
},
},
"headers": {
"X-Api-Key": "FAKE-KEY",
"x-amz-user-agent": "aws-amplify/latest api/latest framework/latest",
},
"signingServiceInfo": undefined,
"withCredentials": undefined,
},
"url": "https://localhost/graphql",
},
],
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -195,79 +195,6 @@ describe('server generateClient', () => {
);
});

test('can list with sort direction (ascending)', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Confirm that this test is not relevant without using compound keys for sorting, which should be tested by data-schema directly instead of indirectly through this abstraction.

Amplify.configure(configFixture as any);
const config = Amplify.getConfig();

const spy = mockApiResponse({
data: {
listTodos: {
items: [
{
__typename: 'Todo',
...serverManagedFields,
name: 'some name',
description: 'something something',
},
],
},
},
});

const getAmplify = async (fn: any) => await fn(Amplify);

const client = generateClientWithAmplifyInstance<
Schema,
V6ClientSSRCookies<Schema>
>({
amplify: getAmplify,
config: config,
});

const { data } = await client.models.Todo.list({
id: 'some-id',
sortDirection: 'ASC',
});

expect(normalizePostGraphqlCalls(spy)).toMatchSnapshot();
});
test('can list with sort direction (descending)', async () => {
Amplify.configure(configFixture as any);
const config = Amplify.getConfig();

const spy = mockApiResponse({
data: {
listTodos: {
items: [
{
__typename: 'Todo',
...serverManagedFields,
name: 'some name',
description: 'something something',
},
],
},
},
});

const getAmplify = async (fn: any) => await fn(Amplify);

const client = generateClientWithAmplifyInstance<
Schema,
V6ClientSSRCookies<Schema>
>({
amplify: getAmplify,
config: config,
});

const { data } = await client.models.Todo.list({
id: 'some-id',
sortDirection: 'DESC',
});

expect(normalizePostGraphqlCalls(spy)).toMatchSnapshot();
});

describe('with request', () => {
test('subscriptions are disabled', () => {
const client = generateClientWithAmplifyInstance<
Expand Down Expand Up @@ -296,7 +223,9 @@ describe('server generateClient', () => {
config: config,
});

const mockContextSpec = {};
const mockContextSpec = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Type changed from any to specific type, which breaks this test, but the type would be required for a customers app to work.

token: { value: Symbol('AmplifyServerContextToken') },
};

const spy = jest
.spyOn(client, 'graphql')
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
"name": "[API] generateClient (AppSync)",
"path": "./dist/esm/api/index.mjs",
"import": "{ generateClient }",
"limit": "40.09 kB"
"limit": "41 kB"
},
{
"name": "[API] REST API handlers",
Expand Down Expand Up @@ -479,7 +479,7 @@
"name": "[Storage] getUrl (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ getUrl }",
"limit": "15.51 kB"
"limit": "15.54 kB"
},
{
"name": "[Storage] list (S3)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/clients/middleware/retry/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const retryMiddlewareFactory = <TInput = Request, TOutput = Response>({
// context.attemptsCount may be updated after calling next handler which may retry the request by itself.
attemptsCount =
(context.attemptsCount ?? 0) > attemptsCount
? context.attemptsCount ?? 0
? (context.attemptsCount ?? 0)
: attemptsCount + 1;
context.attemptsCount = attemptsCount;
if (await retryDecider(response, error)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const updateEndpoint = async ({
// only automatically populate the endpoint with client info and identity id upon endpoint creation to
// avoid overwriting the endpoint with these values every time the endpoint is updated
const demographicsFromClientInfo: UserProfile['demographic'] = {};
const resolvedUserId = createdEndpointId ? userId ?? identityId : userId;
const resolvedUserId = createdEndpointId ? (userId ?? identityId) : userId;
if (createdEndpointId) {
const clientInfo = getClientInfo();
demographicsFromClientInfo.appVersion = clientInfo.appVersion;
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"src"
],
"dependencies": {
"@aws-sdk/client-location": "3.398.0",
"@aws-sdk/client-location": "3.621.0",
"@turf/boolean-clockwise": "6.5.0",
"camelcase-keys": "6.2.2",
"tslib": "^2.5.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
"lex-v2"
],
"dependencies": {
"@aws-sdk/client-lex-runtime-service": "3.398.0",
"@aws-sdk/client-lex-runtime-v2": "3.398.0",
"@aws-sdk/client-lex-runtime-service": "3.621.0",
"@aws-sdk/client-lex-runtime-v2": "3.621.0",
"base-64": "1.0.0",
"fflate": "0.7.3",
"pako": "2.0.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/predictions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
],
"dependencies": {
"@aws-amplify/storage": "6.5.3",
"@aws-sdk/client-comprehend": "3.398.0",
"@aws-sdk/client-polly": "3.398.0",
"@aws-sdk/client-rekognition": "3.398.0",
"@aws-sdk/client-textract": "3.398.0",
"@aws-sdk/client-translate": "3.398.0",
"@aws-sdk/client-comprehend": "3.621.0",
"@aws-sdk/client-polly": "3.621.0",
"@aws-sdk/client-rekognition": "3.621.0",
"@aws-sdk/client-textract": "3.621.0",
"@aws-sdk/client-translate": "3.621.0",
"@smithy/eventstream-codec": "2.0.9",
"@smithy/util-utf8": "2.0.0",
"buffer": "4.9.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
AWSCredentials,
Category,
PredictionsAction,
Signer,

Check warning on line 10 in packages/predictions/src/providers/AmazonAIConvertPredictionsProvider.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/predictions

Deprecated
getAmplifyUserAgentObject,
} from '@aws-amplify/core/internals/utils';
import { PollyClient, SynthesizeSpeechCommand } from '@aws-sdk/client-polly';
import {
PollyClient,
SynthesizeSpeechCommand,
SynthesizeSpeechInput,
} from '@aws-sdk/client-polly';
import {
TranslateClient,
TranslateTextCommand,
Expand Down Expand Up @@ -164,7 +168,7 @@
const synthesizeSpeechCommand = new SynthesizeSpeechCommand({
OutputFormat: 'mp3',
Text: input.textToSpeech?.source?.text,
VoiceId: voiceId,
VoiceId: voiceId as SynthesizeSpeechInput['VoiceId'],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these casting is required since SDK updated the types to be stricter than before and this avoids breaking change and anything outside of this will throw an error from API itself

TextType: 'text',
SampleRate: '24000',
});
Expand Down Expand Up @@ -473,7 +477,7 @@
`language-code=${languageCode}`,
].join('');

const signedUrl = Signer.signUrl(

Check warning on line 480 in packages/predictions/src/providers/AmazonAIConvertPredictionsProvider.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/predictions

Deprecated
url,
credentials,
{ region, service: 'transcribe' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { getUrl } from '@aws-amplify/storage';
import {
DetectFacesCommand,
DetectFacesCommandInput,
DetectLabelsCommand,
DetectLabelsCommandInput,
DetectModerationLabelsCommand,
Expand Down Expand Up @@ -238,7 +239,8 @@ export class AmazonAIIdentifyPredictionsProvider {
} else {
const param: AnalyzeDocumentCommandInput = {
Document: inputDocument,
FeatureTypes: featureTypes,
FeatureTypes:
featureTypes as AnalyzeDocumentCommandInput['FeatureTypes'],
};

const analyzeDocumentCommand = new AnalyzeDocumentCommand(param);
Expand Down Expand Up @@ -448,7 +450,9 @@ export class AmazonAIIdentifyPredictionsProvider {

return { entities: faces };
} else {
const detectFacesCommand = new DetectFacesCommand(param);
const detectFacesCommand = new DetectFacesCommand(
param as DetectFacesCommandInput,
);
const data = await this.rekognitionClient.send(detectFacesCommand);
const faces =
data.FaceDetails?.map(detail => {
Expand Down
Loading
Loading