@optima-chat/bi-cli 0.3.1 → 0.3.3
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 +144 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +9 -1
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# @optima-chat/bi-cli
|
|
2
|
+
|
|
3
|
+
Optima BI CLI - AI-friendly business intelligence tool for e-commerce analytics.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @optima-chat/bi-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Authentication
|
|
12
|
+
|
|
13
|
+
bi-cli uses unified authentication via `~/.optima/token.json`, shared with `commerce-cli` and `optima-agent`.
|
|
14
|
+
|
|
15
|
+
### Login
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Login to production (default)
|
|
19
|
+
bi-cli auth login
|
|
20
|
+
|
|
21
|
+
# Login to stage environment
|
|
22
|
+
bi-cli auth login --env stage
|
|
23
|
+
|
|
24
|
+
# Login to development environment
|
|
25
|
+
bi-cli auth login --env development
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Check Status
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Show current user
|
|
32
|
+
bi-cli auth whoami
|
|
33
|
+
|
|
34
|
+
# Show authentication status
|
|
35
|
+
bi-cli auth status
|
|
36
|
+
|
|
37
|
+
# Logout
|
|
38
|
+
bi-cli auth logout
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Environment Configuration
|
|
42
|
+
|
|
43
|
+
| Environment | Auth URL | Backend URL |
|
|
44
|
+
| ----------- | --------------------- | ----------------------- |
|
|
45
|
+
| production | auth.optima.onl | bi-api.optima.onl |
|
|
46
|
+
| stage | auth.stage.optima.onl | bi-api.stage.optima.onl |
|
|
47
|
+
| development | auth.optima.chat | bi-api.optima.chat |
|
|
48
|
+
|
|
49
|
+
### Token Priority
|
|
50
|
+
|
|
51
|
+
1. `BI_CLI_TOKEN` environment variable
|
|
52
|
+
2. `OPTIMA_TOKEN` environment variable
|
|
53
|
+
3. `~/.optima/token.json` file
|
|
54
|
+
|
|
55
|
+
### Environment Variables
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Override token
|
|
59
|
+
export BI_CLI_TOKEN="your-access-token"
|
|
60
|
+
|
|
61
|
+
# Override URLs
|
|
62
|
+
export BI_CLI_BACKEND_URL="https://custom-api.example.com"
|
|
63
|
+
export BI_CLI_AUTH_URL="https://custom-auth.example.com"
|
|
64
|
+
|
|
65
|
+
# Override environment
|
|
66
|
+
export BI_CLI_ENV="stage"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Commands
|
|
70
|
+
|
|
71
|
+
### Sales Analytics
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Get sales data
|
|
75
|
+
bi-cli sales get
|
|
76
|
+
bi-cli sales get --days 30
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Product Analytics
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Best selling products
|
|
83
|
+
bi-cli product best-sellers
|
|
84
|
+
bi-cli product best-sellers --limit 10
|
|
85
|
+
|
|
86
|
+
# ABC inventory analysis
|
|
87
|
+
bi-cli product abc-analysis
|
|
88
|
+
|
|
89
|
+
# Price point analysis
|
|
90
|
+
bi-cli product price-analysis
|
|
91
|
+
|
|
92
|
+
# Product performance
|
|
93
|
+
bi-cli product performance
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Trend Analytics
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Revenue trends
|
|
100
|
+
bi-cli trends revenue
|
|
101
|
+
bi-cli trends revenue --days 30
|
|
102
|
+
|
|
103
|
+
# Orders heatmap
|
|
104
|
+
bi-cli trends heatmap
|
|
105
|
+
|
|
106
|
+
# Seasonal patterns
|
|
107
|
+
bi-cli trends seasonality
|
|
108
|
+
|
|
109
|
+
# Revenue forecast
|
|
110
|
+
bi-cli trends forecast
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Advanced Analytics
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Compare periods
|
|
117
|
+
bi-cli analytics compare
|
|
118
|
+
bi-cli analytics compare --days 30
|
|
119
|
+
|
|
120
|
+
# Growth trends
|
|
121
|
+
bi-cli analytics growth
|
|
122
|
+
|
|
123
|
+
# Customer cohort analysis
|
|
124
|
+
bi-cli analytics cohort
|
|
125
|
+
|
|
126
|
+
# Order funnel analysis
|
|
127
|
+
bi-cli analytics funnel
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## JSON Output
|
|
131
|
+
|
|
132
|
+
All commands output JSON by default, making it easy to integrate with AI agents and other tools.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Pipe to jq for formatting
|
|
136
|
+
bi-cli sales get | jq .
|
|
137
|
+
|
|
138
|
+
# Use with AI agents
|
|
139
|
+
bi-cli product best-sellers --limit 5 | your-ai-tool
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
3
6
|
import { createAuthCommand } from './commands/auth.js';
|
|
4
7
|
import { createSalesCommand } from './commands/sales.js';
|
|
5
8
|
import { createProductCommand } from './commands/product.js';
|
|
6
9
|
import { createTrendsCommand } from './commands/trends.js';
|
|
7
10
|
import { createAnalyticsCommand } from './commands/analytics.js';
|
|
11
|
+
// Read version from package.json
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
8
15
|
const program = new Command();
|
|
9
16
|
program
|
|
10
17
|
.name('bi-cli')
|
|
11
18
|
.description('Optima BI CLI - AI-friendly business intelligence tool')
|
|
12
|
-
.version(
|
|
19
|
+
.version(pkg.version);
|
|
13
20
|
// Auth commands
|
|
14
21
|
program.addCommand(createAuthCommand());
|
|
15
22
|
// Sales commands
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,wDAAwD,CAAC;KACrE,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,O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;AAClC,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,oBAAoB,CAAC;KACjC,MAAM,CAAC,GAAG,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC;AAEL,mCAAmC;AACnC,OAAO;KACJ,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,qBAAqB,CAAC;KAClC,MAAM,CAAC,GAAG,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC;AAEL,+CAA+C;AAC/C,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,GAAG,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { dirname, join } from 'path';
|
|
4
7
|
import { createAuthCommand } from './commands/auth.js';
|
|
5
8
|
import { createSalesCommand } from './commands/sales.js';
|
|
6
9
|
import { createProductCommand } from './commands/product.js';
|
|
7
10
|
import { createTrendsCommand } from './commands/trends.js';
|
|
8
11
|
import { createAnalyticsCommand } from './commands/analytics.js';
|
|
9
12
|
|
|
13
|
+
// Read version from package.json
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
17
|
+
|
|
10
18
|
const program = new Command();
|
|
11
19
|
|
|
12
20
|
program
|
|
13
21
|
.name('bi-cli')
|
|
14
22
|
.description('Optima BI CLI - AI-friendly business intelligence tool')
|
|
15
|
-
.version(
|
|
23
|
+
.version(pkg.version);
|
|
16
24
|
|
|
17
25
|
// Auth commands
|
|
18
26
|
program.addCommand(createAuthCommand());
|