Skip to content

Commit 080efeb

Browse files
committed
chore: address PR feedbacks
1 parent 930cdc6 commit 080efeb

File tree

9 files changed

+34
-24
lines changed

9 files changed

+34
-24
lines changed

clients/client-transcribe-streaming/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/test/
44
tsconfig.test.json
55
*.tsbuildinfo
6+
jest.config.js

clients/client-transcribe-streaming/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
"clean": "npm run remove-definitions && npm run remove-dist && npm run remove-js && npm run remove-maps",
77
"build-documentation": "npm run clean && typedoc ./",
88
"prepublishOnly": "yarn build",
9-
"pretest": "tsc",
9+
"pretest": "yarn build",
1010
"remove-definitions": "rimraf ./types",
1111
"remove-dist": "rimraf ./dist",
1212
"remove-documentation": "rimraf ./docs",
1313
"remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js",
1414
"remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map",
15-
"test": "yarn build && jest --coverage --passWithNoTests",
15+
"test": "jest --coverage --passWithNoTests",
16+
"test:integration": "jest --config jest.integ.config.js",
17+
"build:cjs": "tsc",
1618
"build:es": "tsc -p tsconfig.es.json",
17-
"build": "yarn pretest && yarn build:es"
19+
"build": "yarn build:cjs && yarn build:es",
20+
"postbuild": "cp test/speech.wav dist/cjs/test"
1821
},
1922
"main": "./dist/cjs/index.js",
2023
"types": "./types/index.d.ts",

clients/client-transcribe-streaming/test/index.integ.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { TranscribeStreaming } from "../index";
22
import { createReadStream } from "fs";
33
import { join } from "path";
4-
const moduleRoot = join(__dirname, "..", "..", "..");
5-
const audio = createReadStream(join(moduleRoot, "test", "speech.wav"));
4+
const audio = createReadStream(join(__dirname, "speech.wav"));
65

