mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-11 04:41:17 +02:00
15 lines
547 B
TypeScript
15 lines
547 B
TypeScript
import * as Schema from "effect/Schema"
|
|
import * as SchemaRepresentation from "effect/SchemaRepresentation"
|
|
|
|
const schema = Schema.toCodecJson(Schema.Struct({
|
|
a: Schema.String,
|
|
b: Schema.optional(Schema.FiniteFromString),
|
|
c: Schema.Array(Schema.String)
|
|
}))
|
|
|
|
const json = SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(schema.ast))
|
|
|
|
export const roundtrip = SchemaRepresentation.fromRepresentation(
|
|
SchemaRepresentation.fromJson(JSON.parse(JSON.stringify(json))),
|
|
{ revivers: [SchemaRepresentation.isFiniteReviver] }
|
|
)
|