Issue with Schema Transform Encode/Decode Order in Effect Typescript Library

Hello 👋 I am a bit stuck with the schema transform encode/decode , I have the following schema which simply stores some metadata (presigned URL data) on an Asset.

NOTE: There are 2 "types" of metadata, hence the reason for using a transform which allows me to decode data from my DB to the correct schema based on the "type" discriminator.

From my understanding it should function the following way:

DB-> DECODE -> AssetMetadata
APPLICATION -> ENCODE -> DB

But the problem with my transform function is that the decode/encode is flipped which I don't want - For example I have seen the supported Effect date types work like this:

S.decodeUnknownSync(DateTimeUtc)(
   anIsoDateString
)


Where we have a RAW VALUE (date iso string) -> DECODE -> DateTimeUtc

https://effect.website/play#52e60930b6e3 - In my example, the decode 'from' argument

I think I am having one of those moments where I've looked at something for too long and am now just confused 😂
Was this page helpful?