@rkmodules/rules 0.0.168 → 0.0.169

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.
@@ -1,5 +1,5 @@
1
1
  import { Tree } from "../DataTree";
2
- import { GraphedFunction, NormalizedVarDef, PrimitiveFunction, AnyFunction, VarDef, VarRef, RecOfTrees, FunctionCall } from "./types";
2
+ import { GraphedFunction, NormalizedVarDef, PrimitiveFunction, AnyFunction, VarDef, VarRef, RecOfTrees, FunctionCall, ExecutionContext } from "./types";
3
3
  export * from "./types";
4
4
  export * from "./util";
5
5
  export interface Ref {
@@ -10,16 +10,8 @@ export interface Ref {
10
10
  refField: string;
11
11
  }
12
12
  export declare function normalizeVarDef(varDef: VarDef): NormalizedVarDef;
13
- export declare function getReferences(inputs: VarRef): Ref[];
13
+ export declare function getReferences(inputs: Record<string, VarRef>): Ref[];
14
14
  export declare function topSort(fn: GraphedFunction): GraphedFunction;
15
- export interface ExecutionContext {
16
- scope: Record<string, Record<string, Tree<any>>>;
17
- calls: Record<string, FunctionCall>;
18
- inputs: Record<string, Record<string, Tree<any>>>;
19
- params: Record<string, Record<string, any>>;
20
- timings: Record<string, number>;
21
- activations: Record<string, boolean>;
22
- }
23
15
  export interface EngineStartEvent {
24
16
  name: string;
25
17
  fn: string;
@@ -61,8 +53,8 @@ export declare class Engine<Env extends Record<string, any> = Record<string, any
61
53
  fireEvent(eventName: "result", event: EngineEndEvent): void;
62
54
  fireEvent(eventName: "functionCall", event: EngineStartEvent): void;
63
55
  fireEvent(eventName: "functionResult", event: EngineEndEvent): void;
64
- run(node: AnyFunction, inputs?: VarRef): any;
65
- runDetailed(node: AnyFunction, inputs?: VarRef): Promise<EngineEndEvent>;
56
+ run(node: AnyFunction, inputs?: Record<string, VarRef>): any;
57
+ runDetailed(node: AnyFunction, inputs?: Record<string, VarRef>): Promise<EngineEndEvent>;
66
58
  getFunction(name: string): PrimitiveFunction | undefined;
67
59
  applyNodeDelete(oldFn: GraphedFunction, nodeIds: string[]): GraphedFunction;
68
60
  applyEdgeDelete(oldFn: GraphedFunction, fromNode: string, toNode: string, fromField: string, toField: string): GraphedFunction;
@@ -1,4 +1,4 @@
1
- import { Engine, ExecutionContext } from ".";
1
+ import { Engine } from ".";
2
2
  import { Tree } from "../DataTree";
3
3
  /**
4
4
  * type definition of rule inputs and outputs
@@ -16,12 +16,17 @@ export type NormalizedVarDef = {
16
16
  allowEmpty?: boolean;
17
17
  controlProps?: Record<string, any>;
18
18
  };
19
+ /**
20
+ * description of an input for a function, it is either a string indicating the type,
21
+ * or a normalized variable definition, containing detailed metadata about the input like
22
+ * type, label, options, min, max etc, see NormalizedVarDef
23
+ */
19
24
  export type VarDef = string | NormalizedVarDef;
25
+ export type VarRefPrimitive = string | number | boolean | Object;
20
26
  /**
21
27
  * a reference to the output of an previous function call or a primitive value
22
28
  */
23
- export type VarRefValue = string | number | boolean | Object;
24
- export type VarRef = Record<string, VarRefValue | VarRefValue[]>;
29
+ export type VarRef = VarRefPrimitive | VarRefPrimitive[];
25
30
  export type RecOfTrees = Record<string, Tree<any>>;
26
31
  /**
27
32
  * primitive node, with input and output definitions and an implementation
@@ -47,8 +52,8 @@ export type PrimitiveFunction = {
47
52
  export type FunctionCall = {
48
53
  name: string;
49
54
  label?: string;
50
- inputs?: VarRef;
51
- params?: VarRef;
55
+ inputs?: Record<string, VarRef>;
56
+ params?: Record<string, VarRef>;
52
57
  inputDefs?: Record<string, VarDef>;
53
58
  outputDefs?: Record<string, VarDef>;
54
59
  };
@@ -62,7 +67,15 @@ export type GraphedFunction = {
62
67
  description?: string;
63
68
  params?: Record<string, VarDef>;
64
69
  inputs?: Record<string, VarDef>;
65
- outputs?: VarRef;
70
+ outputs?: Record<string, VarRef>;
66
71
  body: Record<string, FunctionCall>;
67
72
  };
68
73
  export type AnyFunction = PrimitiveFunction | GraphedFunction;
74
+ export interface ExecutionContext {
75
+ scope: Record<string, Record<string, Tree<any>>>;
76
+ calls: Record<string, FunctionCall>;
77
+ inputs: Record<string, Record<string, Tree<any>>>;
78
+ params: Record<string, Record<string, any>>;
79
+ timings: Record<string, number>;
80
+ activations: Record<string, boolean>;
81
+ }
@@ -7,4 +7,4 @@ export declare function parseReference(ref: string): string;
7
7
  export declare function uid(): string;
8
8
  export declare function getValue(obj: Record<string, any>, path: string): any;
9
9
  export declare function safeName(name: string): string;
10
- export declare function interpolate(inputs: VarRef, scope: Record<string, Record<string, Tree<any>>>): Record<string, Tree<any>>;
10
+ export declare function interpolate(inputs: Record<string, VarRef>, scope: Record<string, Record<string, Tree<any>>>): Record<string, Tree<any>>;
@@ -4,9 +4,9 @@ export type FunctionNode = Node<{
4
4
  name: string;
5
5
  label: string;
6
6
  description?: string;
7
- inputs?: VarRef;
8
- params?: VarRef;
9
- outputs?: VarRef;
7
+ inputs?: Record<string, VarRef>;
8
+ params?: Record<string, VarRef>;
9
+ outputs?: Record<string, VarRef>;
10
10
  inputDefs: Record<string, VarDef>;
11
11
  paramDefs: Record<string, VarDef>;
12
12
  outputDefs: Record<string, VarDef>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rkmodules/rules",
3
- "version": "0.0.168",
3
+ "version": "0.0.169",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- import { PrimitiveFunction } from "../../Engine/types";
2
- export declare const listSlice: PrimitiveFunction;