@gravity-platform/flow 1.1.3
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/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/ClientStorage/index.d.ts +2 -0
- package/dist/ClientStorage/index.d.ts.map +1 -0
- package/dist/ClientStorage/index.js +6 -0
- package/dist/ClientStorage/index.js.map +1 -0
- package/dist/ClientStorage/node/executor.d.ts +7 -0
- package/dist/ClientStorage/node/executor.d.ts.map +1 -0
- package/dist/ClientStorage/node/executor.js +32 -0
- package/dist/ClientStorage/node/executor.js.map +1 -0
- package/dist/ClientStorage/node/index.d.ts +10 -0
- package/dist/ClientStorage/node/index.d.ts.map +1 -0
- package/dist/ClientStorage/node/index.js +64 -0
- package/dist/ClientStorage/node/index.js.map +1 -0
- package/dist/ClientStorage/util/types.d.ts +12 -0
- package/dist/ClientStorage/util/types.d.ts.map +1 -0
- package/dist/ClientStorage/util/types.js +3 -0
- package/dist/ClientStorage/util/types.js.map +1 -0
- package/dist/Code/executor.d.ts +24 -0
- package/dist/Code/executor.d.ts.map +1 -0
- package/dist/Code/executor.js +70 -0
- package/dist/Code/executor.js.map +1 -0
- package/dist/Code/index.d.ts +14 -0
- package/dist/Code/index.d.ts.map +1 -0
- package/dist/Code/index.js +79 -0
- package/dist/Code/index.js.map +1 -0
- package/dist/Code/utils/hashUtils.d.ts +18 -0
- package/dist/Code/utils/hashUtils.d.ts.map +1 -0
- package/dist/Code/utils/hashUtils.js +40 -0
- package/dist/Code/utils/hashUtils.js.map +1 -0
- package/dist/Context/executor.d.ts +16 -0
- package/dist/Context/executor.d.ts.map +1 -0
- package/dist/Context/executor.js +47 -0
- package/dist/Context/executor.js.map +1 -0
- package/dist/Context/index.d.ts +14 -0
- package/dist/Context/index.d.ts.map +1 -0
- package/dist/Context/index.js +45 -0
- package/dist/Context/index.js.map +1 -0
- package/dist/FieldValidator/executor.d.ts +40 -0
- package/dist/FieldValidator/executor.d.ts.map +1 -0
- package/dist/FieldValidator/executor.js +152 -0
- package/dist/FieldValidator/executor.js.map +1 -0
- package/dist/FieldValidator/index.d.ts +18 -0
- package/dist/FieldValidator/index.d.ts.map +1 -0
- package/dist/FieldValidator/index.js +80 -0
- package/dist/FieldValidator/index.js.map +1 -0
- package/dist/FieldValidator/utils/types.d.ts +25 -0
- package/dist/FieldValidator/utils/types.d.ts.map +1 -0
- package/dist/FieldValidator/utils/types.js +7 -0
- package/dist/FieldValidator/utils/types.js.map +1 -0
- package/dist/IfElse/executor.d.ts +24 -0
- package/dist/IfElse/executor.d.ts.map +1 -0
- package/dist/IfElse/executor.js +54 -0
- package/dist/IfElse/executor.js.map +1 -0
- package/dist/IfElse/index.d.ts +14 -0
- package/dist/IfElse/index.d.ts.map +1 -0
- package/dist/IfElse/index.js +61 -0
- package/dist/IfElse/index.js.map +1 -0
- package/dist/Loop/executor.d.ts +45 -0
- package/dist/Loop/executor.d.ts.map +1 -0
- package/dist/Loop/executor.js +182 -0
- package/dist/Loop/executor.js.map +1 -0
- package/dist/Loop/index.d.ts +15 -0
- package/dist/Loop/index.d.ts.map +1 -0
- package/dist/Loop/index.js +92 -0
- package/dist/Loop/index.js.map +1 -0
- package/dist/Loop/utils/index.d.ts +5 -0
- package/dist/Loop/utils/index.d.ts.map +1 -0
- package/dist/Loop/utils/index.js +21 -0
- package/dist/Loop/utils/index.js.map +1 -0
- package/dist/Loop/utils/types.d.ts +24 -0
- package/dist/Loop/utils/types.d.ts.map +1 -0
- package/dist/Loop/utils/types.js +6 -0
- package/dist/Loop/utils/types.js.map +1 -0
- package/dist/MCP/node/executor.d.ts +14 -0
- package/dist/MCP/node/executor.d.ts.map +1 -0
- package/dist/MCP/node/executor.js +99 -0
- package/dist/MCP/node/executor.js.map +1 -0
- package/dist/MCP/node/index.d.ts +10 -0
- package/dist/MCP/node/index.d.ts.map +1 -0
- package/dist/MCP/node/index.js +73 -0
- package/dist/MCP/node/index.js.map +1 -0
- package/dist/MCP/util/types.d.ts +62 -0
- package/dist/MCP/util/types.d.ts.map +1 -0
- package/dist/MCP/util/types.js +6 -0
- package/dist/MCP/util/types.js.map +1 -0
- package/dist/Note/executor.d.ts +16 -0
- package/dist/Note/executor.d.ts.map +1 -0
- package/dist/Note/executor.js +20 -0
- package/dist/Note/executor.js.map +1 -0
- package/dist/Note/index.d.ts +14 -0
- package/dist/Note/index.d.ts.map +1 -0
- package/dist/Note/index.js +82 -0
- package/dist/Note/index.js.map +1 -0
- package/dist/Relay/executor.d.ts +15 -0
- package/dist/Relay/executor.d.ts.map +1 -0
- package/dist/Relay/executor.js +68 -0
- package/dist/Relay/executor.js.map +1 -0
- package/dist/Relay/index.d.ts +15 -0
- package/dist/Relay/index.d.ts.map +1 -0
- package/dist/Relay/index.js +58 -0
- package/dist/Relay/index.js.map +1 -0
- package/dist/SendObject/index.d.ts +2 -0
- package/dist/SendObject/index.d.ts.map +1 -0
- package/dist/SendObject/index.js +6 -0
- package/dist/SendObject/index.js.map +1 -0
- package/dist/SendObject/node/executor.d.ts +7 -0
- package/dist/SendObject/node/executor.d.ts.map +1 -0
- package/dist/SendObject/node/executor.js +57 -0
- package/dist/SendObject/node/executor.js.map +1 -0
- package/dist/SendObject/node/index.d.ts +10 -0
- package/dist/SendObject/node/index.d.ts.map +1 -0
- package/dist/SendObject/node/index.js +64 -0
- package/dist/SendObject/node/index.js.map +1 -0
- package/dist/SendObject/service/publishObject.d.ts +21 -0
- package/dist/SendObject/service/publishObject.d.ts.map +1 -0
- package/dist/SendObject/service/publishObject.js +55 -0
- package/dist/SendObject/service/publishObject.js.map +1 -0
- package/dist/SendObject/util/types.d.ts +11 -0
- package/dist/SendObject/util/types.d.ts.map +1 -0
- package/dist/SendObject/util/types.js +3 -0
- package/dist/SendObject/util/types.js.map +1 -0
- package/dist/Suggestions/executor.d.ts +36 -0
- package/dist/Suggestions/executor.d.ts.map +1 -0
- package/dist/Suggestions/executor.js +116 -0
- package/dist/Suggestions/executor.js.map +1 -0
- package/dist/Suggestions/index.d.ts +14 -0
- package/dist/Suggestions/index.d.ts.map +1 -0
- package/dist/Suggestions/index.js +75 -0
- package/dist/Suggestions/index.js.map +1 -0
- package/dist/UMAP/executor.d.ts +20 -0
- package/dist/UMAP/executor.d.ts.map +1 -0
- package/dist/UMAP/executor.js +103 -0
- package/dist/UMAP/executor.js.map +1 -0
- package/dist/UMAP/index.d.ts +14 -0
- package/dist/UMAP/index.d.ts.map +1 -0
- package/dist/UMAP/index.js +91 -0
- package/dist/UMAP/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/platform.d.ts +14 -0
- package/dist/shared/platform.d.ts.map +1 -0
- package/dist/shared/platform.js +24 -0
- package/dist/shared/platform.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Context Node Definition
|
|
4
|
+
* Extracts and returns workflow context information
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.definition = exports.ContextNode = exports.NODE_TYPE = void 0;
|
|
8
|
+
exports.createNodeDefinition = createNodeDefinition;
|
|
9
|
+
const plugin_base_1 = require("@gravity-platform/plugin-base");
|
|
10
|
+
const executor_1 = require("./executor");
|
|
11
|
+
// Export node type constant
|
|
12
|
+
exports.NODE_TYPE = "Context";
|
|
13
|
+
// Export a function that creates the definition after platform deps are set
|
|
14
|
+
function createNodeDefinition() {
|
|
15
|
+
const { NodeInputType } = (0, plugin_base_1.getPlatformDependencies)();
|
|
16
|
+
return {
|
|
17
|
+
packageVersion: "1.1.1",
|
|
18
|
+
type: exports.NODE_TYPE,
|
|
19
|
+
isService: false,
|
|
20
|
+
name: "Context",
|
|
21
|
+
description: "Extract workflow context (userId, conversationId, chatId, etc.)",
|
|
22
|
+
category: "Flow",
|
|
23
|
+
color: "#f59e0b", // Amber color for code/logic
|
|
24
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1750052178/gravity/icons/6359572-200.png",
|
|
25
|
+
inputs: [
|
|
26
|
+
{
|
|
27
|
+
name: "signal",
|
|
28
|
+
type: NodeInputType.ANY,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
outputs: [{ name: "context", type: NodeInputType.OBJECT }],
|
|
32
|
+
// Declare capabilities
|
|
33
|
+
capabilities: {
|
|
34
|
+
isTrigger: false,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Export as enhanced node
|
|
39
|
+
exports.ContextNode = {
|
|
40
|
+
definition: createNodeDefinition(),
|
|
41
|
+
executor: executor_1.ContextExecutor,
|
|
42
|
+
};
|
|
43
|
+
// Export for node registry
|
|
44
|
+
exports.definition = createNodeDefinition();
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Context/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,oDAwBC;AA/BD,+DAAqG;AACrG,yCAA6C;AAE7C,4BAA4B;AACf,QAAA,SAAS,GAAG,SAAS,CAAC;AAEnC,4EAA4E;AAC5E,SAAgB,oBAAoB;IAClC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,qCAAuB,GAAE,CAAC;IAEpD,OAAO;QACL,cAAc,EAAE,OAAO;QACvB,IAAI,EAAE,iBAAS;QACf,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,iEAAiE;QAC9E,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,SAAS,EAAE,6BAA6B;QAC/C,OAAO,EAAE,yFAAyF;QAClG,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,aAAa,CAAC,GAAG;aACxB;SACF;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC;QAC1D,uBAAuB;QACvB,YAAY,EAAE;YACZ,SAAS,EAAE,KAAK;SACjB;KACF,CAAC;AACJ,CAAC;AAED,0BAA0B;AACb,QAAA,WAAW,GAAG;IACzB,UAAU,EAAE,oBAAoB,EAAE;IAClC,QAAQ,EAAE,0BAAe;CAC1B,CAAC;AAEF,2BAA2B;AACd,QAAA,UAAU,GAAG,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldValidator Node Executor
|
|
3
|
+
* Compares incoming data against required schema and identifies missing fields
|
|
4
|
+
*
|
|
5
|
+
* Logic:
|
|
6
|
+
* 1. Extract field names from requiredSchema
|
|
7
|
+
* 2. Check which fields are missing in incomingData
|
|
8
|
+
* 3. Return next missing field based on priority order
|
|
9
|
+
* 4. Calculate completion percentage
|
|
10
|
+
*/
|
|
11
|
+
import { NodeExecutionContext, ValidationResult } from "@gravity-platform/plugin-base";
|
|
12
|
+
import { PromiseNode } from "../shared/platform";
|
|
13
|
+
import { FieldValidatorConfig, FieldValidatorOutput } from "./utils/types";
|
|
14
|
+
export default class FieldValidatorExecutor extends PromiseNode<FieldValidatorConfig> {
|
|
15
|
+
constructor();
|
|
16
|
+
protected validateConfig(config: FieldValidatorConfig): Promise<ValidationResult>;
|
|
17
|
+
protected executeNode(inputs: Record<string, any>, config: FieldValidatorConfig, context: NodeExecutionContext): Promise<FieldValidatorOutput>;
|
|
18
|
+
/**
|
|
19
|
+
* Extract field names, required list, and properties map from schema object
|
|
20
|
+
* Supports multiple formats:
|
|
21
|
+
* 1. Tool schema format: { inputSchema: { json: { properties: {...}, required: [...] } } }
|
|
22
|
+
* 2. JSON Schema format: { properties: {...}, required: [...] }
|
|
23
|
+
* 3. Direct properties: { name: {...}, email: {...} }
|
|
24
|
+
*/
|
|
25
|
+
private extractSchemaInfo;
|
|
26
|
+
/**
|
|
27
|
+
* Find which required fields are missing in incoming data
|
|
28
|
+
*/
|
|
29
|
+
private findMissingFields;
|
|
30
|
+
/**
|
|
31
|
+
* Get next field to request
|
|
32
|
+
* Priority: 1) Required fields first, 2) Then schema order
|
|
33
|
+
*/
|
|
34
|
+
private getNextField;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate completion percentage
|
|
37
|
+
*/
|
|
38
|
+
private calculateCompletion;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/FieldValidator/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE3E,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,WAAW,CAAC,oBAAoB,CAAC;;cAKnE,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAKvE,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;IAmDhC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAwCzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAqBpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAQ5B"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FieldValidator Node Executor
|
|
4
|
+
* Compares incoming data against required schema and identifies missing fields
|
|
5
|
+
*
|
|
6
|
+
* Logic:
|
|
7
|
+
* 1. Extract field names from requiredSchema
|
|
8
|
+
* 2. Check which fields are missing in incomingData
|
|
9
|
+
* 3. Return next missing field based on priority order
|
|
10
|
+
* 4. Calculate completion percentage
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const platform_1 = require("../shared/platform");
|
|
14
|
+
class FieldValidatorExecutor extends platform_1.PromiseNode {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("FieldValidator");
|
|
17
|
+
}
|
|
18
|
+
async validateConfig(config) {
|
|
19
|
+
// Config validation happens in the template resolver
|
|
20
|
+
return { success: true };
|
|
21
|
+
}
|
|
22
|
+
async executeNode(inputs, config, context) {
|
|
23
|
+
try {
|
|
24
|
+
const { requiredSchema, incomingData } = config;
|
|
25
|
+
this.logger.info("FieldValidator executing", {
|
|
26
|
+
nodeId: context.nodeId,
|
|
27
|
+
requiredSchema,
|
|
28
|
+
incomingData,
|
|
29
|
+
});
|
|
30
|
+
// Extract field names, required list, and properties map from schema
|
|
31
|
+
const { fieldNames, requiredList, propertiesMap } = this.extractSchemaInfo(requiredSchema);
|
|
32
|
+
// Identify missing fields (preserves order)
|
|
33
|
+
const missingFields = this.findMissingFields(fieldNames, incomingData);
|
|
34
|
+
// Get next field prioritized by required list, then schema order
|
|
35
|
+
const nextField = this.getNextField(missingFields, requiredList);
|
|
36
|
+
// Get schema definition for next field
|
|
37
|
+
const nextFieldSchema = nextField ? propertiesMap[nextField] : undefined;
|
|
38
|
+
// Calculate completion
|
|
39
|
+
const completionPercentage = this.calculateCompletion(fieldNames, missingFields);
|
|
40
|
+
const isComplete = missingFields.length === 0;
|
|
41
|
+
this.logger.info("FieldValidator result", {
|
|
42
|
+
fieldNames,
|
|
43
|
+
requiredList,
|
|
44
|
+
missingFields,
|
|
45
|
+
nextField,
|
|
46
|
+
nextFieldSchema,
|
|
47
|
+
completionPercentage,
|
|
48
|
+
isComplete,
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
__outputs: {
|
|
52
|
+
nextField,
|
|
53
|
+
nextFieldSchema,
|
|
54
|
+
missingFields,
|
|
55
|
+
isComplete,
|
|
56
|
+
completionPercentage,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
this.logger.error(`FieldValidator execution failed:`, error);
|
|
62
|
+
throw new Error(`FieldValidator execution failed: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract field names, required list, and properties map from schema object
|
|
67
|
+
* Supports multiple formats:
|
|
68
|
+
* 1. Tool schema format: { inputSchema: { json: { properties: {...}, required: [...] } } }
|
|
69
|
+
* 2. JSON Schema format: { properties: {...}, required: [...] }
|
|
70
|
+
* 3. Direct properties: { name: {...}, email: {...} }
|
|
71
|
+
*/
|
|
72
|
+
extractSchemaInfo(schema) {
|
|
73
|
+
if (!schema || typeof schema !== "object") {
|
|
74
|
+
this.logger.warn("Invalid schema provided, returning empty arrays");
|
|
75
|
+
return { fieldNames: [], requiredList: [], propertiesMap: {} };
|
|
76
|
+
}
|
|
77
|
+
// Check if this is a tool schema format with nested inputSchema.json
|
|
78
|
+
if (schema.inputSchema?.json?.properties) {
|
|
79
|
+
this.logger.info("Detected tool schema format, extracting from inputSchema.json");
|
|
80
|
+
const properties = schema.inputSchema.json.properties;
|
|
81
|
+
return {
|
|
82
|
+
fieldNames: Object.keys(properties),
|
|
83
|
+
requiredList: schema.inputSchema.json.required || [],
|
|
84
|
+
propertiesMap: properties,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Check if this has a direct properties field (JSON Schema format)
|
|
88
|
+
if (schema.properties) {
|
|
89
|
+
this.logger.info("Detected JSON Schema format, extracting from properties");
|
|
90
|
+
return {
|
|
91
|
+
fieldNames: Object.keys(schema.properties),
|
|
92
|
+
requiredList: schema.required || [],
|
|
93
|
+
propertiesMap: schema.properties,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Otherwise treat the schema object itself as the properties
|
|
97
|
+
this.logger.info("Using schema object keys directly as field names");
|
|
98
|
+
return {
|
|
99
|
+
fieldNames: Object.keys(schema),
|
|
100
|
+
requiredList: [],
|
|
101
|
+
propertiesMap: schema,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Find which required fields are missing in incoming data
|
|
106
|
+
*/
|
|
107
|
+
findMissingFields(requiredFields, incomingData) {
|
|
108
|
+
if (!incomingData || typeof incomingData !== "object") {
|
|
109
|
+
// All fields are missing if no data provided
|
|
110
|
+
return requiredFields;
|
|
111
|
+
}
|
|
112
|
+
return requiredFields.filter((field) => {
|
|
113
|
+
const value = incomingData[field];
|
|
114
|
+
// Field is missing if undefined, null, or empty string
|
|
115
|
+
return value === undefined || value === null || value === "";
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get next field to request
|
|
120
|
+
* Priority: 1) Required fields first, 2) Then schema order
|
|
121
|
+
*/
|
|
122
|
+
getNextField(missingFields, requiredList) {
|
|
123
|
+
if (missingFields.length === 0) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
// If there's a required list, prioritize required fields first
|
|
127
|
+
if (requiredList && requiredList.length > 0) {
|
|
128
|
+
// Find first missing field that's in the required list
|
|
129
|
+
for (const field of missingFields) {
|
|
130
|
+
if (requiredList.includes(field)) {
|
|
131
|
+
this.logger.info("Next field from required list", { field });
|
|
132
|
+
return field;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Otherwise return first missing field in schema order
|
|
137
|
+
this.logger.info("Next field from schema order", { field: missingFields[0] });
|
|
138
|
+
return missingFields[0];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Calculate completion percentage
|
|
142
|
+
*/
|
|
143
|
+
calculateCompletion(requiredFields, missingFields) {
|
|
144
|
+
if (requiredFields.length === 0) {
|
|
145
|
+
return 100;
|
|
146
|
+
}
|
|
147
|
+
const filledFields = requiredFields.length - missingFields.length;
|
|
148
|
+
return Math.round((filledFields / requiredFields.length) * 100);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.default = FieldValidatorExecutor;
|
|
152
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/FieldValidator/executor.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldValidator Node Definition
|
|
3
|
+
* Validates incoming data against required schema and outputs next missing field
|
|
4
|
+
*
|
|
5
|
+
* Use Case: Power automatic user questions by identifying missing fields
|
|
6
|
+
* Example: Schema with required: ["email", "phone"], data has {name: "John"}
|
|
7
|
+
* → Outputs "email" as next missing field (required fields prioritized)
|
|
8
|
+
*
|
|
9
|
+
* Priority: 1) Fields in "required" array first, 2) Then schema property order
|
|
10
|
+
*/
|
|
11
|
+
import FieldValidatorExecutor from "./executor";
|
|
12
|
+
export declare const NODE_TYPE = "FieldValidator";
|
|
13
|
+
export declare const FieldValidatorNode: {
|
|
14
|
+
definition: any;
|
|
15
|
+
executor: typeof FieldValidatorExecutor;
|
|
16
|
+
};
|
|
17
|
+
export declare const definition: any;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FieldValidator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,sBAAsB,MAAM,YAAY,CAAC;AAGhD,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAwD1C,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAGF,eAAO,MAAM,UAAU,KAAyB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FieldValidator Node Definition
|
|
4
|
+
* Validates incoming data against required schema and outputs next missing field
|
|
5
|
+
*
|
|
6
|
+
* Use Case: Power automatic user questions by identifying missing fields
|
|
7
|
+
* Example: Schema with required: ["email", "phone"], data has {name: "John"}
|
|
8
|
+
* → Outputs "email" as next missing field (required fields prioritized)
|
|
9
|
+
*
|
|
10
|
+
* Priority: 1) Fields in "required" array first, 2) Then schema property order
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.definition = exports.FieldValidatorNode = exports.NODE_TYPE = void 0;
|
|
17
|
+
const plugin_base_1 = require("@gravity-platform/plugin-base");
|
|
18
|
+
const executor_1 = __importDefault(require("./executor"));
|
|
19
|
+
// Export node type constant
|
|
20
|
+
exports.NODE_TYPE = "FieldValidator";
|
|
21
|
+
// Create node definition
|
|
22
|
+
function createNodeDefinition() {
|
|
23
|
+
return {
|
|
24
|
+
packageVersion: "1.1.1",
|
|
25
|
+
type: exports.NODE_TYPE,
|
|
26
|
+
isService: false,
|
|
27
|
+
name: "Field Validator",
|
|
28
|
+
description: "Validate data against schema and output next missing field",
|
|
29
|
+
category: "Flow",
|
|
30
|
+
color: "#8b5cf6", // Purple color for validation/logic
|
|
31
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1750052178/gravity/icons/6359572-200.png",
|
|
32
|
+
inputs: [
|
|
33
|
+
{
|
|
34
|
+
name: "signal",
|
|
35
|
+
type: plugin_base_1.NodeInputType.OBJECT,
|
|
36
|
+
description: "Incoming data object to validate",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
outputs: [
|
|
40
|
+
{ name: "nextField", type: plugin_base_1.NodeInputType.STRING, description: "Next missing field name" },
|
|
41
|
+
{ name: "nextFieldSchema", type: plugin_base_1.NodeInputType.OBJECT, description: "Schema definition for next field" },
|
|
42
|
+
{ name: "missingFields", type: plugin_base_1.NodeInputType.ARRAY, description: "All missing fields" },
|
|
43
|
+
{ name: "isComplete", type: plugin_base_1.NodeInputType.BOOLEAN, description: "All fields present" },
|
|
44
|
+
{ name: "completionPercentage", type: plugin_base_1.NodeInputType.NUMBER, description: "Data coverage %" },
|
|
45
|
+
],
|
|
46
|
+
// Schema for the node configuration UI
|
|
47
|
+
configSchema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
requiredSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
title: "Required Schema",
|
|
53
|
+
description: "Schema defining required fields. Supports: 1) Tool schema format (inputSchema.json.properties), 2) JSON Schema (properties), 3) Direct object. Example: return signal.toolSchema",
|
|
54
|
+
default: "",
|
|
55
|
+
"ui:field": "template",
|
|
56
|
+
},
|
|
57
|
+
incomingData: {
|
|
58
|
+
type: "object",
|
|
59
|
+
title: "Incoming Data",
|
|
60
|
+
description: "Data object to validate. Use: return signal.data or return input.formData",
|
|
61
|
+
default: "",
|
|
62
|
+
"ui:field": "template",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ["requiredSchema", "incomingData"],
|
|
66
|
+
},
|
|
67
|
+
// Declare capabilities
|
|
68
|
+
capabilities: {
|
|
69
|
+
isTrigger: false,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Export as enhanced node
|
|
74
|
+
exports.FieldValidatorNode = {
|
|
75
|
+
definition: createNodeDefinition(),
|
|
76
|
+
executor: executor_1.default,
|
|
77
|
+
};
|
|
78
|
+
// Export for node registry
|
|
79
|
+
exports.definition = createNodeDefinition();
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/FieldValidator/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,+DAA2F;AAC3F,0DAAgD;AAEhD,4BAA4B;AACf,QAAA,SAAS,GAAG,gBAAgB,CAAC;AAE1C,yBAAyB;AACzB,SAAS,oBAAoB;IAC3B,OAAO;QACL,cAAc,EAAE,OAAO;QACvB,IAAI,EAAE,iBAAS;QACf,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,4DAA4D;QACzE,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,SAAS,EAAE,oCAAoC;QACtD,OAAO,EAAE,yFAAyF;QAClG,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,2BAAa,CAAC,MAAM;gBAC1B,WAAW,EAAE,kCAAkC;aAChD;SACF;QACD,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,2BAAa,CAAC,MAAM,EAAE,WAAW,EAAE,yBAAyB,EAAE;YACzF,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,2BAAa,CAAC,MAAM,EAAE,WAAW,EAAE,kCAAkC,EAAE;YACxG,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,2BAAa,CAAC,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE;YACvF,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,2BAAa,CAAC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE;YACtF,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,2BAAa,CAAC,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE;SAC7F;QACD,uCAAuC;QACvC,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,cAAc,EAAE;oBACd,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,iBAAiB;oBACxB,WAAW,EAAE,kLAAkL;oBAC/L,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,UAAU;iBACvB;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,eAAe;oBACtB,WAAW,EAAE,2EAA2E;oBACxF,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,UAAU;iBACvB;aACF;YACD,QAAQ,EAAE,CAAC,gBAAgB,EAAE,cAAc,CAAC;SAC7C;QACD,uBAAuB;QACvB,YAAY,EAAE;YACZ,SAAS,EAAE,KAAK;SACjB;KACF,CAAC;AACJ,CAAC;AAED,0BAA0B;AACb,QAAA,kBAAkB,GAAG;IAChC,UAAU,EAAE,oBAAoB,EAAE;IAClC,QAAQ,EAAE,kBAAsB;CACjC,CAAC;AAEF,2BAA2B;AACd,QAAA,UAAU,GAAG,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldValidator Types
|
|
3
|
+
* Validates incoming data against a required schema
|
|
4
|
+
*/
|
|
5
|
+
export interface FieldValidatorConfig {
|
|
6
|
+
/** Required schema - object defining required fields (order matters) */
|
|
7
|
+
requiredSchema: any;
|
|
8
|
+
/** Incoming data object to validate */
|
|
9
|
+
incomingData: any;
|
|
10
|
+
}
|
|
11
|
+
export interface FieldValidatorOutput {
|
|
12
|
+
__outputs: {
|
|
13
|
+
/** Next missing field name */
|
|
14
|
+
nextField?: string;
|
|
15
|
+
/** Next missing field schema definition */
|
|
16
|
+
nextFieldSchema?: any;
|
|
17
|
+
/** All missing fields */
|
|
18
|
+
missingFields: string[];
|
|
19
|
+
/** Is validation complete (all fields present) */
|
|
20
|
+
isComplete: boolean;
|
|
21
|
+
/** Current data coverage percentage */
|
|
22
|
+
completionPercentage: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/FieldValidator/utils/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,cAAc,EAAE,GAAG,CAAC;IACpB,uCAAuC;IACvC,YAAY,EAAE,GAAG,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE;QACT,8BAA8B;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,2CAA2C;QAC3C,eAAe,CAAC,EAAE,GAAG,CAAC;QACtB,yBAAyB;QACzB,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,kDAAkD;QAClD,UAAU,EAAE,OAAO,CAAC;QACpB,uCAAuC;QACvC,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/FieldValidator/utils/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IfElse Node Executor
|
|
3
|
+
* Evaluates a condition and routes output to the appropriate connector
|
|
4
|
+
*/
|
|
5
|
+
import { NodeExecutionContext, ValidationResult } from "@gravity-platform/plugin-base";
|
|
6
|
+
import { PromiseNode } from "../shared/platform";
|
|
7
|
+
interface IfElseConfig {
|
|
8
|
+
condition: any;
|
|
9
|
+
}
|
|
10
|
+
interface IfElseOutput {
|
|
11
|
+
__outputs: {
|
|
12
|
+
true?: any;
|
|
13
|
+
false?: any;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export default class IfElseExecutor extends PromiseNode<IfElseConfig> {
|
|
17
|
+
constructor();
|
|
18
|
+
protected validateConfig(config: IfElseConfig): Promise<ValidationResult>;
|
|
19
|
+
protected executeNode(inputs: Record<string, any>, // Raw data from connected nodes
|
|
20
|
+
config: IfElseConfig, // Template-resolved configuration values
|
|
21
|
+
context: NodeExecutionContext): Promise<IfElseOutput>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/IfElse/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,YAAY;IACpB,SAAS,EAAE,GAAG,CAAC;CAChB;AAED,UAAU,YAAY;IACpB,SAAS,EAAE;QACT,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,KAAK,CAAC,EAAE,GAAG,CAAC;KACb,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW,CAAC,YAAY,CAAC;;cAKnD,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAK/D,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,gCAAgC;IAC7D,MAAM,EAAE,YAAY,EAAE,yCAAyC;IAC/D,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,YAAY,CAAC;CAmCzB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IfElse Node Executor
|
|
4
|
+
* Evaluates a condition and routes output to the appropriate connector
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const platform_1 = require("../shared/platform");
|
|
8
|
+
class IfElseExecutor extends platform_1.PromiseNode {
|
|
9
|
+
constructor() {
|
|
10
|
+
super("IfElse");
|
|
11
|
+
}
|
|
12
|
+
async validateConfig(config) {
|
|
13
|
+
// Config validation happens in the template resolver
|
|
14
|
+
return { success: true };
|
|
15
|
+
}
|
|
16
|
+
async executeNode(inputs, // Raw data from connected nodes
|
|
17
|
+
config, // Template-resolved configuration values
|
|
18
|
+
context) {
|
|
19
|
+
try {
|
|
20
|
+
// Get the condition result from config (already evaluated by template resolver)
|
|
21
|
+
const isTrue = Boolean(config.condition);
|
|
22
|
+
this.logger.info(`IfElse condition evaluated to: ${isTrue}`, {
|
|
23
|
+
nodeId: context.nodeId,
|
|
24
|
+
condition: config.condition,
|
|
25
|
+
isTrue,
|
|
26
|
+
});
|
|
27
|
+
this.logger.debug("IfElse routing decision", {
|
|
28
|
+
condition: isTrue ? "true" : "false",
|
|
29
|
+
inputKeys: Object.keys(inputs),
|
|
30
|
+
});
|
|
31
|
+
// Route to the appropriate output connector using __outputs pattern
|
|
32
|
+
if (isTrue) {
|
|
33
|
+
return {
|
|
34
|
+
__outputs: {
|
|
35
|
+
true: inputs,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return {
|
|
41
|
+
__outputs: {
|
|
42
|
+
false: inputs,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
this.logger.error(`IfElse condition evaluation failed:`, error);
|
|
49
|
+
throw new Error(`IfElse condition evaluation failed: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = IfElseExecutor;
|
|
54
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/IfElse/executor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAGH,iDAAiD;AAajD,MAAqB,cAAe,SAAQ,sBAAyB;IACnE;QACE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAAoB;QACjD,qDAAqD;QACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAES,KAAK,CAAC,WAAW,CACzB,MAA2B,EAAE,gCAAgC;IAC7D,MAAoB,EAAE,yCAAyC;IAC/D,OAA6B;QAE7B,IAAI,CAAC;YACH,gFAAgF;YAChF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAEzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,MAAM,EAAE,EAAE;gBAC3D,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,MAAM;aACP,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;gBAC3C,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;gBACpC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aAC/B,CAAC,CAAC;YAEH,oEAAoE;YACpE,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO;oBACL,SAAS,EAAE;wBACT,IAAI,EAAE,MAAM;qBACb;iBACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,SAAS,EAAE;wBACT,KAAK,EAAE,MAAM;qBACd;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,uCAAuC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF;AAjDD,iCAiDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IfElse Node Definition
|
|
3
|
+
* Evaluates a condition and routes output to true or false connector
|
|
4
|
+
*/
|
|
5
|
+
import { type EnhancedNodeDefinition } from "@gravity-platform/plugin-base";
|
|
6
|
+
import IfElseExecutor from "./executor";
|
|
7
|
+
export declare const NODE_TYPE = "IfElse";
|
|
8
|
+
export declare function createNodeDefinition(): EnhancedNodeDefinition;
|
|
9
|
+
export declare const IfElseNode: {
|
|
10
|
+
definition: any;
|
|
11
|
+
executor: typeof IfElseExecutor;
|
|
12
|
+
};
|
|
13
|
+
export declare const definition: any;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/IfElse/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,cAAc,MAAM,YAAY,CAAC;AAGxC,eAAO,MAAM,SAAS,WAAW,CAAC;AAGlC,wBAAgB,oBAAoB,IAAI,sBAAsB,CAsC7D;AAGD,eAAO,MAAM,UAAU;;;CAGtB,CAAC;AAGF,eAAO,MAAM,UAAU,KAAyB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IfElse Node Definition
|
|
4
|
+
* Evaluates a condition and routes output to true or false connector
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.definition = exports.IfElseNode = exports.NODE_TYPE = void 0;
|
|
11
|
+
exports.createNodeDefinition = createNodeDefinition;
|
|
12
|
+
const plugin_base_1 = require("@gravity-platform/plugin-base");
|
|
13
|
+
const executor_1 = __importDefault(require("./executor"));
|
|
14
|
+
// Export node type constant
|
|
15
|
+
exports.NODE_TYPE = "IfElse";
|
|
16
|
+
// Export a function that creates the definition after platform deps are set
|
|
17
|
+
function createNodeDefinition() {
|
|
18
|
+
const { NodeInputType } = (0, plugin_base_1.getPlatformDependencies)();
|
|
19
|
+
return {
|
|
20
|
+
packageVersion: "1.1.1",
|
|
21
|
+
type: exports.NODE_TYPE,
|
|
22
|
+
isService: false,
|
|
23
|
+
name: "If/Else",
|
|
24
|
+
description: "Evaluate a condition and route to true or false output",
|
|
25
|
+
category: "Flow",
|
|
26
|
+
color: "#4A90E2",
|
|
27
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1749961542/gravity/icons/loop.png",
|
|
28
|
+
inputs: [
|
|
29
|
+
{
|
|
30
|
+
name: "signal",
|
|
31
|
+
type: NodeInputType.ANY,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
outputs: [
|
|
35
|
+
{ name: "true", type: NodeInputType.ANY },
|
|
36
|
+
{ name: "false", type: NodeInputType.ANY },
|
|
37
|
+
],
|
|
38
|
+
// Schema for the node configuration UI
|
|
39
|
+
configSchema: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
condition: {
|
|
43
|
+
type: "object",
|
|
44
|
+
title: "Condition",
|
|
45
|
+
description: "true/false expression",
|
|
46
|
+
default: "",
|
|
47
|
+
"ui:field": "template",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ["condition"],
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Export as enhanced node
|
|
55
|
+
exports.IfElseNode = {
|
|
56
|
+
definition: createNodeDefinition(),
|
|
57
|
+
executor: executor_1.default,
|
|
58
|
+
};
|
|
59
|
+
// Export for node registry
|
|
60
|
+
exports.definition = createNodeDefinition();
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/IfElse/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AASH,oDAsCC;AA7CD,+DAAqG;AACrG,0DAAwC;AAExC,4BAA4B;AACf,QAAA,SAAS,GAAG,QAAQ,CAAC;AAElC,4EAA4E;AAC5E,SAAgB,oBAAoB;IAClC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,qCAAuB,GAAE,CAAC;IAEpD,OAAO;QACL,cAAc,EAAE,OAAO;QACvB,IAAI,EAAE,iBAAS;QACjB,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,wDAAwD;QACrE,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,kFAAkF;QAE3F,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,aAAa,CAAC,GAAG;aACxB;SACF;QACD,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE;YACzC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE;SAC3C;QACD,uCAAuC;QACvC,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,WAAW;oBAClB,WAAW,EAAE,uBAAuB;oBACpC,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,UAAU;iBACvB;aACF;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACA,CAAC;AACJ,CAAC;AAED,0BAA0B;AACb,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE,oBAAoB,EAAE;IAClC,QAAQ,EAAE,kBAAc;CACzB,CAAC;AAEF,2BAA2B;AACd,QAAA,UAAU,GAAG,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loop node implementation for GravityWorkflow
|
|
3
|
+
*
|
|
4
|
+
* State machine-based implementation that processes items one at a time.
|
|
5
|
+
* Waits for continue signals to advance through the array.
|
|
6
|
+
*/
|
|
7
|
+
import { ValidationResult } from "@gravity-platform/plugin-base";
|
|
8
|
+
import { CallbackNode } from "../shared/platform";
|
|
9
|
+
import { LoopConfig } from "./utils/types";
|
|
10
|
+
interface LoopState {
|
|
11
|
+
items: any[];
|
|
12
|
+
currentIndex: number;
|
|
13
|
+
isComplete: boolean;
|
|
14
|
+
collectedItems: any[];
|
|
15
|
+
}
|
|
16
|
+
interface LoopInputs {
|
|
17
|
+
items?: any[];
|
|
18
|
+
next?: any;
|
|
19
|
+
}
|
|
20
|
+
interface LoopEvent {
|
|
21
|
+
type: string;
|
|
22
|
+
inputs?: LoopInputs;
|
|
23
|
+
config?: LoopConfig;
|
|
24
|
+
}
|
|
25
|
+
export declare class LoopNode extends CallbackNode<LoopConfig, LoopState> {
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Validate the Loop configuration
|
|
29
|
+
*/
|
|
30
|
+
protected validateConfig(config: LoopConfig): Promise<ValidationResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Initialize state for the loop
|
|
33
|
+
*/
|
|
34
|
+
initializeState(inputs: any): LoopState;
|
|
35
|
+
/**
|
|
36
|
+
* Handle events and update state
|
|
37
|
+
*/
|
|
38
|
+
handleEvent(event: LoopEvent, state: LoopState, emit: (output: any) => void): Promise<LoopState>;
|
|
39
|
+
/**
|
|
40
|
+
* Cleanup any resources when the node is stopped
|
|
41
|
+
*/
|
|
42
|
+
cleanup(state: LoopState): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export default LoopNode;
|
|
45
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/Loop/executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,UAAU,SAAS;IACjB,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,GAAG,EAAE,CAAC;CACvB;AAED,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,qBAAa,QAAS,SAAQ,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC;;IAK/D;;OAEG;cACa,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI7E;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS;IAWvC;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;IAmKtG;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C;AAED,eAAe,QAAQ,CAAC"}
|