n8n-nodes-cribops 0.1.24 → 0.2.1
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 +149 -245
- package/dist/credentials/CribopsApi.credentials.js +3 -3
- package/dist/credentials/HiveApi.credentials.d.ts +7 -0
- package/dist/credentials/HiveApi.credentials.js +44 -0
- package/dist/nodes/Cribops/Cribops.node.d.ts +1 -6
- package/dist/nodes/Cribops/Cribops.node.js +343 -494
- package/dist/nodes/CribopsTrigger/CribopsTrigger.node.d.ts +1 -6
- package/dist/nodes/CribopsTrigger/CribopsTrigger.node.js +122 -159
- package/dist/nodes/HiveAccelerator/HiveAccelerator.node.d.ts +5 -0
- package/dist/nodes/HiveAccelerator/HiveAccelerator.node.js +461 -0
- package/dist/nodes/HiveAccelerator/hive.svg +7 -0
- package/dist/package.json +11 -5
- package/dist/utils/CribopsHttp.d.ts +190 -56
- package/dist/utils/CribopsHttp.js +84 -92
- package/dist/utils/HiveClient.d.ts +138 -0
- package/dist/utils/HiveClient.js +113 -0
- package/package.json +11 -5
|
@@ -4,78 +4,212 @@ export interface CribopsHttpConfig {
|
|
|
4
4
|
apiToken: string;
|
|
5
5
|
timeout?: number;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface CribopsWebhookDelivery {
|
|
8
8
|
id: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
status: '
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
webhook_id: string;
|
|
10
|
+
destination_url: string;
|
|
11
|
+
status: 'pending' | 'delivered' | 'failed' | 'retrying';
|
|
12
|
+
attempts: number;
|
|
13
|
+
max_attempts: number;
|
|
14
|
+
last_attempt_at?: string;
|
|
15
|
+
next_retry_at?: string;
|
|
16
|
+
response_status?: number;
|
|
17
|
+
response_body?: string;
|
|
18
|
+
error_message?: string;
|
|
19
|
+
created_at: string;
|
|
20
|
+
delivered_at?: string;
|
|
15
21
|
}
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export interface CribopsWebhookMetrics {
|
|
23
|
+
total_webhooks: number;
|
|
24
|
+
successful_deliveries: number;
|
|
25
|
+
failed_deliveries: number;
|
|
26
|
+
pending_deliveries: number;
|
|
27
|
+
average_delivery_time_ms: number;
|
|
28
|
+
success_rate: number;
|
|
29
|
+
destinations: {
|
|
30
|
+
url: string;
|
|
31
|
+
count: number;
|
|
32
|
+
success_rate: number;
|
|
33
|
+
average_response_time_ms: number;
|
|
34
|
+
}[];
|
|
28
35
|
}
|
|
29
|
-
export interface
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
export interface CribopsWebhookStore extends IDataObject {
|
|
37
|
+
webhook_id: string;
|
|
38
|
+
destination_url: string;
|
|
39
|
+
payload: IDataObject;
|
|
40
|
+
headers?: IDataObject;
|
|
41
|
+
priority: 'low' | 'normal' | 'high';
|
|
42
|
+
max_retries: number;
|
|
43
|
+
retry_delay: number;
|
|
44
|
+
rate_limit: number;
|
|
45
|
+
timeout: number;
|
|
46
|
+
authentication?: {
|
|
47
|
+
type: 'none' | 'bearer' | 'basic' | 'apikey';
|
|
48
|
+
value: string;
|
|
37
49
|
};
|
|
38
|
-
inserted_at: string;
|
|
39
|
-
}
|
|
40
|
-
export interface CribopsWebhookEntity {
|
|
41
|
-
id: string;
|
|
42
|
-
name: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
type: 'N8N' | 'GHL_API' | 'GENERIC';
|
|
45
|
-
status: 'active' | 'inactive';
|
|
46
|
-
linked_workflow_id?: string;
|
|
47
|
-
linked_workflow_name?: string;
|
|
48
|
-
organization_id: string;
|
|
49
|
-
created_at: string;
|
|
50
|
-
updated_at: string;
|
|
51
50
|
}
|
|
52
51
|
export declare class CribopsHttp {
|
|
53
52
|
private config;
|
|
54
53
|
constructor(config: CribopsHttpConfig);
|
|
55
54
|
private makeRequest;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
sendMessage(agentId: string, message: Partial<CribopsWebhookMessage>): Promise<CribopsWebhookMessage>;
|
|
59
|
-
downloadFile(fileUrl: string): Promise<Buffer>;
|
|
60
|
-
validateWebhook(payload: any, signature: string): Promise<boolean>;
|
|
61
|
-
testConnection(): Promise<boolean>;
|
|
62
|
-
sendTypingIndicator(agentId: string, conversationId: string, typing: boolean): Promise<any>;
|
|
63
|
-
pollQueue(tenantId: string, limit?: number, queueName?: string): Promise<CribopsQueueMessage[]>;
|
|
64
|
-
acknowledgeMessages(tenantId: string, messageIds: number[]): Promise<{
|
|
55
|
+
storeWebhook(data: CribopsWebhookStore): Promise<{
|
|
56
|
+
webhook_id: string;
|
|
65
57
|
status: string;
|
|
66
|
-
deleted_count: number;
|
|
67
58
|
}>;
|
|
68
|
-
|
|
59
|
+
getWebhookStatus(webhookId: string): Promise<CribopsWebhookDelivery>;
|
|
60
|
+
retryWebhook(webhookId: string): Promise<{
|
|
69
61
|
status: string;
|
|
70
|
-
|
|
62
|
+
retry_scheduled: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
listDeliveries(filters?: {
|
|
65
|
+
status?: string;
|
|
66
|
+
destination_url?: string;
|
|
67
|
+
limit?: number;
|
|
68
|
+
offset?: number;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
deliveries: CribopsWebhookDelivery[];
|
|
71
|
+
total: number;
|
|
71
72
|
}>;
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
getMetrics(timeRange: string): Promise<CribopsWebhookMetrics>;
|
|
74
|
+
registerWebhookEndpoint(config: {
|
|
75
|
+
path: string;
|
|
74
76
|
workflow_id: string;
|
|
77
|
+
workflow_name: string;
|
|
75
78
|
webhook_url: string;
|
|
76
79
|
test_webhook_url: string;
|
|
80
|
+
store_webhook: boolean;
|
|
81
|
+
acknowledge_immediately: boolean;
|
|
82
|
+
enable_deduplication?: boolean;
|
|
83
|
+
deduplication_window?: number;
|
|
84
|
+
enable_rate_limit?: boolean;
|
|
85
|
+
rate_limit?: number;
|
|
86
|
+
allowed_ips?: string[];
|
|
87
|
+
metadata?: IDataObject;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
endpoint_id: string;
|
|
90
|
+
status: string;
|
|
91
|
+
}>;
|
|
92
|
+
unregisterWebhookEndpoint(path: string): Promise<{
|
|
93
|
+
status: string;
|
|
94
|
+
}>;
|
|
95
|
+
receiveWebhook(data: {
|
|
96
|
+
path: string;
|
|
97
|
+
headers?: IDataObject;
|
|
98
|
+
query?: IDataObject;
|
|
99
|
+
body: IDataObject;
|
|
100
|
+
metadata?: IDataObject;
|
|
101
|
+
source_ip?: string;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
webhook_id: string;
|
|
104
|
+
status: string;
|
|
105
|
+
}>;
|
|
106
|
+
replayWebhook(webhookId: string, options?: {
|
|
107
|
+
destination_url?: string;
|
|
108
|
+
headers?: IDataObject;
|
|
109
|
+
}): Promise<{
|
|
110
|
+
status: string;
|
|
111
|
+
delivery_id: string;
|
|
112
|
+
}>;
|
|
113
|
+
testConnection(): Promise<boolean>;
|
|
114
|
+
reportError(data: {
|
|
115
|
+
webhook_id: string;
|
|
116
|
+
error: {
|
|
117
|
+
message: string;
|
|
118
|
+
type: string;
|
|
119
|
+
stack_trace?: string;
|
|
120
|
+
node_name?: string;
|
|
121
|
+
retry_recommended: boolean;
|
|
122
|
+
timestamp: string;
|
|
123
|
+
workflow_id?: string;
|
|
124
|
+
workflow_name?: string;
|
|
125
|
+
};
|
|
126
|
+
}): Promise<{
|
|
127
|
+
status: string;
|
|
128
|
+
error_id: string;
|
|
129
|
+
}>;
|
|
130
|
+
reportPerformance(data: {
|
|
131
|
+
webhook_id: string;
|
|
132
|
+
metrics: {
|
|
133
|
+
processing_time_ms: number;
|
|
134
|
+
memory_usage_mb?: number;
|
|
135
|
+
items_processed: number;
|
|
136
|
+
api_calls?: number;
|
|
137
|
+
success: boolean;
|
|
138
|
+
timestamp: string;
|
|
139
|
+
workflow_id?: string;
|
|
140
|
+
workflow_name?: string;
|
|
141
|
+
};
|
|
142
|
+
}): Promise<{
|
|
143
|
+
status: string;
|
|
144
|
+
metric_id: string;
|
|
145
|
+
}>;
|
|
146
|
+
sendCallback(data: {
|
|
147
|
+
webhook_id: string;
|
|
148
|
+
type: 'success' | 'failure' | 'partial';
|
|
149
|
+
data: IDataObject;
|
|
150
|
+
summary?: string;
|
|
151
|
+
timestamp: string;
|
|
152
|
+
workflow_id?: string;
|
|
153
|
+
workflow_name?: string;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
status: string;
|
|
156
|
+
callback_id: string;
|
|
157
|
+
}>;
|
|
158
|
+
sendProgress(data: {
|
|
159
|
+
webhook_id: string;
|
|
160
|
+
progress: {
|
|
161
|
+
percentage: number;
|
|
162
|
+
message?: string;
|
|
163
|
+
items_completed?: number;
|
|
164
|
+
total_items?: number;
|
|
165
|
+
timestamp: string;
|
|
166
|
+
};
|
|
167
|
+
}): Promise<{
|
|
168
|
+
status: string;
|
|
169
|
+
progress_id: string;
|
|
170
|
+
}>;
|
|
171
|
+
analyzeWorkflow(data: {
|
|
172
|
+
workflow_id: string;
|
|
173
|
+
workflow_name: string;
|
|
174
|
+
metrics?: {
|
|
175
|
+
avg_execution_time_ms: number;
|
|
176
|
+
daily_executions: number;
|
|
177
|
+
failure_rate: number;
|
|
178
|
+
node_count: number;
|
|
179
|
+
};
|
|
180
|
+
workflow_definition?: {
|
|
181
|
+
nodes: any[];
|
|
182
|
+
connections: any;
|
|
183
|
+
};
|
|
184
|
+
}): Promise<{
|
|
185
|
+
status: string;
|
|
186
|
+
recommendations: Array<{
|
|
187
|
+
type: string;
|
|
188
|
+
priority: 'high' | 'medium' | 'low';
|
|
189
|
+
description: string;
|
|
190
|
+
estimated_improvement?: string;
|
|
191
|
+
}>;
|
|
192
|
+
optimization_potential: {
|
|
193
|
+
scalability_score: number;
|
|
194
|
+
parallelization_opportunities: number;
|
|
195
|
+
estimated_cost_reduction?: string;
|
|
196
|
+
};
|
|
197
|
+
}>;
|
|
198
|
+
registerN8NEndpoint(config: {
|
|
199
|
+
webhook_path: string;
|
|
200
|
+
n8n_webhook_url: string;
|
|
201
|
+
test_webhook_url?: string;
|
|
202
|
+
workflow_id?: string;
|
|
77
203
|
workflow_name: string;
|
|
78
|
-
|
|
79
|
-
|
|
204
|
+
report_performance?: boolean;
|
|
205
|
+
report_errors?: boolean;
|
|
206
|
+
signature_secret?: string | null;
|
|
207
|
+
}): Promise<{
|
|
208
|
+
status: string;
|
|
209
|
+
endpoint_id: string;
|
|
210
|
+
}>;
|
|
211
|
+
unregisterN8NEndpoint(webhookPath: string): Promise<{
|
|
212
|
+
status: string;
|
|
213
|
+
}>;
|
|
80
214
|
request<T = any>(method: IHttpRequestMethods, endpoint: string, data?: IDataObject, options?: Partial<IHttpRequestOptions>): Promise<T>;
|
|
81
215
|
}
|
|
@@ -62,160 +62,152 @@ class CribopsHttp {
|
|
|
62
62
|
throw new Error(`Request failed: ${error}`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
// Webhook Store & Forward Operations
|
|
66
|
+
async storeWebhook(data) {
|
|
66
67
|
try {
|
|
67
|
-
|
|
68
|
-
return response.agents || [];
|
|
68
|
+
return await this.makeRequest('POST', '/api/v1/webhooks/store', data);
|
|
69
69
|
}
|
|
70
70
|
catch (error) {
|
|
71
|
-
throw new Error(`Failed to
|
|
71
|
+
throw new Error(`Failed to store webhook: ${error}`);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
async
|
|
74
|
+
async getWebhookStatus(webhookId) {
|
|
75
75
|
try {
|
|
76
|
-
|
|
77
|
-
return response.agent;
|
|
76
|
+
return await this.makeRequest('GET', `/api/v1/webhooks/${webhookId}/status`);
|
|
78
77
|
}
|
|
79
78
|
catch (error) {
|
|
80
|
-
throw new Error(`Failed to
|
|
79
|
+
throw new Error(`Failed to get webhook status: ${error}`);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
async
|
|
82
|
+
async retryWebhook(webhookId) {
|
|
84
83
|
try {
|
|
85
|
-
|
|
86
|
-
return response.message;
|
|
84
|
+
return await this.makeRequest('POST', `/api/v1/webhooks/${webhookId}/retry`);
|
|
87
85
|
}
|
|
88
86
|
catch (error) {
|
|
89
|
-
throw new Error(`Failed to
|
|
87
|
+
throw new Error(`Failed to retry webhook: ${error}`);
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
|
-
async
|
|
90
|
+
async listDeliveries(filters) {
|
|
93
91
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
return await this.makeRequest('GET', '/api/v1/webhooks/deliveries', filters);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
throw new Error(`Failed to list webhook deliveries: ${error}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async getMetrics(timeRange) {
|
|
99
|
+
try {
|
|
100
|
+
return await this.makeRequest('GET', `/api/v1/webhooks/metrics`, { range: timeRange });
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new Error(`Failed to get webhook metrics: ${error}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Webhook Endpoint Registration (for trigger nodes)
|
|
107
|
+
async registerWebhookEndpoint(config) {
|
|
108
|
+
try {
|
|
109
|
+
return await this.makeRequest('POST', '/api/v1/webhook-endpoints/register', config);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw new Error(`Failed to register webhook endpoint: ${error}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async unregisterWebhookEndpoint(path) {
|
|
116
|
+
try {
|
|
117
|
+
return await this.makeRequest('DELETE', `/api/v1/webhook-endpoints/${path}`);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new Error(`Failed to unregister webhook endpoint: ${error}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Webhook Reception (for storing incoming webhooks)
|
|
124
|
+
async receiveWebhook(data) {
|
|
125
|
+
try {
|
|
126
|
+
return await this.makeRequest('POST', '/api/v1/webhooks/receive', data);
|
|
114
127
|
}
|
|
115
128
|
catch (error) {
|
|
116
|
-
throw new Error(`Failed to
|
|
129
|
+
throw new Error(`Failed to receive webhook: ${error}`);
|
|
117
130
|
}
|
|
118
131
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
// Webhook Replay
|
|
133
|
+
async replayWebhook(webhookId, options) {
|
|
134
|
+
try {
|
|
135
|
+
return await this.makeRequest('POST', `/api/v1/webhooks/${webhookId}/replay`, options);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw new Error(`Failed to replay webhook: ${error}`);
|
|
139
|
+
}
|
|
123
140
|
}
|
|
141
|
+
// Test connection
|
|
124
142
|
async testConnection() {
|
|
125
143
|
try {
|
|
126
|
-
await this.
|
|
144
|
+
await this.makeRequest('GET', '/api/v1/health');
|
|
127
145
|
return true;
|
|
128
146
|
}
|
|
129
147
|
catch (error) {
|
|
130
148
|
return false;
|
|
131
149
|
}
|
|
132
150
|
}
|
|
133
|
-
|
|
151
|
+
// Error Reporting
|
|
152
|
+
async reportError(data) {
|
|
134
153
|
try {
|
|
135
|
-
|
|
136
|
-
data: {
|
|
137
|
-
typing: typing,
|
|
138
|
-
},
|
|
139
|
-
conversation_id: conversationId,
|
|
140
|
-
callback_type: 'typing',
|
|
141
|
-
});
|
|
142
|
-
return response;
|
|
154
|
+
return await this.makeRequest('POST', '/api/v1/webhooks/report-error', data);
|
|
143
155
|
}
|
|
144
156
|
catch (error) {
|
|
145
|
-
throw new Error(`Failed to
|
|
157
|
+
throw new Error(`Failed to report error: ${error}`);
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
|
-
|
|
160
|
+
// Performance Metrics Reporting
|
|
161
|
+
async reportPerformance(data) {
|
|
149
162
|
try {
|
|
150
|
-
|
|
151
|
-
if (queueName) {
|
|
152
|
-
params.queue_name = queueName;
|
|
153
|
-
}
|
|
154
|
-
const url = `/api/queue/${tenantId}/poll?${new URLSearchParams(params).toString()}`;
|
|
155
|
-
const response = await this.makeRequest('GET', url);
|
|
156
|
-
return response;
|
|
163
|
+
return await this.makeRequest('POST', '/api/v1/webhooks/report-performance', data);
|
|
157
164
|
}
|
|
158
165
|
catch (error) {
|
|
159
|
-
throw new Error(`Failed to
|
|
166
|
+
throw new Error(`Failed to report performance metrics: ${error}`);
|
|
160
167
|
}
|
|
161
168
|
}
|
|
162
|
-
|
|
169
|
+
// Send Callback for Long-Running Workflows
|
|
170
|
+
async sendCallback(data) {
|
|
163
171
|
try {
|
|
164
|
-
|
|
165
|
-
return response;
|
|
172
|
+
return await this.makeRequest('POST', '/api/v1/webhooks/callback', data);
|
|
166
173
|
}
|
|
167
174
|
catch (error) {
|
|
168
|
-
throw new Error(`Failed to
|
|
175
|
+
throw new Error(`Failed to send callback: ${error}`);
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
|
-
|
|
178
|
+
// Send Progress Update
|
|
179
|
+
async sendProgress(data) {
|
|
172
180
|
try {
|
|
173
|
-
|
|
174
|
-
return response;
|
|
181
|
+
return await this.makeRequest('POST', '/api/v1/webhooks/progress', data);
|
|
175
182
|
}
|
|
176
183
|
catch (error) {
|
|
177
|
-
throw new Error(`Failed to
|
|
184
|
+
throw new Error(`Failed to send progress update: ${error}`);
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
|
-
//
|
|
181
|
-
async
|
|
187
|
+
// Workflow Analysis
|
|
188
|
+
async analyzeWorkflow(data) {
|
|
182
189
|
try {
|
|
183
|
-
|
|
184
|
-
const response = await this.makeRequest('GET', '/api/v1/webhooks');
|
|
185
|
-
// Handle different response structures
|
|
186
|
-
// The API might return webhooks directly as array or wrapped in data property
|
|
187
|
-
if (Array.isArray(response)) {
|
|
188
|
-
return response;
|
|
189
|
-
}
|
|
190
|
-
else if (response.data && Array.isArray(response.data)) {
|
|
191
|
-
return response.data;
|
|
192
|
-
}
|
|
193
|
-
else if (response.webhooks && Array.isArray(response.webhooks)) {
|
|
194
|
-
return response.webhooks;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
// If we can't find webhooks, return empty array
|
|
198
|
-
return [];
|
|
199
|
-
}
|
|
190
|
+
return await this.makeRequest('POST', '/api/v1/workflows/analyze', data);
|
|
200
191
|
}
|
|
201
192
|
catch (error) {
|
|
202
|
-
throw new Error(`Failed to
|
|
193
|
+
throw new Error(`Failed to analyze workflow: ${error}`);
|
|
203
194
|
}
|
|
204
195
|
}
|
|
205
|
-
|
|
196
|
+
// N8N Endpoint Registration (Updated for new architecture)
|
|
197
|
+
async registerN8NEndpoint(config) {
|
|
206
198
|
try {
|
|
207
|
-
return await this.makeRequest('POST',
|
|
199
|
+
return await this.makeRequest('POST', '/api/v1/n8n-endpoints/register', config);
|
|
208
200
|
}
|
|
209
201
|
catch (error) {
|
|
210
|
-
throw new Error(`Failed to
|
|
202
|
+
throw new Error(`Failed to register N8N endpoint: ${error}`);
|
|
211
203
|
}
|
|
212
204
|
}
|
|
213
|
-
async
|
|
205
|
+
async unregisterN8NEndpoint(webhookPath) {
|
|
214
206
|
try {
|
|
215
|
-
return await this.makeRequest('DELETE', `/api/v1/
|
|
207
|
+
return await this.makeRequest('DELETE', `/api/v1/n8n-endpoints/${webhookPath}`);
|
|
216
208
|
}
|
|
217
209
|
catch (error) {
|
|
218
|
-
throw new Error(`Failed to
|
|
210
|
+
throw new Error(`Failed to unregister N8N endpoint: ${error}`);
|
|
219
211
|
}
|
|
220
212
|
}
|
|
221
213
|
// Generic request method for custom API calls
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export interface HiveClientConfig {
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
password?: string;
|
|
5
|
+
tls?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface HiveParallelHttpRequest {
|
|
8
|
+
url: string;
|
|
9
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
body?: any;
|
|
12
|
+
}
|
|
13
|
+
export interface HiveParallelHttpResult {
|
|
14
|
+
url: string;
|
|
15
|
+
status: number | null;
|
|
16
|
+
body?: any;
|
|
17
|
+
error?: string;
|
|
18
|
+
time_ms: number;
|
|
19
|
+
}
|
|
20
|
+
export interface HiveCronConfig {
|
|
21
|
+
name: string;
|
|
22
|
+
expression: string;
|
|
23
|
+
webhook_url: string;
|
|
24
|
+
payload?: Record<string, any>;
|
|
25
|
+
timezone?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface HiveCronInfo {
|
|
28
|
+
name: string;
|
|
29
|
+
expression: string;
|
|
30
|
+
webhook_url: string;
|
|
31
|
+
payload: Record<string, any>;
|
|
32
|
+
timezone: string;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
created_at: string;
|
|
35
|
+
next_run?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface HiveFanoutResult {
|
|
38
|
+
endpoint: string;
|
|
39
|
+
status?: number;
|
|
40
|
+
success: boolean;
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface HiveCircuitStatus {
|
|
44
|
+
service: string;
|
|
45
|
+
status: 'closed' | 'open' | 'half_open';
|
|
46
|
+
failure_count: number;
|
|
47
|
+
last_failure: string | null;
|
|
48
|
+
can_proceed: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare class HiveClient {
|
|
51
|
+
private redis;
|
|
52
|
+
private connected;
|
|
53
|
+
constructor(config: HiveClientConfig);
|
|
54
|
+
connect(): Promise<void>;
|
|
55
|
+
disconnect(): Promise<void>;
|
|
56
|
+
private execute;
|
|
57
|
+
ping(): Promise<{
|
|
58
|
+
pong: boolean;
|
|
59
|
+
timestamp: string;
|
|
60
|
+
}>;
|
|
61
|
+
info(): Promise<{
|
|
62
|
+
version: string;
|
|
63
|
+
accelerator: boolean;
|
|
64
|
+
oban_pro: boolean;
|
|
65
|
+
operations: string[];
|
|
66
|
+
dedup_stats: {
|
|
67
|
+
active_dedup_keys: number;
|
|
68
|
+
ttl_ms: number;
|
|
69
|
+
};
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Execute multiple HTTP requests in parallel via Hive's Elixir Task.async_stream
|
|
73
|
+
*/
|
|
74
|
+
parallelHttp(requests: HiveParallelHttpRequest[], options?: {
|
|
75
|
+
concurrency?: number;
|
|
76
|
+
timeout_ms?: number;
|
|
77
|
+
}): Promise<{
|
|
78
|
+
results: HiveParallelHttpResult[];
|
|
79
|
+
stats: {
|
|
80
|
+
total: number;
|
|
81
|
+
successful: number;
|
|
82
|
+
failed: number;
|
|
83
|
+
total_time_ms: number;
|
|
84
|
+
};
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Schedule a dynamic cron job via Oban Pro
|
|
88
|
+
*/
|
|
89
|
+
scheduleCron(config: HiveCronConfig): Promise<{
|
|
90
|
+
scheduled: boolean;
|
|
91
|
+
name: string;
|
|
92
|
+
expression: string;
|
|
93
|
+
timezone: string;
|
|
94
|
+
next_run: string | null;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Delete a dynamic cron job
|
|
98
|
+
*/
|
|
99
|
+
deleteCron(name: string): Promise<{
|
|
100
|
+
deleted: boolean;
|
|
101
|
+
name: string;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* List all dynamic cron jobs
|
|
105
|
+
*/
|
|
106
|
+
listCrons(): Promise<{
|
|
107
|
+
crons: HiveCronInfo[];
|
|
108
|
+
count: number;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Fan-out a payload to multiple webhook endpoints in parallel
|
|
112
|
+
*/
|
|
113
|
+
fanout(endpoints: string[], payload: Record<string, any>, options?: {
|
|
114
|
+
timeout_ms?: number;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
results: HiveFanoutResult[];
|
|
117
|
+
stats: {
|
|
118
|
+
total: number;
|
|
119
|
+
successful: number;
|
|
120
|
+
failed: number;
|
|
121
|
+
total_time_ms: number;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
/**
|
|
125
|
+
* Check if data is a duplicate (deduplication)
|
|
126
|
+
*/
|
|
127
|
+
dedupCheck(data: Record<string, any>, options?: {
|
|
128
|
+
ttl_seconds?: number;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
is_duplicate: boolean;
|
|
131
|
+
hash: string;
|
|
132
|
+
first_seen: string;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* Check circuit breaker status and optionally record success/failure
|
|
136
|
+
*/
|
|
137
|
+
circuitCheck(service: string, recordResult?: 'success' | 'failure'): Promise<HiveCircuitStatus>;
|
|
138
|
+
}
|