apteva 0.2.8 → 0.2.10

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.
@@ -0,0 +1,80 @@
1
+ // Generic Integration Provider Interface
2
+ // Allows multiple providers (Composio, Smithery, etc.) to offer OAuth app connections
3
+
4
+ export interface IntegrationApp {
5
+ id: string;
6
+ name: string;
7
+ slug: string;
8
+ description: string | null;
9
+ logo: string | null;
10
+ categories: string[];
11
+ authSchemes: string[]; // e.g., ["OAUTH2", "API_KEY"]
12
+ }
13
+
14
+ export interface ConnectedAccount {
15
+ id: string;
16
+ appId: string;
17
+ appName: string;
18
+ status: "active" | "pending" | "failed" | "expired";
19
+ createdAt: string;
20
+ metadata?: Record<string, unknown>;
21
+ }
22
+
23
+ export interface ConnectionRequest {
24
+ redirectUrl: string | null; // null for API_KEY auth (no redirect needed)
25
+ connectionId?: string;
26
+ status?: "active" | "pending"; // API_KEY connections are immediately active
27
+ }
28
+
29
+ export interface ConnectionCredentials {
30
+ authScheme: "OAUTH2" | "API_KEY" | "BEARER_TOKEN" | "BASIC";
31
+ apiKey?: string;
32
+ bearerToken?: string;
33
+ username?: string;
34
+ password?: string;
35
+ }
36
+
37
+ export interface IntegrationProvider {
38
+ id: string;
39
+ name: string;
40
+
41
+ // List available apps/toolkits
42
+ listApps(apiKey: string): Promise<IntegrationApp[]>;
43
+
44
+ // List user's connected accounts
45
+ listConnectedAccounts(apiKey: string, userId: string): Promise<ConnectedAccount[]>;
46
+
47
+ // Initiate connection (OAuth or API Key)
48
+ initiateConnection(
49
+ apiKey: string,
50
+ userId: string,
51
+ appSlug: string,
52
+ redirectUrl: string,
53
+ credentials?: ConnectionCredentials
54
+ ): Promise<ConnectionRequest>;
55
+
56
+ // Check connection status
57
+ getConnectionStatus(apiKey: string, connectionId: string): Promise<ConnectedAccount | null>;
58
+
59
+ // Disconnect/revoke
60
+ disconnect(apiKey: string, connectionId: string): Promise<boolean>;
61
+ }
62
+
63
+ // Provider registry
64
+ const providers: Map<string, IntegrationProvider> = new Map();
65
+
66
+ export function registerProvider(provider: IntegrationProvider) {
67
+ providers.set(provider.id, provider);
68
+ }
69
+
70
+ export function getProvider(id: string): IntegrationProvider | undefined {
71
+ return providers.get(id);
72
+ }
73
+
74
+ export function getAllProviders(): IntegrationProvider[] {
75
+ return Array.from(providers.values());
76
+ }
77
+
78
+ export function getProviderIds(): string[] {
79
+ return Array.from(providers.keys());
80
+ }