Skip to content

Commit

Permalink
Merge branch 'main' into yuhengsh-contentDisposition
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhengshs committed Aug 6, 2024
2 parents 5d7329f + f24805a commit 40c898f
Show file tree
Hide file tree
Showing 20 changed files with 3,699 additions and 3,439 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
2 changes: 1 addition & 1 deletion 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
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/datastore/__tests__/mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,5 @@ const timeoutError = {
region: 'us-west-2',
},
},
code: 'ECONNABORTED',
code: 'ERR_NETWORK',
};
2 changes: 1 addition & 1 deletion packages/datastore/src/sync/processors/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class MutationProcessor {

if (
error.message === 'Network Error' ||
code === 'ECONNABORTED' // refers to axios timeout error caused by device's bad network condition
code === 'ERR_NETWORK' // refers to axios timeout error caused by device's bad network condition
) {
if (!this.processing) {
throw new NonRetryableError('Offline');
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 / 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
Loading

0 comments on commit 40c898f

Please sign in to comment.