Registry / http-networking / odata-v4-parser

odata-v4-parser

JSON →
library0.1.29jsnpmunverified

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.

npm install odata-v4-parser
INSTALL
IMPORT
SIG · ODATA-V4-PARSER
O
odata-v4-parser
http-networkingjavascriptv0.1.29
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parser
const parser = require('odata-v4-parser');
import parser from 'odata-v4-parser'
The package is CommonJS-first and effectively abandoned. Direct `require` is the intended import pattern for v0.1.29.
parser.parse
const parser = require('odata-v4-parser'); const ast = parser.parse('$filter=...');
import { parse } from 'odata-v4-parser'
The `parse` method is accessed directly from the default-exported parser object, handling full OData URI segments.
parser.filter
const parser = require('odata-v4-parser'); const filterAst = parser.filter('Title eq \'Article1\'');
import { filter } from 'odata-v4-parser'
The `filter` method provides a specific entry point for parsing $filter expressions, as shown in the package's GitHub README.

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.");
Debug
Known issues
breakingThe `odata-v4-parser` package is effectively abandoned, with its last publish dating back several years. This means it lacks updates for new OData v4 specification features, compatibility with recent Node.js versions, and critical security patches.
fix
Migrate to an actively maintained OData parser library, such as `@odata/parser` or a more recent community fork like `@jwstott/odata-v4-parser` if robust OData parsing is critical for your application.
affects: >=0.1.29
gotchaThis package was developed in a CommonJS-first era. Attempting to use ESM `import` statements will result in runtime errors in modern Node.js environments configured for ESM, or if `type: module` is set in `package.json`.
fix
Always use `const parser = require('odata-v4-parser');` for importing the library in environments where it is still supported. For ESM projects, consider a modern alternative.
affects: >=0.1.0
gotchaDue to its abandoned status, `odata-v4-parser` may contain unfixed security vulnerabilities, including potential regex denial-of-service (ReDoS) attacks or other input-related exploits common in parsing libraries.
fix
Avoid using this library in production environments where security is a concern. If unavoidable, strictly sanitize all OData query inputs before passing them to the parser.
affects: >=0.1.0
gotchaThe internal Abstract Syntax Tree (AST) structure generated by `odata-v4-parser` is specific to this legacy version and may differ significantly from ASTs generated by other OData parsers or newer versions. There is no official, comprehensive documentation for the AST structure.
fix
Thoroughly inspect the generated AST by logging it and write extensive unit tests if you rely on its specific structure. Be prepared for manual migration if switching to a different parser.
affects: >=0.1.0
Errors
Common errors & fixes
require is not defined in ESM module scope
Attempting to use `require()` in an ES module (`.mjs` file or `type: "module"` in `package.json`).
fix
Change your module to CommonJS (`.cjs` file or remove `type: "module"`) or use a tool like `createRequire` for legacy modules (not recommended for an abandoned package). Better yet, migrate to a modern OData parser that supports ESM.
TypeError: parser.filter is not a function
The `odata-v4-parser` object returned by `require` might not have the expected methods, or there's a misunderstanding of the API for this specific version.
fix
Ensure you are calling the methods on the correct `parser` object, as demonstrated in the quickstart. Inspect `console.log(parser)` to see its available properties. If the methods are truly missing, the library might not support the intended parsing action or the version is corrupted.
Error: Expected `(` or whitespace but `$` found.
The parser might not correctly handle certain valid OData v4 syntax or extended features due to its age and lack of updates, leading to unexpected parsing failures for seemingly correct queries.
fix
Simplify your OData query string to isolate the problematic part. Refer to the OData v4 specification and cross-reference with known limitations of older parsers. This package may not support all aspects of the full OData v4 grammar.
Upgrade
Version history
0.1.29latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
odata-v4-parser — npm install odata-v4-parser · libregistry