Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
tson-schema
Advanced tools
Readme
This project aims to bring you an easy way to create json-schemas and TypeScript types using a single API. This API is kept as close as possible to json-schema so you don't have to worry about learning yet another API. Support for new json-schema versions and new TypeScript versions is added on a best effort basis.
This is a work in progress! Known missing json-schema features include:
array.additionalItems
object.additionalProperties
$ref
if
/else
)npm install -S tson-schema
Or
yarn add tson-schema
import * as t from 'tson-schema'
/**
* Array
*/
const numberArraySchema = t.array({
items: t.number({
minimum: 1
}),
minItems: 2,
uniqueItems: true
})
numberArraySchema.getSchema() // { type: 'array', items: { type: 'number', minimum: 1 }, minItems: 2, uniqueItems: true }
numberArraySchema.type // number[]
/**
* Object
*/
const objectSchema = t.object({
properties: {
req: t.string(),
opt: t.tuple({
items: [t.integer()]
})
},
required: ['req']
})
objectSchema.getSchema() // { type: 'object', properties: { req: { type: 'string' }, opt: { type: 'array', items: [{ type: 'integer' }] } }, required: ['req'] }
objectSchema.type // { req: 'string', opt?: [number] }
/**
* Enum
*/
const enumSchema = t.enum(['A', 2, 'C', 4])
enumSchema.getSchema() // { enum: ['A', 2, 'C', 4] }
enumSchema.type // 'A' | 2 | 'C' | 4
/**
* anyOf
*/
const anyOfSchema = t.anyOf([
s.const('A'),
s.integer()
])
enumSchema.getSchema() // { anyOf: [{ const: 'A' }, { type: 'integer' }] }
enumSchema.type // 'A' | number
FAQs
A TypeScript API to create JSON-Schemas and TypeScript types
The npm package tson-schema receives a total of 7 weekly downloads. As such, tson-schema popularity was classified as not popular.
We found that tson-schema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.