CLICLItypeA command you run, rather than a dependency you import.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

cds2types

A command-line tool that generates TypeScript interfaces from a CDS model, written before @cap-js/cds-typer existed.

DeprecatedThis project is not maintained anymore.mrbandler/cds2types — README, the caution notice

Facts

Latestv3.0.1ReleasedLast pushLicenceMIT

Where it sits

Lives in
Provides
TypeScript patternsCAPTypeScript patternscapabilityHow an application is arranged once it is written in TypeScript — where handlers live, what registers them, and how business logic is kept apart from persistence. Distinct from typing, which is about the model being visible to the compiler; this is about the shape of the code around it.
Flavors
Requires
@sap/cds^6.3.1@sap/cdsartifactThe peer range, as published.

Who is behind it

mrbandlermrbandlerPersonMaintains this
In the atlas: maintains 2, contributes to 2, wrote 1
@mrbandler
maintainerSimonPersonContributes to this
In the atlas: contributes to 2
@HeneryHawk
Theo SunPersonContributes to this
In the atlas: maintains 8, contributes to 3
@Soontao
Evan FoxPersonContributes to this
In the atlas: contributes to 1
@thisisevanfox
3 contributors

What it declares

Every artifact

Type
CLI
Origin
Independently maintained

As a CLI

Declared for
^6.3.1
Distributed through
npm

Connections1

Install

npm add cds2types

Derived from the package name. No recipe recorded; the README has the configuration.

Learn more1

Readings
  1. Taking CAP to the next level - with TypeScriptmrbandler, SAP Community

README

quoted from mrbandler/cds2types under MIT, read
mrbandler/cds2types/README.mdOn GitHub

cds2types

npm version Actions Status GitHub License

Caution

This project is not maintained anymore. Please refer to the public CAP documentation for instructions how to setup a typescript based project.

CLI to convert CDS definitions to native Typescript types.

⚠ Breaking change with version 3.0.0 of cds2types:

  • cds2types now uses the CDS version of the project it is used in
  • You have to pass an output directory to the cds2types command instead of a output file
  • For each CDS namespace or service a separate file is generated in the output folder (module syntax)

Table of Content

  1. Installation 💻
  2. Usage ⌨️
  3. Bugs and Features 🐞💡
  4. License 📃

1. Installation

npm install cds2types --save-dev

OR

yarn add cds2types --dev

2. Usage

Let's look at a CDS example:

// schema.cds

using { managed, sap, cuid } from '@sap/cds/common';
namespace sap.capire.bookshop;

entity EntityWithSlashes {
    field1          : String(10);
    ![/part1/part2] : String(23);
}

entity ArrayUsingEntity : cuid {
    inlineArray      : array of {
        id       : String;
        quantity : Integer
    };
    adressArray      : array of Address;
    compositionField : Composition of many {
                           idComposition       : String;
                           quantityComposition : Integer;
                       }
}

entity Books : managed {
    key ID              : Integer;
        title           : localized String(111);
        descr           : localized String(1111);
        longdesc        : localized String(1111111);
        author          : Association to Authors;
        genre           : Association to Genres;
        stock           : Integer;
        price           : Decimal(9, 2);
        currency        : Association to one sap.common.Currencies;
        ![/part1/part2] : String(23) default 'test';
}


type Gender    : Integer enum {
    NonBinary = 1;
    Male      = 2;
    Female    = 3;
}

type NameStr   : String(111);

type Name {
    firstname : NameStr;
    lastname  : NameStr;
}

type Address {
    street  : String;
    houseNo : String;
    town    : String;
    country : String;
}

type Addresses : many Address;

entity Authors : managed {
    key ID           : Integer;
        name         : Name;
        gender       : Gender;
        addresses    : Addresses;
        dateOfBirth  : Date;
        dateOfDeath  : Date;
        placeOfBirth : String;
        placeOfDeath : String;
        books        : Association to many Books
                           on books.author = $self;
}

/**
 * Hierarchically organized Code List for Genres
 */
entity Genres : sap.common.CodeList {
    key ID       : Integer;
        parent   : Association to Genres;
        children : Composition of many Genres
                       on children.parent = $self;
}

Now when we run the CLI:

cds2types --cds ./service.cds --output ./ --prefix I

We get the following output:

// sap.capire.bookshop.ts

import { ICurrencies, Locale } from "./sap.common";

export type Addresses = IAddress[];
export type NameStr = string;

export enum Gender {
    NonBinary = 1,
    Male = 2,
    Female = 3,
}

export interface IAddress {
    street: string;
    houseNo: string;
    town: string;
    country: string;
}

