pushnetgo-cli 1.1.1 → 1.2.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
@@ -7,120 +7,64 @@ Command-line tool for PushNetGo App — sync music, validate API keys.
7
7
  ```bash
8
8
  npm install -g pushnetgo-cli
9
9
  export MYAPP_API_KEY="pushnetgo-xxx"
10
- pushnetgo-cli token check
11
- pushnetgo-cli api-url
12
- pushnetgo-cli sync-music --url "https://..."
10
+ pushnetgo-cli
13
11
  ```
14
12
 
15
- **Three commands. No Firebase config needed. Works on any machine.**
13
+ ## API Endpoint
16
14
 
17
- ## Install
15
+ All operations use one endpoint:
18
16
 
19
- ```bash
20
- npm install -g pushnetgo-cli
21
17
  ```
22
-
23
- Or run without installing:
24
-
25
- ```bash
26
- npx pushnetgo-cli token check --key pushnetgo-xxx
18
+ POST https://flutter-ai-playground-f8e3b.web.app/api
19
+ Auth: x-api-key: pushnetgo-xxx
27
20
  ```
28
21
 
29
- ## HTTP API Endpoints
22
+ ### 3 Operations
30
23
 
31
- | URL | Purpose |
32
- |-----|---------|
33
- | `https://flutter-ai-playground-f8e3b.web.app/api/pushnetgo-upload` | Upload music from URL |
34
- | `https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi` | All actions (token-check, sync-music) |
35
-
36
- Auth: `x-api-key: pushnetgo-xxx`
37
-
38
- ### Actions
39
-
40
- #### token-check
24
+ #### 1. Verify Key
41
25
 
42
26
  ```bash
43
- curl -X POST https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi \
27
+ curl -X POST https://flutter-ai-playground-f8e3b.web.app/api \
44
28
  -H "Content-Type: application/json" \
45
29
  -H "x-api-key: pushnetgo-xxx" \
46
30
  -d '{"action":"token-check"}'
47
31
  ```
48
32
 
49
- #### sync-music
50
-
51
- Download an MP3 from URL and upload to PushNetGo project.
33
+ #### 2. Upload Music
52
34
 
53
35
  ```bash
54
- curl -X POST https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi \
36
+ curl -X POST https://flutter-ai-playground-f8e3b.web.app/api \
55
37
  -H "Content-Type: application/json" \
56
38
  -H "x-api-key: pushnetgo-xxx" \
57
- -d '{"action":"sync-music","projectId":"my-project","url":"https://example.com/track.mp3"}'
58
- ```
59
-
60
- ## CLI Usage
61
-
62
- Set your API key as an environment variable:
63
-
64
- ```bash
65
- export MYAPP_API_KEY="pushnetgo-xxx"
66
- ```
67
-
68
- Or pass it with each command:
69
-
70
- ```bash
71
- pushnetgo-cli --key pushnetgo-xxx <command>
39
+ -d '{"action":"sync-music","url":"https://example.com/track.mp3","title":"My Song"}'
72
40
  ```
73
41
 
74
- ### Commands
75
-
76
- #### sync-music
77
-
78
- Upload local MP3 files or import from URL:
42
+ #### 3. Download Music
79
43
 
80
44
  ```bash
81
- # Upload from local directory
82
- pushnetgo-cli sync-music --project radio99 --dir /path/to/mp3
83
-
84
- # Import from URL
85
- pushnetgo-cli sync-music --project radio99 --url "https://api.mureka.ai/output.mp3"
86
- ```
87
-
88
- #### token check
89
-
90
- Validate an API key:
45
+ # First get track info
46
+ curl -X POST https://flutter-ai-playground-f8e3b.web.app/api \
47
+ -H "x-api-key: pushnetgo-xxx" \
48
+ -d '{"action":"music_list"}'
91
49
 
