Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ duckdb-test/
typr.sh
.mcp.json
.claude/settings.local.json
.claude/scheduled_tasks.lock
14 changes: 13 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.8.1
version=3.11.1
maxColumn = 200
runner.dialect = Scala213Source3

Expand All @@ -19,6 +19,18 @@ fileOverride {
"glob:**/typr-dsl-scala/src/scala/**" {
runner.dialect = scala3
}
"glob:**/typr/src/scala/**" {
runner.dialect = scala3
}
"glob:**/typr-codegen/src/scala/**" {
runner.dialect = scala3
}
"glob:**/typr-scripts/src/scala/**" {
runner.dialect = scala3
}
"glob:**/typr-scripts-sourcegen/src/scala/**" {
runner.dialect = scala3
}
"glob:**/typr/generated-and-checked-in/**" {
runner.dialect = scala3
}
Expand Down
74 changes: 55 additions & 19 deletions bleep.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
$schema: https://raw.githubusercontent.com/oyvindberg/bleep/master/schema.json
$version: 1.0.0-M3
$version: 1.0.0-M10
resolvers:
- https://packages.confluent.io/maven/
jvm:
name: graalvm-community:25.0.0
projects:
typr-dsl:
dependencies: dev.typr.foundations:foundations-jdbc:1.0.0-RC6
extends: template-publishable
java:
options: --release 24 -proc:none
platform:
Expand All @@ -22,7 +23,9 @@ projects:
- configuration: provided
module: org.postgresql:postgresql:42.7.3
dependsOn: typr-dsl
extends: template-kotlin
extends:
- template-kotlin
- template-publishable
kotlin:
options: -Xnested-type-aliases
sourcegen:
Expand All @@ -36,7 +39,9 @@ projects:
- configuration: provided
module: org.postgresql:postgresql:42.7.3
dependsOn: typr-dsl
extends: template-scala-3
extends:
- template-scala-3
- template-publishable
sourcegen:
- project: typr-scripts-sourcegen
main: scripts.GeneratedRowParsers
Expand Down Expand Up @@ -893,9 +898,18 @@ projects:
- io.circe::circe-generic:0.14.10
- io.circe::circe-yaml-v12:1.15.0
- org.typelevel::cats-effect:3.5.7
- com.olvind.jatatui:crossterm:0.30.0
- com.olvind.jatatui:jatatui-core:0.30.0
- com.olvind.jatatui:jatatui-widgets:0.30.0
- com.olvind.jatatui:jatatui-crossterm:0.30.0
- com.olvind.jatatui:jatatui-react:0.30.0
- com.olvind.jatatui:jatatui-components:0.30.0
- com.lihaoyi::cask:0.9.5
dependsOn:
- typr-codegen
extends: template-scala-3
extends:
- template-scala-3
- template-publishable
platform:
name: jvm
mainClass: typr.cli.Main
Expand Down Expand Up @@ -924,7 +938,9 @@ projects:
- org.postgresql:postgresql:42.7.3
- org.slf4j:slf4j-nop:2.0.13
dependsOn: typr-dsl-scala
extends: template-scala-3
extends:
- template-scala-3
- template-publishable
platform:
mainClass: com.foo.App
scala:
Expand All @@ -934,34 +950,46 @@ projects:
- ./generated-and-checked-in-jsonschema
typr-dsl-anorm:
dependsOn: typr-runtime-anorm
extends: template-cross
extends:
- template-cross
- template-publishable
sources: ../typr-dsl-shared
typr-dsl-doobie:
dependsOn: typr-runtime-doobie
extends: template-cross
extends:
- template-cross
- template-publishable
sources: ../typr-dsl-shared
typr-dsl-zio-jdbc:
dependsOn: typr-runtime-zio-jdbc
extends: template-cross
extends:
- template-cross
- template-publishable
sources: ../typr-dsl-shared
typr-runtime-anorm:
dependencies:
- dev.typr.foundations:foundations-jdbc:1.0.0-RC6
- org.playframework.anorm::anorm:2.7.0
extends: template-cross
extends:
- template-cross
- template-publishable
typr-runtime-doobie:
dependencies:
- dev.typr.foundations:foundations-jdbc:1.0.0-RC6
- org.tpolecat::doobie-postgres:1.0.0-RC9
extends: template-cross
extends:
- template-cross
- template-publishable
typr-runtime-zio-jdbc:
dependencies:
- dev.typr.foundations:foundations-jdbc:1.0.0-RC6
- dev.zio::zio-jdbc:0.1.2
extends: template-cross
extends:
- template-cross
- template-publishable
typr-scripts:
dependencies:
- build.bleep::bleep-plugin-ci-release:${BLEEP_VERSION}
- build.bleep::bleep-core:${BLEEP_VERSION}
- com.ibm.db2:jcc:11.5.9.0
dependsOn: typr-codegen
extends: template-scala-3
Expand All @@ -981,12 +1009,6 @@ scripts:
generate-sources:
main: scripts.GeneratedSources
project: typr-scripts
my-publish-local:
main: scripts.PublishLocal
project: typr-scripts
publish:
main: scripts.Publish
project: typr-scripts
templates:
template-common:
java:
Expand All @@ -1010,8 +1032,22 @@ templates:
template-scala-3:
extends: template-common
scala:
options: -release 24 -source 3.4
options: -release 24 -source 3.4 -no-indent
version: 3.8.3
template-publishable:
publish:
groupId: dev.typr
sonatypeProfileName: com.olvind
description: Typed postgres boilerplate generation
url: https://github.com/oyvindberg/typr/
developers:
- id: oyvindberg
name: Øyvind Raddum Berg
url: https://github.com/oyvindberg
licenses:
- name: MIT
url: http://opensource.org/licenses/MIT
distribution: repo
template-kotlin:
kotlin:
version: 2.3.0
Expand Down
12 changes: 12 additions & 0 deletions coursier-channel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"typr": {
"repositories": ["central"],
"dependencies": ["dev.typr:typr_3:latest.release"],
"mainClass": "typr.cli.Main",
"javaOptions": ["-XX:+UseG1GC"],
"properties": {
"name": "typr",
"description": "Type-safe code generator for JVM — databases, OpenAPI, Avro, gRPC"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public record ProductDetailsWithSalesSqlRow(
@JsonProperty("times_ordered") Optional<Long> timesOrdered,
/** Points to {@link testdb.order_items.OrderItemsRow#quantity()} */
@JsonProperty("total_quantity_sold") Optional<Long> totalQuantitySold,
/** Points to {@link testdb.order_items.OrderItemsRow#quantity()} */
/** Points to {@link testdb.order_items.OrderItemsRow#unitPrice()} */
@JsonProperty("total_revenue") Optional<Double> totalRevenue,
/** Points to {@link testdb.order_items.OrderItemsRow#orderId()} */
Optional<String> popularity
Expand Down Expand Up @@ -71,7 +71,7 @@ public ProductDetailsWithSalesSqlRow withTotalQuantitySold(Optional<Long> totalQ
return new ProductDetailsWithSalesSqlRow(productId, sku, name, price, metadata, timesOrdered, totalQuantitySold, totalRevenue, popularity);
}

/** Points to {@link testdb.order_items.OrderItemsRow#quantity()} */
/** Points to {@link testdb.order_items.OrderItemsRow#unitPrice()} */
public ProductDetailsWithSalesSqlRow withTotalRevenue(Optional<Double> totalRevenue) {
return new ProductDetailsWithSalesSqlRow(productId, sku, name, price, metadata, timesOrdered, totalQuantitySold, totalRevenue, popularity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public record ProductSummarySqlRow(
@JsonProperty("order_count") Long orderCount,
/** Points to {@link testdb.order_items.OrderItemsRow#quantity()} */
@JsonProperty("total_quantity") Optional<Long> totalQuantity,
/** Points to {@link testdb.order_items.OrderItemsRow#quantity()} */
/** Points to {@link testdb.order_items.OrderItemsRow#unitPrice()} */
@JsonProperty("total_revenue") Optional<BigDecimal> totalRevenue
) implements Tuple7<ProductsId, String, String, BigDecimal, Long, Optional<Long>, Optional<BigDecimal>> {
/** Points to {@link testdb.products.ProductsRow#productId()} */
Expand Down Expand Up @@ -59,7 +59,7 @@ public ProductSummarySqlRow withTotalQuantity(Optional<Long> totalQuantity) {
return new ProductSummarySqlRow(productId, productName, sku, price, orderCount, totalQuantity, totalRevenue);
}

/** Points to {@link testdb.order_items.OrderItemsRow#quantity()} */
/** Points to {@link testdb.order_items.OrderItemsRow#unitPrice()} */
public ProductSummarySqlRow withTotalRevenue(Optional<BigDecimal> totalRevenue) {
return new ProductSummarySqlRow(productId, productName, sku, price, orderCount, totalQuantity, totalRevenue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data class ProductDetailsWithSalesSqlRow(
@field:JsonProperty("times_ordered") val timesOrdered: kotlin.Long?,
/** Points to [testdb.order_items.OrderItemsRow.quantity] */
@field:JsonProperty("total_quantity_sold") val totalQuantitySold: kotlin.Long?,
/** Points to [testdb.order_items.OrderItemsRow.quantity] */
/** Points to [testdb.order_items.OrderItemsRow.unitPrice] */
@field:JsonProperty("total_revenue") val totalRevenue: kotlin.Double?,
/** Points to [testdb.order_items.OrderItemsRow.orderId] */
val popularity: kotlin.String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data class ProductSummarySqlRow(
@field:JsonProperty("order_count") val orderCount: kotlin.Long,
/** Points to [testdb.order_items.OrderItemsRow.quantity] */
@field:JsonProperty("total_quantity") val totalQuantity: kotlin.Long?,
/** Points to [testdb.order_items.OrderItemsRow.quantity] */
/** Points to [testdb.order_items.OrderItemsRow.unitPrice] */
@field:JsonProperty("total_revenue") val totalRevenue: BigDecimal?
) : Tuple7<ProductsId, kotlin.String, kotlin.String, BigDecimal, kotlin.Long, kotlin.Long?, BigDecimal?> {
override fun _1(): ProductsId = productId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ case class ProductDetailsWithSalesSqlRow(
@JsonProperty("times_ordered") timesOrdered: Option[Long],
/** Points to [[testdb.order_items.OrderItemsRow.quantity]] */
@JsonProperty("total_quantity_sold") totalQuantitySold: Option[Long],
/** Points to [[testdb.order_items.OrderItemsRow.quantity]] */
/** Points to [[testdb.order_items.OrderItemsRow.unitPrice]] */
@JsonProperty("total_revenue") totalRevenue: Option[Double],
/** Points to [[testdb.order_items.OrderItemsRow.orderId]] */
popularity: Option[String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ case class ProductSummarySqlRow(
@JsonProperty("order_count") orderCount: Long,
/** Points to [[testdb.order_items.OrderItemsRow.quantity]] */
@JsonProperty("total_quantity") totalQuantity: Option[Long],
/** Points to [[testdb.order_items.OrderItemsRow.quantity]] */
/** Points to [[testdb.order_items.OrderItemsRow.unitPrice]] */
@JsonProperty("total_revenue") totalRevenue: Option[BigDecimal]
) extends Tuple7[ProductsId, String, String, BigDecimal, Long, Option[Long], Option[BigDecimal]] {
override def `_1`: ProductsId = productId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public record InventoryCheckSqlRow(
@JsonProperty("quantity_on_hand") Integer quantityOnHand,
/** Points to {@link testdb.inventory.InventoryRow#quantityReserved()} */
@JsonProperty("quantity_reserved") Integer quantityReserved,
/** Points to {@link testdb.inventory.InventoryRow#quantityOnHand()} */
/** Points to {@link testdb.inventory.InventoryRow#quantityReserved()} */
Integer available,
/** Points to {@link testdb.inventory.InventoryRow#reorderPoint()} */
@JsonProperty("reorder_point") Integer reorderPoint,
Expand Down Expand Up @@ -87,7 +87,7 @@ public InventoryCheckSqlRow withQuantityReserved(Integer quantityReserved) {
return new InventoryCheckSqlRow(inventoryId, productId, sku, productName, warehouseId, warehouseCode, warehouseName, quantityOnHand, quantityReserved, available, reorderPoint, binLocation);
}

/** Points to {@link testdb.inventory.InventoryRow#quantityOnHand()} */
/** Points to {@link testdb.inventory.InventoryRow#quantityReserved()} */
public InventoryCheckSqlRow withAvailable(Integer available) {
return new InventoryCheckSqlRow(inventoryId, productId, sku, productName, warehouseId, warehouseCode, warehouseName, quantityOnHand, quantityReserved, available, reorderPoint, binLocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class InventoryCheckSqlRow(
@field:JsonProperty("quantity_on_hand") val quantityOnHand: Int,
/** Points to [testdb.inventory.InventoryRow.quantityReserved] */
@field:JsonProperty("quantity_reserved") val quantityReserved: Int,
/** Points to [testdb.inventory.InventoryRow.quantityOnHand] */
/** Points to [testdb.inventory.InventoryRow.quantityReserved] */
val available: Int,
/** Points to [testdb.inventory.InventoryRow.reorderPoint] */
@field:JsonProperty("reorder_point") val reorderPoint: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ case class InventoryCheckSqlRow(
@JsonProperty("quantity_on_hand") quantityOnHand: Int,
/** Points to [[testdb.inventory.InventoryRow.quantityReserved]] */
@JsonProperty("quantity_reserved") quantityReserved: Int,
/** Points to [[testdb.inventory.InventoryRow.quantityOnHand]] */
/** Points to [[testdb.inventory.InventoryRow.quantityReserved]] */
available: Int,
/** Points to [[testdb.inventory.InventoryRow.reorderPoint]] */
@JsonProperty("reorder_point") reorderPoint: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PersonWithAddressesRepo(
pa.addresses.map { case (addressTypeName, wanted) =>
oldStoredAddressTypes.get(addressTypeName) match {
case Some(addresstypeId) => (addresstypeId, wanted)
case None =>
case None =>
val inserted = addresstypeRepo.insert(AddresstypeRowUnsaved(name = addressTypeName))
(inserted.addresstypeid, wanted)
}
Expand All @@ -69,15 +69,15 @@ class PersonWithAddressesRepo(
oldAttachedAddresses.foreach { case (_, ba) =>
currentAddressesByType.get(ba.addresstypeid) match {
case Some(address) if address.addressid == ba.addressid =>
case _ =>
case _ =>
businessentityAddressRepo.deleteById(ba.compositeId)
}
}
// attach new addresses
currentAddressesByType.map { case (addresstypeId, address) =>
oldAttachedAddresses.get((address.addressid, addresstypeId)) match {
case Some(bea) => bea
case None =>
case None =>
val newRow = BusinessentityaddressRowUnsaved(pa.person.businessentityid, address.addressid, addresstypeId)
businessentityAddressRepo.insert(newRow)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ case class PersonWithAddressesRepo(
currentAttachedAddresses <- currentAddressesWithAddresstype.traverse { case (addresstypeId, address) =>
oldAttachedAddresses.find(x => x.addressid == address.addressid && x.addresstypeid == addresstypeId) match {
case Some(bea) => bea.pure[ConnectionIO]
case None =>
case None =>
businessentityAddressRepo.insert(
BusinessentityaddressRowUnsaved(pa.person.businessentityid, address.addressid, addresstypeId)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PersonWithAddressesRepo(
val key = AddressIdAddresstypeIdKey(address.addressid, addresstypeId)
oldAttachedAddresses.get(key) match {
case Some(existing) => existing
case None =>
case None =>
val newRow = BusinessentityaddressRowUnsaved(
pa.person.businessentityid,
address.addressid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PersonWithAddressesRepo(
val key = AddressIdAddresstypeIdKey(address.addressid, addresstypeId)
oldAttachedAddresses.get(key) match {
case Some(existing) => existing
case None =>
case None =>
val newRow = BusinessentityaddressRowUnsaved(
pa.person.businessentityid,
address.addressid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ case class PersonWithAddressesRepo(
currentAttachedAddresses <- currentAddressesWithAddresstype.forEach { case (addresstypeId, address) =>
oldAttachedAddresses.find(x => x.addressid == address.addressid && x.addresstypeid == addresstypeId) match {
case Some(bea) => ZIO.succeed(bea)
case None =>
case None =>
businessentityAddressRepo
.insert(
BusinessentityaddressRowUnsaved(pa.person.businessentityid, address.addressid, addresstypeId)
Expand Down
2 changes: 1 addition & 1 deletion typr-codegen/src/scala/typr/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object NonEmptyList {
def fromList[T](ts: List[T]): Option[NonEmptyList[T]] =
ts match {
case head :: tail => Some(NonEmptyList(head, tail))
case Nil =>
case Nil =>
None
}
}
4 changes: 2 additions & 2 deletions typr-codegen/src/scala/typr/TypoLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ trait TypoLogger {

object TypoLogger {
object Console extends TypoLogger {
override def warn(str: String): Unit = System.err.println(s"typo: $str")
override def info(str: String): Unit = System.out.println(s"typo: $str")
override def warn(str: String): Unit = System.err.println(s"typr: $str")
override def info(str: String): Unit = System.out.println(s"typr: $str")
}

object Noop extends TypoLogger {
Expand Down
Loading
Loading