
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
avro-typescript
Advanced tools
A simple JS library to convert Avro Schemas to TypeScript interfaces.
npm install avro-typescript
The library can be run in node.js or the browser. It takes a Avro Schema as a JavaScript object (from JSON) and returns the TypeScript code as a string.
import { avroToTypeScript, RecordType } from "avro-typescript"
const schemaText = fs.readFileSync("example.avsc", "UTF8");
const schema = JSON.parse(schemaText) as RecordType;
console.log(avroToTypeScript(schema as RecordType));
Tools like avsc allow you to override the serialization/deserialization of LogicalTypes, say from numbers to native JS Date objects, in this case we want to generate the typescript type as 'Date', not 'number'. Therefore, you can pass in a map 'logicalTypes' to the options to override the outputted TS type for the schema logicalType.
For example:
const schema: Schema = {
type: "record",
name: "logicalOverrides",
fields: [
{
name: "eventDate",
type: {
type: "int",
logicalType: "date",
},
},
{
name: "startTime",
type: {
type: "int",
logicalType: "timestamp-millis",
},
},
{
name: "displayTime",
type: {
type: "string",
logicalType: "iso-datetime",
},
},
],
};
const actual = avroToTypeScript(schema, {
logicalTypes: {
date: 'Date',
'timestamp-millis': 'Date',
}
});
// this will output
export interface logicalOverrides {
eventDate: Date;
startTime: Date;
displayTime: string;
}
Most Avro features are supported, including:
FAQs
TypeScript code generator for Apache Avro types
The npm package avro-typescript receives a total of 7,440 weekly downloads. As such, avro-typescript popularity was classified as popular.
We found that avro-typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.