postiz 2.0.12 → 2.1.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/README.md CHANGED
@@ -18,9 +18,30 @@ pnpm install -g postiz
18
18
 
19
19
  ---
20
20
 
21
- ## Setup
21
+ ## Authentication
22
22
 
23
- **Required:** Set your Postiz API key
23
+ ### Option 1: OAuth2 (Recommended)
24
+
25
+ Authenticate using the device flow — no client ID or secret needed:
26
+
27
+ ```bash
28
+ postiz auth:login
29
+ ```
30
+
31
+ This will:
32
+ 1. Display a one-time code in your terminal
33
+ 2. Open your browser to authorize
34
+ 3. Automatically save credentials to `~/.postiz/credentials.json`
35
+
36
+ ```bash
37
+ # Check current auth status (verifies credentials are still valid)
38
+ postiz auth:status
39
+
40
+ # Remove stored credentials
41
+ postiz auth:logout
42
+ ```
43
+
44
+ ### Option 2: API Key
24
45
 
25
46
  ```bash
26
47
  export POSTIZ_API_KEY=your_api_key_here
@@ -32,6 +53,8 @@ export POSTIZ_API_KEY=your_api_key_here
32
53
  export POSTIZ_API_URL=https://your-custom-api.com
33
54
  ```
34
55
 
56
+ > **Note:** OAuth2 credentials take priority over the API key when both are present.
57
+
35
58
  ---
36
59
 
37
60
  ## Commands
@@ -526,8 +549,11 @@ The CLI interacts with these Postiz API endpoints:
526
549
 
527
550
  | Variable | Required | Default | Description |
528
551
  |----------|----------|---------|-------------|
529
- | `POSTIZ_API_KEY` | Yes | - | Your Postiz API key |
552
+ | `POSTIZ_API_KEY` | No* | - | Your Postiz API key |
530
553
  | `POSTIZ_API_URL` | No | `https://api.postiz.com` | Custom API endpoint |
554
+ | `POSTIZ_AUTH_SERVER` | No | `https://cli-auth.postiz.com` | Custom auth server URL |
555
+
556
+ *Either OAuth2 (via `postiz auth:login`) or `POSTIZ_API_KEY` is required.
531
557
 
532
558
  ---
533
559
 
@@ -542,7 +568,7 @@ The CLI provides clear error messages with exit codes:
542
568
 
543
569
  | Error | Solution |
544
570
  |-------|----------|
545
- | `POSTIZ_API_KEY is not set` | Set environment variable: `export POSTIZ_API_KEY=key` |
571
+ | `Not authenticated` | Run `postiz auth:login` or set `POSTIZ_API_KEY` |
546
572
  | `Integration not found` | Run `integrations:list` to get valid IDs |
547
573
  | `startDate/endDate required` | Use ISO 8601 format: `"2024-12-31T12:00:00Z"` |
548
574
  | `Invalid settings` | Check `integrations:settings` for required fields |
@@ -560,8 +586,9 @@ The CLI provides clear error messages with exit codes:
560
586
  src/
561
587
  ├── index.ts # CLI entry point with yargs
562
588
  ├── api.ts # PostizAPI client class
563
- ├── config.ts # Environment configuration
589
+ ├── config.ts # Configuration (OAuth2 + API key)
564
590
  └── commands/
591
+ ├── auth.ts # OAuth2 authentication (login/logout/status)
565
592
  ├── posts.ts # Post management commands
566
593
  ├── integrations.ts # Integration commands
567
594
  ├── analytics.ts # Analytics commands
@@ -599,8 +626,11 @@ Output in `dist/`:
599
626
  ## Quick Reference
600
627
 
601
628
  ```bash
602
- # Environment setup
603
- export POSTIZ_API_KEY=your_key
629
+ # Authentication
630
+ postiz auth:login # OAuth2 device flow
631
+ postiz auth:status # Check auth
632
+ postiz auth:logout # Remove credentials
633
+ export POSTIZ_API_KEY=your_key # Or use API key
604
634
 
605
635
  # Discovery
606
636
  postiz integrations:list # List integrations
package/SKILL.md CHANGED
@@ -2,7 +2,7 @@
2
2
  name: postiz
3
3
  description: Postiz is a tool to schedule social media and chat posts to 28+ channels X, LinkedIn, LinkedIn Page, Reddit, Instagram, Facebook Page, Threads, YouTube, Google My Business, TikTok, Pinterest, Dribbble, Discord, Slack, Kick, Twitch, Mastodon, Bluesky, Lemmy, Farcaster, Telegram, Nostr, VK, Medium, Dev.to, Hashnode, WordPress, ListMonk
4
4
  homepage: https://docs.postiz.com/public-api/introduction
5
- metadata: {"clawdbot":{"emoji":"🌎","requires":{"bins":[],"env":["POSTIZ_API_URL","POSTIZ_API_KEY"]}}}
5
+ metadata: {"openclaw":{"emoji":"🌎","requires":{"bins":[],"env":["POSTIZ_API_URL"]}}}
6
6
  ---
7
7
 
8
8
  ## Install Postiz if it doesn't exist
@@ -28,36 +28,58 @@ official website: https://postiz.com
28
28
 
29
29
  ---
30
30
 
31
+ ## ⚠️ Authentication Required
32
+
33
+ **You MUST authenticate before running any Postiz CLI command.** All commands will fail without valid credentials.
34
+
35
+ Before doing anything else, check auth status:
36
+ ```bash
37
+ postiz auth:status
38
+ ```
39
+
40
+ If not authenticated, either:
41
+ 1. **OAuth2:** `postiz auth:login`
42
+ 2. **API Key:** `export POSTIZ_API_KEY=your_api_key`
43
+
44
+ **Do NOT proceed with any other commands until authentication is confirmed.**
45
+
46
+ ---
47
+
31
48
  ## Core Workflow
32
49
 
33
50
  The fundamental pattern for using Postiz CLI:
34
51
 
35
- 1. **Discover** - List integrations and get their settings
36
- 2. **Fetch** - Use integration tools to retrieve dynamic data (flairs, playlists, companies)
37
- 3. **Prepare** - Upload media files if needed
38
- 4. **Post** - Create posts with content, media, and platform-specific settings
39
- 5. **Analyze** - Track performance with platform and post-level analytics
40
- 6. **Resolve** - If analytics returns `{"missing": true}`, run `posts:missing` to list provider content, then `posts:connect` to link it
52
+ 1. **Authenticate** - Verify or set up authentication (see above)
53
+ 2. **Discover** - List integrations and get their settings
54
+ 3. **Fetch** - Use integration tools to retrieve dynamic data (flairs, playlists, companies)
55
+ 4. **Prepare** - Upload media files if needed
56
+ 5. **Post** - Create posts with content, media, and platform-specific settings
57
+ 6. **Analyze** - Track performance with platform and post-level analytics
58
+ 7. **Resolve** - If analytics returns `{"missing": true}`, run `posts:missing` to list provider content, then `posts:connect` to link it
41
59
 
42
60
  ```bash
43
- # 1. Discover
61
+ # 1. Authenticate
62
+ postiz auth:status
63
+ # If not authenticated: postiz auth:login --client-id <id> --client-secret <secret>
64
+
65
+ # 2. Discover
44
66
  postiz integrations:list
45
67
  postiz integrations:settings <integration-id>
46
68
 
47
- # 2. Fetch (if needed)
69
+ # 3. Fetch (if needed)
48
70
  postiz integrations:trigger <integration-id> <method> -d '{"key":"value"}'
49
71
 
50
- # 3. Prepare
72
+ # 4. Prepare
51
73
  postiz upload image.jpg
52
74
 
53
- # 4. Post
75
+ # 5. Post
54
76
  postiz posts:create -c "Content" -m "image.jpg" -i "<integration-id>"
55
77
 
56
- # 5. Analyze
78
+ # 6. Analyze
57
79
  postiz analytics:platform <integration-id> -d 30
58
80
  postiz analytics:post <post-id> -d 7
59
81
 
60
- # 6. Resolve (if analytics returns {"missing": true})
82
+ # 7. Resolve (if analytics returns {"missing": true})
61
83
  postiz posts:missing <post-id>
62
84
  postiz posts:connect <post-id> --release-id "<content-id>"
63
85
  ```
@@ -66,13 +88,29 @@ postiz posts:connect <post-id> --release-id "<content-id>"
66
88
 
67
89
  ## Essential Commands
68
90
 
69
- ### Setup
91
+ ### Authentication
70
92
 
93
+ **Option 1: OAuth2 (Recommended)**
94
+ ```bash
95
+ # Login via device flow (opens browser, no client ID/secret needed)
96
+ postiz auth:login
97
+
98
+ # Check auth status (verifies credentials are still valid)
99
+ postiz auth:status
100
+
101
+ # Logout (remove stored credentials)
102
+ postiz auth:logout
103
+ ```
104
+
105
+ Credentials are stored in `~/.postiz/credentials.json`. OAuth2 credentials take priority over API key.
106
+
107
+ **Option 2: API Key**
71
108
  ```bash
72
- # Required environment variable
73
109
  export POSTIZ_API_KEY=your_api_key_here
110
+ ```
74
111
 
75
- # Optional custom API URL
112
+ **Optional custom API URL:**
113
+ ```bash
76
114
  export POSTIZ_API_URL=https://custom-api-url.com
77
115
  ```
78
116
 
@@ -654,7 +692,7 @@ https://clawhub.ai/nevo-david/agent-media
654
692
 
655
693
  ## Common Gotchas
656
694
 
657
- 1. **API Key not set** - Always `export POSTIZ_API_KEY=key` before using CLI
695
+ 1. **Not authenticated** - Run `postiz auth:login` or `export POSTIZ_API_KEY=key` before using CLI
658
696
  2. **Invalid integration ID** - Run `integrations:list` to get current IDs
659
697
  3. **Settings schema mismatch** - Check `integrations:settings` for required fields
660
698
  4. **Media MUST be uploaded to Postiz first** - ⚠️ **CRITICAL:** TikTok, Instagram, YouTube, and many platforms only accept verified URLs. Upload files via `postiz upload` first, then use the returned URL in `-m`. External URLs will be rejected!
@@ -671,10 +709,13 @@ https://clawhub.ai/nevo-david/agent-media
671
709
  ## Quick Reference
672
710
 
673
711
  ```bash