92
- ```bash
93
- pushnetgo-cli token check
94
- pushnetgo-cli token check --key pushnetgo-xxx
50
+ # Then download from the returned downloadUrl
51
+ curl -O "https://storage.googleapis.com/flutter-ai-playground-f8e3b.firebasestorage.app/music_files/xxx.mp3"
95
52
  ```
96
53
 
97
- ## Uploading Music (Avoid 403)
98
-
99
- Do NOT call Firebase Storage REST API directly — requests will be blocked by Security Rules (App Check).
100
-
101
- Use the Cloud Functions endpoint or CLI instead:
54
+ ## Commands
102
55
 
103
56
  ```bash
104
- # HTTP API (any language)
105
- curl -X POST https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi \
106
- -H "Content-Type: application/json" \
107
- -H "x-api-key: pushnetgo-xxx" \
108
- -d '{"action":"sync-music","projectId":"p1","url":"https://..."}'
109
-
110
- # CLI
111
- pushnetgo-cli sync-music --url "https://api.mureka.ai/output.mp3"
57
+ pushnetgo-cli chat "hello" — AI chat
58
+ pushnetgo-cli music list — list tracks
59
+ pushnetgo-cli music get <id> — track info
60
+ pushnetgo-cli music download <id> — download to local
61
+ pushnetgo-cli music upload --url URL — upload from URL
62
+ pushnetgo-cli music delete <id> — delete track
63
+ pushnetgo-cli token check — validate key
112
64
  ```
113
65
 
114
- Both methods use server-side Firebase Admin SDK to bypass Storage rules.
115
-
116
66
  ## API Key Format
117
67
 
118
- PushNetGo API keys use the format:
119
-
120
68
  ```
121
69
  pushnetgo-{32-character-hex-uuid}
122
70
  ```
123
-
124
- Example: `pushnetgo-6d122db2132d4a94a91a46e529fd2752`
125
-
126
- Keys are generated from the PushNetGo App Token Hub.
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { Command } = require('commander');
4
4
  const program = new Command();
5
- const API_URL = 'https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi';
5
+ const API_URL = 'https://flutter-ai-playground-f8e3b.web.app/api';
6
6
  const VERSION = require('../package.json').version;
7
7
 
8
8
  program
