@hasna/connectors 1.1.5 → 1.1.6
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/bin/index.js +1 -1
- package/bin/mcp.js +1 -1
- package/connectors/connect-gmail/src/api/attachments.ts +143 -0
- package/connectors/connect-gmail/src/api/bulk.ts +713 -0
- package/connectors/connect-gmail/src/api/client.ts +131 -0
- package/connectors/connect-gmail/src/api/drafts.ts +198 -0
- package/connectors/connect-gmail/src/api/export.ts +312 -0
- package/connectors/connect-gmail/src/api/filters.ts +127 -0
- package/connectors/connect-gmail/src/api/index.ts +63 -0
- package/connectors/connect-gmail/src/api/labels.ts +123 -0
- package/connectors/connect-gmail/src/api/messages.ts +527 -0
- package/connectors/connect-gmail/src/api/profile.ts +72 -0
- package/connectors/connect-gmail/src/api/threads.ts +85 -0
- package/connectors/connect-gmail/src/cli/index.ts +2389 -0
- package/connectors/connect-gmail/src/index.ts +30 -0
- package/connectors/connect-gmail/src/types/index.ts +202 -0
- package/connectors/connect-gmail/src/utils/auth.ts +256 -0
- package/connectors/connect-gmail/src/utils/config.ts +466 -0
- package/connectors/connect-gmail/src/utils/contacts.ts +147 -0
- package/connectors/connect-gmail/src/utils/markdown.ts +119 -0
- package/connectors/connect-gmail/src/utils/output.ts +119 -0
- package/connectors/connect-gmail/src/utils/settings.ts +87 -0
- package/connectors/connect-gmail/tsconfig.json +16 -0
- package/connectors/connect-telegram/src/api/bot.ts +223 -0
- package/connectors/connect-telegram/src/api/chats.ts +290 -0
- package/connectors/connect-telegram/src/api/client.ts +134 -0
- package/connectors/connect-telegram/src/api/index.ts +66 -0
- package/connectors/connect-telegram/src/api/inline.ts +63 -0
- package/connectors/connect-telegram/src/api/messages.ts +781 -0
- package/connectors/connect-telegram/src/api/updates.ts +97 -0
- package/connectors/connect-telegram/src/cli/index.ts +690 -0
- package/connectors/connect-telegram/src/index.ts +22 -0
- package/connectors/connect-telegram/src/types/index.ts +617 -0
- package/connectors/connect-telegram/src/utils/config.ts +197 -0
- package/connectors/connect-telegram/src/utils/output.ts +119 -0
- package/connectors/connect-telegram/tsconfig.json +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { TelegramClient } from './client';
|
|
2
|
+
import type { TelegramUpdate, TelegramWebhookInfo } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface GetUpdatesOptions {
|
|
5
|
+
offset?: number;
|
|
6
|
+
limit?: number;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
allowedUpdates?: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SetWebhookOptions {
|
|
12
|
+
url: string;
|
|
13
|
+
certificate?: Uint8Array;
|
|
14
|
+
ipAddress?: string;
|
|
15
|
+
maxConnections?: number;
|
|
16
|
+
allowedUpdates?: string[];
|
|
17
|
+
dropPendingUpdates?: boolean;
|
|
18
|
+
secretToken?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DeleteWebhookOptions {
|
|
22
|
+
dropPendingUpdates?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Telegram Updates API
|
|
27
|
+
*/
|
|
28
|
+
export class UpdatesApi {
|
|
29
|
+
constructor(private readonly client: TelegramClient) {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get updates using long polling
|
|
33
|
+
*/
|
|
34
|
+
async getUpdates(options: GetUpdatesOptions = {}): Promise<TelegramUpdate[]> {
|
|
35
|
+
return this.client.request<TelegramUpdate[]>('getUpdates', {
|
|
36
|
+
params: {
|
|
37
|
+
offset: options.offset,
|
|
38
|
+
limit: options.limit,
|
|
39
|
+
timeout: options.timeout,
|
|
40
|
+
allowed_updates: options.allowedUpdates ? JSON.stringify(options.allowedUpdates) : undefined,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set webhook for receiving updates
|
|
47
|
+
*/
|
|
48
|
+
async setWebhook(options: SetWebhookOptions): Promise<boolean> {
|
|
49
|
+
if (options.certificate) {
|
|
50
|
+
return this.client.uploadFile<boolean>(
|
|
51
|
+
'setWebhook',
|
|
52
|
+
'certificate',
|
|
53
|
+
options.certificate,
|
|
54
|
+
'certificate.pem',
|
|
55
|
+
{
|
|
56
|
+
url: options.url,
|
|
57
|
+
ip_address: options.ipAddress,
|
|
58
|
+
max_connections: options.maxConnections,
|
|
59
|
+
allowed_updates: options.allowedUpdates ? JSON.stringify(options.allowedUpdates) : undefined,
|
|
60
|
+
drop_pending_updates: options.dropPendingUpdates,
|
|
61
|
+
secret_token: options.secretToken,
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return this.client.request<boolean>('setWebhook', {
|
|
67
|
+
params: {
|
|
68
|
+
url: options.url,
|
|
69
|
+
ip_address: options.ipAddress,
|
|
70
|
+
max_connections: options.maxConnections,
|
|
71
|
+
allowed_updates: options.allowedUpdates ? JSON.stringify(options.allowedUpdates) : undefined,
|
|
72
|
+
drop_pending_updates: options.dropPendingUpdates,
|
|
73
|
+
secret_token: options.secretToken,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Delete webhook and switch to long polling
|
|
80
|
+
*/
|
|
81
|
+
async deleteWebhook(options: DeleteWebhookOptions = {}): Promise<boolean> {
|
|
82
|
+
return this.client.request<boolean>('deleteWebhook', {
|
|
83
|
+
params: {
|
|
84
|
+
drop_pending_updates: options.dropPendingUpdates,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get current webhook status
|
|
91
|
+
*/
|
|
92
|
+
async getWebhookInfo(): Promise<TelegramWebhookInfo> {
|
|
93
|
+
return this.client.request<TelegramWebhookInfo>('getWebhookInfo', {
|
|
94
|
+
method: 'GET',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|