{"_id":"@adysre/rules-renderer","name":"@adysre/rules-renderer","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@adysre/rules-renderer","version":"0.1.0","type":"module","description":"Turns an ADYSRE rule AST into readable language. Generated from the tree, never parsed back into it.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/abhisheksahu093/Adysre.git","directory":"packages/rules-renderer"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./package.json":"./package.json"},"main":"./dist/index.js","types":"./dist/index.d.ts","devDependencies":{"@types/node":"^20.16.10","tsx":"^4.19.1","typescript":"^5.6.3","@adysre/config":"0.1.0"},"dependencies":{"@adysre/rules-core":"0.1.0","@adysre/rules-types":"0.1.0"},"keywords":["rules-engine","business-rules","rule-builder","json-logic","decision-engine","typescript"],"engines":{"node":">=20.0.0"},"sideEffects":false,"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p tsconfig.build.json && node ../config/scripts/fix-declarations.mjs","lint":"eslint src","typecheck":"tsc --noEmit","test":"tsx --test 'src/**/*.test.ts'","clean":"rm -rf dist .turbo tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo"},"_id":"@adysre/rules-renderer@0.1.0","bugs":{"url":"https://github.com/abhisheksahu093/Adysre/issues"},"homepage":"https://github.com/abhisheksahu093/Adysre#readme","_integrity":"sha512-sqN4yT0cCCfTvOjQ33nrOs1ikgwilkPtTFBkg/ei6Rc9OHiAvO33o3ORUR0kPKDyjYW1JtENLlNYasPAky1aBg==","_resolved":"/private/var/folders/xx/vrjl61fs7dlb3dhyq5_lgzkm0000gn/T/018471c8ae8907d333dc6926775feb63/adysre-rules-renderer-0.1.0.tgz","_from":"file:adysre-rules-renderer-0.1.0.tgz","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-sqN4yT0cCCfTvOjQ33nrOs1ikgwilkPtTFBkg/ei6Rc9OHiAvO33o3ORUR0kPKDyjYW1JtENLlNYasPAky1aBg==","shasum":"ea58684b27ab32ca0de972682d9ef5e930b327d0","tarball":"https://registry.npmjs.org/@adysre/rules-renderer/-/rules-renderer-0.1.0.tgz","fileCount":26,"unpackedSize":62244,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCc3nCdrMrIcXtSwHugQoPS0HUAFJPFThO3A2WmLylKWwIhAPF8QxVBHjEL+hWibak5Od+hzE2BGerD+A5bEoXlIN98"}]},"_npmUser":{"name":"adysre","email":"abhisheksahu093@gmail.com"},"directories":{},"maintainers":[{"name":"adysre","email":"abhisheksahu093@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rules-renderer_0.1.0_1785148603832_0.7618980031442433"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-27T10:36:43.581Z","0.1.0":"2026-07-27T10:36:43.969Z","modified":"2026-07-27T10:36:44.238Z"},"maintainers":[{"name":"adysre","email":"abhisheksahu093@gmail.com"}],"description":"Turns an ADYSRE rule AST into readable language. Generated from the tree, never parsed back into it.","homepage":"https://github.com/abhisheksahu093/Adysre#readme","keywords":["rules-engine","business-rules","rule-builder","json-logic","decision-engine","typescript"],"repository":{"type":"git","url":"git+https://github.com/abhisheksahu093/Adysre.git","directory":"packages/rules-renderer"},"bugs":{"url":"https://github.com/abhisheksahu093/Adysre/issues"},"license":"MIT","readme":"# @adysre/rules-renderer\n\nA rule, in language a person can check.\n\n```ts\nimport { describeRule } from '@adysre/rules-renderer';\nimport { builtinPlugins, createRegistry } from '@adysre/rules-core';\n\ndescribeRule(document, { plugins: createRegistry(builtinPlugins), locale: 'en-GB' }).text;\n```\n\n```\nLarge orders from new customers need approval\nWhen all of these are true:\n  - order total is greater than 1,000\n  - any of these are true:\n    - customer tier is \"new\"\n    - order placed at is before today\nThen reject order total\n```\n\n**One direction only.** The AST is generated INTO prose and never parsed back\nout of it. A builder that also read prose would be two authorities on the same\nrule, and the one that loses is always the tree, because prose is what people\nedit.\n\n**Structure first, text second.** `describeRule` returns lines of typed\nsegments; `.text` is a projection of them. A string is enough for a tooltip and\nuseless for a builder that highlights the field being edited or a debugger that\ncolours the condition that decided a verdict, and neither can be recovered from\nprose afterwards.\n\n```ts\ndescribeCondition(node, { plugins });\n// [ { type: 'field', text: 'order total', path: 'order.total' },\n//   { type: 'text',  text: ' is greater than ' },\n//   { type: 'value', text: '1,000', value: 1000 } ]\n```\n\n**The operator writes its own sentence.** `toText` lives on the plugin, so this\npackage holds no second implementation of the operator set to keep in step with\nthe first. What lives here is everything the plugins deliberately do not know:\nconnective words, value formatting, field labels, and the shape of the outline.\n\n## What is here\n\n| Module | Purpose |\n| --- | --- |\n| `render` | `describeRule`, `describeNode`, `describeCondition`, `toPlainText` |\n| `segments` | The typed sentence, and the marker trick that recovers it from a plugin's string |\n| `format` | Numbers, dates and lists as a reader expects them, for a given locale |\n| `phrases` | Every English word the renderer uses, in one replaceable record |\n| `plugin` | `createNrlRenderer`, so a host can register it under the `nrl` format |\n\n## Localising\n\nPhrases are data, so a locale is a `phrases` object rather than a fork:\n\n```ts\ndescribeRule(document, {\n  plugins,\n  locale: 'de-DE',\n  phrases: { when: 'Wenn {conditions}', all: 'alles davon zutrifft:' },\n  fields: { 'order.total': 'Bestellwert' },\n  operatorText: (id, left, args) => (id === 'greaterThan' ? `${left} groesser als ${args[0]} ist` : undefined),\n});\n```\n\n`operatorText` receives markers rather than text and returns a template with\nthem still in it, so the operands stay identifiable through a translation.\n\nSee [`documents/RULES_ENGINE.md`](../../documents/RULES_ENGINE.md).\n","readmeFilename":"README.md","_rev":"1-49f4f114f431bd744f8a545dc98e22a4"}