@junobuild/functions-tools 0.4.0 → 0.4.1
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 +103 -0
- package/dist/node/index.mjs +147 -40
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/api/_contants.d.ts +1 -0
- package/dist/types/api/idl/index.d.ts +2 -3
- package/dist/types/api/idl/services/parser.services.d.ts +1 -1
- package/dist/types/api/index.d.ts +3 -0
- package/dist/types/api/zod/index.d.ts +7 -0
- package/dist/types/api/zod/services/_javascript.templates.d.ts +5 -0
- package/dist/types/api/zod/services/_typescript.templates.d.ts +5 -0
- package/dist/types/api/zod/services/parser.services.d.ts +6 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/converters/zod-to-candid.d.ts +14 -5
- package/dist/types/did/index.d.ts +6 -0
- package/dist/types/did/services/parser.services.d.ts +5 -0
- package/dist/types/functions/index.d.ts +3 -2
- package/dist/types/index.d.ts +2 -1
- package/package.json +4 -4
- package/dist/types/functions/_constants.d.ts +0 -1
- /package/dist/types/api/{idl/types → types}/transformer-options.d.ts +0 -0
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#L174)
|
|
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#L143)
|
|
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)
|