featws-transpiler
raw JSON → 0.7.4-rc1 verified Fri May 01 auth: no javascript
A transpiler that converts FeatWS files (features.json, parameters.json, rules.featws) into GRL (Grule Rule Language) format for use with the Grule rule engine (https://github.com/hyperjumptech/grule-rule-engine). Current version is 0.7.4-rc1 (release candidate) with frequent releases. Supports special markers (# for features, $ for parameters, @ for groups), group definitions, JSON rules, and extended feature format. Key differentiator: designed specifically for Banco do Brasil's FeatWS ecosystem, not a general-purpose transpiler.
Common errors
error Error: Cannot find module 'featws-transpiler' ↓
cause Package not installed or ESM import not configured correctly.
fix
Run 'npm install featws-transpiler'. For ESM, ensure package.json has 'type': 'module'.
error TypeError: features is not iterable ↓
cause features parameter passed as object instead of array.
fix
Ensure features.json is an array of objects, not a single object. Use JSON.parse(file) correctly.
error SyntaxError: Unexpected token '#' in rules.featws ↓
cause The # marker is not being recognized; may be due to incorrect context or missing feature definition.
fix
Declare the feature in features.json. Use extended format if needed. Ensure # is not escaped.
Warnings
breaking v0.7.0-rc1 changed parameters in transpile() call ↓
fix Refer to the changelog: resolve parameter renamed or reordered. Check the new signature in the source.
gotcha Default feature type is 'boolean' if not declared in features.json ↓
fix Always declare non-boolean features in features.json with explicit type.
gotcha Special markers #, $, @ are mandatory in rules.featws ↓
fix Use # for features, $ for parameters, @ for groups. Otherwise transpiler may fail silently.
deprecated v0.5.0-rc1 renamed 'resolve' parameter to something else ↓
fix Update your code to use the new parameter name (e.g., 'resolver' or similar). Check release notes.
Install
npm install featws-transpiler yarn add featws-transpiler pnpm add featws-transpiler Imports
- transpile wrong
const transpile = require('featws-transpiler')correctimport { transpile } from 'featws-transpiler' - FeaturesFile wrong
import FeaturesFile from 'featws-transpiler'correctimport { FeaturesFile } from 'featws-transpiler' - RulesFile wrong
import { RuleFile } from 'featws-transpiler'correctimport { RulesFile } from 'featws-transpiler'
Quickstart
import { transpile } from 'featws-transpiler';
import { readFileSync } from 'fs';
const features = JSON.parse(readFileSync('features.json', 'utf8'));
const parameters = JSON.parse(readFileSync('parameters.json', 'utf8'));
const rules = readFileSync('rules.featws', 'utf8');
const result = transpile(features, parameters, rules);
console.log(result.grlContent);