@junobuild/functions-tools 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,109 @@
10
10
 
11
11
  Tools for generating [Juno] serverless functions code.
12
12
 
13
+ <!-- TSDOC_START -->
14
+
15
+ ### :toolbox: Functions
16
+
17
+ - [zodToIdl](#gear-zodtoidl)
18
+ - [zodToRust](#gear-zodtorust)
19
+ - [zodToCandid](#gear-zodtocandid)
20
+
21
+ #### :gear: zodToIdl
22
+
23
+ Converts a Zod schema to a Candid IDL type for use with `IDL.encode` and `IDL.decode`.
24
+
25
+ | Function | Type |
26
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
27
+ | `zodToIdl` | `({ id, schema, suffix }: { id: string; schema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; suffix: "Args" or "Result"; }) => IdlResult` |
28
+
29
+ Parameters:
30
+
31
+ - `id`: - The base name used to generate the IDL type name.
32
+ - `schema`: - The Zod schema to convert.
33
+ - `suffix`: - Whether this represents function arguments or a return type.
34
+
35
+ Returns:
36
+
37
+ An object containing the generated IDL type and the base type name.
38
+
39
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions-tools/src/converters/zod-to-idl.ts#L71)
40
+
41
+ #### :gear: zodToRust
42
+
43
+ Converts a Zod schema to a Rust type definition string.
44
+
45
+ | Function | Type |
46
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
47
+ | `zodToRust` | `({ id, schema, suffix }: { id: string; schema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; suffix: "Args" or "Result"; }) => RustResult` |
48
+
49
+ Parameters:
50
+
51
+ - `id`: - The base name used to generate the Rust struct or type alias name.
52
+ - `schema`: - The Zod schema to convert.
53
+ - `suffix`: - Whether this represents function arguments or a return type.
54
+
55
+ Returns:
56
+
57
+ An object containing the generated Rust code and the base type name.
58
+
59
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions-tools/src/converters/zod-to-rust.ts#L181)
60
+
61
+ #### :gear: zodToCandid
62
+
63
+ Converts a Zod schema to a Candid type definition string.
64
+
65
+ | Function | Type |
66
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
+ | `zodToCandid` | `({ id, schema, suffix }: { id: string; schema: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; suffix: "Args" or "Result"; }) => CandidResult` |
68
+
69
+ Parameters:
70
+
71
+ - `id`: - The base name used to generate the type name.
72
+ - `schema`: - The Zod schema to convert.
73
+ - `suffix`: - Whether this represents function arguments or a return type.
74
+
75
+ Returns:
76
+
77
+ An object containing the generated Candid type declaration and the base type name.
78
+
79
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions-tools/src/converters/zod-to-candid.ts#L70)
80
+
81
+ ### :tropical_drink: Interfaces
82
+
83
+ - [IdlResult](#gear-idlresult)
84
+ - [RustResult](#gear-rustresult)
85
+ - [CandidResult](#gear-candidresult)
86
+
87
+ #### :gear: IdlResult
88
+
89
+ | Property | Type | Description |
90
+ | ---------- | ---------- | ----------- |
91
+ | `baseName` | `string` | |
92
+ | `idl` | `IDL.Type` | |
93
+
94
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions-tools/src/converters/zod-to-idl.ts#L43)
95
+
96
+ #### :gear: RustResult
97
+
98
+ | Property | Type | Description |
99
+ | ---------- | -------- | ----------- |
100
+ | `baseName` | `string` | |
101
+ | `code` | `string` | |
102
+
103
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions-tools/src/converters/zod-to-rust.ts#L150)
104
+
105
+ #### :gear: CandidResult
106
+
107
+ | Property | Type | Description |
108
+ | ---------- | -------- | ----------- |
109
+ | `baseName` | `string` | |
110
+ | `code` | `string` | |
111
+
112
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions-tools/src/converters/zod-to-candid.ts#L42)
113
+
114
+ <!-- TSDOC_END -->
115
+
13
116
  ## License
14
117
 
15
118
  MIT © [David Dal Busco](mailto:david.dalbusco@outlook.com)