PHPackages                             hoppinger/ts\_generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hoppinger/ts\_generator

ActiveDrupal-module[API Development](/categories/api)

hoppinger/ts\_generator
=======================

Drupal module to generate TypeScript code based on the REST Resources

2.0.1(5y ago)313.9k↓68%2GPL-2.0+PHP

Since Aug 5Pushed 4mo ago3 watchersCompare

[ Source](https://github.com/hoppinger/ts_generator)[ Packagist](https://packagist.org/packages/hoppinger/ts_generator)[ Docs](https://github.com/hoppinger/ts_generator)[ RSS](/packages/hoppinger-ts-generator/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)DependenciesVersions (14)Used By (0)

TS Generator
============

[](#ts-generator)

This is a Drupal module, that generates Typescript type definitions for certain entities. It can optionally also generate cleaned up target type definitions and functions to convert objects from the initials types to the target types (parsers).

Installation
------------

[](#installation)

```
composer require hoppinger/ts_generator
```

Versions
--------

[](#versions)

Version 2.0.0 is Drupal 9 compatible.

Usage
-----

[](#usage)

The generator runs as a Drush command that needs a configuration file.

Create `.yml` file with the following contents:

```
target_directory: client/generated
entities:
  input:
    - node
    - taxonomy_term
generate_parser: true
```

This file instructs the generator to generate the files in a directory `client/generated` (relative to the location of the configuration file), to generate types for the `node` and `taxonomy_term` entities and to generate target types and corresponding parsers.

Trigger the generation using

```
cd [PROJECT DIRECTORY]/web
../vendor/bin/drush ts_generator:generate [PATH TO CONFIGURATION FILE]
```

Actual usage of the types
-------------------------

[](#actual-usage-of-the-types)

This is an example of how you could use those types. You are not limited to this approach, of course.

```
import {
  InputEntity,
  ParsedInputEntity,
} from "./generated/types"

import {
  input_entity_parser,
  input_entity_guard
} from "./generated/parser"

export type Result = T | "error"

export async function drupalGetEntity(alias: string): Promise {
  const res = await fetch(`/${alias}?format=_json`), { method: "get", credentials: "include" })
  if (!res.ok) return "error"

  const json = await res.json()
  if (!input_entity_guard(json)) return "error"

  const parsed = input_entity_parser(json as InputEntity)
  return parsed
}
```

Todo
----

[](#todo)

- Write more documentation on usage
- Write documentation on the internal workings and ways to extend the generator

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance52

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~251 days

Recently: every ~520 days

Total

12

Last Release

128d ago

Major Versions

1.1.0 → v2.x-dev2018-10-09

1.2.1 → 2.0.02020-06-16

2.0.1 → 9.x-dev2021-07-29

9.x-dev → 10.x-dev2023-11-05

10.x-dev → 11.x-dev2026-02-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/692b75a6dde1f076e7248f8f35cda5d6b68d993046ac0a08158d49b72b71ba38?d=identicon)[rolfvandekrol](/maintainers/rolfvandekrol)

![](https://avatars.githubusercontent.com/u/23648809?v=4)[Ashwini Mone](/maintainers/ashwinimone)[@ashwinimone](https://github.com/ashwinimone)

![](https://avatars.githubusercontent.com/u/10885177?v=4)[Giuseppe Maggiore](/maintainers/giuseppemag)[@giuseppemag](https://github.com/giuseppemag)

![](https://avatars.githubusercontent.com/u/5929758?v=4)[Amit Ajgaonkar](/maintainers/amitajgaonkar)[@amitajgaonkar](https://github.com/amitajgaonkar)

---

Top Contributors

[![rolfvandekrol](https://avatars.githubusercontent.com/u/434397?v=4)](https://github.com/rolfvandekrol "rolfvandekrol (10 commits)")[![WimJongeneel](https://avatars.githubusercontent.com/u/14921418?v=4)](https://github.com/WimJongeneel "WimJongeneel (2 commits)")[![ashwinimone](https://avatars.githubusercontent.com/u/23648809?v=4)](https://github.com/ashwinimone "ashwinimone (1 commits)")[![EDeijl](https://avatars.githubusercontent.com/u/2330187?v=4)](https://github.com/EDeijl "EDeijl (1 commits)")

### Embed Badge

![Health badge](/badges/hoppinger-ts-generator/health.svg)

```
[![Health](https://phpackages.com/badges/hoppinger-ts-generator/health.svg)](https://phpackages.com/packages/hoppinger-ts-generator)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
