Socket
Book a DemoInstallSign in
Socket

@lanetix/odata-parser

Package Overview
Dependencies
Maintainers
27
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@lanetix/odata-parser

OData query string parser

unpublished
latest
Source
npmnpm
Version
9.0.0
Version published
Maintainers
27
Created
Source

OData query string parser for node.js based on pegjs.

Build Status

Installation

npm install odata-parser

Usage: parse()

var parser = require("odata-parser");

var ast = parser.parse("$top=10&$skip=5&$select=foo")

util.inspect(ast)

will result in:

{
  '$top': 10,
  '$skip': 5,
  '$select': [ 'foo' ]
}

Filters like:

parser.parse("$filter=Name eq 'John' and LastName lt 'Doe'")

results in:


{
    $filter: {
        type: 'and',
        left: {
            type: 'eq',
            left: {
                type: 'property',
                name: 'Name'
            },
            right: {
                type: 'literal',
                value: 'John'
            }
        },
        right: {
            type: 'lt',
            left: {
                type: 'property',
                name: 'LastName'
            },
            right: {
                type: 'literal',
                value: 'Doe'
            }
        }
    }
}

Using functions in filters

parser.parse("$filter=substringof('nginx', Servers)")

results in:

{
    $filter: {
        type: 'functioncall',
        func: 'substringof',
        args: [{
            type: 'literal',
            value: 'nginx'
        }, {
            type: 'property',
            name: 'Servers'
        }]
    }
}

Usage: stringify()

var mod = require("odata-parser");

var uri = `$filter=( nullable_string ne null and telephone_number eq 999999999 )&$select=name`

var originalAst = mod.parse(uri)
var remadeOdata = mod.stringify(originalAst)
var reParsedAst = mod.parse(remadeOdata)

console.log(remadeOdata)

will result in:

`$select=name&$filter=((nullable_string) ne (null)) and ((telephone_number) eq (999999999))`

assert passes as well:

assert.deepEqual(originalAst, reParsedAst)

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Keywords

odata

FAQs

Package last updated on 22 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts