Skip to content

Commit

Permalink
feat: update for Smithy 1.0.0
Browse files Browse the repository at this point in the history
This commit updates the smithy-aws-typescript-codegen package to version 0.2.0.

This commit updates to the GA version of Smithy tooling, including the 0.2.0
version of the smithy-typescript build plugin. It includes necessary updates
to handle changes in protocol traits, streaming components, and other
assorted breaks.

Fixes are also included for several formatting issues.
  • Loading branch information
kstich authored and AllanZhengYP committed Jun 5, 2020
1 parent 7dbb571 commit 91fa314
Show file tree
Hide file tree
Showing 22 changed files with 185 additions and 84 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: java

jdk:
- oraclejdk8
- openjdk8
- openjdk11

sudo: true

dist: trusty

install: /bin/true

script: ./codegen/gradlew clean smithy-aws-typescript-codegen:build protocol-test-codegen:build -Plog-tests
4 changes: 2 additions & 2 deletions codegen/protocol-test-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import software.amazon.smithy.gradle.tasks.SmithyBuild

plugins {
id("software.amazon.smithy") version "0.4.3"
id("software.amazon.smithy") version "0.5.1"
}

dependencies {
implementation("software.amazon.smithy:smithy-aws-protocol-tests:0.9.9")
implementation("software.amazon.smithy:smithy-aws-protocol-tests:1.0.5")
compile(project(":smithy-aws-typescript-codegen"))
}

Expand Down
25 changes: 15 additions & 10 deletions codegen/protocol-test-codegen/smithy-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"transforms": [
{
"name": "includeServices",
"args": ["aws.protocols.tests.ec2#AwsEc2"]
"args": {
"services": ["aws.protocoltests.ec2#AwsEc2"]
}
}
],
"plugins": {
Expand All @@ -19,7 +21,6 @@
},
"license": "Apache-2.0"
},
"protocol": "aws.ec2",
"private": true
}
}
Expand All @@ -28,7 +29,9 @@
"transforms": [
{
"name": "includeServices",
"args": ["aws.protocols.tests.json#JsonProtocol"]
"args": {
"services": ["aws.protocoltests.json#JsonProtocol"]
}
}
],
"plugins": {
Expand All @@ -42,7 +45,6 @@
},
"license": "Apache-2.0"
},
"protocol": "aws.json-1.1",
"private": true
}
}
Expand All @@ -51,7 +53,9 @@
"transforms": [
{
"name": "includeServices",
"args": ["aws.protocols.tests.query#AwsQuery"]
"args": {
"services": ["aws.protocoltests.query#AwsQuery"]
}
}
],
"plugins": {
Expand All @@ -65,7 +69,6 @@
},
"license": "Apache-2.0"
},
"protocol": "aws.query",
"private": true
}
}
Expand All @@ -74,7 +77,9 @@
"transforms": [
{
"name": "includeServices",
"args": ["aws.protocols.tests.restjson#RestJson"]
"args": {
"services": ["aws.protocoltests.restjson#RestJson"]
}
}
],
"plugins": {
Expand All @@ -88,7 +93,6 @@
},
"license": "Apache-2.0"
},
"protocol": "aws.rest-json-1.1",
"private": true
}
}
Expand All @@ -97,7 +101,9 @@
"transforms": [
{
"name": "includeServices",
"args": ["aws.protocols.tests.restxml#RestXml"]
"args": {
"services": ["aws.protocoltests.restxml#RestXml"]
}
}
],
"plugins": {
Expand All @@ -111,7 +117,6 @@
},
"license": "Apache-2.0"
},
"protocol": "aws.rest-xml",
"private": true
}
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import software.amazon.smithy.model.node.Node
import software.amazon.smithy.gradle.tasks.SmithyBuild

plugins {
id("software.amazon.smithy") version "0.4.3"
id("software.amazon.smithy") version "0.5.1"
}

