@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gravity AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @gravityai-dev/flow
|
|
2
|
+
|
|
3
|
+
Flow control nodes for GravityWorkflow - essential building blocks for workflow logic and data processing.
|
|
4
|
+
|
|
5
|
+
## Nodes Included
|
|
6
|
+
|
|
7
|
+
### Core Flow Control
|
|
8
|
+
- **Code** - Execute custom JavaScript code to transform data
|
|
9
|
+
- **IfElse** - Conditional routing based on boolean expressions
|
|
10
|
+
- **Loop** - Iterate through arrays with state management
|
|
11
|
+
- **Context** - Manage workflow context and variables
|
|
12
|
+
- **Relay** - Simple data passthrough and routing
|
|
13
|
+
|
|
14
|
+
### Utility Nodes
|
|
15
|
+
- **Note** - Documentation and annotation within workflows
|
|
16
|
+
- **UMAP** - Dimensionality reduction for data visualization
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @gravityai-dev/flow
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
This package follows the Gravity Plugin System architecture. It registers automatically when loaded by the platform.
|
|
27
|
+
|
|
28
|
+
### Node Categories
|
|
29
|
+
|
|
30
|
+
All nodes are categorized as "Flow" nodes and provide essential workflow control capabilities:
|
|
31
|
+
|
|
32
|
+
- **Promise Nodes**: Code, IfElse, Context, Relay, Note, UMAP
|
|
33
|
+
- **Callback Nodes**: Loop (for stateful iteration)
|
|
34
|
+
|
|
35
|
+
### Key Features
|
|
36
|
+
|
|
37
|
+
- **Template Resolution**: All nodes support template expressions in their configuration
|
|
38
|
+
- **Type Safety**: Full TypeScript support with proper type definitions
|
|
39
|
+
- **State Management**: Loop node maintains iteration state across events
|
|
40
|
+
- **Error Handling**: Comprehensive error handling and logging
|
|
41
|
+
- **Platform Integration**: Seamless integration with GravityWorkflow platform
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Build the package
|
|
47
|
+
npm run build
|
|
48
|
+
|
|
49
|
+
# Watch for changes
|
|
50
|
+
npm run dev
|
|
51
|
+
|
|
52
|
+
# Clean build artifacts
|
|
53
|
+
npm run clean
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Architecture
|
|
57
|
+
|
|
58
|
+
This package uses the standard Gravity plugin structure:
|
|
59
|
+
- `src/NodeName/` - Individual node implementations
|
|
60
|
+
- `src/shared/platform.ts` - Platform dependency management
|
|
61
|
+
- `src/index.ts` - Plugin registration and setup
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ClientStorage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientStorageNode = void 0;
|
|
4
|
+
var node_1 = require("./node");
|
|
5
|
+
Object.defineProperty(exports, "ClientStorageNode", { enumerable: true, get: function () { return node_1.ClientStorageNode; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ClientStorage/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2C;AAAlC,yGAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PromiseNode, type NodeExecutionContext } from "@gravity-platform/plugin-base";
|
|
2
|
+
import { ClientStorageConfig, ClientStorageOutput } from "../util/types";
|
|
3
|
+
export default class ClientStorageExecutor extends PromiseNode {
|
|
4
|
+
constructor();
|
|
5
|
+
protected executeNode(inputs: Record<string, any>, config: ClientStorageConfig, context: NodeExecutionContext): Promise<ClientStorageOutput>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/ClientStorage/node/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzE,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;;cAK5C,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;CAwBhC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const plugin_base_1 = require("@gravity-platform/plugin-base");
|
|
4
|
+
const NODE_TYPE = "ClientStorage";
|
|
5
|
+
class ClientStorageExecutor extends plugin_base_1.PromiseNode {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(NODE_TYPE);
|
|
8
|
+
}
|
|
9
|
+
async executeNode(inputs, config, context) {
|
|
10
|
+
if (!config.storageKey || config.storageKey.trim() === "") {
|
|
11
|
+
throw new Error("Storage key is required");
|
|
12
|
+
}
|
|
13
|
+
if (!config.data) {
|
|
14
|
+
throw new Error("Data is required");
|
|
15
|
+
}
|
|
16
|
+
this.logger.info("ClientStorage: sending data to client", {
|
|
17
|
+
storageKey: config.storageKey,
|
|
18
|
+
nodeId: context.nodeId,
|
|
19
|
+
dataKeys: typeof config.data === "object" ? Object.keys(config.data) : "primitive",
|
|
20
|
+
});
|
|
21
|
+
// Return data with storageKey and node ID for client identification
|
|
22
|
+
return {
|
|
23
|
+
__outputs: {
|
|
24
|
+
storageKey: config.storageKey,
|
|
25
|
+
id: context.nodeId,
|
|
26
|
+
data: config.data,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = ClientStorageExecutor;
|
|
32
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/ClientStorage/node/executor.ts"],"names":[],"mappings":";;AAAA,+DAAuF;AAGvF,MAAM,SAAS,GAAG,eAAe,CAAC;AAElC,MAAqB,qBAAsB,SAAQ,yBAAW;IAC5D;QACE,KAAK,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC;IAES,KAAK,CAAC,WAAW,CACzB,MAA2B,EAC3B,MAA2B,EAC3B,OAA6B;QAE7B,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,EAAE;YACxD,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW;SACnF,CAAC,CAAC;QAEH,oEAAoE;QACpE,OAAO;YACL,SAAS,EAAE;gBACT,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,EAAE,EAAE,OAAO,CAAC,MAAM;gBAClB,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB;SACK,CAAC;IACX,CAAC;CACF;AAjCD,wCAiCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type EnhancedNodeDefinition } from "@gravity-platform/plugin-base";
|
|
2
|
+
import ClientStorageExecutor from "./executor";
|
|
3
|
+
export declare const NODE_TYPE = "ClientStorage";
|
|
4
|
+
declare function createNodeDefinition(): EnhancedNodeDefinition;
|
|
5
|
+
export declare const ClientStorageNode: {
|
|
6
|
+
definition: any;
|
|
7
|
+
executor: typeof ClientStorageExecutor;
|
|
8
|
+
};
|
|
9
|
+
export { createNodeDefinition };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ClientStorage/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,qBAAqB,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC,iBAAS,oBAAoB,IAAI,sBAAsB,CA+CtD;AAID,eAAO,MAAM,iBAAiB;;;CAG7B,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ClientStorageNode = exports.NODE_TYPE = void 0;
|
|
7
|
+
exports.createNodeDefinition = createNodeDefinition;
|
|
8
|
+
const plugin_base_1 = require("@gravity-platform/plugin-base");
|
|
9
|
+
const executor_1 = __importDefault(require("./executor"));
|
|
10
|
+
exports.NODE_TYPE = "ClientStorage";
|
|
11
|
+
function createNodeDefinition() {
|
|
12
|
+
return {
|
|
13
|
+
packageVersion: "1.0.0",
|
|
14
|
+
type: exports.NODE_TYPE,
|
|
15
|
+
name: "Client Storage",
|
|
16
|
+
description: "Send JSON data to client with a unique storage key for IndexedDB/localStorage",
|
|
17
|
+
category: "Flow",
|
|
18
|
+
color: "#10B981",
|
|
19
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1751366180/gravity/icons/gravityIcon.png",
|
|
20
|
+
inputs: [
|
|
21
|
+
{
|
|
22
|
+
name: "signal",
|
|
23
|
+
type: plugin_base_1.NodeInputType.OBJECT,
|
|
24
|
+
description: "Trigger signal (optional)",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
outputs: [
|
|
28
|
+
{
|
|
29
|
+
name: "output",
|
|
30
|
+
type: plugin_base_1.NodeInputType.OBJECT,
|
|
31
|
+
description: "Data with storageKey and id for client-side storage",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
configSchema: {
|
|
35
|
+
type: "object",
|
|
36
|
+
required: ["storageKey", "data"],
|
|
37
|
+
properties: {
|
|
38
|
+
storageKey: {
|
|
39
|
+
type: "string",
|
|
40
|
+
title: "Storage Key",
|
|
41
|
+
description: "Unique identifier for this data in client storage (e.g., 'user_preferences', 'cart_items')",
|
|
42
|
+
default: "workflow_data",
|
|
43
|
+
"ui:field": "template",
|
|
44
|
+
},
|
|
45
|
+
data: {
|
|
46
|
+
type: "object",
|
|
47
|
+
title: "Data",
|
|
48
|
+
description: "JSON data to send to client. Supports template syntax: {{signal.fieldName}}",
|
|
49
|
+
default: {},
|
|
50
|
+
"ui:field": "template",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
capabilities: {
|
|
55
|
+
isTrigger: false,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const definition = createNodeDefinition();
|
|
60
|
+
exports.ClientStorageNode = {
|
|
61
|
+
definition,
|
|
62
|
+
executor: executor_1.default,
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ClientStorage/node/index.ts"],"names":[],"mappings":";;;;;;AA6DS,oDAAoB;AA7D7B,+DAA2F;AAC3F,0DAA+C;AAElC,QAAA,SAAS,GAAG,eAAe,CAAC;AAEzC,SAAS,oBAAoB;IAC3B,OAAO;QACL,cAAc,EAAE,OAAO;QACvB,IAAI,EAAE,iBAAS;QACf,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,+EAA+E;QAC5F,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,yFAAyF;QAClG,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,2BAAa,CAAC,MAAM;gBAC1B,WAAW,EAAE,2BAA2B;aACzC;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,2BAAa,CAAC,MAAM;gBAC1B,WAAW,EAAE,qDAAqD;aACnE;SACF;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC;YAChC,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,aAAa;oBACpB,WAAW,EAAE,4FAA4F;oBACzG,OAAO,EAAE,eAAe;oBACxB,UAAU,EAAE,UAAU;iBACvB;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,MAAM;oBACb,WAAW,EAAE,6EAA6E;oBAC1F,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,UAAU;iBACvB;aACF;SACF;QACD,YAAY,EAAE;YACZ,SAAS,EAAE,KAAK;SACjB;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;AAE7B,QAAA,iBAAiB,GAAG;IAC/B,UAAU;IACV,QAAQ,EAAE,kBAAqB;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ClientStorage/util/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,GAAG,CAAC;KACX,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ClientStorage/util/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Node Executor
|
|
3
|
+
* Executes custom JavaScript code with access to inputs and context
|
|
4
|
+
*
|
|
5
|
+
* Security considerations:
|
|
6
|
+
* - Runs in isolated VM context
|
|
7
|
+
* - Limited access to Node.js APIs
|
|
8
|
+
* - Timeout protection
|
|
9
|
+
* - Memory limits
|
|
10
|
+
*/
|
|
11
|
+
import { NodeExecutionContext, ValidationResult } from "@gravity-platform/plugin-base";
|
|
12
|
+
import { PromiseNode } from "../shared/platform";
|
|
13
|
+
interface CodeConfig {
|
|
14
|
+
code: any;
|
|
15
|
+
generateIds?: boolean;
|
|
16
|
+
saveToContext?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export default class CodeExecutor extends PromiseNode<CodeConfig> {
|
|
19
|
+
constructor();
|
|
20
|
+
protected validateConfig(config: CodeConfig): Promise<ValidationResult>;
|
|
21
|
+
protected executeNode(inputs: Record<string, any>, config: CodeConfig, context: NodeExecutionContext): Promise<any>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/Code/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAc,MAAM,oBAAoB,CAAC;AAG7D,UAAU,UAAU;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW,CAAC,UAAU,CAAC;;cAK/C,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAK7D,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,GAAG,CAAC;CAmDhB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Code Node Executor
|
|
4
|
+
* Executes custom JavaScript code with access to inputs and context
|
|
5
|
+
*
|
|
6
|
+
* Security considerations:
|
|
7
|
+
* - Runs in isolated VM context
|
|
8
|
+
* - Limited access to Node.js APIs
|
|
9
|
+
* - Timeout protection
|
|
10
|
+
* - Memory limits
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const platform_1 = require("../shared/platform");
|
|
14
|
+
const hashUtils_1 = require("./utils/hashUtils");
|
|
15
|
+
class CodeExecutor extends platform_1.PromiseNode {
|
|
16
|
+
constructor() {
|
|
17
|
+
super("Code");
|
|
18
|
+
}
|
|
19
|
+
async validateConfig(config) {
|
|
20
|
+
// Config validation happens in the template resolver
|
|
21
|
+
return { success: true };
|
|
22
|
+
}
|
|
23
|
+
async executeNode(inputs, config, context) {
|
|
24
|
+
try {
|
|
25
|
+
// The template resolver has already executed the code if it was a JS template
|
|
26
|
+
// If config.code is already resolved, just use it
|
|
27
|
+
const result = config.code;
|
|
28
|
+
// Build base output
|
|
29
|
+
const outputs = {
|
|
30
|
+
output: result,
|
|
31
|
+
};
|
|
32
|
+
// If generateIds is enabled, also generate IDs
|
|
33
|
+
if (config.generateIds) {
|
|
34
|
+
const workflowId = context.workflow?.id || "unknown";
|
|
35
|
+
const nodeId = context.nodeId || "code";
|
|
36
|
+
// Include the result content in the universalId hash
|
|
37
|
+
const universalId = (0, hashUtils_1.createUniversalId)(workflowId, nodeId, result);
|
|
38
|
+
const contentId = (0, hashUtils_1.createContentHash)(result);
|
|
39
|
+
platform_1.codeLogger.info("Generated IDs for output", {
|
|
40
|
+
workflowId,
|
|
41
|
+
nodeId,
|
|
42
|
+
universalId,
|
|
43
|
+
contentId,
|
|
44
|
+
});
|
|
45
|
+
outputs.ids = {
|
|
46
|
+
universalId,
|
|
47
|
+
contentId,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// If saveToContext is enabled, write to Redis AND flag output for in-memory cache
|
|
51
|
+
if (config.saveToContext) {
|
|
52
|
+
outputs.__saveToContext = true;
|
|
53
|
+
if (context.api?.getRedisClient) {
|
|
54
|
+
const redis = context.api.getRedisClient();
|
|
55
|
+
const redisKey = `saved:${context.executionId}`;
|
|
56
|
+
await redis.hset(redisKey, context.nodeId, JSON.stringify(result));
|
|
57
|
+
await redis.expire(redisKey, 3600);
|
|
58
|
+
platform_1.codeLogger.info("Saved output to Redis", { nodeId: context.nodeId, redisKey });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { __outputs: outputs };
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
platform_1.codeLogger.error(`Code execution failed:`, error);
|
|
65
|
+
throw new Error(`Code execution failed: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.default = CodeExecutor;
|
|
70
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/Code/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAGH,iDAA6D;AAC7D,iDAAyE;AAQzE,MAAqB,YAAa,SAAQ,sBAAuB;IAC/D;QACE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAAkB;QAC/C,qDAAqD;QACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAES,KAAK,CAAC,WAAW,CACzB,MAA2B,EAC3B,MAAkB,EAClB,OAA6B;QAE7B,IAAI,CAAC;YACH,8EAA8E;YAC9E,kDAAkD;YAClD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;YAE3B,oBAAoB;YACpB,MAAM,OAAO,GAAQ;gBACnB,MAAM,EAAE,MAAM;aACf,CAAC;YAEF,+CAA+C;YAC/C,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;gBACvB,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,IAAI,SAAS,CAAC;gBACrD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;gBAExC,qDAAqD;gBACrD,MAAM,WAAW,GAAG,IAAA,6BAAiB,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;gBAClE,MAAM,SAAS,GAAG,IAAA,6BAAiB,EAAC,MAAM,CAAC,CAAC;gBAE5C,qBAAU,CAAC,IAAI,CAAC,0BAA0B,EAAE;oBAC1C,UAAU;oBACV,MAAM;oBACN,WAAW;oBACX,SAAS;iBACV,CAAC,CAAC;gBAEH,OAAO,CAAC,GAAG,GAAG;oBACZ,WAAW;oBACX,SAAS;iBACV,CAAC;YACJ,CAAC;YAED,kFAAkF;YAClF,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;gBACzB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAC/B,IAAI,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,CAAC;oBAChC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;oBAC3C,MAAM,QAAQ,GAAG,SAAS,OAAO,CAAC,WAAW,EAAE,CAAC;oBAChD,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;oBACnE,MAAM,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;oBACnC,qBAAU,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACjF,CAAC;YACH,CAAC;YAED,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;QAChC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,qBAAU,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AAjED,+BAiEC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Node Definition
|
|
3
|
+
* Executes custom JavaScript code with input data
|
|
4
|
+
*/
|
|
5
|
+
import { type EnhancedNodeDefinition } from "@gravity-platform/plugin-base";
|
|
6
|
+
import CodeExecutor from "./executor";
|
|
7
|
+
export declare const NODE_TYPE = "Code";
|
|
8
|
+
export declare function createNodeDefinition(): EnhancedNodeDefinition;
|
|
9
|
+
export declare const CodeNode: {
|
|
10
|
+
definition: any;
|
|
11
|
+
executor: typeof CodeExecutor;
|
|
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/Code/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,YAAY,MAAM,YAAY,CAAC;AAGtC,eAAO,MAAM,SAAS,SAAS,CAAC;AAGhC,wBAAgB,oBAAoB,IAAI,sBAAsB,CAuD7D;AAGD,eAAO,MAAM,QAAQ;;;CAGpB,CAAC;AAGF,eAAO,MAAM,UAAU,KAAyB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Code Node Definition
|
|
4
|
+
* Executes custom JavaScript code with input data
|
|
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.CodeNode = 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 = "Code";
|
|
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: "Code",
|
|
24
|
+
description: "Execute custom code to transform data",
|
|
25
|
+
category: "Flow",
|
|
26
|
+
color: "#f59e0b", // Amber color for code/logic
|
|
27
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1750052178/gravity/icons/6359572-200.png",
|
|
28
|
+
inputs: [
|
|
29
|
+
{
|
|
30
|
+
name: "signal",
|
|
31
|
+
type: NodeInputType.ANY,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
outputs: [
|
|
35
|
+
{ name: "output", type: NodeInputType.ANY },
|
|
36
|
+
{ name: "ids", type: NodeInputType.OBJECT },
|
|
37
|
+
],
|
|
38
|
+
// Schema for the node configuration UI
|
|
39
|
+
configSchema: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
code: {
|
|
43
|
+
type: "object",
|
|
44
|
+
title: "Code",
|
|
45
|
+
description: "JS Code to transform data",
|
|
46
|
+
default: "",
|
|
47
|
+
"ui:field": "template",
|
|
48
|
+
},
|
|
49
|
+
generateIds: {
|
|
50
|
+
type: "boolean",
|
|
51
|
+
title: "Generate IDs",
|
|
52
|
+
description: "Generate content IDs",
|
|
53
|
+
default: false,
|
|
54
|
+
"ui:widget": "toggle",
|
|
55
|
+
},
|
|
56
|
+
saveToContext: {
|
|
57
|
+
type: "boolean",
|
|
58
|
+
title: "Save to Context",
|
|
59
|
+
description: "Save output to workflow context for template access",
|
|
60
|
+
default: false,
|
|
61
|
+
"ui:widget": "toggle",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ["code"],
|
|
65
|
+
},
|
|
66
|
+
// Declare capabilities
|
|
67
|
+
capabilities: {
|
|
68
|
+
isTrigger: false,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Export as enhanced node
|
|
73
|
+
exports.CodeNode = {
|
|
74
|
+
definition: createNodeDefinition(),
|
|
75
|
+
executor: executor_1.default,
|
|
76
|
+
};
|
|
77
|
+
// Export for node registry
|
|
78
|
+
exports.definition = createNodeDefinition();
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Code/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AASH,oDAuDC;AA9DD,+DAAqG;AACrG,0DAAsC;AAEtC,4BAA4B;AACf,QAAA,SAAS,GAAG,MAAM,CAAC;AAEhC,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,MAAM;QACZ,WAAW,EAAE,uCAAuC;QACpD,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;YACP,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE;YAC3C,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE;SAC5C;QACD,uCAAuC;QACvC,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,MAAM;oBACb,WAAW,EAAE,2BAA2B;oBACxC,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,UAAU;iBACvB;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,cAAc;oBACrB,WAAW,EAAE,sBAAsB;oBACnC,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,QAAQ;iBACtB;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,iBAAiB;oBACxB,WAAW,EAAE,qDAAqD;oBAClE,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,QAAQ;iBACtB;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;QACD,uBAAuB;QACvB,YAAY,EAAE;YACZ,SAAS,EAAE,KAAK;SACjB;KACF,CAAC;AACJ,CAAC;AAED,0BAA0B;AACb,QAAA,QAAQ,GAAG;IACtB,UAAU,EAAE,oBAAoB,EAAE;IAClC,QAAQ,EAAE,kBAAY;CACvB,CAAC;AAEF,2BAA2B;AACd,QAAA,UAAU,GAAG,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash utilities for Code node
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates a content hash from input data
|
|
6
|
+
* @param input - The input data to hash
|
|
7
|
+
* @returns Short hash (12 characters) representing the content
|
|
8
|
+
*/
|
|
9
|
+
export declare function createContentHash(input: any): string;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a universal ID hash from workflow ID, node ID, and content
|
|
12
|
+
* @param workflowId - The workflow ID
|
|
13
|
+
* @param nodeId - The node ID
|
|
14
|
+
* @param content - The output content to include in the hash
|
|
15
|
+
* @returns Universal ID hash (12 characters)
|
|
16
|
+
*/
|
|
17
|
+
export declare function createUniversalId(workflowId: string, nodeId: string, content?: any): string;
|
|
18
|
+
//# sourceMappingURL=hashUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashUtils.d.ts","sourceRoot":"","sources":["../../../src/Code/utils/hashUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAOpD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,MAAM,CAa3F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hash utilities for Code node
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createContentHash = createContentHash;
|
|
7
|
+
exports.createUniversalId = createUniversalId;
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
/**
|
|
10
|
+
* Creates a content hash from input data
|
|
11
|
+
* @param input - The input data to hash
|
|
12
|
+
* @returns Short hash (12 characters) representing the content
|
|
13
|
+
*/
|
|
14
|
+
function createContentHash(input) {
|
|
15
|
+
// Convert input to string for hashing
|
|
16
|
+
const inputString = typeof input === "string" ? input : JSON.stringify(input, Object.keys(input).sort());
|
|
17
|
+
// Create hash and return short version (similar to git short hash)
|
|
18
|
+
const fullHash = (0, crypto_1.createHash)("sha256").update(inputString).digest("hex");
|
|
19
|
+
return fullHash.substring(0, 12);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a universal ID hash from workflow ID, node ID, and content
|
|
23
|
+
* @param workflowId - The workflow ID
|
|
24
|
+
* @param nodeId - The node ID
|
|
25
|
+
* @param content - The output content to include in the hash
|
|
26
|
+
* @returns Universal ID hash (12 characters)
|
|
27
|
+
*/
|
|
28
|
+
function createUniversalId(workflowId, nodeId, content) {
|
|
29
|
+
// Start with workflow and node IDs
|
|
30
|
+
let idString = `${workflowId}-${nodeId}`;
|
|
31
|
+
// If content is provided, include it in the hash
|
|
32
|
+
if (content !== undefined && content !== null) {
|
|
33
|
+
const contentString = typeof content === "string" ? content : JSON.stringify(content, Object.keys(content).sort());
|
|
34
|
+
idString = `${idString}-${contentString}`;
|
|
35
|
+
}
|
|
36
|
+
// Create hash and return short version
|
|
37
|
+
const fullHash = (0, crypto_1.createHash)("sha256").update(idString).digest("hex");
|
|
38
|
+
return fullHash.substring(0, 12);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=hashUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../../../src/Code/utils/hashUtils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AASH,8CAOC;AASD,8CAaC;AApCD,mCAAoC;AAEpC;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,KAAU;IAC1C,sCAAsC;IACtC,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAEzG,mEAAmE;IACnE,MAAM,QAAQ,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxE,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,UAAkB,EAAE,MAAc,EAAE,OAAa;IACjF,mCAAmC;IACnC,IAAI,QAAQ,GAAG,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC;IAEzC,iDAAiD;IACjD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,aAAa,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACnH,QAAQ,GAAG,GAAG,QAAQ,IAAI,aAAa,EAAE,CAAC;IAC5C,CAAC;IAED,uCAAuC;IACvC,MAAM,QAAQ,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrE,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Node Executor
|
|
3
|
+
* Extracts and returns workflow context information including:
|
|
4
|
+
* - userId, conversationId, chatId
|
|
5
|
+
* - workflowId, executionId
|
|
6
|
+
* - workflow variables
|
|
7
|
+
* - execution metadata
|
|
8
|
+
*/
|
|
9
|
+
import { NodeExecutionContext, ValidationResult } from "@gravity-platform/plugin-base";
|
|
10
|
+
import { PromiseNode } from "../shared/platform";
|
|
11
|
+
export declare class ContextExecutor extends PromiseNode {
|
|
12
|
+
constructor();
|
|
13
|
+
protected validateConfig(config: any): Promise<ValidationResult>;
|
|
14
|
+
protected executeNode(inputs: Record<string, any>, config: any, context: NodeExecutionContext): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/Context/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUjD,qBAAa,eAAgB,SAAQ,WAAW;;cAK9B,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAItD,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,GAAG,CAAC;CA2BhB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Context Node Executor
|
|
4
|
+
* Extracts and returns workflow context information including:
|
|
5
|
+
* - userId, conversationId, chatId
|
|
6
|
+
* - workflowId, executionId
|
|
7
|
+
* - workflow variables
|
|
8
|
+
* - execution metadata
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ContextExecutor = void 0;
|
|
12
|
+
const platform_1 = require("../shared/platform");
|
|
13
|
+
class ContextExecutor extends platform_1.PromiseNode {
|
|
14
|
+
constructor() {
|
|
15
|
+
super("Context");
|
|
16
|
+
}
|
|
17
|
+
async validateConfig(config) {
|
|
18
|
+
return { success: true };
|
|
19
|
+
}
|
|
20
|
+
async executeNode(inputs, config, context) {
|
|
21
|
+
try {
|
|
22
|
+
// Get workflow variables for core context fields
|
|
23
|
+
const workflowVars = context.workflow?.variables || {};
|
|
24
|
+
// Build the output object with only core fields
|
|
25
|
+
const output = {
|
|
26
|
+
userId: workflowVars?.userId,
|
|
27
|
+
conversationId: workflowVars?.conversationId,
|
|
28
|
+
chatId: workflowVars?.chatId,
|
|
29
|
+
workflowId: context.workflow?.id,
|
|
30
|
+
executionId: context.executionId,
|
|
31
|
+
};
|
|
32
|
+
this.logger.info("Context extracted", output);
|
|
33
|
+
// Return the context data to the output connector
|
|
34
|
+
return {
|
|
35
|
+
__outputs: {
|
|
36
|
+
context: output,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.logger.error("Failed to extract context:", error);
|
|
42
|
+
throw new Error(`Context extraction failed: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ContextExecutor = ContextExecutor;
|
|
47
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/Context/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAGH,iDAAiD;AAUjD,MAAa,eAAgB,SAAQ,sBAAW;IAC9C;QACE,KAAK,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAAW;QACxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAES,KAAK,CAAC,WAAW,CACzB,MAA2B,EAC3B,MAAW,EACX,OAA6B;QAE7B,IAAI,CAAC;YACH,iDAAiD;YACjD,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,CAAC;YAEvD,gDAAgD;YAChD,MAAM,MAAM,GAAkB;gBAC5B,MAAM,EAAE,YAAY,EAAE,MAAM;gBAC5B,cAAc,EAAE,YAAY,EAAE,cAAc;gBAC5C,MAAM,EAAE,YAAY,EAAE,MAAM;gBAC5B,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;gBAChC,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;YAE9C,kDAAkD;YAClD,OAAO;gBACL,SAAS,EAAE;oBACT,OAAO,EAAE,MAAM;iBAChB;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;YACvD,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF;AAxCD,0CAwCC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Node Definition
|
|
3
|
+
* Extracts and returns workflow context information
|
|
4
|
+
*/
|
|
5
|
+
import { type EnhancedNodeDefinition } from "@gravity-platform/plugin-base";
|
|
6
|
+
import { ContextExecutor } from "./executor";
|
|
7
|
+
export declare const NODE_TYPE = "Context";
|
|
8
|
+
export declare function createNodeDefinition(): EnhancedNodeDefinition;
|
|
9
|
+
export declare const ContextNode: {
|
|
10
|
+
definition: any;
|
|
11
|
+
executor: typeof ContextExecutor;
|
|
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/Context/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,eAAO,MAAM,SAAS,YAAY,CAAC;AAGnC,wBAAgB,oBAAoB,IAAI,sBAAsB,CAwB7D;AAGD,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAGF,eAAO,MAAM,UAAU,KAAyB,CAAC"}
|