{"id":20825811,"url":"https://github.com/joewood/avro-typescript","last_synced_at":"2026-02-24T20:44:11.992Z","repository":{"id":38918307,"uuid":"92165803","full_name":"joewood/avro-typescript","owner":"joewood","description":"TypeScript Code Generator for Apache Avro Schema Types","archived":false,"fork":false,"pushed_at":"2025-01-14T20:38:31.000Z","size":440,"stargazers_count":38,"open_issues_count":2,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T16:08:49.815Z","etag":null,"topics":["avro","avro-schema","typescript","typescript-library"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joewood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-23T11:36:04.000Z","updated_at":"2025-02-12T15:05:10.000Z","dependencies_parsed_at":"2025-02-24T00:00:33.458Z","dependency_job_id":null,"html_url":"https://github.com/joewood/avro-typescript","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewood%2Favro-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewood%2Favro-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewood%2Favro-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewood%2Favro-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joewood","download_url":"https://codeload.github.com/joewood/avro-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217179,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avro","avro-schema","typescript","typescript-library"],"created_at":"2024-11-17T23:06:50.986Z","updated_at":"2026-02-24T20:44:06.969Z","avatar_url":"https://github.com/joewood.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Avro Typescript\n\nA simple JS library to convert Avro Schemas to TypeScript interfaces.\n\n## Install\n\n```\nnpm install avro-typescript\n```\n\nThe 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.\n\n## Usage\n\n```typescript\nimport { avroToTypeScript, RecordType } from \"avro-typescript\"\n\nconst schemaText = fs.readFileSync(\"example.avsc\", \"UTF8\");\nconst schema = JSON.parse(schemaText) as RecordType;\nconsole.log(avroToTypeScript(schema as RecordType));\n```\n\n## Override logicalTypes\n\nTools like [avsc](https://github.com/mtth/avsc) allow you to [override the serialization/deserialization of LogicalTypes](https://github.com/mtth/avsc/wiki/Advanced-usage#logical-types),\n say from numbers to native JS Date objects, in this case we want to generate the typescript type as 'Date', not 'number'.\n Therefore, you can pass in a map 'logicalTypes' to the options to override the outputted TS type for the schema logicalType.\n \nFor example:\n\n```typescript\nconst schema: Schema = {\n    type: \"record\",\n    name: \"logicalOverrides\",\n    fields: [\n        {\n            name: \"eventDate\",\n            type: {\n                type: \"int\",\n                logicalType: \"date\",\n            },\n        },\n        {\n            name: \"startTime\",\n            type: {\n                type: \"int\",\n                logicalType: \"timestamp-millis\",\n            },\n        },\n        {\n            name: \"displayTime\",\n            type: {\n                type: \"string\",\n                logicalType: \"iso-datetime\",\n            },\n        },\n    ],\n};\nconst actual = avroToTypeScript(schema, {\nlogicalTypes: {\n    date: 'Date',\n    'timestamp-millis': 'Date',\n}\n});\n\n// this will output\nexport interface logicalOverrides {\n    eventDate: Date;\n    startTime: Date;\n    displayTime: string;\n}\n```\n\n## Features\n\nMost Avro features are supported, including:\n\n* Enumerated Types\n* Maps\n* Named Records\n* Mandatory and optional fields\n* Unions\n* Primitives\n\n### To-do\n\n* Generate a function to set defaults as per the schema\n* Add support for fixed\n* Generate JSDocs from documentation\n* Add namespace support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoewood%2Favro-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoewood%2Favro-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoewood%2Favro-typescript/lists"}