feat: refactor CLI to support multi-domain OSMAP token generation and update documentation accordingly
This commit is contained in:
@@ -1,143 +1,107 @@
|
|||||||
# OSMAP CLI - Embed Map Navigator & Token Manager
|
# OSMAP Embed Map & Token CLI
|
||||||
|
|
||||||
A lightweight CLI tool for developers and administrators to manage authentication tokens and quickly navigate or launch OSMAP KAI embed map routes across different environments (`live`, `beta`, `staging`, `demo`, `local`).
|
Unified CLI utility and API reference for generating embed tokens and URLs for all **OSMAP** domains:
|
||||||
|
1. **`app.osmap.id`** (Share-Map Token API)
|
||||||
|
2. **`live.osmap.id`** (KAI Live App Token)
|
||||||
|
3. **`beta.osmap.id`** (KAI Beta App Token)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ⚡ Quick Start (No Installation Needed)
|
## 🚀 cURL Reference by Domain
|
||||||
|
|
||||||
### 1. Prerequisites
|
### 1. New Share-Map System (`app.osmap.id`)
|
||||||
- **Bash** (`Git Bash`, `WSL`, `Linux`, or `macOS`)
|
**API Endpoint**: `POST https://api.osmap.id/apps/token/share-map`
|
||||||
- **`curl`**
|
**Embed Format**: `https://app.osmap.id/maps/embed/<map_id>?token=<token>`
|
||||||
- **`jq`** (JSON processor)
|
|
||||||
- **Windows (PowerShell as Admin)**: `choco install jq -y`
|
|
||||||
- **Ubuntu / Debian / WSL**: `sudo apt update && sudo apt install -y jq`
|
|
||||||
- **macOS**: `brew install jq`
|
|
||||||
|
|
||||||
---
|
#### Map 1: Accelerometer (Map ID: 94)
|
||||||
|
|
||||||
## 🚀 Running the CLI
|
|
||||||
|
|
||||||
### Option A: Direct Execution via `curl`
|
|
||||||
|
|
||||||
#### Using Git Bash / Linux / macOS:
|
|
||||||
```bash
|
```bash
|
||||||
curl -sSL https://git.oslog.pro/dandy/osmap_cli/raw/branch/main/osmap-embed.sh | bash
|
curl -X POST "https://api.osmap.id/apps/token/share-map" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"app_id":"6f728437e6c4d361fb811913b8acd70e","app_secret":"ab9419a7fed7c51a6ff6daf501d408f2aed25c0ccd148a6c18b76f54949f55d8","expires_in":86400,"map_id":94}'
|
||||||
```
|
```
|
||||||
|
|
||||||
To pass arguments / flags:
|
#### Map 2: ROCC (Map ID: 46)
|
||||||
```bash
|
```bash
|
||||||
# Open Executive Map directly in browser
|
curl -X POST "https://api.osmap.id/apps/token/share-map" \
|
||||||
curl -sSL https://git.oslog.pro/dandy/osmap_cli/raw/branch/main/osmap-embed.sh | bash -s -- executive --env live --open
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"app_id":"6f728437e6c4d361fb811913b8acd70e","app_secret":"ab9419a7fed7c51a6ff6daf501d408f2aed25c0ccd148a6c18b76f54949f55d8","expires_in":86400,"map_id":46}'
|
||||||
# Get all embed URLs for beta environment
|
|
||||||
curl -sSL https://git.oslog.pro/dandy/osmap_cli/raw/branch/main/osmap-embed.sh | bash -s -- all --env beta
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using Windows PowerShell:
|
#### Map 3: Genset (Map ID: 74)
|
||||||
```powershell
|
```bash
|
||||||
bash -c "curl -sSL https://git.oslog.pro/dandy/osmap_cli/raw/branch/main/osmap-embed.sh | bash"
|
curl -X POST "https://api.osmap.id/apps/token/share-map" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"app_id":"6f728437e6c4d361fb811913b8acd70e","app_secret":"ab9419a7fed7c51a6ff6daf501d408f2aed25c0ccd148a6c18b76f54949f55d8","expires_in":86400,"map_id":74}'
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Map 4: RCS (Map ID: 72)
|
||||||
|
```bash
|
||||||
|
curl -X POST "https://api.osmap.id/apps/token/share-map" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"app_id":"6f728437e6c4d361fb811913b8acd70e","app_secret":"ab9419a7fed7c51a6ff6daf501d408f2aed25c0ccd148a6c18b76f54949f55d8","expires_in":86400,"map_id":72}'
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Map 5: JPL (Map ID: 70)
|
||||||
|
```bash
|
||||||
|
curl -X POST "https://api.osmap.id/apps/token/share-map" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"app_id":"2ee1aa4876f6b7fa3c43c75ca1c83139","app_secret":"073d0929a74bb664c402de98d24153c1f9f2f648d59c381f2fef3c32610fa174","expires_in":86400,"map_id":70}'
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Option B: Clone & Run Locally
|
### 2. OSMAP KAI System (`live.osmap.id`)
|
||||||
|
**API Endpoint**: `POST https://live.osmap.id/api/apps/token`
|
||||||
|
**Embed Format**: `https://live.osmap.id/<route>?token=<token>`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.oslog.pro/dandy/osmap_cli.git
|
curl -X POST "https://live.osmap.id/api/apps/token" \
|
||||||
cd osmap_cli
|
-H "Content-Type: application/json" \
|
||||||
chmod +x osmap-embed.sh
|
-d '{
|
||||||
|
"app_id": "IrSIcf06QRwUCmsRCZ0JvsVibSfuPUG4",
|
||||||
|
"app_secret": "Z8tPOBHGbwWu9TrIddRqkiDFDymtiPAhMNbSz6aUOOTkqdZoQYuTWXTra5m2mPQa",
|
||||||
|
"expires_in_hours": 24
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
# Launch Interactive Menu
|
---
|
||||||
|
|
||||||
|
### 3. OSMAP KAI System (`beta.osmap.id`)
|
||||||
|
**API Endpoint**: `POST https://beta.osmap.id/api/apps/token`
|
||||||
|
**Embed Format**: `https://beta.osmap.id/<route>?token=<token>`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST "https://beta.osmap.id/api/apps/token" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"app_id": "IrSIcf06QRwUCmsRCZ0JvsVibSfuPUG4",
|
||||||
|
"app_secret": "Z8tPOBHGbwWu9TrIddRqkiDFDymtiPAhMNbSz6aUOOTkqdZoQYuTWXTra5m2mPQa",
|
||||||
|
"expires_in_hours": 24
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ CLI Usage (`osmap-embed.sh`)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x ./osmap-embed.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Launch Interactive Navigator
|
||||||
|
```bash
|
||||||
./osmap-embed.sh
|
./osmap-embed.sh
|
||||||
```
|
```
|
||||||
|
*Allows selecting maps from `app.osmap.id` or routes from `live.osmap.id` / `beta.osmap.id` with live environment switching!*
|
||||||
|
|
||||||
---
|
### Quick Commands
|
||||||
|
|
||||||
## 📖 Usage & Commands
|
| Goal | Command |
|
||||||
|
|---|---|
|
||||||
```bash
|
| Show all cURL commands | `./osmap-embed.sh curls` |
|
||||||
./osmap-embed.sh [route|command] [options]
|
| View `app.osmap.id` embed URLs | `./osmap-embed.sh all` |
|
||||||
```
|
| View `live.osmap.id` embed URLs | `./osmap-embed.sh all --env live` |
|
||||||
|
| View `beta.osmap.id` embed URLs | `./osmap-embed.sh all --env beta` |
|
||||||
### Commands
|
| Open map from `app.osmap.id` in browser | `./osmap-embed.sh accelerometer --open` |
|
||||||
|
| Open KAI route in browser | `./osmap-embed.sh executive --env live --open` |
|
||||||
| Command | Description |
|
| Get token string only | `./osmap-embed.sh token 94` or `./osmap-embed.sh token executive` |
|
||||||
| :--- | :--- |
|
|
||||||
| `interactive` *(default)* | Opens an interactive CLI menu to pick routes, copy tokens, or switch environments |
|
|
||||||
| `all` | Prints a formatted table of all map embed URLs with a valid token |
|
|
||||||
| `token` | Fetches and prints the raw active access token only |
|
|
||||||
| `validate` | Checks whether the locally cached token is still valid |
|
|
||||||
| `revoke` | Revokes active tokens on the server and clears local cache |
|
|
||||||
| `register` | Registers a new application and saves credentials |
|
|
||||||
|
|
||||||
### Available Map Routes
|
|
||||||
|
|
||||||
| Route Identifier | Map Name | Target Path |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| `executive` | Executive Map | `/executive` |
|
|
||||||
| `rolling` | Rolling Map | `/rolling` |
|
|
||||||
| `iris-jpl` | IRIS JPL | `/iris-jpl` |
|
|
||||||
| `iris-jpl-v2` | IRIS JPL (v2) | `/v2/iris-jpl` |
|
|
||||||
| `accelerometer` | Executive Accelerometer | `/executive/accelerometer` |
|
|
||||||
| `genset` | Genset Monitoring | `/genset` |
|
|
||||||
| `managerial` | Managerial / Asset View | `/managerial` |
|
|
||||||
| `fatigue` | Fatigue Monitoring | `/fatigue` |
|
|
||||||
| `sigap-tracker` | SIGAP Tracker | `/sigap-tracker` |
|
|
||||||
| `sigap-dashboard` | SIGAP Dashboard | `/sigap-dashboard` |
|
|
||||||
| `railway-cargo-system` | Railway Cargo System (RCS) | `/railway-cargo-system` |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ⚙️ Options & Flags
|
|
||||||
|
|
||||||
| Flag | Description | Default |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| `-e`, `--env <env>` | Target environment (`live`, `beta`, `staging`, `demo`, `local`, or custom URL) | `live` |
|
|
||||||
| `-o`, `--open` | Automatically open the generated URL in your default browser | `false` |
|
|
||||||
| `-c`, `--copy` | Automatically copy the URL to system clipboard | `false` |
|
|
||||||
| `--app-id <id>` | Override App ID credential | Default Built-in / Env |
|
|
||||||
| `--app-secret <sec>` | Override App Secret credential | Default Built-in / Env |
|
|
||||||
| `--save` | Save provided `--app-id` and `--app-secret` to `.osmap_credentials` | `false` |
|
|
||||||
| `-h`, `--help` | Show command line help and usage | - |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 💡 Examples
|
|
||||||
|
|
||||||
- **Interactive Menu (live environment):**
|
|
||||||
```bash
|
|
||||||
./osmap-embed.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Open IRIS JPL in browser on Live environment:**
|
|
||||||
```bash
|
|
||||||
./osmap-embed.sh iris-jpl --open
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Get the raw token string for scripts / automation:**
|
|
||||||
```bash
|
|
||||||
TOKEN=$(./osmap-embed.sh token --env live)
|
|
||||||
echo "Current Token: $TOKEN"
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Open Managerial Map on Beta environment:**
|
|
||||||
```bash
|
|
||||||
./osmap-embed.sh managerial --env beta --open
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Test against Local development server (`http://localhost:8000`):**
|
|
||||||
```bash
|
|
||||||
./osmap-embed.sh --env local
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔐 Credentials & Configuration Precedence
|
|
||||||
|
|
||||||
Credentials are automatically loaded in the following order:
|
|
||||||
1. CLI Flags (`--app-id`, `--app-secret`)
|
|
||||||
2. Environment Variables (`OSMAP_APP_ID`, `OSMAP_APP_SECRET`)
|
|
||||||
3. Local config file (`.osmap_credentials`)
|
|
||||||
4. Current directory `.env` file
|
|
||||||
5. Built-in default credentials
|
|
||||||
|
|||||||
+635
-404
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user