@hypequery/cli 1.16.2 → 1.16.4

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.
Files changed (2) hide show
  1. package/README.md +30 -301
  2. package/package.json +19 -7
package/README.md CHANGED
@@ -1,331 +1,60 @@
1
1
  # @hypequery/cli
2
2
 
3
- CLI for scaffolding and running the main hypequery path.
3
+ The fastest way to start a type-safe ClickHouse analytics backend in TypeScript.
4
4
 
5
- Use it to:
5
+ `@hypequery/cli` connects to ClickHouse or embedded chDB, generates schema types, scaffolds queries or semantic datasets, and runs a local API with interactive documentation. The same CLI can generate React route manifests and deploy a verified analytics bundle when you are ready.
6
6
 
7
- - generate schema types from ClickHouse or embedded chDB
8
- - scaffold `analytics/` files
9
- - run the local dev server with docs
10
- - build and validate portable deployment contracts
11
-
12
- ## Quick Start
13
-
14
- Run it directly:
15
-
16
- ```bash
17
- npx @hypequery/cli init
18
- npx @hypequery/cli dev
19
- npx @hypequery/cli generate
20
- ```
21
-
22
- Or install it once:
7
+ ## Start here
23
8
 
24
9
  ```bash
25
10
  npm install -D @hypequery/cli
26
- ```
27
-
28
- ## Commands
29
-
30
- ### `hypequery init`
31
-
32
- Scaffolds the standard hypequery setup.
33
-
34
- ```bash
35
11
  npx hypequery init
12
+ npx hypequery dev --open
36
13
  ```
37
14
 
