@hypequery/cli 1.1.0 → 1.1.2
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 +52 -154
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -2
- package/dist/commands/generate.js +1 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +140 -160
- package/dist/generators/clickhouse.d.ts +2 -0
- package/dist/generators/clickhouse.d.ts.map +1 -1
- package/dist/generators/clickhouse.js +84 -41
- package/dist/generators/index.js +1 -1
- package/dist/templates/client.js +1 -1
- package/dist/templates/env.d.ts +2 -1
- package/dist/templates/env.d.ts.map +1 -1
- package/dist/templates/env.js +5 -3
- package/dist/templates/queries.d.ts.map +1 -1
- package/dist/templates/queries.js +3 -2
- package/dist/test-utils.d.ts +0 -1
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +0 -1
- package/dist/utils/clickhouse-client.js +1 -1
- package/dist/utils/dependency-installer.d.ts +3 -1
- package/dist/utils/dependency-installer.d.ts.map +1 -1
- package/dist/utils/dependency-installer.js +75 -15
- package/dist/utils/load-api.d.ts +1 -0
- package/dist/utils/load-api.d.ts.map +1 -1
- package/dist/utils/load-api.js +79 -55
- package/dist/utils/load-hypequery-config.d.ts +7 -0
- package/dist/utils/load-hypequery-config.d.ts.map +1 -0
- package/dist/utils/load-hypequery-config.js +89 -0
- package/dist/utils/prompts.d.ts +0 -5
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/prompts.js +9 -34
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -1,211 +1,109 @@
|
|
|
1
1
|
# @hypequery/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI for scaffolding and running the main hypequery path.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use it to:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- generate schema types from ClickHouse
|
|
8
|
+
- scaffold `analytics/` files
|
|
9
|
+
- run the local dev server with docs
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
2. Build queries with the typed query builder
|
|
11
|
-
3. Wrap reusable queries with `query({ ... })`
|
|
12
|
-
4. Add `serve({ queries })` when you want HTTP routes and docs
|
|
11
|
+
## Quick Start
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
Run it directly:
|
|
15
14
|
|
|
16
15
|
```bash
|
|
17
|
-
# Initialize a new project
|
|
18
16
|
npx @hypequery/cli init
|
|
19
|
-
|
|
20
|
-
# Start development server
|
|
21
17
|
npx @hypequery/cli dev
|
|
22
|
-
|
|
23
|
-
# Generate types from database
|
|
24
18
|
npx @hypequery/cli generate
|
|
25
19
|
```
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
For frequent use, install as a dev dependency:
|
|
21
|
+
Or install it once:
|
|
30
22
|
|
|
31
23
|
```bash
|
|
32
24
|
npm install -D @hypequery/cli
|
|
33
|
-
# or
|
|
34
|
-
pnpm add -D @hypequery/cli
|
|
35
|
-
# or
|
|
36
|
-
yarn add -D @hypequery/cli
|
|
37
25
|
```
|
|
38
26
|
|
|
39
|
-
Then use the shorter `hypequery` command:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npx hypequery dev
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Or add to your `package.json` scripts:
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"scripts": {
|
|
50
|
-
"hypequery:init": "hypequery init",
|
|
51
|
-
"hypequery:dev": "hypequery dev",
|
|
52
|
-
"hypequery:generate": "hypequery generate"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## TypeScript Support
|
|
58
|
-
|
|
59
|
-
`hypequery dev` bundles a TypeScript runtime (powered by `tsx`), so pointing it at `analytics/queries.ts` or any `.ts/.tsx` file just works—no extra install or custom runner required. If your project already compiles to JavaScript you can keep targeting the generated `.js` file instead.
|
|
60
|
-
|
|
61
27
|
## Commands
|
|
62
28
|
|
|
63
29
|
### `hypequery init`
|
|
64
30
|
|
|
65
|
-
|
|
31
|
+
Scaffolds the standard hypequery setup.
|
|
66
32
|
|
|
67
33
|
```bash
|
|
68
|
-
# Without installation
|
|
69
|
-
npx @hypequery/cli init
|
|
70
|
-
|
|
71
|
-
# With installation
|
|
72
34
|
npx hypequery init
|
|
73
35
|
```
|
|
74
36
|
|
|
75
|
-
|
|
76
|
-
- Connects to your ClickHouse database
|
|
77
|
-
- Generates TypeScript types from your schema
|
|
78
|
-
- Creates the client, query, and serve files for the main path
|
|
79
|
-
- Sets up `.env` with connection details
|
|
80
|
-
- Updates `.gitignore` to protect secrets
|
|
81
|
-
|
|
82
|
-
**Options:**
|
|
83
|
-
- `--database <type>` - Database type (currently only `clickhouse`)
|
|
84
|
-
- `--path <path>` - Output directory (default: `analytics/`)
|
|
85
|
-
- `--no-example` - Skip example query generation
|
|
86
|
-
- `--no-interactive` - Non-interactive mode (uses environment variables)
|
|
87
|
-
- `--force` - Overwrite existing files without confirmation
|
|
88
|
-
|
|
89
|
-
**Example:**
|
|
90
|
-
```bash
|
|
91
|
-
# Interactive mode (recommended)
|
|
92
|
-
npx @hypequery/cli init
|
|
37
|
+
It will:
|
|
93
38
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
39
|
+
- generate schema types
|
|
40
|
+
- create client and query files
|
|
41
|
+
- write `.env` values
|
|
42
|
+
- update `.gitignore`
|
|
43
|
+
- install scaffold dependencies, including `zod`
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
|
|
47
|
+
- `--path <path>`: output directory, default `analytics/`
|
|
48
|
+
- `--no-example`: skip the example query
|
|
49
|
+
- `--no-interactive`: read connection details from env vars
|
|
50
|
+
- `--force`: overwrite existing scaffold files
|
|
51
|
+
- `--skip-connection`: skip testing the ClickHouse connection before scaffolding
|
|
97
52
|
|
|
98
53
|
### `hypequery dev`
|
|
99
54
|
|
|
100
|
-
|
|
55
|
+
Runs the local serve runtime with docs and hot reload.
|
|
101
56
|
|
|
102
57
|
```bash
|
|
103
|
-
# Without installation
|
|
104
|
-
npx @hypequery/cli dev
|
|
105
|
-
|
|
106
|
-
# With installation
|
|
107
58
|
npx hypequery dev
|
|
108
|
-
|
|
109
|
-
# With TypeScript file
|
|
110
|
-
npx @hypequery/cli dev src/analytics/queries.ts
|
|
111
59
|
```
|
|
112
60
|
|
|
113
|
-
|
|
114
|
-
- Starts a local HTTP server for your queries
|
|
115
|
-
- Provides interactive API documentation at `/docs`
|
|
116
|
-
- Auto-reloads on file changes
|
|
117
|
-
- Displays query execution stats
|
|
118
|
-
|
|
119
|
-
**Options:**
|
|
120
|
-
- `-p, --port <port>` - Port number (default: `4000`)
|
|
121
|
-
- `-h, --hostname <host>` - Hostname to bind (default: `localhost`)
|
|
122
|
-
- `--no-watch` - Disable file watching
|
|
123
|
-
- `--cache <provider>` - Cache provider (`memory` | `redis` | `none`)
|
|
124
|
-
- `--open` - Open browser automatically
|
|
125
|
-
- `--cors` - Enable CORS
|
|
126
|
-
- `-q, --quiet` - Suppress startup messages
|
|
127
|
-
|
|
128
|
-
**Example:**
|
|
129
|
-
```bash
|
|
130
|
-
# Basic usage
|
|
131
|
-
npx @hypequery/cli dev
|
|
61
|
+
Options:
|
|
132
62
|
|
|
133
|
-
|
|
134
|
-
|
|
63
|
+
- `--port <port>`: default `4000`
|
|
64
|
+
- `--hostname <host>`: default `localhost`
|
|
65
|
+
- `--no-watch`: disable file watching
|
|
66
|
+
- `--cache <provider>`: `memory`, `redis`, or `none`
|
|
67
|
+
- `--open`: open the browser automatically
|
|
68
|
+
- `--cors`: enable CORS
|
|
69
|
+
- `--quiet`: reduce startup output
|
|
135
70
|
|
|
136
|
-
|
|
137
|
-
npx @hypequery/cli dev --cache none
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Common Issues:**
|
|
141
|
-
|
|
142
|
-
If you see "Unexpected token" errors while loading your queries, double-check that you're pointing the CLI at the TypeScript source file (e.g. `analytics/queries.ts`). The CLI bundles the loader and should not require additional dependencies.
|
|
71
|
+
The CLI understands TypeScript entry files directly, so `analytics/queries.ts` works without an extra runner.
|
|
143
72
|
|
|
144
73
|
### `hypequery generate`
|
|
145
74
|
|
|
146
|
-
|
|
75
|
+
Regenerates schema types from ClickHouse.
|
|
147
76
|
|
|
148
77
|
```bash
|
|
149
|
-
# Without installation
|
|
150
|
-
npx @hypequery/cli generate
|
|
151
|
-
|
|
152
|
-
# With installation
|
|
153
78
|
npx hypequery generate
|
|
154
79
|
```
|
|
155
80
|
|
|
156
|
-
|
|
81
|
+
Options:
|
|
157
82
|
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
- Generates TypeScript interfaces for all tables
|
|
162
|
-
- Updates your schema file with type-safe definitions
|
|
83
|
+
- `--output <path>`: default `analytics/schema.ts`
|
|
84
|
+
- `--tables <names>`: comma-separated table list
|
|
85
|
+
- `--database <type>`: currently `clickhouse`
|
|
163
86
|
|
|
164
|
-
|
|
165
|
-
- `-o, --output <path>` - Output file (default: `analytics/schema.ts`)
|
|
166
|
-
- `--tables <names>` - Only generate for specific tables (comma-separated)
|
|
167
|
-
- `--database <type>` - Override detected database (currently only `clickhouse`)
|
|
87
|
+
## Non-interactive Setup
|
|
168
88
|
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
# Generate all tables
|
|
172
|
-
npx @hypequery/cli generate
|
|
173
|
-
|
|
174
|
-
# Generate specific tables
|
|
175
|
-
npx @hypequery/cli generate --tables users,events
|
|
176
|
-
|
|
177
|
-
# Custom output path
|
|
178
|
-
npx @hypequery/cli generate --output src/schema.ts
|
|
179
|
-
```
|
|
89
|
+
`hypequery init --no-interactive` reads:
|
|
180
90
|
|
|
181
|
-
|
|
91
|
+
- `CLICKHOUSE_URL` or deprecated `CLICKHOUSE_HOST`
|
|
92
|
+
- `CLICKHOUSE_DATABASE`
|
|
93
|
+
- `CLICKHOUSE_USERNAME` or `CLICKHOUSE_USER`
|
|
94
|
+
- `CLICKHOUSE_PASSWORD`
|
|
182
95
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
```json
|
|
186
|
-
{
|
|
187
|
-
"scripts": {
|
|
188
|
-
"db:init": "hypequery init",
|
|
189
|
-
"db:dev": "hypequery dev",
|
|
190
|
-
"db:generate": "hypequery generate"
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
Then run with:
|
|
196
|
-
```bash
|
|
197
|
-
npm run db:dev
|
|
198
|
-
```
|
|
96
|
+
## Notes
|
|
199
97
|
|
|
200
|
-
|
|
98
|
+
- generated scaffold files use NodeNext-safe local `.js` imports
|
|
99
|
+
- `CLICKHOUSE_URL` is now the preferred connection variable
|
|
100
|
+
- the CLI bundles the ClickHouse driver for schema generation
|
|
201
101
|
|
|
202
|
-
|
|
102
|
+
## Docs
|
|
203
103
|
|
|
204
|
-
- [Quick
|
|
205
|
-
- [
|
|
206
|
-
- [Query Building](https://hypequery.com/docs/query-building/basics)
|
|
207
|
-
- [Serve Runtime Reference](https://hypequery.com/docs/reference/runtime)
|
|
104
|
+
- [Quick start](https://hypequery.com/docs/quick-start)
|
|
105
|
+
- [CLI reference](https://hypequery.com/docs/reference/api/cli)
|
|
208
106
|
|
|
209
107
|
## License
|
|
210
108
|
|
|
211
|
-
Apache-2.0
|
|
109
|
+
Apache-2.0.
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,QAAA,MAAM,OAAO,SAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AAE9B,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;EAKpE;AA6FD,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -39,6 +50,9 @@ import { initCommand } from './commands/init.js';
|
|
|
39
50
|
import { devCommand } from './commands/dev.js';
|
|
40
51
|
import { generateCommand } from './commands/generate.js';
|
|
41
52
|
var program = new Command();
|
|
53
|
+
export function normalizeInitOptions(options) {
|
|
54
|
+
return __assign(__assign({}, options), { noInteractive: options.noInteractive === true || options.interactive === false });
|
|
55
|
+
}
|
|
42
56
|
program
|
|
43
57
|
.name('hypequery')
|
|
44
58
|
.description('Type-safe analytics layer for ClickHouse')
|
|
@@ -47,7 +61,6 @@ program
|
|
|
47
61
|
program
|
|
48
62
|
.command('init')
|
|
49
63
|
.description('Initialize a new hypequery project')
|
|
50
|
-
.option('--database <type>', 'Database type (clickhouse|bigquery)')
|
|
51
64
|
.option('--path <path>', 'Output directory (default: analytics/)')
|
|
52
65
|
.option('--no-example', 'Skip example query generation')
|
|
53
66
|
.option('--no-interactive', 'Non-interactive mode (use env vars)')
|
|
@@ -59,7 +72,7 @@ program
|
|
|
59
72
|
switch (_a.label) {
|
|
60
73
|
case 0:
|
|
61
74
|
_a.trys.push([0, 2, , 3]);
|
|
62
|
-
return [4 /*yield*/, initCommand(options)];
|
|
75
|
+
return [4 /*yield*/, initCommand(normalizeInitOptions(options))];
|
|
63
76
|
case 1:
|
|
64
77
|
_a.sent();
|
|
65
78
|
return [3 /*break*/, 3];
|
|
@@ -118,7 +118,7 @@ export function generateCommand() {
|
|
|
118
118
|
logger.indent('• Firewall blocking connection');
|
|
119
119
|
logger.newline();
|
|
120
120
|
logger.info('Check your configuration:');
|
|
121
|
-
logger.indent('
|
|
121
|
+
logger.indent('CLICKHOUSE_URL=' + (process.env.CLICKHOUSE_URL || process.env.CLICKHOUSE_HOST || 'not set'));
|
|
122
122
|
logger.newline();
|
|
123
123
|
logger.info('Docs: https://hypequery.com/docs/troubleshooting#connection-errors');
|
|
124
124
|
}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAiED,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAAgB,iBAwO1D"}
|