# @sap-ux/cds-annotation-parser

> Annotation Parser for CDS

Latest version **1.1.1** (published 2026-10-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @sap-ux/cds-annotation-parser
pnpm add @sap-ux/cds-annotation-parser
yarn add @sap-ux/cds-annotation-parser
bun add @sap-ux/cds-annotation-parser
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-10-16 |
| First published | 2024-01-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22.x |
| Dependencies | 5 |
| Unpacked size | 296.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 159 |
| Author | SAP SE |
| Maintainers | tqueck, kranthie.sap, sap_extncrepos, sap-ospo-admin, devinea |

## Links

- npm: https://www.npmjs.com/package/@sap-ux/cds-annotation-parser
- Repository: https://github.com/SAP/open-ux-tools
- npm.io page: https://npm.io/package/@sap-ux/cds-annotation-parser

## Dependencies (5)

- [chevrotain](https://npm.io/package/chevrotain.md) 7.1.1
- [@sap-ux/odata-entity-model](https://npm.io/package/@sap-ux/odata-entity-model.md) 1.0.1
- [@sap-ux/odata-vocabularies](https://npm.io/package/@sap-ux/odata-vocabularies.md) 1.1.3
- [@sap-ux/text-document-utils](https://npm.io/package/@sap-ux/text-document-utils.md) 1.0.4
- [@sap-ux/odata-annotation-core](https://npm.io/package/@sap-ux/odata-annotation-core.md) 1.0.4

## Recent versions

- 1.1.1 (latest) — 2026-10-16
- 1.1.0 — 2026-09-22
- 1.0.7 — 2026-08-25
- 1.0.6 — 2026-08-06
- 1.0.5 — 2026-07-22
- 1.0.4 — 2026-07-03
- 1.0.3 — 2026-07-03
- 1.0.2 — 2026-06-23
- 1.0.1 — 2026-06-04
- 1.0.0 — 2026-05-30
- 0.3.1 — 2026-05-20
- 0.3.0 — 2026-05-15
- 0.2.36 — 2026-04-30
- 0.2.35 — 2026-03-30
- 0.2.34 — 2026-03-16
- … 47 more at https://npm.io/package/@sap-ux/cds-annotation-parser/versions

## README

[![Changelog](https://img.shields.io/badge/changelog-8A2BE2)](https://github.com/SAP/open-ux-tools/blob/main/packages/cds-annotation-parser/CHANGELOG.md) [![Github repo](https://img.shields.io/badge/github-repo-blue)](https://github.com/SAP/open-ux-tools/tree/main/packages/cds-annotation-parser)

# [`@sap-ux/cds-annotation-parser`](https://github.com/SAP/open-ux-tools/tree/main/packages/cds-annotation-parser)

## Installation
Npm
`npm install --save @sap-ux/cds-annotation-parser`

Yarn
`yarn add @sap-ux/cds-annotation-parser`

Pnpm
`pnpm add @sap-ux/cds-annotation-parser`

## Usage
Examples of how to use CDS annotation parsing and abstract syntax tree (AST) node search functions.

```Typescript
import { parse, findAnnotationNode, getAstNodes, getNode } from '@sap-ux/cds-annotation-parser';

const ast = parse(`
  UI.LineItem #table1 : [
    {
      $type: 'UI.DataField',
      value: some.path,
      Label: 'Sample column'
    }  
  ]';
`);

if (ast !== undefined) {
    // Expected pathToLabel: "/value/items/0/properties/2/value"
    const pathToLabel = findAnnotationNode(ast, {
        position: { line: 5, character: 15 },
        includeDelimiterCharacters: true
    });
    
    // An array of nodes matching each segment of the path.
    const nodes = getAstNodes(ast, pathToLabel);
    const serializedNodes = nodes.map((n) =>
        Array.isArray(n) ? '<array of child elements>' : typeof n === 'object' ? `Node of type '${n.type}'` : n
    );
    /* Expected serializedNodes:
    [
        "Node of type 'collection'",
        "<array of child elements>",
        "Node of type 'record'",
        "<array of child elements>",
        "Node of type 'record-property'",
        "Node of type 'string'",
    ]
    */

    const termNode = getNode(ast, '/term');
    if (termNode.type === 'path') {
        // expected termName: "UI.LineItem"
        const termName = termNode.value;
    }

    const qualifierNode = getNode(ast, '/qualifier');
    if (qualifierNode.type === 'qualifier') {
        // expected qualifier: "table1"
        const qualifier = qualifierNode.value;
    }

    const propertyValueNode = getNode(ast, '/value/items/0/properties/1/value');
    if (propertyValueNode.type === 'path') {
        // expected value: "some.path"
        const value = propertyValueNode.value;
    }
}

```

## Keywords
OData annotations CAP CDS

---
_Source: https://npm.io/package/@sap-ux/cds-annotation-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
