@circus_sh/n8n-nodes-circus 1.3.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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/credentials/CircusAnthropicApi.credentials.d.ts +24 -0
- package/dist/credentials/CircusAnthropicApi.credentials.js +43 -0
- package/dist/credentials/CircusAnthropicApi.credentials.js.map +1 -0
- package/dist/credentials/CircusApi.credentials.d.ts +13 -0
- package/dist/credentials/CircusApi.credentials.js +50 -0
- package/dist/credentials/CircusApi.credentials.js.map +1 -0
- package/dist/credentials/CircusGoogleApi.credentials.d.ts +18 -0
- package/dist/credentials/CircusGoogleApi.credentials.js +33 -0
- package/dist/credentials/CircusGoogleApi.credentials.js.map +1 -0
- package/dist/credentials/CircusOpenaiApi.credentials.d.ts +21 -0
- package/dist/credentials/CircusOpenaiApi.credentials.js +36 -0
- package/dist/credentials/CircusOpenaiApi.credentials.js.map +1 -0
- package/dist/credentials/CircusXaiApi.credentials.d.ts +21 -0
- package/dist/credentials/CircusXaiApi.credentials.js +36 -0
- package/dist/credentials/CircusXaiApi.credentials.js.map +1 -0
- package/dist/credentials/icons/circus.dark.svg +5 -0
- package/dist/credentials/icons/circus.svg +5 -0
- package/dist/nodes/CircusAgent/CircusAgent.node.d.ts +5 -0
- package/dist/nodes/CircusAgent/CircusAgent.node.js +455 -0
- package/dist/nodes/CircusAgent/CircusAgent.node.js.map +1 -0
- package/dist/nodes/CircusAgent/CircusAgent.node.json +18 -0
- package/dist/nodes/CircusAgent/circusAgent.dark.svg +5 -0
- package/dist/nodes/CircusAgent/circusAgent.svg +5 -0
- package/dist/nodes/CircusComplete/CircusComplete.node.d.ts +5 -0
- package/dist/nodes/CircusComplete/CircusComplete.node.js +128 -0
- package/dist/nodes/CircusComplete/CircusComplete.node.js.map +1 -0
- package/dist/nodes/CircusComplete/CircusComplete.node.json +18 -0
- package/dist/nodes/CircusComplete/circusComplete.dark.svg +5 -0
- package/dist/nodes/CircusComplete/circusComplete.svg +5 -0
- package/dist/nodes/CircusInit/CircusInit.node.d.ts +5 -0
- package/dist/nodes/CircusInit/CircusInit.node.js +74 -0
- package/dist/nodes/CircusInit/CircusInit.node.js.map +1 -0
- package/dist/nodes/CircusInit/CircusInit.node.json +18 -0
- package/dist/nodes/CircusInit/circusInit.dark.svg +4 -0
- package/dist/nodes/CircusInit/circusInit.svg +4 -0
- package/dist/nodes/CircusLog/CircusLog.node.d.ts +5 -0
- package/dist/nodes/CircusLog/CircusLog.node.js +244 -0
- package/dist/nodes/CircusLog/CircusLog.node.js.map +1 -0
- package/dist/nodes/CircusLog/CircusLog.node.json +18 -0
- package/dist/nodes/CircusLog/circusLog.dark.svg +8 -0
- package/dist/nodes/CircusLog/circusLog.svg +8 -0
- package/dist/nodes/CircusTerminate/CircusTerminate.node.d.ts +5 -0
- package/dist/nodes/CircusTerminate/CircusTerminate.node.js +104 -0
- package/dist/nodes/CircusTerminate/CircusTerminate.node.js.map +1 -0
- package/dist/nodes/CircusTerminate/CircusTerminate.node.json +18 -0
- package/dist/nodes/CircusTerminate/circusTerminate.dark.svg +6 -0
- package/dist/nodes/CircusTerminate/circusTerminate.svg +6 -0
- package/dist/nodes/shared/circusContext.d.ts +10 -0
- package/dist/nodes/shared/circusContext.js +24 -0
- package/dist/nodes/shared/circusContext.js.map +1 -0
- package/dist/package.json +62 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-circus.circusComplete",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Development", "Developer Tools"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://circus.sh/docs/n8n-nodes#credentials"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://circus.sh/docs/n8n-nodes#complete"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#66dd88"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
|
4
|
+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#33aa55"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
|
4
|
+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class CircusInit implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CircusInit = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
class CircusInit {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Circus Init',
|
|
9
|
+
name: 'circusInit',
|
|
10
|
+
icon: { light: 'file:circusInit.svg', dark: 'file:circusInit.dark.svg' },
|
|
11
|
+
group: ['input'],
|
|
12
|
+
version: 1,
|
|
13
|
+
subtitle: 'Initialize Circus execution context',
|
|
14
|
+
description: 'Store the Circus webhook payload in execution data so all downstream Circus nodes can access it',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Circus Init',
|
|
17
|
+
},
|
|
18
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
19
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
20
|
+
usableAsTool: true,
|
|
21
|
+
properties: [],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async execute() {
|
|
25
|
+
const items = this.getInputData();
|
|
26
|
+
const returnData = [];
|
|
27
|
+
for (let i = 0; i < items.length; i++) {
|
|
28
|
+
try {
|
|
29
|
+
const body = items[i].json.body;
|
|
30
|
+
if (!body) {
|
|
31
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No webhook payload found. Place this node directly after a Webhook trigger node.', { itemIndex: i });
|
|
32
|
+
}
|
|
33
|
+
const workflowExecutionId = body.workflow_execution_id;
|
|
34
|
+
if (!workflowExecutionId) {
|
|
35
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Missing workflow_execution_id in webhook payload', { itemIndex: i });
|
|
36
|
+
}
|
|
37
|
+
this.customData.set('circus_init_node', this.getNode().name);
|
|
38
|
+
this.customData.set('circus_workflow_execution_id', workflowExecutionId);
|
|
39
|
+
this.customData.set('circus_external_execution_id', this.getExecutionId());
|
|
40
|
+
const verifyName = this.customData.get('circus_init_node');
|
|
41
|
+
const verifyId = this.customData.get('circus_workflow_execution_id');
|
|
42
|
+
returnData.push({
|
|
43
|
+
json: {
|
|
44
|
+
...items[i].json,
|
|
45
|
+
_circusInit: {
|
|
46
|
+
storedNodeName: verifyName,
|
|
47
|
+
storedExecutionId: verifyId,
|
|
48
|
+
allKeys: Object.keys(this.customData.getAll()),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
pairedItem: { item: i },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
if (this.continueOnFail()) {
|
|
59
|
+
returnData.push({
|
|
60
|
+
json: { error: error.message },
|
|
61
|
+
pairedItem: { item: i },
|
|
62
|
+
});
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
66
|
+
itemIndex: i,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [returnData];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.CircusInit = CircusInit;
|
|
74
|
+
//# sourceMappingURL=CircusInit.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircusInit.node.js","sourceRoot":"","sources":["../../../nodes/CircusInit/CircusInit.node.ts"],"names":[],"mappings":";;;AAMA,+CAAuE;AAEvE,MAAa,UAAU;IAAvB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,0BAA0B,EAAE;YACxE,KAAK,EAAE,CAAC,OAAO,CAAC;YAChB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,qCAAqC;YAC/C,WAAW,EACV,iGAAiG;YAClG,QAAQ,EAAE;gBACT,IAAI,EAAE,aAAa;aACnB;YACD,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,EAAE;SACd,CAAC;IAoEH,CAAC;IAlEA,KAAK,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,UAAU,GAAy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;4BAC3B,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;yBAC9C;qBACD;oBACD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBACvB,CAAC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,KAAK,YAAY,iCAAkB,EAAE,CAAC;oBAEzC,MAAM,KAAK,CAAC;gBACb,CAAC;gBACD,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,UAAU,CAAC,IAAI,CAAC;wBACf,IAAI,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE;wBACzC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACvB,CAAC,CAAC;oBACH,SAAS;gBACV,CAAC;gBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE;oBAC5D,SAAS,EAAE,CAAC;iBACZ,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AArFD,gCAqFC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-circus.circusInit",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Development", "Developer Tools"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://circus.sh/docs/n8n-nodes#credentials"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://circus.sh/docs/n8n-nodes#init"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class CircusLog implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CircusLog = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const circusContext_1 = require("../shared/circusContext");
|
|
7
|
+
class CircusLog {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = {
|
|
10
|
+
displayName: 'Circus Log',
|
|
11
|
+
name: 'circusLog',
|
|
12
|
+
icon: { light: 'file:circusLog.svg', dark: 'file:circusLog.dark.svg' },
|
|
13
|
+
group: ['output'],
|
|
14
|
+
version: 1,
|
|
15
|
+
subtitle: '={{$parameter["workerType"] + " / " + $parameter["status"]}}',
|
|
16
|
+
description: 'Create a log entry on the Circus platform and check cost/time thresholds',
|
|
17
|
+
defaults: {
|
|
18
|
+
name: 'Circus Log',
|
|
19
|
+
},
|
|
20
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
21
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
usableAsTool: true,
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'circusApi',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
properties: [
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Node Name',
|
|
32
|
+
name: 'nodeName',
|
|
33
|
+
type: 'string',
|
|
34
|
+
required: true,
|
|
35
|
+
default: '',
|
|
36
|
+
description: 'Name of the workflow step being logged',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Worker Type',
|
|
40
|
+
name: 'workerType',
|
|
41
|
+
type: 'options',
|
|
42
|
+
required: true,
|
|
43
|
+
options: [
|
|
44
|
+
{ name: 'Internal', value: 'internal' },
|
|
45
|
+
{ name: 'Service', value: 'service' },
|
|
46
|
+
],
|
|
47
|
+
default: 'internal',
|
|
48
|
+
description: 'Type of worker. Agent is not available — Agent nodes handle their own logging.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Worker Slug',
|
|
52
|
+
name: 'workerSlug',
|
|
53
|
+
type: 'string',
|
|
54
|
+
required: true,
|
|
55
|
+
default: '',
|
|
56
|
+
description: 'Slug identifying the service for cost lookup (when worker type is service). For internal, use a descriptive slug.',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Status',
|
|
60
|
+
name: 'status',
|
|
61
|
+
type: 'options',
|
|
62
|
+
required: true,
|
|
63
|
+
options: [
|
|
64
|
+
{ name: 'Error', value: 'error' },
|
|
65
|
+
{ name: 'Success', value: 'success' },
|
|
66
|
+
],
|
|
67
|
+
default: 'success',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Duration (Seconds)',
|
|
71
|
+
name: 'durationSeconds',
|
|
72
|
+
type: 'number',
|
|
73
|
+
default: 0,
|
|
74
|
+
description: 'Step execution time in seconds',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'Input Size',
|
|
78
|
+
name: 'inputSize',
|
|
79
|
+
type: 'number',
|
|
80
|
+
default: 0,
|
|
81
|
+
description: 'Consumption input (service-defined units for services, 0 for internal)',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
displayName: 'Output Size',
|
|
85
|
+
name: 'outputSize',
|
|
86
|
+
type: 'number',
|
|
87
|
+
default: 0,
|
|
88
|
+
description: 'Consumption output (service-defined units for services, 0 for internal)',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: 'Error Message',
|
|
92
|
+
name: 'errorMessage',
|
|
93
|
+
type: 'string',
|
|
94
|
+
default: '',
|
|
95
|
+
description: 'Error description (for failed steps)',
|
|
96
|
+
displayOptions: {
|
|
97
|
+
show: {
|
|
98
|
+
status: ['error'],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
displayName: 'Request Payload',
|
|
104
|
+
name: 'requestPayload',
|
|
105
|
+
type: 'json',
|
|
106
|
+
default: '',
|
|
107
|
+
description: 'Request data to store',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
displayName: 'Response Payload',
|
|
111
|
+
name: 'responsePayload',
|
|
112
|
+
type: 'json',
|
|
113
|
+
default: '',
|
|
114
|
+
description: 'Response data to store',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async execute() {
|
|
120
|
+
const items = this.getInputData();
|
|
121
|
+
const returnData = [];
|
|
122
|
+
for (let i = 0; i < items.length; i++) {
|
|
123
|
+
try {
|
|
124
|
+
const nodeName = this.getNodeParameter('nodeName', i);
|
|
125
|
+
const workerType = this.getNodeParameter('workerType', i);
|
|
126
|
+
const workerSlug = this.getNodeParameter('workerSlug', i);
|
|
127
|
+
const status = this.getNodeParameter('status', i);
|
|
128
|
+
const durationSeconds = this.getNodeParameter('durationSeconds', i, 0);
|
|
129
|
+
const inputSize = Number(this.getNodeParameter('inputSize', i, 0)) || 0;
|
|
130
|
+
const outputSize = Number(this.getNodeParameter('outputSize', i, 0)) || 0;
|
|
131
|
+
const errorMessage = status === 'error'
|
|
132
|
+
? this.getNodeParameter('errorMessage', i, '')
|
|
133
|
+
: undefined;
|
|
134
|
+
const requestPayloadRaw = this.getNodeParameter('requestPayload', i, '');
|
|
135
|
+
const responsePayloadRaw = this.getNodeParameter('responsePayload', i, '');
|
|
136
|
+
const requestPayload = requestPayloadRaw
|
|
137
|
+
? JSON.parse(requestPayloadRaw)
|
|
138
|
+
: undefined;
|
|
139
|
+
const responsePayload = responsePayloadRaw
|
|
140
|
+
? JSON.parse(responsePayloadRaw)
|
|
141
|
+
: undefined;
|
|
142
|
+
const circus = await (0, circusContext_1.getCircusContext)(this);
|
|
143
|
+
const idempotencyKey = (0, node_crypto_1.randomUUID)();
|
|
144
|
+
const body = {
|
|
145
|
+
idempotency_key: idempotencyKey,
|
|
146
|
+
node_name: nodeName,
|
|
147
|
+
worker_type: workerType,
|
|
148
|
+
worker_slug: workerSlug,
|
|
149
|
+
status,
|
|
150
|
+
external_execution_id: circus.externalExecutionId,
|
|
151
|
+
};
|
|
152
|
+
if (durationSeconds)
|
|
153
|
+
body.duration_seconds = durationSeconds;
|
|
154
|
+
if (inputSize)
|
|
155
|
+
body.input_size = inputSize;
|
|
156
|
+
if (outputSize)
|
|
157
|
+
body.output_size = outputSize;
|
|
158
|
+
if (errorMessage)
|
|
159
|
+
body.error_message = errorMessage;
|
|
160
|
+
if (requestPayload)
|
|
161
|
+
body.request_payload = requestPayload;
|
|
162
|
+
if (responsePayload)
|
|
163
|
+
body.response_payload = responsePayload;
|
|
164
|
+
let responseData;
|
|
165
|
+
try {
|
|
166
|
+
const response = (await this.helpers.httpRequestWithAuthentication.call(this, 'circusApi', {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
url: `${circus.baseUrl}/logs`,
|
|
169
|
+
body,
|
|
170
|
+
json: true,
|
|
171
|
+
}));
|
|
172
|
+
responseData = response.data;
|
|
173
|
+
}
|
|
174
|
+
catch (logError) {
|
|
175
|
+
const continueOnFail = this.continueOnFail();
|
|
176
|
+
const retryOnFail = this.getNode().retryOnFail;
|
|
177
|
+
if (!continueOnFail && retryOnFail) {
|
|
178
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), logError, { message: `${logError.message}`, itemIndex: i });
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'circusApi', {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
url: `${circus.baseUrl}/terminate`,
|
|
184
|
+
body: {
|
|
185
|
+
reason: `Log endpoint failed: ${logError.message}`,
|
|
186
|
+
external_execution_id: circus.externalExecutionId,
|
|
187
|
+
},
|
|
188
|
+
json: true,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
}
|
|
193
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), logError, { message: `Log endpoint failed: ${logError.message}`, itemIndex: i });
|
|
194
|
+
}
|
|
195
|
+
if (responseData.abort) {
|
|
196
|
+
const reason = 'Execution aborted: cost or time threshold exceeded';
|
|
197
|
+
try {
|
|
198
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'circusApi', {
|
|
199
|
+
method: 'POST',
|
|
200
|
+
url: `${circus.baseUrl}/terminate`,
|
|
201
|
+
body: {
|
|
202
|
+
reason,
|
|
203
|
+
external_execution_id: circus.externalExecutionId,
|
|
204
|
+
},
|
|
205
|
+
json: true,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
}
|
|
210
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), reason, {
|
|
211
|
+
itemIndex: i,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
returnData.push({
|
|
215
|
+
json: {
|
|
216
|
+
logged: true,
|
|
217
|
+
cost_consumed: responseData.cost_consumed,
|
|
218
|
+
time_consumed: responseData.time_consumed,
|
|
219
|
+
abort: false,
|
|
220
|
+
},
|
|
221
|
+
pairedItem: { item: i },
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
if (error instanceof n8n_workflow_1.NodeApiError || error instanceof n8n_workflow_1.NodeOperationError) {
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
if (this.continueOnFail()) {
|
|
229
|
+
returnData.push({
|
|
230
|
+
json: { error: error.message },
|
|
231
|
+
pairedItem: { item: i },
|
|
232
|
+
});
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
236
|
+
itemIndex: i,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return [returnData];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.CircusLog = CircusLog;
|
|
244
|
+
//# sourceMappingURL=CircusLog.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircusLog.node.js","sourceRoot":"","sources":["../../../nodes/CircusLog/CircusLog.node.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAQzC,+CAAqF;AACrF,2DAA2D;AAE3D,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,yBAAyB,EAAE;YACtE,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,0EAA0E;YACvF,QAAQ,EAAE;gBACT,IAAI,EAAE,YAAY;aAClB;YACD,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,WAAW;oBACjB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,UAAU,EAAE;gBACX;oBACC,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,wCAAwC;iBACrD;gBACD;oBACC,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,IAAI;oBACd,OAAO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IAAI,CAAC;wBACf,IAAI,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE;wBACzC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACvB,CAAC,CAAC;oBACH,SAAS;gBACV,CAAC;gBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE;oBAC5D,SAAS,EAAE,CAAC;iBACZ,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AA5SD,8BA4SC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-circus.circusLog",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Development", "Developer Tools"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://circus.sh/docs/n8n-nodes#credentials"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://circus.sh/docs/n8n-nodes#log"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#7ab8ff"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
|
4
|
+
<polyline points="14 2 14 8 20 8"></polyline>
|
|
5
|
+
<line x1="16" y1="13" x2="8" y2="13"></line>
|
|
6
|
+
<line x1="16" y1="17" x2="8" y2="17"></line>
|
|
7
|
+
<polyline points="10 9 9 9 8 9"></polyline>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#4a90d9"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
|
4
|
+
<polyline points="14 2 14 8 20 8"></polyline>
|
|
5
|
+
<line x1="16" y1="13" x2="8" y2="13"></line>
|
|
6
|
+
<line x1="16" y1="17" x2="8" y2="17"></line>
|
|
7
|
+
<polyline points="10 9 9 9 8 9"></polyline>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class CircusTerminate implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CircusTerminate = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const circusContext_1 = require("../shared/circusContext");
|
|
7
|
+
class CircusTerminate {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = {
|
|
10
|
+
displayName: 'Circus Terminate',
|
|
11
|
+
name: 'circusTerminate',
|
|
12
|
+
icon: { light: 'file:circusTerminate.svg', dark: 'file:circusTerminate.dark.svg' },
|
|
13
|
+
group: ['output'],
|
|
14
|
+
version: 1,
|
|
15
|
+
subtitle: 'Terminate workflow execution',
|
|
16
|
+
description: 'Terminate a workflow execution on the Circus platform',
|
|
17
|
+
defaults: {
|
|
18
|
+
name: 'Circus Terminate',
|
|
19
|
+
},
|
|
20
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
21
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
usableAsTool: true,
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'circusApi',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
properties: [
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Termination Reason',
|
|
32
|
+
name: 'reason',
|
|
33
|
+
type: 'string',
|
|
34
|
+
default: '',
|
|
35
|
+
description: 'Reason for terminating the execution. Supports static text or dynamic expressions.',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async execute() {
|
|
41
|
+
const items = this.getInputData();
|
|
42
|
+
const returnData = [];
|
|
43
|
+
for (let i = 0; i < items.length; i++) {
|
|
44
|
+
try {
|
|
45
|
+
const reason = this.getNodeParameter('reason', i, '');
|
|
46
|
+
const circus = await (0, circusContext_1.getCircusContext)(this);
|
|
47
|
+
try {
|
|
48
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'circusApi', {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
url: `${circus.baseUrl}/terminate`,
|
|
51
|
+
body: { reason, external_execution_id: circus.externalExecutionId },
|
|
52
|
+
json: true,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
try {
|
|
57
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'circusApi', {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
url: `${circus.baseUrl}/logs`,
|
|
60
|
+
body: {
|
|
61
|
+
idempotency_key: (0, node_crypto_1.randomUUID)(),
|
|
62
|
+
external_execution_id: circus.externalExecutionId,
|
|
63
|
+
node_name: 'circus-terminate',
|
|
64
|
+
worker_type: 'internal',
|
|
65
|
+
worker_slug: 'system',
|
|
66
|
+
status: 'error',
|
|
67
|
+
error_message: `Terminate endpoint failed: ${error.message}`,
|
|
68
|
+
},
|
|
69
|
+
json: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
}
|
|
74
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { message: `Terminate endpoint failed: ${error.message}`, itemIndex: i });
|
|
75
|
+
}
|
|
76
|
+
returnData.push({
|
|
77
|
+
json: {
|
|
78
|
+
terminated: true,
|
|
79
|
+
reason,
|
|
80
|
+
},
|
|
81
|
+
pairedItem: { item: i },
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof n8n_workflow_1.NodeApiError || error instanceof n8n_workflow_1.NodeOperationError) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
if (this.continueOnFail()) {
|
|
89
|
+
returnData.push({
|
|
90
|
+
json: { error: error.message },
|
|
91
|
+
pairedItem: { item: i },
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
96
|
+
itemIndex: i,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [returnData];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.CircusTerminate = CircusTerminate;
|
|
104
|
+
//# sourceMappingURL=CircusTerminate.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircusTerminate.node.js","sourceRoot":"","sources":["../../../nodes/CircusTerminate/CircusTerminate.node.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAQzC,+CAAqF;AACrF,2DAA2D;AAE3D,MAAa,eAAe;IAA5B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,kBAAkB;YAC/B,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,+B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e,CAAC,OAAO,EAAE;wBACzC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACvB,CAAC,CAAC;oBACH,SAAS;gBACV,CAAC;gBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE;oBAC5D,SAAS,EAAE,CAAC;iBACZ,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AA3GD,0CA2GC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-circus.circusTerminate",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Development", "Developer Tools"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://circus.sh/docs/n8n-nodes#credentials"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://circus.sh/docs/n8n-nodes#terminate"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#ff6666"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<circle cx="12" cy="12" r="10"></circle>
|
|
4
|
+
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
5
|
+
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cc3333"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<circle cx="12" cy="12" r="10"></circle>
|
|
4
|
+
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
5
|
+
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
export interface CircusContext {
|
|
3
|
+
workflowExecutionId: string;
|
|
4
|
+
externalExecutionId: string;
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
initNodeName: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function getCircusContext(ctx: IExecuteFunctions): Promise<CircusContext>;
|
|
10
|
+
export declare function getSnapshot<T>(ctx: IExecuteFunctions, initNodeName: string, snapshotKey: string, itemIndex: number): T | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCircusContext = getCircusContext;
|
|
4
|
+
exports.getSnapshot = getSnapshot;
|
|
5
|
+
async function getCircusContext(ctx) {
|
|
6
|
+
const initNodeName = ctx.customData.get('circus_init_node');
|
|
7
|
+
if (!initNodeName) {
|
|
8
|
+
throw new Error('Circus execution context not found. Ensure a Circus Init node is placed after the Webhook trigger and before this node.');
|
|
9
|
+
}
|
|
10
|
+
const workflowExecutionId = ctx.customData.get('circus_workflow_execution_id');
|
|
11
|
+
if (!workflowExecutionId) {
|
|
12
|
+
throw new Error('Circus workflow_execution_id not found in execution context.');
|
|
13
|
+
}
|
|
14
|
+
const externalExecutionId = ctx.customData.get('circus_external_execution_id') || ctx.getExecutionId();
|
|
15
|
+
const credentials = await ctx.getCredentials('circusApi');
|
|
16
|
+
const apiUrl = credentials.apiUrl;
|
|
17
|
+
const baseUrl = `${apiUrl}/api/machine/workflow-executions/${workflowExecutionId}`;
|
|
18
|
+
return { workflowExecutionId, externalExecutionId, apiUrl, baseUrl, initNodeName };
|
|
19
|
+
}
|
|
20
|
+
function getSnapshot(ctx, initNodeName, snapshotKey, itemIndex) {
|
|
21
|
+
const result = ctx.evaluateExpression(`{{ $('${initNodeName}').item.json.body.${snapshotKey} }}`, itemIndex);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=circusContext.js.map
|