Transforming Schemas Based on Original Types

I have the following Schema:
const Asset = Schema.Struct({ 
    id: Schema.Number,
    name: Schema.String
})

I need to transform it into the following schema:
const AssetQuery = Schema.Struct({
   id: Schema.Union(Schema.Number, Schema.Struct({ $in: Schema.Array(Schema.Number) }))),
   name: Schema.Union(Schema.String, Schema.Struct({ $in: Schema.Array(Schema.String) }))),
})


I can do this using Schema.transform however I need a solution which does the equivalent for any Schema, not just the Asset Schema above.
Essentially I want the equivalent of TypeScript Mapped Types, but for Schema.
To do this I think I would need to query the type of the original Schema in order to generate the resulting Schema.
How do I go about this?
Was this page helpful?