@@ -109,10 +109,10 @@ if (process.argv.length <= 2) {
109
109
  Token:
110
110
  pushnetgo-cli token check — validate key
111
111
  pushnetgo-cli api-url — HTTP endpoint
112
- pushnetgo-cli --help — all options
113
112
 
114
- Public guide (no auth): GET https://flutter-ai-playground-f8e3b.web.app/api
115
- HTTP endpoint: ${API_URL}
113
+ Setup guide: curl -s https://flutter-ai-playground-f8e3b.web.app/guide.sh | bash
114
+ Public API: POST https://flutter-ai-playground-f8e3b.web.app/api
115
+ Auth: x-api-key: pushnetgo-xxx
116
116
  Auth: x-api-key: pushnetgo-xxx
117
117
 
118
118
  No Firebase config needed. Any machine.`);
package/guide.sh ADDED
@@ -0,0 +1,78 @@
1
+ #!/bin/bash
2
+ # PushNetGo Setup Guide — for AI agents and users
3
+ # Usage: curl -s https://flutter-ai-playground-f8e3b.web.app/guide.sh | bash
4
+ # or: curl -s https://...web.app/guide.sh | bash -s pushnetgo-xxx
5
+
6
+ set -e
7
+
8
+ KEY="${1:-$MYAPP_API_KEY}"
9
+ CLI="pushnetgo-cli"
10
+ API="https://flutter-ai-playground-f8e3b.web.app/api"
11
+ UPLOAD="https://flutter-ai-playground-f8e3b.web.app/api"
12
+
13
+ echo ""
14
+ echo "=============================================="
15
+ echo " PushNetGo Setup Guide"
16
+ echo "=============================================="
17
+ echo ""
18
+
19
+ # Step 1: Install CLI
20
+ echo "[1/4] Installing $CLI..."
21
+ if command -v $CLI &>/dev/null; then
22
+ echo " Already installed."
23
+ elif command -v npm &>/dev/null; then
24
+ npm install -g pushnetgo-cli 2>/dev/null && echo " Installed." || echo " npm install failed (non-critical)."
25
+ else
26
+ echo " npm not found. Skip CLI install. Use HTTP API directly."
27
+ fi
28
+
29
+ # Step 2: Key setup
30
+ if [ -z "$KEY" ]; then
31
+ echo "[2/4] No key provided. Usage:"
32
+ echo " export MYAPP_API_KEY=\"pushnetgo-xxx\""
33
+ echo " Generate key from: PushNetGo App > Admin > Token Hub"
34
+ echo ""
35
+ else
36
+ echo "[2/4] Using key: ${KEY:0:20}..."
37
+ if [ ! "$KEY" = "pushnetgo-"* ]; then
38
+ echo " WARNING: Key does not start with pushnetgo-. Format should be: pushnetgo-{32-hex}"
39
+ fi
40
+ fi
41
+
42
+ # Step 3: Verify key via HTTP API
43
+ if [ -n "$KEY" ] && [ "$KEY" = "pushnetgo-"* ]; then
44
+ echo "[3/4] Verifying key..."
45
+ RESULT=$(curl -sf -X POST "$API" -H "Content-Type: application/json" -H "x-api-key: $KEY" -d '{"action":"token-check"}' 2>/dev/null)
46
+ if echo "$RESULT" | grep -q '"active":true'; then
47
+ echo " Key is ACTIVE."
48
+ elif echo "$RESULT" | grep -q '"active":false'; then
49
+ echo " Key is INACTIVE. Generate a new one from PushNetGo Token Hub."
50
+ else
51
+ echo " Could not verify (network error or invalid key)."
52
+ fi
53
+ elif [ -n "$KEY" ]; then
54
+ echo "[3/4] Skipping verification (invalid format)."
55
+ else
56
+ echo "[3/4] Skipping verification (no key)."
57
+ fi
58
+
59
+ # Step 4: Show menu
60
+ echo "[4/4] Available commands:"
61
+ echo ""
62
+ echo " CLI (npm install -g pushnetgo-cli):"
63
+ echo " $CLI chat \"hello\" — AI chat"
64
+ echo " $CLI music list — list tracks"
65
+ echo " $CLI music get <id> — track info"
66
+ echo " $CLI music download <id> — download to local"
67
+ echo " $CLI music upload --url URL — upload from URL"
68
+ echo " $CLI music delete <id> — delete track"
69
+ echo " $CLI token check — validate key"
70
+ echo " $CLI api-url — show HTTP endpoint"
71
+ echo ""
72
+ echo " HTTP API (any language, no install):"
73
+ echo " curl -X POST $API -H \"x-api-key: YOUR_KEY\" -d '{\"action\":\"token-check\"}'"
74
+ echo " curl -X POST $UPLOAD -H \"x-api-key: YOUR_KEY\" -d '{\"action\":\"sync-music\",\"url\":\"https://...\"}'"
75
+ echo ""
76
+ echo " Public guide: GET https://flutter-ai-playground-f8e3b.web.app/api"
77
+ echo "=============================================="
78
+ echo ""
@@ -1,7 +1,7 @@
1
1
  const https = require('https');
2
2
  const http = require('http');
3
3
 
4
- const API_URL = 'https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi';
4
+ const API_URL = 'https://flutter-ai-playground-f8e3b.web.app/api';
5
5
 
6
6
  const fs = require('fs');
7
7
  const path = require('path');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushnetgo-cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "PushNetGo App CLI — HTTP API: https://us-central1-flutter-ai-playground-f8e3b.cloudfunctions.net/unifiedGatewayApi",
5
5
  "bin": {
6
6
  "pushnetgo-cli": "./bin/pushnetgo-cli.js"