38
- Interactive setup asks which database driver to use, whether to include
39
- request-context authentication scaffolding, where to write the generated
40
- files, and which API style to create. Selecting chDB replaces the remote
41
- credential questions with an embedded-storage choice.
42
-
43
- Run `init` from the project directory that contains `package.json`. If no
44
- package manifest is found, interactive setup asks for confirmation before
45
- writing files and dependency installation must be completed manually.
46
-
47
- It will:
48
-
49
- - connect to ClickHouse or start an embedded chDB session
50
- - generate schema types when the database is available
51
- - create client and query files
52
- - write `.env` values for ClickHouse connections
53
- - update `.gitignore`, including a project-local persistent chDB directory
54
- - install scaffold dependencies, including `zod` and the selected database adapter
55
-
56
- Options:
57
-
58
- - `--path <path>`: output directory, default `analytics/`
59
- - `--style <style>`: `queries` (default) or `datasets`
60
- - `--database <type>`: `clickhouse` (default) or `chdb`
61
- - `--chdb-path <path>`: persistent chDB data directory; omit for an in-memory session
62
- - `--auth <mode>`: `none` (default) or `context`
63
- - `--all-tables`: with `--style datasets`, scaffold every table
64
- - `--tables <names>`: with `--style datasets`, scaffold these comma-separated tables
65
- - `--exclude-tables <names>`: with `--style datasets`, exclude these comma-separated tables
66
- - `--no-example`: skip the example query
67
- - `--no-interactive`: skip prompts; ClickHouse connection details come from env vars
68
- - `--force`: overwrite existing scaffold files
69
- - `--skip-connection`: skip testing the selected database before scaffolding
70
-
71
- Set `HYPEQUERY_SKIP_INSTALL=1` to skip the automatic dependency install.
72
-
73
- To scaffold against persistent embedded chDB without server credentials:
74
-
75
- ```bash
76
- npx hypequery init --database chdb --chdb-path ./analytics.chdb --no-interactive
77
- ```
78
-
79
- ### `hypequery dev`
80
-
81
- Runs the local serve runtime with docs and hot reload.
82
-
83
- ```bash
84
- npx hypequery dev
85
- ```
86
-
87
- Options:
88
-
89
- - `--port <port>`: default `4000`
90
- - `--hostname <host>`: default `localhost`
91
- - `--path <path>`: analytics directory to load (`<path>/api.ts` or `<path>/queries.ts`)
92
- - `--no-watch`: disable file watching
93
- - `--open`: open the browser automatically
94
- - `--quiet`: reduce startup output
95
-
96
- The CLI understands TypeScript entry files directly, so `analytics/queries.ts` works without an extra runner.
97
-
98
- ### `hypequery generate`
99
-
100
- Regenerates schema types from ClickHouse or embedded chDB.
101
-
102
- ```bash
103
- npx hypequery generate
104
- ```
105
-
106
- Options:
107
-
108
- - `--output <path>`: default `analytics/schema.ts`
109
- - `--path <path>`: analytics directory (derives `<path>/schema.ts`)
110
- - `--tables <names>`: comma-separated table list
111
- - `--database <type>`: `clickhouse` or `chdb`; chDB generation must be selected explicitly
112
- - `--chdb-path <path>`: persistent chDB data directory; omit for an in-memory session
113
-
114
- For a persistent chDB scaffold, pass the same path used by `init`:
115
-
116
- ```bash
117
- npx hypequery generate --database chdb --chdb-path ./analytics.chdb
118
- ```
119
-
120
- `hypequery generate:types` is an alias for `hypequery generate`.
121
-
122
- ### `hypequery generate:datasets`
123
-
124
- Generates dataset (semantic layer) definitions from ClickHouse.
125
-
126
- ```bash
127
- npx hypequery generate:datasets
128
- ```
129
-
130
- Options:
131
-
132
- - `--output <path>`: default `src/datasets/generated.ts`
133
- - `--path <path>`: analytics directory (derives `<path>/datasets.ts`)
134
- - `--tables <names>`: comma-separated table list
135
- - `--exclude-tables <names>`: comma-separated tables to exclude
136
-
137
- ### `hypequery generate:manifest`
138
-
139
- Generates a static React hook route manifest from an exported HypeQuery API.
140
-
141
- ```bash
142
- npx hypequery generate:manifest analytics/api.ts --output analytics/hypequery-manifest.json
143
- ```
144
-
145
- The output is the exact serializable JSON returned by `api.manifest()`, including
146
- semantic keys such as `dataset:orders`.
147
-
148
- ### `hypequery deployment:build`
149
-
150
- Builds a closed deployment bundle for an exported HypeQuery API. The bundle
151
- contains canonical deployment metadata, every referenced runtime artifact, and
152
- a manifest that binds their exact bytes and identities. It is the first step of
153
- a deployment pipeline, and produces the input `deployment:release` binds to a
154
- target.
155
-
156
- ```bash
157
- npx hypequery deployment:build analytics/api.ts
158
- ```
159
-
160
- The default output is `analytics/hypequery-deployment/`. Named Serve handlers
161
- are bundled into a Node runtime artifact automatically. Dataset-only APIs do
162
- not produce a runtime artifact. For a separately built Node or Python runtime,
163
- provide both its expected digest and file path:
164
-
165
- ```bash
166
- npx hypequery deployment:build analytics/api.ts \
167
- --runtime python \
168
- --runtime-artifact <sha256> \
169
- --runtime-file dist/runtime.pyz
170
- ```
171
-
172
- Options:
173
-
174
- - `--bundle-output <directory>`: default `analytics/hypequery-deployment`
175
- - `--runtime <runtime>`: `node` (default) or `python`
176
- - `--runtime-artifact <sha256>`: lowercase SHA-256 of a prebuilt runtime artifact
177
- - `--runtime-file <path>`: bytes for the prebuilt runtime artifact
178
- - `--entrypoint-prefix <prefix>`: default `queries`
179
-
180
- The compatibility options `--output`, `--runtime-output`, and `--hash-output`
181
- still emit the earlier metadata files instead of a complete bundle. They cannot
182
- be combined with `--bundle-output`.
183
-
184
- ### `hypequery deployment:validate`
185
-
186
- Verifies a complete deployment bundle before returning any contained metadata.
187
- Verification rejects missing or undeclared files, symbolic links, path
188
- traversal, byte-length or hash mismatches, deployment identity mismatches, and
189
- runtime files not referenced by the deployment. Legacy deployment JSON files
190
- are still accepted for metadata-only validation.
191
-
192
- ```bash
193
- npx hypequery deployment:validate analytics/hypequery-deployment
194
- ```
195
-
196
- ### `hypequery deployment:release`
197
-
198
- Prepares a deterministic release request from a verified deployment bundle and
199
- a project/environment target. This command does not upload, authorize, or
200
- execute the release.
201
-
202
- Pass the target as both flags. A half-specified target is rejected rather than
203
- completed from anywhere else, so an unset shell variable fails loudly instead of
204
- silently retargeting the release. The resolved target is printed alongside the
205
- release identity:
206
-
207
- ```bash
208
- npx hypequery deployment:release analytics/hypequery-deployment \
209
- --project my-project \
210
- --environment production
211
- ```
212
-
213
- The default output is `analytics/hypequery-deployment.release.json`. It is
214
- written beside the bundle because adding it inside the closed bundle would
215
- invalidate bundle verification.
216
-
217
- Options:
218
-
219
- - `--project <project>`: target project identifier; must be paired with
220
- `--environment`
221
- - `--environment <environment>`: target environment identifier; must be paired
222
- with `--project`
223
- - `--output <path>`: release JSON path, default beside the bundle
224
-
225
- ### `hypequery deployment:submit`
226
-
227
- Submits a verified deployment bundle with an already-prepared target-bound
228
- release. The command verifies both inputs again, requires their bundle
229
- identities to match, and streams only the files declared by the bundle.
230
-
231
- ```bash
232
- npx hypequery deployment:submit analytics/hypequery-deployment \
233
- --release analytics/hypequery-deployment.release.json
234
- ```
235
-
236
- Set `HYPEQUERY_API_TOKEN` together with either `--endpoint` or
237
- `HYPEQUERY_DEPLOYMENT_ENDPOINT`. Tokens are never accepted as command-line
238
- arguments, keeping them out of shell history. The submission endpoint must not
239
- contain credentials or a URL fragment, and must use HTTPS except for
240
- `127.0.0.1`/`localhost`, which is permitted for local development and warns that
241
- the token is sent in cleartext. The release identity is sent as the idempotency
242
- key, so an unchanged release can be submitted safely again. An accepted release
243
- becomes live immediately. The CLI pins the upload to the current activation
244
- revision, so a concurrent deploy or restore returns a conflict. If the current
245
- release was restored, pass `--replace-restored` to confirm that a different
246
- release should replace it.
247
-
248
- Options:
249
-
250
- - `--release <path>`: required target-bound release JSON
251
- - `--endpoint <url>`: HTTPS submission endpoint; requires `HYPEQUERY_API_TOKEN`
252
- - `--replace-restored`: intentionally replace a restored live release
253
-
254
- ### `hypequery pull`
255
-
256
- Downloads the exact multi-file TypeScript source snapshot stored with the live
257
- release. Pull requires an interactive Cloud credential with source-read access;
258
- run `hypequery login` again if the credential predates this capability.
259
-
260
- ```bash
261
- npx hypequery pull
262
- ```
263
-
264
- By default the snapshot is written to a new release-specific directory under
265
- `.hypequery/live/<environment>/`. Use `--output <directory>` to choose another
266
- new directory. Pull never overwrites an existing path.
15
+ `init` checks the database, writes an `analytics/` project, generates types, and installs the packages used by the scaffold.
267
16
 
