krl-stdlib 1.5.0 → 1.9.0

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/dist/KrlCtx.d.ts CHANGED
@@ -19,6 +19,15 @@ export interface Directive {
19
19
  txnId: string | null;
20
20
  };
21
21
  }
22
+ export type RuleOutcomeStatus = "fired" | "not_fired" | "not_selected";
23
+ /** Per annotated rule after an event (1.8 rule outcome reporting). */
24
+ export interface RuleOutcome {
25
+ rid: string;
26
+ rule: string;
27
+ status: RuleOutcomeStatus;
28
+ /** Present when status is not_selected (from ruleset schema). */
29
+ select?: string;
30
+ }
22
31
  export interface PicoLogEntry {
23
32
  level: string;
24
33
  time: string;
@@ -43,5 +52,15 @@ export interface KrlCtx {
43
52
  [name: string]: any;
44
53
  }): Directive;
45
54
  drainDirectives(): Directive[];
55
+ /** Record selected rule finished (fired or condition false). */
56
+ recordRuleOutcome(rule: string, fired: boolean): void;
57
+ drainRuleOutcomes(): RuleOutcome[];
46
58
  krl: typeof krl;
59
+ /** Engine-injected KRL console compiler (not available in KRL modules). */
60
+ compileEvalExpression?: (expr: string, opts: {
61
+ rulesetKrl: string;
62
+ }) => {
63
+ warnings: unknown[];
64
+ run: ($ctx: KrlCtx, $g: Record<string, unknown>) => Promise<unknown>;
65
+ };
47
66
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as krl from "./krl";
2
- import { CurrentPicoEvent, CurrentPicoQuery, Directive, KrlCtx, PicoLogEntry } from "./KrlCtx";
2
+ import { CurrentPicoEvent, CurrentPicoQuery, Directive, KrlCtx, PicoLogEntry, RuleOutcome, RuleOutcomeStatus } from "./KrlCtx";
3
3
  import { KrlLogger, krlLogLevelCodeToHuman, makeKrlLogger } from "./KrlLogger";
4
4
  import stdlib from "./stdlib";
5
- export { krl, CurrentPicoEvent, CurrentPicoQuery, Directive, KrlCtx, PicoLogEntry, KrlLogger, krlLogLevelCodeToHuman, makeKrlLogger, stdlib, };
5
+ export { krl, CurrentPicoEvent, CurrentPicoQuery, Directive, KrlCtx, PicoLogEntry, RuleOutcome, RuleOutcomeStatus, KrlLogger, krlLogLevelCodeToHuman, makeKrlLogger, stdlib, };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAY3B,kBAAG;AAJL,2CAA+E;AAW7E,uGAXkB,kCAAsB,OAWlB;AACtB,8FAZ0C,yBAAa,OAY1C;AAXf,qCAA8B;AAY5B,iBAZK,gBAAM,CAYL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAc3B,kBAAG;AAJL,2CAA+E;AAa7E,uGAbkB,kCAAsB,OAalB;AACtB,8FAd0C,yBAAa,OAc1C;AAbf,qCAA8B;AAc5B,iBAdK,gBAAM,CAcL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "krl-stdlib",
3
- "version": "1.5.0",
3
+ "version": "1.9.0",
4
4
  "description": "Standard library for KRL",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -8,7 +8,6 @@
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
- "prepare": "npm run build",
12
11
  "start": "ava -w",
13
12
  "test": "ava",
14
13
  "build": "rm -rf dist && tsc"
@@ -38,7 +37,7 @@
38
37
  "dependencies": {
39
38
  "json-log": "^3.0.1",
40
39
  "lodash": "^4.17.11",
41
- "pico-framework": "^0.8.0",
40
+ "pico-framework": "^0.8.2",
42
41
  "select-when": "^0.1.9"
43
42
  },
44
43
  "ava": {
@@ -52,5 +51,5 @@
52
51
  "test.ts"
53
52
  ]
54
53
  },
55
- "gitHead": "38f550eb9a0de399e9f1c4554176d4a7cc84d8c8"
54
+ "gitHead": "c07badbb5d2305c44fdfb687d36cb94028323636"
56
55
  }
package/src/KrlCtx.ts CHANGED
@@ -21,6 +21,17 @@ export interface Directive {
21
21
  };
22
22
  }
23
23
 
24
+ export type RuleOutcomeStatus = "fired" | "not_fired" | "not_selected";
25
+
26
+ /** Per annotated rule after an event (1.8 rule outcome reporting). */
27
+ export interface RuleOutcome {
28
+ rid: string;
29
+ rule: string;
30
+ status: RuleOutcomeStatus;
31
+ /** Present when status is not_selected (from ruleset schema). */
32
+ select?: string;
33
+ }
34
+
24
35
  export interface PicoLogEntry {
25
36
  level: string;
26
37
  time: string;
@@ -55,6 +66,19 @@ export interface KrlCtx {
55
66
  addDirective(name: string, options: { [name: string]: any }): Directive;
56
67
  drainDirectives(): Directive[];
57
68
 
69
+ /** Record selected rule finished (fired or condition false). */
70
+ recordRuleOutcome(rule: string, fired: boolean): void;
71
+ drainRuleOutcomes(): RuleOutcome[];
72
+
58
73
  // compiler lib
59
74
  krl: typeof krl;
75
+
76
+ /** Engine-injected KRL console compiler (not available in KRL modules). */
77
+ compileEvalExpression?: (
78
+ expr: string,
79
+ opts: { rulesetKrl: string }
80
+ ) => {
81
+ warnings: unknown[];
82
+ run: ($ctx: KrlCtx, $g: Record<string, unknown>) => Promise<unknown>;
83
+ };
60
84
  }
package/src/index.ts CHANGED
@@ -5,6 +5,8 @@ import {
5
5
  Directive,
6
6
  KrlCtx,
7
7
  PicoLogEntry,
8
+ RuleOutcome,
9
+ RuleOutcomeStatus,
8
10
  } from "./KrlCtx";
9
11
  import { KrlLogger, krlLogLevelCodeToHuman, makeKrlLogger } from "./KrlLogger";
10
12
  import stdlib from "./stdlib";
@@ -16,6 +18,8 @@ export {
16
18
  Directive,
17
19
  KrlCtx,
18
20
  PicoLogEntry,
21
+ RuleOutcome,
22
+ RuleOutcomeStatus,
19
23
  KrlLogger,
20
24
  krlLogLevelCodeToHuman,
21
25
  makeKrlLogger,