export interface IArrayUsingEntity {
    ID: string;
    inlineArray: unknown[];
    adressArray: IAddress[];
    compositionField: ICompositionField[];
}

export interface ICompositionField {
    up_?: IArrayUsingEntity;
    up__ID?: string;
    idComposition: string;
    quantityComposition: number;
}

export interface IAuthors {
    createdAt?: Date;
    createdBy?: string;
    modifiedAt?: Date;
    modifiedBy?: string;
    ID: number;
    name: IName;
    gender: Gender;
    addresses: Addresses;
    dateOfBirth: Date;
    dateOfDeath: Date;
    placeOfBirth: string;
    placeOfDeath: string;
    books?: IBooks[];
}

export interface IBooks {
    createdAt?: Date;
    createdBy?: string;
    modifiedAt?: Date;
    modifiedBy?: string;
    ID: number;
    title: string;
    descr: string;
    longdesc: string;
    author?: IAuthors;
    author_ID?: number;
    genre?: IGenres;
    genre_ID?: number;
    stock: number;
    price: number;
    currency?: ICurrencies;
    currency_code?: string;
    "/part1/part2"?: string;
    texts?: IBooksTexts[];
    localized?: IBooksTexts;
}

export interface IBooksTexts {
    locale: Locale;
    ID: number;
    title: string;
    descr: string;
    longdesc: string;
}

export interface IEntityWithSlashes {
    field1: string;
    "/part1/part2": string;
}

export interface IGenres {
    name: string;
    descr: string;
    ID: number;
    parent?: IGenres;
    parent_ID?: number;
    children: IGenres[];
    texts?: IGenresTexts[];
    localized?: IGenresTexts;
}

export interface IGenresTexts {
    locale: Locale;
    name: string;
    descr: string;
    ID: number;
}

export interface IName {
    firstname: NameStr;
    lastname: NameStr;
}

export enum Entity {
    Address = "sap.capire.bookshop.Address",
    ArrayUsingEntity = "sap.capire.bookshop.ArrayUsingEntity",
    CompositionField = "sap.capire.bookshop.ArrayUsingEntity.compositionField",
    Authors = "sap.capire.bookshop.Authors",
    Books = "sap.capire.bookshop.Books",
    BooksTexts = "sap.capire.bookshop.Books.texts",
    EntityWithSlashes = "sap.capire.bookshop.EntityWithSlashes",
    Genres = "sap.capire.bookshop.Genres",
    GenresTexts = "sap.capire.bookshop.Genres.texts",
    Name = "sap.capire.bookshop.Name",
}

export enum SanitizedEntity {
    Address = "Address",
    ArrayUsingEntity = "ArrayUsingEntity",
    CompositionField = "CompositionField",
    Authors = "Authors",
    Books = "Books",
    BooksTexts = "BooksTexts",
    EntityWithSlashes = "EntityWithSlashes",
    Genres = "Genres",
    GenresTexts = "GenresTexts",
    Name = "Name",
}
// sap.common.ts

export type Locale = string;

export interface ICountries {
    name: string;
    descr: string;
    code: string;
    texts?: ICountriesTexts[];
    localized?: ICountriesTexts;
}

export interface ICountriesTexts {
    locale: Locale;
    name: string;
    descr: string;
    code: string;
}

export interface ICurrencies {
    name: string;
    descr: string;
    code: string;
    symbol: string;
    texts?: ICurrenciesTexts[];
    localized?: ICurrenciesTexts;
}

export interface ICurrenciesTexts {
    locale: Locale;
    name: string;
    descr: string;
    code: string;
}

export interface ILanguages {
    name: string;
    descr: string;
    code: Locale;
    texts?: ILanguagesTexts[];
    localized?: ILanguagesTexts;
}

export interface ILanguagesTexts {
    locale: Locale;
    name: string;
    descr: string;
    code: Locale;
}

export enum Entity {
    Countries = "sap.common.Countries",
    CountriesTexts = "sap.common.Countries.texts",
    Currencies = "sap.common.Currencies",
    CurrenciesTexts = "sap.common.Currencies.texts",
    Languages = "sap.common.Languages",
    LanguagesTexts = "sap.common.Languages.texts",
}

export enum SanitizedEntity {
    Countries = "Countries",
    CountriesTexts = "CountriesTexts",
    Currencies = "Currencies",
    CurrenciesTexts = "CurrenciesTexts",
    Languages = "Languages",
    LanguagesTexts = "LanguagesTexts",
}
// other.ts

export type User = string;

export enum Entity {}

