/odata-v4-parser

OData(V4) URI Parser

Primary LanguageTypeScriptMIT LicenseMIT

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")