Tools for generating Juno serverless functions code.
Converts a Zod schema to a Candid IDL type for use with IDL.encode and IDL.decode.
| Function | Type |
|---|---|
zodToIdl |
({ id, schema, suffix }: { id: string; schema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; suffix: "Args" or "Result"; }) => IdlResult |
Parameters:
id: - The base name used to generate the IDL type name.schema: - The Zod schema to convert.suffix: - Whether this represents function arguments or a return type.
Returns:
An object containing the generated IDL type and the base type name.
Converts a Zod schema to a Rust type definition string.
| Function | Type |
|---|---|
zodToRust |
({ id, schema, suffix }: { id: string; schema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; suffix: "Args" or "Result"; }) => RustResult |
Parameters:
id: - The base name used to generate the Rust struct or type alias name.schema: - The Zod schema to convert.suffix: - Whether this represents function arguments or a return type.
Returns:
An object containing the generated Rust code and the base type name.
Converts a Zod schema to a Candid type definition string.
| Function | Type |
|---|---|
zodToCandid |
({ id, schema, suffix }: { id: string; schema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; suffix: "Args" or "Result"; }) => CandidResult |
Parameters:
id: - The base name used to generate the type name.schema: - The Zod schema to convert.suffix: - Whether this represents function arguments or a return type.
Returns:
An object containing the generated Candid type declaration and the base type name.
| Property | Type | Description |
|---|---|---|
baseName |
string |
|
idl |
IDL.Type |
| Property | Type | Description |
|---|---|---|
baseName |
string |
|
code |
string |
| Property | Type | Description |
|---|---|---|
baseName |
string |
|
code |
string |
MIT © David Dal Busco