dotshare-cli 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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +253 -0
  3. package/bin/dotshare-cli.js +47 -0
  4. package/bin/dotshare-scheduler.js +208 -0
  5. package/out/analytics.js +67 -0
  6. package/out/analytics.js.map +1 -0
  7. package/out/bluesky.js +100 -0
  8. package/out/bluesky.js.map +1 -0
  9. package/out/cli/commands.js +376 -0
  10. package/out/cli/commands.js.map +1 -0
  11. package/out/cli/config.js +144 -0
  12. package/out/cli/config.js.map +1 -0
  13. package/out/credential-provider.js +92 -0
  14. package/out/credential-provider.js.map +1 -0
  15. package/out/discord.js +85 -0
  16. package/out/discord.js.map +1 -0
  17. package/out/extension.js +1383 -0
  18. package/out/extension.js.map +1 -0
  19. package/out/facebook.js +66 -0
  20. package/out/facebook.js.map +1 -0
  21. package/out/gemini.js +219 -0
  22. package/out/gemini.js.map +1 -0
  23. package/out/linkedin.js +110 -0
  24. package/out/linkedin.js.map +1 -0
  25. package/out/message-handlers.js +391 -0
  26. package/out/message-handlers.js.map +1 -0
  27. package/out/openai.js +217 -0
  28. package/out/openai.js.map +1 -0
  29. package/out/post-executor.js +168 -0
  30. package/out/post-executor.js.map +1 -0
  31. package/out/reddit.js +538 -0
  32. package/out/reddit.js.map +1 -0
  33. package/out/scheduled-posts.js +100 -0
  34. package/out/scheduled-posts.js.map +1 -0
  35. package/out/scheduler.js +98 -0
  36. package/out/scheduler.js.map +1 -0
  37. package/out/storage-manager.js +403 -0
  38. package/out/storage-manager.js.map +1 -0
  39. package/out/telegram.js +104 -0
  40. package/out/telegram.js.map +1 -0
  41. package/out/types.js +3 -0
  42. package/out/types.js.map +1 -0
  43. package/out/webview-provider.js +168 -0
  44. package/out/webview-provider.js.map +1 -0
  45. package/out/x.js +55 -0
  46. package/out/x.js.map +1 -0
  47. package/out/xai.js +235 -0
  48. package/out/xai.js.map +1 -0
  49. package/package.json +117 -0
  50. package/src/cli/commands.ts +380 -0
  51. package/src/cli/config.ts +148 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 FreeRave
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # DotShare
2
+
3
+ [![Version](https://img.shields.io/badge/version-2.0.0-blue.svg)](https://github.com/kareem2099/DotShare)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A VS Code extension that helps you share your project updates to social media using AI-powered content generation.
7
+
8
+ ## Features
9
+
10
+ - 🤖 **AI-Powered Content Generation**: Generate engaging social media posts using Gemini AI, OpenAI, or xAI
11
+ - ✏️ **Manual Post Creation**: Write and post content manually without AI assistance
12
+ - 📎 **Enhanced Media Upload**: Drag-and-drop and click-to-browse functionality for images and videos
13
+ - 🔗 **LinkedIn Integration**: Share posts directly to LinkedIn
14
+ - 📱 **Telegram Support**: Post to Telegram channels and groups
15
+ - 🐦 **X/Twitter Integration**: Post directly to X (formerly Twitter)
16
+ - 📘 **Facebook Support**: Share to Facebook profiles and pages
17
+ - 🔵 **Discord Webhooks**: Post updates to Discord channels
18
+ - 🟠 **Reddit Integration**: Submit posts to Reddit communities and user profiles (r/ and u/)
19
+ - 🌅 **BlueSky Support**: Early adopter integration with BlueSky social
20
+ - ⏰ **Scheduled Posting**: CLI tool for automated cross-platform posting
21
+ - 🌐 **Multi-language Support**: English, Arabic, and Russian
22
+ - 🎨 **Interactive UI**: Built-in webview for managing your posts with improved user experience
23
+ - 📊 **Analytics Dashboard**: Track posting performance across platforms
24
+
25
+ ## Installation
26
+
27
+ ### VS Code Extension
28
+
29
+ 1. Open VS Code
30
+ 2. Go to Extensions (Ctrl+Shift+X)
31
+ 3. Search for "DotShare"
32
+ 4. Click Install
33
+
34
+ ### CLI Scheduler
35
+
36
+ The CLI scheduler can be used independently for automated posting:
37
+
38
+ ```bash
39
+ npm install -g dotshare
40
+ dotshare-scheduler --help
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### VS Code Extension
46
+
47
+ #### Generating Posts
48
+
49
+ 1. Open your project in VS Code
50
+ 2. Use Command Palette (Ctrl+Shift+P)
51
+ 3. Run "DotShare: Generate Social Media Post with Gemini"
52
+ 4. Choose your AI provider and customize the generated content
53
+
54
+ #### Sharing Posts
55
+
56
+ - Use "DotShare: Share to LinkedIn" to post to LinkedIn
57
+ - Use "DotShare: Share to Telegram" to post to Telegram groups/channels
58
+
59
+ The extension now supports sharing to multiple platforms including:
60
+ - LinkedIn (profiles)
61
+ - Telegram (bots, channels, groups)
62
+ - X/Twitter (tweets)
63
+ - Facebook (profiles and pages)
64
+ - Discord (webhooks)
65
+ - Reddit (submissions)
66
+ - BlueSky (posts)
67
+
68
+ ### CLI Tool
69
+
70
+ The CLI provides a powerful command-line interface for social media posting.
71
+
72
+ #### Quick Start
73
+
74
+ ```bash
75
+ # Initialize CLI configuration
76
+ dotshare init
77
+
78
+ # Authenticate with platforms
79
+ dotshare login telegram
80
+ dotshare login linkedin
81
+ dotshare login reddit
82
+
83
+ # Check your setup
84
+ dotshare whoami
85
+
86
+ # Start posting!
87
+ dotshare "Hello from CLI! 🚀"
88
+ ```
89
+
90
+ #### CLI Commands
91
+
92
+ ##### `dotshare init`
93
+ Initialize CLI configuration and test server connection.
94
+ ```bash
95
+ dotshare init
96
+ ```
97
+
98
+ ##### `dotshare login <platform>`
99
+ Authenticate with social media platforms. Opens browser for OAuth flow.
100
+ ```bash
101
+ dotshare login telegram # Telegram authentication
102
+ dotshare login linkedin # LinkedIn authentication
103
+ dotshare login reddit # Reddit authentication
104
+ ```
105
+
106
+ ##### `dotshare whoami`
107
+ Show current configuration and authenticated platforms.
108
+ ```bash
109
+ dotshare whoami
110
+ ```
111
+
112
+ ##### `dotshare [message]` (Default)
113
+ Post message to all configured platforms.
114
+ ```bash
115
+ # Post text message
116
+ dotshare "🚀 Just deployed a new feature!"
117
+
118
+ # Post with media
119
+ dotshare "Beautiful sunset today 🌅" --media ./sunset.jpg
120
+
121
+ # Post to specific platforms
122
+ dotshare "Team update" --platforms telegram,linkedin
123
+
124
+ # Post media only
125
+ dotshare --media ./video.mp4
126
+ ```
127
+
128
+ #### CLI Options
129
+
130
+ - `--media <path>`: Path to media file (image/video)
131
+ - `--platforms <list>`: Comma-separated list of platforms (telegram,linkedin,reddit)
132
+
133
+ #### CLI Configuration
134
+
135
+ Configuration is stored in `~/.dotshare/config.json`:
136
+
137
+ ```json
138
+ {
139
+ "serverUrl": "https://your-railway-app.railway.app",
140
+ "credentials": {
141
+ "telegram": {
142
+ "botToken": "your_telegram_bot_token",
143
+ "chatId": "your_chat_id"
144
+ },
145
+ "linkedin": {
146
+ "accessToken": "your_linkedin_token"
147
+ },
148
+ "reddit": {
149
+ "accessToken": "your_reddit_token",
150
+ "refreshToken": "your_refresh_token"
151
+ }
152
+ },
153
+ "defaultPlatforms": ["telegram", "linkedin", "reddit"]
154
+ }
155
+ ```
156
+
157
+ ### Scheduled Posting
158
+
159
+ Use the CLI scheduler for automated cross-platform posting:
160
+
161
+ ```bash
162
+ # Run scheduler (requires config file)
163
+ npm run scheduler
164
+
165
+ # Or use the interactive CLI for manual posting
166
+ dotshare "Scheduled post content"
167
+ ```
168
+
169
+ #### CLI Troubleshooting
170
+
171
+ **"Server connection failed"**
172
+ - Make sure the Python server is running: `cd DotSharePY && python3 server.py`
173
+ - Check that the server URL is correct (default: http://localhost:3000)
174
+
175
+ **"No platforms configured"**
176
+ - Run `dotshare login <platform>` to authenticate with platforms
177
+ - Check `dotshare whoami` to see configured platforms
178
+
179
+ **"Authentication failed"**
180
+ - Verify your credentials are correct
181
+ - Check that the Python server has the right environment variables
182
+ - Try re-authenticating with `dotshare login <platform>`
183
+
184
+ **Permission Issues**
185
+ - Make sure the CLI has execute permissions: `chmod +x bin/dotshare-cli.js`
186
+ - Check file permissions for `~/.dotshare/config.json`
187
+
188
+ #### CLI Development
189
+
190
+ To modify the CLI:
191
+
192
+ 1. Edit commands in `src/cli/commands.ts`
193
+ 2. Edit config management in `src/cli/config.ts`
194
+ 3. Compile: `npm run compile`
195
+ 4. Test: `npm run cli --help`
196
+
197
+ ## Requirements
198
+
199
+ - VS Code 1.74.0 or higher
200
+ - Node.js 18.x or higher
201
+ - API keys for AI services (Gemini, OpenAI, etc.)
202
+ - API keys for social media platforms
203
+
204
+ ## Configuration
205
+
206
+ Set up your API keys in VS Code settings or environment variables:
207
+
208
+ - `dotshare.geminiApiKey`: For Gemini AI
209
+ - `dotshare.openaiApiKey`: For OpenAI
210
+ - `dotshare.xaiApiKey`: For xAI
211
+ - `dotshare.linkedinToken`: LinkedIn access token
212
+ - `dotshare.telegramBot`: Telegram bot token
213
+ - `dotshare.telegramChat`: Telegram chat ID
214
+ - `dotshare.xAccessToken`: X/Twitter access token
215
+ - `dotshare.xAccessSecret`: X/Twitter access secret
216
+ - `dotshare.facebookToken`: Facebook access token
217
+ - `dotshare.facebookPageToken`: Facebook page access token
218
+ - `dotshare.facebookPageId`: Facebook page ID
219
+ - `dotshare.discordWebhookUrl`: Discord webhook URL
220
+ - `dotshare.redditClientId`: Reddit client ID
221
+ - `dotshare.redditClientSecret`: Reddit client secret
222
+ - `dotshare.redditAccessToken`: Reddit access token
223
+ - `dotshare.redditRefreshToken`: Reddit refresh token
224
+ - `dotshare.blueskyIdentifier`: BlueSky username/handle
225
+ - `dotshare.blueskyPassword`: BlueSky app password
226
+
227
+ ## Development
228
+
229
+ ```bash
230
+ git clone https://github.com/kareem2099/DotShare.git
231
+ cd DotShare
232
+ npm install
233
+ npm run compile
234
+ # Press F5 in VS Code to test
235
+ ```
236
+
237
+ ## Contributing
238
+
239
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
240
+
241
+ ## Changelog
242
+
243
+ See [CHANGELOG.md](CHANGELOG.md) for the latest updates.
244
+
245
+ ## License
246
+
247
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
248
+
249
+ ## Support
250
+
251
+ - 📧 Create an issue on GitHub
252
+ - � Get your Telegram User ID using [FreeID Bot](https://github.com/kareem2099/FreeID)
253
+ - �💝 Support the project: [GitHub Sponsors](https://github.com/sponsors/kareem2099)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * DotShare CLI - Interactive command-line interface for social media posting
5
+ * Usage: dotshare [command] [options]
6
+ */
7
+
8
+ const { Command } = require('commander');
9
+ const { setupInitCommand, setupLoginCommand, setupWhoamiCommand, setupDefaultCommand } = require('../out/cli/commands.js');
10
+
11
+ const program = new Command();
12
+
13
+ // CLI metadata
14
+ program
15
+ .name('dotshare')
16
+ .description('DotShare CLI - Post to social media platforms')
17
+ .version('1.0.0')
18
+ .option('-v, --verbose', 'Enable verbose output');
19
+
20
+ // Setup all commands
21
+ setupInitCommand(program);
22
+ setupLoginCommand(program);
23
+ setupWhoamiCommand(program);
24
+ setupDefaultCommand(program);
25
+
26
+ // Add help examples
27
+ program.addHelpText('after', `
28
+ Examples:
29
+ $ dotshare init # Initialize CLI configuration
30
+ $ dotshare login telegram # Authenticate with Telegram
31
+ $ dotshare login linkedin # Authenticate with LinkedIn
32
+ $ dotshare login reddit # Authenticate with Reddit
33
+ $ dotshare whoami # Show current configuration
34
+ $ dotshare "Hello World!" # Post to all configured platforms
35
+ $ dotshare --media ./image.jpg # Post media file
36
+ $ dotshare "Check this" --media ./video.mp4 --platforms telegram,linkedin
37
+
38
+ For more information, visit: https://github.com/kareem2099/DotShare
39
+ `);
40
+
41
+ // Handle no arguments - show help
42
+ if (process.argv.length === 2) {
43
+ program.help();
44
+ }
45
+
46
+ // Parse arguments
47
+ program.parse(process.argv);
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * DotShare CLI Scheduler
5
+ * Runs scheduled posts independently of VS Code
6
+ * Usage: node bin/dotshare-scheduler.js [--config config.json]
7
+ */
8
+
9
+ // MUST set up mocking BEFORE any other imports/requires
10
+ const mockVscode = {
11
+ window: null, // This makes isVscodeEnvironment = false
12
+ Uri: null,
13
+ env: null
14
+ };
15
+
16
+ // Override require globally to intercept 'vscode' imports
17
+ const Module = require('module');
18
+ const originalResolveFilename = Module._resolveFilename;
19
+ const originalLoad = Module._load;
20
+
21
+ // Override the module resolution
22
+ Module._load = function(request) {
23
+ if (request === 'vscode') {
24
+ return mockVscode;
25
+ }
26
+ return originalLoad.apply(this, arguments);
27
+ };
28
+
29
+ // Also override resolve to prevent filesystem lookup
30
+ Module._resolveFilename = function(request) {
31
+ if (request === 'vscode') {
32
+ return 'vscode';
33
+ }
34
+ return originalResolveFilename.apply(this, arguments);
35
+ };
36
+
37
+ // Cache the mocked module
38
+ require.cache['vscode'] = {
39
+ id: 'vscode',
40
+ filename: 'vscode',
41
+ loaded: true,
42
+ exports: mockVscode
43
+ };
44
+
45
+ // Now we can import safely
46
+ const fs = require('fs');
47
+ const path = require('path');
48
+
49
+ // Now require the modules after mocking vscode
50
+ const { Scheduler } = require('../out/scheduler.js');
51
+
52
+ // Default config location
53
+ const DEFAULT_CONFIG_PATH = path.join(require('os').homedir(), '.dotshare-config.json');
54
+
55
+ // Parse command line arguments
56
+ function parseArgs() {
57
+ const args = process.argv.slice(2);
58
+ let configPath = DEFAULT_CONFIG_PATH;
59
+
60
+ for (let i = 0; i < args.length; i++) {
61
+ if (args[i] === '--config' && i + 1 < args.length) {
62
+ configPath = args[i + 1];
63
+ i++;
64
+ } else if (args[i] === '--help' || args[i] === '-h') {
65
+ showHelp();
66
+ process.exit(0);
67
+ }
68
+ }
69
+
70
+ return { configPath };
71
+ }
72
+
73
+ function showHelp() {
74
+ console.log(`
75
+ DotShare CLI Scheduler
76
+
77
+ Runs scheduled social media posts independently of VS Code.
78
+
79
+ USAGE:
80
+ node bin/dotshare-scheduler.js [OPTIONS]
81
+
82
+ OPTIONS:
83
+ --config PATH Path to config file (default: ~/.dotshare-config.json)
84
+ --help, -h Show this help message
85
+
86
+ CONFIG FILE FORMAT:
87
+ {
88
+ "storagePath": "/home/user/.config/Code/User/globalStorage/freerave.dotshare",
89
+ "credentials": {
90
+ "linkedinToken": "your_linkedin_token_here",
91
+ "telegramBot": "your_telegram_bot_token",
92
+ "telegramChat": "your_telegram_chat_id",
93
+ "xAccessToken": "your_x_access_token",
94
+ "xAccessSecret": "your_x_access_secret",
95
+ "facebookToken": "your_facebook_token",
96
+ "facebookPageToken": "your_facebook_page_token",
97
+ "facebookPageId": "your_facebook_page_id",
98
+ "discordWebhookUrl": "your_discord_webhook_url",
99
+ "redditAccessToken": "your_reddit_access_token",
100
+ "redditRefreshToken": "your_reddit_refresh_token",
101
+ "blueskyIdentifier": "your_bluesky_handle",
102
+ "blueskyPassword": "your_bluesky_password"
103
+ }
104
+ }
105
+
106
+ EXAMPLE CRON SETUP (Linux/Mac):
107
+ # Check every 5 minutes
108
+ */5 * * * * cd /path/to/dotshare && /usr/bin/node bin/dotshare-scheduler.js
109
+
110
+ # Check every minute
111
+ * * * * * cd /path/to/dotshare && /usr/bin/node bin/dotshare-scheduler.js
112
+ `);
113
+ }
114
+
115
+ // Load configuration from file
116
+ function loadConfig(configPath) {
117
+ try {
118
+ if (!fs.existsSync(configPath)) {
119
+ console.error(`Config file not found: ${configPath}`);
120
+ console.error('Please create the config file with your credentials.');
121
+ console.error('Run with --help for config file format.');
122
+ process.exit(1);
123
+ }
124
+
125
+ const configData = fs.readFileSync(configPath, 'utf8');
126
+ const config = JSON.parse(configData);
127
+
128
+ if (!config.storagePath) {
129
+ console.error('Config error: storagePath is required');
130
+ process.exit(1);
131
+ }
132
+
133
+ if (!config.credentials) {
134
+ config.credentials = {};
135
+ }
136
+
137
+ return config;
138
+ } catch (error) {
139
+ console.error('Error loading config:', error.message);
140
+ process.exit(1);
141
+ }
142
+ }
143
+
144
+ // Create credentials getter that uses the static credentials from config
145
+ function createCredentialsGetter(credentials) {
146
+ return async () => ({
147
+ linkedinToken: credentials.linkedinToken,
148
+ telegramBot: credentials.telegramBot,
149
+ telegramChat: credentials.telegramChat,
150
+ xAccessToken: credentials.xAccessToken,
151
+ xAccessSecret: credentials.xAccessSecret,
152
+ facebookToken: credentials.facebookToken,
153
+ facebookPageToken: credentials.facebookPageToken,
154
+ facebookPageId: credentials.facebookPageId,
155
+ discordWebhookUrl: credentials.discordWebhookUrl,
156
+ redditAccessToken: credentials.redditAccessToken,
157
+ redditRefreshToken: credentials.redditRefreshToken,
158
+ blueskyIdentifier: credentials.blueskyIdentifier,
159
+ blueskyPassword: credentials.blueskyPassword
160
+ });
161
+ }
162
+
163
+ // Main function
164
+ async function main() {
165
+ console.log('🚀 Starting DotShare CLI Scheduler...\n');
166
+
167
+ const args = parseArgs();
168
+ const config = loadConfig(args.configPath);
169
+
170
+ console.log(`📂 Using storage path: ${config.storagePath}`);
171
+ console.log('🔐 Credentials loaded');
172
+
173
+ // Create logger callbacks for CLI
174
+ const loggerCallbacks = {
175
+ onSuccess: (message) => console.log(`✅ ${message}`),
176
+ onError: (message) => console.error(`❌ ${message}`),
177
+ onOpenLink: (url) => console.log(`🔗 Link prepared: ${url}`)
178
+ };
179
+
180
+ // Create scheduler with credentials getter
181
+ const credentialsGetter = createCredentialsGetter(config.credentials || {});
182
+ const scheduler = new Scheduler(config.storagePath, undefined, credentialsGetter, loggerCallbacks);
183
+
184
+ console.log('⏰ Starting scheduler...\n');
185
+
186
+ // Start the scheduler
187
+ scheduler.start();
188
+
189
+ // Keep the process running
190
+ process.on('SIGINT', () => {
191
+ console.log('\n⏹️ Stopping scheduler...');
192
+ scheduler.stop();
193
+ process.exit(0);
194
+ });
195
+
196
+ process.on('SIGTERM', () => {
197
+ console.log('\n⏹️ Stopping scheduler...');
198
+ scheduler.stop();
199
+ process.exit(0);
200
+ });
201
+ }
202
+
203
+ // Run main function
204
+ main().catch(error => {
205
+ console.error('❌ Error:', error.message);
206
+ console.error(error.stack);
207
+ process.exit(1);
208
+ });
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Analytics = void 0;
4
+ class Analytics {
5
+ calculateAnalytics(history) {
6
+ const totalPosts = history.length;
7
+ let successfulShares = 0;
8
+ let failedShares = 0;
9
+ let linkedinShares = 0;
10
+ let telegramShares = 0;
11
+ let xShares = 0;
12
+ let facebookShares = 0;
13
+ let discordShares = 0;
14
+ let redditShares = 0;
15
+ let blueskyShares = 0;
16
+ for (const post of history) {
17
+ for (const share of post.shares) {
18
+ switch (share.platform) {
19
+ case 'linkedin':
20
+ linkedinShares++;
21
+ break;
22
+ case 'telegram':
23
+ telegramShares++;
24
+ break;
25
+ case 'x':
26
+ xShares++;
27
+ break;
28
+ case 'facebook':
29
+ facebookShares++;
30
+ break;
31
+ case 'discord':
32
+ discordShares++;
33
+ break;
34
+ case 'reddit':
35
+ redditShares++;
36
+ break;
37
+ case 'bluesky':
38
+ blueskyShares++;
39
+ break;
40
+ }
41
+ if (share.success) {
42
+ successfulShares++;
43
+ }
44
+ else {
45
+ failedShares++;
46
+ }
47
+ }
48
+ }
49
+ const totalShares = successfulShares + failedShares;
50
+ const successRate = totalShares > 0 ? Math.round((successfulShares / totalShares) * 100) : 0;
51
+ return {
52
+ totalPosts,
53
+ successfulShares,
54
+ failedShares,
55
+ linkedinShares,
56
+ telegramShares,
57
+ xShares,
58
+ facebookShares,
59
+ discordShares,
60
+ redditShares,
61
+ blueskyShares,
62
+ successRate
63
+ };
64
+ }
65
+ }
66
+ exports.Analytics = Analytics;
67
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IACX,kBAAkB,CAAC,OAAyB;QAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAClC,IAAI,gBAAgB,GAAG,CAAC,CAAC;QACzB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAI,aAAa,GAAG,CAAC,CAAC;QAEtB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YACxB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC7B,QAAQ,KAAK,CAAC,QAAQ,EAAE;oBACpB,KAAK,UAAU;wBAAE,cAAc,EAAE,CAAC;wBAAC,MAAM;oBACzC,KAAK,UAAU;wBAAE,cAAc,EAAE,CAAC;wBAAC,MAAM;oBACzC,KAAK,GAAG;wBAAE,OAAO,EAAE,CAAC;wBAAC,MAAM;oBAC3B,KAAK,UAAU;wBAAE,cAAc,EAAE,CAAC;wBAAC,MAAM;oBACzC,KAAK,SAAS;wBAAE,aAAa,EAAE,CAAC;wBAAC,MAAM;oBACvC,KAAK,QAAQ;wBAAE,YAAY,EAAE,CAAC;wBAAC,MAAM;oBACrC,KAAK,SAAS;wBAAE,aAAa,EAAE,CAAC;wBAAC,MAAM;iBAC1C;gBAED,IAAI,KAAK,CAAC,OAAO,EAAE;oBACf,gBAAgB,EAAE,CAAC;iBACtB;qBAAM;oBACH,YAAY,EAAE,CAAC;iBAClB;aACJ;SACJ;QAED,MAAM,WAAW,GAAG,gBAAgB,GAAG,YAAY,CAAC;QACpD,MAAM,WAAW,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE7F,OAAO;YACH,UAAU;YACV,gBAAgB;YAChB,YAAY;YACZ,cAAc;YACd,cAAc;YACd,OAAO;YACP,cAAc;YACd,aAAa;YACb,YAAY;YACZ,aAAa;YACb,WAAW;SACd,CAAC;IACN,CAAC;CACJ;AAlDD,8BAkDC"}
package/out/bluesky.js ADDED
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.refreshBlueSkySession = exports.validateBlueSkyCredentials = exports.authenticateBlueSky = exports.shareToBlueSky = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ async function shareToBlueSky(identifier, password, postData) {
9
+ try {
10
+ // First, authenticate and get session
11
+ const session = await authenticateBlueSky(identifier, password);
12
+ const headers = {
13
+ 'Authorization': `Bearer ${session.accessJwt}`,
14
+ 'Content-Type': 'application/json'
15
+ };
16
+ const postPayload = {
17
+ collection: 'app.bsky.feed.post',
18
+ repo: session.did,
19
+ record: {
20
+ text: postData.text,
21
+ createdAt: new Date().toISOString(),
22
+ $type: 'app.bsky.feed.post'
23
+ }
24
+ };
25
+ // Handle media attachments (BlueSky supports images)
26
+ if (postData.media && postData.media.length > 0) {
27
+ for (const mediaFile of postData.media) {
28
+ // Note: This is simplified - actual implementation requires uploading blobs
29
+ // BlueSky requires media to be uploaded as blobs first
30
+ console.log(`Media upload for BlueSky not fully implemented yet: ${mediaFile}`);
31
+ // For now, just add as external links if they're URLs
32
+ if (mediaFile.startsWith('http')) {
33
+ // Could add as link card, but that requires separate API call
34
+ postPayload.record.text += `\n\n${mediaFile}`;
35
+ }
36
+ }
37
+ }
38
+ const response = await axios_1.default.post(`https://bsky.social/xrpc/com.atproto.repo.createRecord`, postPayload, { headers });
39
+ return response.data.uri; // AT URI of the created post
40
+ }
41
+ catch (error) {
42
+ const errorMessage = error instanceof Error ? error.message : String(error);
43
+ const axiosError = error;
44
+ const apiMessage = axiosError.response?.data?.message;
45
+ console.error('Error posting to BlueSky:', apiMessage || errorMessage);
46
+ throw new Error(apiMessage || 'Failed to post to BlueSky');
47
+ }
48
+ }
49
+ exports.shareToBlueSky = shareToBlueSky;
50
+ async function authenticateBlueSky(identifier, password) {
51
+ try {
52
+ const response = await axios_1.default.post('https://bsky.social/xrpc/com.atproto.server.createSession', {
53
+ identifier,
54
+ password
55
+ });
56
+ return {
57
+ accessJwt: response.data.accessJwt,
58
+ refreshJwt: response.data.refreshJwt,
59
+ did: response.data.did
60
+ };
61
+ }
62
+ catch (error) {
63
+ const errorMessage = error instanceof Error ? error.message : String(error);
64
+ const axiosError = error;
65
+ const apiMessage = axiosError.response?.data?.message;
66
+ console.error('Error authenticating with BlueSky:', apiMessage || errorMessage);
67
+ throw new Error(apiMessage || 'Failed to authenticate with BlueSky');
68
+ }
69
+ }
70
+ exports.authenticateBlueSky = authenticateBlueSky;
71
+ async function validateBlueSkyCredentials(identifier, password) {
72
+ try {
73
+ await authenticateBlueSky(identifier, password);
74
+ return true;
75
+ }
76
+ catch (error) {
77
+ return false;
78
+ }
79
+ }
80
+ exports.validateBlueSkyCredentials = validateBlueSkyCredentials;
81
+ async function refreshBlueSkySession(refreshToken) {
82
+ try {
83
+ const response = await axios_1.default.post('https://bsky.social/xrpc/com.atproto.server.refreshSession', {}, {
84
+ headers: {
85
+ 'Authorization': `Bearer ${refreshToken}`
86
+ }
87
+ });
88
+ return {
89
+ accessJwt: response.data.accessJwt,
90
+ refreshJwt: response.data.refreshJwt,
91
+ did: response.data.did
92
+ };
93
+ }
94
+ catch (error) {
95
+ console.error('Error refreshing BlueSky session:', error);
96
+ throw new Error('Failed to refresh BlueSky session');
97
+ }
98
+ }
99
+ exports.refreshBlueSkySession = refreshBlueSkySession;
100
+ //# sourceMappingURL=bluesky.js.map