@clipboard-health/rules-engine 3.1.88 → 3.1.89
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/package.json +1 -1
- package/src/lib/appendOutput.d.ts +2 -2
- package/src/lib/rule.d.ts +2 -2
- package/src/lib/runners/all.d.ts +2 -2
- package/src/lib/runners/all.js.map +1 -1
- package/src/lib/runners/allIf.d.ts +2 -2
- package/src/lib/runners/allIf.js.map +1 -1
- package/src/lib/runners/firstMatch.d.ts +2 -2
- package/src/lib/runners/firstMatch.js +1 -1
- package/src/lib/runners/firstMatch.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ReadonlyDeep } from "type-fest";
|
|
2
|
+
import type { RuleContext } from "./rule";
|
|
3
3
|
/**
|
|
4
4
|
* Rule output is immutable, do not modify existing items, only append using this function.
|
|
5
5
|
*/
|
package/src/lib/rule.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReadonlyDeep } from "type-fest";
|
|
2
2
|
export interface RuleContext<TInput, TOutput> {
|
|
3
3
|
/**
|
|
4
4
|
* Input is immutable, rules must not modify it.
|
|
@@ -7,7 +7,7 @@ export interface RuleContext<TInput, TOutput> {
|
|
|
7
7
|
/**
|
|
8
8
|
* Output is immutable, do not modify existing items, only append using {@link appendOutput}.
|
|
9
9
|
*/
|
|
10
|
-
output:
|
|
10
|
+
output: readonly ReadonlyDeep<TOutput>[];
|
|
11
11
|
}
|
|
12
12
|
export interface Rule<TInput, TOutput, TContext extends RuleContext<TInput, TOutput> = RuleContext<TInput, TOutput>> {
|
|
13
13
|
/**
|
package/src/lib/runners/all.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Rule, RuleContext } from "../rule";
|
|
2
2
|
/**
|
|
3
3
|
* Run all rules that return true for `runIf`.
|
|
4
4
|
*
|
|
5
5
|
* @param rules The rules to run.
|
|
6
6
|
*/
|
|
7
|
-
export declare function all<TInput, TOutput, TContext extends RuleContext<TInput, TOutput>>(...rules:
|
|
7
|
+
export declare function all<TInput, TOutput, TContext extends RuleContext<TInput, TOutput>>(...rules: Rule<TInput, TOutput, TContext>[]): Rule<TInput, TOutput, TContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../../../packages/rules-engine/src/lib/runners/all.ts"],"names":[],"mappings":";;AAOA,kBAUC;AAfD;;;;GAIG;AACH,SAAgB,GAAG,CACjB,GAAG,
|
|
1
|
+
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../../../packages/rules-engine/src/lib/runners/all.ts"],"names":[],"mappings":";;AAOA,kBAUC;AAfD;;;;GAIG;AACH,SAAgB,GAAG,CACjB,GAAG,KAAwC;IAE3C,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzD,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CACf,KAAK;aACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC3C,MAAM,CAAC,CAAC,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Rule, RuleContext } from "../rule";
|
|
2
2
|
/**
|
|
3
3
|
* Run all rules that return true for their runIf condition, but only when the predicate function returns true.
|
|
4
4
|
*
|
|
@@ -13,4 +13,4 @@ import { type Rule, type RuleContext } from "../rule";
|
|
|
13
13
|
* rule2
|
|
14
14
|
* );
|
|
15
15
|
*/
|
|
16
|
-
export declare function allIf<TInput, TOutput, TContext extends RuleContext<TInput, TOutput>>(allIfPredicate: (input: RuleContext<TInput, TOutput>["input"]) => boolean, ...rules:
|
|
16
|
+
export declare function allIf<TInput, TOutput, TContext extends RuleContext<TInput, TOutput>>(allIfPredicate: (input: RuleContext<TInput, TOutput>["input"]) => boolean, ...rules: Rule<TInput, TOutput, TContext>[]): Rule<TInput, TOutput, TContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allIf.js","sourceRoot":"","sources":["../../../../../../packages/rules-engine/src/lib/runners/allIf.ts"],"names":[],"mappings":";;AAgBA,sBAWC;AAzBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,KAAK,CACnB,cAAyE,EACzE,GAAG,
|
|
1
|
+
{"version":3,"file":"allIf.js","sourceRoot":"","sources":["../../../../../../packages/rules-engine/src/lib/runners/allIf.ts"],"names":[],"mappings":";;AAgBA,sBAWC;AAzBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,KAAK,CACnB,cAAyE,EACzE,GAAG,KAAwC;IAE3C,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC;QACvC,GAAG,EAAE,CAAC,OAAiB,EAAE,EAAE,CACzB,KAAK;aACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC3C,MAAM,CAAC,CAAC,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Rule, RuleContext } from "../rule";
|
|
2
2
|
/**
|
|
3
3
|
* Run the first rule that returns true for `runIf`.
|
|
4
4
|
*
|
|
5
5
|
* @param rules The rules to run.
|
|
6
6
|
*/
|
|
7
|
-
export declare function firstMatch<TInput, TOutput, TContext extends RuleContext<TInput, TOutput>>(...rules:
|
|
7
|
+
export declare function firstMatch<TInput, TOutput, TContext extends RuleContext<TInput, TOutput>>(...rules: Rule<TInput, TOutput, TContext>[]): Rule<TInput, TOutput, TContext>;
|
|
@@ -10,7 +10,7 @@ function firstMatch(...rules) {
|
|
|
10
10
|
return {
|
|
11
11
|
runIf: (input) => rules.some((rule) => rule.runIf(input)),
|
|
12
12
|
run: (context) => {
|
|
13
|
-
const rule = rules.find((
|
|
13
|
+
const rule = rules.find((r) => r.runIf(context.input));
|
|
14
14
|
return rule ? rule.run(context) : context;
|
|
15
15
|
},
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstMatch.js","sourceRoot":"","sources":["../../../../../../packages/rules-engine/src/lib/runners/firstMatch.ts"],"names":[],"mappings":";;AAOA,gCAUC;AAfD;;;;GAIG;AACH,SAAgB,UAAU,CACxB,GAAG,
|
|
1
|
+
{"version":3,"file":"firstMatch.js","sourceRoot":"","sources":["../../../../../../packages/rules-engine/src/lib/runners/firstMatch.ts"],"names":[],"mappings":";;AAOA,gCAUC;AAfD;;;;GAIG;AACH,SAAgB,UAAU,CACxB,GAAG,KAAwC;IAE3C,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzD,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;YACf,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC"}
|