Skip to content

Commit

Permalink
[Chore]Update aws-sdk dependencies to latest possible (#13665)
Browse files Browse the repository at this point in the history
* update aws-sdk version

* update yarn.lock

* test fix + pin data-schema

* pin glob version

* enable integ test on the branch

* set resolution on glob

* update bundle size

* fix: Remove meaningless tests instead of fixing them

* fix: Update snapshot to reflect removed tests

* fix: Increase api-graphql bundle size to cover data-schema size changes

* revert e2e enable

---------

Co-authored-by:  ashika112 <[email protected]>
Co-authored-by: Aaron S <[email protected]>
Co-authored-by: Aaron S. <[email protected]>
  • Loading branch information
3 people authored Aug 2, 2024
1 parent e28d538 commit f24805a
Show file tree
Hide file tree
Showing 16 changed files with 3,695 additions and 3,435 deletions.
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",
"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 () => {
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 = {
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 @@ -10,7 +10,11 @@ import {
Signer,

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

View workflow job for this annotation

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

Deprecated

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 @@ export class AmazonAIConvertPredictionsProvider {
const synthesizeSpeechCommand = new SynthesizeSpeechCommand({
OutputFormat: 'mp3',
Text: input.textToSpeech?.source?.text,
VoiceId: voiceId,
VoiceId: voiceId as SynthesizeSpeechInput['VoiceId'],
TextType: 'text',
SampleRate: '24000',
});
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import {
ComprehendClient,
DetectDominantLanguageCommand,
DetectEntitiesCommand,
DetectEntitiesCommandInput,
DetectKeyPhrasesCommand,
DetectKeyPhrasesCommandInput,
DetectSentimentCommand,
DetectSentimentCommandInput,
DetectSyntaxCommand,
DetectSyntaxCommandInput,
Entity,
SyntaxToken,
} from '@aws-sdk/client-comprehend';
Expand Down Expand Up @@ -159,7 +163,9 @@ export class AmazonAIInterpretPredictionsProvider {

private async detectKeyPhrases(params: DetectParams): Promise<KeyPhrases> {
try {
const detectKeyPhrasesCommand = new DetectKeyPhrasesCommand(params);
const detectKeyPhrasesCommand = new DetectKeyPhrasesCommand(
params as DetectKeyPhrasesCommandInput,
);
const data = await this.comprehendClient!.send(detectKeyPhrasesCommand);
const { KeyPhrases: keyPhrases = [] } = data || {};

Expand All @@ -180,7 +186,9 @@ export class AmazonAIInterpretPredictionsProvider {

private async detectSyntax(params: DetectParams): Promise<TextSyntax[]> {
try {
const detectSyntaxCommand = new DetectSyntaxCommand(params);
const detectSyntaxCommand = new DetectSyntaxCommand(
params as DetectSyntaxCommandInput,
);
const data = await this.comprehendClient!.send(detectSyntaxCommand);
const { SyntaxTokens = [] } = data || {};

Expand Down Expand Up @@ -212,7 +220,9 @@ export class AmazonAIInterpretPredictionsProvider {

private async detectSentiment(params: DetectParams): Promise<TextSentiment> {
try {
const detectSentimentCommand = new DetectSentimentCommand(params);
const detectSentimentCommand = new DetectSentimentCommand(
params as DetectSentimentCommandInput,
);
const data = await this.comprehendClient!.send(detectSentimentCommand);
const {
Sentiment: predominant = '',
Expand All @@ -239,7 +249,9 @@ export class AmazonAIInterpretPredictionsProvider {

private async detectEntities(params: DetectParams): Promise<TextEntities[]> {
try {
const detectEntitiesCommand = new DetectEntitiesCommand(params);
const detectEntitiesCommand = new DetectEntitiesCommand(
params as DetectEntitiesCommandInput,
);
const data = await this.comprehendClient!.send(detectEntitiesCommand);
const { Entities = [] } = data || {};

Expand Down
Loading

0 comments on commit f24805a

Please sign in to comment.