@tailglow/cli 0.6.5 → 0.8.1
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 +88 -7
- package/package.json +2 -2
- package/src/commands.generated.js +593 -262
- package/src/docs.generated.js +32 -32
- package/src/help.js +7 -1
- package/src/import-command.js +647 -0
- package/src/import-file.js +181 -0
- package/src/import-options.js +24 -0
- package/src/import-worker.generated.js +1616 -0
- package/src/import.generated.d.ts +155 -0
- package/src/import.generated.js +4731 -0
- package/src/index.js +14 -2
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @tailglow/cli
|
|
2
2
|
|
|
3
|
-
`tglow` is the Tailglow command line.
|
|
4
|
-
validations, so the CLI,
|
|
5
|
-
|
|
3
|
+
`tglow` is the Tailglow command line. API resource commands are generated from the API's own
|
|
4
|
+
routes and validations, so the CLI, docs site and in-product AI assistant describe the same API.
|
|
5
|
+
Local commands also support sign-in, bundled documentation and file imports.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install -g @tailglow/cli
|
|
@@ -10,7 +10,7 @@ tglow login
|
|
|
10
10
|
tglow projects list
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Node
|
|
13
|
+
Node 22 or newer. `bun add -g` and `pnpm add -g` work the same way.
|
|
14
14
|
|
|
15
15
|
Prefer a shorter name? Alias it rather than installing over one:
|
|
16
16
|
|
|
@@ -33,8 +33,8 @@ tglow metrics create --project prj_x --name "API Latency" --view-id view_x
|
|
|
33
33
|
tglow metrics delete --project prj_x --metric-id met_x
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Field names are snake_case on the wire and kebab-case on the command line: `
|
|
37
|
-
becomes `--
|
|
36
|
+
Field names are snake_case on the wire and kebab-case on the command line: `repeat_window_minutes`
|
|
37
|
+
becomes `--repeat-window-minutes`. Object and array fields take JSON:
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
tglow views create-join --project prj_x --joins '[{"view_id":"view_b","on":"user_id"}]'
|
|
@@ -135,8 +135,89 @@ Pages print as markdown even when piped; `--json` returns `{ path, url, content
|
|
|
135
135
|
bun run tglow <resource> <command> # run from source, without installing
|
|
136
136
|
bun run test:cli # unit tests, no network
|
|
137
137
|
bun run build:llms # regenerate src/commands.generated.js and src/docs.generated.js
|
|
138
|
+
bun run build:import # regenerate the bundled importer and its XML worker
|
|
138
139
|
```
|
|
139
140
|
|
|
140
141
|
`src/commands.generated.js` and `src/docs.generated.js` are written by `scripts/build/llms.build.js`
|
|
141
142
|
and are never edited by hand. Adding a route to the API adds its command here with no change to this
|
|
142
|
-
package, and editing a guide changes the bundled page the same way.
|
|
143
|
+
package, and editing a guide changes the bundled page the same way. `src/import.generated.js`, its
|
|
144
|
+
declarations and `src/import-worker.generated.js` are self-contained bundles of the workspace
|
|
145
|
+
importer written by `scripts/build/import.build.js`.
|
|
146
|
+
|
|
147
|
+
## Import files
|
|
148
|
+
|
|
149
|
+
Scan and validate locally without credentials:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
tglow import scan export.xml
|
|
153
|
+
tglow import scan export.xml --record-path /HealthData/Record --full
|
|
154
|
+
tglow import validate events.jsonl --timestamp-field /event/created_at
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Content detection supports XML, JSONL, JSON, CSV and TSV; use `--format` to resolve ambiguity.
|
|
158
|
+
Scan defaults to a bounded sample, reports its coverage, and discovers literal XML element paths.
|
|
159
|
+
XML automatically imports every direct child of the document root, including different record
|
|
160
|
+
types. Root attributes and meaningful direct text become a separate document record; a root-only
|
|
161
|
+
document becomes one record. `--record-path` is an optional filter for importing just part of a
|
|
162
|
+
file. Rows preserve the `{name, attributes, children}` tree, strings, qualified names and child
|
|
163
|
+
order. Line-break indentation in element-only containers is removed. Mixed text, inline spaces,
|
|
164
|
+
whitespace-only values, CDATA, character references and inherited `xml:space="preserve"` stay intact;
|
|
165
|
+
formatting separators between top-level records are omitted.
|
|
166
|
+
There is no Apple-specific flattening. DTDs use the documented ignore profile; declarations are not
|
|
167
|
+
applied and declared entities are not expanded. JSON documents have a 50 MiB limit; the other
|
|
168
|
+
formats stream in bounded memory. Every serialized row must fit within 1 MiB including its
|
|
169
|
+
newline.
|
|
170
|
+
|
|
171
|
+
Upload using an exact project, source and ingest key, with normal CLI authentication:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
tglow import events.jsonl --project prj_x --source-id src_x --ingest-key-id ik_x --collection events
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Alternatively pass an explicit `--ingest-url` containing its key and `--project prj_x` to verify
|
|
178
|
+
the expected project. Treat the URL as a credential: passing it on the command line exposes it
|
|
179
|
+
to shell history and process listings. The CLI never prints the URL or API credential. The
|
|
180
|
+
project can come from the existing environment/config default; `--project-id` is an alias for
|
|
181
|
+
`--project`. Source and ingest-key IDs never default or select themselves. A localhost API cannot
|
|
182
|
+
automatically direct an upload to a remote URL; use an explicit ingest URL for that destination.
|
|
183
|
+
|
|
184
|
+
Upload reads a bounded preview, checks destination readiness, then validates records and sends
|
|
185
|
+
batches as it reads. It holds one file descriptor and checks for file changes before every request
|
|
186
|
+
and at EOF. These checks detect ordinary replacement, edits, append and truncation; they are not
|
|
187
|
+
an immutable snapshot guarantee. Do not edit the input during import. No full temporary copy is
|
|
188
|
+
needed by default. A late parse error can leave earlier batches accepted.
|
|
189
|
+
|
|
190
|
+
Add `--validate-first` to copy the file into a private temporary directory and check the whole
|
|
191
|
+
snapshot before any upload. This needs free temporary disk space approximately equal to the input
|
|
192
|
+
size. The same snapshot is used for checking and delivery, then removed on completion, failure or
|
|
193
|
+
graceful Ctrl-C. A cleanup failure is reported separately as `cleanup_error` and a warning; it does
|
|
194
|
+
not change delivery status or acknowledged counts. Changes to the original after copying do not change the uploaded bytes. A failed
|
|
195
|
+
full check sends no rows; successful checking cannot prevent a later delivery failure.
|
|
196
|
+
|
|
197
|
+
`--timestamp-field` accepts a JSON pointer or an exact top-level field name. Source fields remain
|
|
198
|
+
unchanged; the selected value sets request-level `ts`. Missing, invalid or timezone-ambiguous
|
|
199
|
+
values fail validation. Selected dates must be between 1970-01-01 UTC and the current time, since earlier or future ingest timestamps cannot be preserved by the server. No timestamp field is selected automatically. Batches split whenever
|
|
200
|
+
the exact parsed timestamp changes, which can produce one request per row, and otherwise stay
|
|
201
|
+
within 500 rows and 1 MiB.
|
|
202
|
+
|
|
203
|
+
Only HTTP 202 acknowledges a batch. Upload stops on rejection or uncertain delivery and never
|
|
204
|
+
retries automatically. The report includes `accepted_count` and the affected batch's inclusive
|
|
205
|
+
`first_row`/`last_row`; these indices refer to the selected output rows, not physical file lines.
|
|
206
|
+
A timeout, cancellation during a request, or missing acknowledgement may mean that batch arrived.
|
|
207
|
+
Do not blindly rerun a partial upload: import idempotency is not provided yet.
|
|
208
|
+
|
|
209
|
+
Full scans, validation and upload read large XML files with worker threads. `--workers auto`, the
|
|
210
|
+
default, starts two for files of 32 MiB or more on machines with at least four logical processors;
|
|
211
|
+
`--workers 0` reads on the main thread, and `--workers 1` to `16` sets the count for any XML file.
|
|
212
|
+
Each pass checks that its workers start and answer before reading, falls back to the main thread
|
|
213
|
+
if they cannot, and reports what ran on stderr (`XML workers: 2.`). Reports, rows, batches and
|
|
214
|
+
errors are identical with any worker count; JSONL, JSON, CSV, TSV and sampled scans read on the
|
|
215
|
+
main thread.
|
|
216
|
+
|
|
217
|
+
Progress is written to stderr. In `--json` mode or when piped, import always writes its final
|
|
218
|
+
JSON report to stdout, including failures and partial uploads. `total_rows` is `null` until a full
|
|
219
|
+
check or clean EOF establishes it. `accepted_count` counts only acknowledged rows. The `outcome`
|
|
220
|
+
field distinguishes validation failures, changed files, destination failures, rejected batches,
|
|
221
|
+
uncertain delivery and cancellation. Exit code is 0 on success, 1 on
|
|
222
|
+
failure, and 130 after cancellation. Other CLI commands retain the standard failure-to-stderr
|
|
223
|
+
behavior described above. See `tglow import --help` for all flags.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailglow/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Tailglow command line. Every command is generated from the Tailglow API reference, so the CLI and the documentation can never describe different APIs.",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"src"
|
|
16
16
|
],
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
18
|
+
"node": ">=22.0.0"
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://docs.tailglow.io",
|
|
21
21
|
"bugs": {
|