@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
package/bin/index.js
CHANGED
|
@@ -12361,7 +12361,7 @@ var PRESETS = {
|
|
|
12361
12361
|
commerce: { description: "Commerce and finance", connectors: ["stripe", "shopify", "revolut", "mercury", "pandadoc"] }
|
|
12362
12362
|
};
|
|
12363
12363
|
var program2 = new Command;
|
|
12364
|
-
program2.name("connectors").description("Install API connectors for your project").version("1.1.
|
|
12364
|
+
program2.name("connectors").description("Install API connectors for your project").version("1.1.6").enablePositionalOptions();
|
|
12365
12365
|
program2.command("interactive", { isDefault: true }).alias("i").description("Interactive connector browser").action(() => {
|
|
12366
12366
|
if (!isTTY) {
|
|
12367
12367
|
console.log(`Non-interactive environment detected. Use a subcommand:
|
package/bin/mcp.js
CHANGED
|
@@ -25829,7 +25829,7 @@ async function getConnectorCommandHelp(name, command) {
|
|
|
25829
25829
|
loadConnectorVersions();
|
|
25830
25830
|
var server = new McpServer({
|
|
25831
25831
|
name: "connectors",
|
|
25832
|
-
version: "1.1.
|
|
25832
|
+
version: "1.1.6"
|
|
25833
25833
|
});
|
|
25834
25834
|
server.registerTool("search_connectors", {
|
|
25835
25835
|
title: "Search Connectors",
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import type { GmailClient } from './client';
|
|
4
|
+
import type { GmailMessage, MessagePart } from '../types';
|
|
5
|
+
import { getConfigDir } from '../utils/config';
|
|
6
|
+
|
|
7
|
+
export interface AttachmentInfo {
|
|
8
|
+
attachmentId: string;
|
|
9
|
+
filename: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
size: number;
|
|
12
|
+
partId: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AttachmentData {
|
|
16
|
+
data: string; // base64 encoded
|
|
17
|
+
size: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DownloadedAttachment {
|
|
21
|
+
filename: string;
|
|
22
|
+
path: string;
|
|
23
|
+
size: number;
|
|
24
|
+
mimeType: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class AttachmentsApi {
|
|
28
|
+
private client: GmailClient;
|
|
29
|
+
|
|
30
|
+
constructor(client: GmailClient) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the attachments directory for a specific message
|
|
36
|
+
*/
|
|
37
|
+
private getAttachmentsDir(messageId: string): string {
|
|
38
|
+
const dir = join(getConfigDir(), 'attachments', messageId);
|
|
39
|
+
if (!existsSync(dir)) {
|
|
40
|
+
mkdirSync(dir, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
return dir;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extract attachment info from a message part recursively
|
|
47
|
+
*/
|
|
48
|
+
private extractAttachments(part: MessagePart, attachments: AttachmentInfo[] = []): AttachmentInfo[] {
|
|
49
|
+
// Check if this part is an attachment
|
|
50
|
+
if (part.body?.attachmentId && part.filename) {
|
|
51
|
+
attachments.push({
|
|
52
|
+
attachmentId: part.body.attachmentId,
|
|
53
|
+
filename: part.filename,
|
|
54
|
+
mimeType: part.mimeType,
|
|
55
|
+
size: part.body.size,
|
|
56
|
+
partId: part.partId,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Recursively check nested parts
|
|
61
|
+
if (part.parts) {
|
|
62
|
+
for (const subpart of part.parts) {
|
|
63
|
+
this.extractAttachments(subpart, attachments);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return attachments;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* List all attachments in a message
|
|
72
|
+
*/
|
|
73
|
+
async list(messageId: string): Promise<AttachmentInfo[]> {
|
|
74
|
+
const message = await this.client.get<GmailMessage>(
|
|
75
|
+
`/users/${this.client.getUserId()}/messages/${messageId}`,
|
|
76
|
+
{ format: 'full' }
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (!message.payload) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this.extractAttachments(message.payload);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get attachment data by attachment ID
|
|
88
|
+
*/
|
|
89
|
+
async get(messageId: string, attachmentId: string): Promise<AttachmentData> {
|
|
90
|
+
return this.client.get<AttachmentData>(
|
|
91
|
+
`/users/${this.client.getUserId()}/messages/${messageId}/attachments/${attachmentId}`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Download a specific attachment to disk
|
|
97
|
+
*/
|
|
98
|
+
async download(messageId: string, attachmentId: string, filename: string, mimeType: string): Promise<DownloadedAttachment> {
|
|
99
|
+
// Normalize Unicode whitespace characters in filename (e.g. non-breaking spaces from Gmail)
|
|
100
|
+
const cleanFilename = filename.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, ' ');
|
|
101
|
+
const data = await this.get(messageId, attachmentId);
|
|
102
|
+
const dir = this.getAttachmentsDir(messageId);
|
|
103
|
+
const filepath = join(dir, cleanFilename);
|
|
104
|
+
|
|
105
|
+
// Decode base64url to buffer
|
|
106
|
+
const buffer = Buffer.from(data.data, 'base64url');
|
|
107
|
+
writeFileSync(filepath, buffer);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
filename: cleanFilename,
|
|
111
|
+
path: filepath,
|
|
112
|
+
size: buffer.length,
|
|
113
|
+
mimeType,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Download all attachments from a message
|
|
119
|
+
*/
|
|
120
|
+
async downloadAll(messageId: string): Promise<DownloadedAttachment[]> {
|
|
121
|
+
const attachments = await this.list(messageId);
|
|
122
|
+
const downloaded: DownloadedAttachment[] = [];
|
|
123
|
+
|
|
124
|
+
for (const attachment of attachments) {
|
|
125
|
+
const result = await this.download(
|
|
126
|
+
messageId,
|
|
127
|
+
attachment.attachmentId,
|
|
128
|
+
attachment.filename,
|
|
129
|
+
attachment.mimeType
|
|
130
|
+
);
|
|
131
|
+
downloaded.push(result);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return downloaded;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get the path where attachments for a message are/would be stored
|
|
139
|
+
*/
|
|
140
|
+
getStoragePath(messageId: string): string {
|
|
141
|
+
return this.getAttachmentsDir(messageId);
|
|
142
|
+
}
|
|
143
|
+
}
|