@orkestrel/rater 0.0.13 → 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 +13 -9
- package/dist/src/core/index.cjs +70 -32
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +100 -53
- package/dist/src/core/index.d.ts +100 -53
- package/dist/src/core/index.js +70 -32
- package/dist/src/core/index.js.map +1 -1
- package/package.json +15 -16
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Aggregation } from '@orkestrel/reason';
|
|
2
|
-
import { Check } from '@orkestrel/reason';
|
|
3
|
-
import { CheckResult } from '@orkestrel/reason';
|
|
4
|
-
import { Comparison } from '@orkestrel/reason';
|
|
5
|
-
import { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
6
|
-
import { EmitterHooks } from '@orkestrel/emitter';
|
|
7
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
8
|
-
import { Factor } from '@orkestrel/reason';
|
|
9
|
-
import { FactorResult } from '@orkestrel/reason';
|
|
10
|
-
import { FieldPath } from '@orkestrel/contract';
|
|
11
|
-
import { GroupResult } from '@orkestrel/reason';
|
|
12
|
-
import { Guard } from '@orkestrel/contract';
|
|
13
|
-
import { JSONValue } from '@orkestrel/contract';
|
|
14
|
-
import { QuantitativeDefinition } from '@orkestrel/reason';
|
|
15
|
-
import { QuantitativeResult } from '@orkestrel/reason';
|
|
16
|
-
import { ReasonInterface } from '@orkestrel/reason';
|
|
17
|
-
import { Subject } from '@orkestrel/reason';
|
|
1
|
+
import type { Aggregation } from '@orkestrel/reason';
|
|
2
|
+
import type { Check } from '@orkestrel/reason';
|
|
3
|
+
import type { CheckResult } from '@orkestrel/reason';
|
|
4
|
+
import type { Comparison } from '@orkestrel/reason';
|
|
5
|
+
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
6
|
+
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
7
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
8
|
+
import type { Factor } from '@orkestrel/reason';
|
|
9
|
+
import type { FactorResult } from '@orkestrel/reason';
|
|
10
|
+
import type { FieldPath } from '@orkestrel/contract';
|
|
11
|
+
import type { GroupResult } from '@orkestrel/reason';
|
|
12
|
+
import type { Guard } from '@orkestrel/contract';
|
|
13
|
+
import type { JSONValue } from '@orkestrel/contract';
|
|
14
|
+
import type { QuantitativeDefinition } from '@orkestrel/reason';
|
|
15
|
+
import type { QuantitativeResult } from '@orkestrel/reason';
|
|
16
|
+
import type { ReasonInterface } from '@orkestrel/reason';
|
|
17
|
+
import type { Subject } from '@orkestrel/reason';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Builds an {@link Evidence} row from an evaluated {@link Check}.
|
|
@@ -58,7 +58,9 @@ export declare function buildEvidence(check: Check, actual: unknown, met: boolea
|
|
|
58
58
|
export declare function buildEvidenceRows(checks: readonly Check[] | undefined, results: readonly CheckResult[] | undefined, labels?: Readonly<Record<string, string>>): readonly Evidence[];
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Builds a {@link LineDefinition}
|
|
61
|
+
* Builds a fresh {@link LineDefinition} from a line id, a display name, and the
|
|
62
|
+
* line's quantitative rating definition, with `overrides` merged over those
|
|
63
|
+
* defaults.
|
|
62
64
|
*
|
|
63
65
|
* @param id - The line id
|
|
64
66
|
* @param name - The display name
|
|
@@ -98,7 +100,8 @@ export declare function buildLineDefinition(id: string, name: string, rate: Quan
|
|
|
98
100
|
export declare function buildLineResult(definition: LineDefinition, result: QuantitativeResult, labels?: Readonly<Record<string, string>>): LineResult;
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
|
-
* Builds a {@link RatingDefinition}
|
|
103
|
+
* Builds a fresh {@link RatingDefinition} from a rating id, a display name, and
|
|
104
|
+
* the rating's ordered lines, with `overrides` merged over those defaults.
|
|
102
105
|
*
|
|
103
106
|
* @param id - The rating id
|
|
104
107
|
* @param name - The display name
|
|
@@ -220,12 +223,13 @@ export declare function buildWorksheetStep(stage: Stage, id: string | undefined,
|
|
|
220
223
|
export declare function buildWorksheetSteps(definition: QuantitativeDefinition, result: QuantitativeResult, groups: readonly WorksheetGroup[]): readonly Step[];
|
|
221
224
|
|
|
222
225
|
/**
|
|
223
|
-
* Creates a rating orchestrator
|
|
226
|
+
* Creates a rating orchestrator over the shared quantitative engine, seeded
|
|
227
|
+
* from {@link RaterOptions} and returning a {@link RaterInterface}.
|
|
224
228
|
*
|
|
225
229
|
* @param options - Optional total handler, labels, injected engine, and emitter hooks
|
|
226
230
|
* @returns A {@link RaterInterface}
|
|
227
231
|
*
|
|
228
|
-
* @example
|
|
232
|
+
* @example Create a rater
|
|
229
233
|
* ```ts
|
|
230
234
|
* import { createRater } from '@orkestrel/rater'
|
|
231
235
|
*
|
|
@@ -249,10 +253,13 @@ export declare interface Evidence {
|
|
|
249
253
|
* Determines whether a value is an open result-side {@link Evidence} object.
|
|
250
254
|
*
|
|
251
255
|
* @remarks
|
|
256
|
+
* Optional `field` is checked as a `FieldPath`, `label` as a string,
|
|
257
|
+
* `comparison` as a `Comparison`, and `met` as a boolean, each when defined.
|
|
252
258
|
* Unknown members, prototypes, and class instances are admitted. Arrays are
|
|
253
259
|
* refused. `expected` and `actual` are `unknown`, so this guard does not read or
|
|
254
|
-
* check them
|
|
255
|
-
*
|
|
260
|
+
* check them and a borrowed result is never narrowed on them; either member may
|
|
261
|
+
* also be absent because `objectOf` reads declared members rather than
|
|
262
|
+
* requiring or enumerating own keys.
|
|
256
263
|
*
|
|
257
264
|
* @param value - The value to test
|
|
258
265
|
* @returns True if every checked `Evidence` member conforms; false otherwise
|
|
@@ -270,8 +277,11 @@ export declare function isEvidence(value: unknown): value is Evidence;
|
|
|
270
277
|
* Determines whether a value is an exact {@link LineDefinition} record.
|
|
271
278
|
*
|
|
272
279
|
* @remarks
|
|
273
|
-
*
|
|
274
|
-
*
|
|
280
|
+
* Every `LineDefinition` member is checked, including its quantitative
|
|
281
|
+
* definition. Total guard: adversarial input (cycles, hostile prototypes)
|
|
282
|
+
* returns `false`, never throws. The record shape is exact — this package owns
|
|
283
|
+
* the authored input record, so an extra key fails and nothing is left
|
|
284
|
+
* unchecked.
|
|
275
285
|
*
|
|
276
286
|
* @param value - The value to test
|
|
277
287
|
* @returns True if `value` is a `LineDefinition`; false otherwise
|
|
@@ -290,10 +300,14 @@ export declare function isLineDefinition(value: unknown): value is LineDefinitio
|
|
|
290
300
|
* Determines whether a value is an open {@link LineResult} object.
|
|
291
301
|
*
|
|
292
302
|
* @remarks
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
303
|
+
* Identity, an optional plain-number `amount`, and the nested `Worksheet` that
|
|
304
|
+
* carries the line's outcome are checked. Unknown members, prototypes, and
|
|
305
|
+
* class instances are admitted and left unchecked, because a borrowed result
|
|
306
|
+
* implementation may add them, and so is the relationship between `amount` and
|
|
307
|
+
* `worksheet.success`, which the published interface types independently.
|
|
308
|
+
* Arrays are refused. `amount` may be absent or read as `undefined`; when
|
|
309
|
+
* present it stays a plain JavaScript `number` without a finite or range
|
|
310
|
+
* refinement.
|
|
297
311
|
*
|
|
298
312
|
* @param value - The value to test
|
|
299
313
|
* @returns True if every published line-result member conforms; false otherwise
|
|
@@ -330,8 +344,11 @@ export declare function isRaterError(value: unknown): value is RaterError;
|
|
|
330
344
|
* Determines whether a value is an exact {@link RatingDefinition} record.
|
|
331
345
|
*
|
|
332
346
|
* @remarks
|
|
333
|
-
*
|
|
334
|
-
*
|
|
347
|
+
* Every `RatingDefinition` member is checked, including each nested line
|
|
348
|
+
* definition. Total guard: adversarial input (cycles, hostile prototypes)
|
|
349
|
+
* returns `false`, never throws. The record shape is exact — this package owns
|
|
350
|
+
* the authored input record, so an extra key fails and nothing is left
|
|
351
|
+
* unchecked.
|
|
335
352
|
*
|
|
336
353
|
* @param value - The value to test
|
|
337
354
|
* @returns True if `value` is a `RatingDefinition`; false otherwise
|
|
@@ -349,10 +366,13 @@ export declare function isRatingDefinition(value: unknown): value is RatingDefin
|
|
|
349
366
|
* Determines whether a value is an open {@link RatingResult} object.
|
|
350
367
|
*
|
|
351
368
|
* @remarks
|
|
352
|
-
* Use this guard for a result returned by a borrowed `RaterInterface`.
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
369
|
+
* Use this guard for a result returned by a borrowed `RaterInterface`. Every
|
|
370
|
+
* nested `LineResult`, an optional plain-number `total`, and a boolean `success`
|
|
371
|
+
* are checked. Unknown members, prototypes, and class instances are admitted and
|
|
372
|
+
* left unchecked, and so are the relationships among totals, lines, and success,
|
|
373
|
+
* because the borrowed interface publishes only their member types. Arrays are
|
|
374
|
+
* refused. `total` may be absent or read as `undefined`; when present it stays a
|
|
375
|
+
* plain JavaScript `number` without a finite or range refinement.
|
|
356
376
|
*
|
|
357
377
|
* @param value - The value to test
|
|
358
378
|
* @returns True if every published rating-result member conforms; false otherwise
|
|
@@ -369,6 +389,10 @@ export declare function isRatingResult(value: unknown): value is RatingResult;
|
|
|
369
389
|
/**
|
|
370
390
|
* Determines whether a value is a {@link Stage} literal.
|
|
371
391
|
*
|
|
392
|
+
* @remarks
|
|
393
|
+
* A scalar union has no open or exact axis, so this guard accepts one of the
|
|
394
|
+
* `Stage` literals and leaves nothing unchecked.
|
|
395
|
+
*
|
|
372
396
|
* @param value - The value to test
|
|
373
397
|
* @returns True if `value` is `'factor'`, `'group'`, or `'total'`; false otherwise
|
|
374
398
|
*
|
|
@@ -386,8 +410,11 @@ export declare const isStage: Guard<Stage>;
|
|
|
386
410
|
* Determines whether a value is an open {@link Step} result object.
|
|
387
411
|
*
|
|
388
412
|
* @remarks
|
|
389
|
-
*
|
|
390
|
-
*
|
|
413
|
+
* `stage` is checked through `isStage`, `id`, `name`, and `expression` when
|
|
414
|
+
* defined, and `value` as a plain number. Unknown members, prototypes, and
|
|
415
|
+
* class instances are admitted and left unchecked, because a borrowed result
|
|
416
|
+
* implementation may add them. Arrays are refused. Optional members may be
|
|
417
|
+
* absent or read as `undefined`.
|
|
391
418
|
*
|
|
392
419
|
* @param value - The value to test
|
|
393
420
|
* @returns True if every published worksheet-step member conforms; false otherwise
|
|
@@ -405,8 +432,12 @@ export declare function isStep(value: unknown): value is Step;
|
|
|
405
432
|
* Determines whether a value is an open {@link Worksheet} result object.
|
|
406
433
|
*
|
|
407
434
|
* @remarks
|
|
408
|
-
*
|
|
409
|
-
*
|
|
435
|
+
* Identity, `aggregation` through reason's `isAggregation`, an optional
|
|
436
|
+
* plain-number `precision`, a plain-number `value`, the nested groups and steps,
|
|
437
|
+
* `trace`, `errors`, and `success` are checked. Unknown members, prototypes, and
|
|
438
|
+
* class instances are admitted and left unchecked, because a borrowed result
|
|
439
|
+
* implementation may add them. Arrays are refused. Optional members may be
|
|
440
|
+
* absent or read as `undefined`.
|
|
410
441
|
*
|
|
411
442
|
* @param value - The value to test
|
|
412
443
|
* @returns True if every published worksheet member conforms; false otherwise
|
|
@@ -424,8 +455,11 @@ export declare function isWorksheet(value: unknown): value is Worksheet;
|
|
|
424
455
|
* Determines whether a value is an open {@link WorksheetFactor} result object.
|
|
425
456
|
*
|
|
426
457
|
* @remarks
|
|
427
|
-
*
|
|
428
|
-
*
|
|
458
|
+
* `id`, the optional authored text, `applied`, an optional plain-number
|
|
459
|
+
* `value`, and each `Evidence` entry are checked. Unknown members, prototypes,
|
|
460
|
+
* and class instances are admitted and left unchecked, because a borrowed
|
|
461
|
+
* result implementation may add them. Arrays are refused. Optional members may
|
|
462
|
+
* be absent or read as `undefined`.
|
|
429
463
|
*
|
|
430
464
|
* @param value - The value to test
|
|
431
465
|
* @returns True if every published worksheet-factor member conforms; false otherwise
|
|
@@ -443,8 +477,11 @@ export declare function isWorksheetFactor(value: unknown): value is WorksheetFac
|
|
|
443
477
|
* Determines whether a value is an open {@link WorksheetGroup} result object.
|
|
444
478
|
*
|
|
445
479
|
* @remarks
|
|
446
|
-
*
|
|
447
|
-
*
|
|
480
|
+
* `id`, the optional authored text, `applied`, a plain-number `value`, and each
|
|
481
|
+
* `WorksheetFactor` entry are checked. Unknown members, prototypes, and class
|
|
482
|
+
* instances are admitted and left unchecked, because a borrowed result
|
|
483
|
+
* implementation may add them. Arrays are refused. Optional members may be
|
|
484
|
+
* absent or read as `undefined`.
|
|
448
485
|
*
|
|
449
486
|
* @param value - The value to test
|
|
450
487
|
* @returns True if every published worksheet-group member conforms; false otherwise
|
|
@@ -479,7 +516,7 @@ export declare interface LineDefinition {
|
|
|
479
516
|
* @remarks
|
|
480
517
|
* `worksheet` is always present — even a failed evaluation resolves to a
|
|
481
518
|
* type-shaped failure worksheet, so a `LineResult` is always constructible.
|
|
482
|
-
* The worksheet also carries the line's outcome: `amount` is present
|
|
519
|
+
* The worksheet also carries the line's outcome: `amount` is present only
|
|
483
520
|
* when `worksheet.success` is `true`.
|
|
484
521
|
*/
|
|
485
522
|
export declare interface LineResult {
|
|
@@ -494,12 +531,12 @@ export declare interface LineResult {
|
|
|
494
531
|
* reasoning engine and projects results into the rating domain vocabulary.
|
|
495
532
|
*
|
|
496
533
|
* @remarks
|
|
497
|
-
* When no `engine` is injected, `Rater` builds and
|
|
498
|
-
* quantitative-only engine (`bail: false`) — Rater performs
|
|
534
|
+
* When no `engine` is injected, `Rater` builds and owns its own
|
|
535
|
+
* quantitative-only engine (`bail: false`) — Rater performs no evaluation
|
|
499
536
|
* arithmetic of its own; it only orchestrates and projects. The
|
|
500
|
-
* array-of-lines `rate` overload is declared
|
|
501
|
-
* resolves to that form. `destroy()` destroys an
|
|
502
|
-
* emitter
|
|
537
|
+
* array-of-lines `rate` overload is declared first so a plain line list
|
|
538
|
+
* resolves to that form. `destroy()` destroys an owned engine, then the
|
|
539
|
+
* emitter last; an injected engine is never destroyed. Afterwards every
|
|
503
540
|
* other method throws {@link RaterError} `'DESTROYED'`.
|
|
504
541
|
*
|
|
505
542
|
* @example
|
|
@@ -526,7 +563,8 @@ export declare class Rater implements RaterInterface {
|
|
|
526
563
|
* @remarks
|
|
527
564
|
* `DEFINITION` — the `rate` input failed both the array-of-lines and rating
|
|
528
565
|
* definition validation. `MISMATCH` — a rated subject is not a record.
|
|
529
|
-
* `DESTROYED` — use of a destroyed entity.
|
|
566
|
+
* `DESTROYED` — use of a destroyed entity. `context` carries optional
|
|
567
|
+
* structured detail beside the message.
|
|
530
568
|
*
|
|
531
569
|
* @example
|
|
532
570
|
* ```ts
|
|
@@ -559,14 +597,23 @@ export declare type RaterEventMap = {
|
|
|
559
597
|
* Represents the rating orchestrator over the shared quantitative reasoning engine.
|
|
560
598
|
*
|
|
561
599
|
* @remarks
|
|
562
|
-
* The array-of-lines `rate` overload is declared
|
|
563
|
-
* resolves to that form.
|
|
600
|
+
* The array-of-lines `rate` overload is declared first so a plain line list
|
|
601
|
+
* resolves to that form. Each overload rates a single subject — there is no
|
|
564
602
|
* batch-of-subjects overload.
|
|
565
603
|
*/
|
|
566
604
|
export declare interface RaterInterface {
|
|
605
|
+
/** Holds the typed emitter every `rate` call fires its event through. */
|
|
567
606
|
readonly emitter: EmitterInterface<RaterEventMap>;
|
|
607
|
+
/**
|
|
608
|
+
* Rates an array of lines, or a {@link RatingDefinition}, against one subject over
|
|
609
|
+
* the shared quantitative engine.
|
|
610
|
+
*/
|
|
568
611
|
rate(lines: readonly LineDefinition[], subject: Subject): RatingResult;
|
|
569
612
|
rate(definition: RatingDefinition, subject: Subject): RatingResult;
|
|
613
|
+
/**
|
|
614
|
+
* Destroys an owned engine and then the emitter, and does nothing on a later
|
|
615
|
+
* call.
|
|
616
|
+
*/
|
|
570
617
|
destroy(): void;
|
|
571
618
|
}
|
|
572
619
|
|
|
@@ -575,7 +622,7 @@ export declare interface RaterInterface {
|
|
|
575
622
|
*
|
|
576
623
|
* @remarks
|
|
577
624
|
* `engine` — an injected {@link ReasonInterface}; when omitted, `Rater` builds
|
|
578
|
-
* and
|
|
625
|
+
* and owns its own quantitative-only engine (`bail: false`), destroying it on
|
|
579
626
|
* `destroy()`. `total` — a {@link TotalHandler} overriding the default
|
|
580
627
|
* {@link sumAmounts} projection. `labels` — field-to-label display overrides
|
|
581
628
|
* threaded into every resolved {@link Evidence}.
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Aggregation } from '@orkestrel/reason';
|
|
2
|
-
import { Check } from '@orkestrel/reason';
|
|
3
|
-
import { CheckResult } from '@orkestrel/reason';
|
|
4
|
-
import { Comparison } from '@orkestrel/reason';
|
|
5
|
-
import { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
6
|
-
import { EmitterHooks } from '@orkestrel/emitter';
|
|
7
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
8
|
-
import { Factor } from '@orkestrel/reason';
|
|
9
|
-
import { FactorResult } from '@orkestrel/reason';
|
|
10
|
-
import { FieldPath } from '@orkestrel/contract';
|
|
11
|
-
import { GroupResult } from '@orkestrel/reason';
|
|
12
|
-
import { Guard } from '@orkestrel/contract';
|
|
13
|
-
import { JSONValue } from '@orkestrel/contract';
|
|
14
|
-
import { QuantitativeDefinition } from '@orkestrel/reason';
|
|
15
|
-
import { QuantitativeResult } from '@orkestrel/reason';
|
|
16
|
-
import { ReasonInterface } from '@orkestrel/reason';
|
|
17
|
-
import { Subject } from '@orkestrel/reason';
|
|
1
|
+
import type { Aggregation } from '@orkestrel/reason';
|
|
2
|
+
import type { Check } from '@orkestrel/reason';
|
|
3
|
+
import type { CheckResult } from '@orkestrel/reason';
|
|
4
|
+
import type { Comparison } from '@orkestrel/reason';
|
|
5
|
+
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
6
|
+
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
7
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
8
|
+
import type { Factor } from '@orkestrel/reason';
|
|
9
|
+
import type { FactorResult } from '@orkestrel/reason';
|
|
10
|
+
import type { FieldPath } from '@orkestrel/contract';
|
|
11
|
+
import type { GroupResult } from '@orkestrel/reason';
|
|
12
|
+
import type { Guard } from '@orkestrel/contract';
|
|
13
|
+
import type { JSONValue } from '@orkestrel/contract';
|
|
14
|
+
import type { QuantitativeDefinition } from '@orkestrel/reason';
|
|
15
|
+
import type { QuantitativeResult } from '@orkestrel/reason';
|
|
16
|
+
import type { ReasonInterface } from '@orkestrel/reason';
|
|
17
|
+
import type { Subject } from '@orkestrel/reason';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Builds an {@link Evidence} row from an evaluated {@link Check}.
|
|
@@ -58,7 +58,9 @@ export declare function buildEvidence(check: Check, actual: unknown, met: boolea
|
|
|
58
58
|
export declare function buildEvidenceRows(checks: readonly Check[] | undefined, results: readonly CheckResult[] | undefined, labels?: Readonly<Record<string, string>>): readonly Evidence[];
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Builds a {@link LineDefinition}
|
|
61
|
+
* Builds a fresh {@link LineDefinition} from a line id, a display name, and the
|
|
62
|
+
* line's quantitative rating definition, with `overrides` merged over those
|
|
63
|
+
* defaults.
|
|
62
64
|
*
|
|
63
65
|
* @param id - The line id
|
|
64
66
|
* @param name - The display name
|
|
@@ -98,7 +100,8 @@ export declare function buildLineDefinition(id: string, name: string, rate: Quan
|
|
|
98
100
|
export declare function buildLineResult(definition: LineDefinition, result: QuantitativeResult, labels?: Readonly<Record<string, string>>): LineResult;
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
|
-
* Builds a {@link RatingDefinition}
|
|
103
|
+
* Builds a fresh {@link RatingDefinition} from a rating id, a display name, and
|
|
104
|
+
* the rating's ordered lines, with `overrides` merged over those defaults.
|
|
102
105
|
*
|
|
103
106
|
* @param id - The rating id
|
|
104
107
|
* @param name - The display name
|
|
@@ -220,12 +223,13 @@ export declare function buildWorksheetStep(stage: Stage, id: string | undefined,
|
|
|
220
223
|
export declare function buildWorksheetSteps(definition: QuantitativeDefinition, result: QuantitativeResult, groups: readonly WorksheetGroup[]): readonly Step[];
|
|
221
224
|
|
|
222
225
|
/**
|
|
223
|
-
* Creates a rating orchestrator
|
|
226
|
+
* Creates a rating orchestrator over the shared quantitative engine, seeded
|
|
227
|
+
* from {@link RaterOptions} and returning a {@link RaterInterface}.
|
|
224
228
|
*
|
|
225
229
|
* @param options - Optional total handler, labels, injected engine, and emitter hooks
|
|
226
230
|
* @returns A {@link RaterInterface}
|
|
227
231
|
*
|
|
228
|
-
* @example
|
|
232
|
+
* @example Create a rater
|
|
229
233
|
* ```ts
|
|
230
234
|
* import { createRater } from '@orkestrel/rater'
|
|
231
235
|
*
|
|
@@ -249,10 +253,13 @@ export declare interface Evidence {
|
|
|
249
253
|
* Determines whether a value is an open result-side {@link Evidence} object.
|
|
250
254
|
*
|
|
251
255
|
* @remarks
|
|
256
|
+
* Optional `field` is checked as a `FieldPath`, `label` as a string,
|
|
257
|
+
* `comparison` as a `Comparison`, and `met` as a boolean, each when defined.
|
|
252
258
|
* Unknown members, prototypes, and class instances are admitted. Arrays are
|
|
253
259
|
* refused. `expected` and `actual` are `unknown`, so this guard does not read or
|
|
254
|
-
* check them
|
|
255
|
-
*
|
|
260
|
+
* check them and a borrowed result is never narrowed on them; either member may
|
|
261
|
+
* also be absent because `objectOf` reads declared members rather than
|
|
262
|
+
* requiring or enumerating own keys.
|
|
256
263
|
*
|
|
257
264
|
* @param value - The value to test
|
|
258
265
|
* @returns True if every checked `Evidence` member conforms; false otherwise
|
|
@@ -270,8 +277,11 @@ export declare function isEvidence(value: unknown): value is Evidence;
|
|
|
270
277
|
* Determines whether a value is an exact {@link LineDefinition} record.
|
|
271
278
|
*
|
|
272
279
|
* @remarks
|
|
273
|
-
*
|
|
274
|
-
*
|
|
280
|
+
* Every `LineDefinition` member is checked, including its quantitative
|
|
281
|
+
* definition. Total guard: adversarial input (cycles, hostile prototypes)
|
|
282
|
+
* returns `false`, never throws. The record shape is exact — this package owns
|
|
283
|
+
* the authored input record, so an extra key fails and nothing is left
|
|
284
|
+
* unchecked.
|
|
275
285
|
*
|
|
276
286
|
* @param value - The value to test
|
|
277
287
|
* @returns True if `value` is a `LineDefinition`; false otherwise
|
|
@@ -290,10 +300,14 @@ export declare function isLineDefinition(value: unknown): value is LineDefinitio
|
|
|
290
300
|
* Determines whether a value is an open {@link LineResult} object.
|
|
291
301
|
*
|
|
292
302
|
* @remarks
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
303
|
+
* Identity, an optional plain-number `amount`, and the nested `Worksheet` that
|
|
304
|
+
* carries the line's outcome are checked. Unknown members, prototypes, and
|
|
305
|
+
* class instances are admitted and left unchecked, because a borrowed result
|
|
306
|
+
* implementation may add them, and so is the relationship between `amount` and
|
|
307
|
+
* `worksheet.success`, which the published interface types independently.
|
|
308
|
+
* Arrays are refused. `amount` may be absent or read as `undefined`; when
|
|
309
|
+
* present it stays a plain JavaScript `number` without a finite or range
|
|
310
|
+
* refinement.
|
|
297
311
|
*
|
|
298
312
|
* @param value - The value to test
|
|
299
313
|
* @returns True if every published line-result member conforms; false otherwise
|
|
@@ -330,8 +344,11 @@ export declare function isRaterError(value: unknown): value is RaterError;
|
|
|
330
344
|
* Determines whether a value is an exact {@link RatingDefinition} record.
|
|
331
345
|
*
|
|
332
346
|
* @remarks
|
|
333
|
-
*
|
|
334
|
-
*
|
|
347
|
+
* Every `RatingDefinition` member is checked, including each nested line
|
|
348
|
+
* definition. Total guard: adversarial input (cycles, hostile prototypes)
|
|
349
|
+
* returns `false`, never throws. The record shape is exact — this package owns
|
|
350
|
+
* the authored input record, so an extra key fails and nothing is left
|
|
351
|
+
* unchecked.
|
|
335
352
|
*
|
|
336
353
|
* @param value - The value to test
|
|
337
354
|
* @returns True if `value` is a `RatingDefinition`; false otherwise
|
|
@@ -349,10 +366,13 @@ export declare function isRatingDefinition(value: unknown): value is RatingDefin
|
|
|
349
366
|
* Determines whether a value is an open {@link RatingResult} object.
|
|
350
367
|
*
|
|
351
368
|
* @remarks
|
|
352
|
-
* Use this guard for a result returned by a borrowed `RaterInterface`.
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
369
|
+
* Use this guard for a result returned by a borrowed `RaterInterface`. Every
|
|
370
|
+
* nested `LineResult`, an optional plain-number `total`, and a boolean `success`
|
|
371
|
+
* are checked. Unknown members, prototypes, and class instances are admitted and
|
|
372
|
+
* left unchecked, and so are the relationships among totals, lines, and success,
|
|
373
|
+
* because the borrowed interface publishes only their member types. Arrays are
|
|
374
|
+
* refused. `total` may be absent or read as `undefined`; when present it stays a
|
|
375
|
+
* plain JavaScript `number` without a finite or range refinement.
|
|
356
376
|
*
|
|
357
377
|
* @param value - The value to test
|
|
358
378
|
* @returns True if every published rating-result member conforms; false otherwise
|
|
@@ -369,6 +389,10 @@ export declare function isRatingResult(value: unknown): value is RatingResult;
|
|
|
369
389
|
/**
|
|
370
390
|
* Determines whether a value is a {@link Stage} literal.
|
|
371
391
|
*
|
|
392
|
+
* @remarks
|
|
393
|
+
* A scalar union has no open or exact axis, so this guard accepts one of the
|
|
394
|
+
* `Stage` literals and leaves nothing unchecked.
|
|
395
|
+
*
|
|
372
396
|
* @param value - The value to test
|
|
373
397
|
* @returns True if `value` is `'factor'`, `'group'`, or `'total'`; false otherwise
|
|
374
398
|
*
|
|
@@ -386,8 +410,11 @@ export declare const isStage: Guard<Stage>;
|
|
|
386
410
|
* Determines whether a value is an open {@link Step} result object.
|
|
387
411
|
*
|
|
388
412
|
* @remarks
|
|
389
|
-
*
|
|
390
|
-
*
|
|
413
|
+
* `stage` is checked through `isStage`, `id`, `name`, and `expression` when
|
|
414
|
+
* defined, and `value` as a plain number. Unknown members, prototypes, and
|
|
415
|
+
* class instances are admitted and left unchecked, because a borrowed result
|
|
416
|
+
* implementation may add them. Arrays are refused. Optional members may be
|
|
417
|
+
* absent or read as `undefined`.
|
|
391
418
|
*
|
|
392
419
|
* @param value - The value to test
|
|
393
420
|
* @returns True if every published worksheet-step member conforms; false otherwise
|
|
@@ -405,8 +432,12 @@ export declare function isStep(value: unknown): value is Step;
|
|
|
405
432
|
* Determines whether a value is an open {@link Worksheet} result object.
|
|
406
433
|
*
|
|
407
434
|
* @remarks
|
|
408
|
-
*
|
|
409
|
-
*
|
|
435
|
+
* Identity, `aggregation` through reason's `isAggregation`, an optional
|
|
436
|
+
* plain-number `precision`, a plain-number `value`, the nested groups and steps,
|
|
437
|
+
* `trace`, `errors`, and `success` are checked. Unknown members, prototypes, and
|
|
438
|
+
* class instances are admitted and left unchecked, because a borrowed result
|
|
439
|
+
* implementation may add them. Arrays are refused. Optional members may be
|
|
440
|
+
* absent or read as `undefined`.
|
|
410
441
|
*
|
|
411
442
|
* @param value - The value to test
|
|
412
443
|
* @returns True if every published worksheet member conforms; false otherwise
|
|
@@ -424,8 +455,11 @@ export declare function isWorksheet(value: unknown): value is Worksheet;
|
|
|
424
455
|
* Determines whether a value is an open {@link WorksheetFactor} result object.
|
|
425
456
|
*
|
|
426
457
|
* @remarks
|
|
427
|
-
*
|
|
428
|
-
*
|
|
458
|
+
* `id`, the optional authored text, `applied`, an optional plain-number
|
|
459
|
+
* `value`, and each `Evidence` entry are checked. Unknown members, prototypes,
|
|
460
|
+
* and class instances are admitted and left unchecked, because a borrowed
|
|
461
|
+
* result implementation may add them. Arrays are refused. Optional members may
|
|
462
|
+
* be absent or read as `undefined`.
|
|
429
463
|
*
|
|
430
464
|
* @param value - The value to test
|
|
431
465
|
* @returns True if every published worksheet-factor member conforms; false otherwise
|
|
@@ -443,8 +477,11 @@ export declare function isWorksheetFactor(value: unknown): value is WorksheetFac
|
|
|
443
477
|
* Determines whether a value is an open {@link WorksheetGroup} result object.
|
|
444
478
|
*
|
|
445
479
|
* @remarks
|
|
446
|
-
*
|
|
447
|
-
*
|
|
480
|
+
* `id`, the optional authored text, `applied`, a plain-number `value`, and each
|
|
481
|
+
* `WorksheetFactor` entry are checked. Unknown members, prototypes, and class
|
|
482
|
+
* instances are admitted and left unchecked, because a borrowed result
|
|
483
|
+
* implementation may add them. Arrays are refused. Optional members may be
|
|
484
|
+
* absent or read as `undefined`.
|
|
448
485
|
*
|
|
449
486
|
* @param value - The value to test
|
|
450
487
|
* @returns True if every published worksheet-group member conforms; false otherwise
|
|
@@ -479,7 +516,7 @@ export declare interface LineDefinition {
|
|
|
479
516
|
* @remarks
|
|
480
517
|
* `worksheet` is always present — even a failed evaluation resolves to a
|
|
481
518
|
* type-shaped failure worksheet, so a `LineResult` is always constructible.
|
|
482
|
-
* The worksheet also carries the line's outcome: `amount` is present
|
|
519
|
+
* The worksheet also carries the line's outcome: `amount` is present only
|
|
483
520
|
* when `worksheet.success` is `true`.
|
|
484
521
|
*/
|
|
485
522
|
export declare interface LineResult {
|
|
@@ -494,12 +531,12 @@ export declare interface LineResult {
|
|
|
494
531
|
* reasoning engine and projects results into the rating domain vocabulary.
|
|
495
532
|
*
|
|
496
533
|
* @remarks
|
|
497
|
-
* When no `engine` is injected, `Rater` builds and
|
|
498
|
-
* quantitative-only engine (`bail: false`) — Rater performs
|
|
534
|
+
* When no `engine` is injected, `Rater` builds and owns its own
|
|
535
|
+
* quantitative-only engine (`bail: false`) — Rater performs no evaluation
|
|
499
536
|
* arithmetic of its own; it only orchestrates and projects. The
|
|
500
|
-
* array-of-lines `rate` overload is declared
|
|
501
|
-
* resolves to that form. `destroy()` destroys an
|
|
502
|
-
* emitter
|
|
537
|
+
* array-of-lines `rate` overload is declared first so a plain line list
|
|
538
|
+
* resolves to that form. `destroy()` destroys an owned engine, then the
|
|
539
|
+
* emitter last; an injected engine is never destroyed. Afterwards every
|
|
503
540
|
* other method throws {@link RaterError} `'DESTROYED'`.
|
|
504
541
|
*
|
|
505
542
|
* @example
|
|
@@ -526,7 +563,8 @@ export declare class Rater implements RaterInterface {
|
|
|
526
563
|
* @remarks
|
|
527
564
|
* `DEFINITION` — the `rate` input failed both the array-of-lines and rating
|
|
528
565
|
* definition validation. `MISMATCH` — a rated subject is not a record.
|
|
529
|
-
* `DESTROYED` — use of a destroyed entity.
|
|
566
|
+
* `DESTROYED` — use of a destroyed entity. `context` carries optional
|
|
567
|
+
* structured detail beside the message.
|
|
530
568
|
*
|
|
531
569
|
* @example
|
|
532
570
|
* ```ts
|
|
@@ -559,14 +597,23 @@ export declare type RaterEventMap = {
|
|
|
559
597
|
* Represents the rating orchestrator over the shared quantitative reasoning engine.
|
|
560
598
|
*
|
|
561
599
|
* @remarks
|
|
562
|
-
* The array-of-lines `rate` overload is declared
|
|
563
|
-
* resolves to that form.
|
|
600
|
+
* The array-of-lines `rate` overload is declared first so a plain line list
|
|
601
|
+
* resolves to that form. Each overload rates a single subject — there is no
|
|
564
602
|
* batch-of-subjects overload.
|
|
565
603
|
*/
|
|
566
604
|
export declare interface RaterInterface {
|
|
605
|
+
/** Holds the typed emitter every `rate` call fires its event through. */
|
|
567
606
|
readonly emitter: EmitterInterface<RaterEventMap>;
|
|
607
|
+
/**
|
|
608
|
+
* Rates an array of lines, or a {@link RatingDefinition}, against one subject over
|
|
609
|
+
* the shared quantitative engine.
|
|
610
|
+
*/
|
|
568
611
|
rate(lines: readonly LineDefinition[], subject: Subject): RatingResult;
|
|
569
612
|
rate(definition: RatingDefinition, subject: Subject): RatingResult;
|
|
613
|
+
/**
|
|
614
|
+
* Destroys an owned engine and then the emitter, and does nothing on a later
|
|
615
|
+
* call.
|
|
616
|
+
*/
|
|
570
617
|
destroy(): void;
|
|
571
618
|
}
|
|
572
619
|
|
|
@@ -575,7 +622,7 @@ export declare interface RaterInterface {
|
|
|
575
622
|
*
|
|
576
623
|
* @remarks
|
|
577
624
|
* `engine` — an injected {@link ReasonInterface}; when omitted, `Rater` builds
|
|
578
|
-
* and
|
|
625
|
+
* and owns its own quantitative-only engine (`bail: false`), destroying it on
|
|
579
626
|
* `destroy()`. `total` — a {@link TotalHandler} overriding the default
|
|
580
627
|
* {@link sumAmounts} projection. `labels` — field-to-label display overrides
|
|
581
628
|
* threaded into every resolved {@link Evidence}.
|