n8n-nodes-tnl-intelligence 0.1.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/README.md +20 -0
- package/dist/credentials/TnlApi.credentials.d.ts +22 -0
- package/dist/credentials/TnlApi.credentials.js +49 -0
- package/dist/credentials/TnlApi.credentials.js.map +1 -0
- package/dist/icons/tnl-bot-dark.svg +8 -0
- package/dist/icons/tnl-bot.svg +8 -0
- package/dist/nodes/TnlIntelligence/TnlIntelligence.node.d.ts +5 -0
- package/dist/nodes/TnlIntelligence/TnlIntelligence.node.js +217 -0
- package/dist/nodes/TnlIntelligence/TnlIntelligence.node.js.map +1 -0
- package/dist/nodes/TnlTrigger/TnlTrigger.node.d.ts +12 -0
- package/dist/nodes/TnlTrigger/TnlTrigger.node.js +139 -0
- package/dist/nodes/TnlTrigger/TnlTrigger.node.js.map +1 -0
- package/dist/nodes/shared/runtime.d.ts +39 -0
- package/dist/nodes/shared/runtime.js +390 -0
- package/dist/nodes/shared/runtime.js.map +1 -0
- package/dist/package.json +47 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# TNL Intelligence for n8n
|
|
2
|
+
|
|
3
|
+
The package provides a unified TNL action node and a signed instant trigger. It uses
|
|
4
|
+
`@theneuralledger/connectors` for normalized outputs, research tasks, webhook verification,
|
|
5
|
+
deduplication, and subscription lifecycle behavior.
|
|
6
|
+
|
|
7
|
+
Credentials stay in n8n's credential store. The one-time webhook verification secret is stored in
|
|
8
|
+
workflow static data and is never emitted as node output. Activation creates a remote subscription;
|
|
9
|
+
deactivation deletes it. Webhooks fail unless n8n exposes the exact raw request body.
|
|
10
|
+
|
|
11
|
+
Local validation:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm run build
|
|
15
|
+
npm run lint
|
|
16
|
+
npm test
|
|
17
|
+
npm pack --dry-run
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
TNL output is research, not investment advice. The node has no trade-execution operation.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class TnlApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
icon: "file:../icons/tnl-bot.svg";
|
|
6
|
+
documentationUrl: string;
|
|
7
|
+
properties: INodeProperties[];
|
|
8
|
+
authenticate: {
|
|
9
|
+
type: "generic";
|
|
10
|
+
properties: {
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
test: {
|
|
17
|
+
request: {
|
|
18
|
+
baseURL: string;
|
|
19
|
+
url: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TnlApi = void 0;
|
|
4
|
+
class TnlApi {
|
|
5
|
+
name = 'tnlApi';
|
|
6
|
+
displayName = 'TNL Intelligence API';
|
|
7
|
+
icon = 'file:../icons/tnl-bot.svg';
|
|
8
|
+
documentationUrl = 'https://github.com/bekirdag/tnl-intelligence';
|
|
9
|
+
properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Key',
|
|
12
|
+
name: 'apiKey',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
default: '',
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'API URL',
|
|
20
|
+
name: 'baseUrl',
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: 'https://theneuralledger.com',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Research URL',
|
|
27
|
+
name: 'researchUrl',
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: 'https://research.theneuralledger.com',
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Webhook Control URL',
|
|
34
|
+
name: 'webhookUrl',
|
|
35
|
+
type: 'string',
|
|
36
|
+
default: 'https://hooks.theneuralledger.com',
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
authenticate = {
|
|
41
|
+
type: 'generic',
|
|
42
|
+
properties: { headers: { Authorization: '=Bearer {{$credentials.apiKey}}' } },
|
|
43
|
+
};
|
|
44
|
+
test = {
|
|
45
|
+
request: { baseURL: '={{$credentials.baseUrl}}', url: '/v1/me' },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.TnlApi = TnlApi;
|
|
49
|
+
//# sourceMappingURL=TnlApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TnlApi.credentials.js","sourceRoot":"","sources":["../../credentials/TnlApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IACjB,IAAI,GAAG,QAAQ,CAAC;IAChB,WAAW,GAAG,sBAAsB,CAAC;IACrC,IAAI,GAAG,2BAAoC,CAAC;IAC5C,gBAAgB,GAAG,8CAA8C,CAAC;IAClE,UAAU,GAAsB;QAC9B;YACE,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC/B,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,IAAI;SACf;QACD;YACE,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,6BAA6B;YACtC,QAAQ,EAAE,IAAI;SACf;QACD;YACE,WAAW,EAAE,cAAc;YAC3B,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,sCAAsC;YAC/C,QAAQ,EAAE,IAAI;SACf;QACD;YACE,WAAW,EAAE,qBAAqB;YAClC,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,mCAAmC;YAC5C,QAAQ,EAAE,IAAI;SACf;KACF,CAAC;IACF,YAAY,GAAG;QACb,IAAI,EAAE,SAAkB;QACxB,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,iCAAiC,EAAE,EAAE;KAC9E,CAAC;IACF,IAAI,GAAG;QACL,OAAO,EAAE,EAAE,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,QAAQ,EAAE;KACjE,CAAC;CACH;AA3CD,wBA2CC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#f5f5f5" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M12 3v2"/><circle cx="12" cy="2" r="1" fill="#b5dfca" stroke="none"/>
|
|
4
|
+
<rect x="4" y="6" width="16" height="13" rx="3" fill="#b5dfca"/>
|
|
5
|
+
<path d="M8 19v3m8-3v3M4 11H2m20 0h-2"/>
|
|
6
|
+
<circle cx="9" cy="11" r="1" fill="#f5f5f5" stroke="none"/><circle cx="15" cy="11" r="1" fill="#f5f5f5" stroke="none"/>
|
|
7
|
+
<path d="M9 15h6"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#151515" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M12 3v2"/><circle cx="12" cy="2" r="1" fill="#f4b942" stroke="none"/>
|
|
4
|
+
<rect x="4" y="6" width="16" height="13" rx="3" fill="#f4b942"/>
|
|
5
|
+
<path d="M8 19v3m8-3v3M4 11H2m20 0h-2"/>
|
|
6
|
+
<circle cx="9" cy="11" r="1" fill="#151515" stroke="none"/><circle cx="15" cy="11" r="1" fill="#151515" stroke="none"/>
|
|
7
|
+
<path d="M9 15h6"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class TnlIntelligence implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TnlIntelligence = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const runtime_1 = require("../shared/runtime");
|
|
6
|
+
class TnlIntelligence {
|
|
7
|
+
description = {
|
|
8
|
+
displayName: 'TNL Intelligence',
|
|
9
|
+
name: 'tnlIntelligence',
|
|
10
|
+
icon: {
|
|
11
|
+
light: 'file:../../icons/tnl-bot.svg',
|
|
12
|
+
dark: 'file:../../icons/tnl-bot-dark.svg',
|
|
13
|
+
},
|
|
14
|
+
group: ['transform'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
17
|
+
description: 'Search, retrieve, enrich, and research TNL intelligence',
|
|
18
|
+
defaults: { name: 'TNL Intelligence' },
|
|
19
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
20
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
21
|
+
usableAsTool: true,
|
|
22
|
+
credentials: [{ name: 'tnlApi', required: true }],
|
|
23
|
+
properties: [
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Resource',
|
|
26
|
+
name: 'resource',
|
|
27
|
+
type: 'options',
|
|
28
|
+
noDataExpression: true,
|
|
29
|
+
options: [
|
|
30
|
+
{ name: 'Intelligence', value: 'intelligence' },
|
|
31
|
+
{ name: 'Research', value: 'research' },
|
|
32
|
+
],
|
|
33
|
+
default: 'intelligence',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Operation',
|
|
37
|
+
name: 'operation',
|
|
38
|
+
type: 'options',
|
|
39
|
+
noDataExpression: true,
|
|
40
|
+
options: [
|
|
41
|
+
{ name: 'Get Exposure', value: 'get_exposure', action: 'Get exposure' },
|
|
42
|
+
{ name: 'Get Intelligence', value: 'get_intelligence', action: 'Get intelligence' },
|
|
43
|
+
{ name: 'List Recent Changes', value: 'list_recent_changes', action: 'List recent changes' },
|
|
44
|
+
{ name: 'Search Intelligence', value: 'search_intelligence', action: 'Search intelligence' },
|
|
45
|
+
],
|
|
46
|
+
default: 'search_intelligence',
|
|
47
|
+
displayOptions: { show: { resource: ['intelligence'] } },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Operation',
|
|
51
|
+
name: 'operation',
|
|
52
|
+
type: 'options',
|
|
53
|
+
noDataExpression: true,
|
|
54
|
+
options: [
|
|
55
|
+
{ name: 'Get Research Result', value: 'get_research_result', action: 'Get research result' },
|
|
56
|
+
{ name: 'Get Weekly Edition', value: 'get_weekly_edition', action: 'Get weekly edition' },
|
|
57
|
+
{ name: 'Run Research', value: 'run_research', action: 'Run research' },
|
|
58
|
+
],
|
|
59
|
+
default: 'run_research',
|
|
60
|
+
displayOptions: { show: { resource: ['research'] } },
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
displayName: 'Query',
|
|
64
|
+
name: 'query',
|
|
65
|
+
type: 'string',
|
|
66
|
+
default: '',
|
|
67
|
+
displayOptions: { show: { operation: ['search_intelligence'] } },
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Identifier',
|
|
72
|
+
name: 'identifier',
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: '',
|
|
75
|
+
displayOptions: { show: { operation: ['get_intelligence', 'get_exposure'] } },
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
displayName: 'Exposure Kind',
|
|
80
|
+
name: 'exposureKind',
|
|
81
|
+
type: 'options',
|
|
82
|
+
options: [
|
|
83
|
+
{ name: 'Asset', value: 'asset' },
|
|
84
|
+
{ name: 'Entity', value: 'entity' },
|
|
85
|
+
{ name: 'Impact Path', value: 'impact_path' },
|
|
86
|
+
],
|
|
87
|
+
default: 'entity',
|
|
88
|
+
displayOptions: { show: { operation: ['get_exposure'] } },
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: 'Research Result ID',
|
|
92
|
+
name: 'resultId',
|
|
93
|
+
type: 'string',
|
|
94
|
+
default: '',
|
|
95
|
+
displayOptions: { show: { operation: ['get_research_result'] } },
|
|
96
|
+
required: true,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
displayName: 'Research Workflow',
|
|
100
|
+
name: 'workflowId',
|
|
101
|
+
type: 'options',
|
|
102
|
+
options: [
|
|
103
|
+
{ name: 'Asset Exposure', value: 'asset-exposure' },
|
|
104
|
+
{ name: 'Compare Sources', value: 'compare-sources' },
|
|
105
|
+
{ name: 'Operational Risk', value: 'operational-risk' },
|
|
106
|
+
{ name: 'Validate Event', value: 'validate-event' },
|
|
107
|
+
{ name: 'Weekly Consequential', value: 'weekly-consequential' },
|
|
108
|
+
{ name: 'What Changed', value: 'what-changed' },
|
|
109
|
+
],
|
|
110
|
+
default: 'what-changed',
|
|
111
|
+
displayOptions: { show: { operation: ['run_research'] } },
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Research Question',
|
|
115
|
+
name: 'question',
|
|
116
|
+
type: 'string',
|
|
117
|
+
typeOptions: { rows: 3 },
|
|
118
|
+
default: '',
|
|
119
|
+
displayOptions: { show: { operation: ['run_research'] } },
|
|
120
|
+
required: true,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
displayName: 'From (UTC)',
|
|
124
|
+
name: 'from',
|
|
125
|
+
type: 'dateTime',
|
|
126
|
+
default: '',
|
|
127
|
+
description: 'Inclusive published or research start time',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
displayName: 'To (UTC)',
|
|
131
|
+
name: 'to',
|
|
132
|
+
type: 'dateTime',
|
|
133
|
+
default: '',
|
|
134
|
+
description: 'Inclusive published or research end time',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
displayName: 'Page Size',
|
|
138
|
+
name: 'pageSize',
|
|
139
|
+
type: 'number',
|
|
140
|
+
typeOptions: { minValue: 1, maxValue: 100 },
|
|
141
|
+
default: 25,
|
|
142
|
+
displayOptions: { hide: { operation: ['get_intelligence', 'run_research', 'get_research_result', 'get_weekly_edition'] } },
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
async execute() {
|
|
147
|
+
const credentials = await this.getCredentials('tnlApi');
|
|
148
|
+
const output = [];
|
|
149
|
+
const input = this.getInputData();
|
|
150
|
+
for (let index = 0; index < Math.max(input.length, 1); index += 1) {
|
|
151
|
+
try {
|
|
152
|
+
const operation = this.getNodeParameter('operation', index);
|
|
153
|
+
const request = operationInput(this, operation, index);
|
|
154
|
+
const result = await (0, runtime_1.executeTnlOperation)(this, credentials, request);
|
|
155
|
+
output.push({ json: result, pairedItem: index });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (this.continueOnFail()) {
|
|
159
|
+
output.push({ json: { error: safeError(error) }, pairedItem: index });
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: index });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return [output];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.TnlIntelligence = TnlIntelligence;
|
|
169
|
+
function operationInput(context, operation, index) {
|
|
170
|
+
const from = optional(context.getNodeParameter('from', index, ''));
|
|
171
|
+
const to = optional(context.getNodeParameter('to', index, ''));
|
|
172
|
+
const pageSize = context.getNodeParameter('pageSize', index, 25);
|
|
173
|
+
const range = { ...(from ? { from } : {}), ...(to ? { to } : {}) };
|
|
174
|
+
switch (operation) {
|
|
175
|
+
case 'search_intelligence':
|
|
176
|
+
return { operation, input: { query: context.getNodeParameter('query', index), pageSize, ...range } };
|
|
177
|
+
case 'get_intelligence':
|
|
178
|
+
return { operation, input: { id: context.getNodeParameter('identifier', index) } };
|
|
179
|
+
case 'list_recent_changes':
|
|
180
|
+
return { operation, input: { since: from ?? new Date(Date.now() - 86_400_000).toISOString(), pageSize } };
|
|
181
|
+
case 'get_exposure':
|
|
182
|
+
return {
|
|
183
|
+
operation,
|
|
184
|
+
input: {
|
|
185
|
+
kind: context.getNodeParameter('exposureKind', index),
|
|
186
|
+
value: context.getNodeParameter('identifier', index),
|
|
187
|
+
pageSize,
|
|
188
|
+
...range,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
case 'run_research':
|
|
192
|
+
return {
|
|
193
|
+
operation,
|
|
194
|
+
input: {
|
|
195
|
+
workflowId: context.getNodeParameter('workflowId', index),
|
|
196
|
+
question: context.getNodeParameter('question', index),
|
|
197
|
+
...range,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
case 'get_research_result':
|
|
201
|
+
return {
|
|
202
|
+
operation,
|
|
203
|
+
input: { resultId: context.getNodeParameter('resultId', index) },
|
|
204
|
+
};
|
|
205
|
+
case 'get_weekly_edition':
|
|
206
|
+
return { operation, input: { ...(to ? { weekEnding: to } : {}) } };
|
|
207
|
+
default:
|
|
208
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Unsupported TNL operation');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function optional(value) {
|
|
212
|
+
return value.trim() || undefined;
|
|
213
|
+
}
|
|
214
|
+
function safeError(error) {
|
|
215
|
+
return error instanceof Error ? error.message.slice(0, 300) : 'TNL connector failed';
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=TnlIntelligence.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TnlIntelligence.node.js","sourceRoot":"","sources":["../../../nodes/TnlIntelligence/TnlIntelligence.node.ts"],"names":[],"mappings":";;;AAOA,+CAAuE;AACvE,+CAG2B;AAE3B,MAAa,eAAe;IAC1B,WAAW,GAAyB;QAClC,WAAW,EAAE,kBAAkB;QAC/B,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE;YACJ,KAAK,EAAE,8BAA8B;YACrC,IAAI,EAAE,mCAAmC;SAC1C;QACD,KAAK,EAAE,CAAC,WAAW,CAAC;QACpB,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,8BAA8B;QACxC,WAAW,EAAE,yDAAyD;QACtE,QAAQ,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;QACtC,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;QACnC,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACjD,UAAU,EAAE;YACV;gBACE,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;gBACf,gBAAgB,EAAE,IAAI;gBACtB,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE;oBAC/C,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;iBACxC;gBACD,OAAO,EAAE,cAAc;aACxB;YACD;gBACE,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,WAAW;gBACjB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AgB,CAAC,YAAY,EAAE,KAAK,CAAW;oBAC9D,QAAQ;oBACR,GAAG,KAAK;iBACT;aACO,CAAC;QACb,KAAK,cAAc;YACjB,OAAO;gBACL,SAAS;gBACT,KAAK,EAAE;oBACL,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAK,CAAW;oBACnE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAW;oBAC/D,GAAG,KAAK;iBACT;aACO,CAAC;QACb,KAAK,qBAAqB;YACxB,OAAO;gBACL,SAAS;gBACT,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAW,EAAE;aAClE,CAAC;QACb,KAAK,oBAAoB;YACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAW,CAAC;QAC9E;YACE,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,2BAA2B,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
+
export declare class TnlTrigger implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
webhookMethods: {
|
|
5
|
+
default: {
|
|
6
|
+
checkExists: (this: IHookFunctions) => Promise<boolean>;
|
|
7
|
+
create: (this: IHookFunctions) => Promise<boolean>;
|
|
8
|
+
delete: (this: IHookFunctions) => Promise<boolean>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TnlTrigger = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const runtime_1 = require("../shared/runtime");
|
|
6
|
+
class TnlTrigger {
|
|
7
|
+
description = {
|
|
8
|
+
displayName: 'TNL Trigger',
|
|
9
|
+
name: 'tnlTrigger',
|
|
10
|
+
icon: {
|
|
11
|
+
light: 'file:../../icons/tnl-bot.svg',
|
|
12
|
+
dark: 'file:../../icons/tnl-bot-dark.svg',
|
|
13
|
+
},
|
|
14
|
+
group: ['trigger'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["eventTypes"].join(", ")}}',
|
|
17
|
+
description: 'Receive signed new, revised, retracted, impact, and weekly TNL events',
|
|
18
|
+
defaults: { name: 'TNL Trigger' },
|
|
19
|
+
inputs: [],
|
|
20
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
21
|
+
usableAsTool: true,
|
|
22
|
+
credentials: [{ name: 'tnlApi', required: true }],
|
|
23
|
+
webhooks: [
|
|
24
|
+
{
|
|
25
|
+
name: 'default',
|
|
26
|
+
httpMethod: 'POST',
|
|
27
|
+
responseMode: 'onReceived',
|
|
28
|
+
path: 'tnl-intelligence',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
properties: [
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Event Types',
|
|
34
|
+
name: 'eventTypes',
|
|
35
|
+
type: 'multiOptions',
|
|
36
|
+
options: [
|
|
37
|
+
{ name: 'Impact Classification Changed', value: 'intelligence.impact_changed' },
|
|
38
|
+
{ name: 'Intelligence Published', value: 'intelligence.published' },
|
|
39
|
+
{ name: 'Intelligence Retracted', value: 'intelligence.retracted' },
|
|
40
|
+
{ name: 'Intelligence Updated', value: 'intelligence.updated' },
|
|
41
|
+
{ name: 'Weekly Edition Published', value: 'digest.weekly_published' },
|
|
42
|
+
],
|
|
43
|
+
default: ['intelligence.published', 'intelligence.updated'],
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: 'Categories',
|
|
48
|
+
name: 'categories',
|
|
49
|
+
type: 'string',
|
|
50
|
+
default: '',
|
|
51
|
+
description: 'Optional comma-separated exact category filters',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
displayName: 'Minimum Confidence',
|
|
55
|
+
name: 'minimumConfidence',
|
|
56
|
+
type: 'number',
|
|
57
|
+
typeOptions: { minValue: 0, maxValue: 1, numberPrecision: 2 },
|
|
58
|
+
default: 0,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
webhookMethods = {
|
|
63
|
+
default: {
|
|
64
|
+
checkExists: async function () {
|
|
65
|
+
return Boolean(state(this).subscriptionId);
|
|
66
|
+
},
|
|
67
|
+
create: async function () {
|
|
68
|
+
const credentials = await this.getCredentials('tnlApi');
|
|
69
|
+
const endpoint = this.getNodeWebhookUrl('default');
|
|
70
|
+
if (!endpoint)
|
|
71
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Webhook URL is unavailable');
|
|
72
|
+
const categories = comma(this.getNodeParameter('categories'));
|
|
73
|
+
const minimumConfidence = this.getNodeParameter('minimumConfidence');
|
|
74
|
+
const subscription = await (0, runtime_1.createTnlSubscription)(this, credentials, {
|
|
75
|
+
endpoint,
|
|
76
|
+
eventTypes: this.getNodeParameter('eventTypes'),
|
|
77
|
+
filters: {
|
|
78
|
+
...(categories.length ? { categories } : {}),
|
|
79
|
+
...(minimumConfidence > 0 ? { minimumConfidence } : {}),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
Object.assign(state(this), {
|
|
83
|
+
subscriptionId: subscription.id,
|
|
84
|
+
webhookSecret: subscription.secret,
|
|
85
|
+
webhookKeyId: subscription.keyId,
|
|
86
|
+
deliveries: [],
|
|
87
|
+
events: [],
|
|
88
|
+
});
|
|
89
|
+
return true;
|
|
90
|
+
},
|
|
91
|
+
delete: async function () {
|
|
92
|
+
const data = state(this);
|
|
93
|
+
if (!data.subscriptionId)
|
|
94
|
+
return true;
|
|
95
|
+
const credentials = await this.getCredentials('tnlApi');
|
|
96
|
+
await (0, runtime_1.deleteTnlSubscription)(this, credentials, data.subscriptionId);
|
|
97
|
+
for (const key of ['subscriptionId', 'webhookSecret', 'webhookKeyId', 'deliveries', 'events'])
|
|
98
|
+
delete data[key];
|
|
99
|
+
return true;
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
async webhook() {
|
|
104
|
+
const data = state(this);
|
|
105
|
+
if (!data.webhookSecret || !data.webhookKeyId)
|
|
106
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'TNL webhook is not activated');
|
|
107
|
+
const request = this.getRequestObject();
|
|
108
|
+
if (!request.rawBody)
|
|
109
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'TNL webhook requires exact raw request bytes');
|
|
110
|
+
const result = await (0, runtime_1.processTnlWebhook)({
|
|
111
|
+
rawBody: request.rawBody,
|
|
112
|
+
headers: request.headers,
|
|
113
|
+
secret: data.webhookSecret,
|
|
114
|
+
keyId: data.webhookKeyId,
|
|
115
|
+
replayStore: listStore(data, 'deliveries'),
|
|
116
|
+
eventDedupeStore: listStore(data, 'events'),
|
|
117
|
+
});
|
|
118
|
+
return { workflowData: [this.helpers.returnJsonArray([result])] };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.TnlTrigger = TnlTrigger;
|
|
122
|
+
function state(context) {
|
|
123
|
+
return context.getWorkflowStaticData('node');
|
|
124
|
+
}
|
|
125
|
+
function listStore(data, field) {
|
|
126
|
+
return {
|
|
127
|
+
claim(id) {
|
|
128
|
+
const values = data[field] ?? [];
|
|
129
|
+
if (values.includes(id))
|
|
130
|
+
return false;
|
|
131
|
+
data[field] = [...values, id].slice(-5_000);
|
|
132
|
+
return true;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function comma(value) {
|
|
137
|
+
return [...new Set(value.split(',').map((item) => item.trim()).filter(Boolean))];
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=TnlTrigger.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TnlTrigger.node.js","sourceRoot":"","sources":["../../../nodes/TnlTrigger/TnlTrigger.node.ts"],"names":[],"mappings":";;;AAQA,+CAAuE;AACvE,+CAK2B;AAU3B,MAAa,UAAU;IACrB,WAAW,GAAyB;QAClC,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,KAAK,EAAE,8BAA8B;YACrC,IAAI,EAAE,mCAAmC;SAC1C;QACD,KAAK,EAAE,CAAC,SAAS,CAAC;QAClB,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,0CAA0C;QACpD,WAAW,EAAE,uEAAuE;QACpF,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;QACjC,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;QACnC,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACjD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,MAAM;gBAClB,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE,kBAAkB;a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B,EAAE,KAA8B;IACnE,OAAO;QACL,KAAK,CAAC,EAAU;YACd,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACjC,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAAE,OAAO,KAAK,CAAC;YACtC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ICredentialDataDecryptedObject, IExecuteFunctions, IHookFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare const TNL_WEBHOOK_EVENT_TYPES: readonly ["intelligence.published", "intelligence.updated", "intelligence.retracted", "intelligence.impact_changed", "digest.weekly_published"];
|
|
3
|
+
export type TnlWebhookEventType = (typeof TNL_WEBHOOK_EVENT_TYPES)[number];
|
|
4
|
+
export type TnlOperation = 'search_intelligence' | 'get_intelligence' | 'list_recent_changes' | 'get_exposure' | 'run_research' | 'get_research_result' | 'get_weekly_edition';
|
|
5
|
+
export interface TnlOperationRequest {
|
|
6
|
+
operation: TnlOperation;
|
|
7
|
+
input: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
interface SubscriptionInput {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
eventTypes: TnlWebhookEventType[];
|
|
12
|
+
filters?: {
|
|
13
|
+
categories?: string[];
|
|
14
|
+
minimumConfidence?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface SubscriptionResult {
|
|
18
|
+
id: string;
|
|
19
|
+
secret: string;
|
|
20
|
+
keyId: string;
|
|
21
|
+
state: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function executeTnlOperation(context: IExecuteFunctions, credentials: ICredentialDataDecryptedObject, request: TnlOperationRequest): Promise<Record<string, unknown>>;
|
|
24
|
+
export declare function createTnlSubscription(context: IHookFunctions, credentials: ICredentialDataDecryptedObject, input: SubscriptionInput): Promise<SubscriptionResult>;
|
|
25
|
+
export declare function deleteTnlSubscription(context: IHookFunctions, credentials: ICredentialDataDecryptedObject, subscriptionId: string): Promise<void>;
|
|
26
|
+
export declare function processTnlWebhook(options: {
|
|
27
|
+
rawBody: Buffer;
|
|
28
|
+
headers: Record<string, string | string[] | undefined>;
|
|
29
|
+
secret: string;
|
|
30
|
+
keyId: string;
|
|
31
|
+
replayStore: {
|
|
32
|
+
claim(id: string, expiresAt: number): boolean | Promise<boolean>;
|
|
33
|
+
};
|
|
34
|
+
eventDedupeStore: {
|
|
35
|
+
claim(id: string, expiresAt: number): boolean | Promise<boolean>;
|
|
36
|
+
};
|
|
37
|
+
now?: number;
|
|
38
|
+
}): Promise<Record<string, unknown>>;
|
|
39
|
+
export {};
|