OData v4 Parser

0.1.29 · abandoned · verified Sun Apr 19

The `odata-v4-parser` package provides a JavaScript parser for OData v4 URI query strings, converting them into an Abstract Syntax Tree (AST). This allows developers to programmatically interpret and act upon OData query parameters like `$filter`, `$orderby`, `$top`, and `$skip`. The package's current specified version, 0.1.29, reflects its last update several years ago, making it an effectively abandoned project. It was primarily designed for CommonJS environments and does not actively support modern JavaScript features or evolving OData specifications. While it ships with TypeScript type definitions, its long-term maintenance status and compatibility with contemporary Node.js versions are highly questionable. It differentiates itself by offering a direct parsing utility for OData v4 queries, but its lack of updates means it may not support all features of the OData v4 standard or address potential security concerns inherent in parsing external input.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates parsing OData $filter expressions and full OData URI query strings into an Abstract Syntax Tree (AST).

const parser = require('odata-v4-parser');

// Example 1: Parsing a simple $filter expression
const filterQuery = "$filter=Name eq 'John Doe' and Age gt 30";
try {
  const filterAst = parser.filter(filterQuery);
  console.log('Parsed Filter AST:', JSON.stringify(filterAst, null, 2));
} catch (e) {
  console.error(`Error parsing filter '${filterQuery}':`, e.message);
}

// Example 2: Parsing a full OData URI (assuming a 'parse' method is available)
const fullODataQuery = "$filter=Category/Name eq 'Books'&$orderby=Price desc&$top=5&$skip=10";
try {
  const fullAst = parser.parse(fullODataQuery);
  console.log('Parsed Full Query AST:', JSON.stringify(fullAst, null, 2));
} catch (e) {
  console.error(`Error parsing full query '${fullODataQuery}':`, e.message);
  console.log("Note: If 'parser.parse' is not available, you might need to parse sections individually.");
}

console.log("\nNote: The output AST structure depends on the internal implementation of this specific parser version.");

view raw JSON →