@orkestrel/rater 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -27
- package/dist/src/core/index.cjs +238 -1292
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +469 -1092
- package/dist/src/core/index.d.ts +469 -1092
- package/dist/src/core/index.js +237 -1235
- package/dist/src/core/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
# @orkestrel/rater
|
|
2
2
|
|
|
3
|
-
A typed **rating
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`AggregateResult` — is a fresh object carrying a `trace` and accumulated
|
|
12
|
-
`errors`. Batch rating additionally supports per-program aggregate fields, an
|
|
13
|
-
optional partition key, and gated aggregate determinations, plus per-`Status`
|
|
14
|
-
tallies. Environment-agnostic — no I/O, no browser or server assumptions.
|
|
15
|
-
Part of the `@orkestrel` line.
|
|
3
|
+
A typed **quantitative rating layer** over [`@orkestrel/reason`](https://github.com/orkestrel/reason):
|
|
4
|
+
authored **lines** — each a plain reason `QuantitativeDefinition` joined to display
|
|
5
|
+
metadata — are rated against a **subject** (a plain data record) to produce a
|
|
6
|
+
`LineResult` per line (an `amount` plus its `Worksheet` audit trail) and one
|
|
7
|
+
`RatingResult` (every line's outcome plus a derived `total`). The caller decides
|
|
8
|
+
which lines to rate; `Rater` only evaluates what it is given. Rating never mutates
|
|
9
|
+
its inputs — every result is a fresh object. Environment-agnostic — no I/O, no
|
|
10
|
+
browser or server assumptions. Part of the `@orkestrel` line.
|
|
16
11
|
|
|
17
12
|
## Install
|
|
18
13
|
|
|
@@ -23,12 +18,12 @@ npm install @orkestrel/rater
|
|
|
23
18
|
## Requirements
|
|
24
19
|
|
|
25
20
|
- Node.js >= 24
|
|
26
|
-
- ESM
|
|
21
|
+
- ESM (`import`) and CommonJS (`require`) via the `exports` field
|
|
27
22
|
|
|
28
23
|
## Usage
|
|
29
24
|
|
|
30
25
|
```ts
|
|
31
|
-
import { createRater, lineDefinition
|
|
26
|
+
import { createRater, lineDefinition } from '@orkestrel/rater'
|
|
32
27
|
import { factorGroup, quantitativeDefinition, staticFactor } from '@orkestrel/reason'
|
|
33
28
|
|
|
34
29
|
const rater = createRater()
|
|
@@ -41,26 +36,23 @@ const base = lineDefinition(
|
|
|
41
36
|
]),
|
|
42
37
|
)
|
|
43
38
|
|
|
44
|
-
rater.
|
|
39
|
+
const result = rater.rate([base], { id: 'subject-1' })
|
|
40
|
+
result.lines[0]?.amount // 100
|
|
41
|
+
result.total // 100
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
result.programs[0]?.eligibility // 'eligible'
|
|
48
|
-
|
|
49
|
-
rater.rate([{ id: 'a' }, { id: 'b' }]) // an ARRAY resolves to the batch AggregateResult overload
|
|
43
|
+
rater.emitter.on('rate', (subject, rated) => rated.success)
|
|
50
44
|
|
|
51
45
|
rater.destroy()
|
|
52
46
|
```
|
|
53
47
|
|
|
54
|
-
`rate`
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`rater.emitter` (`rate` / `aggregate` / `determine` / `decide`).
|
|
48
|
+
`rate` accepts a plain `LineDefinition[]` or a full `RatingDefinition` plus one
|
|
49
|
+
subject — both overloads rate a single subject. Every `rate` call fires once
|
|
50
|
+
through `rater.emitter` (`rate`).
|
|
58
51
|
|
|
59
52
|
## Guide
|
|
60
53
|
|
|
61
|
-
For the full surface —
|
|
62
|
-
|
|
63
|
-
factories, errors, and the observation surface — see
|
|
54
|
+
For the full surface — `Rater`, `RatingResult`, worksheet types, validators,
|
|
55
|
+
factories, errors, and options — see
|
|
64
56
|
[`guides/src/rater.md`](guides/src/rater.md).
|
|
65
57
|
|
|
66
58
|
## Package
|