@almadar/integrations 1.0.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 +72 -0
- package/README.md +290 -0
- package/dist/factory-rMujCO3M.d.ts +159 -0
- package/dist/index.d.ts +189 -0
- package/dist/index.js +1336 -0
- package/dist/index.js.map +1 -0
- package/dist/mocks/index.d.ts +50 -0
- package/dist/mocks/index.js +342 -0
- package/dist/mocks/index.js.map +1 -0
- package/dist/runtime/index.d.ts +29 -0
- package/dist/runtime/index.js +179 -0
- package/dist/runtime/index.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: Almadar FZE
|
|
6
|
+
Licensed Work: KFlow Builder / Almadar
|
|
7
|
+
The Licensed Work is (c) 2025-2026 Almadar FZE.
|
|
8
|
+
Additional Use Grant: You may make production use of the Licensed Work for
|
|
9
|
+
non-commercial purposes and for internal evaluation.
|
|
10
|
+
Production use for commercial purposes requires a
|
|
11
|
+
commercial license from the Licensor.
|
|
12
|
+
Change Date: 2030-02-01
|
|
13
|
+
Change License: Apache License, Version 2.0
|
|
14
|
+
|
|
15
|
+
Terms
|
|
16
|
+
|
|
17
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
18
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
19
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
20
|
+
production use.
|
|
21
|
+
|
|
22
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
23
|
+
available distribution of a specific version of the Licensed Work under this
|
|
24
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
25
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
26
|
+
above terminate.
|
|
27
|
+
|
|
28
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
29
|
+
currently in effect as described in this License, you must purchase a
|
|
30
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
31
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
32
|
+
|
|
33
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
34
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
35
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
36
|
+
for each version of the Licensed Work released by Licensor.
|
|
37
|
+
|
|
38
|
+
You must conspicuously display this License on each original or modified copy
|
|
39
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
40
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
41
|
+
License apply to your use of that work.
|
|
42
|
+
|
|
43
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
44
|
+
terminate your rights under this License for the current and all other
|
|
45
|
+
versions of the Licensed Work.
|
|
46
|
+
|
|
47
|
+
This License does not grant you any right in any trademark or logo of
|
|
48
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
49
|
+
Licensor as expressly required by this License).
|
|
50
|
+
|
|
51
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
52
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
55
|
+
TITLE.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
60
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
61
|
+
|
|
62
|
+
ADDITIONAL TERMS:
|
|
63
|
+
|
|
64
|
+
Documentation (builder/packages/website/docs/) is licensed under CC BY 4.0.
|
|
65
|
+
|
|
66
|
+
TRADEMARKS:
|
|
67
|
+
|
|
68
|
+
"Orbital", "KFlow", "Almadar", and the Almadar logo are trademarks of
|
|
69
|
+
Almadar FZE. You may not use these trademarks without prior written
|
|
70
|
+
permission from Almadar FZE.
|
|
71
|
+
|
|
72
|
+
For licensing inquiries: licensing@almadar.io
|
package/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# @almadar/integrations
|
|
2
|
+
|
|
3
|
+
> External service integrations for Almadar applications
|
|
4
|
+
|
|
5
|
+
Production-ready implementations of external service integrations that work seamlessly in both **interpreted runtime** and **compiled applications**.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- ✅ **Type-Safe** - Full TypeScript types from registry to implementation
|
|
10
|
+
- ✅ **Environment-Agnostic** - Works in runtime AND compiled apps
|
|
11
|
+
- ✅ **Testable** - Mock implementations for testing
|
|
12
|
+
- ✅ **Extensible** - Easy to add new integrations
|
|
13
|
+
- ✅ **Secure** - API keys via environment variables
|
|
14
|
+
- ✅ **Observable** - Logging and error tracking
|
|
15
|
+
- ✅ **Validated** - Input validation against registry schema
|
|
16
|
+
|
|
17
|
+
## Supported Integrations
|
|
18
|
+
|
|
19
|
+
| Integration | Actions | Use Case |
|
|
20
|
+
|-------------|---------|----------|
|
|
21
|
+
| **Stripe** | createPaymentIntent, confirmPayment, refund | Payment processing |
|
|
22
|
+
| **YouTube** | search, getVideo, getChannel | Video data and search |
|
|
23
|
+
| **Twilio** | sendSMS, sendWhatsApp | Messaging |
|
|
24
|
+
| **Email** | send | Transactional email (SendGrid/Resend) |
|
|
25
|
+
| **LLM** | generate, classify, extract, summarize | AI content generation |
|
|
26
|
+
| **DeepAgent** | sendMessage, validateSchema, compileSchema | AI code generation |
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm add @almadar/integrations
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### 1. Runtime Integration
|
|
37
|
+
|
|
38
|
+
Use with `@almadar/runtime`:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { RuntimeIntegrationManager } from '@almadar/integrations/runtime';
|
|
42
|
+
import '@almadar/integrations'; // Auto-register integrations
|
|
43
|
+
|
|
44
|
+
const integrationManager = new RuntimeIntegrationManager();
|
|
45
|
+
integrationManager.configureFromEnv();
|
|
46
|
+
|
|
47
|
+
const runtime = new OrbitalServerRuntime({
|
|
48
|
+
schema,
|
|
49
|
+
effectHandlers: {
|
|
50
|
+
callService: integrationManager.getCallServiceHandler(),
|
|
51
|
+
// ... other handlers
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 2. Compiled App
|
|
57
|
+
|
|
58
|
+
Use in generated code:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { IntegrationFactory } from '@almadar/integrations';
|
|
62
|
+
import '@almadar/integrations'; // Auto-register integrations
|
|
63
|
+
|
|
64
|
+
const integrations = new IntegrationFactory();
|
|
65
|
+
|
|
66
|
+
// Configure integrations
|
|
67
|
+
integrations.configure('stripe', {
|
|
68
|
+
env: {
|
|
69
|
+
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY!,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Use in effect handler
|
|
74
|
+
async function handleCallService(service, action, params) {
|
|
75
|
+
const result = await integrations.execute(service, action, params);
|
|
76
|
+
|
|
77
|
+
if (!result.success) {
|
|
78
|
+
throw result.error;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return result.data;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 3. Direct Usage
|
|
86
|
+
|
|
87
|
+
Use integrations directly:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { StripeIntegration } from '@almadar/integrations';
|
|
91
|
+
|
|
92
|
+
const stripe = new StripeIntegration({
|
|
93
|
+
name: 'stripe',
|
|
94
|
+
env: {
|
|
95
|
+
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY!,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const result = await stripe.execute('createPaymentIntent', {
|
|
100
|
+
amount: 2000,
|
|
101
|
+
currency: 'usd',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (result.success) {
|
|
105
|
+
console.log('Payment intent:', result.data);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
Set environment variables:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Stripe
|
|
115
|
+
STRIPE_SECRET_KEY=sk_test_...
|
|
116
|
+
|
|
117
|
+
# YouTube
|
|
118
|
+
YOUTUBE_API_KEY=AIza...
|
|
119
|
+
|
|
120
|
+
# Twilio
|
|
121
|
+
TWILIO_ACCOUNT_SID=AC...
|
|
122
|
+
TWILIO_AUTH_TOKEN=...
|
|
123
|
+
TWILIO_PHONE_NUMBER=+1...
|
|
124
|
+
|
|
125
|
+
# Email (SendGrid)
|
|
126
|
+
SENDGRID_API_KEY=SG....
|
|
127
|
+
FROM_EMAIL=noreply@example.com
|
|
128
|
+
|
|
129
|
+
# Email (Resend)
|
|
130
|
+
RESEND_API_KEY=re_...
|
|
131
|
+
|
|
132
|
+
# LLM (Anthropic)
|
|
133
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
134
|
+
|
|
135
|
+
# LLM (OpenAI)
|
|
136
|
+
OPENAI_API_KEY=sk-...
|
|
137
|
+
|
|
138
|
+
# DeepAgent
|
|
139
|
+
DEEPAGENT_API_URL=http://localhost:3000
|
|
140
|
+
DEEPAGENT_API_KEY=...
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Testing
|
|
144
|
+
|
|
145
|
+
Use mock implementations:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { MockIntegrationFactory } from '@almadar/integrations/mocks';
|
|
149
|
+
|
|
150
|
+
const mockFactory = new MockIntegrationFactory();
|
|
151
|
+
|
|
152
|
+
// Set mock response
|
|
153
|
+
mockFactory.setMockResponse('stripe', 'createPaymentIntent', {
|
|
154
|
+
id: 'pi_test_123',
|
|
155
|
+
clientSecret: 'secret_test_123',
|
|
156
|
+
status: 'succeeded',
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Execute
|
|
160
|
+
const result = await mockFactory.execute('stripe', 'createPaymentIntent', {
|
|
161
|
+
amount: 2000,
|
|
162
|
+
currency: 'usd',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Assert
|
|
166
|
+
expect(result.success).toBe(true);
|
|
167
|
+
expect(result.data).toHaveProperty('id');
|
|
168
|
+
|
|
169
|
+
// Check calls
|
|
170
|
+
const calls = mockFactory.getMockCalls('stripe');
|
|
171
|
+
expect(calls).toHaveLength(1);
|
|
172
|
+
expect(calls[0].action).toBe('createPaymentIntent');
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Schema Usage
|
|
176
|
+
|
|
177
|
+
In `.orb` files, use `call-service` effect:
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"transitions": [{
|
|
182
|
+
"from": "idle",
|
|
183
|
+
"to": "processing",
|
|
184
|
+
"event": "CHECKOUT",
|
|
185
|
+
"effects": [
|
|
186
|
+
["call-service", "stripe", "createPaymentIntent", {
|
|
187
|
+
"amount": "@payload.amount",
|
|
188
|
+
"currency": "@payload.currency"
|
|
189
|
+
}]
|
|
190
|
+
]
|
|
191
|
+
}]
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## API
|
|
196
|
+
|
|
197
|
+
### IntegrationFactory
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const factory = new IntegrationFactory();
|
|
201
|
+
|
|
202
|
+
// Configure an integration
|
|
203
|
+
factory.configure('stripe', {
|
|
204
|
+
env: { STRIPE_SECRET_KEY: '...' },
|
|
205
|
+
timeout: 30000,
|
|
206
|
+
retry: { maxAttempts: 3, backoffMs: 1000 }
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Execute an action
|
|
210
|
+
const result = await factory.execute('stripe', 'createPaymentIntent', params);
|
|
211
|
+
|
|
212
|
+
// Get integration instance
|
|
213
|
+
const stripe = factory.get('stripe');
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### RuntimeIntegrationManager
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
const manager = new RuntimeIntegrationManager();
|
|
220
|
+
|
|
221
|
+
// Auto-configure from environment
|
|
222
|
+
manager.configureFromEnv();
|
|
223
|
+
|
|
224
|
+
// Get effect handler
|
|
225
|
+
const callServiceHandler = manager.getCallServiceHandler();
|
|
226
|
+
|
|
227
|
+
// Get factory
|
|
228
|
+
const factory = manager.getFactory();
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### BaseIntegration
|
|
232
|
+
|
|
233
|
+
Extend for custom integrations:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { BaseIntegration } from '@almadar/integrations';
|
|
237
|
+
|
|
238
|
+
class MyIntegration extends BaseIntegration {
|
|
239
|
+
async execute(action, params) {
|
|
240
|
+
const validation = this.validateParams(action, params);
|
|
241
|
+
if (!validation.valid) {
|
|
242
|
+
return { success: false, error: ... };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Implement your logic
|
|
246
|
+
const data = await this.myApiCall(params);
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
success: true,
|
|
250
|
+
data,
|
|
251
|
+
metadata: this.createMetadata(action, duration)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Architecture
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
261
|
+
│ .orb Schema File │
|
|
262
|
+
│ ["call-service", "stripe", "createPaymentIntent", {...}] │
|
|
263
|
+
└──────────────────────────────┬──────────────────────────────┘
|
|
264
|
+
│
|
|
265
|
+
▼
|
|
266
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
267
|
+
│ @almadar/patterns (Registry) │
|
|
268
|
+
│ integrators-registry.json - Defines actions & params │
|
|
269
|
+
└──────────────────────────────┬──────────────────────────────┘
|
|
270
|
+
│
|
|
271
|
+
▼
|
|
272
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
273
|
+
│ @almadar/integrations (THIS PACKAGE) │
|
|
274
|
+
│ - SDK wrappers │
|
|
275
|
+
│ - Auth handling │
|
|
276
|
+
│ - Error handling │
|
|
277
|
+
│ - Type-safe implementations │
|
|
278
|
+
└──────────────────────────────┬──────────────────────────────┘
|
|
279
|
+
│
|
|
280
|
+
▼
|
|
281
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
282
|
+
│ Runtime / Compiled App │
|
|
283
|
+
│ - @almadar/runtime (interpreted) │
|
|
284
|
+
│ - Generated TypeScript/Python code (compiled) │
|
|
285
|
+
└─────────────────────────────────────────────────────────────┘
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
MIT
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for Almadar integrations
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for an integration instance
|
|
6
|
+
*/
|
|
7
|
+
interface IntegrationConfig {
|
|
8
|
+
/** Integration name (matches registry) */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Environment variables (API keys, secrets) */
|
|
11
|
+
env: Record<string, string>;
|
|
12
|
+
/** Optional logger */
|
|
13
|
+
logger?: IntegrationLogger;
|
|
14
|
+
/** Optional rate limiting config */
|
|
15
|
+
rateLimit?: {
|
|
16
|
+
requestsPerSecond: number;
|
|
17
|
+
burstSize: number;
|
|
18
|
+
};
|
|
19
|
+
/** Optional timeout (ms) */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
/** Optional retry config */
|
|
22
|
+
retry?: {
|
|
23
|
+
maxAttempts: number;
|
|
24
|
+
backoffMs: number;
|
|
25
|
+
maxBackoffMs?: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Result of an integration action call
|
|
30
|
+
*/
|
|
31
|
+
interface IntegrationResult<T = unknown> {
|
|
32
|
+
/** Success flag */
|
|
33
|
+
success: boolean;
|
|
34
|
+
/** Response data (on success) */
|
|
35
|
+
data?: T;
|
|
36
|
+
/** Error (on failure) */
|
|
37
|
+
error?: IntegrationError;
|
|
38
|
+
/** Metadata (timing, retries, etc.) */
|
|
39
|
+
metadata: {
|
|
40
|
+
integration: string;
|
|
41
|
+
action: string;
|
|
42
|
+
duration: number;
|
|
43
|
+
retries: number;
|
|
44
|
+
timestamp: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Integration error codes
|
|
49
|
+
*/
|
|
50
|
+
type IntegrationErrorCode = 'VALIDATION_ERROR' | 'AUTH_ERROR' | 'RATE_LIMIT_ERROR' | 'TIMEOUT_ERROR' | 'NETWORK_ERROR' | 'SERVICE_ERROR' | 'UNKNOWN_ERROR';
|
|
51
|
+
/**
|
|
52
|
+
* Integration error
|
|
53
|
+
*/
|
|
54
|
+
declare class IntegrationError extends Error {
|
|
55
|
+
code: IntegrationErrorCode;
|
|
56
|
+
integration?: string;
|
|
57
|
+
action?: string;
|
|
58
|
+
details?: unknown;
|
|
59
|
+
constructor(message: string, code?: IntegrationErrorCode, details?: unknown);
|
|
60
|
+
toJSON(): {
|
|
61
|
+
name: string;
|
|
62
|
+
message: string;
|
|
63
|
+
code: IntegrationErrorCode;
|
|
64
|
+
integration: string | undefined;
|
|
65
|
+
action: string | undefined;
|
|
66
|
+
details: unknown;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Logger interface
|
|
71
|
+
*/
|
|
72
|
+
interface IntegrationLogger {
|
|
73
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
74
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
75
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
76
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validation result
|
|
80
|
+
*/
|
|
81
|
+
interface ValidationResult {
|
|
82
|
+
valid: boolean;
|
|
83
|
+
errors: ValidationError[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validation error
|
|
87
|
+
*/
|
|
88
|
+
interface ValidationError {
|
|
89
|
+
param: string;
|
|
90
|
+
message: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Validate action params against registry schema
|
|
95
|
+
*/
|
|
96
|
+
declare function validateParams(integration: string, action: string, params: Record<string, unknown>): ValidationResult;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Base class for all integrations
|
|
100
|
+
*/
|
|
101
|
+
declare abstract class BaseIntegration {
|
|
102
|
+
protected config: IntegrationConfig;
|
|
103
|
+
protected logger: IntegrationLogger;
|
|
104
|
+
constructor(config: IntegrationConfig);
|
|
105
|
+
/**
|
|
106
|
+
* Execute an action
|
|
107
|
+
*/
|
|
108
|
+
abstract execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Validate action params against registry
|
|
111
|
+
*/
|
|
112
|
+
protected validateParams(action: string, params: Record<string, unknown>): ReturnType<typeof validateParams>;
|
|
113
|
+
/**
|
|
114
|
+
* Handle errors uniformly
|
|
115
|
+
*/
|
|
116
|
+
protected handleError(action: string, error: unknown): IntegrationResult;
|
|
117
|
+
/**
|
|
118
|
+
* Create metadata for result
|
|
119
|
+
*/
|
|
120
|
+
protected createMetadata(action: string, duration: number, retries?: number): IntegrationResult['metadata'];
|
|
121
|
+
/**
|
|
122
|
+
* Execute with retry logic
|
|
123
|
+
*/
|
|
124
|
+
protected executeWithRetry<T>(fn: () => Promise<T>): Promise<T>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Factory for creating and managing integration instances
|
|
129
|
+
*/
|
|
130
|
+
declare class IntegrationFactory {
|
|
131
|
+
private instances;
|
|
132
|
+
private configs;
|
|
133
|
+
/**
|
|
134
|
+
* Configure an integration (doesn't instantiate yet)
|
|
135
|
+
*/
|
|
136
|
+
configure(name: string, config: Omit<IntegrationConfig, 'name'>): void;
|
|
137
|
+
/**
|
|
138
|
+
* Get or create an integration instance
|
|
139
|
+
*/
|
|
140
|
+
get(name: string): BaseIntegration;
|
|
141
|
+
/**
|
|
142
|
+
* Execute an action on an integration
|
|
143
|
+
*/
|
|
144
|
+
execute(integration: string, action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Check if integration is configured
|
|
147
|
+
*/
|
|
148
|
+
isConfigured(name: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Clear all instances (useful for testing)
|
|
151
|
+
*/
|
|
152
|
+
clear(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Clear all instances and configs
|
|
155
|
+
*/
|
|
156
|
+
reset(): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { BaseIntegration as B, type IntegrationLogger as I, type ValidationError as V, type IntegrationErrorCode as a, type IntegrationConfig as b, type IntegrationResult as c, IntegrationError as d, IntegrationFactory as e, type ValidationResult as f, validateParams as v };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { I as IntegrationLogger, a as IntegrationErrorCode, b as IntegrationConfig, B as BaseIntegration, c as IntegrationResult } from './factory-rMujCO3M.js';
|
|
2
|
+
export { d as IntegrationError, e as IntegrationFactory, V as ValidationError, f as ValidationResult, v as validateParams } from './factory-rMujCO3M.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Console-based logger implementation
|
|
6
|
+
*/
|
|
7
|
+
declare class ConsoleLogger implements IntegrationLogger {
|
|
8
|
+
private level;
|
|
9
|
+
constructor(level?: 'debug' | 'info' | 'warn' | 'error');
|
|
10
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
11
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
12
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
13
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
14
|
+
private shouldLog;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Retry configuration
|
|
19
|
+
*/
|
|
20
|
+
interface RetryConfig {
|
|
21
|
+
maxAttempts: number;
|
|
22
|
+
backoffMs: number;
|
|
23
|
+
maxBackoffMs?: number;
|
|
24
|
+
retryableErrors?: IntegrationErrorCode[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute a function with retry logic
|
|
28
|
+
*/
|
|
29
|
+
declare function withRetry<T>(fn: () => Promise<T>, config: RetryConfig): Promise<T>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Integration constructor type
|
|
33
|
+
*/
|
|
34
|
+
type IntegrationConstructor = new (config: IntegrationConfig) => BaseIntegration;
|
|
35
|
+
/**
|
|
36
|
+
* Register an integration
|
|
37
|
+
*/
|
|
38
|
+
declare function registerIntegration(name: string, constructor: IntegrationConstructor): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get integration constructor by name
|
|
41
|
+
*/
|
|
42
|
+
declare function getIntegration(name: string): IntegrationConstructor | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Check if integration is known
|
|
45
|
+
*/
|
|
46
|
+
declare function isKnownIntegration(name: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get all registered integration names
|
|
49
|
+
*/
|
|
50
|
+
declare function getRegisteredIntegrations(): string[];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Stripe integration for payment processing
|
|
54
|
+
*/
|
|
55
|
+
declare class StripeIntegration extends BaseIntegration {
|
|
56
|
+
private client;
|
|
57
|
+
constructor(config: IntegrationConfig);
|
|
58
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
59
|
+
private createPaymentIntent;
|
|
60
|
+
private confirmPayment;
|
|
61
|
+
private refund;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* YouTube Data API integration
|
|
66
|
+
*/
|
|
67
|
+
declare class YouTubeIntegration extends BaseIntegration {
|
|
68
|
+
private client;
|
|
69
|
+
constructor(config: IntegrationConfig);
|
|
70
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
71
|
+
private search;
|
|
72
|
+
private getVideo;
|
|
73
|
+
private getChannel;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Twilio messaging integration
|
|
78
|
+
*/
|
|
79
|
+
declare class TwilioIntegration extends BaseIntegration {
|
|
80
|
+
private client;
|
|
81
|
+
private phoneNumber;
|
|
82
|
+
constructor(config: IntegrationConfig);
|
|
83
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
84
|
+
private sendSMS;
|
|
85
|
+
private sendWhatsApp;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Email integration (SendGrid/Resend)
|
|
90
|
+
*/
|
|
91
|
+
declare class EmailIntegration extends BaseIntegration {
|
|
92
|
+
private provider;
|
|
93
|
+
private fromEmail;
|
|
94
|
+
private resendClient?;
|
|
95
|
+
constructor(config: IntegrationConfig);
|
|
96
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
97
|
+
private send;
|
|
98
|
+
private sendViaSendGrid;
|
|
99
|
+
private sendViaResend;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* LLM integration using @almadar/llm
|
|
104
|
+
*/
|
|
105
|
+
declare class LLMIntegration extends BaseIntegration {
|
|
106
|
+
private client;
|
|
107
|
+
private provider;
|
|
108
|
+
constructor(config: IntegrationConfig);
|
|
109
|
+
private createLLMClient;
|
|
110
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
111
|
+
private generate;
|
|
112
|
+
private classify;
|
|
113
|
+
private extract;
|
|
114
|
+
private summarize;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* DeepAgent integration for AI code generation
|
|
119
|
+
*/
|
|
120
|
+
declare class DeepAgentIntegration extends BaseIntegration {
|
|
121
|
+
private apiUrl;
|
|
122
|
+
private apiKey;
|
|
123
|
+
constructor(config: IntegrationConfig);
|
|
124
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
125
|
+
private sendMessage;
|
|
126
|
+
private cancelGeneration;
|
|
127
|
+
private validateSchema;
|
|
128
|
+
private compileSchema;
|
|
129
|
+
private getThreadHistory;
|
|
130
|
+
private request;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* GitHub Integration for Almadar
|
|
135
|
+
* Provides git operations and GitHub API access for the agent
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* GitHub integration class
|
|
140
|
+
*/
|
|
141
|
+
declare class GitHubIntegration extends BaseIntegration {
|
|
142
|
+
private token;
|
|
143
|
+
private owner;
|
|
144
|
+
private repo;
|
|
145
|
+
private workDir;
|
|
146
|
+
constructor(config: IntegrationConfig);
|
|
147
|
+
/**
|
|
148
|
+
* Execute a GitHub action
|
|
149
|
+
*/
|
|
150
|
+
execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
|
|
151
|
+
/**
|
|
152
|
+
* Clone a repository
|
|
153
|
+
*/
|
|
154
|
+
private cloneRepo;
|
|
155
|
+
/**
|
|
156
|
+
* Create a branch
|
|
157
|
+
*/
|
|
158
|
+
private createBranch;
|
|
159
|
+
/**
|
|
160
|
+
* Commit changes
|
|
161
|
+
*/
|
|
162
|
+
private commit;
|
|
163
|
+
/**
|
|
164
|
+
* Push branch
|
|
165
|
+
*/
|
|
166
|
+
private push;
|
|
167
|
+
/**
|
|
168
|
+
* Create a pull request
|
|
169
|
+
*/
|
|
170
|
+
private createPR;
|
|
171
|
+
/**
|
|
172
|
+
* Get PR comments
|
|
173
|
+
*/
|
|
174
|
+
private getPRComments;
|
|
175
|
+
/**
|
|
176
|
+
* List issues
|
|
177
|
+
*/
|
|
178
|
+
private listIssues;
|
|
179
|
+
/**
|
|
180
|
+
* Get issue details
|
|
181
|
+
*/
|
|
182
|
+
private getIssue;
|
|
183
|
+
/**
|
|
184
|
+
* Get API config for GitHub API calls
|
|
185
|
+
*/
|
|
186
|
+
private getAPIConfig;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { BaseIntegration, ConsoleLogger, DeepAgentIntegration, EmailIntegration, GitHubIntegration, IntegrationConfig, type IntegrationConstructor, IntegrationErrorCode, IntegrationLogger, IntegrationResult, LLMIntegration, type RetryConfig, StripeIntegration, TwilioIntegration, YouTubeIntegration, getIntegration, getRegisteredIntegrations, isKnownIntegration, registerIntegration, withRetry };
|