@fbp/evaluator 0.2.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/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.graphqlRequestDef = exports.netDefinitions = exports.stringConcatDef = exports.stringTemplateDef = exports.flowGuardDef = exports.jsonObjectDef = exports.jsonSelectDef = exports.coreDefinitions = exports.graphPropDef = exports.graphOutputDef = exports.graphInputDef = exports.textDef = exports.buttonDef = exports.inputDef = exports.formDef = exports.pageDef = exports.uiDefinitions = exports.multiplyDef = exports.addDef = exports.constNumberDef = exports.mathDefinitions = exports.evaluate = void 0;
4
+ var evaluate_1 = require("./evaluate");
5
+ Object.defineProperty(exports, "evaluate", { enumerable: true, get: function () { return evaluate_1.evaluate; } });
6
+ // Re-export node definitions for convenience
7
+ var math_1 = require("./definitions/math");
8
+ Object.defineProperty(exports, "mathDefinitions", { enumerable: true, get: function () { return math_1.mathDefinitions; } });
9
+ Object.defineProperty(exports, "constNumberDef", { enumerable: true, get: function () { return math_1.constNumberDef; } });
10
+ Object.defineProperty(exports, "addDef", { enumerable: true, get: function () { return math_1.addDef; } });
11
+ Object.defineProperty(exports, "multiplyDef", { enumerable: true, get: function () { return math_1.multiplyDef; } });
12
+ var ui_1 = require("./definitions/ui");
13
+ Object.defineProperty(exports, "uiDefinitions", { enumerable: true, get: function () { return ui_1.uiDefinitions; } });
14
+ Object.defineProperty(exports, "pageDef", { enumerable: true, get: function () { return ui_1.pageDef; } });
15
+ Object.defineProperty(exports, "formDef", { enumerable: true, get: function () { return ui_1.formDef; } });
16
+ Object.defineProperty(exports, "inputDef", { enumerable: true, get: function () { return ui_1.inputDef; } });
17
+ Object.defineProperty(exports, "buttonDef", { enumerable: true, get: function () { return ui_1.buttonDef; } });
18
+ Object.defineProperty(exports, "textDef", { enumerable: true, get: function () { return ui_1.textDef; } });
19
+ Object.defineProperty(exports, "graphInputDef", { enumerable: true, get: function () { return ui_1.graphInputDef; } });
20
+ Object.defineProperty(exports, "graphOutputDef", { enumerable: true, get: function () { return ui_1.graphOutputDef; } });
21
+ Object.defineProperty(exports, "graphPropDef", { enumerable: true, get: function () { return ui_1.graphPropDef; } });
22
+ var core_1 = require("./definitions/core");
23
+ Object.defineProperty(exports, "coreDefinitions", { enumerable: true, get: function () { return core_1.coreDefinitions; } });
24
+ Object.defineProperty(exports, "jsonSelectDef", { enumerable: true, get: function () { return core_1.jsonSelectDef; } });
25
+ Object.defineProperty(exports, "jsonObjectDef", { enumerable: true, get: function () { return core_1.jsonObjectDef; } });
26
+ Object.defineProperty(exports, "flowGuardDef", { enumerable: true, get: function () { return core_1.flowGuardDef; } });
27
+ Object.defineProperty(exports, "stringTemplateDef", { enumerable: true, get: function () { return core_1.stringTemplateDef; } });
28
+ Object.defineProperty(exports, "stringConcatDef", { enumerable: true, get: function () { return core_1.stringConcatDef; } });
29
+ var net_1 = require("./definitions/net");
30
+ Object.defineProperty(exports, "netDefinitions", { enumerable: true, get: function () { return net_1.netDefinitions; } });
31
+ Object.defineProperty(exports, "graphqlRequestDef", { enumerable: true, get: function () { return net_1.graphqlRequestDef; } });
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@fbp/evaluator",
3
+ "version": "0.2.0",
4
+ "author": "Dan Lynch <pyramation@gmail.com>",
5
+ "description": "Lazy graph evaluator for Flow-Based Programming",
6
+ "main": "index.js",
7
+ "module": "esm/index.js",
8
+ "types": "index.d.ts",
9
+ "homepage": "https://github.com/constructive-io/fbp",
10
+ "license": "MIT",
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "directory": "dist"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/constructive-io/fbp"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/constructive-io/fbp/issues"
21
+ },
22
+ "scripts": {
23
+ "clean": "makage clean",
24
+ "prepack": "npm run build",
25
+ "build": "makage build",
26
+ "build:dev": "makage build --dev",
27
+ "lint": "eslint . --fix",
28
+ "test": "jest",
29
+ "test:watch": "jest --watch"
30
+ },
31
+ "keywords": [
32
+ "fbp",
33
+ "evaluator",
34
+ "flow-based-programming",
35
+ "lazy-evaluation"
36
+ ],
37
+ "dependencies": {
38
+ "@fbp/types": "0.3.0"
39
+ },
40
+ "devDependencies": {
41
+ "makage": "0.1.9"
42
+ },
43
+ "gitHead": "df9788647c06b6a034adbca2438995dd415eb7f5"
44
+ }
package/types.d.ts ADDED
@@ -0,0 +1,38 @@
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
+ }
package/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });