@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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Object publishing service
|
|
4
|
+
* Publishes JSON data to the client via COMPONENT_INIT (same as design-system components)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.publishObject = publishObject;
|
|
8
|
+
async function publishObject(config, api, context) {
|
|
9
|
+
const logger = api?.createLogger?.("ObjectPublisher") || console;
|
|
10
|
+
try {
|
|
11
|
+
// Get WebSocket manager
|
|
12
|
+
const wsManager = api?.getWebSocketManager?.();
|
|
13
|
+
const websocket = wsManager?.get(config.userId, config.conversationId);
|
|
14
|
+
const componentKey = `${config.chatId}_${config.nodeId}`;
|
|
15
|
+
logger.info("📦 Publishing object via COMPONENT_INIT", {
|
|
16
|
+
nodeId: config.nodeId,
|
|
17
|
+
objectId: config.objectId,
|
|
18
|
+
componentKey,
|
|
19
|
+
});
|
|
20
|
+
const event = {
|
|
21
|
+
type: "OBJECT_DATA",
|
|
22
|
+
nodeId: config.nodeId,
|
|
23
|
+
chatId: config.chatId,
|
|
24
|
+
data: config.data,
|
|
25
|
+
};
|
|
26
|
+
// Check if we have a valid WebSocket connection
|
|
27
|
+
if (!wsManager) {
|
|
28
|
+
logger.warn("WebSocket manager not available");
|
|
29
|
+
return { channel: "websocket", success: false };
|
|
30
|
+
}
|
|
31
|
+
if (!websocket) {
|
|
32
|
+
logger.warn("WebSocket connection not found - object not sent", {
|
|
33
|
+
userId: config.userId,
|
|
34
|
+
conversationId: config.conversationId,
|
|
35
|
+
});
|
|
36
|
+
return { channel: "websocket", success: false };
|
|
37
|
+
}
|
|
38
|
+
// Send to WebSocket
|
|
39
|
+
websocket.send(JSON.stringify(event));
|
|
40
|
+
logger.info("✅ Data object sent to client", {
|
|
41
|
+
nodeId: config.nodeId,
|
|
42
|
+
objectId: config.objectId,
|
|
43
|
+
});
|
|
44
|
+
return { channel: "websocket", success: true };
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error("Failed to publish object", {
|
|
48
|
+
error: error.message,
|
|
49
|
+
workflowId: config.workflowId,
|
|
50
|
+
nodeId: config.nodeId,
|
|
51
|
+
});
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=publishObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishObject.js","sourceRoot":"","sources":["../../../src/SendObject/service/publishObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiBH,sCA0DC;AA1DM,KAAK,UAAU,aAAa,CACjC,MAA2B,EAC3B,GAAQ,EACR,OAAa;IAEb,MAAM,MAAM,GAAG,GAAG,EAAE,YAAY,EAAE,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC;IAEjE,IAAI,CAAC;QACH,wBAAwB;QACxB,MAAM,SAAS,GAAG,GAAG,EAAE,mBAAmB,EAAE,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,cAA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C,0BAA0B,EAAE;YACvC,KAAK,EAAE,KAAK,CAAC,OAAO;YACpB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/SendObject/util/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,GAAG,CAAC;KACX,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/SendObject/util/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggestions Node Executor
|
|
3
|
+
* Publishes FAQs, Actions, and Recommendations to the client state via WebSocket
|
|
4
|
+
*/
|
|
5
|
+
import { NodeExecutionContext, ValidationResult } from "@gravity-platform/plugin-base";
|
|
6
|
+
import { PromiseNode } from "../shared/platform";
|
|
7
|
+
interface SuggestionsConfig {
|
|
8
|
+
faqs?: Array<{
|
|
9
|
+
id?: string;
|
|
10
|
+
question: string;
|
|
11
|
+
}>;
|
|
12
|
+
actions?: Array<{
|
|
13
|
+
object?: Record<string, any>;
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
image?: string;
|
|
17
|
+
callToAction?: string;
|
|
18
|
+
}>;
|
|
19
|
+
recommendations?: Array<{
|
|
20
|
+
id?: string;
|
|
21
|
+
text: string;
|
|
22
|
+
confidence?: number;
|
|
23
|
+
actionLabel?: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export default class SuggestionsExecutor extends PromiseNode<SuggestionsConfig> {
|
|
27
|
+
constructor();
|
|
28
|
+
protected validateConfig(config: SuggestionsConfig): Promise<ValidationResult>;
|
|
29
|
+
protected executeNode(inputs: Record<string, any>, config: SuggestionsConfig, context: NodeExecutionContext): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Extract suggestions data from signal input
|
|
32
|
+
*/
|
|
33
|
+
private extractSignalData;
|
|
34
|
+
}
|
|
35
|
+
export { SuggestionsExecutor };
|
|
36
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/Suggestions/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,iBAAiB;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnG;AAcD,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,WAAW,CAAC,iBAAiB,CAAC;;cAK7D,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAKpE,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,GAAG,CAAC;IAoEf;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAkC1B;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Suggestions Node Executor
|
|
4
|
+
* Publishes FAQs, Actions, and Recommendations to the client state via WebSocket
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SuggestionsExecutor = void 0;
|
|
8
|
+
const platform_1 = require("../shared/platform");
|
|
9
|
+
class SuggestionsExecutor extends platform_1.PromiseNode {
|
|
10
|
+
constructor() {
|
|
11
|
+
super("Suggestions");
|
|
12
|
+
}
|
|
13
|
+
async validateConfig(config) {
|
|
14
|
+
// No required config - all optional
|
|
15
|
+
return { success: true };
|
|
16
|
+
}
|
|
17
|
+
async executeNode(inputs, config, context) {
|
|
18
|
+
// Extract suggestions from signal input or config
|
|
19
|
+
const signalData = this.extractSignalData(inputs);
|
|
20
|
+
const suggestions = {
|
|
21
|
+
faqs: signalData?.faqs || config.faqs || [],
|
|
22
|
+
actions: signalData?.actions || config.actions || [],
|
|
23
|
+
recommendations: signalData?.recommendations || config.recommendations || [],
|
|
24
|
+
};
|
|
25
|
+
this.logger.info("📤 Suggestions node executing", {
|
|
26
|
+
nodeId: context.nodeId,
|
|
27
|
+
faqCount: suggestions.faqs.length,
|
|
28
|
+
actionCount: suggestions.actions.length,
|
|
29
|
+
recommendationCount: suggestions.recommendations.length,
|
|
30
|
+
});
|
|
31
|
+
// Get publishing context
|
|
32
|
+
if (!context.publishingContext) {
|
|
33
|
+
this.logger.warn("Publishing context not available - suggestions not sent to client");
|
|
34
|
+
return { __outputs: { suggestions } };
|
|
35
|
+
}
|
|
36
|
+
// Publish to client via WebSocket
|
|
37
|
+
try {
|
|
38
|
+
const api = context.api;
|
|
39
|
+
const wsManager = api?.getWebSocketManager?.();
|
|
40
|
+
if (wsManager) {
|
|
41
|
+
const websocket = wsManager.get(context.publishingContext.userId, context.publishingContext.conversationId);
|
|
42
|
+
if (websocket) {
|
|
43
|
+
const wsMessage = {
|
|
44
|
+
type: "SUGGESTIONS_UPDATE",
|
|
45
|
+
chatId: context.publishingContext.chatId,
|
|
46
|
+
conversationId: context.publishingContext.conversationId,
|
|
47
|
+
userId: context.publishingContext.userId,
|
|
48
|
+
workflowId: context.workflowId,
|
|
49
|
+
workflowRunId: context.executionId,
|
|
50
|
+
suggestions,
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
};
|
|
53
|
+
websocket.send(JSON.stringify(wsMessage));
|
|
54
|
+
this.logger.info("✅ Suggestions sent to client", {
|
|
55
|
+
nodeId: context.nodeId,
|
|
56
|
+
userId: context.publishingContext.userId,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.logger.debug("No WebSocket connection found for suggestions");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.logger.debug("WebSocket manager not available");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.logger.warn("Failed to publish suggestions (non-blocking)", {
|
|
69
|
+
error: error.message,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
__outputs: {
|
|
74
|
+
suggestions,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Extract suggestions data from signal input
|
|
80
|
+
*/
|
|
81
|
+
extractSignalData(inputs) {
|
|
82
|
+
if (!inputs.signal)
|
|
83
|
+
return null;
|
|
84
|
+
// Handle direct object
|
|
85
|
+
if (typeof inputs.signal === "object" && !Array.isArray(inputs.signal)) {
|
|
86
|
+
// Check if it has suggestions properties directly
|
|
87
|
+
if (inputs.signal.faqs || inputs.signal.actions || inputs.signal.recommendations) {
|
|
88
|
+
return inputs.signal;
|
|
89
|
+
}
|
|
90
|
+
// Handle nested structure from signal routing
|
|
91
|
+
// e.g., { signal: { sourceNode: { outputHandle: { faqs: [...] } } } }
|
|
92
|
+
const sourceNodes = Object.keys(inputs.signal);
|
|
93
|
+
if (sourceNodes.length > 0) {
|
|
94
|
+
const sourceData = inputs.signal[sourceNodes[0]];
|
|
95
|
+
if (typeof sourceData === "object") {
|
|
96
|
+
// Check for direct properties
|
|
97
|
+
if (sourceData.faqs || sourceData.actions || sourceData.recommendations) {
|
|
98
|
+
return sourceData;
|
|
99
|
+
}
|
|
100
|
+
// Check nested output handle
|
|
101
|
+
const handles = Object.keys(sourceData);
|
|
102
|
+
if (handles.length > 0) {
|
|
103
|
+
const handleData = sourceData[handles[0]];
|
|
104
|
+
if (handleData?.faqs || handleData?.actions || handleData?.recommendations) {
|
|
105
|
+
return handleData;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.default = SuggestionsExecutor;
|
|
115
|
+
exports.SuggestionsExecutor = SuggestionsExecutor;
|
|
116
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/Suggestions/executor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iDAAiD;AA0BjD,MAAqB,mBAAoB,SAAQ,sBAA8B;IAC7E;QACE,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;I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@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggestions Node Definition
|
|
3
|
+
* Publishes FAQs, Actions, and Recommendations to the client state
|
|
4
|
+
*/
|
|
5
|
+
import { type EnhancedNodeDefinition } from "@gravity-platform/plugin-base";
|
|
6
|
+
import SuggestionsExecutor from "./executor";
|
|
7
|
+
export declare const NODE_TYPE = "Suggestions";
|
|
8
|
+
export declare function createNodeDefinition(): EnhancedNodeDefinition;
|
|
9
|
+
export declare const SuggestionsNode: {
|
|
10
|
+
definition: any;
|
|
11
|
+
executor: typeof SuggestionsExecutor;
|
|
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/Suggestions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,mBAAmB,MAAM,YAAY,CAAC;AAG7C,eAAO,MAAM,SAAS,gBAAgB,CAAC;AAGvC,wBAAgB,oBAAoB,IAAI,sBAAsB,CAsD7D;AAGD,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAGF,eAAO,MAAM,UAAU,KAAyB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Suggestions Node Definition
|
|
4
|
+
* Publishes FAQs, Actions, and Recommendations to the client state
|
|
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.SuggestionsNode = 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 = "Suggestions";
|
|
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: "Suggestions",
|
|
24
|
+
description: "Publish FAQs, Actions, and Recommendations to the client UI",
|
|
25
|
+
category: "Flow",
|
|
26
|
+
color: "#8B5CF6", // Purple for suggestions/AI
|
|
27
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1751366180/gravity/icons/gravityIcon.png",
|
|
28
|
+
inputs: [
|
|
29
|
+
{
|
|
30
|
+
name: "signal",
|
|
31
|
+
type: NodeInputType.ANY,
|
|
32
|
+
description: "Signal containing suggestions data",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
outputs: [
|
|
36
|
+
{
|
|
37
|
+
name: "suggestions",
|
|
38
|
+
type: NodeInputType.OBJECT,
|
|
39
|
+
description: "The suggestions object that was published",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
configSchema: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
faqs: {
|
|
46
|
+
type: "object",
|
|
47
|
+
title: "FAQs",
|
|
48
|
+
description: "Static FAQs (can be overridden by input)",
|
|
49
|
+
"ui:field": "template",
|
|
50
|
+
},
|
|
51
|
+
actions: {
|
|
52
|
+
type: "object",
|
|
53
|
+
title: "Actions",
|
|
54
|
+
description: "Static Actions (can be overridden by input)",
|
|
55
|
+
"ui:field": "template",
|
|
56
|
+
},
|
|
57
|
+
recommendations: {
|
|
58
|
+
type: "object",
|
|
59
|
+
title: "Recommendations",
|
|
60
|
+
description: "Static Recommendations (can be overridden by input)",
|
|
61
|
+
"ui:field": "template",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: [],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Export as enhanced node
|
|
69
|
+
exports.SuggestionsNode = {
|
|
70
|
+
definition: createNodeDefinition(),
|
|
71
|
+
executor: executor_1.default,
|
|
72
|
+
};
|
|
73
|
+
// Export for node registry
|
|
74
|
+
exports.definition = createNodeDefinition();
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Suggestions/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AASH,oDAsDC;AA7DD,+DAAqG;AACrG,0DAA6C;AAE7C,4BAA4B;AACf,QAAA,SAAS,GAAG,aAAa,CAAC;AAEvC,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,aAAa;QACnB,WAAW,EAAE,6DAA6D;QAC1E,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,SAAS,EAAE,4BAA4B;QAC9C,OAAO,EAAE,yFAAyF;QAElG,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,aAAa,CAAC,GAAG;gBACvB,WAAW,EAAE,oCAAoC;aAClD;SACF;QAED,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,aAAa,CAAC,MAAM;gBAC1B,WAAW,EAAE,2CAA2C;aACzD;SACF;QAED,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,MAAM;oBACb,WAAW,EAAE,0CAA0C;oBACvD,UAAU,EAAE,UAAU;iBACvB;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,SAAS;oBAChB,WAAW,EAAE,6CAA6C;oBAC1D,UAAU,EAAE,UAAU;iBACvB;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,iBAAiB;oBACxB,WAAW,EAAE,qDAAqD;oBAClE,UAAU,EAAE,UAAU;iBACvB;aACF;YACD,QAAQ,EAAE,EAAE;SACb;KACF,CAAC;AACJ,CAAC;AAED,0BAA0B;AACb,QAAA,eAAe,GAAG;IAC7B,UAAU,EAAE,oBAAoB,EAAE;IAClC,QAAQ,EAAE,kBAAmB;CAC9B,CAAC;AAEF,2BAA2B;AACd,QAAA,UAAU,GAAG,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UMAP Node Executor
|
|
3
|
+
* Performs UMAP dimensionality reduction on high-dimensional vectors
|
|
4
|
+
* Returns 3D UMAP coordinates (clustering should be done separately on full dataset)
|
|
5
|
+
*/
|
|
6
|
+
import { NodeExecutionContext, ValidationResult } from "@gravity-platform/plugin-base";
|
|
7
|
+
import { PromiseNode } from "../shared/platform";
|
|
8
|
+
interface UMAPConfig {
|
|
9
|
+
vector?: any;
|
|
10
|
+
nComponents?: number;
|
|
11
|
+
nNeighbors?: number;
|
|
12
|
+
minDist?: number;
|
|
13
|
+
}
|
|
14
|
+
declare class UMAPExecutor extends PromiseNode {
|
|
15
|
+
constructor();
|
|
16
|
+
protected validateConfig(config: UMAPConfig): Promise<ValidationResult>;
|
|
17
|
+
protected executeNode(inputs: Record<string, any>, config: UMAPConfig, context: NodeExecutionContext): Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
export default UMAPExecutor;
|
|
20
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/UMAP/executor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAQD,cAAM,YAAa,SAAQ,WAAW;;cAKpB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAsB7D,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,GAAG,CAAC;CA6EhB;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UMAP Node Executor
|
|
4
|
+
* Performs UMAP dimensionality reduction on high-dimensional vectors
|
|
5
|
+
* Returns 3D UMAP coordinates (clustering should be done separately on full dataset)
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const platform_1 = require("../shared/platform");
|
|
9
|
+
const umap_js_1 = require("umap-js");
|
|
10
|
+
class UMAPExecutor extends platform_1.PromiseNode {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("UMAP");
|
|
13
|
+
}
|
|
14
|
+
async validateConfig(config) {
|
|
15
|
+
if (config.nComponents && (config.nComponents < 1 || config.nComponents > 3)) {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
error: "nComponents must be between 1 and 3",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (config.nNeighbors && config.nNeighbors < 2) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
error: "nNeighbors must be at least 2",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (config.minDist && (config.minDist < 0 || config.minDist > 1)) {
|
|
28
|
+
return {
|
|
29
|
+
success: false,
|
|
30
|
+
error: "minDist must be between 0 and 1",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { success: true };
|
|
34
|
+
}
|
|
35
|
+
async executeNode(inputs, config, context) {
|
|
36
|
+
try {
|
|
37
|
+
// Get the embedding from config.vector (already resolved by template system)
|
|
38
|
+
const embedding = config.vector;
|
|
39
|
+
if (!embedding || !Array.isArray(embedding)) {
|
|
40
|
+
throw new Error("Config 'vector' must be an array of numbers");
|
|
41
|
+
}
|
|
42
|
+
if (embedding.length === 0) {
|
|
43
|
+
throw new Error("Embedding array cannot be empty");
|
|
44
|
+
}
|
|
45
|
+
// Validate all elements are numbers
|
|
46
|
+
if (!embedding.every((val) => typeof val === "number" && !isNaN(val))) {
|
|
47
|
+
throw new Error("All embedding values must be valid numbers");
|
|
48
|
+
}
|
|
49
|
+
this.logger?.info(`Processing embedding of dimension ${embedding.length}`);
|
|
50
|
+
// Configure UMAP
|
|
51
|
+
const nComponents = config.nComponents || 3;
|
|
52
|
+
const nNeighbors = config.nNeighbors || 15;
|
|
53
|
+
const minDist = config.minDist || 0.1;
|
|
54
|
+
// UMAP needs at least 2 points to work
|
|
55
|
+
// For a single embedding, we'll duplicate it with minimal variation
|
|
56
|
+
const dataPoints = [
|
|
57
|
+
embedding,
|
|
58
|
+
embedding.map((val) => val + 0.0001) // Tiny variation to make UMAP work
|
|
59
|
+
];
|
|
60
|
+
// Create and fit UMAP
|
|
61
|
+
const umap = new umap_js_1.UMAP({
|
|
62
|
+
nComponents,
|
|
63
|
+
nNeighbors: Math.min(nNeighbors, dataPoints.length - 1),
|
|
64
|
+
minDist,
|
|
65
|
+
});
|
|
66
|
+
const umapCoords = await umap.fit(dataPoints);
|
|
67
|
+
// Get the coordinates for the original embedding (first one)
|
|
68
|
+
const coords = umapCoords[0];
|
|
69
|
+
const coordinates = [
|
|
70
|
+
coords[0] || 0, // x
|
|
71
|
+
coords[1] || 0, // y
|
|
72
|
+
nComponents >= 3 ? coords[2] || 0 : 0, // z
|
|
73
|
+
];
|
|
74
|
+
// Build output - clustering will be done separately on full dataset
|
|
75
|
+
const output = {
|
|
76
|
+
coordinates,
|
|
77
|
+
clusterId: null, // Will be assigned during batch clustering
|
|
78
|
+
color: "#999999" // Default gray until clustering
|
|
79
|
+
};
|
|
80
|
+
this.logger?.info("UMAP reduction complete", {
|
|
81
|
+
inputDimension: embedding.length,
|
|
82
|
+
outputDimension: nComponents,
|
|
83
|
+
coordinates: {
|
|
84
|
+
x: coordinates[0],
|
|
85
|
+
y: coordinates[1],
|
|
86
|
+
z: coordinates[2],
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
// Return the result to the output connector
|
|
90
|
+
return {
|
|
91
|
+
__outputs: {
|
|
92
|
+
result: output,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.logger?.error("UMAP reduction failed:", error);
|
|
98
|
+
throw new Error(`UMAP reduction failed: ${error.message}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.default = UMAPExecutor;
|
|
103
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/UMAP/executor.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAGH,iDAAiD;AACjD,qCAA+B;AAe/B,MAAM,YAAa,SAAQ,sBAAW;IACpC;QACE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAAkB;QAC/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AS,CAAE,gCAAgC;aACnD,CAAC;YAEF,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,yBAAyB,EAAE;gBAC3C,cAAc,EAAE,SAAS,CAAC,MAAM;gBAChC,eAAe,EAAE,WAAW;gBAC5B,WAAW,EAAE;oBACX,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;oBACjB,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;oBACjB,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;iBAClB;aACF,CAAC,CAAC;YAEH,4CAA4C;YAC5C,OAAO;gBACL,SAAS,EAAE;oBACT,MAAM,EAAE,MAAM;iBACf;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UMAP Node Definition
|
|
3
|
+
* Performs UMAP dimensionality reduction on high-dimensional vectors
|
|
4
|
+
*/
|
|
5
|
+
import { type EnhancedNodeDefinition } from "@gravity-platform/plugin-base";
|
|
6
|
+
import UMAPExecutor from "./executor";
|
|
7
|
+
export declare const NODE_TYPE = "UMAP";
|
|
8
|
+
export declare function createNodeDefinition(): EnhancedNodeDefinition;
|
|
9
|
+
export declare const UMAPNode: {
|
|
10
|
+
definition: any;
|
|
11
|
+
executor: typeof UMAPExecutor;
|
|
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/UMAP/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,CAmE7D;AAGD,eAAO,MAAM,QAAQ;;;CAGpB,CAAC;AAGF,eAAO,MAAM,UAAU,KAAyB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UMAP Node Definition
|
|
4
|
+
* Performs UMAP dimensionality reduction on high-dimensional vectors
|
|
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.UMAPNode = 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 = "UMAP";
|
|
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: "UMAP",
|
|
24
|
+
description: "Reduce high-dimensional vectors to 3D coordinates using UMAP",
|
|
25
|
+
category: "Flow",
|
|
26
|
+
color: "#8b5cf6", // Purple color for ML/transformation
|
|
27
|
+
logoUrl: "https://res.cloudinary.com/sonik/image/upload/v1753958030/gravity/icons/uMapIcon.png",
|
|
28
|
+
inputs: [
|
|
29
|
+
{
|
|
30
|
+
name: "embedding",
|
|
31
|
+
type: NodeInputType.ARRAY,
|
|
32
|
+
description: "High-dimensional vector array",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
outputs: [
|
|
36
|
+
{
|
|
37
|
+
name: "result",
|
|
38
|
+
type: NodeInputType.OBJECT,
|
|
39
|
+
description: "UMAP result with 3D coordinates, cluster ID, and color (properties: coordinates[x,y,z], clusterId, color)",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
configSchema: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
vector: {
|
|
46
|
+
type: "object",
|
|
47
|
+
title: "Vector",
|
|
48
|
+
description: "Vector array to embed",
|
|
49
|
+
default: "",
|
|
50
|
+
"ui:field": "template",
|
|
51
|
+
},
|
|
52
|
+
nComponents: {
|
|
53
|
+
type: "number",
|
|
54
|
+
title: "Components",
|
|
55
|
+
description: "Number of dimensions to reduce to",
|
|
56
|
+
default: 3,
|
|
57
|
+
minimum: 1,
|
|
58
|
+
maximum: 3,
|
|
59
|
+
},
|
|
60
|
+
nNeighbors: {
|
|
61
|
+
type: "number",
|
|
62
|
+
title: "Neighbors",
|
|
63
|
+
description: "Number of neighbors for UMAP",
|
|
64
|
+
default: 15,
|
|
65
|
+
minimum: 2,
|
|
66
|
+
maximum: 100,
|
|
67
|
+
},
|
|
68
|
+
minDist: {
|
|
69
|
+
type: "number",
|
|
70
|
+
title: "Min Distance",
|
|
71
|
+
description: "Minimum distance between points in low-dimensional space",
|
|
72
|
+
default: 0.1,
|
|
73
|
+
minimum: 0,
|
|
74
|
+
maximum: 1,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
// Declare capabilities
|
|
79
|
+
capabilities: {
|
|
80
|
+
isTrigger: false,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Export as enhanced node
|
|
85
|
+
exports.UMAPNode = {
|
|
86
|
+
definition: createNodeDefinition(),
|
|
87
|
+
executor: executor_1.default,
|
|
88
|
+
};
|
|
89
|
+
// Export for node registry
|
|
90
|
+
exports.definition = createNodeDefinition();
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/UMAP/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AASH,oDAmEC;AA1ED,+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;QACjB,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,8DAA8D;QAC3E,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,SAAS,EAAE,qCAAqC;QACvD,OAAO,EAAE,sFAAsF;QAC/F,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,aAAa,CAAC,KAAK;gBACzB,WAAW,EAAE,+BAA+B;aAC7C;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,aAAa,CAAC,MAAM;gBAC1B,WAAW,EAAE,2GAA2G;aACzH;SACF;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,uBAAuB;oBACpC,OAAO,EAAE,EAAE;oBACX,UAAU,EAAE,UAAU;iBACvB;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,YAAY;oBACnB,WAAW,EAAE,mCAAmC;oBAChD,OAAO,EAAE,CAA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