@fbp/evaluator 1.1.0 → 1.3.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/README.md +4 -84
- package/definitions/core.d.ts +60 -6
- package/definitions/core.js +422 -19
- package/definitions/math.d.ts +1 -0
- package/definitions/math.js +18 -2
- package/esm/definitions/core.js +421 -18
- package/esm/definitions/math.js +17 -1
- package/esm/evaluate.js +67 -9
- package/esm/index.js +5 -4
- package/esm/validate.js +147 -0
- package/evaluate.js +67 -9
- package/index.d.ts +7 -5
- package/index.js +31 -18
- package/package.json +20 -26
- package/validate.d.ts +54 -0
- package/validate.js +150 -0
- package/esm/definitions/core.d.ts +0 -72
- package/esm/definitions/math.d.ts +0 -8
- package/esm/definitions/net.d.ts +0 -25
- package/esm/definitions/ui.d.ts +0 -10
- package/esm/evaluate.d.ts +0 -12
- package/esm/index.d.ts +0 -6
- package/esm/types.d.ts +0 -38
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { NodeDefinitionWithImpl } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Core node definitions with implementations.
|
|
4
|
-
* These nodes handle JSON manipulation, flow control, and string operations.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* core/json/select - Extract a value from JSON by path
|
|
8
|
-
*
|
|
9
|
-
* Props:
|
|
10
|
-
* - path: string (dot-path like "a.b.c" or "data.user.email")
|
|
11
|
-
*
|
|
12
|
-
* Inputs:
|
|
13
|
-
* - obj: json (the object to extract from)
|
|
14
|
-
*
|
|
15
|
-
* Outputs:
|
|
16
|
-
* - value: any (the extracted value)
|
|
17
|
-
*/
|
|
18
|
-
export declare const jsonSelectDef: NodeDefinitionWithImpl;
|
|
19
|
-
/**
|
|
20
|
-
* core/json/object - Build a JSON object from named inputs
|
|
21
|
-
*
|
|
22
|
-
* This node has dynamic inputs - any input wired to it becomes a key in the output object.
|
|
23
|
-
* The implementation receives all inputs as a Record<string, any>.
|
|
24
|
-
*
|
|
25
|
-
* Inputs:
|
|
26
|
-
* - (dynamic) arbitrary named inputs
|
|
27
|
-
*
|
|
28
|
-
* Outputs:
|
|
29
|
-
* - value: json (the constructed object)
|
|
30
|
-
*/
|
|
31
|
-
export declare const jsonObjectDef: NodeDefinitionWithImpl;
|
|
32
|
-
/**
|
|
33
|
-
* core/flow/guard - Stop the flow if a condition fails
|
|
34
|
-
*
|
|
35
|
-
* Inputs:
|
|
36
|
-
* - ok: boolean (the condition to check)
|
|
37
|
-
* - error?: json (optional error info)
|
|
38
|
-
*
|
|
39
|
-
* Outputs:
|
|
40
|
-
* - pass: signal (emitted if ok is true)
|
|
41
|
-
* - fail: signal (emitted if ok is false)
|
|
42
|
-
* - error: json (the error if failed)
|
|
43
|
-
*/
|
|
44
|
-
export declare const flowGuardDef: NodeDefinitionWithImpl;
|
|
45
|
-
/**
|
|
46
|
-
* core/string/template - Build a string from a template with placeholders
|
|
47
|
-
*
|
|
48
|
-
* Props:
|
|
49
|
-
* - template: string (template with {{placeholder}} syntax)
|
|
50
|
-
*
|
|
51
|
-
* Inputs:
|
|
52
|
-
* - (dynamic) values to substitute into the template
|
|
53
|
-
*
|
|
54
|
-
* Outputs:
|
|
55
|
-
* - value: string (the resulting string)
|
|
56
|
-
*/
|
|
57
|
-
export declare const stringTemplateDef: NodeDefinitionWithImpl;
|
|
58
|
-
/**
|
|
59
|
-
* core/string/concat - Concatenate strings with an optional separator
|
|
60
|
-
*
|
|
61
|
-
* Props:
|
|
62
|
-
* - prefix: string (optional prefix)
|
|
63
|
-
* - suffix: string (optional suffix)
|
|
64
|
-
*
|
|
65
|
-
* Inputs:
|
|
66
|
-
* - value: string (the main value)
|
|
67
|
-
*
|
|
68
|
-
* Outputs:
|
|
69
|
-
* - value: string (the resulting string)
|
|
70
|
-
*/
|
|
71
|
-
export declare const stringConcatDef: NodeDefinitionWithImpl;
|
|
72
|
-
export declare const coreDefinitions: NodeDefinitionWithImpl[];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { NodeDefinitionWithImpl } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Math node definitions with implementations for testing.
|
|
4
|
-
*/
|
|
5
|
-
export declare const constNumberDef: NodeDefinitionWithImpl;
|
|
6
|
-
export declare const addDef: NodeDefinitionWithImpl;
|
|
7
|
-
export declare const multiplyDef: NodeDefinitionWithImpl;
|
|
8
|
-
export declare const mathDefinitions: NodeDefinitionWithImpl[];
|
package/esm/definitions/net.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { NodeDefinitionWithImpl } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Network node definitions with implementations.
|
|
4
|
-
* These nodes handle GraphQL requests and related operations.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* net/graphql/request - Execute GraphQL query or mutation
|
|
8
|
-
*
|
|
9
|
-
* Props:
|
|
10
|
-
* - document: string (GraphQL query/mutation document)
|
|
11
|
-
* - operationName?: string (optional operation name)
|
|
12
|
-
* - endpoint: string (GraphQL endpoint URL)
|
|
13
|
-
* - timeout?: number (request timeout in ms, default 30000)
|
|
14
|
-
*
|
|
15
|
-
* Inputs:
|
|
16
|
-
* - variables: json (GraphQL variables)
|
|
17
|
-
* - headers?: json (additional headers)
|
|
18
|
-
*
|
|
19
|
-
* Outputs:
|
|
20
|
-
* - data: json (response data)
|
|
21
|
-
* - error?: json (error if any)
|
|
22
|
-
* - ok: boolean (true if request succeeded without errors)
|
|
23
|
-
*/
|
|
24
|
-
export declare const graphqlRequestDef: NodeDefinitionWithImpl;
|
|
25
|
-
export declare const netDefinitions: NodeDefinitionWithImpl[];
|
package/esm/definitions/ui.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { NodeDefinitionWithImpl } from '../types';
|
|
2
|
-
export declare const graphInputDef: NodeDefinitionWithImpl;
|
|
3
|
-
export declare const graphOutputDef: NodeDefinitionWithImpl;
|
|
4
|
-
export declare const graphPropDef: NodeDefinitionWithImpl;
|
|
5
|
-
export declare const pageDef: NodeDefinitionWithImpl;
|
|
6
|
-
export declare const formDef: NodeDefinitionWithImpl;
|
|
7
|
-
export declare const inputDef: NodeDefinitionWithImpl;
|
|
8
|
-
export declare const buttonDef: NodeDefinitionWithImpl;
|
|
9
|
-
export declare const textDef: NodeDefinitionWithImpl;
|
|
10
|
-
export declare const uiDefinitions: NodeDefinitionWithImpl[];
|
package/esm/evaluate.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Graph } from '@fbp/types';
|
|
2
|
-
import type { EvaluateOptions } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Evaluate a graph starting from the specified output node/port.
|
|
5
|
-
* Uses lazy evaluation - only evaluates nodes that are needed for the output.
|
|
6
|
-
* Fully async to support async node implementations.
|
|
7
|
-
*
|
|
8
|
-
* @param graph - The graph to evaluate
|
|
9
|
-
* @param options - Evaluation options including definitions, output node/port, and external inputs
|
|
10
|
-
* @returns Promise resolving to the value at the specified output port
|
|
11
|
-
*/
|
|
12
|
-
export declare function evaluate(graph: Graph, options: EvaluateOptions): Promise<any>;
|
package/esm/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { evaluate } from './evaluate';
|
|
2
|
-
export type { NodeImplFn, NodeDefinitionWithImpl, EvaluateOptions, PropDefinitionWithOptions } from './types';
|
|
3
|
-
export { mathDefinitions, constNumberDef, addDef, multiplyDef } from './definitions/math';
|
|
4
|
-
export { uiDefinitions, pageDef, formDef, inputDef, buttonDef, textDef, graphInputDef, graphOutputDef, graphPropDef } from './definitions/ui';
|
|
5
|
-
export { coreDefinitions, jsonSelectDef, jsonObjectDef, flowGuardDef, stringTemplateDef, stringConcatDef } from './definitions/core';
|
|
6
|
-
export { netDefinitions, graphqlRequestDef } from './definitions/net';
|
package/esm/types.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { NodeDefinition, PropDefinition } from '@fbp/types';
|
|
2
|
-
/**
|
|
3
|
-
* A function that implements a node's computation.
|
|
4
|
-
* Takes inputs (keyed by port name) and props, returns outputs (keyed by port name).
|
|
5
|
-
* Can be sync or async - the evaluator will await the result.
|
|
6
|
-
*/
|
|
7
|
-
export type NodeImplFn = (inputs: Record<string, any>, props: Record<string, any>) => Record<string, any> | Promise<Record<string, any>>;
|
|
8
|
-
/**
|
|
9
|
-
* Extended PropDefinition with runtime-only options for enum/select types.
|
|
10
|
-
* The options field is not part of the JSON schema but is used by the UI.
|
|
11
|
-
*/
|
|
12
|
-
export interface PropDefinitionWithOptions extends PropDefinition {
|
|
13
|
-
options?: string[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A NodeDefinition extended with an optional implementation function.
|
|
17
|
-
* The impl function is not part of the JSON schema (not serializable),
|
|
18
|
-
* but is used at runtime for evaluation.
|
|
19
|
-
*/
|
|
20
|
-
export interface NodeDefinitionWithImpl extends Omit<NodeDefinition, 'props'> {
|
|
21
|
-
props?: PropDefinitionWithOptions[];
|
|
22
|
-
impl?: NodeImplFn;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Options for the evaluate function.
|
|
26
|
-
*/
|
|
27
|
-
export interface EvaluateOptions {
|
|
28
|
-
/** Node definitions with implementations */
|
|
29
|
-
definitions: NodeDefinitionWithImpl[];
|
|
30
|
-
/** The node to get output from */
|
|
31
|
-
outputNode: string;
|
|
32
|
-
/** The port to get output from */
|
|
33
|
-
outputPort: string;
|
|
34
|
-
/** External inputs to provide to graphInput nodes (keyed by portName property value) */
|
|
35
|
-
inputs?: Record<string, any>;
|
|
36
|
-
/** Props to provide to graphProp nodes (keyed by propName property value) */
|
|
37
|
-
props?: Record<string, any>;
|
|
38
|
-
}
|