CDS pluginCDS plugintypeInstalls into a CAP project and extends the runtime. CAP loads it through cds.requires or the plugin hook.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 →

@neoimpulse/cap-js-restore-model-defined-types

A CAP plugin that casts values back to the types the CDS model declares after a READ, for the entities you name, where the database driver returned them as strings.

A cds.Decimal that arrives as a string is a familiar surprise, and the usual fix is a conversion in every handler that touches it. This does it once, on READ, for the entities you name.

Facts

Latestv1.0.2ReleasedLast pushLicenceApache-2.0

Where it sits

Lives in
Provides
Database connectorsCAPDatabase connectorscapabilityConnecting an application’s data model and queries to a database, including the differences in supported queries, types and schema management between database implementations. Changing an existing schema belongs to [schema evolution](capability:schema-evolution).
Flavors
Node.jsfrom its runtime
Requires
@sap/cds≥ 9@sap/cdsartifactThe peer range, as published.

Who is behind it

neoimpulse GmbHneoimpulse GmbHOrganisationMaintains this
In the atlas: maintains 7
@neoimpulseGmbH
maintainer

Before choosing this

Conditions

LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
  • § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
  • § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
  • § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
SAP Developer License Agreement 3.2 CAP →

Also, from Database connectors§ 1: The connector itself does not decide the licence boundary. Section 1 makes the destination and purpose of extraction relevant, including the scoped exception for interoperability with an SAP product.

What it declares

Every artifact

Type
CDS plugin
Origin
Independently maintained
Runtime
Node.js

As a CDS plugin

Declared for
>=9
Distributed through
npm

Connections1

@neoimpulse/cap-js-restore-model-defined-types connections@neoimpulse/cap-js-restore-model-defined-typesPROVIDES→ provides1provides authoredDatabase connectors

Install

npm add @neoimpulse/cap-js-restore-model-defined-types

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

README

quoted from neoimpulseGmbH/cap-js-restore-model-defined-types under Apache-2.0, read
neoimpulseGmbH/cap-js-restore-model-defined-types/README.mdOn GitHub

CAP.js Restore Model Defined Types Plugin

This plugin for the SAP Cloud Application Programming Model (CAP) automatically restores model-defined types for numeric and structured data in READ operations. It ensures that data returned from the database matches the types defined in your CDS model.

Features

  • Automatically converts string representations of numbers back to their proper types (cds.Decimal → float, cds.Integer → int)
  • Handles nested structures including Associations and Compositions
  • Processes structured types (cds.Structured) recursively
  • Works with both single entities and arrays of entities
  • Applies to all READ operations automatically

Installation

To install the plugin, add it to your CAP project:

npm install @neoimpulse/cap-js-restore-model-defined-types

Usage

The plugin works automatically once installed, but you can configure which entities should be processed.

Basic Usage (All Entities)

By default, the plugin processes all entities. No additional configuration required.

Configuration Options

You can configure the plugin in your package.json or .cdsrc.json:

{
  "cds": {
    "requires": {
      "cap-js-restore-model-defined-types": {
        "enabled": true,
        "entities": "*",
        "exclude": [],
        "annotation": "@restoreTypes"
      }
    }
  }
}
Configuration Properties
  • enabled (boolean, default: true): Enable or disable the plugin
  • entities (string|array, default: "*"): Which entities to process
    • "*": Process all entities
    • ["EntityA", "EntityB"]: Process specific entities by name
    • "Book*": Process entities matching pattern (supports glob-like patterns)
    • "annotation": Only process entities with the specified annotation
  • exclude (array, default: []): Entity names to explicitly exclude
  • annotation (string, default: "@restoreTypes"): Custom annotation to enable per entity
Configuration Examples
1. Process All Entities (Default)
{
  "cds": {
    "requires": {
      "cap-js-restore-model-defined-types": {}
    }
  }
}
2. Process Specific Entities
{
  "cds": {
    "requires": {
      "cap-js-restore-model-defined-types": {
        "entities": ["Books", "Authors", "Orders"]
      }
    }
  }
}
3. Process Entities with Pattern
{
  "cds": {
    "requires": {
      "cap-js-restore-model-defined-types": {
        "entities": "my.bookshop.*"
      }
    }
  }
}
4. Use Annotation-Based Configuration
{
  "cds": {
    "requires": {
      "cap-js-restore-model-defined-types": {
        "entities": "annotation"
      }
    }
  }
}

Then annotate your entities:

namespace my.bookshop;

entity Books @restoreTypes {
    key ID : Integer;
    title : String;
    price : Decimal(10,2);
    pages : Integer;
}

entity Authors {
    key ID : Integer;
    name : String;
    // This entity will NOT be processed
}
5. Exclude Specific Entities
{
  "cds": {
    "requires": {
      "cap-js-restore-model-defined-types": {
        "entities": "*",
        "exclude": ["TechnicalEntity", "LogEntry"]
      }
    }
  }
}
Example Model
namespace my.bookshop;

entity Books {
    key ID : Integer;
    title : String;
    price : Decimal(10,2);
    pages : Integer;
    author : Association to Authors;
}

entity Authors {
    key ID : Integer;
    name : String;
    age : Integer;
    books : Composition of many Books on books.author = $self;
}
What It Does

When you perform READ operations, the plugin ensures that:

  • price values are returned as proper floating-point numbers (not strings)
  • pages and age values are returned as integers (not strings)
  • Associated and composed entities are processed recursively
  • Structured types maintain their proper data types

How It Works

