@orkestrel/rater 0.0.12 → 0.0.14
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 +25 -17
- package/dist/src/core/index.cjs +185 -147
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +343 -293
- package/dist/src/core/index.d.ts +343 -293
- package/dist/src/core/index.js +178 -140
- package/dist/src/core/index.js.map +1 -1
- package/package.json +22 -19
package/README.md
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
# @orkestrel/rater
|
|
2
2
|
|
|
3
|
-
A typed
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
> A typed quantitative rating layer over `@orkestrel/reason`'s shared engine: authored
|
|
4
|
+
> lines, each a plain reason `QuantitativeDefinition` joined to display metadata, rated
|
|
5
|
+
> against one subject to produce a `LineResult` per line — an `amount` and its
|
|
6
|
+
> `Worksheet` audit trail — and one `RatingResult` carrying every line's outcome and a
|
|
7
|
+
> derived `total`.
|
|
8
|
+
|
|
9
|
+
Create a rater with the `createRater` function, hand it the lines a subject is rated
|
|
10
|
+
against, and read the `LineResult` rows and the `total` it derives. Inject a
|
|
11
|
+
[`@orkestrel/reason`](https://github.com/orkestrel/reason) `ReasonInterface` where the
|
|
12
|
+
rating shares an engine with the rest of your reasoning, and call `destroy()` when the
|
|
13
|
+
rater's work is done. Environment-agnostic — no I/O, no browser or server assumptions.
|
|
14
|
+
Part of the `@orkestrel` line.
|
|
11
15
|
|
|
12
16
|
## Install
|
|
13
17
|
|
|
@@ -17,22 +21,26 @@ npm install @orkestrel/rater
|
|
|
17
21
|
|
|
18
22
|
## Requirements
|
|
19
23
|
|
|
20
|
-
- Node.js >=
|
|
21
|
-
- ESM (`import`) and CommonJS (`require`)
|
|
24
|
+
- Node.js >= 22.12.0
|
|
25
|
+
- ESM (`import`) and CommonJS (`require`) through the `exports` field
|
|
22
26
|
|
|
23
27
|
## Usage
|
|
24
28
|
|
|
25
29
|
```ts
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
30
|
+
import { buildLineDefinition, createRater } from '@orkestrel/rater'
|
|
31
|
+
import {
|
|
32
|
+
createFactorGroup,
|
|
33
|
+
createQuantitativeDefinition,
|
|
34
|
+
createStaticFactor,
|
|
35
|
+
} from '@orkestrel/reason'
|
|
28
36
|
|
|
29
37
|
const rater = createRater()
|
|
30
38
|
|
|
31
|
-
const base =
|
|
39
|
+
const base = buildLineDefinition(
|
|
32
40
|
'base',
|
|
33
41
|
'Base Amount',
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
createQuantitativeDefinition('base', 'Base', [
|
|
43
|
+
createFactorGroup('amount', 'sum', [createStaticFactor('flat', 100)]),
|
|
36
44
|
]),
|
|
37
45
|
)
|
|
38
46
|
|
|
@@ -46,14 +54,14 @@ rater.destroy()
|
|
|
46
54
|
```
|
|
47
55
|
|
|
48
56
|
`rate` accepts a plain `LineDefinition[]` or a full `RatingDefinition` plus one
|
|
49
|
-
subject
|
|
57
|
+
subject, and each overload rates that single subject. Every `rate` call fires once
|
|
50
58
|
through `rater.emitter` (`rate`).
|
|
51
59
|
|
|
52
60
|
## Guide
|
|
53
61
|
|
|
54
62
|
For the full surface — `Rater`, `RatingResult`, worksheet types, validators,
|
|
55
63
|
factories, errors, and options — see
|
|
56
|
-
[`guides/
|
|
64
|
+
[`guides/rater.md`](guides/rater.md).
|
|
57
65
|
|
|
58
66
|
## Package
|
|
59
67
|
|