{"id":42770,"library":"formulex","title":"Formulex","description":"Formulex is a lightweight, extensible library (v0.0.60, pre-1.0, rapid releases) that parses user-defined formulas (e.g., `{Field 1} + {Field 2} * 2`) into SQL expressions or executable JavaScript functions, with built-in AST support. It targets low-code platforms, dashboards, and dynamic logic engines. Key differentiators: built-in type casting for `dropdown`/`checkboxes` fields with id↔name mapping via CTE, minimal dependencies (only luxon for dates), and support for custom field mappings. Note: requires Node.js >= 22.11 < 23; work-in-progress, expect breaking changes.","status":"active","version":"0.0.60","language":"javascript","source_language":"en","source_url":"https://github.com/bpium/formulex","tags":["javascript","typescript"],"install":[{"cmd":"npm install formulex","lang":"bash","label":"npm"},{"cmd":"yarn add formulex","lang":"bash","label":"yarn"},{"cmd":"pnpm add formulex","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Date handling for field types like date","package":"luxon","optional":false}],"imports":[{"note":"ESM-only; CommonJS require() will not work as the package does not export a default. TypeScript types included.","wrong":"const Parser = require('formulex')","symbol":"Parser","correct":"import { Parser } from 'formulex'"}],"quickstart":{"code":"import { Parser } from 'formulex';\n\nconst fields = [\n  { id: '1', name: 'Field 1', type: 'number' },\n  { id: '2', name: 'Field 2', type: 'number' },\n];\n\nconst expression = '{Field_1} + {Field_2} * 2';\n\nconst parser = new Parser(expression, fields);\n\nconst sql = parser.toSqlWithVariables();\n// => (field_1 + (field_2 * 2))\n\nconst jsFormula = parser.toJs();\n// => VARIABLES[\"1\"] + (VARIABLES[\"2\"] * 2)\n\nconst result = parser.runJs(jsFormula, { 1: 10, 2: 5 });\n// => 20\n\nconsole.log({ sql, jsFormula, result });","lang":"typescript","description":"Parses a formula using Parser, generates SQL and JS, then evaluates JS with variable values."},"warnings":[{"fix":"Replace spaces with underscores in field name references within formulas.","message":"Field names in formulas use underscores instead of spaces (e.g., {Field_1} not {Field 1}).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure Node.js version satisfies range (e.g., use nvm to switch to v22.11+).","message":"Node.js version requirement: >= 22.11 < 23. May fail on older or newer Node versions.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Use ES import syntax: import { Parser } from 'formulex';","message":"ESM-only package; no CommonJS support. Using require() will throw an error.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Pin to specific version and test updates thoroughly.","message":"API may change without notice as package is pre-1.0 and marked as work-in-progress.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'-1.0':10 '1':21 '2':23,24 '22.11':81 '23':82 'ast':36 'break':88 'built':34,52 'built-in':33,51 'cast':55 'chang':89 'checkbox':58 'code':42 'cte':65 'custom':75 'dashboard':44 'date':71 'defin':17 'depend':67 'differenti':50 'dropdown':57 'dynam':46 'e.g':19 'engin':48 'execut':29 'expect':87 'express':27 'extens':6 'field':20,22,59,76 'formula':18 'formulex':1,2 'function':31 'id':61 'javascript':30,90 'key':49 'librari':7 'lightweight':5 'logic':47 'low':41 'low-cod':40 'luxon':69 'map':63,77 'minim':66 'name':62 'node.js':80 'note':78 'pars':14 'platform':43 'pre':9 'progress':86 'rapid':11 'releas':12 'requir':79 'sql':26 'support':37,73 'target':39 'type':54 'typescript':91 'user':16 'user-defin':15 'v0.0.60':8 'via':64 'work':84 'work-in-progress':83","created_at":"2026-06-05T16:56:34.845390+00:00","updated_at":"2026-06-05T16:56:34.845390+00:00","problems":[{"fix":"Add \"type\": \"module\" in package.json or use .mjs extension, and ensure Node >= 22.11.","cause":"Using import in a CommonJS environment or Node < 22.11.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Use import { Parser } from 'formulex' instead of require.","cause":"Likely using require('formulex') which does not export default.","error":"TypeError: formulex_1.Parser is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/bpium/formulex#readme","github":"https://github.com/bpium/formulex","docs":null,"changelog":null,"pypi":null,"npm":"formulex","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}