bug(datastar): `DatastarRequestCancellation` has invalid enum values and case mismatch
bug
## Description
`DatastarRequestCancellation` has two problems:
### 1. Invalid `Cleanup` value
The current implementation uses `Auto` and `Disabled`, but also accepts arbitrary strings as `Custom(Js(...))`. The previous implementation had a `Cleanup` variant — however, the Datastar protocol defines only:
```
requestCancellation?: 'auto' | 'disabled' | AbortController
```
There is no `cleanup` value in the Datastar specification.
**Source**: [Datastar `FetchArgs` type](https://github.com/starfederation/datastar/blob/main/library/src/plugins/actions/fetch.ts)
### 2. PascalCase vs lowercase mismatch
The `Schema` transform encodes/decodes `"Auto"` and `"Disabled"` (PascalCase), but Datastar expects lowercase `"auto"` and `"disabled"`.
## Current code
```scala
implicit val schema: Schema[DatastarRequestCancellation] = Schema[String].transform[DatastarRequestCancellation](
{
case "Auto" => Auto
case "Disabled" => Disabled
case other => Custom(Js(other))
},
{
case Auto => "Auto" // Bug: should be "auto"
case Disabled => "Disabled" // Bug: should be "disabled"
case Custom(value) => value.value
},
)
```
## Expected
Encode/decode should use lowercase strings matching the Datastar protocol:
```scala
{
case "auto" => Auto
case "disabled" => Disabled
case other => Custom(Js(other))
},
{
case Auto => "auto"
case Disabled => "disabled"
case Custom(value) => value.value
},
```
## File
`zio-http-datastar-sdk/src/main/scala/zio/http/datastar/model/DatastarRequest.scala`
关闭于 2026-03-14 0 条评论