674
- # Environment
675
- export POSTIZ_API_KEY=key
712
+ # ⚠️ AUTHENTICATE FIRST - required before any other command
713
+ postiz auth:status # Check if authenticated
714
+ postiz auth:login # OAuth2 device flow login
715
+ postiz auth:logout # Remove credentials
716
+ export POSTIZ_API_KEY=key # Or use API key
676
717
 
677
- # Discovery
718
+ # Discovery (only after auth is confirmed)
678
719
  postiz integrations:list # Get integration IDs
679
720
  postiz integrations:settings <id> # Get settings schema
680
721
  postiz integrations:trigger <id> <method> -d '{}' # Fetch dynamic data
package/dist/index.js CHANGED
@@ -190,13 +190,207 @@ var PostizAPI = class {
190
190
  }
191
191
  };
192
192
 
193
+ // src/commands/auth.ts
194
+ var import_fs = require("fs");
195
+ var import_path = require("path");
196
+ var import_os = require("os");
197
+ var import_node_fetch2 = __toESM(require("node-fetch"));
198
+ var CREDENTIALS_DIR = (0, import_path.join)((0, import_os.homedir)(), ".postiz");
199
+ var CREDENTIALS_FILE = (0, import_path.join)(CREDENTIALS_DIR, "credentials.json");
200
+ var DEFAULT_AUTH_SERVER = "https://cli-auth.postiz.com";
201
+ function loadCredentials() {
202
+ try {
203
+ if (!(0, import_fs.existsSync)(CREDENTIALS_FILE)) return null;
204
+ const data = JSON.parse((0, import_fs.readFileSync)(CREDENTIALS_FILE, "utf-8"));
205
+ if (!data.accessToken) return null;
206
+ return data;
207
+ } catch (e) {
208
+ return null;
209
+ }
210
+ }
211
+ function saveCredentials(credentials) {
212
+ if (!(0, import_fs.existsSync)(CREDENTIALS_DIR)) {
213
+ (0, import_fs.mkdirSync)(CREDENTIALS_DIR, { recursive: true, mode: 448 });
214
+ }
215
+ (0, import_fs.writeFileSync)(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2), { encoding: "utf-8", mode: 384 });
216
+ (0, import_fs.chmodSync)(CREDENTIALS_FILE, 384);
217
+ }
218
+ function deleteCredentials() {
219
+ if ((0, import_fs.existsSync)(CREDENTIALS_FILE)) {
220
+ (0, import_fs.unlinkSync)(CREDENTIALS_FILE);
221
+ }
222
+ }
223
+ function openBrowser(url) {
224
+ const { exec } = require("child_process");
225
+ const platform = process.platform;
226
+ if (platform === "darwin") {
227
+ exec(`open "${url}"`);
228
+ } else if (platform === "win32") {
229
+ exec(`start "" "${url}"`);
230
+ } else {
231
+ exec(`xdg-open "${url}"`);
232
+ }
233
+ }
234
+ function sleep(ms) {
235
+ return new Promise((resolve) => setTimeout(resolve, ms));
236
+ }
237
+ async function authLogin(argv) {
238
+ const authServer = argv.authServer || process.env.POSTIZ_AUTH_SERVER || DEFAULT_AUTH_SERVER;
239
+ console.log("\u{1F510} Starting device authorization flow...\n");
240
+ let deviceCode;
241
+ let userCode;
242
+ let verificationUri;
243
+ let expiresIn;
244
+ let interval;
245
+ try {
246
+ const response = await (0, import_node_fetch2.default)(`${authServer}/device/code`, {
247
+ method: "POST",
248
+ headers: { "Content-Type": "application/json" }
249
+ });
250
+ if (!response.ok) {
251
+ const error = await response.text();
252
+ console.error(`\u274C Failed to start authorization (${response.status}): ${error}`);
253
+ process.exit(1);
254
+ }
255
+ const data = await response.json();
256
+ deviceCode = data.device_code;
257
+ userCode = data.user_code;
258
+ verificationUri = data.verification_uri;
259
+ expiresIn = data.expires_in;
260
+ interval = data.interval || 5;
261
+ } catch (error) {
262
+ console.error(`\u274C Could not reach auth server at ${authServer}: ${error.message}`);
263
+ process.exit(1);
264
+ }
265
+ console.log(" Your authorization code:\n");
266
+ console.log(` \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`);
267
+ console.log(` \u2502 ${userCode} \u2502`);
268
+ console.log(` \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
269
+ `);
270
+ console.log(` Open this URL and enter the code above:`);
271
+ console.log(` ${verificationUri}
272
+ `);
273
+ openBrowser(`${verificationUri}?code=${encodeURIComponent(userCode)}`);
274
+ console.log(" Waiting for authorization...\n");
275
+ const deadline = Date.now() + expiresIn * 1e3;
276
+ while (Date.now() < deadline) {
277
+ await sleep(interval * 1e3);
278
+ try {
279
+ const response = await (0, import_node_fetch2.default)(`${authServer}/device/token`, {
280
+ method: "POST",
281
+ headers: { "Content-Type": "application/json" },
282
+ body: JSON.stringify({ device_code: deviceCode })
283
+ });
284
+ const data = await response.json();
285
+ if (response.ok && data.access_token) {
286
+ saveCredentials({
287
+ accessToken: data.access_token,
288
+ apiUrl: data.api_url || "https://api.postiz.com",
289
+ organizationId: data.organization_id
290
+ });
291
+ console.log("\u2705 Successfully authenticated!");
292
+ console.log(`\u{1F4C1} Credentials saved to ${CREDENTIALS_FILE}`);
293
+ if (data.organization_id) {
294
+ console.log(`\u{1F3E2} Organization ID: ${data.organization_id}`);
295
+ }
296
+ return;
297
+ }
298
+ if (data.error === "authorization_pending") {
299
+ continue;
300
+ }
301
+ if (data.error === "expired_token") {
302
+ console.error("\u274C Authorization expired. Please try again.");
303
+ process.exit(1);
304
+ }
305
+ console.error(`\u274C Authorization failed: ${data.error}`);
306
+ process.exit(1);
307
+ } catch (e) {
308
+ continue;
309
+ }
310
+ }
311
+ console.error("\u274C Authorization timed out. Please try again.");
312
+ process.exit(1);
313
+ }
314
+ async function authLogout() {
315
+ const creds = loadCredentials();
316
+ if (!creds) {
317
+ console.log("\u2139\uFE0F No stored credentials found.");
318
+ return;
319
+ }
320
+ deleteCredentials();
321
+ console.log("\u2705 Credentials removed.");
322
+ }
323
+ async function authStatus() {
324
+ const envKey = process.env.POSTIZ_API_KEY;
325
+ const creds = loadCredentials();
326
+ let apiKey;
327
+ let apiUrl;
328
+ if (creds) {
329
+ console.log("\u{1F510} Authentication method: OAuth2");
330
+ console.log(`\u{1F4E1} API URL: ${creds.apiUrl}`);
331
+ console.log(`\u{1F511} Token: ${creds.accessToken.substring(0, 8)}...`);
332
+ if (creds.organizationId) {
333
+ console.log(`\u{1F3E2} Organization: ${creds.organizationId}`);
334
+ }
335
+ console.log(`\u{1F4C1} Credentials file: ${CREDENTIALS_FILE}`);
336
+ apiKey = creds.accessToken;
337
+ apiUrl = creds.apiUrl;
338
+ } else if (envKey) {
339
+ console.log("\u{1F511} Authentication method: API Key (environment variable)");
340
+ console.log(`\u{1F511} Key: ${envKey.substring(0, 8)}...`);
341
+ apiKey = envKey;
342
+ apiUrl = process.env.POSTIZ_API_URL || "https://api.postiz.com";
343
+ } else {
344
+ console.log("\u274C Not authenticated.");
345
+ console.log("\nOptions:");
346
+ console.log(" 1. OAuth2: postiz auth:login");
347
+ console.log(" 2. API Key: export POSTIZ_API_KEY=your_api_key");
348
+ return;
349
+ }
350
+ console.log("\n\u{1F504} Verifying credentials...");
351
+ try {
352
+ const response = await (0, import_node_fetch2.default)(`${apiUrl}/public/v1/integrations`, {
353
+ method: "GET",
354
+ headers: {
355
+ "Content-Type": "application/json",
356
+ Authorization: apiKey
357
+ }
358
+ });
359
+ if (response.ok) {
360
+ const integrations = await response.json();
361
+ console.log(`\u2705 Credentials are valid. ${integrations.length} integration(s) connected.`);
362
+ } else if (response.status === 401 || response.status === 403) {
363
+ console.log("\u274C Credentials are expired or invalid. Please re-authenticate.");
364
+ if (creds) {
365
+ console.log(" Run: postiz auth:login");
366
+ } else {
367
+ console.log(" Update your POSTIZ_API_KEY environment variable.");
368
+ }
369
+ } else {
370
+ const error = await response.text();
371
+ console.log(`\u26A0\uFE0F Could not verify credentials (HTTP ${response.status}): ${error}`);
372
+ }
373
+ } catch (error) {
374
+ console.log(`\u26A0\uFE0F Could not reach API to verify credentials: ${error.message}`);
375
+ }
376
+ }
377
+
193
378
  // src/config.ts