76
describe("TranscribeStream client", () => {
87
const client = new TranscribeStreaming({});
@@ -11,19 +10,22 @@ describe("TranscribeStream client", () => {
1110
});
1211

1312
it("should stream the transcript", async () => {
13+
const LanguageCode = "en-US";
14+
const MediaEncoding = "pcm";
15+
const MediaSampleRateHertz = 44100;
1416
const result = await client.startStreamTranscription({
15-
LanguageCode: "en-US",
16-
MediaEncoding: "pcm",
17-
MediaSampleRateHertz: 44100,
17+
LanguageCode,
18+
MediaEncoding,
19+
MediaSampleRateHertz,
1820
AudioStream: (async function* () {
1921
for await (const chunk of audio) {
2022
yield { AudioEvent: { AudioChunk: chunk } };
2123
}
2224
})()
2325
});
24-
expect(result.LanguageCode).toBe("en-US");
25-
expect(result.MediaEncoding).toBe("pcm");
26-
expect(result.MediaSampleRateHertz).toBe(44100);
26+
expect(result.LanguageCode).toBe(LanguageCode);
27+
expect(result.MediaEncoding).toBe(MediaEncoding);
28+
expect(result.MediaSampleRateHertz).toBe(MediaSampleRateHertz);
2729
expect(result.TranscriptResultStream).toBeDefined();
2830
const transcripts = [];
2931
for await (const event of result.TranscriptResultStream!) {

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected void serializeInputPayload(
207207
writer.write("contents = $L;",
208208
getInputValue(context, Location.PAYLOAD, "input." + memberName, member, target));
209209

210-
// Structure and Union payloads that's not events stream will serialize as XML documents via XmlNode.
210+
// XmlNode will serialize non-eventstream Structure and Union payloads as XML documents.
211211
if ((target instanceof StructureShape || target instanceof UnionShape)
212212
&& !member.hasTrait(EventStreamTrait.class)) {
213213
// Start with the XML declaration.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"pretest:all": "yarn build:all",
1818
"test:all": "jest --coverage --passWithNoTests && lerna run test --scope @aws-sdk/fetch-http-handler --scope @aws-sdk/hash-blob-browser",
1919
"test:functional": "jest --config tests/functional/jest.config.js --passWithNoTests",
20-
"test:integration": "cucumber-js --fail-fast && jest --config jest.config.integ.js --passWithNoTests",
20+
"test:integration-legacy": "cucumber-js --fail-fast",
21+
"test:integration": "jest --config jest.config.integ.js --passWithNoTests",
2122
"test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-*'"
2223
},
2324
"repository": {

packages/eventstream-handler-node/src/EventStreamPayloadHandler.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ describe("EventStreamPayloadHandler", () => {
2020
const mockUtf8Decoder: Decoder = jest.fn();
2121
const mockUtf8encoder: Encoder = jest.fn();
2222
const mockNextHandler: FinalizeHandler<any, any> = jest.fn();
23+
2324
beforeEach(() => {
2425
jest.clearAllMocks();
2526
});
27+
2628
it("should throw if request payload is not a stream", () => {
2729
const handler = new EventStreamPayloadHandler({
2830
eventSigner: () => Promise.resolve(mockSigner),
@@ -36,6 +38,7 @@ describe("EventStreamPayloadHandler", () => {
3638
})
3739
).rejects.toThrow("Eventstream payload must be a Readable stream.");
3840
});
41+
3942
it("should close the request payload if downstream middleware throws", async () => {
4043
(mockNextHandler as any).mockImplementationOnce(() =>
4144
Promise.reject(new Error())
@@ -62,6 +65,7 @@ describe("EventStreamPayloadHandler", () => {
6265
mockRequest.body.write("");
6366
}).toThrowError("write after end");
6467
});
68+
6569
it("should call event signer with request signature from signing middleware", async () => {
6670
const authorization =
6771
"AWS4-HMAC-SHA256 Credential=AKID/20200510/us-west-2/foo/aws4_request, SignedHeaders=host, Signature=1234567890";
@@ -83,6 +87,7 @@ describe("EventStreamPayloadHandler", () => {
8387
"1234567890"
8488
);
8589
});
90+
8691
it("should start piping to request payload through event signer if downstream middleware returns", async () => {
8792
const authorization =
8893
"AWS4-HMAC-SHA256 Credential=AKID/20200510/us-west-2/foo/aws4_request, SignedHeaders=host, Signature=1234567890";

packages/eventstream-serde-universal/src/getChunkedStream.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function getChunkedStream(
55
let currentMessagePendingLength = 0;
66
let currentMessage: Uint8Array | null = null;
77
let messageLengthBuffer: Uint8Array | null = null;
8-
const allocateMessage = function (size: number) {
8+
const allocateMessage = (size: number) => {
99
if (typeof size !== "number") {
1010
throw new Error(
1111
"Attempted to allocate an event message where size was not a number: " +
@@ -21,17 +21,15 @@ export function getChunkedStream(
2121

2222
const iterator = async function* () {
2323
const sourceIterator = source[Symbol.asyncIterator]();
24-
let complete = false;
25-
while (!complete) {
24+
while (true) {
2625
const { value, done } = await sourceIterator.next();
27-
complete = done || false;
2826
if (done) {
29-
if (currentMessageTotalLength) {
30-
if (currentMessageTotalLength === currentMessagePendingLength) {
31-
yield currentMessage as Uint8Array;
32-
} else {
33-
throw new Error("Truncated event message received.");
34-
}
27+
if (!currentMessageTotalLength) {
28+
return;
29+
} else if (currentMessageTotalLength === currentMessagePendingLength) {
30+
yield currentMessage as Uint8Array;
31+
} else {
32+
throw new Error("Truncated event message received.");
3533
}
3634
return;
3735
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from "./configuration";
22
export * from "./handling-middleware";
33
export * from "./headers-middleware";
4-
export * from "./pluggin";
4+
export * from "./plugin";

0 commit comments

Comments
 (0)