export enum SanitizedEntity {}

3. Bugs and Features

Please open a issue when you encounter any bugs 🐞 or if you have an idea for a additional feature 💡.


4. License

MIT License

Copyright (c) 2019 mrbandler

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT, read

History

Latest

v3.0.1

Notes

Deprecate project

  1. v3.0.0

    Other 3

    Notes
    • cds2types now uses the CDS version of the project it is used in
    • You have to pass an output directory to the cds2types command instead of a output file
    • For each CDS namespace or service a separate file is generated in the output folder (module syntax)
  2. v2.8.0

    Notes

    Add hana.tinyint type mapping to number (#37)

  3. v2.7.4

    Notes

    Fixes issue #32

  4. v2.7.3

    Notes

    Adds option to sort output types (#28)

  5. v2.7.1

    Notes

    Fixes issue #17

  6. v2.7.0

    Notes

    Update deps and use cds@5.

  7. v2.6.2

    Notes

    cds2types can now parse array of definitions if they have a defined type or entity as the type of the array elements. Inline declaration of the type of array elements is currently not supported.

    See Issue #9

  8. v2.6.1

141downloads per week, npm
Weekly downloads for cds2types26 complete calendar weeks from 2026-04-27 to 2026-10-25; the latest total is 141.27 Apr – 3 May: 9234 May – 10 May: 1,20311 May – 17 May: 92218 May – 24 May: 1,01025 May – 31 May: 1,2181 Jun – 7 Jun: 8148 Jun – 14 Jun: 99315 Jun – 21 Jun: 87322 Jun – 28 Jun: 84429 Jun – 5 Jul: 1,0456 Jul – 12 Jul: 1,22813 Jul – 19 Jul: 84220 Jul – 26 Jul: 1,13927 Jul – 2 Aug: 1,1003 Aug – 9 Aug: 64410 Aug – 16 Aug: 59417 Aug – 23 Aug: 55724 Aug – 30 Aug: 1,14531 Aug – 6 Sept: 5657 Sept – 13 Sept: 1,48214 Sept – 20 Sept: 1,80721 Sept – 27 Sept: 1,12128 Sept – 4 Oct: 1,2675 Oct – 11 Oct: 53812 Oct – 18 Oct: 25519 Oct – 25 Oct: 141
TypeScript patterns
  1. @dxfrontier/cds-ts-dispatcherDecorator-driven handler registration for CAP in TypeScriptfrom CAP
  2. @dxfrontier/cds-ts-repositoryTyped BaseRepository over CAP entitiesfrom CAP
  3. cds-plugin-handlersOne handler file per entity in CAP servicesfrom CAP
  4. cds-routing-handlersDecorator-based routing of CAP service handlers in TypeScriptfrom CAP
  5. cap-handler-frameworkConvention-based handler layer for CAP with draft lifecycle hooksfrom CAP
  6. cds-plugin-typescriptCDS build task compiling TypeScript sources during cds buildfrom CAP
  7. cds-hyper-app-serviceTyped class-based service layer over CAP ApplicationServicefrom CAP

Details

Sources5
npm registrydiscovered herechecked
The discovery passdiscovered herechecked
npm registry, cds2typesversion, releases, installschecked
github.com/git+ssh://git@github.com/mrbandler/cds2types.gittree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
declared for^6.3.1
latestv3.0.1
first release
releases and cadence39, ~7d median
discovered vianpm registry, The discovery pass
first seen in the atlas
ecosystem and domaincap, developer-experience
Flavors1
Node.js
“npm install cds2types --save-dev” — mrbandler/cds2types — READMEchecked
Contributors3

From the repository’s contributor list, .

History in the atlas5
  1. The README read today opens with a caution notice from its maintainer: the project is not maintained anymore, and it points readers to capire's TypeScript page instead. Deprecated is the state that matches that sentence — not to start with it any more — rather than retired, which would say the maintainer had ended it; nothing in the notice says that, and it carries no date, so none is recorded.
  2. The edge carried no sentence. It now says what the tool produces and that it says nothing about the arrangement of the code around it. Whether this edge belongs on typescript-patterns at all is an open editorial question recorded with the capability's review: generating types from a model is the typing concern, and this pass does not move the edge.
  3. Typed cds-plugin by placement, which defaults every candidate to that. It is not one.
  4. Generates TypeScript interfaces from a CDS model at the command line, from before @cap-js/cds-typer existed.
  5. First seen.
For your agent
Ref
artifact:mrbandler-cds2types
JSON
/artifacts/mrbandler-cds2types.json
MCP
Connecting an agent