@sinclair/typebox-codegen
Advanced tools
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
| import { TypeBoxModel } from './model'; | ||
| export interface ModelToValibotSettings { | ||
| exactOptionalPropertyTypes: boolean; | ||
| } | ||
| export declare namespace ModelToValibot { | ||
| function Generate(model: TypeBoxModel): string; | ||
| function Generate(model: TypeBoxModel, options?: ModelToValibotSettings): string; | ||
| } |
@@ -35,2 +35,3 @@ "use strict"; | ||
| // -------------------------------------------------------------------------- | ||
| // prettier-ignore | ||
| var ModelToValibot; | ||
@@ -94,3 +95,2 @@ (function (ModelToValibot) { | ||
| function Literal(schema) { | ||
| // prettier-ignore | ||
| return typeof schema.const === `string` | ||
@@ -104,3 +104,3 @@ ? Type(`v.literal`, `'${schema.const}'`, []) | ||
| function Null(schema) { | ||
| return Type(`v.null_`, null, []); | ||
| return Type(`v.null`, null, []); | ||
| } | ||
@@ -128,7 +128,10 @@ function String(schema) { | ||
| function Object(schema) { | ||
| // prettier-ignore | ||
| const properties = globalThis.Object.entries(schema.properties).map(([key, value]) => { | ||
| const optional = Types.TypeGuard.IsOptional(value); | ||
| const property = index_1.PropertyEncoder.Encode(key); | ||
| return optional ? `${property}: v.optional(${Visit(value)})` : `${property}: ${Visit(value)}`; | ||
| return optional | ||
| ? settings.exactOptionalPropertyTypes | ||
| ? `${property}: v.exactOptional(${Visit(value)})` | ||
| : `${property}: v.optional(${Visit(value)})` | ||
| : `${property}: ${Visit(value)}`; | ||
| }).join(`,`); | ||
@@ -175,3 +178,3 @@ const constraints = []; | ||
| function Undefined(schema) { | ||
| return Type(`v.undefined_`, null, []); | ||
| return Type(`v.undefined`, null, []); | ||
| } | ||
@@ -186,3 +189,3 @@ function Union(schema) { | ||
| function Void(schema) { | ||
| return Type(`v.void_`, null, []); | ||
| return Type(`v.void`, null, []); | ||
| } | ||
@@ -277,3 +280,9 @@ function UnsupportedType(schema) { | ||
| const emitted_set = new Set(); | ||
| function Generate(model) { | ||
| const settings = { | ||
| exactOptionalPropertyTypes: false | ||
| }; | ||
| function Generate(model, options = { | ||
| exactOptionalPropertyTypes: false | ||
| }) { | ||
| settings.exactOptionalPropertyTypes = options.exactOptionalPropertyTypes; | ||
| reference_map.clear(); | ||
@@ -280,0 +289,0 @@ recursive_set.clear(); |
@@ -0,0 +0,0 @@ "use strict"; |
+1
-1
| { | ||
| "name": "@sinclair/typebox-codegen", | ||
| "version": "0.10.5", | ||
| "version": "0.11.0", | ||
| "description": "Code Generation Tools for TypeBox", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
162145
0.26%3556
0.34%