n8n-mcp 2.11.3 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +26 -0
- package/README.md +8 -6
- package/data/nodes.db +0 -0
- package/dist/config/n8n-api.d.ts +6 -0
- package/dist/config/n8n-api.d.ts.map +1 -1
- package/dist/config/n8n-api.js +12 -0
- package/dist/config/n8n-api.js.map +1 -1
- package/dist/http-server-single-session.d.ts +6 -1
- package/dist/http-server-single-session.d.ts.map +1 -1
- package/dist/http-server-single-session.js +116 -4
- package/dist/http-server-single-session.js.map +1 -1
- package/dist/mcp/handlers-n8n-manager.d.ts +22 -17
- package/dist/mcp/handlers-n8n-manager.d.ts.map +1 -1
- package/dist/mcp/handlers-n8n-manager.js +255 -46
- package/dist/mcp/handlers-n8n-manager.js.map +1 -1
- package/dist/mcp/handlers-workflow-diff.d.ts +2 -1
- package/dist/mcp/handlers-workflow-diff.d.ts.map +1 -1
- package/dist/mcp/handlers-workflow-diff.js +2 -2
- package/dist/mcp/handlers-workflow-diff.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +41 -22
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tool-docs/index.d.ts.map +1 -1
- package/dist/mcp/tool-docs/index.js +1 -0
- package/dist/mcp/tool-docs/index.js.map +1 -1
- package/dist/mcp/tool-docs/validation/validate-workflow.js +1 -1
- package/dist/mcp/tool-docs/validation/validate-workflow.js.map +1 -1
- package/dist/mcp/tool-docs/workflow_management/index.d.ts +1 -0
- package/dist/mcp/tool-docs/workflow_management/index.d.ts.map +1 -1
- package/dist/mcp/tool-docs/workflow_management/index.js +3 -1
- package/dist/mcp/tool-docs/workflow_management/index.js.map +1 -1
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.js +127 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-validate-workflow.js +1 -1
- package/dist/mcp/tool-docs/workflow_management/n8n-validate-workflow.js.map +1 -1
- package/dist/mcp/tools-n8n-manager.d.ts.map +1 -1
- package/dist/mcp/tools-n8n-manager.js +35 -0
- package/dist/mcp/tools-n8n-manager.js.map +1 -1
- package/dist/mcp-engine.d.ts +2 -1
- package/dist/mcp-engine.d.ts.map +1 -1
- package/dist/mcp-engine.js +2 -2
- package/dist/mcp-engine.js.map +1 -1
- package/dist/scripts/debug-http-search.d.ts +3 -0
- package/dist/scripts/debug-http-search.d.ts.map +1 -0
- package/dist/scripts/debug-http-search.js +57 -0
- package/dist/scripts/debug-http-search.js.map +1 -0
- package/dist/scripts/sanitize-templates.js +11 -1
- package/dist/scripts/sanitize-templates.js.map +1 -1
- package/dist/scripts/test-autofix-documentation.d.ts +3 -0
- package/dist/scripts/test-autofix-documentation.d.ts.map +1 -0
- package/dist/scripts/test-autofix-documentation.js +103 -0
- package/dist/scripts/test-autofix-documentation.js.map +1 -0
- package/dist/scripts/test-autofix-workflow.d.ts +2 -0
- package/dist/scripts/test-autofix-workflow.d.ts.map +1 -0
- package/dist/scripts/test-autofix-workflow.js +223 -0
- package/dist/scripts/test-autofix-workflow.js.map +1 -0
- package/dist/scripts/test-node-suggestions.d.ts +3 -0
- package/dist/scripts/test-node-suggestions.d.ts.map +1 -0
- package/dist/scripts/test-node-suggestions.js +165 -0
- package/dist/scripts/test-node-suggestions.js.map +1 -0
- package/dist/scripts/test-summary.d.ts +3 -0
- package/dist/scripts/test-summary.d.ts.map +1 -0
- package/dist/scripts/test-summary.js +77 -0
- package/dist/scripts/test-summary.js.map +1 -0
- package/dist/scripts/test-validation-parity.d.ts +2 -0
- package/dist/scripts/test-validation-parity.d.ts.map +1 -0
- package/dist/scripts/test-validation-parity.js +153 -0
- package/dist/scripts/test-validation-parity.js.map +1 -0
- package/dist/scripts/test-webhook-autofix.d.ts +3 -0
- package/dist/scripts/test-webhook-autofix.d.ts.map +1 -0
- package/dist/scripts/test-webhook-autofix.js +117 -0
- package/dist/scripts/test-webhook-autofix.js.map +1 -0
- package/dist/services/confidence-scorer.d.ts +24 -0
- package/dist/services/confidence-scorer.d.ts.map +1 -0
- package/dist/services/confidence-scorer.js +139 -0
- package/dist/services/confidence-scorer.js.map +1 -0
- package/dist/services/expression-format-validator.d.ts +33 -0
- package/dist/services/expression-format-validator.d.ts.map +1 -0
- package/dist/services/expression-format-validator.js +209 -0
- package/dist/services/expression-format-validator.js.map +1 -0
- package/dist/services/node-similarity-service.d.ts +51 -0
- package/dist/services/node-similarity-service.d.ts.map +1 -0
- package/dist/services/node-similarity-service.js +335 -0
- package/dist/services/node-similarity-service.js.map +1 -0
- package/dist/services/universal-expression-validator.d.ts +20 -0
- package/dist/services/universal-expression-validator.d.ts.map +1 -0
- package/dist/services/universal-expression-validator.js +192 -0
- package/dist/services/universal-expression-validator.js.map +1 -0
- package/dist/services/workflow-auto-fixer.d.ts +65 -0
- package/dist/services/workflow-auto-fixer.d.ts.map +1 -0
- package/dist/services/workflow-auto-fixer.js +394 -0
- package/dist/services/workflow-auto-fixer.js.map +1 -0
- package/dist/services/workflow-ownership.d.ts +35 -0
- package/dist/services/workflow-ownership.d.ts.map +1 -0
- package/dist/services/workflow-ownership.js +195 -0
- package/dist/services/workflow-ownership.js.map +1 -0
- package/dist/services/workflow-validator.d.ts +2 -1
- package/dist/services/workflow-validator.d.ts.map +1 -1
- package/dist/services/workflow-validator.js +131 -90
- package/dist/services/workflow-validator.js.map +1 -1
- package/dist/types/instance-context.d.ts +15 -0
- package/dist/types/instance-context.d.ts.map +1 -0
- package/dist/types/instance-context.js +127 -0
- package/dist/types/instance-context.js.map +1 -0
- package/dist/types/n8n-api.d.ts +6 -0
- package/dist/types/n8n-api.d.ts.map +1 -1
- package/dist/types/n8n-api.js.map +1 -1
- package/dist/utils/cache-utils.d.ts +58 -0
- package/dist/utils/cache-utils.d.ts.map +1 -0
- package/dist/utils/cache-utils.js +243 -0
- package/dist/utils/cache-utils.js.map +1 -0
- package/dist/utils/node-type-utils.d.ts +9 -0
- package/dist/utils/node-type-utils.d.ts.map +1 -0
- package/dist/utils/node-type-utils.js +78 -0
- package/dist/utils/node-type-utils.js.map +1 -0
- package/dist/utils/template-sanitizer.d.ts.map +1 -1
- package/dist/utils/template-sanitizer.js +6 -3
- package/dist/utils/template-sanitizer.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpressionFormatValidator = void 0;
|
|
4
|
+
const universal_expression_validator_1 = require("./universal-expression-validator");
|
|
5
|
+
const confidence_scorer_1 = require("./confidence-scorer");
|
|
6
|
+
class ExpressionFormatValidator {
|
|
7
|
+
static shouldUseResourceLocator(fieldName, nodeType) {
|
|
8
|
+
const nodeBase = nodeType.split('.').pop()?.toLowerCase() || '';
|
|
9
|
+
for (const [pattern, fields] of Object.entries(this.RESOURCE_LOCATOR_FIELDS)) {
|
|
10
|
+
if ((nodeBase === pattern || nodeBase.startsWith(`${pattern}-`)) && fields.includes(fieldName)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
static isResourceLocator(value) {
|
|
17
|
+
if (typeof value !== 'object' || value === null || value.__rl !== true) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (!('value' in value) || !('mode' in value)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value.mode !== 'string' || !this.VALID_RL_MODES.includes(value.mode)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
static generateCorrection(value, needsResourceLocator) {
|
|
29
|
+
const correctedValue = value.startsWith(this.EXPRESSION_PREFIX)
|
|
30
|
+
? value
|
|
31
|
+
: `${this.EXPRESSION_PREFIX}${value}`;
|
|
32
|
+
if (needsResourceLocator) {
|
|
33
|
+
return {
|
|
34
|
+
__rl: true,
|
|
35
|
+
value: correctedValue,
|
|
36
|
+
mode: 'expression'
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return correctedValue;
|
|
40
|
+
}
|
|
41
|
+
static validateAndFix(value, fieldPath, context) {
|
|
42
|
+
if (typeof value !== 'string' && !this.isResourceLocator(value)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (this.isResourceLocator(value)) {
|
|
46
|
+
const universalResults = universal_expression_validator_1.UniversalExpressionValidator.validate(value.value);
|
|
47
|
+
const invalidResult = universalResults.find(r => !r.isValid && r.needsPrefix);
|
|
48
|
+
if (invalidResult) {
|
|
49
|
+
return {
|
|
50
|
+
fieldPath,
|
|
51
|
+
currentValue: value,
|
|
52
|
+
correctedValue: {
|
|
53
|
+
...value,
|
|
54
|
+
value: universal_expression_validator_1.UniversalExpressionValidator.getCorrectedValue(value.value)
|
|
55
|
+
},
|
|
56
|
+
issueType: 'missing-prefix',
|
|
57
|
+
explanation: `Resource locator value: ${invalidResult.explanation}`,
|
|
58
|
+
severity: 'error'
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const universalResults = universal_expression_validator_1.UniversalExpressionValidator.validate(value);
|
|
64
|
+
const invalidResults = universalResults.filter(r => !r.isValid);
|
|
65
|
+
if (invalidResults.length > 0) {
|
|
66
|
+
const prefixIssue = invalidResults.find(r => r.needsPrefix);
|
|
67
|
+
if (prefixIssue) {
|
|
68
|
+
const fieldName = fieldPath.split('.').pop() || '';
|
|
69
|
+
const confidenceScore = confidence_scorer_1.ConfidenceScorer.scoreResourceLocatorRecommendation(fieldName, context.nodeType, value);
|
|
70
|
+
if (confidenceScore.value >= 0.8) {
|
|
71
|
+
return {
|
|
72
|
+
fieldPath,
|
|
73
|
+
currentValue: value,
|
|
74
|
+
correctedValue: this.generateCorrection(value, true),
|
|
75
|
+
issueType: 'needs-resource-locator',
|
|
76
|
+
explanation: `Field '${fieldName}' contains expression but needs resource locator format with '${this.EXPRESSION_PREFIX}' prefix for evaluation.`,
|
|
77
|
+
severity: 'error',
|
|
78
|
+
confidence: confidenceScore.value
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return {
|
|
83
|
+
fieldPath,
|
|
84
|
+
currentValue: value,
|
|
85
|
+
correctedValue: universal_expression_validator_1.UniversalExpressionValidator.getCorrectedValue(value),
|
|
86
|
+
issueType: 'missing-prefix',
|
|
87
|
+
explanation: prefixIssue.explanation,
|
|
88
|
+
severity: 'error'
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const firstIssue = invalidResults[0];
|
|
93
|
+
return {
|
|
94
|
+
fieldPath,
|
|
95
|
+
currentValue: value,
|
|
96
|
+
correctedValue: value,
|
|
97
|
+
issueType: 'mixed-format',
|
|
98
|
+
explanation: firstIssue.explanation,
|
|
99
|
+
severity: 'error'
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const hasExpression = universalResults.some(r => r.hasExpression);
|
|
103
|
+
if (hasExpression && typeof value === 'string') {
|
|
104
|
+
const fieldName = fieldPath.split('.').pop() || '';
|
|
105
|
+
const confidenceScore = confidence_scorer_1.ConfidenceScorer.scoreResourceLocatorRecommendation(fieldName, context.nodeType, value);
|
|
106
|
+
if (confidenceScore.value >= 0.5) {
|
|
107
|
+
return {
|
|
108
|
+
fieldPath,
|
|
109
|
+
currentValue: value,
|
|
110
|
+
correctedValue: this.generateCorrection(value, true),
|
|
111
|
+
issueType: 'needs-resource-locator',
|
|
112
|
+
explanation: `Field '${fieldName}' should use resource locator format for better compatibility. (Confidence: ${Math.round(confidenceScore.value * 100)}%)`,
|
|
113
|
+
severity: 'warning',
|
|
114
|
+
confidence: confidenceScore.value
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
static validateNodeParameters(parameters, context) {
|
|
121
|
+
const issues = [];
|
|
122
|
+
const visited = new WeakSet();
|
|
123
|
+
this.validateRecursive(parameters, '', context, issues, visited);
|
|
124
|
+
return issues;
|
|
125
|
+
}
|
|
126
|
+
static validateRecursive(obj, path, context, issues, visited, depth = 0) {
|
|
127
|
+
if (depth > this.MAX_RECURSION_DEPTH) {
|
|
128
|
+
issues.push({
|
|
129
|
+
fieldPath: path,
|
|
130
|
+
currentValue: obj,
|
|
131
|
+
correctedValue: obj,
|
|
132
|
+
issueType: 'mixed-format',
|
|
133
|
+
explanation: `Maximum recursion depth (${this.MAX_RECURSION_DEPTH}) exceeded. Object may have circular references or be too deeply nested.`,
|
|
134
|
+
severity: 'warning'
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (obj && typeof obj === 'object') {
|
|
139
|
+
if (visited.has(obj))
|
|
140
|
+
return;
|
|
141
|
+
visited.add(obj);
|
|
142
|
+
}
|
|
143
|
+
const issue = this.validateAndFix(obj, path, context);
|
|
144
|
+
if (issue) {
|
|
145
|
+
issues.push(issue);
|
|
146
|
+
}
|
|
147
|
+
if (Array.isArray(obj)) {
|
|
148
|
+
obj.forEach((item, index) => {
|
|
149
|
+
const newPath = path ? `${path}[${index}]` : `[${index}]`;
|
|
150
|
+
this.validateRecursive(item, newPath, context, issues, visited, depth + 1);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else if (obj && typeof obj === 'object') {
|
|
154
|
+
if (this.isResourceLocator(obj)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
158
|
+
if (key.startsWith('__'))
|
|
159
|
+
return;
|
|
160
|
+
const newPath = path ? `${path}.${key}` : key;
|
|
161
|
+
this.validateRecursive(value, newPath, context, issues, visited, depth + 1);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
static formatErrorMessage(issue, context) {
|
|
166
|
+
let message = `Expression format ${issue.severity} in node '${context.nodeName}':\n`;
|
|
167
|
+
message += `Field '${issue.fieldPath}' ${issue.explanation}\n\n`;
|
|
168
|
+
message += `Current (incorrect):\n`;
|
|
169
|
+
if (typeof issue.currentValue === 'string') {
|
|
170
|
+
message += `"${issue.fieldPath}": "${issue.currentValue}"\n\n`;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
message += `"${issue.fieldPath}": ${JSON.stringify(issue.currentValue, null, 2)}\n\n`;
|
|
174
|
+
}
|
|
175
|
+
message += `Fixed (correct):\n`;
|
|
176
|
+
if (typeof issue.correctedValue === 'string') {
|
|
177
|
+
message += `"${issue.fieldPath}": "${issue.correctedValue}"`;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
message += `"${issue.fieldPath}": ${JSON.stringify(issue.correctedValue, null, 2)}`;
|
|
181
|
+
}
|
|
182
|
+
return message;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.ExpressionFormatValidator = ExpressionFormatValidator;
|
|
186
|
+
ExpressionFormatValidator.VALID_RL_MODES = ['id', 'url', 'expression', 'name', 'list'];
|
|
187
|
+
ExpressionFormatValidator.MAX_RECURSION_DEPTH = 100;
|
|
188
|
+
ExpressionFormatValidator.EXPRESSION_PREFIX = '=';
|
|
189
|
+
ExpressionFormatValidator.RESOURCE_LOCATOR_FIELDS = {
|
|
190
|
+
'github': ['owner', 'repository', 'user', 'organization'],
|
|
191
|
+
'googleSheets': ['sheetId', 'documentId', 'spreadsheetId', 'rangeDefinition'],
|
|
192
|
+
'googleDrive': ['fileId', 'folderId', 'driveId'],
|
|
193
|
+
'slack': ['channel', 'user', 'channelId', 'userId', 'teamId'],
|
|
194
|
+
'notion': ['databaseId', 'pageId', 'blockId'],
|
|
195
|
+
'airtable': ['baseId', 'tableId', 'viewId'],
|
|
196
|
+
'monday': ['boardId', 'itemId', 'groupId'],
|
|
197
|
+
'hubspot': ['contactId', 'companyId', 'dealId'],
|
|
198
|
+
'salesforce': ['recordId', 'objectName'],
|
|
199
|
+
'jira': ['projectKey', 'issueKey', 'boardId'],
|
|
200
|
+
'gitlab': ['projectId', 'mergeRequestId', 'issueId'],
|
|
201
|
+
'mysql': ['table', 'database', 'schema'],
|
|
202
|
+
'postgres': ['table', 'database', 'schema'],
|
|
203
|
+
'mongodb': ['collection', 'database'],
|
|
204
|
+
's3': ['bucketName', 'key', 'fileName'],
|
|
205
|
+
'ftp': ['path', 'fileName'],
|
|
206
|
+
'ssh': ['path', 'fileName'],
|
|
207
|
+
'redis': ['key'],
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=expression-format-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-format-validator.js","sourceRoot":"","sources":["../../src/services/expression-format-validator.ts"],"names":[],"mappings":";;;AASA,qFAA2G;AAC3G,2DAAuD;AAwBvD,MAAa,yBAAyB;IAkC5B,MAAM,CAAC,wBAAwB,CAAC,SAAiB,EAAE,QAAgB;QAEzE,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAGhE,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC;YAG7E,IAAI,CAAC,QAAQ,KAAK,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC/F,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAGD,OAAO,KAAK,CAAC;I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Aa,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;IAChD,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC;IAC7D,QAAQ,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC;IAC7C,UAAU,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;IAC3C,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC;IAC1C,SAAS,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC;IAC/C,YAAY,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;IACxC,MAAM,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC;IAC7C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,EAAE,SAAS,CAAC;IACpD,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;IACxC,UAAU,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;IAC3C,SAAS,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;IACrC,IAAI,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,UAAU,CAAC;IACvC,KAAK,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;IAC3B,KAAK,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;IAC3B,OAAO,EAAE,CAAC,KAAK,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { NodeRepository } from '../database/node-repository';
|
|
2
|
+
export interface NodeSuggestion {
|
|
3
|
+
nodeType: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
confidence: number;
|
|
6
|
+
reason: string;
|
|
7
|
+
category?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SimilarityScore {
|
|
11
|
+
nameSimilarity: number;
|
|
12
|
+
categoryMatch: number;
|
|
13
|
+
packageMatch: number;
|
|
14
|
+
patternMatch: number;
|
|
15
|
+
totalScore: number;
|
|
16
|
+
}
|
|
17
|
+
export interface CommonMistakePattern {
|
|
18
|
+
pattern: string;
|
|
19
|
+
suggestion: string;
|
|
20
|
+
confidence: number;
|
|
21
|
+
reason: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class NodeSimilarityService {
|
|
24
|
+
private static readonly SCORING_THRESHOLD;
|
|
25
|
+
private static readonly TYPO_EDIT_DISTANCE;
|
|
26
|
+
private static readonly SHORT_SEARCH_LENGTH;
|
|
27
|
+
private static readonly CACHE_DURATION_MS;
|
|
28
|
+
private static readonly AUTO_FIX_CONFIDENCE;
|
|
29
|
+
private repository;
|
|
30
|
+
private commonMistakes;
|
|
31
|
+
private nodeCache;
|
|
32
|
+
private cacheExpiry;
|
|
33
|
+
private cacheVersion;
|
|
34
|
+
constructor(repository: NodeRepository);
|
|
35
|
+
private initializeCommonMistakes;
|
|
36
|
+
private isCommonNodeWithoutPrefix;
|
|
37
|
+
findSimilarNodes(invalidType: string, limit?: number): Promise<NodeSuggestion[]>;
|
|
38
|
+
private checkCommonMistakes;
|
|
39
|
+
private calculateSimilarityScore;
|
|
40
|
+
private createSuggestion;
|
|
41
|
+
private normalizeNodeType;
|
|
42
|
+
private getStringSimilarity;
|
|
43
|
+
private getEditDistance;
|
|
44
|
+
private getCachedNodes;
|
|
45
|
+
invalidateCache(): void;
|
|
46
|
+
refreshCache(): Promise<void>;
|
|
47
|
+
formatSuggestionMessage(suggestions: NodeSuggestion[], invalidType: string): string;
|
|
48
|
+
isAutoFixable(suggestion: NodeSuggestion): boolean;
|
|
49
|
+
clearCache(): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=node-similarity-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-similarity-service.d.ts","sourceRoot":"","sources":["../../src/services/node-similarity-service.ts"],"names":[],"mappings":"AA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O,CAAC,cAAc,EAAE,CAAC;IA8CzF,OAAO,CAAC,mBAAmB;IA0E3B,OAAO,CAAC,wBAAwB;IAuEhC,OAAO,CAAC,gBAAgB;IA2BxB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,eAAe;YAgDT,cAAc;IAqCrB,eAAe,IAAI,IAAI;IAUjB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ1C,uBAAuB,CAAC,WAAW,EAAE,cAAc,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;IA8BnF,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO;IAQlD,UAAU,IAAI,IAAI;CAGnB"}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeSimilarityService = void 0;
|
|
4
|
+
const logger_1 = require("../utils/logger");
|
|
5
|
+
class NodeSimilarityService {
|
|
6
|
+
constructor(repository) {
|
|
7
|
+
this.nodeCache = null;
|
|
8
|
+
this.cacheExpiry = 0;
|
|
9
|
+
this.cacheVersion = 0;
|
|
10
|
+
this.repository = repository;
|
|
11
|
+
this.commonMistakes = this.initializeCommonMistakes();
|
|
12
|
+
}
|
|
13
|
+
initializeCommonMistakes() {
|
|
14
|
+
const patterns = new Map();
|
|
15
|
+
patterns.set('case_variations', [
|
|
16
|
+
{ pattern: 'httprequest', suggestion: 'nodes-base.httpRequest', confidence: 0.95, reason: 'Incorrect capitalization' },
|
|
17
|
+
{ pattern: 'webhook', suggestion: 'nodes-base.webhook', confidence: 0.95, reason: 'Incorrect capitalization' },
|
|
18
|
+
{ pattern: 'slack', suggestion: 'nodes-base.slack', confidence: 0.9, reason: 'Missing package prefix' },
|
|
19
|
+
{ pattern: 'gmail', suggestion: 'nodes-base.gmail', confidence: 0.9, reason: 'Missing package prefix' },
|
|
20
|
+
{ pattern: 'googlesheets', suggestion: 'nodes-base.googleSheets', confidence: 0.9, reason: 'Missing package prefix' },
|
|
21
|
+
{ pattern: 'telegram', suggestion: 'nodes-base.telegram', confidence: 0.9, reason: 'Missing package prefix' },
|
|
22
|
+
]);
|
|
23
|
+
patterns.set('specific_variations', [
|
|
24
|
+
{ pattern: 'HttpRequest', suggestion: 'nodes-base.httpRequest', confidence: 0.95, reason: 'Incorrect capitalization' },
|
|
25
|
+
{ pattern: 'HTTPRequest', suggestion: 'nodes-base.httpRequest', confidence: 0.95, reason: 'Common capitalization mistake' },
|
|
26
|
+
{ pattern: 'Webhook', suggestion: 'nodes-base.webhook', confidence: 0.95, reason: 'Incorrect capitalization' },
|
|
27
|
+
{ pattern: 'WebHook', suggestion: 'nodes-base.webhook', confidence: 0.95, reason: 'Common capitalization mistake' },
|
|
28
|
+
]);
|
|
29
|
+
patterns.set('deprecated_prefixes', [
|
|
30
|
+
{ pattern: 'n8n-nodes-base.', suggestion: 'nodes-base.', confidence: 0.95, reason: 'Full package name used instead of short form' },
|
|
31
|
+
{ pattern: '@n8n/n8n-nodes-langchain.', suggestion: 'nodes-langchain.', confidence: 0.95, reason: 'Full package name used instead of short form' },
|
|
32
|
+
]);
|
|
33
|
+
patterns.set('typos', [
|
|
34
|
+
{ pattern: 'htprequest', suggestion: 'nodes-base.httpRequest', confidence: 0.8, reason: 'Likely typo' },
|
|
35
|
+
{ pattern: 'httpreqest', suggestion: 'nodes-base.httpRequest', confidence: 0.8, reason: 'Likely typo' },
|
|
36
|
+
{ pattern: 'webook', suggestion: 'nodes-base.webhook', confidence: 0.8, reason: 'Likely typo' },
|
|
37
|
+
{ pattern: 'slak', suggestion: 'nodes-base.slack', confidence: 0.8, reason: 'Likely typo' },
|
|
38
|
+
{ pattern: 'googlesheets', suggestion: 'nodes-base.googleSheets', confidence: 0.8, reason: 'Likely typo' },
|
|
39
|
+
]);
|
|
40
|
+
patterns.set('ai_nodes', [
|
|
41
|
+
{ pattern: 'openai', suggestion: 'nodes-langchain.openAi', confidence: 0.85, reason: 'AI node - incorrect package' },
|
|
42
|
+
{ pattern: 'nodes-base.openai', suggestion: 'nodes-langchain.openAi', confidence: 0.9, reason: 'Wrong package - OpenAI is in LangChain package' },
|
|
43
|
+
{ pattern: 'chatopenai', suggestion: 'nodes-langchain.lmChatOpenAi', confidence: 0.85, reason: 'LangChain node naming convention' },
|
|
44
|
+
{ pattern: 'vectorstore', suggestion: 'nodes-langchain.vectorStoreInMemory', confidence: 0.7, reason: 'Generic vector store reference' },
|
|
45
|
+
]);
|
|
46
|
+
return patterns;
|
|
47
|
+
}
|
|
48
|
+
isCommonNodeWithoutPrefix(type) {
|
|
49
|
+
const commonNodes = {
|
|
50
|
+
'httprequest': 'nodes-base.httpRequest',
|
|
51
|
+
'webhook': 'nodes-base.webhook',
|
|
52
|
+
'slack': 'nodes-base.slack',
|
|
53
|
+
'gmail': 'nodes-base.gmail',
|
|
54
|
+
'googlesheets': 'nodes-base.googleSheets',
|
|
55
|
+
'telegram': 'nodes-base.telegram',
|
|
56
|
+
'discord': 'nodes-base.discord',
|
|
57
|
+
'notion': 'nodes-base.notion',
|
|
58
|
+
'airtable': 'nodes-base.airtable',
|
|
59
|
+
'postgres': 'nodes-base.postgres',
|
|
60
|
+
'mysql': 'nodes-base.mySql',
|
|
61
|
+
'mongodb': 'nodes-base.mongoDb',
|
|
62
|
+
};
|
|
63
|
+
const normalized = type.toLowerCase();
|
|
64
|
+
return commonNodes[normalized] || null;
|
|
65
|
+
}
|
|
66
|
+
async findSimilarNodes(invalidType, limit = 5) {
|
|
67
|
+
if (!invalidType || invalidType.trim() === '') {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const suggestions = [];
|
|
71
|
+
const mistakeSuggestion = this.checkCommonMistakes(invalidType);
|
|
72
|
+
if (mistakeSuggestion) {
|
|
73
|
+
suggestions.push(mistakeSuggestion);
|
|
74
|
+
}
|
|
75
|
+
const allNodes = await this.getCachedNodes();
|
|
76
|
+
const scores = allNodes.map(node => ({
|
|
77
|
+
node,
|
|
78
|
+
score: this.calculateSimilarityScore(invalidType, node)
|
|
79
|
+
}));
|
|
80
|
+
scores.sort((a, b) => b.score.totalScore - a.score.totalScore);
|
|
81
|
+
for (const { node, score } of scores) {
|
|
82
|
+
if (suggestions.some(s => s.nodeType === node.nodeType)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (score.totalScore >= NodeSimilarityService.SCORING_THRESHOLD) {
|
|
86
|
+
suggestions.push(this.createSuggestion(node, score));
|
|
87
|
+
}
|
|
88
|
+
if (suggestions.length >= limit) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return suggestions;
|
|
93
|
+
}
|
|
94
|
+
checkCommonMistakes(invalidType) {
|
|
95
|
+
const cleanType = invalidType.trim();
|
|
96
|
+
const lowerType = cleanType.toLowerCase();
|
|
97
|
+
const commonNodeSuggestion = this.isCommonNodeWithoutPrefix(cleanType);
|
|
98
|
+
if (commonNodeSuggestion) {
|
|
99
|
+
const node = this.repository.getNode(commonNodeSuggestion);
|
|
100
|
+
if (node) {
|
|
101
|
+
return {
|
|
102
|
+
nodeType: commonNodeSuggestion,
|
|
103
|
+
displayName: node.displayName,
|
|
104
|
+
confidence: 0.9,
|
|
105
|
+
reason: 'Missing package prefix',
|
|
106
|
+
category: node.category,
|
|
107
|
+
description: node.description
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (const [category, patterns] of this.commonMistakes) {
|
|
112
|
+
if (category === 'deprecated_prefixes') {
|
|
113
|
+
for (const pattern of patterns) {
|
|
114
|
+
if (cleanType.startsWith(pattern.pattern)) {
|
|
115
|
+
const actualSuggestion = cleanType.replace(pattern.pattern, pattern.suggestion);
|
|
116
|
+
const node = this.repository.getNode(actualSuggestion);
|
|
117
|
+
if (node) {
|
|
118
|
+
return {
|
|
119
|
+
nodeType: actualSuggestion,
|
|
120
|
+
displayName: node.displayName,
|
|
121
|
+
confidence: pattern.confidence,
|
|
122
|
+
reason: pattern.reason,
|
|
123
|
+
category: node.category,
|
|
124
|
+
description: node.description
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const [category, patterns] of this.commonMistakes) {
|
|
132
|
+
if (category === 'deprecated_prefixes')
|
|
133
|
+
continue;
|
|
134
|
+
for (const pattern of patterns) {
|
|
135
|
+
const match = category === 'specific_variations'
|
|
136
|
+
? cleanType === pattern.pattern
|
|
137
|
+
: lowerType === pattern.pattern.toLowerCase();
|
|
138
|
+
if (match && pattern.suggestion) {
|
|
139
|
+
const node = this.repository.getNode(pattern.suggestion);
|
|
140
|
+
if (node) {
|
|
141
|
+
return {
|
|
142
|
+
nodeType: pattern.suggestion,
|
|
143
|
+
displayName: node.displayName,
|
|
144
|
+
confidence: pattern.confidence,
|
|
145
|
+
reason: pattern.reason,
|
|
146
|
+
category: node.category,
|
|
147
|
+
description: node.description
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
calculateSimilarityScore(invalidType, node) {
|
|
156
|
+
const cleanInvalid = this.normalizeNodeType(invalidType);
|
|
157
|
+
const cleanValid = this.normalizeNodeType(node.nodeType);
|
|
158
|
+
const displayNameClean = this.normalizeNodeType(node.displayName);
|
|
159
|
+
const isShortSearch = invalidType.length <= NodeSimilarityService.SHORT_SEARCH_LENGTH;
|
|
160
|
+
let nameSimilarity = Math.max(this.getStringSimilarity(cleanInvalid, cleanValid), this.getStringSimilarity(cleanInvalid, displayNameClean)) * 40;
|
|
161
|
+
if (isShortSearch && (cleanValid.includes(cleanInvalid) || displayNameClean.includes(cleanInvalid))) {
|
|
162
|
+
nameSimilarity = Math.max(nameSimilarity, 10);
|
|
163
|
+
}
|
|
164
|
+
let categoryMatch = 0;
|
|
165
|
+
if (node.category) {
|
|
166
|
+
const categoryClean = this.normalizeNodeType(node.category);
|
|
167
|
+
if (cleanInvalid.includes(categoryClean) || categoryClean.includes(cleanInvalid)) {
|
|
168
|
+
categoryMatch = 20;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
let packageMatch = 0;
|
|
172
|
+
const invalidParts = cleanInvalid.split(/[.-]/);
|
|
173
|
+
const validParts = cleanValid.split(/[.-]/);
|
|
174
|
+
if (invalidParts[0] === validParts[0]) {
|
|
175
|
+
packageMatch = 15;
|
|
176
|
+
}
|
|
177
|
+
let patternMatch = 0;
|
|
178
|
+
if (cleanValid.includes(cleanInvalid) || displayNameClean.includes(cleanInvalid)) {
|
|
179
|
+
patternMatch = isShortSearch ? 45 : 25;
|
|
180
|
+
}
|
|
181
|
+
else if (this.getEditDistance(cleanInvalid, cleanValid) <= NodeSimilarityService.TYPO_EDIT_DISTANCE) {
|
|
182
|
+
patternMatch = 20;
|
|
183
|
+
}
|
|
184
|
+
else if (this.getEditDistance(cleanInvalid, displayNameClean) <= NodeSimilarityService.TYPO_EDIT_DISTANCE) {
|
|
185
|
+
patternMatch = 18;
|
|
186
|
+
}
|
|
187
|
+
if (isShortSearch && (cleanValid.startsWith(cleanInvalid) || displayNameClean.startsWith(cleanInvalid))) {
|
|
188
|
+
patternMatch = Math.max(patternMatch, 40);
|
|
189
|
+
}
|
|
190
|
+
const totalScore = nameSimilarity + categoryMatch + packageMatch + patternMatch;
|
|
191
|
+
return {
|
|
192
|
+
nameSimilarity,
|
|
193
|
+
categoryMatch,
|
|
194
|
+
packageMatch,
|
|
195
|
+
patternMatch,
|
|
196
|
+
totalScore
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
createSuggestion(node, score) {
|
|
200
|
+
let reason = 'Similar node';
|
|
201
|
+
if (score.patternMatch >= 20) {
|
|
202
|
+
reason = 'Name similarity';
|
|
203
|
+
}
|
|
204
|
+
else if (score.categoryMatch >= 15) {
|
|
205
|
+
reason = 'Same category';
|
|
206
|
+
}
|
|
207
|
+
else if (score.packageMatch >= 10) {
|
|
208
|
+
reason = 'Same package';
|
|
209
|
+
}
|
|
210
|
+
const confidence = Math.min(score.totalScore / 100, 1);
|
|
211
|
+
return {
|
|
212
|
+
nodeType: node.nodeType,
|
|
213
|
+
displayName: node.displayName,
|
|
214
|
+
confidence,
|
|
215
|
+
reason,
|
|
216
|
+
category: node.category,
|
|
217
|
+
description: node.description
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
normalizeNodeType(type) {
|
|
221
|
+
return type
|
|
222
|
+
.toLowerCase()
|
|
223
|
+
.replace(/[^a-z0-9]/g, '')
|
|
224
|
+
.trim();
|
|
225
|
+
}
|
|
226
|
+
getStringSimilarity(s1, s2) {
|
|
227
|
+
if (s1 === s2)
|
|
228
|
+
return 1;
|
|
229
|
+
if (!s1 || !s2)
|
|
230
|
+
return 0;
|
|
231
|
+
const distance = this.getEditDistance(s1, s2);
|
|
232
|
+
const maxLen = Math.max(s1.length, s2.length);
|
|
233
|
+
return 1 - (distance / maxLen);
|
|
234
|
+
}
|
|
235
|
+
getEditDistance(s1, s2, maxDistance = 5) {
|
|
236
|
+
if (s1 === s2)
|
|
237
|
+
return 0;
|
|
238
|
+
const m = s1.length;
|
|
239
|
+
const n = s2.length;
|
|
240
|
+
const lengthDiff = Math.abs(m - n);
|
|
241
|
+
if (lengthDiff > maxDistance)
|
|
242
|
+
return maxDistance + 1;
|
|
243
|
+
if (m === 0)
|
|
244
|
+
return n;
|
|
245
|
+
if (n === 0)
|
|
246
|
+
return m;
|
|
247
|
+
let prev = Array(n + 1).fill(0).map((_, i) => i);
|
|
248
|
+
for (let i = 1; i <= m; i++) {
|
|
249
|
+
const curr = [i];
|
|
250
|
+
let minInRow = i;
|
|
251
|
+
for (let j = 1; j <= n; j++) {
|
|
252
|
+
const cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
|
|
253
|
+
const val = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
254
|
+
curr.push(val);
|
|
255
|
+
minInRow = Math.min(minInRow, val);
|
|
256
|
+
}
|
|
257
|
+
if (minInRow > maxDistance) {
|
|
258
|
+
return maxDistance + 1;
|
|
259
|
+
}
|
|
260
|
+
prev = curr;
|
|
261
|
+
}
|
|
262
|
+
return prev[n];
|
|
263
|
+
}
|
|
264
|
+
async getCachedNodes() {
|
|
265
|
+
const now = Date.now();
|
|
266
|
+
if (!this.nodeCache || now > this.cacheExpiry) {
|
|
267
|
+
try {
|
|
268
|
+
const newNodes = this.repository.getAllNodes();
|
|
269
|
+
if (newNodes && newNodes.length > 0) {
|
|
270
|
+
this.nodeCache = newNodes;
|
|
271
|
+
this.cacheExpiry = now + NodeSimilarityService.CACHE_DURATION_MS;
|
|
272
|
+
this.cacheVersion++;
|
|
273
|
+
logger_1.logger.debug('Node cache refreshed', {
|
|
274
|
+
count: newNodes.length,
|
|
275
|
+
version: this.cacheVersion
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
else if (this.nodeCache) {
|
|
279
|
+
logger_1.logger.warn('Node fetch returned empty, using stale cache');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
logger_1.logger.error('Failed to fetch nodes for similarity service', error);
|
|
284
|
+
if (this.nodeCache) {
|
|
285
|
+
logger_1.logger.info('Using stale cache due to fetch error');
|
|
286
|
+
return this.nodeCache;
|
|
287
|
+
}
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return this.nodeCache || [];
|
|
292
|
+
}
|
|
293
|
+
invalidateCache() {
|
|
294
|
+
this.nodeCache = null;
|
|
295
|
+
this.cacheExpiry = 0;
|
|
296
|
+
this.cacheVersion++;
|
|
297
|
+
logger_1.logger.debug('Node cache invalidated', { version: this.cacheVersion });
|
|
298
|
+
}
|
|
299
|
+
async refreshCache() {
|
|
300
|
+
this.invalidateCache();
|
|
301
|
+
await this.getCachedNodes();
|
|
302
|
+
}
|
|
303
|
+
formatSuggestionMessage(suggestions, invalidType) {
|
|
304
|
+
if (suggestions.length === 0) {
|
|
305
|
+
return `Unknown node type: "${invalidType}". No similar nodes found.`;
|
|
306
|
+
}
|
|
307
|
+
let message = `Unknown node type: "${invalidType}"\n\nDid you mean one of these?\n`;
|
|
308
|
+
for (const suggestion of suggestions) {
|
|
309
|
+
const confidence = Math.round(suggestion.confidence * 100);
|
|
310
|
+
message += `• ${suggestion.nodeType} (${confidence}% match)`;
|
|
311
|
+
if (suggestion.displayName) {
|
|
312
|
+
message += ` - ${suggestion.displayName}`;
|
|
313
|
+
}
|
|
314
|
+
message += `\n → ${suggestion.reason}`;
|
|
315
|
+
if (suggestion.confidence >= 0.9) {
|
|
316
|
+
message += ' (can be auto-fixed)';
|
|
317
|
+
}
|
|
318
|
+
message += '\n';
|
|
319
|
+
}
|
|
320
|
+
return message;
|
|
321
|
+
}
|
|
322
|
+
isAutoFixable(suggestion) {
|
|
323
|
+
return suggestion.confidence >= NodeSimilarityService.AUTO_FIX_CONFIDENCE;
|
|
324
|
+
}
|
|
325
|
+
clearCache() {
|
|
326
|
+
this.invalidateCache();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.NodeSimilarityService = NodeSimilarityService;
|
|
330
|
+
NodeSimilarityService.SCORING_THRESHOLD = 50;
|
|
331
|
+
NodeSimilarityService.TYPO_EDIT_DISTANCE = 2;
|
|
332
|
+
NodeSimilarityService.SHORT_SEARCH_LENGTH = 5;
|
|
333
|
+
NodeSimilarityService.CACHE_DURATION_MS = 5 * 60 * 1000;
|
|
334
|
+
NodeSimilarityService.AUTO_FIX_CONFIDENCE = 0.9;
|
|
335
|
+
//# sourceMappingURL=node-similarity-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-similarity-service.js","sourceRoot":"","sources":["../../src/services/node-similarity-service.ts"],"names":[],"mappings":";;;AACA,4CAAyC;AA0BzC,MAAa,qBAAqB;IAchC,YAAY,UA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AAO"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UniversalValidationResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
hasExpression: boolean;
|
|
4
|
+
needsPrefix: boolean;
|
|
5
|
+
isMixedContent: boolean;
|
|
6
|
+
confidence: 1.0;
|
|
7
|
+
suggestion?: string;
|
|
8
|
+
explanation: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class UniversalExpressionValidator {
|
|
11
|
+
private static readonly EXPRESSION_PATTERN;
|
|
12
|
+
private static readonly EXPRESSION_PREFIX;
|
|
13
|
+
static validateExpressionPrefix(value: any): UniversalValidationResult;
|
|
14
|
+
private static hasMixedContent;
|
|
15
|
+
static validateExpressionSyntax(value: string): UniversalValidationResult;
|
|
16
|
+
static validateCommonPatterns(value: string): UniversalValidationResult;
|
|
17
|
+
static validate(value: any): UniversalValidationResult[];
|
|
18
|
+
static getCorrectedValue(value: string): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=universal-expression-validator.d.ts.map
|