Socket
Socket
Sign inDemoInstall

@lanetix/formula-fields-parser

Package Overview
Dependencies
Maintainers
30
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lanetix/formula-fields-parser

Parses OData with LX aliases and generates query string options.


Version published
Weekly downloads
0
Maintainers
30
Weekly downloads
 
Created
Source

js-standard-style codecov

formula-fields-parser

This repository contains the WIP Formula Fields Parser. Currently implemented:

  1. Lexer
  2. Parser
  3. Visitor
  4. Symbol Table
  5. Semantic Analysis

Exports

  • Parser - The formula fields parser
  • visit - The formula fields AST Visitor
  • errors - Built in errors for use with the visitor
  • validate - The formula fields semantic analysis

default

The default export is a convenience function that takes the text of a formula, parses it, and runs semantic validation. It takes the following parameters:

  • formulaText - The formula text
  • recordType - Optional. The type definition of the record the formula is being applied to. If not provided, all fields are assumed to be semantically valid
  • recordTypeName - Optional, but required if recordType is provided. The human friendly name of recordType. If recordType is provided and this is not, all fields are assumed to be semantically valid

It returns an object with the following properties:

  • ast - The formula abstract syntax tree. This may be undefined if there are errors during the lexing or parsing phases.
  • errors - An array of any lex, parse, or semantic errors that occurred when validating the formula.

All errors are guaranteed to have the following properties, although some may have additional:

  • name - The name of the error type (e.g. MismatchedTokenException)
  • message - The error message
  • location - The location where the error occurred
Example
import parseAndValidate from '@lanetix/formula-fields-parser'

// fields *are not* validated
const { ast, errors } = parseAndValidate('CONCAT($first_name, $last_name)')

// fields are validated
const recordType = ...     // get from records service if not available
const recordTypeName = ... // get from records service if not available
const { ast, errors } = parseAndValidate('CONCAT($first_name, $last_name)', recordType, recordTypeName)

Keywords

FAQs

Package last updated on 24 Jan 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc