@junobuild/functions-tools
v0.6.9
Published
Tools for generating Juno serverless functions code.
Readme
Juno DID tools
Tools for generating Juno serverless functions code.
:toolbox: Functions
:gear: zodToIdl
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.
:gear: zodToRust
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.
:gear: zodToCandid
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.
:tropical_drink: Interfaces
:gear: IdlResult
| Property | Type | Description |
| ---------- | ---------- | ----------- |
| baseName | string | |
| idl | IDL.Type | |
:gear: RustResult
| Property | Type | Description |
| ---------- | -------- | ----------- |
| baseName | string | |
| code | string | |
:gear: CandidResult
| Property | Type | Description |
| ---------- | -------- | ----------- |
| baseName | string | |
| code | string | |
License
MIT © David Dal Busco
