postgresai 0.11.0-alpha.1 → 0.11.0-alpha.10
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 +143 -17
- package/bin/postgres-ai.ts +1011 -0
- package/dist/bin/postgres-ai.d.ts +3 -0
- package/dist/bin/postgres-ai.d.ts.map +1 -0
- package/dist/bin/postgres-ai.js +898 -0
- package/dist/bin/postgres-ai.js.map +1 -0
- package/dist/lib/auth-server.d.ts +31 -0
- package/dist/lib/auth-server.d.ts.map +1 -0
- package/dist/lib/auth-server.js +263 -0
- package/dist/lib/auth-server.js.map +1 -0
- package/dist/lib/config.d.ts +45 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +181 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/pkce.d.ts +32 -0
- package/dist/lib/pkce.d.ts.map +1 -0
- package/dist/lib/pkce.js +101 -0
- package/dist/lib/pkce.js.map +1 -0
- package/dist/package.json +42 -0
- package/lib/auth-server.ts +267 -0
- package/lib/config.ts +161 -0
- package/lib/pkce.ts +79 -0
- package/package.json +17 -7
- package/tsconfig.json +28 -0
- package/bin/postgres-ai.js +0 -360
package/README.md
CHANGED
|
@@ -1,31 +1,157 @@
|
|
|
1
|
-
|
|
1
|
+
# PostgresAI CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for PostgresAI monitoring and database management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### From npm
|
|
2
8
|
|
|
3
|
-
### run without install
|
|
4
9
|
```bash
|
|
5
|
-
npm
|
|
6
|
-
node ./cli/bin/postgres-ai.js --help
|
|
10
|
+
npm install -g postgresai@alpha
|
|
7
11
|
```
|
|
8
12
|
|
|
9
|
-
###
|
|
13
|
+
### From Homebrew (macOS)
|
|
14
|
+
|
|
10
15
|
```bash
|
|
11
|
-
#
|
|
12
|
-
|
|
16
|
+
# Add the PostgresAI tap
|
|
17
|
+
brew tap postgres-ai/tap https://gitlab.com/postgres-ai/homebrew-tap.git
|
|
18
|
+
|
|
19
|
+
# Install postgresai
|
|
20
|
+
brew install postgresai
|
|
21
|
+
```
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
|
|
16
|
-
exec zsh -l
|
|
23
|
+
## Usage
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
The CLI provides three command aliases:
|
|
26
|
+
```bash
|
|
19
27
|
postgres-ai --help
|
|
20
|
-
|
|
28
|
+
postgresai --help
|
|
29
|
+
pgai --help # short alias
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
### Authentication
|
|
35
|
+
|
|
36
|
+
Authenticate via browser to obtain API key:
|
|
37
|
+
```bash
|
|
38
|
+
pgai auth
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This will:
|
|
42
|
+
- Open your browser for authentication
|
|
43
|
+
- Prompt you to select an organization
|
|
44
|
+
- Automatically save your API key to `~/.config/postgresai/config.json`
|
|
45
|
+
|
|
46
|
+
### Start monitoring
|
|
47
|
+
|
|
48
|
+
Start monitoring with demo database:
|
|
49
|
+
```bash
|
|
50
|
+
postgres-ai mon quickstart --demo
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This will:
|
|
54
|
+
- Generate secure Grafana password
|
|
55
|
+
- Start all monitoring services
|
|
56
|
+
- Open Grafana at http://localhost:3000
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
### Monitoring services management (`mon` group)
|
|
61
|
+
```bash
|
|
62
|
+
postgres-ai mon start # Start monitoring services
|
|
63
|
+
postgres-ai mon stop # Stop monitoring services
|
|
64
|
+
postgres-ai mon restart # Restart all monitoring services
|
|
65
|
+
postgres-ai mon status # Show monitoring services status
|
|
66
|
+
postgres-ai mon logs [service] # Show logs for monitoring services
|
|
67
|
+
postgres-ai mon health # Check monitoring services health
|
|
68
|
+
postgres-ai mon config # Show monitoring configuration
|
|
69
|
+
postgres-ai mon update-config # Apply monitoring configuration
|
|
70
|
+
postgres-ai mon update # Update monitoring stack
|
|
71
|
+
postgres-ai mon reset [service] # Reset monitoring service
|
|
72
|
+
postgres-ai mon clean # Cleanup monitoring services artifacts
|
|
73
|
+
postgres-ai mon check # System readiness check
|
|
74
|
+
postgres-ai mon generate-grafana-password # Generate Grafana password
|
|
75
|
+
postgres-ai mon show-grafana-credentials # Show Grafana credentials
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Instance management
|
|
79
|
+
```bash
|
|
80
|
+
postgres-ai list-instances # List configured instances
|
|
81
|
+
postgres-ai add-instance <conn-string> <name> # Add new instance
|
|
82
|
+
postgres-ai remove-instance <name> # Remove instance
|
|
83
|
+
postgres-ai test-instance <name> # Test instance connectivity
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Authentication and API key management
|
|
87
|
+
```bash
|
|
88
|
+
postgres-ai auth # Authenticate via browser (recommended)
|
|
89
|
+
postgres-ai add-key <key> # Manually store API key
|
|
90
|
+
postgres-ai show-key # Show stored key (masked)
|
|
91
|
+
postgres-ai remove-key # Remove stored key
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Configuration
|
|
95
|
+
|
|
96
|
+
The CLI stores configuration in `~/.config/postgresai/config.json` including:
|
|
97
|
+
- API key
|
|
98
|
+
- Base URL
|
|
99
|
+
- Organization ID
|
|
100
|
+
|
|
101
|
+
### Configuration priority
|
|
102
|
+
|
|
103
|
+
API key resolution order:
|
|
104
|
+
1. Command line option (`--api-key`)
|
|
105
|
+
2. Environment variable (`PGAI_API_KEY`)
|
|
106
|
+
3. User config file (`~/.config/postgresai/config.json`)
|
|
107
|
+
4. Legacy project config (`.pgwatch-config`)
|
|
108
|
+
|
|
109
|
+
### Environment variables
|
|
110
|
+
|
|
111
|
+
- `PGAI_API_KEY` - API key for PostgresAI services
|
|
112
|
+
- `PGAI_API_BASE_URL` - API endpoint for backend RPC (default: `https://postgres.ai/api/general/`)
|
|
113
|
+
- `PGAI_UI_BASE_URL` - UI endpoint for browser routes (default: `https://console.postgres.ai`)
|
|
114
|
+
|
|
115
|
+
### CLI options
|
|
116
|
+
|
|
117
|
+
- `--api-base-url <url>` - overrides `PGAI_API_BASE_URL`
|
|
118
|
+
- `--ui-base-url <url>` - overrides `PGAI_UI_BASE_URL`
|
|
119
|
+
|
|
120
|
+
### Examples
|
|
121
|
+
|
|
122
|
+
Linux/macOS (bash/zsh):
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
export PGAI_API_BASE_URL=https://v2.postgres.ai/api/general/
|
|
126
|
+
export PGAI_UI_BASE_URL=https://console.postgres.ai
|
|
127
|
+
pgai auth --debug
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Windows PowerShell:
|
|
131
|
+
|
|
132
|
+
```powershell
|
|
133
|
+
$env:PGAI_API_BASE_URL = "https://v2.postgres.ai/api/general/"
|
|
134
|
+
$env:PGAI_UI_BASE_URL = "https://console.postgres.ai"
|
|
135
|
+
pgai auth --debug
|
|
21
136
|
```
|
|
22
137
|
|
|
23
|
-
|
|
138
|
+
Via CLI options (overrides env):
|
|
139
|
+
|
|
24
140
|
```bash
|
|
25
|
-
|
|
141
|
+
pgai auth --debug \
|
|
142
|
+
--api-base-url https://v2.postgres.ai/api/general/ \
|
|
143
|
+
--ui-base-url https://console.postgres.ai
|
|
26
144
|
```
|
|
27
145
|
|
|
28
|
-
|
|
29
|
-
- `
|
|
30
|
-
|
|
146
|
+
Notes:
|
|
147
|
+
- If `PGAI_UI_BASE_URL` is not set, the default is `https://console.postgres.ai`.
|
|
148
|
+
|
|
149
|
+
## Requirements
|
|
150
|
+
|
|
151
|
+
- Node.js 18 or higher
|
|
152
|
+
- Docker and Docker Compose
|
|
153
|
+
|
|
154
|
+
## Learn more
|
|
31
155
|
|
|
156
|
+
- Documentation: https://postgres.ai/docs
|
|
157
|
+
- Issues: https://gitlab.com/postgres-ai/postgres_ai/-/issues
|