Skip to content

Commit 8b88c79

Browse files
authored
Merge pull request #71 from jeskew/feature/client-generator
Feature/client generator
2 parents 4b5647e + 3743ded commit 8b88c79

File tree

466 files changed

+7500
-4366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

466 files changed

+7500
-4366
lines changed

packages/config-resolver/src/index.spec.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { ConfigurationDefinition } from "@aws/types";
33

44
describe("resolveConfiguration", () => {
55
it("should throw if a required property is not supplied", () => {
6-
const definition: ConfigurationDefinition<{ region: string }> = {
6+
const definition: ConfigurationDefinition<
7+
{ region: string },
8+
{ region: string }
9+
> = {
710
region: {
811
required: true
912
}
@@ -14,7 +17,10 @@ describe("resolveConfiguration", () => {
1417
});
1518

1619
it("should inject a default value if a property is not supplied", () => {
17-
const definition: ConfigurationDefinition<{ region?: string }> = {
20+
const definition: ConfigurationDefinition<
21+
{ region?: string },
22+
{ region: string }
23+
> = {
1824
region: {
1925
required: false,
2026
defaultValue: "us-west-2"
@@ -27,7 +33,10 @@ describe("resolveConfiguration", () => {
2733
});
2834

2935
it("should not inject a default value if a property is supplied", () => {
30-
const definition: ConfigurationDefinition<{ region?: string }> = {
36+
const definition: ConfigurationDefinition<
37+
{ region?: string },
38+
{ region: string }
39+
> = {
3140
region: {
3241
required: false,
3342
defaultValue: "us-west-2"
@@ -41,7 +50,10 @@ describe("resolveConfiguration", () => {
4150

4251
it("should call a default provider and inject its return value if a property is not supplied", () => {
4352
const defaultProvider = jest.fn(() => "us-west-2");
44-
const definition: ConfigurationDefinition<{ region?: string }> = {
53+
const definition: ConfigurationDefinition<
54+
{ region?: string },
55+
{ region: string }
56+
> = {
4557
region: {
4658
required: false,
4759
defaultProvider
@@ -57,7 +69,10 @@ describe("resolveConfiguration", () => {
5769

5870
it("should not call a default provider if a property is supplied", () => {
5971
const defaultProvider = jest.fn(() => "us-west-2");
60-
const definition: ConfigurationDefinition<{ region?: string }> = {
72+
const definition: ConfigurationDefinition<
73+
{ region?: string },
74+
{ region: string }
75+
> = {
6176
region: {
6277
required: false,
6378
defaultProvider
@@ -73,7 +88,10 @@ describe("resolveConfiguration", () => {
7388
it("should always call an apply function if one is provided", () => {
7489
const apply = jest.fn(() => {});
7590
const middlewareStack = {} as any;
76-
const definition: ConfigurationDefinition<{ region?: string }> = {
91+
const definition: ConfigurationDefinition<
92+
{ region: string },
93+
{ region: string }
94+
> = {
7795
region: {
7896
required: true,
7997
apply

packages/config-resolver/src/index.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ export type IndexedObject = { [key: string]: any };
44

55
export function resolveConfiguration<T extends IndexedObject, R extends T>(
66
providedConfiguration: T,
7-
configurationDefinition: ConfigurationDefinition<T>,
8-
middlewareStack: MiddlewareStack<any>
7+
configurationDefinition: ConfigurationDefinition<T, R>,
8+
middlewareStack: MiddlewareStack<any, any, any>
99
): R {
10-
const out = {} as Partial<R>;
10+
const out: Partial<R> = {};
1111

12-
for (const property of Object.keys(configurationDefinition)) {
12+
// Iterate over the definitions own keys, using getOwnPropertyNames to
13+
// guarantee insertion order is preserved.
14+
// @see https://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
15+
for (const property of Object.getOwnPropertyNames(configurationDefinition)) {
1316
const {
1417
required,
1518
defaultValue,
@@ -22,20 +25,18 @@ export function resolveConfiguration<T extends IndexedObject, R extends T>(
2225
if (defaultValue !== undefined) {
2326
input = defaultValue;
2427
} else if (defaultProvider) {
25-
input = defaultProvider(out);
28+
input = defaultProvider(out as R);
29+
} else if (required) {
30+
throw new Error(
31+
`No input provided for required configuration parameter: ${property}`
32+
);
2633
}
2734
}
2835

29-
if (required && input === undefined) {
30-
throw new Error(
31-
`No input provided for required configuration parameter: ${property}`
32-
);
33-
}
34-
3536
out[property] = input;
3637

3738
if (apply) {
38-
apply(out[property], out, middlewareStack);
39+
apply(input, out as R, middlewareStack);
3940
}
4041
}
4142

packages/crypto-sha256-node/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "A Node.JS implementation of the AWS SDK for JavaScript's `Hash` interface for SHA-256",
55
"main": "./build/index.js",
66
"scripts": {
7-
"pretest": "tsc",
7+
"pretest": "tsc -p tsconfig.test.json",
88
"test": "jest"
99
},
10-
"author": "aws-javascript-sdk-team@amazon.com",
11-
"license": "UNLICENSED",
10+
"author": "aws-sdk-js@amazon.com",
11+
"license": "Apache-2.0",
1212
"dependencies": {
1313
"@aws/types": "^0.0.1",
1414
"@aws/util-buffer-from": "^0.0.1"
@@ -20,4 +20,4 @@
2020
"typescript": "^2.3"
2121
},
2222
"types": "./build/index.d.ts"
23-
}
23+
}

packages/middleware-stack/src/index.spec.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import { Handler, HandlerArguments } from "@aws/types";
33

44
type input = Array<string>;
55
type output = object;
6-
type handler = Handler<input, output>;
76

8-
class ConcatMiddleware implements handler {
7+
class ConcatMiddleware implements Handler<input, output> {
98
constructor(
109
private readonly message: string,
11-
private readonly next: handler
10+
private readonly next: Handler<input, output>
1211
) {}
1312

1413
handle(args: HandlerArguments<input>): Promise<output> {
@@ -31,7 +30,7 @@ function shuffle<T>(arr: Array<T>): Array<T> {
3130

3231
describe("MiddlewareStack", () => {
3332
it("should resolve the stack into a composed handler", async () => {
34-
const stack = new MiddlewareStack<handler>();
33+
const stack = new MiddlewareStack<input, output>();
3534

3635
const middleware = shuffle([
3736
[ConcatMiddleware.bind(null, "second")],
@@ -66,7 +65,7 @@ describe("MiddlewareStack", () => {
6665
});
6766

6867
it("should allow cloning", async () => {
69-
const stack = new MiddlewareStack<handler>();
68+
const stack = new MiddlewareStack<input, output>();
7069
stack.add(ConcatMiddleware.bind(null, "second"));
7170
stack.add(ConcatMiddleware.bind(null, "first"), { priority: 100 });
7271

@@ -83,11 +82,11 @@ describe("MiddlewareStack", () => {
8382
});
8483

8584
it("should allow combining stacks", async () => {
86-
const stack = new MiddlewareStack<handler>();
85+
const stack = new MiddlewareStack<input, output>();
8786
stack.add(ConcatMiddleware.bind(null, "second"));
8887
stack.add(ConcatMiddleware.bind(null, "first"), { priority: 100 });
8988

90-
const secondStack = new MiddlewareStack<handler>();
89+
const secondStack = new MiddlewareStack<input, output>();
9190
secondStack.add(ConcatMiddleware.bind(null, "fourth"), { step: "build" });
9291
secondStack.add(ConcatMiddleware.bind(null, "third"), {
9392
step: "build",
@@ -110,7 +109,7 @@ describe("MiddlewareStack", () => {
110109

111110
it("should allow the removal of middleware by constructor identity", async () => {
112111
const MyMiddleware = ConcatMiddleware.bind(null, "remove me!");
113-
const stack = new MiddlewareStack<handler>();
112+
const stack = new MiddlewareStack<input, output>();
114113
stack.add(MyMiddleware);
115114
stack.add(ConcatMiddleware.bind(null, "don't remove me"));
116115

@@ -142,7 +141,7 @@ describe("MiddlewareStack", () => {
142141
});
143142

144143
it("should allow the removal of middleware by tag", async () => {
145-
const stack = new MiddlewareStack<handler>();
144+
const stack = new MiddlewareStack<input, output>();
146145
stack.add(ConcatMiddleware.bind(null, "not removed"), {
147146
tags: new Set(["foo", "bar"])
148147
});

packages/middleware-stack/src/index.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,32 @@ import {
88

99
export type Step = "initialize" | "build" | "finalize";
1010

11-
interface HandlerListEntry<T extends Handler<any, any>> {
11+
interface HandlerListEntry<
12+
InputType extends object,
13+
OutputType extends object,
14+
StreamType
15+
> {
1216
step: Step;
1317
priority: number;
14-
middleware: Middleware<T>;
18+
middleware: Middleware<InputType, OutputType, StreamType>;
1519
tags?: Set<string>;
1620
}
1721

18-
export class MiddlewareStack<T extends Handler<any, any, any>>
19-
implements IMiddlewareStack<T> {
20-
private readonly entries: Array<HandlerListEntry<T>> = [];
22+
export class MiddlewareStack<
23+
InputType extends object,
24+
OutputType extends object,
25+
StreamType = Uint8Array
26+
> implements IMiddlewareStack<InputType, OutputType, StreamType> {
27+
private readonly entries: Array<
28+
HandlerListEntry<InputType, OutputType, StreamType>
29+
> = [];
2130
private sorted: boolean = false;
2231

2332
add(
24-
middleware: Middleware<T>,
25-
{ step = "initialize", priority = 0, tags }: HandlerOptions = {}
33+
middleware: Middleware<InputType, OutputType, StreamType>,
34+
options: HandlerOptions = {}
2635
): void {
36+
const { step = "initialize", priority = 0, tags } = options;
2737
this.sorted = false;
2838
this.entries.push({
2939
middleware,
@@ -33,19 +43,23 @@ export class MiddlewareStack<T extends Handler<any, any, any>>
3343
});
3444
}
3545

36-
clone(): MiddlewareStack<T> {
37-
const clone = new MiddlewareStack<T>();
46+
clone(): MiddlewareStack<InputType, OutputType, StreamType> {
47+
const clone = new MiddlewareStack<InputType, OutputType, StreamType>();
3848
clone.entries.push(...this.entries);
3949
return clone;
4050
}
4151

42-
concat(from: MiddlewareStack<T>): MiddlewareStack<T> {
43-
const clone = new MiddlewareStack<T>();
52+
concat(
53+
from: MiddlewareStack<InputType, OutputType, StreamType>
54+
): MiddlewareStack<InputType, OutputType, StreamType> {
55+
const clone = new MiddlewareStack<InputType, OutputType, StreamType>();
4456
clone.entries.push(...this.entries, ...from.entries);
4557
return clone;
4658
}
4759

48-
remove(toRemove: Middleware<T> | string): boolean {
60+
remove(
61+
toRemove: Middleware<InputType, OutputType, StreamType> | string
62+
): boolean {
4963
const { length } = this.entries;
5064
if (typeof toRemove === "string") {
5165
this.removeByTag(toRemove);
@@ -56,7 +70,10 @@ export class MiddlewareStack<T extends Handler<any, any, any>>
5670
return this.entries.length < length;
5771
}
5872

59-
resolve(handler: T, context: HandlerExecutionContext): T {
73+
resolve(
74+
handler: Handler<InputType, OutputType, StreamType>,
75+
context: HandlerExecutionContext
76+
): Handler<InputType, OutputType, StreamType> {
6077
if (!this.sorted) {
6178
this.sort();
6279
}
@@ -68,7 +85,9 @@ export class MiddlewareStack<T extends Handler<any, any, any>>
6885
return handler;
6986
}
7087

71-
private removeByIdentity(toRemove: Middleware<T>) {
88+
private removeByIdentity(
89+
toRemove: Middleware<InputType, OutputType, StreamType>
90+
) {
7291
for (let i = this.entries.length - 1; i >= 0; i--) {
7392
if (this.entries[i].middleware === toRemove) {
7493
this.entries.splice(i, 1);

packages/model-codecommit-v1/BatchGetRepositoriesInput.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/model-codecommit-v1/BatchGetRepositoriesOutput.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/model-codecommit-v1/BranchNameRequiredException.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/model-codecommit-v1/CommitDoesNotExistException.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)