Skip to content

Commit 62bb879

Browse files
committed
Merge branch 'main' into chore/bump-typedoc
2 parents f7ceef5 + 9472517 commit 62bb879

File tree

30 files changed

+7836
-4424
lines changed

30 files changed

+7836
-4424
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gradle"
4+
# Look for `build.gradle.kts` file in the `root` directory
5+
directory: "/"
6+
# Check for updates every day (weekdays)
7+
schedule:
8+
interval: "weekly"
9+
open-pull-requests-limit: 5

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ subprojects {
8787

8888
// Apply junit 5 and hamcrest test dependencies to all java projects.
8989
dependencies {
90-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.0")
91-
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.4.0")
92-
testImplementation("org.junit.jupiter:junit-jupiter-params:5.4.0")
93-
testImplementation("org.hamcrest:hamcrest:2.1")
90+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
91+
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.2")
92+
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.2")
93+
testImplementation("org.hamcrest:hamcrest:2.2")
9494
}
9595

9696
// Reusable license copySpec

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,13 @@ private void generateCommandMiddlewareResolver(String configType) {
315315
}
316316

317317
private void addInputAndOutputTypes() {
318-
writeInputType(inputType.getName(), operationIndex.getInput(operation));
319-
writeOutputType(outputType.getName(), operationIndex.getOutput(operation));
318+
writeInputType(inputType.getName(), operationIndex.getInput(operation), symbol.getName());
319+
writeOutputType(outputType.getName(), operationIndex.getOutput(operation), symbol.getName());
320320
writer.write("");
321321
}
322322

323-
private void writeInputType(String typeName, Optional<StructureShape> inputShape) {
323+
private void writeInputType(String typeName, Optional<StructureShape> inputShape, String commandName) {
324+
writer.writeDocs("The input for {@link " + commandName + "}.");
324325
if (inputShape.isPresent()) {
325326
StructureShape input = inputShape.get();
326327
List<MemberShape> blobStreamingMembers = getBlobStreamingMembers(model, input);
@@ -336,7 +337,8 @@ private void writeInputType(String typeName, Optional<StructureShape> inputShape
336337
}
337338
}
338339

339-
private void writeOutputType(String typeName, Optional<StructureShape> outputShape) {
340+
private void writeOutputType(String typeName, Optional<StructureShape> outputShape, String commandName) {
341+
writer.writeDocs("The output of {@link " + commandName + "}.");
340342
// Output types should always be MetadataBearers, possibly in addition
341343
// to a defined output shape.
342344
writer.addImport("MetadataBearer", "__MetadataBearer", TypeScriptDependency.AWS_SDK_TYPES.packageName);

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/PaginationGenerator.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ public void run() {
9595
writer.addImport(outputSymbol.getName(),
9696
outputSymbol.getName(),
9797
outputSymbol.getNamespace());
98-
String aggregatedClientLocation = serviceSymbol.getNamespace()
99-
.replace(serviceSymbol.getName(), aggregatedClientName);
100-
writer.addImport(aggregatedClientName, aggregatedClientName, aggregatedClientLocation);
10198
writer.addImport(serviceSymbol.getName(), serviceSymbol.getName(), serviceSymbol.getNamespace());
10299

103100
// Import Pagination types
@@ -106,7 +103,6 @@ public void run() {
106103
Paths.get(".", PAGINATION_INTERFACE_FILE.replace(".ts", "")).toString());
107104

108105
writeCommandRequest();
109-
writeMethodRequest();
110106
writePager();
111107
}
112108

@@ -121,13 +117,11 @@ static void generateServicePaginationInterfaces(
121117
TypeScriptWriter writer
122118
) {
123119
writer.addImport("PaginationConfiguration", "PaginationConfiguration", "@aws-sdk/types");
124-
String aggregatedClientLocation = service.getNamespace().replace(service.getName(), aggregatedClientName);
125-
writer.addImport(aggregatedClientName, aggregatedClientName, aggregatedClientLocation);
126120
writer.addImport(service.getName(), service.getName(), service.getNamespace());
127121

128122
writer.openBlock("export interface $LPaginationConfiguration extends PaginationConfiguration {",
129123
"}", aggregatedClientName, () -> {
130-
writer.write("client: $L | $L;", aggregatedClientName, service.getName());
124+
writer.write("client: $L;", service.getName());
131125
});
132126
}
133127

@@ -190,10 +184,7 @@ private void writePager() {
190184
writer.write("input[$S] = config.pageSize;", pageSize);
191185
}
192186

193-
writer.openBlock("if (config.client instanceof $L) {", "}", aggregatedClientName, () -> {
194-
writer.write("page = await makePagedRequest(config.client, input, ...additionalArguments);");
195-
});
196-
writer.openBlock("else if (config.client instanceof $L) {", "}", serviceTypeName, () -> {
187+
writer.openBlock("if (config.client instanceof $L) {", "}", serviceTypeName, () -> {
197188
writer.write("page = await makePagedClientRequest(config.client, input, ...additionalArguments);");
198189
});
199190
writer.openBlock("else {", "}", () -> {
@@ -213,21 +204,6 @@ private void writePager() {
213204
}
214205

215206

216-
/**
217-
* Paginated command that calls client.method({...}) under the hood. This is meant for server side environments and
218-
* exposes the entire service.
219-
*/
220-
private void writeMethodRequest() {
221-
writer.writeDocs("@private");
222-
writer.openBlock(
223-
"const makePagedRequest = async (client: $L, input: $L, ...args: any): Promise<$L> => {",
224-
"}", aggregatedClientName, inputSymbol.getName(),
225-
outputSymbol.getName(), () -> {
226-
writer.write("// @ts-ignore");
227-
writer.write("return await client.$L(input, ...args);", methodName);
228-
});
229-
}
230-
231207
/**
232208
* Paginated command that calls CommandClient().send({...}) under the hood. This is meant for client side (browser)
233209
* environments and does not generally expose the entire service.

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public Symbol bigDecimalShape(BigDecimalShape shape) {
237237
}
238238

239239
private Symbol createBigJsSymbol(Shape shape) {
240-
return createSymbolBuilder(shape, "Big", TypeScriptDependency.TYPES_BIG_JS.packageName)
240+
return createSymbolBuilder(shape, "Big", TypeScriptDependency.BIG_JS.packageName)
241241
.addDependency(TypeScriptDependency.TYPES_BIG_JS)
242242
.addDependency(TypeScriptDependency.BIG_JS)
243243
.build();

smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class ResponseDeserializationTestHandler implements HttpHandler {
5757
options?: HttpHandlerOptions
5858
): Promise<{ response: HttpResponse }> {
5959
return Promise.resolve({
60-
response: {
60+
response: new HttpResponse({
6161
statusCode: this.code,
6262
headers: this.headers,
6363
body: Readable.from([this.body])
64-
}
64+
})
6565
});
6666
}
6767
}

smithy-typescript-ssdk-libs/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
**/yarn-error.log
55
coverage
66
**/.turbo
7+
.pnp.*
8+
.yarn/*
9+
!.yarn/patches
10+
!.yarn/plugins
11+
!.yarn/releases
12+
!.yarn/sdks
13+
!.yarn/versions

smithy-typescript-ssdk-libs/.yarn/releases/yarn-3.4.1.cjs

Lines changed: 873 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
yarnPath: .yarn/releases/yarn-3.4.1.cjs
2+
nodeLinker: node-modules

smithy-typescript-ssdk-libs/jest.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ const base = require("./jest.config.base.js");
22

33
module.exports = {
44
...base,
5-
projects: ["<rootDir>/*/jest.config.js"],
6-
testPathIgnorePatterns: ["/node_modules/"],
7-
coveragePathIgnorePatterns: ["/node_modules/"],
5+
projects: ["<rootDir>/*/jest.config.js"]
86
};

smithy-typescript-ssdk-libs/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
},
2424
"devDependencies": {
2525
"@types/jest": "^26.0.4",
26-
"@typescript-eslint/eslint-plugin": "4.30.0",
27-
"@typescript-eslint/parser": "4.30.0",
28-
"eslint": "7.32.0",
29-
"eslint-config-prettier": "8.3.0",
30-
"eslint-plugin-prettier": "3.4.1",
31-
"eslint-plugin-simple-import-sort": "7.0.0",
3226
"jest": "^26.1.0",
3327
"prettier": "2.2.1",
3428
"ts-jest": "^26.4.1",
@@ -41,5 +35,5 @@
4135
"*"
4236
]
4337
},
44-
"packageManager": "yarn@1.22.10"
38+
"packageManager": "yarn@3.4.1"
4539
}

smithy-typescript-ssdk-libs/server-apigateway/package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"postbuild": "rimraf dist/types/ts3.4 && downlevel-dts dist/types dist/types/ts3.4",
1616
"test": "jest --passWithNoTests",
1717
"clean": "rimraf dist",
18-
"lint": "yarn run eslint -c ../.eslintrc.js \"src/**/*.ts\"",
18+
"lint": "eslint -c ../.eslintrc.js \"src/**/*.ts\"",
1919
"format": "prettier --config ../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\""
2020
},
2121
"repository": {
@@ -34,11 +34,17 @@
3434
"devDependencies": {
3535
"@types/jest": "^26.0.4",
3636
"@types/node": "^14.14.37",
37+
"@typescript-eslint/eslint-plugin": "4.30.0",
38+
"@typescript-eslint/parser": "4.30.0",
3739
"concurrently": "^7.6.0",
3840
"downlevel-dts": "^0.7.0",
41+
"eslint": "7.32.0",
42+
"eslint-config-prettier": "8.3.0",
43+
"eslint-plugin-prettier": "3.4.1",
44+
"eslint-plugin-simple-import-sort": "7.0.0",
3945
"jest": "^26.1.0",
40-
"typescript": "~4.2.2",
41-
"rimraf": "^3.0.2"
46+
"rimraf": "^3.0.2",
47+
"typescript": "~4.2.2"
4248
},
4349
"files": [
4450
"dist/cjs/**/*.js",

smithy-typescript-ssdk-libs/server-common/package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"postbuild": "rimraf dist/types/ts3.4 && downlevel-dts dist/types dist/types/ts3.4",
1616
"test": "jest",
1717
"clean": "rimraf dist",
18-
"lint": "yarn run eslint -c ../.eslintrc.js \"src/**/*.ts\"",
18+
"lint": "eslint -c ../.eslintrc.js \"src/**/*.ts\"",
1919
"format": "prettier --config ../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\""
2020
},
2121
"repository": {
@@ -28,18 +28,24 @@
2828
"dependencies": {
2929
"@aws-sdk/protocol-http": "^3.267.0",
3030
"@aws-sdk/types": "^3.267.0",
31-
"tslib": "^1.8.0",
32-
"re2-wasm": "^1.0.2"
31+
"re2-wasm": "^1.0.2",
32+
"tslib": "^1.8.0"
3333
},
3434
"devDependencies": {
3535
"@types/jest": "^26.0.22",
3636
"@types/node": "^14.14.37",
37+
"@typescript-eslint/eslint-plugin": "4.30.0",
38+
"@typescript-eslint/parser": "4.30.0",
3739
"concurrently": "^7.6.0",
3840
"downlevel-dts": "^0.7.0",
41+
"eslint": "7.32.0",
42+
"eslint-config-prettier": "8.3.0",
43+
"eslint-plugin-prettier": "3.4.1",
44+
"eslint-plugin-simple-import-sort": "7.0.0",
3945
"jest": "^26.6.3",
46+
"rimraf": "^3.0.2",
4047
"ts-jest": "^26.5.2",
41-
"typescript": "^4.2.2",
42-
"rimraf": "^3.0.2"
48+
"typescript": "^4.2.2"
4349
},
4450
"files": [
4551
"dist/cjs/**/*.js",

smithy-typescript-ssdk-libs/server-common/src/validation/index.spec.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
PatternValidationFailure,
2222
RangeValidationFailure,
2323
RequiredValidationFailure,
24+
UniqueItemsValidationFailure,
2425
} from "./index";
2526

2627
describe("message formatting", () => {
@@ -32,8 +33,7 @@ describe("message formatting", () => {
3233
path: "/test",
3334
};
3435
expect(generateValidationMessage(failure)).toEqual(
35-
"Value zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz... " +
36-
"(truncated) at '/test' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-c]$"
36+
"Value at '/test' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-c]$"
3737
);
3838
});
3939
it("omits null values", () => {
@@ -50,7 +50,7 @@ describe("message formatting", () => {
5050
it("formats required failures", () => {
5151
const failure = new RequiredValidationFailure("/test");
5252
expect(generateValidationMessage(failure)).toEqual(
53-
"Value null at '/test' failed to satisfy constraint: Member must not be null"
53+
"Value at '/test' failed to satisfy constraint: Member must not be null"
5454
);
5555
});
5656
it("formats enum failures", () => {
@@ -61,7 +61,7 @@ describe("message formatting", () => {
6161
path: "/test",
6262
};
6363
expect(generateValidationMessage(failure)).toEqual(
64-
"Value pear at '/test' failed to satisfy constraint: Member must satisfy enum value set: [apple, banana]"
64+
"Value at '/test' failed to satisfy constraint: Member must satisfy enum value set: [apple, banana]"
6565
);
6666
});
6767
it("formats integer enum failures", () => {
@@ -72,7 +72,7 @@ describe("message formatting", () => {
7272
path: "/test",
7373
};
7474
expect(generateValidationMessage(failure)).toEqual(
75-
"Value 3 at '/test' failed to satisfy constraint: Member must satisfy enum value set: [1, 2]"
75+
"Value at '/test' failed to satisfy constraint: Member must satisfy enum value set: [1, 2]"
7676
);
7777
});
7878
describe("formats length failures", () => {
@@ -118,7 +118,7 @@ describe("message formatting", () => {
118118
path: "/test",
119119
};
120120
expect(generateValidationMessage(failure)).toEqual(
121-
"Value xyz at '/test' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-c]$"
121+
"Value at '/test' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-c]$"
122122
);
123123
});
124124
describe("formats range failures", () => {
@@ -130,7 +130,7 @@ describe("message formatting", () => {
130130
path: "/test",
131131
};
132132
expect(generateValidationMessage(failure)).toEqual(
133-
"Value 3 at '/test' failed to satisfy constraint: Member must be greater than or equal to 7"
133+
"Value at '/test' failed to satisfy constraint: Member must be greater than or equal to 7"
134134
);
135135
});
136136
it("with only max values", () => {
@@ -141,7 +141,7 @@ describe("message formatting", () => {
141141
path: "/test",
142142
};
143143
expect(generateValidationMessage(failure)).toEqual(
144-
"Value 3 at '/test' failed to satisfy constraint: Member must be less than or equal to 2"
144+
"Value at '/test' failed to satisfy constraint: Member must be less than or equal to 2"
145145
);
146146
});
147147
it("with min and max values", () => {
@@ -152,7 +152,17 @@ describe("message formatting", () => {
152152
path: "/test",
153153
};
154154
expect(generateValidationMessage(failure)).toEqual(
155-
"Value 2 at '/test' failed to satisfy constraint: Member must be between 3 and 7, inclusive"
155+
"Value at '/test' failed to satisfy constraint: Member must be between 3 and 7, inclusive"
156+
);
157+
});
158+
it("with unique items", () => {
159+
const failure: UniqueItemsValidationFailure = {
160+
constraintType: "uniqueItems",
161+
failureValue: [5, 9],
162+
path: "/test",
163+
};
164+
expect(generateValidationMessage(failure)).toEqual(
165+
"Value at '/test' failed to satisfy constraint: Member must have unique values"
156166
);
157167
});
158168
});

smithy-typescript-ssdk-libs/server-common/src/validation/index.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,6 @@ export const generateValidationSummary = (failures: readonly ValidationFailure[]
103103
};
104104

105105
export const generateValidationMessage = (failure: ValidationFailure): string => {
106-
let failureValue;
107-
if (failure.constraintType === "required") {
108-
failureValue = "null ";
109-
} else if (failure.failureValue === null) {
110-
failureValue = "";
111-
} else {
112-
const rawFailureValue = failure.failureValue.toString();
113-
if (rawFailureValue.length > 64) {
114-
failureValue = rawFailureValue.substr(0, 49) + "... (truncated) ";
115-
} else {
116-
failureValue = rawFailureValue + " ";
117-
}
118-
}
119-
120106
let prefix = "Value";
121107
let suffix: string;
122108
switch (failure.constraintType) {
@@ -136,7 +122,7 @@ export const generateValidationMessage = (failure: ValidationFailure): string =>
136122
}
137123
case "length": {
138124
if (failure.failureValue !== null) {
139-
prefix = prefix + " with length";
125+
prefix = prefix + " with length " + failure.failureValue;
140126
}
141127
const min = failure.constraintValues[0];
142128
const max = failure.constraintValues[1];
@@ -166,9 +152,8 @@ export const generateValidationMessage = (failure: ValidationFailure): string =>
166152
break;
167153
}
168154
case "uniqueItems": {
169-
prefix = prefix + " with repeated values";
170155
suffix = "must have unique values";
171156
}
172157
}
173-
return `${prefix} ${failureValue}at '${failure.path}' failed to satisfy constraint: Member ${suffix}`;
158+
return `${prefix} at '${failure.path}' failed to satisfy constraint: Member ${suffix}`;
174159
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/node_modules/
2+
/build/
3+
/coverage/
4+
/docs/
5+
*.tsbuildinfo
6+
*.tgz
7+
*.log
8+
package-lock.json
9+
src/*.js
10+
dist/
11+
types/

0 commit comments

Comments
 (0)