194
379
  function getConfig() {
380
+ const creds = loadCredentials();
381
+ if (creds) {
382
+ return {
383
+ apiKey: creds.accessToken,
384
+ apiUrl: creds.apiUrl
385
+ };
386
+ }
195
387
  const apiKey = process.env.POSTIZ_API_KEY;
196
388
  const apiUrl = process.env.POSTIZ_API_URL;
197
389
  if (!apiKey) {
198
- console.error("\u274C Error: POSTIZ_API_KEY environment variable is required");
199
- console.error("Please set it using: export POSTIZ_API_KEY=your_api_key");
390
+ console.error("\u274C Error: No authentication found.");
391
+ console.error("Options:");
392
+ console.error(" 1. OAuth2: postiz auth:login --client-id <id> --client-secret <secret>");
393
+ console.error(" 2. API Key: export POSTIZ_API_KEY=your_api_key");
200
394
  process.exit(1);
201
395
  }
202
396
  return {
@@ -206,7 +400,7 @@ function getConfig() {
206
400
  }
207
401
 
208
402
  // src/commands/posts.ts
209
- var import_fs = require("fs");
403
+ var import_fs2 = require("fs");
210
404
  async function getMissingContent(args) {
211
405
  const config = getConfig();
212
406
  const api = new PostizAPI(config);
@@ -251,11 +445,11 @@ async function createPost(args) {
251
445
  if (args.json) {
252
446
  try {
253
447
  const jsonPath = args.json;
254
- if (!(0, import_fs.existsSync)(jsonPath)) {
448
+ if (!(0, import_fs2.existsSync)(jsonPath)) {
255
449
  console.error(`\u274C JSON file not found: ${jsonPath}`);
256
450
  process.exit(1);
257
451
  }
258
- const jsonContent = (0, import_fs.readFileSync)(jsonPath, "utf-8");
452
+ const jsonContent = (0, import_fs2.readFileSync)(jsonPath, "utf-8");
259
453
  postData = JSON.parse(jsonContent);
260
454
  } catch (error) {
261
455
  console.error("\u274C Failed to parse JSON file:", error.message);
@@ -461,7 +655,7 @@ async function getPostAnalytics(args) {
461
655
  }
462
656
 
463
657
  // src/commands/upload.ts
464
- var import_fs2 = require("fs");
658
+ var import_fs3 = require("fs");
465
659
  async function uploadFile(args) {
466
660
  const config = getConfig();
467
661
  const api = new PostizAPI(config);
@@ -470,7 +664,7 @@ async function uploadFile(args) {
470
664
  process.exit(1);
471
665
  }
472
666
  try {
473
- const fileBuffer = (0, import_fs2.readFileSync)(args.file);
667
+ const fileBuffer = (0, import_fs3.readFileSync)(args.file);
474
668
  const filename = args.file.split("/").pop() || "file";
475
669
  const result = await api.upload(fileBuffer, filename);
476
670
  console.log("\u2705 File uploaded successfully!");
@@ -730,7 +924,30 @@ async function uploadFile(args) {
730
924
  }).example("$0 upload ./image.png", "Upload an image");
731
925
  },
732
926
  uploadFile
927
+ ).command(
928
+ "auth:login",
929
+ "Authenticate using OAuth2 (device flow)",
930
+ (yargs2) => {
931
+ return yargs2.option("auth-server", {
932
+ describe: "Auth server URL (default: https://cli-auth.postiz.com)",
933
+ type: "string"
934
+ }).example(
935
+ "$0 auth:login",
936
+ "Login via OAuth2 device flow"
937
+ );
938
+ },
939
+ authLogin
940
+ ).command(
941
+ "auth:logout",
942
+ "Remove stored OAuth2 credentials",
943
+ {},
944
+ authLogout
945
+ ).command(
946
+ "auth:status",
947
+ "Show current authentication status",
948
+ {},
949
+ authStatus
733
950
  ).demandCommand(1, "You need at least one command").help().alias("h", "help").version().alias("v", "version").epilogue(
734
- "For more information, visit: https://postiz.com\n\nSet your API key: export POSTIZ_API_KEY=your_api_key\n\n\u{1F4FD}\uFE0F Recommendation: Use agent-media to generate AI videos & images (Kling, Veo, Sora, Seedance, Flux, Grok) and post them directly with Postiz.\n Install: npm install -g agent-media-cli\n Learn more: https://agent-media.ai"
951
+ "For more information, visit: https://postiz.com\n\nAuthentication:\n OAuth2: postiz auth:login\n API Key: export POSTIZ_API_KEY=your_api_key\n\n\u{1F4FD}\uFE0F Recommendation: Use agent-media to generate AI videos & images (Kling, Veo, Sora, Seedance, Flux, Grok) and post them directly with Postiz.\n Install: npm install -g agent-media-cli\n Learn more: https://agent-media.ai"
735
952
  ).parse();
736
953
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/api.ts","../src/config.ts","../src/commands/posts.ts","../src/commands/integrations.ts","../src/commands/analytics.ts","../src/commands/upload.ts"],"sourcesContent":["import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { createPost, listPosts, deletePost, getMissingContent, connectPost } from './commands/posts';\nimport { listIntegrations, getIntegrationSettings, triggerIntegrationTool } from './commands/integrations';\nimport { getAnalytics, getPostAnalytics } from './commands/analytics';\nimport { uploadFile } from './commands/upload';\nimport type { Argv } from 'yargs';\n\nyargs(hideBin(process.argv))\n .scriptName('postiz')\n .usage('$0 <command> [options]')\n .command(\n 'posts:create',\n 'Create a new post',\n (yargs: Argv) => {\n return yargs\n .option('content', {\n alias: 'c',\n describe: 'Post/comment content (can be used multiple times)',\n type: 'string',\n })\n .option('media', {\n alias: 'm',\n describe: 'Comma-separated media URLs for the corresponding -c (can be used multiple times)',\n type: 'string',\n })\n .option('integrations', {\n alias: 'i',\n describe: 'Comma-separated list of integration IDs',\n type: 'string',\n })\n .option('date', {\n alias: 's',\n describe: 'Schedule date (ISO 8601 format) - REQUIRED',\n type: 'string',\n })\n .option('type', {\n alias: 't',\n describe: 'Post type: \"schedule\" or \"draft\"',\n type: 'string',\n choices: ['schedule', 'draft'],\n default: 'schedule',\n })\n .option('delay', {\n alias: 'd',\n describe: 'Delay in minutes between comments (default: 0)',\n type: 'number',\n default: 0,\n })\n .option('json', {\n alias: 'j',\n describe: 'Path to JSON file with full post structure',\n type: 'string',\n })\n .option('shortLink', {\n describe: 'Use short links',\n type: 'boolean',\n default: true,\n })\n .option('settings', {\n describe: 'Platform-specific settings as JSON string',\n type: 'string',\n })\n .check((argv) => {\n if (!argv.json && !argv.content) {\n throw new Error('Either --content or --json is required');\n }\n if (!argv.json && !argv.integrations) {\n throw new Error('--integrations is required when not using --json');\n }\n if (!argv.json && !argv.date) {\n throw new Error('--date is required when not using --json');\n }\n return true;\n })\n .example(\n '$0 posts:create -c \"Hello World!\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Simple scheduled post'\n )\n .example(\n '$0 posts:create -c \"Draft post\" -s \"2024-12-31T12:00:00Z\" -t draft -i \"twitter-123\"',\n 'Create draft post'\n )\n .example(\n '$0 posts:create -c \"Main post\" -m \"img1.jpg,img2.jpg\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Post with multiple images'\n )\n .example(\n '$0 posts:create -c \"Main post\" -m \"img1.jpg\" -c \"First comment\" -m \"img2.jpg\" -c \"Second comment\" -m \"img3.jpg,img4.jpg\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Post with comments, each having their own media'\n )\n .example(\n '$0 posts:create -c \"Main\" -c \"Comment with semicolon; see?\" -c \"Another!\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Comments can contain semicolons'\n )\n .example(\n '$0 posts:create -c \"Thread 1/3\" -c \"Thread 2/3\" -c \"Thread 3/3\" -d 5 -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Twitter thread with 5 minute delay'\n )\n .example(\n '$0 posts:create --json ./post.json',\n 'Complex post from JSON file'\n )\n .example(\n '$0 posts:create -c \"Post to subreddit\" -s \"2024-12-31T12:00:00Z\" --settings \\'{\"subreddit\":[{\"value\":{\"subreddit\":\"programming\",\"title\":\"My Title\",\"type\":\"text\",\"url\":\"\",\"is_flair_required\":false}}]}\\' -i \"reddit-123\"',\n 'Reddit post with specific subreddit settings'\n )\n .example(\n '$0 posts:create -c \"Video description\" -s \"2024-12-31T12:00:00Z\" --settings \\'{\"title\":\"My Video\",\"type\":\"public\",\"tags\":[{\"value\":\"tech\",\"label\":\"Tech\"}]}\\' -i \"youtube-123\"',\n 'YouTube post with title and tags'\n )\n .example(\n '$0 posts:create -c \"Tweet content\" -s \"2024-12-31T12:00:00Z\" --settings \\'{\"who_can_reply_post\":\"everyone\"}\\' -i \"twitter-123\"',\n 'X (Twitter) post with reply settings'\n );\n },\n createPost as any\n )\n .command(\n 'posts:list',\n 'List all posts',\n (yargs: Argv) => {\n return yargs\n .option('startDate', {\n describe: 'Start date (ISO 8601 format). Default: 30 days ago',\n type: 'string',\n })\n .option('endDate', {\n describe: 'End date (ISO 8601 format). Default: 30 days from now',\n type: 'string',\n })\n .option('customer', {\n describe: 'Customer ID (optional)',\n type: 'string',\n })\n .example('$0 posts:list', 'List all posts (last 30 days to next 30 days)')\n .example(\n '$0 posts:list --startDate \"2024-01-01T00:00:00Z\" --endDate \"2024-12-31T23:59:59Z\"',\n 'List posts for a specific date range'\n )\n .example(\n '$0 posts:list --customer \"customer-id\"',\n 'List posts for a specific customer'\n );\n },\n listPosts as any\n )\n .command(\n 'posts:delete <id>',\n 'Delete a post',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID to delete',\n type: 'string',\n })\n .example('$0 posts:delete abc123', 'Delete post with ID abc123');\n },\n deletePost as any\n )\n .command(\n 'posts:missing <id>',\n 'List available content from the provider for a post with missing release ID',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID',\n type: 'string',\n })\n .example(\n '$0 posts:missing post-123',\n 'Get available content to connect to a post'\n );\n },\n getMissingContent as any\n )\n .command(\n 'posts:connect <id>',\n 'Connect a post to its published content by updating the release ID',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID',\n type: 'string',\n })\n .option('release-id', {\n describe: 'The platform-specific content ID to connect',\n type: 'string',\n demandOption: true,\n })\n .example(\n '$0 posts:connect post-123 --release-id \"7321456789012345678\"',\n 'Connect a post to its published content'\n );\n },\n connectPost as any\n )\n .command(\n 'integrations:list',\n 'List all connected integrations',\n {},\n listIntegrations as any\n )\n .command(\n 'integrations:settings <id>',\n 'Get settings schema for a specific integration',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Integration ID',\n type: 'string',\n })\n .example(\n '$0 integrations:settings reddit-123',\n 'Get settings schema for Reddit integration'\n )\n .example(\n '$0 integrations:settings youtube-456',\n 'Get settings schema for YouTube integration'\n );\n },\n getIntegrationSettings as any\n )\n .command(\n 'integrations:trigger <id> <method>',\n 'Trigger an integration tool to fetch additional data',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Integration ID',\n type: 'string',\n })\n .positional('method', {\n describe: 'Method name from the integration tools',\n type: 'string',\n })\n .option('data', {\n alias: 'd',\n describe: 'Data to pass to the tool as JSON string',\n type: 'string',\n })\n .example(\n '$0 integrations:trigger reddit-123 getSubreddits',\n 'Get list of subreddits'\n )\n .example(\n '$0 integrations:trigger reddit-123 searchSubreddits -d \\'{\"query\":\"programming\"}\\'',\n 'Search for subreddits'\n )\n .example(\n '$0 integrations:trigger youtube-123 getPlaylists',\n 'Get YouTube playlists'\n );\n },\n triggerIntegrationTool as any\n )\n .command(\n 'analytics:platform <id>',\n 'Get analytics for a specific integration/channel',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Integration ID',\n type: 'string',\n })\n .option('date', {\n alias: 'd',\n describe: 'Number of days to look back (default: 7)',\n type: 'string',\n default: '7',\n })\n .example(\n '$0 analytics:platform integration-123',\n 'Get last 7 days of analytics'\n )\n .example(\n '$0 analytics:platform integration-123 -d 30',\n 'Get last 30 days of analytics'\n );\n },\n getAnalytics as any\n )\n .command(\n 'analytics:post <id>',\n 'Get analytics for a specific post',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID',\n type: 'string',\n })\n .option('date', {\n alias: 'd',\n describe: 'Number of days to look back (default: 7)',\n type: 'string',\n default: '7',\n })\n .example(\n '$0 analytics:post post-123',\n 'Get last 7 days of post analytics'\n )\n .example(\n '$0 analytics:post post-123 -d 30',\n 'Get last 30 days of post analytics'\n );\n },\n getPostAnalytics as any\n )\n .command(\n 'upload <file>',\n 'Upload a file',\n (yargs: Argv) => {\n return yargs\n .positional('file', {\n describe: 'File path to upload',\n type: 'string',\n })\n .example('$0 upload ./image.png', 'Upload an image');\n },\n uploadFile as any\n )\n .demandCommand(1, 'You need at least one command')\n .help()\n .alias('h', 'help')\n .version()\n .alias('v', 'version')\n .epilogue(\n 'For more information, visit: https://postiz.com\\n\\nSet your API key: export POSTIZ_API_KEY=your_api_key\\n\\n📽️ Recommendation: Use agent-media to generate AI videos & images (Kling, Veo, Sora, Seedance, Flux, Grok) and post them directly with Postiz.\\n Install: npm install -g agent-media-cli\\n Learn more: https://agent-media.ai'\n )\n .parse();\n","import fetch, { FormData } from 'node-fetch';\n\nexport interface PostizConfig {\n apiKey: string;\n apiUrl?: string;\n}\n\nexport class PostizAPI {\n private apiKey: string;\n private apiUrl: string;\n\n constructor(config: PostizConfig) {\n this.apiKey = config.apiKey;\n this.apiUrl = config.apiUrl || 'https://api.postiz.com';\n }\n\n private async request(endpoint: string, options: any = {}) {\n const url = `${this.apiUrl}${endpoint}`;\n const headers = {\n 'Content-Type': 'application/json',\n Authorization: this.apiKey,\n ...options.headers,\n };\n\n try {\n const response = await fetch(url, {\n ...options,\n headers,\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`API Error (${response.status}): ${error}`);\n }\n\n return await response.json();\n } catch (error: any) {\n throw new Error(`Request failed: ${error.message}`);\n }\n }\n\n async createPost(data: any) {\n return this.request('/public/v1/posts', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n async listPosts(filters: any = {}) {\n const queryString = new URLSearchParams(\n Object.entries(filters).reduce((acc, [key, value]) => {\n if (value !== undefined && value !== null) {\n acc[key] = String(value);\n }\n return acc;\n }, {} as Record<string, string>)\n ).toString();\n\n const endpoint = queryString\n ? `/public/v1/posts?${queryString}`\n : '/public/v1/posts';\n\n return this.request(endpoint, {\n method: 'GET',\n });\n }\n\n async deletePost(id: string) {\n return this.request(`/public/v1/posts/${id}`, {\n method: 'DELETE',\n });\n }\n\n async upload(file: Buffer, filename: string) {\n const formData = new FormData();\n const extension = filename.split('.').pop()?.toLowerCase() || '';\n\n // Determine MIME type based on file extension\n const mimeTypes: Record<string, string> = {\n // Images\n 'png': 'image/png',\n 'jpg': 'image/jpeg',\n 'jpeg': 'image/jpeg',\n 'gif': 'image/gif',\n 'webp': 'image/webp',\n 'svg': 'image/svg+xml',\n 'bmp': 'image/bmp',\n 'ico': 'image/x-icon',\n\n // Videos\n 'mp4': 'video/mp4',\n 'mov': 'video/quicktime',\n 'avi': 'video/x-msvideo',\n 'mkv': 'video/x-matroska',\n 'webm': 'video/webm',\n 'flv': 'video/x-flv',\n 'wmv': 'video/x-ms-wmv',\n 'm4v': 'video/x-m4v',\n 'mpeg': 'video/mpeg',\n 'mpg': 'video/mpeg',\n '3gp': 'video/3gpp',\n\n // Audio\n 'mp3': 'audio/mpeg',\n 'wav': 'audio/wav',\n 'ogg': 'audio/ogg',\n 'aac': 'audio/aac',\n 'flac': 'audio/flac',\n 'm4a': 'audio/mp4',\n\n // Documents\n 'pdf': 'application/pdf',\n 'doc': 'application/msword',\n 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n };\n\n const type = mimeTypes[extension] || 'application/octet-stream';\n\n const blob = new Blob([file], { type });\n formData.append('file', blob, filename);\n\n const url = `${this.apiUrl}/public/v1/upload`;\n const response = await fetch(url, {\n method: 'POST',\n // @ts-ignore\n body: formData,\n headers: {\n Authorization: this.apiKey,\n },\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Upload failed (${response.status}): ${error}`);\n }\n\n return await response.json();\n }\n\n async getMissingContent(postId: string) {\n return this.request(`/public/v1/posts/${postId}/missing`, {\n method: 'GET',\n });\n }\n\n async updateReleaseId(postId: string, releaseId: string) {\n return this.request(`/public/v1/posts/${postId}/release-id`, {\n method: 'PUT',\n body: JSON.stringify({ releaseId }),\n });\n }\n\n async getAnalytics(integrationId: string, date: string) {\n return this.request(`/public/v1/analytics/${integrationId}?date=${encodeURIComponent(date)}`, {\n method: 'GET',\n });\n }\n\n async getPostAnalytics(postId: string, date: string) {\n return this.request(`/public/v1/analytics/post/${postId}?date=${encodeURIComponent(date)}`, {\n method: 'GET',\n });\n }\n\n async listIntegrations() {\n return this.request('/public/v1/integrations', {\n method: 'GET',\n });\n }\n\n async getIntegrationSettings(integrationId: string) {\n return this.request(`/public/v1/integration-settings/${integrationId}`, {\n method: 'GET',\n });\n }\n\n async triggerIntegrationTool(\n integrationId: string,\n methodName: string,\n data: Record<string, string>\n ) {\n return this.request(`/public/v1/integration-trigger/${integrationId}`, {\n method: 'POST',\n body: JSON.stringify({ methodName, data }),\n });\n }\n}\n","import { PostizConfig } from './api';\n\nexport function getConfig(): PostizConfig {\n const apiKey = process.env.POSTIZ_API_KEY;\n const apiUrl = process.env.POSTIZ_API_URL;\n\n if (!apiKey) {\n console.error('❌ Error: POSTIZ_API_KEY environment variable is required');\n console.error('Please set it using: export POSTIZ_API_KEY=your_api_key');\n process.exit(1);\n }\n\n return {\n apiKey,\n apiUrl,\n };\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\nimport { readFileSync, existsSync } from 'fs';\n\nexport async function getMissingContent(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n try {\n const result = await api.getMissingContent(args.id);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get missing content:', error.message);\n process.exit(1);\n }\n}\n\nexport async function connectPost(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n if (!args.releaseId) {\n console.error('❌ --release-id is required');\n process.exit(1);\n }\n\n try {\n const result = await api.updateReleaseId(args.id, args.releaseId);\n console.log(`✅ Post ${args.id} connected to release ${args.releaseId}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to connect post:', error.message);\n process.exit(1);\n }\n}\n\nexport async function createPost(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n // Support both simple and complex post creation\n let postData: any;\n\n if (args.json) {\n // Load from JSON file for complex posts with comments and media\n try {\n const jsonPath = args.json;\n if (!existsSync(jsonPath)) {\n console.error(`❌ JSON file not found: ${jsonPath}`);\n process.exit(1);\n }\n const jsonContent = readFileSync(jsonPath, 'utf-8');\n postData = JSON.parse(jsonContent);\n } catch (error: any) {\n console.error('❌ Failed to parse JSON file:', error.message);\n process.exit(1);\n }\n } else {\n const integrations = args.integrations\n ? args.integrations.split(',').map((id: string) => id.trim())\n : [];\n\n if (integrations.length === 0) {\n console.error('❌ At least one integration ID is required');\n console.error('Use -i or --integrations to specify integration IDs');\n console.error('Run \"postiz integrations:list\" to see available integrations');\n process.exit(1);\n }\n\n // Support multiple -c and -m flags\n // Normalize to arrays\n const contents = Array.isArray(args.content) ? args.content : [args.content];\n const medias = Array.isArray(args.media) ? args.media : (args.media ? [args.media] : []);\n\n if (!contents[0]) {\n console.error('❌ At least one -c/--content is required');\n process.exit(1);\n }\n\n // Build value array by pairing contents with their media\n const values = contents.map((content: string, index: number) => {\n const mediaForThisContent = medias[index];\n const images = mediaForThisContent\n ? mediaForThisContent.split(',').map((img: string) => ({\n id: Math.random().toString(36).substring(7),\n path: img.trim(),\n }))\n : [];\n\n return {\n content: content,\n image: images,\n delay: args?.delay || 0,\n };\n });\n\n // Parse provider-specific settings if provided\n // Note: __type is automatically added by the backend based on integration ID\n let settings: any = undefined;\n\n if (args.settings) {\n try {\n settings = typeof args.settings === 'string'\n ? JSON.parse(args.settings)\n : args.settings;\n } catch (error: any) {\n console.error('❌ Failed to parse settings JSON:', error.message);\n process.exit(1);\n }\n }\n\n // Build the proper post structure\n postData = {\n type: args.type || 'schedule', // 'schedule' or 'draft'\n date: args.date, // Required date field\n shortLink: args.shortLink !== false,\n tags: [],\n posts: integrations.map((integrationId: string) => ({\n integration: { id: integrationId },\n value: values,\n settings: settings,\n })),\n };\n }\n\n try {\n const result = await api.createPost(postData);\n console.log('✅ Post created successfully!');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to create post:', error.message);\n process.exit(1);\n }\n}\n\nexport async function listPosts(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n // Set default date range: last 30 days to 30 days in the future\n const defaultStartDate = new Date();\n defaultStartDate.setDate(defaultStartDate.getDate() - 30);\n\n const defaultEndDate = new Date();\n defaultEndDate.setDate(defaultEndDate.getDate() + 30);\n\n // Only send fields that are in GetPostsDto\n const filters: any = {\n startDate: args.startDate || defaultStartDate.toISOString(),\n endDate: args.endDate || defaultEndDate.toISOString(),\n };\n\n // customer is optional in the DTO\n if (args.customer) {\n filters.customer = args.customer;\n }\n\n try {\n const result = await api.listPosts(filters);\n console.log('📋 Posts:');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to list posts:', error.message);\n process.exit(1);\n }\n}\n\nexport async function deletePost(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n try {\n await api.deletePost(args.id);\n console.log(`✅ Post ${args.id} deleted successfully!`);\n } catch (error: any) {\n console.error('❌ Failed to delete post:', error.message);\n process.exit(1);\n }\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\n\nexport async function listIntegrations() {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n try {\n const result = await api.listIntegrations();\n console.log('🔌 Connected Integrations:');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to list integrations:', error.message);\n process.exit(1);\n }\n}\n\nexport async function getIntegrationSettings(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Integration ID is required');\n process.exit(1);\n }\n\n try {\n const result = await api.getIntegrationSettings(args.id);\n console.log(`⚙️ Settings for integration: ${args.id}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get integration settings:', error.message);\n process.exit(1);\n }\n}\n\nexport async function triggerIntegrationTool(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Integration ID is required');\n process.exit(1);\n }\n\n if (!args.method) {\n console.error('❌ Method name is required');\n process.exit(1);\n }\n\n // Parse data from JSON string or use empty object\n let data: Record<string, string> = {};\n if (args.data) {\n try {\n data = JSON.parse(args.data);\n } catch (error: any) {\n console.error('❌ Failed to parse data JSON:', error.message);\n process.exit(1);\n }\n }\n\n try {\n const result = await api.triggerIntegrationTool(args.id, args.method, data);\n console.log(`🔧 Tool result for ${args.method}:`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to trigger tool:', error.message);\n process.exit(1);\n }\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\n\nexport async function getAnalytics(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Integration ID is required');\n process.exit(1);\n }\n\n const date = args.date || '7';\n\n try {\n const result = await api.getAnalytics(args.id, date);\n console.log(`📊 Analytics for integration: ${args.id}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get analytics:', error.message);\n process.exit(1);\n }\n}\n\nexport async function getPostAnalytics(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n const date = args.date || '7';\n\n try {\n const result = await api.getPostAnalytics(args.id, date);\n console.log(`📊 Analytics for post: ${args.id}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get post analytics:', error.message);\n process.exit(1);\n }\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\nimport { readFileSync } from 'fs';\n\nexport async function uploadFile(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.file) {\n console.error('❌ File path is required');\n process.exit(1);\n }\n\n try {\n const fileBuffer = readFileSync(args.file);\n const filename = args.file.split('/').pop() || 'file';\n\n const result = await api.upload(fileBuffer, filename);\n console.log('✅ File uploaded successfully!');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } cat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O,QAAQ;AAAA,MACd,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC;AAAA,MACC;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAACA,WAAgB;AACf,WAAOA,OACJ,WAAW,MAAM;AAAA,MAChB,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA,OAAO,QAAQ;AAAA,MACd,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC,EACA;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC;AAAA,MACC;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAACA,WAAgB;AACf,WAAOA,OACJ,WAAW,MAAM;AAAA,MAChB,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA,OAAO,QAAQ;AAAA,MACd,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC,EACA;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC;AAAA,MACC;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAACA,WAAgB;AACf,WAAOA,OACJ,WAAW,QAAQ;AAAA,MAClB,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA,QAAQ,yBAAyB,iBAAiB;AAAA,EACvD;AAAA,EACA;AACF,EACC,cAAc,GAAG,+BAA+B,EAChD,KAAK,EACL,MAAM,KAAK,MAAM,EACjB,QAAQ,EACR,MAAM,KAAK,SAAS,EACpB;AAAA,EACC;AACF,EACC,MAAM;","names":["fetch","import_fs","yargs"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/api.ts","../src/commands/auth.ts","../src/config.ts","../src/commands/posts.ts","../src/commands/integrations.ts","../src/commands/analytics.ts","../src/commands/upload.ts"],"sourcesContent":["import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { createPost, listPosts, deletePost, getMissingContent, connectPost } from './commands/posts';\nimport { listIntegrations, getIntegrationSettings, triggerIntegrationTool } from './commands/integrations';\nimport { getAnalytics, getPostAnalytics } from './commands/analytics';\nimport { uploadFile } from './commands/upload';\nimport { authLogin, authLogout, authStatus } from './commands/auth';\nimport type { Argv } from 'yargs';\n\nyargs(hideBin(process.argv))\n .scriptName('postiz')\n .usage('$0 <command> [options]')\n .command(\n 'posts:create',\n 'Create a new post',\n (yargs: Argv) => {\n return yargs\n .option('content', {\n alias: 'c',\n describe: 'Post/comment content (can be used multiple times)',\n type: 'string',\n })\n .option('media', {\n alias: 'm',\n describe: 'Comma-separated media URLs for the corresponding -c (can be used multiple times)',\n type: 'string',\n })\n .option('integrations', {\n alias: 'i',\n describe: 'Comma-separated list of integration IDs',\n type: 'string',\n })\n .option('date', {\n alias: 's',\n describe: 'Schedule date (ISO 8601 format) - REQUIRED',\n type: 'string',\n })\n .option('type', {\n alias: 't',\n describe: 'Post type: \"schedule\" or \"draft\"',\n type: 'string',\n choices: ['schedule', 'draft'],\n default: 'schedule',\n })\n .option('delay', {\n alias: 'd',\n describe: 'Delay in minutes between comments (default: 0)',\n type: 'number',\n default: 0,\n })\n .option('json', {\n alias: 'j',\n describe: 'Path to JSON file with full post structure',\n type: 'string',\n })\n .option('shortLink', {\n describe: 'Use short links',\n type: 'boolean',\n default: true,\n })\n .option('settings', {\n describe: 'Platform-specific settings as JSON string',\n type: 'string',\n })\n .check((argv) => {\n if (!argv.json && !argv.content) {\n throw new Error('Either --content or --json is required');\n }\n if (!argv.json && !argv.integrations) {\n throw new Error('--integrations is required when not using --json');\n }\n if (!argv.json && !argv.date) {\n throw new Error('--date is required when not using --json');\n }\n return true;\n })\n .example(\n '$0 posts:create -c \"Hello World!\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Simple scheduled post'\n )\n .example(\n '$0 posts:create -c \"Draft post\" -s \"2024-12-31T12:00:00Z\" -t draft -i \"twitter-123\"',\n 'Create draft post'\n )\n .example(\n '$0 posts:create -c \"Main post\" -m \"img1.jpg,img2.jpg\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Post with multiple images'\n )\n .example(\n '$0 posts:create -c \"Main post\" -m \"img1.jpg\" -c \"First comment\" -m \"img2.jpg\" -c \"Second comment\" -m \"img3.jpg,img4.jpg\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Post with comments, each having their own media'\n )\n .example(\n '$0 posts:create -c \"Main\" -c \"Comment with semicolon; see?\" -c \"Another!\" -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Comments can contain semicolons'\n )\n .example(\n '$0 posts:create -c \"Thread 1/3\" -c \"Thread 2/3\" -c \"Thread 3/3\" -d 5 -s \"2024-12-31T12:00:00Z\" -i \"twitter-123\"',\n 'Twitter thread with 5 minute delay'\n )\n .example(\n '$0 posts:create --json ./post.json',\n 'Complex post from JSON file'\n )\n .example(\n '$0 posts:create -c \"Post to subreddit\" -s \"2024-12-31T12:00:00Z\" --settings \\'{\"subreddit\":[{\"value\":{\"subreddit\":\"programming\",\"title\":\"My Title\",\"type\":\"text\",\"url\":\"\",\"is_flair_required\":false}}]}\\' -i \"reddit-123\"',\n 'Reddit post with specific subreddit settings'\n )\n .example(\n '$0 posts:create -c \"Video description\" -s \"2024-12-31T12:00:00Z\" --settings \\'{\"title\":\"My Video\",\"type\":\"public\",\"tags\":[{\"value\":\"tech\",\"label\":\"Tech\"}]}\\' -i \"youtube-123\"',\n 'YouTube post with title and tags'\n )\n .example(\n '$0 posts:create -c \"Tweet content\" -s \"2024-12-31T12:00:00Z\" --settings \\'{\"who_can_reply_post\":\"everyone\"}\\' -i \"twitter-123\"',\n 'X (Twitter) post with reply settings'\n );\n },\n createPost as any\n )\n .command(\n 'posts:list',\n 'List all posts',\n (yargs: Argv) => {\n return yargs\n .option('startDate', {\n describe: 'Start date (ISO 8601 format). Default: 30 days ago',\n type: 'string',\n })\n .option('endDate', {\n describe: 'End date (ISO 8601 format). Default: 30 days from now',\n type: 'string',\n })\n .option('customer', {\n describe: 'Customer ID (optional)',\n type: 'string',\n })\n .example('$0 posts:list', 'List all posts (last 30 days to next 30 days)')\n .example(\n '$0 posts:list --startDate \"2024-01-01T00:00:00Z\" --endDate \"2024-12-31T23:59:59Z\"',\n 'List posts for a specific date range'\n )\n .example(\n '$0 posts:list --customer \"customer-id\"',\n 'List posts for a specific customer'\n );\n },\n listPosts as any\n )\n .command(\n 'posts:delete <id>',\n 'Delete a post',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID to delete',\n type: 'string',\n })\n .example('$0 posts:delete abc123', 'Delete post with ID abc123');\n },\n deletePost as any\n )\n .command(\n 'posts:missing <id>',\n 'List available content from the provider for a post with missing release ID',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID',\n type: 'string',\n })\n .example(\n '$0 posts:missing post-123',\n 'Get available content to connect to a post'\n );\n },\n getMissingContent as any\n )\n .command(\n 'posts:connect <id>',\n 'Connect a post to its published content by updating the release ID',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID',\n type: 'string',\n })\n .option('release-id', {\n describe: 'The platform-specific content ID to connect',\n type: 'string',\n demandOption: true,\n })\n .example(\n '$0 posts:connect post-123 --release-id \"7321456789012345678\"',\n 'Connect a post to its published content'\n );\n },\n connectPost as any\n )\n .command(\n 'integrations:list',\n 'List all connected integrations',\n {},\n listIntegrations as any\n )\n .command(\n 'integrations:settings <id>',\n 'Get settings schema for a specific integration',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Integration ID',\n type: 'string',\n })\n .example(\n '$0 integrations:settings reddit-123',\n 'Get settings schema for Reddit integration'\n )\n .example(\n '$0 integrations:settings youtube-456',\n 'Get settings schema for YouTube integration'\n );\n },\n getIntegrationSettings as any\n )\n .command(\n 'integrations:trigger <id> <method>',\n 'Trigger an integration tool to fetch additional data',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Integration ID',\n type: 'string',\n })\n .positional('method', {\n describe: 'Method name from the integration tools',\n type: 'string',\n })\n .option('data', {\n alias: 'd',\n describe: 'Data to pass to the tool as JSON string',\n type: 'string',\n })\n .example(\n '$0 integrations:trigger reddit-123 getSubreddits',\n 'Get list of subreddits'\n )\n .example(\n '$0 integrations:trigger reddit-123 searchSubreddits -d \\'{\"query\":\"programming\"}\\'',\n 'Search for subreddits'\n )\n .example(\n '$0 integrations:trigger youtube-123 getPlaylists',\n 'Get YouTube playlists'\n );\n },\n triggerIntegrationTool as any\n )\n .command(\n 'analytics:platform <id>',\n 'Get analytics for a specific integration/channel',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Integration ID',\n type: 'string',\n })\n .option('date', {\n alias: 'd',\n describe: 'Number of days to look back (default: 7)',\n type: 'string',\n default: '7',\n })\n .example(\n '$0 analytics:platform integration-123',\n 'Get last 7 days of analytics'\n )\n .example(\n '$0 analytics:platform integration-123 -d 30',\n 'Get last 30 days of analytics'\n );\n },\n getAnalytics as any\n )\n .command(\n 'analytics:post <id>',\n 'Get analytics for a specific post',\n (yargs: Argv) => {\n return yargs\n .positional('id', {\n describe: 'Post ID',\n type: 'string',\n })\n .option('date', {\n alias: 'd',\n describe: 'Number of days to look back (default: 7)',\n type: 'string',\n default: '7',\n })\n .example(\n '$0 analytics:post post-123',\n 'Get last 7 days of post analytics'\n )\n .example(\n '$0 analytics:post post-123 -d 30',\n 'Get last 30 days of post analytics'\n );\n },\n getPostAnalytics as any\n )\n .command(\n 'upload <file>',\n 'Upload a file',\n (yargs: Argv) => {\n return yargs\n .positional('file', {\n describe: 'File path to upload',\n type: 'string',\n })\n .example('$0 upload ./image.png', 'Upload an image');\n },\n uploadFile as any\n )\n .command(\n 'auth:login',\n 'Authenticate using OAuth2 (device flow)',\n (yargs: Argv) => {\n return yargs\n .option('auth-server', {\n describe: 'Auth server URL (default: https://cli-auth.postiz.com)',\n type: 'string',\n })\n .example(\n '$0 auth:login',\n 'Login via OAuth2 device flow'\n );\n },\n authLogin as any\n )\n .command(\n 'auth:logout',\n 'Remove stored OAuth2 credentials',\n {},\n authLogout as any\n )\n .command(\n 'auth:status',\n 'Show current authentication status',\n {},\n authStatus as any\n )\n .demandCommand(1, 'You need at least one command')\n .help()\n .alias('h', 'help')\n .version()\n .alias('v', 'version')\n .epilogue(\n 'For more information, visit: https://postiz.com\\n\\nAuthentication:\\n OAuth2: postiz auth:login\\n API Key: export POSTIZ_API_KEY=your_api_key\\n\\n📽️ Recommendation: Use agent-media to generate AI videos & images (Kling, Veo, Sora, Seedance, Flux, Grok) and post them directly with Postiz.\\n Install: npm install -g agent-media-cli\\n Learn more: https://agent-media.ai'\n )\n .parse();\n","import fetch, { FormData } from 'node-fetch';\n\nexport interface PostizConfig {\n apiKey: string;\n apiUrl?: string;\n}\n\nexport class PostizAPI {\n private apiKey: string;\n private apiUrl: string;\n\n constructor(config: PostizConfig) {\n this.apiKey = config.apiKey;\n this.apiUrl = config.apiUrl || 'https://api.postiz.com';\n }\n\n private async request(endpoint: string, options: any = {}) {\n const url = `${this.apiUrl}${endpoint}`;\n const headers = {\n 'Content-Type': 'application/json',\n Authorization: this.apiKey,\n ...options.headers,\n };\n\n try {\n const response = await fetch(url, {\n ...options,\n headers,\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`API Error (${response.status}): ${error}`);\n }\n\n return await response.json();\n } catch (error: any) {\n throw new Error(`Request failed: ${error.message}`);\n }\n }\n\n async createPost(data: any) {\n return this.request('/public/v1/posts', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n async listPosts(filters: any = {}) {\n const queryString = new URLSearchParams(\n Object.entries(filters).reduce((acc, [key, value]) => {\n if (value !== undefined && value !== null) {\n acc[key] = String(value);\n }\n return acc;\n }, {} as Record<string, string>)\n ).toString();\n\n const endpoint = queryString\n ? `/public/v1/posts?${queryString}`\n : '/public/v1/posts';\n\n return this.request(endpoint, {\n method: 'GET',\n });\n }\n\n async deletePost(id: string) {\n return this.request(`/public/v1/posts/${id}`, {\n method: 'DELETE',\n });\n }\n\n async upload(file: Buffer, filename: string) {\n const formData = new FormData();\n const extension = filename.split('.').pop()?.toLowerCase() || '';\n\n // Determine MIME type based on file extension\n const mimeTypes: Record<string, string> = {\n // Images\n 'png': 'image/png',\n 'jpg': 'image/jpeg',\n 'jpeg': 'image/jpeg',\n 'gif': 'image/gif',\n 'webp': 'image/webp',\n 'svg': 'image/svg+xml',\n 'bmp': 'image/bmp',\n 'ico': 'image/x-icon',\n\n // Videos\n 'mp4': 'video/mp4',\n 'mov': 'video/quicktime',\n 'avi': 'video/x-msvideo',\n 'mkv': 'video/x-matroska',\n 'webm': 'video/webm',\n 'flv': 'video/x-flv',\n 'wmv': 'video/x-ms-wmv',\n 'm4v': 'video/x-m4v',\n 'mpeg': 'video/mpeg',\n 'mpg': 'video/mpeg',\n '3gp': 'video/3gpp',\n\n // Audio\n 'mp3': 'audio/mpeg',\n 'wav': 'audio/wav',\n 'ogg': 'audio/ogg',\n 'aac': 'audio/aac',\n 'flac': 'audio/flac',\n 'm4a': 'audio/mp4',\n\n // Documents\n 'pdf': 'application/pdf',\n 'doc': 'application/msword',\n 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n };\n\n const type = mimeTypes[extension] || 'application/octet-stream';\n\n const blob = new Blob([file], { type });\n formData.append('file', blob, filename);\n\n const url = `${this.apiUrl}/public/v1/upload`;\n const response = await fetch(url, {\n method: 'POST',\n // @ts-ignore\n body: formData,\n headers: {\n Authorization: this.apiKey,\n },\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Upload failed (${response.status}): ${error}`);\n }\n\n return await response.json();\n }\n\n async getMissingContent(postId: string) {\n return this.request(`/public/v1/posts/${postId}/missing`, {\n method: 'GET',\n });\n }\n\n async updateReleaseId(postId: string, releaseId: string) {\n return this.request(`/public/v1/posts/${postId}/release-id`, {\n method: 'PUT',\n body: JSON.stringify({ releaseId }),\n });\n }\n\n async getAnalytics(integrationId: string, date: string) {\n return this.request(`/public/v1/analytics/${integrationId}?date=${encodeURIComponent(date)}`, {\n method: 'GET',\n });\n }\n\n async getPostAnalytics(postId: string, date: string) {\n return this.request(`/public/v1/analytics/post/${postId}?date=${encodeURIComponent(date)}`, {\n method: 'GET',\n });\n }\n\n async listIntegrations() {\n return this.request('/public/v1/integrations', {\n method: 'GET',\n });\n }\n\n async getIntegrationSettings(integrationId: string) {\n return this.request(`/public/v1/integration-settings/${integrationId}`, {\n method: 'GET',\n });\n }\n\n async triggerIntegrationTool(\n integrationId: string,\n methodName: string,\n data: Record<string, string>\n ) {\n return this.request(`/public/v1/integration-trigger/${integrationId}`, {\n method: 'POST',\n body: JSON.stringify({ methodName, data }),\n });\n }\n}\n","import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync, chmodSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport fetch from 'node-fetch';\n\nconst CREDENTIALS_DIR = join(homedir(), '.postiz');\nconst CREDENTIALS_FILE = join(CREDENTIALS_DIR, 'credentials.json');\n\nconst DEFAULT_AUTH_SERVER = 'https://cli-auth.postiz.com';\n\ninterface StoredCredentials {\n accessToken: string;\n apiUrl: string;\n organizationId?: string;\n}\n\nexport function loadCredentials(): StoredCredentials | null {\n try {\n if (!existsSync(CREDENTIALS_FILE)) return null;\n const data = JSON.parse(readFileSync(CREDENTIALS_FILE, 'utf-8'));\n if (!data.accessToken) return null;\n return data;\n } catch {\n return null;\n }\n}\n\nfunction saveCredentials(credentials: StoredCredentials): void {\n if (!existsSync(CREDENTIALS_DIR)) {\n mkdirSync(CREDENTIALS_DIR, { recursive: true, mode: 0o700 });\n }\n writeFileSync(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2), { encoding: 'utf-8', mode: 0o600 });\n // Ensure permissions even if file already existed\n chmodSync(CREDENTIALS_FILE, 0o600);\n}\n\nfunction deleteCredentials(): void {\n if (existsSync(CREDENTIALS_FILE)) {\n unlinkSync(CREDENTIALS_FILE);\n }\n}\n\nfunction openBrowser(url: string): void {\n const { exec } = require('child_process');\n const platform = process.platform;\n\n if (platform === 'darwin') {\n exec(`open \"${url}\"`);\n } else if (platform === 'win32') {\n exec(`start \"\" \"${url}\"`);\n } else {\n exec(`xdg-open \"${url}\"`);\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function authLogin(argv: any) {\n const authServer = argv.authServer || process.env.POSTIZ_AUTH_SERVER || DEFAULT_AUTH_SERVER;\n\n console.log('🔐 Starting device authorization flow...\\n');\n\n // Step 1: Request a device code from the auth server\n let deviceCode: string;\n let userCode: string;\n let verificationUri: string;\n let expiresIn: number;\n let interval: number;\n\n try {\n const response = await fetch(`${authServer}/device/code`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n });\n\n if (!response.ok) {\n const error = await response.text();\n console.error(`❌ Failed to start authorization (${response.status}): ${error}`);\n process.exit(1);\n }\n\n const data = (await response.json()) as any;\n deviceCode = data.device_code;\n userCode = data.user_code;\n verificationUri = data.verification_uri;\n expiresIn = data.expires_in;\n interval = data.interval || 5;\n } catch (error: any) {\n console.error(`❌ Could not reach auth server at ${authServer}: ${error.message}`);\n process.exit(1);\n }\n\n // Step 2: Show the user code and open browser\n console.log(' Your authorization code:\\n');\n console.log(` ┌─────────────────┐`);\n console.log(` │ ${userCode} │`);\n console.log(` └─────────────────┘\\n`);\n console.log(` Open this URL and enter the code above:`);\n console.log(` ${verificationUri}\\n`);\n\n openBrowser(`${verificationUri}?code=${encodeURIComponent(userCode)}`);\n\n console.log(' Waiting for authorization...\\n');\n\n // Step 3: Poll for the token\n const deadline = Date.now() + expiresIn * 1000;\n\n while (Date.now() < deadline) {\n await sleep(interval * 1000);\n\n try {\n const response = await fetch(`${authServer}/device/token`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ device_code: deviceCode }),\n });\n\n const data = (await response.json()) as any;\n\n if (response.ok && data.access_token) {\n saveCredentials({\n accessToken: data.access_token,\n apiUrl: data.api_url || 'https://api.postiz.com',\n organizationId: data.organization_id,\n });\n\n console.log('✅ Successfully authenticated!');\n console.log(`📁 Credentials saved to ${CREDENTIALS_FILE}`);\n if (data.organization_id) {\n console.log(`🏢 Organization ID: ${data.organization_id}`);\n }\n return;\n }\n\n if (data.error === 'authorization_pending') {\n continue;\n }\n\n if (data.error === 'expired_token') {\n console.error('❌ Authorization expired. Please try again.');\n process.exit(1);\n }\n\n // Unknown error\n console.error(`❌ Authorization failed: ${data.error}`);\n process.exit(1);\n } catch {\n // Network error during poll — keep trying\n continue;\n }\n }\n\n console.error('❌ Authorization timed out. Please try again.');\n process.exit(1);\n}\n\nexport async function authLogout() {\n const creds = loadCredentials();\n if (!creds) {\n console.log('ℹ️ No stored credentials found.');\n return;\n }\n\n deleteCredentials();\n console.log('✅ Credentials removed.');\n}\n\nexport async function authStatus() {\n const envKey = process.env.POSTIZ_API_KEY;\n const creds = loadCredentials();\n\n let apiKey: string | undefined;\n let apiUrl: string;\n\n if (creds) {\n console.log('🔐 Authentication method: OAuth2');\n console.log(`📡 API URL: ${creds.apiUrl}`);\n console.log(`🔑 Token: ${creds.accessToken.substring(0, 8)}...`);\n if (creds.organizationId) {\n console.log(`🏢 Organization: ${creds.organizationId}`);\n }\n console.log(`📁 Credentials file: ${CREDENTIALS_FILE}`);\n apiKey = creds.accessToken;\n apiUrl = creds.apiUrl;\n } else if (envKey) {\n console.log('🔑 Authentication method: API Key (environment variable)');\n console.log(`🔑 Key: ${envKey.substring(0, 8)}...`);\n apiKey = envKey;\n apiUrl = process.env.POSTIZ_API_URL || 'https://api.postiz.com';\n } else {\n console.log('❌ Not authenticated.');\n console.log('\\nOptions:');\n console.log(' 1. OAuth2: postiz auth:login');\n console.log(' 2. API Key: export POSTIZ_API_KEY=your_api_key');\n return;\n }\n\n // Verify credentials by calling the integrations endpoint\n console.log('\\n🔄 Verifying credentials...');\n try {\n const response = await fetch(`${apiUrl}/public/v1/integrations`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: apiKey,\n },\n });\n\n if (response.ok) {\n const integrations = (await response.json()) as any[];\n console.log(`✅ Credentials are valid. ${integrations.length} integration(s) connected.`);\n } else if (response.status === 401 || response.status === 403) {\n console.log('❌ Credentials are expired or invalid. Please re-authenticate.');\n if (creds) {\n console.log(' Run: postiz auth:login');\n } else {\n console.log(' Update your POSTIZ_API_KEY environment variable.');\n }\n } else {\n const error = await response.text();\n console.log(`⚠️ Could not verify credentials (HTTP ${response.status}): ${error}`);\n }\n } catch (error: any) {\n console.log(`⚠️ Could not reach API to verify credentials: ${error.message}`);\n }\n}\n","import { PostizConfig } from './api';\nimport { loadCredentials } from './commands/auth';\n\nexport function getConfig(): PostizConfig {\n // Check for stored OAuth credentials first\n const creds = loadCredentials();\n if (creds) {\n return {\n apiKey: creds.accessToken,\n apiUrl: creds.apiUrl,\n };\n }\n\n // Fall back to environment variable\n const apiKey = process.env.POSTIZ_API_KEY;\n const apiUrl = process.env.POSTIZ_API_URL;\n\n if (!apiKey) {\n console.error('❌ Error: No authentication found.');\n console.error('Options:');\n console.error(' 1. OAuth2: postiz auth:login --client-id <id> --client-secret <secret>');\n console.error(' 2. API Key: export POSTIZ_API_KEY=your_api_key');\n process.exit(1);\n }\n\n return {\n apiKey,\n apiUrl,\n };\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\nimport { readFileSync, existsSync } from 'fs';\n\nexport async function getMissingContent(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n try {\n const result = await api.getMissingContent(args.id);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get missing content:', error.message);\n process.exit(1);\n }\n}\n\nexport async function connectPost(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n if (!args.releaseId) {\n console.error('❌ --release-id is required');\n process.exit(1);\n }\n\n try {\n const result = await api.updateReleaseId(args.id, args.releaseId);\n console.log(`✅ Post ${args.id} connected to release ${args.releaseId}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to connect post:', error.message);\n process.exit(1);\n }\n}\n\nexport async function createPost(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n // Support both simple and complex post creation\n let postData: any;\n\n if (args.json) {\n // Load from JSON file for complex posts with comments and media\n try {\n const jsonPath = args.json;\n if (!existsSync(jsonPath)) {\n console.error(`❌ JSON file not found: ${jsonPath}`);\n process.exit(1);\n }\n const jsonContent = readFileSync(jsonPath, 'utf-8');\n postData = JSON.parse(jsonContent);\n } catch (error: any) {\n console.error('❌ Failed to parse JSON file:', error.message);\n process.exit(1);\n }\n } else {\n const integrations = args.integrations\n ? args.integrations.split(',').map((id: string) => id.trim())\n : [];\n\n if (integrations.length === 0) {\n console.error('❌ At least one integration ID is required');\n console.error('Use -i or --integrations to specify integration IDs');\n console.error('Run \"postiz integrations:list\" to see available integrations');\n process.exit(1);\n }\n\n // Support multiple -c and -m flags\n // Normalize to arrays\n const contents = Array.isArray(args.content) ? args.content : [args.content];\n const medias = Array.isArray(args.media) ? args.media : (args.media ? [args.media] : []);\n\n if (!contents[0]) {\n console.error('❌ At least one -c/--content is required');\n process.exit(1);\n }\n\n // Build value array by pairing contents with their media\n const values = contents.map((content: string, index: number) => {\n const mediaForThisContent = medias[index];\n const images = mediaForThisContent\n ? mediaForThisContent.split(',').map((img: string) => ({\n id: Math.random().toString(36).substring(7),\n path: img.trim(),\n }))\n : [];\n\n return {\n content: content,\n image: images,\n delay: args?.delay || 0,\n };\n });\n\n // Parse provider-specific settings if provided\n // Note: __type is automatically added by the backend based on integration ID\n let settings: any = undefined;\n\n if (args.settings) {\n try {\n settings = typeof args.settings === 'string'\n ? JSON.parse(args.settings)\n : args.settings;\n } catch (error: any) {\n console.error('❌ Failed to parse settings JSON:', error.message);\n process.exit(1);\n }\n }\n\n // Build the proper post structure\n postData = {\n type: args.type || 'schedule', // 'schedule' or 'draft'\n date: args.date, // Required date field\n shortLink: args.shortLink !== false,\n tags: [],\n posts: integrations.map((integrationId: string) => ({\n integration: { id: integrationId },\n value: values,\n settings: settings,\n })),\n };\n }\n\n try {\n const result = await api.createPost(postData);\n console.log('✅ Post created successfully!');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to create post:', error.message);\n process.exit(1);\n }\n}\n\nexport async function listPosts(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n // Set default date range: last 30 days to 30 days in the future\n const defaultStartDate = new Date();\n defaultStartDate.setDate(defaultStartDate.getDate() - 30);\n\n const defaultEndDate = new Date();\n defaultEndDate.setDate(defaultEndDate.getDate() + 30);\n\n // Only send fields that are in GetPostsDto\n const filters: any = {\n startDate: args.startDate || defaultStartDate.toISOString(),\n endDate: args.endDate || defaultEndDate.toISOString(),\n };\n\n // customer is optional in the DTO\n if (args.customer) {\n filters.customer = args.customer;\n }\n\n try {\n const result = await api.listPosts(filters);\n console.log('📋 Posts:');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to list posts:', error.message);\n process.exit(1);\n }\n}\n\nexport async function deletePost(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n try {\n await api.deletePost(args.id);\n console.log(`✅ Post ${args.id} deleted successfully!`);\n } catch (error: any) {\n console.error('❌ Failed to delete post:', error.message);\n process.exit(1);\n }\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\n\nexport async function listIntegrations() {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n try {\n const result = await api.listIntegrations();\n console.log('🔌 Connected Integrations:');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to list integrations:', error.message);\n process.exit(1);\n }\n}\n\nexport async function getIntegrationSettings(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Integration ID is required');\n process.exit(1);\n }\n\n try {\n const result = await api.getIntegrationSettings(args.id);\n console.log(`⚙️ Settings for integration: ${args.id}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get integration settings:', error.message);\n process.exit(1);\n }\n}\n\nexport async function triggerIntegrationTool(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Integration ID is required');\n process.exit(1);\n }\n\n if (!args.method) {\n console.error('❌ Method name is required');\n process.exit(1);\n }\n\n // Parse data from JSON string or use empty object\n let data: Record<string, string> = {};\n if (args.data) {\n try {\n data = JSON.parse(args.data);\n } catch (error: any) {\n console.error('❌ Failed to parse data JSON:', error.message);\n process.exit(1);\n }\n }\n\n try {\n const result = await api.triggerIntegrationTool(args.id, args.method, data);\n console.log(`🔧 Tool result for ${args.method}:`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to trigger tool:', error.message);\n process.exit(1);\n }\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\n\nexport async function getAnalytics(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Integration ID is required');\n process.exit(1);\n }\n\n const date = args.date || '7';\n\n try {\n const result = await api.getAnalytics(args.id, date);\n console.log(`📊 Analytics for integration: ${args.id}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get analytics:', error.message);\n process.exit(1);\n }\n}\n\nexport async function getPostAnalytics(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.id) {\n console.error('❌ Post ID is required');\n process.exit(1);\n }\n\n const date = args.date || '7';\n\n try {\n const result = await api.getPostAnalytics(args.id, date);\n console.log(`📊 Analytics for post: ${args.id}`);\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to get post analytics:', error.message);\n process.exit(1);\n }\n}\n","import { PostizAPI } from '../api';\nimport { getConfig } from '../config';\nimport { readFileSync } from 'fs';\n\nexport async function uploadFile(args: any) {\n const config = getConfig();\n const api = new PostizAPI(config);\n\n if (!args.file) {\n console.error('❌ File path is required');\n process.exit(1);\n }\n\n try {\n const fileBuffer = readFileSync(args.file);\n const filename = args.file.split('/').pop() || 'file';\n\n const result = await api.upload(fileBuffer, filename);\n console.log('✅ File uploaded successfully!');\n console.log(JSON.stringify(result, null, 2));\n return result;\n } catch (error: any) {\n console.error('❌ Failed to upload file:', error.message);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAkB;AAClB,qBAAwB;;;ACDxB,wBAAgC;AAOzB,IAAM,YAAN,MAAgB;AAAA,EAIrB,YAAY,QAAsB;AAChC,SAAK,SAAS,OAAO;AACrB,SAAK,SAAS,OAAO,UAAU;AAAA,EACjC;AAAA,EAEA,MAAc,QAAQ,UAAkB,UAAe,CAAC,GAAG;AACzD,UAAM,MAAM,GAAG,KAAK,MAAM,GAAG,QAAQ;AACrC,UAAM,UAAU;AAAA,MACd,gBAAgB;AAAA,MAChB,eAAe,KAAK;AAAA,OACjB,QAAQ;AAGb,QAAI;AACF,YAAM,WAAW,UAAM,kBAAAA,SAAM,KAAK,iCAC7B,UAD6B;AAAA,QAEhC;AAAA,MACF,EAAC;AAED,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,QAAQ,M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;AAAA,EACA,CAACA,WAAgB;AACf,WAAOA,OACJ,WAAW,MAAM;AAAA,MAChB,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA,OAAO,QAAQ;AAAA,MACd,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC,EACA;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC;AAAA,MACC;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAACA,WAAgB;AACf,WAAOA,OACJ,WAAW,QAAQ;AAAA,MAClB,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA,QAAQ,yBAAyB,iBAAiB;AAAA,EACvD;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAACA,WAAgB;AACf,WAAOA,OACJ,OAAO,eAAe;AAAA,MACrB,UAAU;AAAA,MACV,MAAM;AAAA,IACR,CAAC,EACA;AAAA,MACC;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAC;AAAA,EACD;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAC;AAAA,EACD;AACF,EACC,cAAc,GAAG,+BAA+B,EAChD,KAAK,EACL,MAAM,KAAK,MAAM,EACjB,QAAQ,EACR,MAAM,KAAK,SAAS,EACpB;AAAA,EACC;AACF,EACC,MAAM;","names":["fetch","import_node_fetch","fetch","import_fs","import_fs","yargs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postiz",
3
- "version": "2.0.12",
3
+ "version": "2.1.0",
4
4
  "description": "Postiz CLI - Command line interface for the Postiz social media scheduling API",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -43,6 +43,7 @@
43
43
  "node": ">=18.0.0"
44
44
  },
45
45
  "dependencies": {
46
+ "@types/pg": "^8.20.0",
46
47
  "node-fetch": "^3.3.2",
47
48
  "yargs": "^17.7.2"
48
49
  },