{"_id":"@atari-engine/core","name":"@atari-engine/core","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@atari-engine/core","version":"0.1.0","description":"Lightweight rule evaluation engine for conditions and feature flags","author":{"name":"JammyTheDreamer"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jammythedreamer/atari-engine.git"},"homepage":"https://github.com/jammythedreamer/atari-engine","bugs":{"url":"https://github.com/jammythedreamer/atari-engine/issues"},"keywords":["rules","engine","evaluation","conditions","feature-flags","validation"],"type":"module","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"sideEffects":false,"engines":{"node":">=18"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","test":"vitest run","prepublishOnly":"npm run build && npm run test"},"devDependencies":{"@biomejs/biome":"^1.9.4","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^2.1.6"},"_id":"@atari-engine/core@0.1.0","gitHead":"f3878d22b6d3ee866d8363110a26f422139a5cb0","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-RQ2SvGi7CbGOVQ9MSlh168RGU4zfy8Rzy76Pnpjb+GN5qXoMi4ZSfKUDeKDF526cPmVa67gZncrAm9/QWk0X7A==","shasum":"0bc6d18a8a624d76dfdf5430b2684f60ef2f121f","tarball":"https://registry.npmjs.org/@atari-engine/core/-/core-0.1.0.tgz","fileCount":7,"unpackedSize":39845,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDZrMMWY7L4hHiNFjY0KHzR9YU316z5nCdlLOlaVBOzvwIgbiFlACREXUFsqWYEcUb1EbZg8EVCSA72q/KrN29RYDc="}]},"_npmUser":{"name":"jammythedreamer","email":"jammythedreamer@gmail.com"},"directories":{},"maintainers":[{"name":"jammythedreamer","email":"jammythedreamer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_0.1.0_1771909916645_0.27272999513270935"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-24T05:11:56.528Z","0.1.0":"2026-02-24T05:11:56.795Z","modified":"2026-02-24T05:11:57.071Z"},"maintainers":[{"name":"jammythedreamer","email":"jammythedreamer@gmail.com"}],"description":"Lightweight rule evaluation engine for conditions and feature flags","homepage":"https://github.com/jammythedreamer/atari-engine","keywords":["rules","engine","evaluation","conditions","feature-flags","validation"],"repository":{"type":"git","url":"git+https://github.com/jammythedreamer/atari-engine.git"},"author":{"name":"JammyTheDreamer"},"bugs":{"url":"https://github.com/jammythedreamer/atari-engine/issues"},"license":"MIT","readme":"# @atari-engine/core\n\nLightweight rule evaluation engine for conditions, feature flags, and user targeting. Define rules with AND/OR groups, validate structure, and evaluate against context (e.g. user properties). Zero runtime dependencies.\n\n## Installation\n\n```bash\nnpm install @atari-engine/core\n# or\npnpm add @atari-engine/core\n# or\nyarn add @atari-engine/core\n```\n\n## Quick Start\n\n```ts\nimport {\n  evaluate,\n  validate,\n  FIELD_TYPES,\n  LOGICAL_OPERATORS,\n  OPERATORS,\n  type RuleGroup,\n  type UserProperties,\n} from \"@atari-engine/core\";\n\nconst rule: RuleGroup = {\n  logicalOperator: LOGICAL_OPERATORS.AND,\n  conditions: [\n    {\n      fieldName: \"age\",\n      fieldType: FIELD_TYPES.NUMBER,\n      operator: OPERATORS.GREATER_THAN_OR_EQUAL_TO,\n      value: 18,\n    },\n    {\n      fieldName: \"country\",\n      fieldType: FIELD_TYPES.STRING,\n      operator: OPERATORS.IN,\n      value: [\"KR\", \"JP\", \"US\"],\n    },\n  ],\n};\n\nconst validation = validate(rule);\nif (!validation.valid) {\n  console.error(validation.errors);\n  process.exit(1);\n}\n\nconst user: UserProperties = { age: 25, country: \"KR\" };\nconst matched = evaluate(rule, user);\nconsole.log(matched); // true\n```\n\n## API Reference\n\n### `evaluate(rule, context, options?)`\n\nEvaluates a rule or rule group against a context object. Returns `true` if the rule matches, `false` otherwise. Never throws; use `options.onError` to receive validation/runtime errors.\n\n- **rule**: `Rule | RuleGroup` — A single rule or nested AND/OR group.\n- **context**: `UserProperties` — Key-value context (e.g. user properties). Supports dot notation for nested keys (e.g. `\"address.city\"`).\n- **options.onError**: `(error: AtariError) => void` — Optional callback for errors (e.g. missing field, type mismatch).\n\n### `validate(rule)`\n\nValidates the structure and types of a rule. Returns `{ valid: true }` or `{ valid: false, errors: ValidationError[] }`.\n\n### Types\n\n- **Rule**: `{ fieldName, fieldType, operator, value }` — Single condition.\n- **RuleGroup**: `{ logicalOperator: \"AND\" | \"OR\", conditions: (Rule | RuleGroup)[] }` — Nested conditions.\n- **FieldType**: `\"string\" | \"number\" | \"boolean\" | \"date\" | \"date_unix\"`.\n- **Operator**: Equality (`==`, `!=`), comparison (`>`, `>=`, `<`, `<=`), `in` / `not_in`, string (`contains`, `starts_with`, `ends_with`), `exists` / `not_exists`.\n\n### Constants\n\n- **FIELD_TYPES**, **OPERATORS**, **LOGICAL_OPERATORS** — Use these when building rules.\n- **OPERATOR_FIELD_TYPE_MATRIX** — Map of which operators are allowed per field type.\n- **isOperatorAllowedForFieldType(operator, fieldType)** — Helper for UI/validation.\n\n### Errors\n\n- **AtariError** — Custom error class; `code` has `id` and `category`, `message` for description.\n- **ATARI_ERROR_CODES** — `FIELD_NOT_FOUND`, `TYPE_MISMATCH`, `INVALID_OPERATOR`, `INVALID_RULE`, `EMPTY_CONDITIONS`.\n\n## License\n\nMIT © JammyTheDreamer\n","readmeFilename":"README.md","_rev":"1-d1f4d1ff5da75a8ab00d79d311591896"}