268
- ### `hypequery diff [source]`
269
-
270
- Compares the local TypeScript dependency graph with the live release snapshot
271
- and reports added (`A`), modified (`M`), and deleted (`D`) files. The deployed
272
- entrypoint is used when `source` is omitted.
17
+ For a semantic layer:
273
18
 
274
19
  ```bash
275
- npx hypequery diff analytics/api.ts
20
+ npx hypequery init --style datasets
276
21
  ```
277
22
 
278
- Both commands use the target selected by `hypequery login`. Advanced and CI
279
- usage can pass `--project`, `--environment`, and `--endpoint` explicitly.
280
-
281
- ## Non-interactive Setup
282
-
283
- ### Cloud deployment targets in CI
284
-
285
- Login selects a stable Cloud deployment target. The deployment itself captures
286
- the checked-out Git branch, commit, and dirty state as source provenance; none
287
- of those values select or create an environment. Select the destination
288
- explicitly when the same branch or commit deploys to more than one environment:
289
-
290
- ```bash
291
- npx hypequery login --environment development
292
- ```
293
-
294
- For CI, create a target-scoped API key in Cloud for each environment and store
295
- it as a separate secret. The explicit release target and its matching key make
296
- the destination independent of the source branch:
23
+ For embedded analytics without a ClickHouse server:
297
24
 
298
25
  ```bash
299
- HYPEQUERY_API_TOKEN="$HYPEQUERY_DEV_TOKEN" npx hypequery deploy analytics/api.ts \
300
- --project acme:analytics \
301
- --environment development
302
-
303
- HYPEQUERY_API_TOKEN="$HYPEQUERY_PROD_TOKEN" npx hypequery deploy analytics/api.ts \
304
- --project acme:analytics \
305
- --environment production
26
+ npx hypequery init \
27
+ --database chdb \
28
+ --chdb-path ./analytics.chdb
306
29
  ```
307
30
 
