Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 0.18 into 0.19 #1561

Merged
merged 42 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7adb389
Change Blob equals semantics + fix tests
msosnicki May 16, 2024
c3f0eb9
Update CHANGELOG
msosnicki May 16, 2024
b578b19
Fix hashCode + equals, add test
msosnicki May 20, 2024
655a3bd
Fix typo
msosnicki May 20, 2024
60c2e27
Merge branch 'series/0.18' into blob-equals
msosnicki May 20, 2024
4614d7b
Fix 2.12 test compilation
msosnicki May 20, 2024
947034e
Merge pull request #1526 from msosnicki/blob-equals
Baccata May 21, 2024
1e9cd5f
Avoid hardcoding the appending of `smithy4s` in SBT
Baccata May 21, 2024
e710edb
Bump versions
Baccata May 21, 2024
52556e2
Avoid deprecated calls to fs2-data-xml's render
Baccata May 21, 2024
5e19073
Make mdoc happy
Baccata May 21, 2024
89e88c9
Merge pull request #1534 from disneystreaming/fix-smithy4s-output-dir
Baccata May 21, 2024
ff8e2c3
Update sbt-bloop to 1.5.18
scala-steward May 25, 2024
187fb89
Update sbt-scalafix to 0.12.1
scala-steward May 25, 2024
00bb1a3
Update smithytranslate-proto to 0.5.3
scala-steward May 25, 2024
d7f5fcd
Update jsoniter-scala-macros to 2.28.5
scala-steward May 25, 2024
6ae6fc8
Merge pull request #1540 from scala-steward/update/sbt-bloop-1.5.18
mergify[bot] May 25, 2024
b6e6298
Merge pull request #1541 from scala-steward/update/sbt-scalafix-0.12.1
mergify[bot] May 25, 2024
86032b6
Merge pull request #1543 from scala-steward/update/jsoniter-scala-mac…
mergify[bot] May 25, 2024
f669528
Merge pull request #1542 from scala-steward/update/smithytranslate-pr…
mergify[bot] May 25, 2024
b9b99d6
Update protobuf-java, protobuf-java-util to 3.24.4
scala-steward May 27, 2024
f64f15d
Update sbt-protoc to 1.0.7
scala-steward May 27, 2024
e11dbae
Merge pull request #1546 from scala-steward/update/protobuf-java-3.24.4
mergify[bot] May 27, 2024
5588515
Merge pull request #1548 from scala-steward/update/sbt-protoc-1.0.7
mergify[bot] May 27, 2024
d40e0f5
Allow customize sbt opts (#1551)
lenguyenthanh May 31, 2024
ec2b8b1
Add backticks on AWS page
kubukoz Jun 2, 2024
1790751
Implement `scalaImports` trait (#1550)
lenguyenthanh Jun 3, 2024
e3572f3
Support parsing timestamps without seconds (#1553)
dhpiggott Jun 3, 2024
22cb91f
Update os-lib to 0.10.1 (#1547)
scala-steward Jun 3, 2024
9b3b3ce
Bump clsx from 2.0.0 to 2.1.1 in /modules/website (#1554)
dependabot[bot] Jun 3, 2024
9a15160
Bump docusaurus-lunr-search from 3.3.2 to 3.4.0 in /modules/website (…
dependabot[bot] Jun 3, 2024
19acfb2
Timestamp defaults (#1557)
msosnicki Jun 6, 2024
72a9503
Log the args diff when re-running the smithy4s codegen (#1559)
majk-p Jun 10, 2024
93a8958
Merge branch 'series/0.18' into merge-018-into-019-jun14
kubukoz Jun 14, 2024
c3d34e4
unused import
kubukoz Jun 14, 2024
8cef834
Use protoc from nix when available (#1558)
ghostbuster91 Jun 18, 2024
8e1ee57
fix: use default values for optional httpPayload if there is no body …
ghostbuster91 Jun 19, 2024
44dab5a
Merge branch 'series/0.18' into merge-018-into-019-jun14
kubukoz Jun 20, 2024
5cee547
Validated newtypes (#1454)
denisrosca Jun 24, 2024
5d4a0c3
Merge branch 'series/0.18' into merge-018-into-019-jun14
kubukoz Jun 24, 2024
8d943ab
Update 15-validated-newtypes.md (#1563)
kubukoz Jul 1, 2024
276535e
Merge branch 'series/0.18' into merge-018-into-019-jun14
kubukoz Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
# midnight, every Monday and Thursday
- cron: '0 0 * * 1,4'

env:
SBT_OPTS: "-XX:MaxMetaspaceSize=4G -XX:MaxInlineLevel=20 -Xss2m -Xms512M -Xmx6G -XX:ReservedCodeCacheSize=256M"

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -62,8 +65,7 @@ jobs:
- name: Run tests
run: |
sbt test_$BUILD_KEY \
pushRemoteCache_$BUILD_KEY \
-J-Xmx4G
pushRemoteCache_$BUILD_KEY

- name: Run plugin tests
if: matrix.scalaVersion == '2_12' && matrix.scalaPlatform == 'jvm'
Expand Down Expand Up @@ -134,7 +136,7 @@ jobs:
- name: Publish ${{ github.ref }}
run: |
echo $PGP_SECRET | base64 --decode | gpg --import --no-tty --batch --yes
sbt 'pullRemoteCache; release' -J-Xmx2G
sbt 'pullRemoteCache; release'
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ version

#smithy cli metadata
build/smithy/classpath.json

.sbtopts
File renamed without changes.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ Previously they'd be named after the **member target**, now they will use the na

There's usually only one instance of `EncoderK[F, A]` for a particular `F[_]`, and interpreters don't need to know what `A` is. For convenience, the type parameter has been moved to a type member.

# 0.18.23

## Validated newtypes [#1454](https://github.com/disneystreaming/smithy4s/pull/1454)

Add support for rendering constrained newtypes over Smithy primitives as validated newtypes. These types now have an `apply` method which returns either an error or a validated value.

# 0.18.22

* Add support for `@default` for `Timestamp` fields in https://github.com/disneystreaming/smithy4s/pull/1557

# 0.18.21

## Documentation fix

* Addition of a new `@scalaImport` trait to provide a mechanism to add additional imports to the generated code. Read the new [docs](https://disneystreaming.github.io/smithy4s/docs/codegen/customisation/scala-imports) for more info (see https://github.com/disneystreaming/smithy4s/pull/1550).
* Added support for parsing timestamps without seconds in https://github.com/disneystreaming/smithy4s/pull/1553.

# 0.18.20

* Change semantics of `Blob.equals` - Blobs do not take underlying type into consideration, just bytes in https://github.com/disneystreaming/smithy4s/pull/1526

# 0.18.19 - binary-breaking changes in `core`

**WARNING**: This release includes binary-breaking changes in the `core` module. This is indirectly caused by an upstream change in [smithy-lang/smithy](https://github.com/smithy-lang/smithy/).
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ ThisBuild / bloopAllowedCombos := Seq(
)
)
```

## Note for .sbtopts

You usually should use `.sbtopts` to add some more memory for `sbt`, as Smithy4s is complex. You copy the `.sbtopts.example` to `.sbtopts` and adjust the values to your needs:

```bash
cp .sbtopts.example .sbtopts
```

14 changes: 11 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ lazy val core = projectMatrix
}
.taskValue
},
scalacOptions ++= Seq(
"-Wconf:msg=value noInlineDocumentSupport in class ProtocolDefinition is deprecated:silent"
),
libraryDependencies += Dependencies.collectionsCompat.value,
Compile / packageSrc / mappings ++= {
val base = (Compile / sourceManaged).value
Expand Down Expand Up @@ -414,7 +417,7 @@ lazy val codegen = projectMatrix
Dependencies.Alloy.core,
Dependencies.Alloy.openapi,
Dependencies.Smithytranslate.proto,
"com.lihaoyi" %% "os-lib" % "0.9.3",
"com.lihaoyi" %% "os-lib" % "0.10.1",
Dependencies.Circe.core.value,
Dependencies.Circe.parser.value,
Dependencies.Circe.generic.value,
Expand Down Expand Up @@ -471,6 +474,7 @@ lazy val codegenPlugin = (projectMatrix in file("modules/codegen-plugin"))
Compile / unmanagedSources / excludeFilter := { f =>
Glob("**/sbt-test/**").matches(f.toPath)
},
libraryDependencies += Dependencies.MunitV1.diff.value,
publishLocal := {
// make sure that core and codegen are published before the
// plugin is published
Expand Down Expand Up @@ -704,8 +708,8 @@ lazy val protobuf = projectMatrix
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.jvm))
Seq(
"com.google.protobuf" % "protobuf-java" % "3.24.0",
"com.google.protobuf" % "protobuf-java-util" % "3.24.0" % Test
"com.google.protobuf" % "protobuf-java" % "3.24.4",
"com.google.protobuf" % "protobuf-java-util" % "3.24.4" % Test
)
else
Seq(
Expand Down Expand Up @@ -941,6 +945,10 @@ lazy val bootstrapped = projectMatrix
Compile / PB.protoSources ++= Seq(
exampleGeneratedResourcesOutput.value
),
Compile / PB.protocExecutable := sys.env
.get("PROTOC_PATH")
.map(file(_))
.getOrElse((Compile / PB.protocExecutable).value),
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@
inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils, ... }@inputs:
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
shellPackages = [
"jre"
"sbt"
"nodejs-16_x"
"yarn"
shellPackages = with pkgs; [
temurin-jre-bin-17
nodejs-18_x
yarn
(pkgs.sbt.override { jre = pkgs.temurin-jre-bin-17; })
];
protobuf = pkgs.protobuf3_21;
in
{
devShells.default = pkgs.mkShell {
buildInputs = map (pkgName: pkgs.${pkgName}) shellPackages;
nativeBuildInputs = [ pkgs.openssl pkgs.zlib ];
buildInputs = shellPackages;
nativeBuildInputs = [ pkgs.openssl pkgs.zlib protobuf ];
welcomeMessage = ''
Welcome to the smithy4s Nix shell! 👋
Available packages:
${builtins.concatStringsSep "\n" (map (n : "- ${n}") shellPackages)}
${builtins.concatStringsSep "\n" (map (n : "- ${n.name}") shellPackages)}
'';

shellHook = ''
echo "$welcomeMessage"
'';
PROTOC_PATH = pkgs.lib.getExe protobuf;
};
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"paths": {
"/operation/{requiredLabel}": {
"post": {
"operationId": "Operation",
"operationId": "DefaultNullsOperation",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OperationRequestContent"
"$ref": "#/components/schemas/DefaultNullsOperationRequestContent"
}
}
},
Expand Down Expand Up @@ -78,7 +78,7 @@
],
"responses": {
"200": {
"description": "Operation 200 response",
"description": "DefaultNullsOperation 200 response",
"headers": {
"optional-header": {
"schema": {
Expand All @@ -102,18 +102,38 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OperationResponseContent"
"$ref": "#/components/schemas/DefaultNullsOperationResponseContent"
}
}
}
}
}
}
},
"/timestamp-operation": {
"post": {
"operationId": "TimestampOperation",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TimestampOperationRequestContent"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "TimestampOperation 200 response"
}
}
}
}
},
"components": {
"schemas": {
"OperationRequestContent": {
"DefaultNullsOperationRequestContent": {
"type": "object",
"properties": {
"optional": {
Expand All @@ -132,7 +152,7 @@
"requiredWithDefault"
]
},
"OperationResponseContent": {
"DefaultNullsOperationResponseContent": {
"type": "object",
"properties": {
"optional": {
Expand All @@ -150,6 +170,30 @@
"required": [
"requiredWithDefault"
]
},
"TimestampOperationRequestContent": {
"type": "object",
"properties": {
"httpDate": {
"type": "string",
"default": "Thu, 23 May 2024 10:20:30 GMT",
"format": "date-time"
},
"epochSeconds": {
"type": "number",
"default": 1716459630
},
"dateTime": {
"type": "string",
"default": "2024-05-23T10:20:30.000Z",
"format": "date-time"
}
},
"required": [
"dateTime",
"epochSeconds",
"httpDate"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package smithy4s.example

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.struct

final case class DefaultNullsOperationInput(optionalWithDefault: String = "optional-default", requiredLabel: String = "required-label-with-default", requiredWithDefault: String = "required-default", optionalHeaderWithDefault: String = "optional-header-with-default", requiredHeaderWithDefault: String = "required-header-with-default", optionalQueryWithDefault: String = "optional-query-with-default", requiredQueryWithDefault: String = "required-query-with-default", optional: Option[String] = None, optionalHeader: Option[String] = None, optionalQuery: Option[String] = None)

object DefaultNullsOperationInput extends ShapeTag.Companion[DefaultNullsOperationInput] {
val id: ShapeId = ShapeId("smithy4s.example", "DefaultNullsOperationInput")

val hints: Hints = Hints(
smithy.api.Input(),
).lazily

// constructor using the original order from the spec
private def make(optional: Option[String], optionalWithDefault: String, requiredLabel: String, requiredWithDefault: String, optionalHeader: Option[String], optionalHeaderWithDefault: String, requiredHeaderWithDefault: String, optionalQuery: Option[String], optionalQueryWithDefault: String, requiredQueryWithDefault: String): DefaultNullsOperationInput = DefaultNullsOperationInput(optionalWithDefault, requiredLabel, requiredWithDefault, optionalHeaderWithDefault, requiredHeaderWithDefault, optionalQueryWithDefault, requiredQueryWithDefault, optional, optionalHeader, optionalQuery)

implicit val schema: Schema[DefaultNullsOperationInput] = struct(
string.optional[DefaultNullsOperationInput]("optional", _.optional),
string.field[DefaultNullsOperationInput]("optionalWithDefault", _.optionalWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("optional-default"))),
string.required[DefaultNullsOperationInput]("requiredLabel", _.requiredLabel).addHints(smithy.api.Default(smithy4s.Document.fromString("required-label-with-default")), smithy.api.HttpLabel()),
string.required[DefaultNullsOperationInput]("requiredWithDefault", _.requiredWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("required-default"))),
string.optional[DefaultNullsOperationInput]("optionalHeader", _.optionalHeader).addHints(smithy.api.HttpHeader("optional-header")),
string.field[DefaultNullsOperationInput]("optionalHeaderWithDefault", _.optionalHeaderWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("optional-header-with-default")), smithy.api.HttpHeader("optional-header-with-default")),
string.required[DefaultNullsOperationInput]("requiredHeaderWithDefault", _.requiredHeaderWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("required-header-with-default")), smithy.api.HttpHeader("required-header-with-default")),
string.optional[DefaultNullsOperationInput]("optionalQuery", _.optionalQuery).addHints(smithy.api.HttpQuery("optional-query")),
string.field[DefaultNullsOperationInput]("optionalQueryWithDefault", _.optionalQueryWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("optional-query-with-default")), smithy.api.HttpQuery("optional-query-with-default")),
string.field[DefaultNullsOperationInput]("requiredQueryWithDefault", _.requiredQueryWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("required-query-with-default")), smithy.api.HttpQuery("required-query-with-default")),
)(make).withId(id).addHints(hints)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package smithy4s.example

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.struct

final case class DefaultNullsOperationOutput(optionalWithDefault: String = "optional-default", requiredWithDefault: String = "required-default", optionalHeaderWithDefault: String = "optional-header-with-default", requiredHeaderWithDefault: String = "required-header-with-default", optional: Option[String] = None, optionalHeader: Option[String] = None)

object DefaultNullsOperationOutput extends ShapeTag.Companion[DefaultNullsOperationOutput] {
val id: ShapeId = ShapeId("smithy4s.example", "DefaultNullsOperationOutput")

val hints: Hints = Hints(
smithy.api.Output(),
).lazily

// constructor using the original order from the spec
private def make(optional: Option[String], optionalWithDefault: String, requiredWithDefault: String, optionalHeader: Option[String], optionalHeaderWithDefault: String, requiredHeaderWithDefault: String): DefaultNullsOperationOutput = DefaultNullsOperationOutput(optionalWithDefault, requiredWithDefault, optionalHeaderWithDefault, requiredHeaderWithDefault, optional, optionalHeader)

implicit val schema: Schema[DefaultNullsOperationOutput] = struct(
string.optional[DefaultNullsOperationOutput]("optional", _.optional),
string.field[DefaultNullsOperationOutput]("optionalWithDefault", _.optionalWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("optional-default"))),
string.required[DefaultNullsOperationOutput]("requiredWithDefault", _.requiredWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("required-default"))),
string.optional[DefaultNullsOperationOutput]("optionalHeader", _.optionalHeader).addHints(smithy.api.HttpHeader("optional-header")),
string.field[DefaultNullsOperationOutput]("optionalHeaderWithDefault", _.optionalHeaderWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("optional-header-with-default")), smithy.api.HttpHeader("optional-header-with-default")),
string.required[DefaultNullsOperationOutput]("requiredHeaderWithDefault", _.requiredHeaderWithDefault).addHints(smithy.api.Default(smithy4s.Document.fromString("required-header-with-default")), smithy.api.HttpHeader("required-header-with-default")),
)(make).withId(id).addHints(hints)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.struct
import smithy4s.schema.Schema.timestamp

final case class DefaultTest(one: Int = 1, two: String = "test", three: List[String] = List(), four: List[String] = List(), five: String = "", six: Int = 0, seven: Document = smithy4s.Document.nullDoc, eight: Map[String, String] = Map(), nine: Short = 0, ten: Double = 0.0d, eleven: Float = 0.0f, twelve: Long = 0L, thirteen: Timestamp = Timestamp(0, 0), fourteen: Timestamp = Timestamp(0, 0), fifteen: Timestamp = Timestamp(0, 0), sixteen: Byte = 0, seventeen: Blob = Blob.empty, eighteen: Boolean = false)
final case class DefaultTest(one: Int = 1, two: String = "test", three: List[String] = List(), four: List[String] = List(), five: String = "", six: Int = 0, seven: Document = smithy4s.Document.nullDoc, eight: Map[String, String] = Map(), nine: Short = 0, ten: Double = 0.0d, eleven: Float = 0.0f, twelve: Long = 0L, thirteen: Timestamp = Timestamp(0L, 0), fourteen: Timestamp = Timestamp(0L, 0), fifteen: Timestamp = Timestamp(0L, 0), sixteen: Byte = 0, seventeen: Blob = Blob.empty, eighteen: Boolean = false)

object DefaultTest extends ShapeTag.Companion[DefaultTest] {
val id: ShapeId = ShapeId("smithy4s.example", "DefaultTest")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package smithy4s.example

import smithy4s.Hints
import smithy4s.Newtype
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.schema.Schema.bijection
import smithy4s.schema.Schema.string

object NonValidatedString extends Newtype[String] {
val id: ShapeId = ShapeId("smithy4s.example", "NonValidatedString")
val hints: Hints = Hints.empty
val underlyingSchema: Schema[String] = string.withId(id).addHints(hints).validated(smithy.api.Length(min = Some(1L), max = None)).validated(smithy.api.Pattern("[a-zA-Z0-9]+"))
implicit val schema: Schema[NonValidatedString] = bijection(underlyingSchema, asBijection)
}
Loading