@rkmodules/rules 0.0.167 → 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.
- package/dist/index.cjs.js +14 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +15 -25
- package/dist/index.esm.mjs.map +1 -1
- package/dist/lib/Engine/index.d.ts +7 -15
- package/dist/lib/Engine/types.d.ts +19 -6
- package/dist/lib/Engine/util.d.ts +1 -1
- package/dist/lib/Flow/Context.d.ts +1 -1
- package/dist/lib/Flow/types.d.ts +3 -3
- package/package.json +1 -1
- package/dist/lib/Primitives/List/listSlice.d.ts +0 -2
|
@@ -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;
|
|
@@ -36,14 +28,14 @@ export interface EngineEndEvent extends EngineStartEvent {
|
|
|
36
28
|
}
|
|
37
29
|
export type EngineEvent = EngineStartEvent | EngineEndEvent;
|
|
38
30
|
export type EngineEventName = "result" | "functionCall" | "functionResult";
|
|
39
|
-
export declare class Engine {
|
|
31
|
+
export declare class Engine<Env extends Record<string, any> = Record<string, any>> {
|
|
40
32
|
private fnIndex;
|
|
41
33
|
private listeners;
|
|
42
34
|
private cache;
|
|
43
35
|
private cacheMiss;
|
|
44
36
|
private context;
|
|
45
|
-
env:
|
|
46
|
-
constructor(morePrimitives?: Record<string, PrimitiveFunction>, env?:
|
|
37
|
+
env: Env;
|
|
38
|
+
constructor(morePrimitives?: Record<string, PrimitiveFunction>, env?: Env);
|
|
47
39
|
private checkCache;
|
|
48
40
|
private runGraph;
|
|
49
41
|
/**
|
|
@@ -61,8 +53,8 @@ export declare class Engine {
|
|
|
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
|
|
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
|
|
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:
|
|
10
|
+
export declare function interpolate(inputs: Record<string, VarRef>, scope: Record<string, Record<string, Tree<any>>>): Record<string, Tree<any>>;
|
|
@@ -9,7 +9,7 @@ type FlowContextState = {
|
|
|
9
9
|
prompts?: Prompts;
|
|
10
10
|
};
|
|
11
11
|
export declare const FlowContext: React.Context<FlowContextState>;
|
|
12
|
-
export declare const useEngine: () => Engine
|
|
12
|
+
export declare const useEngine: () => Engine<Record<string, any>>;
|
|
13
13
|
export declare const useControls: () => {};
|
|
14
14
|
export declare const useGraphedFunction: () => GraphedFunction;
|
|
15
15
|
export declare const usePrompts: () => {
|
package/dist/lib/Flow/types.d.ts
CHANGED
|
@@ -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