308
- Set `HYPEQUERY_DEPLOYMENT_ENDPOINT` for both jobs. A key is scoped to one target,
309
- so a production key cannot submit a development release or vice versa.
31
+ ## The commands you will use
310
32
 
311
- For ClickHouse, `hypequery init --no-interactive` reads:
33
+ | Command | Outcome |
34
+ | --- | --- |
35
+ | `hypequery init` | A working typed analytics project |
36
+ | `hypequery dev` | Local API, docs, and hot reload |
37
+ | `hypequery generate` | Fresh TypeScript types from ClickHouse or chDB |
38
+ | `hypequery generate:datasets` | Dataset definitions scaffolded from tables |
39
+ | `hypequery generate:manifest` | A browser-safe route manifest for React hooks |
40
+ | `hypequery login` | An authenticated Cloud target |
41
+ | `hypequery deploy` | A verified deployment of the analytics API |
42
+ | `hypequery pull` / `diff` | Live source inspection and comparison |
312
43
 
313
- - `CLICKHOUSE_URL` or deprecated `CLICKHOUSE_HOST`
314
- - `CLICKHOUSE_DATABASE`
315
- - `CLICKHOUSE_USERNAME` or `CLICKHOUSE_USER`
316
- - `CLICKHOUSE_PASSWORD`
44
+ Non-interactive ClickHouse commands read `CLICKHOUSE_URL`, `CLICKHOUSE_DATABASE`, `CLICKHOUSE_USERNAME`, and `CLICKHOUSE_PASSWORD`.
317
45
 
318
- ## Notes
46
+ ## Why use the CLI
319
47
 
320
- - generated scaffold files use NodeNext-safe local `.js` imports
321
- - `CLICKHOUSE_URL` is now the preferred connection variable
322
- - the CLI bundles the ClickHouse driver for schema generation
323
- - chDB runs in memory unless `--chdb-path` is provided; persistent paths must be reused by later `generate` commands
48
+ - Get correct ClickHouse runtime types instead of guessing interfaces.
49
+ - Move from one local query to datasets, APIs, React, and MCP without changing tools.
50
+ - Keep generated types and route manifests reproducible in CI.
51
+ - Build closed, hash-verified deployment artifacts from the same source.
324
52
 
325
- ## Docs
53
+ ## Learn more
326
54
 
327
55
  - [Quick start](https://hypequery.com/docs/quick-start)
328
56
  - [CLI reference](https://hypequery.com/docs/reference/api/cli)
57
+ - [Current capabilities](https://hypequery.com/docs/capabilities)
329
58
 
330
59
  ## License
331
60
 
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "@hypequery/cli",
3
- "version": "1.16.2",
4
- "description": "Command-line interface for hypequery",
3
+ "version": "1.16.4",
4
+ "description": "CLI for scaffolding type-safe ClickHouse analytics, semantic datasets, React manifests, and deployments",
5
+ "keywords": [
6
+ "clickhouse",
7
+ "typescript",
8
+ "analytics",
9
+ "semantic-layer",
10
+ "query-builder",
11
+ "orm",
12
+ "code-generation",
13
+ "chdb",
14
+ "cli"
15
+ ],
5
16
  "license": "Apache-2.0",
6
17
  "type": "module",
7
18
  "bin": {
@@ -19,8 +30,8 @@
19
30
  "open": "^10.0.0",
20
31
  "ora": "^8.0.1",
21
32
  "prompts": "^2.4.2",
22
- "@hypequery/deployment": "0.7.1",
23
- "@hypequery/protocol": "0.10.1"
33
+ "@hypequery/deployment": "0.7.3",
34
+ "@hypequery/protocol": "0.11.0"
24
35
  },
25
36
  "optionalDependencies": {
26
37
  "@napi-rs/keyring": "1.3.0"
@@ -34,13 +45,14 @@
34
45
  "@vitest/coverage-v8": "^3.2.6",
35
46
  "typescript": "^5.7.3",
36
47
  "vitest": "^3.2.6",
37
- "@hypequery/serve": "0.15.0"
48
+ "@hypequery/serve": "0.15.3"
38
49
  },
39
50
  "repository": {
40
51
  "type": "git",
41
- "url": "https://github.com/hypequery/hypequery.git"
52
+ "url": "git+https://github.com/hypequery/hypequery.git",
53
+ "directory": "packages/cli"
42
54
  },
43
- "homepage": "https://www.hypequery.com",
55
+ "homepage": "https://hypequery.com",
44
56
  "bugs": {
45
57
  "url": "https://github.com/hypequery/hypequery/issues"
46
58
  },