New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@sinclair/typebox-codegen

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sinclair/typebox-codegen - npm Package Compare versions

Comparing version
0.11.0
to
0.11.1
+31
-4
model/model-to-arktype.js

@@ -53,2 +53,9 @@ "use strict";

}
/**
* Check if the type need to be wrapped in an api chain (`type(...).some()`)
* Instead of string.
*/
function IsApiChain(type) {
return type.indexOf('type(') === 0;
}
function ConstructUnionOrIntersect(types, operator) {

@@ -65,4 +72,20 @@ function Reduce(types) {

else {
const mapped = types.map((type) => Unwrap(type)).join(` ${operator} `);
return Wrap(mapped);
// For some cases arktype cannot construct types from string literals,
// i.e `{ [key: string]: any } | undefined` to `'{} | undefined'`.
// Instead, create api chain `type({}).or('undefined')`.
const [left, ...right] = types;
if (IsApiChain(left)) {
let chainOperator = null;
if (operator === '&') {
chainOperator = 'intersect';
}
else if (operator === '|') {
chainOperator = 'or';
}
return [left, ...right.map((v) => `${chainOperator}(${v})`)].join('.');
}
else {
const mapped = types.map((type) => Unwrap(type)).join(` ${operator} `);
return Wrap(mapped);
}
}

@@ -173,3 +196,4 @@ }

const buffer = [];
buffer.push(`{\n${properties}\n}`);
buffer.push(`type({\n${properties}\n})`);
import_references.add('type');
return buffer.join(`\n`);

@@ -294,2 +318,3 @@ }

const emitted_types = new Set();
const import_references = new Set();
function Generate(model) {

@@ -309,3 +334,5 @@ reference_map.clear();

}
buffer.unshift(`import { scope } from 'arktype'`, '');
const imports = ['scope', ...import_references].join(',');
buffer.unshift(`import { ${imports} } from 'arktype'`, '');
import_references.clear();
return index_1.Formatter.Format(buffer.join('\n'));

@@ -312,0 +339,0 @@ }

+1
-1
{
"name": "@sinclair/typebox-codegen",
"version": "0.11.0",
"version": "0.11.1",
"description": "Code Generation Tools for TypeBox",

@@ -5,0 +5,0 @@ "main": "index.js",