Skip to content

Commit 858cefa

Browse files
authored
Merge pull request #71 from jeskew/feature/client-generator
Feature/client generator
2 parents 34b4f73 + 6ea86bb commit 858cefa

File tree

458 files changed

+7264
-4223
lines changed

Some content is hidden

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

458 files changed

+7264
-4223
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
}
@@ -15,7 +18,10 @@ describe('resolveConfiguration', () => {
1518
});
1619

1720
it('should inject a default value if a property is not supplied', () => {
18-
const definition: ConfigurationDefinition<{region?: string}> = {
21+
const definition: ConfigurationDefinition<
22+
{region?: string},
23+
{region: string}
24+
> = {
1925
region: {
2026
required: false,
2127
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',
@@ -45,7 +54,10 @@ describe('resolveConfiguration', () => {
4554
'should call a default provider and inject its return value if a property is not supplied',
4655
() => {
4756
const defaultProvider = jest.fn(() => 'us-west-2');
48-
const definition: ConfigurationDefinition<{region?: string}> = {
57+
const definition: ConfigurationDefinition<
58+
{region?: string},
59+
{region: string}
60+
> = {
4961
region: {
5062
required: false,
5163
defaultProvider,
@@ -61,7 +73,10 @@ describe('resolveConfiguration', () => {
6173

6274
it('should not call a default provider if a property is supplied', () => {
6375
const defaultProvider = jest.fn(() => 'us-west-2');
64-
const definition: ConfigurationDefinition<{region?: string}> = {
76+
const definition: ConfigurationDefinition<
77+
{region?: string},
78+
{region: string}
79+
> = {
6580
region: {
6681
required: false,
6782
defaultProvider,
@@ -79,7 +94,10 @@ describe('resolveConfiguration', () => {
7994
it('should always call an apply function if one is provided', () => {
8095
const apply = jest.fn(() => {});
8196
const middlewareStack = {} as any;
82-
const definition: ConfigurationDefinition<{region?: string}> = {
97+
const definition: ConfigurationDefinition<
98+
{region: string},
99+
{region: string}
100+
> = {
83101
region: {
84102
required: true,
85103
apply,

packages/config-resolver/src/index.ts

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

88
export function resolveConfiguration<T extends IndexedObject, R extends T>(
99
providedConfiguration: T,
10-
configurationDefinition: ConfigurationDefinition<T>,
11-
middlewareStack: MiddlewareStack<any>
10+
configurationDefinition: ConfigurationDefinition<T, R>,
11+
middlewareStack: MiddlewareStack<any, any, any>
1212
): R {
13-
const out = {} as Partial<R>;
13+
const out: Partial<R> = {};
1414

15-
for (const property of Object.keys(configurationDefinition)) {
15+
// Iterate over the definitions own keys, using getOwnPropertyNames to
16+
// guarantee insertion order is preserved.
17+
// @see https://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
18+
for (const property of Object.getOwnPropertyNames(configurationDefinition)) {
1619
const {
1720
required,
1821
defaultValue,
@@ -25,22 +28,20 @@ export function resolveConfiguration<T extends IndexedObject, R extends T>(
2528
if (defaultValue !== undefined) {
2629
input = defaultValue;
2730
} else if (defaultProvider) {
28-
input = defaultProvider(out);
31+
input = defaultProvider(out as R);
32+
} else if (required) {
33+
throw new Error(
34+
`No input provided for required configuration parameter: ${property}`
35+
);
2936
}
3037
}
3138

32-
if (required && input === undefined) {
33-
throw new Error(
34-
`No input provided for required configuration parameter: ${property}`
35-
);
36-
}
37-
3839
out[property] = input;
3940

4041
if (apply) {
4142
apply(
42-
out[property],
43-
out,
43+
input,
44+
out as R,
4445
middlewareStack
4546
);
4647
}

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
@@ -6,12 +6,11 @@ import {
66

77
type input = Array<string>;
88
type output = object;
9-
type handler = Handler<input, output>;
109

11-
class ConcatMiddleware implements handler {
10+
class ConcatMiddleware implements Handler<input, output> {
1211
constructor(
1312
private readonly message: string,
14-
private readonly next: handler
13+
private readonly next: Handler<input, output>
1514
) {}
1615

1716
handle(args: HandlerArguments<input>): Promise<output> {
@@ -34,7 +33,7 @@ function shuffle<T>(arr: Array<T>): Array<T> {
3433

3534
describe('MiddlewareStack', () => {
3635
it('should resolve the stack into a composed handler', async () => {
37-
const stack = new MiddlewareStack<handler>();
36+
const stack = new MiddlewareStack<input, output>();
3837

3938
const middleware = shuffle([
4039
[ConcatMiddleware.bind(null, 'second')],
@@ -75,7 +74,7 @@ describe('MiddlewareStack', () => {
7574
});
7675

7776
it('should allow cloning', async () => {
78-
const stack = new MiddlewareStack<handler>();
77+
const stack = new MiddlewareStack<input, output>();
7978
stack.add(ConcatMiddleware.bind(null, 'second'));
8079
stack.add(ConcatMiddleware.bind(null, 'first'), {priority: 100});
8180

@@ -95,11 +94,11 @@ describe('MiddlewareStack', () => {
9594
});
9695

9796
it('should allow combining stacks', async () => {
98-
const stack = new MiddlewareStack<handler>();
97+
const stack = new MiddlewareStack<input, output>();
9998
stack.add(ConcatMiddleware.bind(null, 'second'));
10099
stack.add(ConcatMiddleware.bind(null, 'first'), {priority: 100});
101100

102-
const secondStack = new MiddlewareStack<handler>();
101+
const secondStack = new MiddlewareStack<input, output>();
103102
secondStack.add(ConcatMiddleware.bind(null, 'fourth'), {step: 'build'});
104103
secondStack.add(
105104
ConcatMiddleware.bind(null, 'third'),
@@ -125,7 +124,7 @@ describe('MiddlewareStack', () => {
125124

126125
it('should allow the removal of middleware by constructor identity', async () => {
127126
const MyMiddleware = ConcatMiddleware.bind(null, 'remove me!');
128-
const stack = new MiddlewareStack<handler>();
127+
const stack = new MiddlewareStack<input, output>();
129128
stack.add(MyMiddleware);
130129
stack.add(ConcatMiddleware.bind(null, "don't remove me"));
131130

@@ -150,7 +149,7 @@ describe('MiddlewareStack', () => {
150149
});
151150

152151
it('should allow the removal of middleware by tag', async () => {
153-
const stack = new MiddlewareStack<handler>();
152+
const stack = new MiddlewareStack<input, output>();
154153
stack.add(
155154
ConcatMiddleware.bind(null, 'not removed'),
156155
{tags: new Set(['foo', 'bar'])}

packages/middleware-stack/src/index.ts

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,31 @@ import {
99
export type Step = 'initialize'|'build'|'finalize';
1010

1111
interface HandlerListEntry<
12-
T extends Handler<any, any>
12+
InputType extends object,
13+
OutputType extends object,
14+
StreamType
1315
> {
1416
step: Step;
1517
priority: number;
16-
middleware: Middleware<T>;
18+
middleware: Middleware<InputType, OutputType, StreamType>;
1719
tags?: Set<string>;
1820
}
1921

20-
export class MiddlewareStack<T extends Handler<any, any, any>> implements
21-
IMiddlewareStack<T>
22-
{
23-
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+
> = [];
2430
private sorted: boolean = false;
2531

2632
add(
27-
middleware: Middleware<T>,
28-
{
29-
step = 'initialize',
30-
priority = 0,
31-
tags,
32-
}: HandlerOptions = {}
33+
middleware: Middleware<InputType, OutputType, StreamType>,
34+
options: HandlerOptions = {}
3335
): void {
36+
const {step = 'initialize', priority = 0, tags} = options;
3437
this.sorted = false;
3538
this.entries.push({
3639
middleware,
@@ -40,21 +43,23 @@ export class MiddlewareStack<T extends Handler<any, any, any>> implements
4043
});
4144
}
4245

43-
clone(): MiddlewareStack<T> {
44-
const clone = new MiddlewareStack<T>();
46+
clone(): MiddlewareStack<InputType, OutputType, StreamType> {
47+
const clone = new MiddlewareStack<InputType, OutputType, StreamType>();
4548
clone.entries.push(...this.entries);
4649
return clone;
4750
}
4851

4952
concat(
50-
from: MiddlewareStack<T>
51-
): MiddlewareStack<T> {
52-
const clone = new MiddlewareStack<T>();
53+
from: MiddlewareStack<InputType, OutputType, StreamType>
54+
): MiddlewareStack<InputType, OutputType, StreamType> {
55+
const clone = new MiddlewareStack<InputType, OutputType, StreamType>();
5356
clone.entries.push(...this.entries, ...from.entries);
5457
return clone;
5558
}
5659

57-
remove(toRemove: Middleware<T>|string): boolean {
60+
remove(
61+
toRemove: Middleware<InputType, OutputType, StreamType>|string
62+
): boolean {
5863
const {length} = this.entries;
5964
if (typeof toRemove === 'string') {
6065
this.removeByTag(toRemove);
@@ -65,7 +70,10 @@ export class MiddlewareStack<T extends Handler<any, any, any>> implements
6570
return this.entries.length < length;
6671
}
6772

68-
resolve(handler: T, context: HandlerExecutionContext): T {
73+
resolve(
74+
handler: Handler<InputType, OutputType, StreamType>,
75+
context: HandlerExecutionContext
76+
): Handler<InputType, OutputType, StreamType> {
6977
if (!this.sorted) {
7078
this.sort();
7179
}
@@ -77,7 +85,9 @@ export class MiddlewareStack<T extends Handler<any, any, any>> implements
7785
return handler;
7886
}
7987

80-
private removeByIdentity(toRemove: Middleware<T>) {
88+
private removeByIdentity(
89+
toRemove: Middleware<InputType, OutputType, StreamType>
90+
) {
8191
for (let i = this.entries.length - 1; i >= 0; i--) {
8292
if (this.entries[i].middleware === toRemove) {
8393
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)