The plugin hooks into all READ operations and processes the results to restore the correct data types based on your CDS model definitions. It:

  1. Scans each attribute in the returned data
  2. Checks the corresponding CDS model definition
  3. Converts string representations back to proper numeric types
  4. Recursively processes nested structures (Associations, Compositions, Structured types)

The conversion happens automatically for:

  • cds.Decimal: String values are converted to floating-point numbers using parseFloat()
  • cds.Integer: String values are converted to integers using parseInt()
  • cds.Association: Nested associated entities are processed recursively
  • cds.Composition: Nested composed entities are processed recursively
  • cds.Structured: Structured types are processed recursively

Technical Details

The plugin adds a restoreModelDefinedTypes method to each Application Service and hooks it into the after READ event handler. This ensures that all data returned from READ operations has the correct types according to your CDS model.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions, please open an issue in the GitHub repository.```

License

This project is licensed under the Apache License 2.0. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

Thanks to the SAP CAP community for their support and contributions.

Apache-2.0, read

History

Latest

v1.0.2

Notes
Bug Fixes
  1. v1.0.1

    Notes
    Bug Fixes
    • update dependency version ranges (48d70b9)
  2. v1.0.0

    Notes
    Bug Fixes
57downloads per week, npm
Weekly downloads for @neoimpulse/cap-js-restore-model-defined-types26 complete calendar weeks from 2026-04-27 to 2026-10-25; the latest total is 57.27 Apr – 3 May: 2044 May – 10 May: 6211 May – 17 May: 6818 May – 24 May: 5725 May – 31 May: 691 Jun – 7 Jun: 288 Jun – 14 Jun: 5415 Jun – 21 Jun: 4922 Jun – 28 Jun: 7329 Jun – 5 Jul: 636 Jul – 12 Jul: 3513 Jul – 19 Jul: 3120 Jul – 26 Jul: 8927 Jul – 2 Aug: 513 Aug – 9 Aug: 5810 Aug – 16 Aug: 4917 Aug – 23 Aug: 2424 Aug – 30 Aug: 4431 Aug – 6 Sept: 547 Sept – 13 Sept: 5314 Sept – 20 Sept: 3721 Sept – 27 Sept: 8928 Sept – 4 Oct: 565 Oct – 11 Oct: 7712 Oct – 18 Oct: 7319 Oct – 25 Oct: 57
Database connectors
  1. SAP ASE ServiceManaged SAP ASE databases on BTP for Java applicationsfrom BTP/BAIP
  2. SAP HANA CloudManaged SAP HANA database service on BTPfrom BTP/BAIP
  3. SAP HANA Service (SAP Regions) for SAP BTPManaged SAP HANA 2.0 databases in fixed sizes on SAP BTPfrom BTP/BAIP
  4. PostgreSQL on SAP BTP, hyperscaler optionManaged PostgreSQL from the hyperscaler via a BTP service bindingfrom BTP/BAIP
  5. com.sap.cds:cds-feature-hanaSAP HANA Cloud datasource for CAP Java applicationsfrom CAP
  6. com.sap.cds:cds-feature-jdbcJDBC runtime for H2 and SQLite in CAP Javafrom CAP
  7. com.sap.cds:cds-feature-postgresqlPostgreSQL datasource for CAP Java applicationsfrom CAP
  8. com.sap.cds:cds-services-bomMaven bill of materials pinning CAP Java module versionsfrom CAP
  9. @cap-js/db-serviceBase service shared by CAP's SQLite, PostgreSQL and HANA servicesfrom CAP
  10. @cap-js/hanaSAP HANA database service for CAPfrom CAP
  11. @cap-js/postgresPostgreSQL database service for CAPfrom CAP
  12. @cap-js/sqliteSQLite database service for CAP, in memory during developmentfrom CAP
  13. cap-postgres-btp-connectivityTunnels CAP Node.js to a private PostgreSQL via Cloud Connectorfrom CAP
  14. cds-mongodbMongoDB as a CAP database service through Mongoosefrom CAP
  15. @cds-pgroll/postgresCLI for DROP and RENAME schema changes beside @cap-js/postgresfrom CAP
  16. hdbPure JavaScript SAP HANA driver for Node.jsfrom BTP/BAIP
  17. @quadrio/cds-db2DB2 adapter for CDSfrom CAP
  18. @sap/cds-hanaDatabase adapter for SAP HANA in CAPfrom CAP
  19. @sap/cdsCAP Node.js runtimefrom CAP
  20. @sap/hana-clientSAP's Node.js driver for SAP HANAfrom BTP/BAIP
  21. SAP HANASAP's relational database platform, on-premise and in HANA Cloudfrom BTP/BAIP
  22. SAP-samples/hana-hdbext-promisfied-examplePromise-based wrappers around the SAP HANA client librariesfrom BTP/BAIP
  23. cds-pgPostgreSQL adapter for SAP CDS from the SAP Mentors communityfrom CAP
  24. cap-snowflakeCAP database adapter for Snowflake with OData V4 supportfrom CAP
  25. cds-mysqlMySQL and MariaDB database adapter for CAPfrom CAP

Details

Sources5
npm registrydiscovered here, cds-pluginchecked
npm registrydiscovered here, @cap-jschecked
npm registry, @neoimpulse/cap-js-restore-model-defined-typesversion, releases, installschecked
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
runtimesnode
declared for>=9
latestv1.0.2
first release
releases and cadence3, ~259d median
discovered vianpm registry · cds-plugin, npm registry · @cap-js
first seen in the atlas
ecosystem and domaincap, data-and-persistence
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:neoimpulse-cap-js-restore-model-defined-types
JSON
/artifacts/neoimpulse-cap-js-restore-model-defined-types.json
MCP
Connecting an agent