dependencies {
Expand Down
13 changes: 10 additions & 3 deletions codegen/smithy-aws-typescript-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {
}

group = "software.amazon.smithy"
version = "0.1.0"
version = "0.2.0"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -33,8 +33,8 @@ tasks.withType<Test> {
}

dependencies {
api("software.amazon.smithy:smithy-aws-traits:0.9.8")
api("software.amazon.smithy:smithy-typescript-codegen:0.1.0")
api("software.amazon.smithy:smithy-aws-traits:1.0.5")
api("software.amazon.smithy:smithy-typescript-codegen:0.2.0")
testCompile("org.junit.jupiter:junit-jupiter-api:5.4.0")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.4.0")
testCompile("org.junit.jupiter:junit-jupiter-params:5.4.0")
Expand All @@ -61,6 +61,13 @@ tasks.withType<JacocoReport> {
// We don't need to lint tests.
tasks["spotbugsTest"].enabled = false

// Log on passed, skipped, and failed test events if the `-Plog-tests` property is set.
if (project.hasProperty("log-tests")) {
tasks.test {
testLogging.events("passed", "skipped", "failed")
}
}

// Configure the bug filter for spotbugs.
tasks.withType<com.github.spotbugs.SpotBugsTask> {
effort = "max"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
/*
* Copyright 2019 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/

package software.amazon.smithy.aws.typescript.codegen;

import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_CONFIG;
import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE;


import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.EventStreamIndex;
Expand Down Expand Up @@ -106,7 +119,8 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
writer.addImport("invalidFunction", "invalidFunction",
TypeScriptDependency.INVALID_DEPENDENCY.packageName);
writer.openBlock("eventStreamPayloadHandlerProvider: () => ({", "}),", () -> {
writer.write("handle: invalidFunction(\"event stream request is not supported in ReactNative.\"),");
writer.write("handle: invalidFunction(\"event stream request "
+ "is not supported in ReactNative.\"),");
});
});
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/*
* Copyright 2019 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/

package software.amazon.smithy.aws.typescript.codegen;

import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;

import software.amazon.smithy.aws.traits.ServiceTrait;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
Expand All @@ -23,7 +37,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
SymbolProvider symbolProvider,
LanguageTarget target
) {
if(!isHttp2Applicable(settings.getService(model))) {
if (!isHttp2Applicable(settings.getService(model))) {
return Collections.emptyMap();
}
switch (target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AddProtocols implements TypeScriptIntegration {

@Override
public List<ProtocolGenerator> getProtocolGenerators() {
return ListUtils.of(new AwsRestJson1_1(), new AwsJsonRpc1_0(), new AwsJsonRpc1_1(),
return ListUtils.of(new AwsRestJson1(), new AwsJsonRpc1_0(), new AwsJsonRpc1_1(),
new AwsRestXml(), new AwsQuery(), new AwsEc2());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package software.amazon.smithy.aws.typescript.codegen;

import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_CONFIG;
import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE;
/*
* Copyright 2019 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/

package software.amazon.smithy.aws.typescript.codegen;

import java.util.Collections;
import java.util.List;
Expand All @@ -13,7 +24,6 @@
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.typescript.codegen.LanguageTarget;
import software.amazon.smithy.typescript.codegen.TypeScriptDependency;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin;
Expand All @@ -23,8 +33,8 @@

/**
* Add client plugins and configs to support WebSocket streaming for Transcribe
* Streaming service
* */
* Streaming service.
**/
public class AddTranscribeStreamingDependency implements TypeScriptIntegration {
@Override
public List<RuntimeClientPlugin> getClientPlugins() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public enum AwsDependency implements SymbolDependencyContainer {
UUID_GENERATOR_TYPES(DEV_DEPENDENCY, "@types/uuid", "^7.0.0"),
MIDDLEWARE_EVENTSTREAM(NORMAL_DEPENDENCY, "@aws-sdk/middleware-eventstream", "^1.0.0-beta.0"),
AWS_SDK_EVENTSTREAM_HANDLER_NODE(NORMAL_DEPENDENCY, "@aws-sdk/eventstream-handler-node", "^1.0.0-beta.0"),
TRANSCRIBE_STREAMING_MIDDLEWARE(NORMAL_DEPENDENCY, "@aws-sdk/middleware-sdk-transcribe-streaming", "^1.0.0-gamma.0");
TRANSCRIBE_STREAMING_MIDDLEWARE(NORMAL_DEPENDENCY, "@aws-sdk/middleware-sdk-transcribe-streaming",
"^1.0.0-gamma.0");

public final String packageName;
public final String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
package software.amazon.smithy.aws.typescript.codegen;

import java.util.Set;
import software.amazon.smithy.aws.traits.protocols.Ec2QueryTrait;
import software.amazon.smithy.codegen.core.SymbolReference;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.traits.TimestampFormatTrait.Format;
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
Expand Down Expand Up @@ -51,6 +53,11 @@ protected String getOperationPath(GenerationContext context, OperationShape oper
return "/";
}

@Override
public ShapeId getProtocol() {
return Ec2QueryTrait.ID;
}

@Override
public String getName() {
return "aws.ec2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

package software.amazon.smithy.aws.typescript.codegen;

import software.amazon.smithy.aws.traits.protocols.AwsJson1_0Trait;
import software.amazon.smithy.model.shapes.ShapeId;

/**
* Handles generating the aws.json-1.0 protocol for services.
*
Expand All @@ -29,6 +32,11 @@ protected String getDocumentContentType() {
return "application/x-amz-json-1.0";
}

@Override
public ShapeId getProtocol() {
return AwsJson1_0Trait.ID;
}

@Override
public String getName() {
return "aws.json-1.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

package software.amazon.smithy.aws.typescript.codegen;

import software.amazon.smithy.aws.traits.protocols.AwsJson1_1Trait;
import software.amazon.smithy.model.shapes.ShapeId;

/**
* Handles generating the aws.json-1.1 protocol for services.
*
Expand All @@ -29,6 +32,11 @@ protected String getDocumentContentType() {
return "application/x-amz-json-1.1";
}

@Override
public ShapeId getProtocol() {
return AwsJson1_1Trait.ID;
}

@Override
public String getName() {
return "aws.json-1.1";
Expand Down

0 comments on commit 91fa314

Please sign in to comment.