diff --git a/package.json b/package.json index ba45fcf5f2ee6..dacafd18538b2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "build:smithy-client": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/client-rds-data' --include-dependencies pretest", "build:all": "yarn build:crypto-dependencies && lerna run pretest --include-dependencies --include-dependents", "pretest:all": "yarn build:all", - "test:all": "jest --coverage --passWithNoTests && lerna run test --scope @aws-sdk/stream-collector-browser --scope @aws-sdk/hash-blob-browser", + "test:all": "jest --coverage --passWithNoTests && lerna run test --scope @aws-sdk/stream-collector-web --scope @aws-sdk/hash-blob-browser", "test:functional": "jest --config tests/functional/jest.config.js --passWithNoTests", "test:integration": "cucumber-js --fail-fast", "test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-*'" diff --git a/packages/fetch-http-handler/src/fetch-http-handler.spec.ts b/packages/fetch-http-handler/src/fetch-http-handler.spec.ts index 35bd672b6e4f1..2b88afac242f0 100644 --- a/packages/fetch-http-handler/src/fetch-http-handler.spec.ts +++ b/packages/fetch-http-handler/src/fetch-http-handler.spec.ts @@ -40,7 +40,7 @@ describe("httpHandler", () => { ["bizz", "bazz"] ]) }, - body: "FOO" //should be a ReadableStream in real life. + blob: jest.fn().mockResolvedValue(new Blob(["FOO"])), }; const mockFetch = jest.fn().mockResolvedValue(mockResponse); @@ -50,7 +50,8 @@ describe("httpHandler", () => { let response = await fetchHttpHandler.handle({} as any, {}); expect(mockFetch.mock.calls.length).toBe(1); - expect(response.response.body).toBe("FOO"); + console.log(response.response.body, typeof response.response.body); + expect(await blobToText(response.response.body)).toBe("FOO"); }); it("properly constructs url", async () => { @@ -61,7 +62,7 @@ describe("httpHandler", () => { ["bizz", "bazz"] ]) }, - body: "" + blob: jest.fn().mockResolvedValue(new Blob()), }; const mockFetch = jest.fn().mockResolvedValue(mockResponse); @@ -92,8 +93,7 @@ describe("httpHandler", () => { ["bizz", "bazz"] ]) }, - blob: jest.fn().mockResolvedValue(""), - body: "test" + blob: jest.fn().mockResolvedValue(new Blob()), }; const mockFetch = jest.fn().mockResolvedValue(mockResponse); @@ -119,8 +119,7 @@ describe("httpHandler", () => { ["bizz", "bazz"] ]) }, - blob: jest.fn().mockResolvedValue(""), - body: "test" + blob: jest.fn().mockResolvedValue(new Blob()), }; const mockFetch = jest.fn().mockResolvedValue(mockResponse); (global as any).fetch = mockFetch; @@ -145,8 +144,7 @@ describe("httpHandler", () => { ["bizz", "bazz"] ]) }, - blob: jest.fn().mockResolvedValue(""), - body: "test" + blob: jest.fn().mockResolvedValue(new Blob()), }; const mockFetch = jest.fn().mockResolvedValue(mockResponse); (global as any).fetch = mockFetch; @@ -207,4 +205,20 @@ describe("httpHandler", () => { expect(httpHandler.destroy()).toBeUndefined(); }); }); + + // The Blob implementation does not implement Blob.text, so we deal with it here. + async function blobToText(blob: Blob): Promise { + const reader = new FileReader(); + + return new Promise((resolve) => { + // This fires after the blob has been read/loaded. + reader.addEventListener('loadend', (e) => { + const text = e.target!.result as string; + resolve(text); + }); + + // Start reading the blob as text. + reader.readAsText(blob); + }); + } }); diff --git a/packages/fetch-http-handler/src/fetch-http-handler.ts b/packages/fetch-http-handler/src/fetch-http-handler.ts index d918a3cacadbc..3d9aa867d64d9 100644 --- a/packages/fetch-http-handler/src/fetch-http-handler.ts +++ b/packages/fetch-http-handler/src/fetch-http-handler.ts @@ -14,14 +14,6 @@ export interface BrowserHttpOptions { * terminated. */ requestTimeout?: number; - /** - * Buffer the whole response body before returning. This option is useful in the - * runtime that doesn't support ReadableStream in response like ReactNative. When - * set to true, the response body of http handler will be a Blob instead of - * ReadableStream. - * This option is only useful in ReactNative. - */ - bufferBody?: boolean; } export class FetchHttpHandler implements HttpHandler { @@ -80,8 +72,10 @@ export class FetchHttpHandler implements HttpHandler { transformedHeaders[pair[0]] = pair[1]; } + const hasReadableStream = response.body !== undefined; + // Return the response with buffered body - if (this.httpOptions.bufferBody) { + if (!hasReadableStream) { return response.blob().then(body => ({ response: new HttpResponse({ headers: transformedHeaders, diff --git a/packages/stream-collector-browser/CHANGELOG.md b/packages/stream-collector-browser/CHANGELOG.md deleted file mode 100644 index 574d1f07c1e32..0000000000000 --- a/packages/stream-collector-browser/CHANGELOG.md +++ /dev/null @@ -1,720 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [1.0.0-beta.4](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-beta.4) (2020-04-27) - - -### Features - -* use exact @aws-sdk/* dependencies ([#1110](https://github.com/aws/aws-sdk-js-v3/issues/1110)) ([bcfd7a2](https://github.com/aws/aws-sdk-js-v3/commit/bcfd7a2faeca3a2605057fd4736d710aa4902b62)) - - - -# 1.0.0-beta.2 (2020-03-28) - - - -# 1.0.0-beta.1 (2020-03-25) - - -### Features - -* bump packages to beta ([#1050](https://github.com/aws/aws-sdk-js-v3/issues/1050)) ([40501d4](https://github.com/aws/aws-sdk-js-v3/commit/40501d4394d04bc1bc91c10136fa48b1d3a67d8f)) - - - -# 1.0.0-alpha.28 (2020-03-20) - - - -# 1.0.0-alpha.25 (2020-03-09) - - - -# 1.0.0-alpha.24 (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c53382999dcbf59e97e64252f5b404acb8)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed45fd5580ef9633da78f13aaa6aa472805)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10cb6b0ebc32004b797556bfc171c96bbf16)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab4ac5343058eaf7d448a428d8c4b72c844)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-beta.3](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-beta.3) (2020-04-25) - - - -# 1.0.0-beta.2 (2020-03-28) - - - -# 1.0.0-beta.1 (2020-03-25) - - -### Features - -* bump packages to beta ([#1050](https://github.com/aws/aws-sdk-js-v3/issues/1050)) ([40501d4](https://github.com/aws/aws-sdk-js-v3/commit/40501d4394d04bc1bc91c10136fa48b1d3a67d8f)) - - - -# 1.0.0-alpha.28 (2020-03-20) - - - -# 1.0.0-alpha.25 (2020-03-09) - - - -# 1.0.0-alpha.24 (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c53382999dcbf59e97e64252f5b404acb8)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed45fd5580ef9633da78f13aaa6aa472805)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10cb6b0ebc32004b797556bfc171c96bbf16)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab4ac5343058eaf7d448a428d8c4b72c844)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-beta.2](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-beta.2) (2020-03-28) - - - -# 1.0.0-beta.1 (2020-03-25) - - -### Features - -* bump packages to beta ([#1050](https://github.com/aws/aws-sdk-js-v3/issues/1050)) ([40501d4](https://github.com/aws/aws-sdk-js-v3/commit/40501d4394d04bc1bc91c10136fa48b1d3a67d8f)) - - - -# 1.0.0-alpha.28 (2020-03-20) - - - -# 1.0.0-alpha.25 (2020-03-09) - - - -# 1.0.0-alpha.24 (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c53382999dcbf59e97e64252f5b404acb8)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed45fd5580ef9633da78f13aaa6aa472805)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10cb6b0ebc32004b797556bfc171c96bbf16)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab4ac5343058eaf7d448a428d8c4b72c844)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-beta.1](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-beta.1) (2020-03-25) - - -### Features - -* bump packages to beta ([#1050](https://github.com/aws/aws-sdk-js-v3/issues/1050)) ([40501d4](https://github.com/aws/aws-sdk-js-v3/commit/40501d4394d04bc1bc91c10136fa48b1d3a67d8f)) - - - -# 1.0.0-alpha.28 (2020-03-20) - - - -# 1.0.0-alpha.25 (2020-03-09) - - - -# 1.0.0-alpha.24 (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c53382999dcbf59e97e64252f5b404acb8)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed45fd5580ef9633da78f13aaa6aa472805)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10cb6b0ebc32004b797556bfc171c96bbf16)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab4ac5343058eaf7d448a428d8c4b72c844)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.7](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.7) (2020-03-20) - - - -# 1.0.0-alpha.25 (2020-03-09) - - - -# 1.0.0-alpha.24 (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c53382999dcbf59e97e64252f5b404acb8)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed45fd5580ef9633da78f13aaa6aa472805)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10cb6b0ebc32004b797556bfc171c96bbf16)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab4ac5343058eaf7d448a428d8c4b72c844)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.6](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.6) (2020-03-09) - - - -# 1.0.0-alpha.24 (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c53382999dcbf59e97e64252f5b404acb8)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed45fd5580ef9633da78f13aaa6aa472805)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10cb6b0ebc32004b797556bfc171c96bbf16)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab4ac5343058eaf7d448a428d8c4b72c844)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.5](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.5) (2020-02-19) - - - -# 1.0.0-alpha.13 (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.4](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.4) (2020-01-24) - - - -# 1.0.0-alpha.12 (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.3](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.3) (2020-01-22) - - -### Features - -* add support for browser streaming ([#721](https://github.com/aws/aws-sdk-js-v3/issues/721)) ([133430c](https://github.com/aws/aws-sdk-js-v3/commit/133430c)) - - - -# 0.9.0 (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.2](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.2) (2020-01-09) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [1.0.0-alpha.1](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@1.0.0-alpha.1) (2020-01-08) - - - -# 0.6.0 (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [0.1.0-preview.7](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@0.1.0-preview.7) (2019-10-30) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [0.1.0-preview.6](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@0.1.0-preview.6) (2019-10-29) - - - -# 0.3.0 (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [0.1.0-preview.5](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@0.1.0-preview.5) (2019-09-09) - - -### Features - -* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed)) - - - -# 0.2.0 (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [0.1.0-preview.4](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@0.1.0-preview.4) (2019-07-12) - - -### Features - -* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c)) -* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab)) - - - -# 0.1.0 (2019-04-19) - - - - - -# [0.1.0-preview.3](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.2...@aws-sdk/stream-collector-browser@0.1.0-preview.3) (2019-04-19) - -**Note:** Version bump only for package @aws-sdk/stream-collector-browser - -# [0.1.0-preview.2](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/stream-collector-browser@0.1.0-preview.1...@aws-sdk/stream-collector-browser@0.1.0-preview.2) (2019-03-27) - -**Note:** Version bump only for package @aws-sdk/stream-collector-browser diff --git a/packages/stream-collector-browser/README.md b/packages/stream-collector-browser/README.md deleted file mode 100644 index b677ad763697b..0000000000000 --- a/packages/stream-collector-browser/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# @aws-sdk/stream-collector-browser - -[![NPM version](https://img.shields.io/npm/v/@aws-sdk/stream-collector-browser/beta.svg)](https://www.npmjs.com/package/@aws-sdk/stream-collector-browser) -[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/stream-collector-browser.svg)](https://www.npmjs.com/package/@aws-sdk/stream-collector-browser) diff --git a/packages/stream-collector-browser/package.json b/packages/stream-collector-browser/package.json deleted file mode 100644 index 35954c9d25104..0000000000000 --- a/packages/stream-collector-browser/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "@aws-sdk/stream-collector-browser", - "version": "1.0.0-beta.4", - "description": "Provides a way to store the contents of a stream into a Uint8Array", - "scripts": { - "prepublishOnly": "tsc", - "pretest": "tsc -p tsconfig.json", - "test": "karma start karma.conf.js" - }, - "author": { - "name": "AWS SDK for JavaScript Team", - "url": "https://aws.amazon.com/javascript/" - }, - "license": "Apache-2.0", - "main": "./build/index.js", - "types": "./build/index.d.ts", - "dependencies": { - "@aws-sdk/types": "1.0.0-beta.4", - "tslib": "^1.8.0" - }, - "devDependencies": { - "@types/jest": "^25.1.4", - "jasmine-core": "^3.5.0", - "karma": "^4.4.1", - "karma-chrome-launcher": "^3.1.0", - "karma-jasmine": "^3.1.1", - "karma-typescript": "^4.1.1", - "puppeteer": "^3.0.1", - "source-map": "^0.7.3", - "typescript": "~3.8.3" - } -} diff --git a/packages/stream-collector-browser/src/index.ts b/packages/stream-collector-browser/src/index.ts deleted file mode 100644 index f48229ef9b72a..0000000000000 --- a/packages/stream-collector-browser/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { StreamCollector } from "@aws-sdk/types"; - -export const streamCollector: StreamCollector = ( - stream: ReadableStream -): Promise => { - return new Response(stream) - .arrayBuffer() - .then(arrayBuffer => new Uint8Array(arrayBuffer)); -}; diff --git a/packages/stream-collector-native/.gitignore b/packages/stream-collector-native/.gitignore deleted file mode 100644 index 3d1714c9806ef..0000000000000 --- a/packages/stream-collector-native/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/node_modules/ -/build/ -/coverage/ -/docs/ -*.tsbuildinfo -*.tgz -*.log -package-lock.json diff --git a/packages/stream-collector-native/.npmignore b/packages/stream-collector-native/.npmignore deleted file mode 100644 index 9fc09eec2b85e..0000000000000 --- a/packages/stream-collector-native/.npmignore +++ /dev/null @@ -1,16 +0,0 @@ -/src/ -/coverage/ -tsconfig.test.json -*.tsbuildinfo - -*.spec.js -*.spec.d.ts -*.spec.js.map - -*.mock.js -*.mock.d.ts -*.mock.js.map - -*.fixture.js -*.fixture.d.ts -*.fixture.js.map diff --git a/packages/stream-collector-native/LICENSE b/packages/stream-collector-native/LICENSE deleted file mode 100644 index a23adae1f9871..0000000000000 --- a/packages/stream-collector-native/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/packages/stream-collector-native/karma.conf.js b/packages/stream-collector-native/karma.conf.js deleted file mode 100644 index c328befe3d25f..0000000000000 --- a/packages/stream-collector-native/karma.conf.js +++ /dev/null @@ -1,26 +0,0 @@ -process.env.CHROME_BIN = require("puppeteer").executablePath(); -module.exports = function (config) { - config.set({ - frameworks: ["jasmine", "karma-typescript"], - files: ["src/**/*.ts"], - exclude: ["**/*.d.ts"], - preprocessors: { - "**/*.ts": "karma-typescript" - }, - reporters: ["progress", "karma-typescript"], - browsers: ["ChromeHeadlessNoSandbox"], - customLaunchers: { - ChromeHeadlessNoSandbox: { - base: "ChromeHeadless", - flags: ["--no-sandbox"] - } - }, - karmaTypescriptConfig: { - tsconfig: "./tsconfig.json", - bundlerOptions: { - addNodeGlobals: false - } - }, - singleRun: true - }); -}; diff --git a/packages/stream-collector-native/src/index.spec.ts b/packages/stream-collector-native/src/index.spec.ts deleted file mode 100644 index 067794efb363d..0000000000000 --- a/packages/stream-collector-native/src/index.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { streamCollector } from "./index"; - -describe("streamCollector", () => { - it("returns a Uint8Array from a blob", done => { - const dataPromise = new Response(new Uint8Array([102, 111, 111]).buffer) - .blob() - .then(blob => streamCollector(blob)); - dataPromise.then((data: any) => { - expect(data).toEqual(Uint8Array.from([102, 111, 111])); - done(); - }); - }); -}); diff --git a/packages/stream-collector-native/tsconfig.json b/packages/stream-collector-native/tsconfig.json deleted file mode 100644 index efcdb957a6688..0000000000000 --- a/packages/stream-collector-native/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "declaration": true, - "strict": true, - "sourceMap": true, - "downlevelIteration": true, - "lib": ["dom", "es5", "es2015.promise", "es2015.iterable"], - "rootDir": "./src", - "outDir": "./build", - "importHelpers": true, - "noEmitHelpers": true, - "incremental": true - } -} diff --git a/packages/stream-collector-browser/.gitignore b/packages/stream-collector-web/.gitignore similarity index 100% rename from packages/stream-collector-browser/.gitignore rename to packages/stream-collector-web/.gitignore diff --git a/packages/stream-collector-browser/.npmignore b/packages/stream-collector-web/.npmignore similarity index 100% rename from packages/stream-collector-browser/.npmignore rename to packages/stream-collector-web/.npmignore diff --git a/packages/stream-collector-native/CHANGELOG.md b/packages/stream-collector-web/CHANGELOG.md similarity index 100% rename from packages/stream-collector-native/CHANGELOG.md rename to packages/stream-collector-web/CHANGELOG.md diff --git a/packages/stream-collector-browser/LICENSE b/packages/stream-collector-web/LICENSE similarity index 100% rename from packages/stream-collector-browser/LICENSE rename to packages/stream-collector-web/LICENSE diff --git a/packages/stream-collector-native/README.md b/packages/stream-collector-web/README.md similarity index 100% rename from packages/stream-collector-native/README.md rename to packages/stream-collector-web/README.md diff --git a/packages/stream-collector-browser/karma.conf.js b/packages/stream-collector-web/karma.conf.js similarity index 100% rename from packages/stream-collector-browser/karma.conf.js rename to packages/stream-collector-web/karma.conf.js diff --git a/packages/stream-collector-native/package.json b/packages/stream-collector-web/package.json similarity index 91% rename from packages/stream-collector-native/package.json rename to packages/stream-collector-web/package.json index 64d368dc910f4..84cff63adeeaf 100644 --- a/packages/stream-collector-native/package.json +++ b/packages/stream-collector-web/package.json @@ -1,6 +1,6 @@ { - "name": "@aws-sdk/stream-collector-native", - "version": "1.0.0-beta.4", + "name": "@aws-sdk/stream-collector-web", + "version": "1.0.0-beta.0", "description": "Provides a way to store the contents of a stream into a Uint8Array", "scripts": { "prepublishOnly": "tsc", diff --git a/packages/stream-collector-browser/src/index.spec.ts b/packages/stream-collector-web/src/index.spec.ts similarity index 67% rename from packages/stream-collector-browser/src/index.spec.ts rename to packages/stream-collector-web/src/index.spec.ts index fbb61aad744cb..e80fbd01d034e 100644 --- a/packages/stream-collector-browser/src/index.spec.ts +++ b/packages/stream-collector-web/src/index.spec.ts @@ -1,9 +1,17 @@ import { streamCollector } from "./index"; -declare const global: any; - describe("streamCollector", () => { it("returns a Uint8Array from a blob", done => { + const dataPromise = new Response(new Uint8Array([102, 111, 111]).buffer) + .blob() + .then(blob => streamCollector(blob)); + dataPromise.then((data: any) => { + expect(data).toEqual(Uint8Array.from([102, 111, 111])); + done(); + }); + }); + + it("returns a Uint8Array from a ReadableStream", done => { const dataPromise = streamCollector( new Response(new Uint8Array([102, 111, 111]).buffer).body ); diff --git a/packages/stream-collector-native/src/index.ts b/packages/stream-collector-web/src/index.ts similarity index 51% rename from packages/stream-collector-native/src/index.ts rename to packages/stream-collector-web/src/index.ts index f8ee53cbb4050..94d6cacce936b 100644 --- a/packages/stream-collector-native/src/index.ts +++ b/packages/stream-collector-web/src/index.ts @@ -3,14 +3,39 @@ import { fromBase64 } from "@aws-sdk/util-base64-browser"; //reference: https://snack.expo.io/r1JCSWRGU export const streamCollector: StreamCollector = ( - stream: Blob + stream: Blob | ReadableStream ): Promise => { - return readToBase64(stream) - .then(base64 => fromBase64(base64)) - .then(arrayBuffer => new Uint8Array(arrayBuffer)); + if(stream instanceof Blob) { + return collectBlob(stream); + } + + return collectStream(stream); }; -const readToBase64 = (blob: Blob): Promise => { +async function collectBlob(blob: Blob): Promise { + const base64 = await readToBase64(blob); + const arrayBuffer = fromBase64(base64); + return new Uint8Array(arrayBuffer); +} + +async function collectStream(stream: ReadableStream): Promise { + let res = new Uint8Array(0); + const reader = stream.getReader(); + let isDone = false; + while(!isDone) { + const { done, value } = await reader.read(); + if(value) { + const prior = res; + res = new Uint8Array(prior.length + value.length); + res.set(prior); + res.set(value, prior.length); + } + isDone = done; + } + return res; +} + +function readToBase64(blob: Blob): Promise { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onloadend = () => { @@ -25,7 +50,7 @@ const readToBase64 = (blob: Blob): Promise => { }; reader.onabort = () => reject(new Error("Read aborted")); reader.onerror = () => reject(reader.error); - // reader.readAsArrayBuffer is not available in RN + // reader.readAsArrayBuffer is not always available reader.readAsDataURL(blob); }); -}; +} \ No newline at end of file diff --git a/packages/stream-collector-browser/tsconfig.json b/packages/stream-collector-web/tsconfig.json similarity index 100% rename from packages/stream-collector-browser/tsconfig.json rename to packages/stream-collector-web/tsconfig.json diff --git a/protocol_tests/aws-ec2/package.json b/protocol_tests/aws-ec2/package.json index c22b4d3b3d115..d736018ccf882 100644 --- a/protocol_tests/aws-ec2/package.json +++ b/protocol_tests/aws-ec2/package.json @@ -46,8 +46,7 @@ "@aws-sdk/protocol-http": "^1.0.0-beta.3", "@aws-sdk/region-provider": "^1.0.0-beta.3", "@aws-sdk/smithy-client": "^1.0.0-beta.4", - "@aws-sdk/stream-collector-browser": "^1.0.0-beta.3", - "@aws-sdk/stream-collector-native": "^1.0.0-beta.3", + "@aws-sdk/stream-collector-web": "^1.0.0-beta.0", "@aws-sdk/stream-collector-node": "^1.0.0-beta.3", "@aws-sdk/types": "^1.0.0-beta.3", "@aws-sdk/url-parser-browser": "^1.0.0-beta.3", diff --git a/protocol_tests/aws-ec2/runtimeConfig.browser.ts b/protocol_tests/aws-ec2/runtimeConfig.browser.ts index a3a4e9d78fb39..7526724851ce8 100644 --- a/protocol_tests/aws-ec2/runtimeConfig.browser.ts +++ b/protocol_tests/aws-ec2/runtimeConfig.browser.ts @@ -1,8 +1,12 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-browser"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; + +import { parseUrl } from "@aws-sdk/url-parser-browser"; +import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; +import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { invalidFunction } from "@aws-sdk/invalid-dependency"; -import { streamCollector } from "@aws-sdk/stream-collector-browser"; import { parseUrl } from "@aws-sdk/url-parser-browser"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; diff --git a/protocol_tests/aws-ec2/runtimeConfig.native.ts b/protocol_tests/aws-ec2/runtimeConfig.native.ts index 73f2effef1c25..e2db1d665e983 100644 --- a/protocol_tests/aws-ec2/runtimeConfig.native.ts +++ b/protocol_tests/aws-ec2/runtimeConfig.native.ts @@ -1,16 +1,17 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-js"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; -import { streamCollector } from "@aws-sdk/stream-collector-native"; + import { parseUrl } from "@aws-sdk/url-parser-node"; import { ClientDefaults } from "./EC2ProtocolClient"; import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; export const ClientDefaultValues: Required = { ...BrowserDefaults, + requestHandler: new FetchHttpHandler(), runtime: "react-native", defaultUserAgent: `aws-sdk-js-v3-react-native-${name}/${version}`, - requestHandler: new FetchHttpHandler({ bufferBody: true }), sha256: Sha256, streamCollector, urlParser: parseUrl diff --git a/protocol_tests/aws-json/package.json b/protocol_tests/aws-json/package.json index 33dfe108d991a..bd61e5b9eb7cd 100644 --- a/protocol_tests/aws-json/package.json +++ b/protocol_tests/aws-json/package.json @@ -46,8 +46,7 @@ "@aws-sdk/protocol-http": "^1.0.0-beta.3", "@aws-sdk/region-provider": "^1.0.0-beta.3", "@aws-sdk/smithy-client": "^1.0.0-beta.4", - "@aws-sdk/stream-collector-browser": "^1.0.0-beta.3", - "@aws-sdk/stream-collector-native": "^1.0.0-beta.3", + "@aws-sdk/stream-collector-web": "^1.0.0-beta.0", "@aws-sdk/stream-collector-node": "^1.0.0-beta.3", "@aws-sdk/types": "^1.0.0-beta.3", "@aws-sdk/url-parser-browser": "^1.0.0-beta.3", diff --git a/protocol_tests/aws-json/runtimeConfig.browser.ts b/protocol_tests/aws-json/runtimeConfig.browser.ts index afa42131a6dc0..f1dafff50e91f 100644 --- a/protocol_tests/aws-json/runtimeConfig.browser.ts +++ b/protocol_tests/aws-json/runtimeConfig.browser.ts @@ -1,8 +1,8 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-browser"; -import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; import { invalidFunction } from "@aws-sdk/invalid-dependency"; -import { streamCollector } from "@aws-sdk/stream-collector-browser"; +import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-browser"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; diff --git a/protocol_tests/aws-json/runtimeConfig.native.ts b/protocol_tests/aws-json/runtimeConfig.native.ts index 369c180b6fb14..388163c71423b 100644 --- a/protocol_tests/aws-json/runtimeConfig.native.ts +++ b/protocol_tests/aws-json/runtimeConfig.native.ts @@ -1,7 +1,7 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-js"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; -import { streamCollector } from "@aws-sdk/stream-collector-native"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-node"; import { ClientDefaults } from "./JsonProtocolClient"; import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; @@ -10,7 +10,7 @@ export const ClientDefaultValues: Required = { ...BrowserDefaults, runtime: "react-native", defaultUserAgent: `aws-sdk-js-v3-react-native-${name}/${version}`, - requestHandler: new FetchHttpHandler({ bufferBody: true }), + requestHandler: new FetchHttpHandler(), sha256: Sha256, streamCollector, urlParser: parseUrl diff --git a/protocol_tests/aws-query/package.json b/protocol_tests/aws-query/package.json index 6aa539fca89c6..06afe51001f18 100644 --- a/protocol_tests/aws-query/package.json +++ b/protocol_tests/aws-query/package.json @@ -46,8 +46,7 @@ "@aws-sdk/protocol-http": "^1.0.0-beta.3", "@aws-sdk/region-provider": "^1.0.0-beta.3", "@aws-sdk/smithy-client": "^1.0.0-beta.4", - "@aws-sdk/stream-collector-browser": "^1.0.0-beta.3", - "@aws-sdk/stream-collector-native": "^1.0.0-beta.3", + "@aws-sdk/stream-collector-web": "^1.0.0-beta.0", "@aws-sdk/stream-collector-node": "^1.0.0-beta.3", "@aws-sdk/types": "^1.0.0-beta.3", "@aws-sdk/url-parser-browser": "^1.0.0-beta.3", diff --git a/protocol_tests/aws-query/runtimeConfig.browser.ts b/protocol_tests/aws-query/runtimeConfig.browser.ts index 750caa0d7f33e..e527edf1937a6 100644 --- a/protocol_tests/aws-query/runtimeConfig.browser.ts +++ b/protocol_tests/aws-query/runtimeConfig.browser.ts @@ -2,7 +2,7 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-browser"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; import { invalidFunction } from "@aws-sdk/invalid-dependency"; -import { streamCollector } from "@aws-sdk/stream-collector-browser"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-browser"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; diff --git a/protocol_tests/aws-query/runtimeConfig.native.ts b/protocol_tests/aws-query/runtimeConfig.native.ts index a1a108377376e..f91ef71b70ca2 100644 --- a/protocol_tests/aws-query/runtimeConfig.native.ts +++ b/protocol_tests/aws-query/runtimeConfig.native.ts @@ -1,16 +1,16 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-js"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; -import { streamCollector } from "@aws-sdk/stream-collector-native"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-node"; import { ClientDefaults } from "./QueryProtocolClient"; import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; export const ClientDefaultValues: Required = { ...BrowserDefaults, - runtime: "react-native", defaultUserAgent: `aws-sdk-js-v3-react-native-${name}/${version}`, - requestHandler: new FetchHttpHandler({ bufferBody: true }), + requestHandler: new FetchHttpHandler(), + runtime: "react-native", sha256: Sha256, streamCollector, urlParser: parseUrl diff --git a/protocol_tests/aws-restjson/package.json b/protocol_tests/aws-restjson/package.json index 2c60e64e2670e..a8b09d5ebf06e 100644 --- a/protocol_tests/aws-restjson/package.json +++ b/protocol_tests/aws-restjson/package.json @@ -47,8 +47,7 @@ "@aws-sdk/querystring-builder": "^1.0.0-beta.3", "@aws-sdk/region-provider": "^1.0.0-beta.3", "@aws-sdk/smithy-client": "^1.0.0-beta.4", - "@aws-sdk/stream-collector-browser": "^1.0.0-beta.3", - "@aws-sdk/stream-collector-native": "^1.0.0-beta.3", + "@aws-sdk/stream-collector-web": "^1.0.0-beta.0", "@aws-sdk/stream-collector-node": "^1.0.0-beta.3", "@aws-sdk/types": "^1.0.0-beta.3", "@aws-sdk/url-parser-browser": "^1.0.0-beta.3", diff --git a/protocol_tests/aws-restjson/runtimeConfig.browser.ts b/protocol_tests/aws-restjson/runtimeConfig.browser.ts index 8774cb79f26cf..2a85999d9ca64 100644 --- a/protocol_tests/aws-restjson/runtimeConfig.browser.ts +++ b/protocol_tests/aws-restjson/runtimeConfig.browser.ts @@ -2,7 +2,7 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-browser"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; import { invalidFunction } from "@aws-sdk/invalid-dependency"; -import { streamCollector } from "@aws-sdk/stream-collector-browser"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-browser"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; diff --git a/protocol_tests/aws-restjson/runtimeConfig.native.ts b/protocol_tests/aws-restjson/runtimeConfig.native.ts index 8cbfce0be1fbb..2ef3a3d4fc522 100644 --- a/protocol_tests/aws-restjson/runtimeConfig.native.ts +++ b/protocol_tests/aws-restjson/runtimeConfig.native.ts @@ -1,16 +1,16 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-js"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; -import { streamCollector } from "@aws-sdk/stream-collector-native"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-node"; import { ClientDefaults } from "./RestJsonProtocolClient"; import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; export const ClientDefaultValues: Required = { ...BrowserDefaults, - runtime: "react-native", defaultUserAgent: `aws-sdk-js-v3-react-native-${name}/${version}`, - requestHandler: new FetchHttpHandler({ bufferBody: true }), + requestHandler: new FetchHttpHandler(), + runtime: "react-native", sha256: Sha256, streamCollector, urlParser: parseUrl diff --git a/protocol_tests/aws-restxml/package.json b/protocol_tests/aws-restxml/package.json index 0462633f6c6a3..94050fad45d71 100644 --- a/protocol_tests/aws-restxml/package.json +++ b/protocol_tests/aws-restxml/package.json @@ -47,8 +47,7 @@ "@aws-sdk/querystring-builder": "^1.0.0-beta.3", "@aws-sdk/region-provider": "^1.0.0-beta.3", "@aws-sdk/smithy-client": "^1.0.0-beta.4", - "@aws-sdk/stream-collector-browser": "^1.0.0-beta.3", - "@aws-sdk/stream-collector-native": "^1.0.0-beta.3", + "@aws-sdk/stream-collector-web": "^1.0.0-beta.0", "@aws-sdk/stream-collector-node": "^1.0.0-beta.3", "@aws-sdk/types": "^1.0.0-beta.3", "@aws-sdk/url-parser-browser": "^1.0.0-beta.3", diff --git a/protocol_tests/aws-restxml/runtimeConfig.browser.ts b/protocol_tests/aws-restxml/runtimeConfig.browser.ts index a4ac80ee03471..5eca81f654c92 100644 --- a/protocol_tests/aws-restxml/runtimeConfig.browser.ts +++ b/protocol_tests/aws-restxml/runtimeConfig.browser.ts @@ -2,12 +2,12 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-browser"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; import { invalidFunction } from "@aws-sdk/invalid-dependency"; -import { streamCollector } from "@aws-sdk/stream-collector-browser"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-browser"; +import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; -import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { ClientDefaults } from "./RestXmlProtocolClient"; import { ClientSharedValues } from "./runtimeConfig.shared"; diff --git a/protocol_tests/aws-restxml/runtimeConfig.native.ts b/protocol_tests/aws-restxml/runtimeConfig.native.ts index db0d89140d4f1..959f131808ca4 100644 --- a/protocol_tests/aws-restxml/runtimeConfig.native.ts +++ b/protocol_tests/aws-restxml/runtimeConfig.native.ts @@ -1,16 +1,16 @@ import { name, version } from "./package.json"; import { Sha256 } from "@aws-crypto/sha256-js"; import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; -import { streamCollector } from "@aws-sdk/stream-collector-native"; +import { streamCollector } from "@aws-sdk/stream-collector-web"; import { parseUrl } from "@aws-sdk/url-parser-node"; import { ClientDefaults } from "./RestXmlProtocolClient"; import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; export const ClientDefaultValues: Required = { ...BrowserDefaults, - runtime: "react-native", defaultUserAgent: `aws-sdk-js-v3-react-native-${name}/${version}`, - requestHandler: new FetchHttpHandler({ bufferBody: true }), + requestHandler: new FetchHttpHandler(), + runtime: "react-native", sha256: Sha256, streamCollector, urlParser: parseUrl