@odata/parser
TypeScript icon, indicating that this package has built-in type declarations

0.2.14 • Public • Published

OData(V4) URI Parser

npm (scoped) GitHub Workflow Status Codecov

OData v4 parser based on OASIS Standard OData v4 ABNF grammar

Usage - URI Parser

import { defaultParser } from "@odata/parser";
const ast = defaultParser.odataUri("/Categories(10)?$expand=A,C&$select=D,E")
// process it

Usage - OData QueryParam/Filter Builder

import { param, filter } from "@odata/parser";
param().top(1).filter(filter({ A: 1 }))
// => $top=1&$filter=A eq 1

filter with type

import { filter, literalValues } from "@odata/parser";

expect(filter({ A: 1 }).build())
    .toBe("A eq 1")
expect(filter({ A: literalValues.String(1) }).build())
    .toBe("A eq '1'")
expect(filter({ A: literalValues.Guid("253f842d-d739-41b8-ac8c-139ac7a9dd14") }).build())
    .toBe("A eq 253f842d-d739-41b8-ac8c-139ac7a9dd14")

CHANGELOG

LICENSE

Package Sidebar

Install

npm i @odata/parser

Weekly Downloads

3,884

Version

0.2.14

License

MIT

Unpacked Size

506 kB

Total Files

73

Last publish

Collaborators

  • suntao