@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
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { Transferable } from "node:worker_threads";
|
|
2
|
+
|
|
3
|
+
export type ImportFormat = "xml" | "jsonl" | "json" | "csv" | "tsv";
|
|
4
|
+
export interface ImportSource {
|
|
5
|
+
name: string;
|
|
6
|
+
size: number;
|
|
7
|
+
open(): AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>;
|
|
8
|
+
/**
|
|
9
|
+
* Optional random access to the same immutable bytes: exactly `end - start` bytes from `start`.
|
|
10
|
+
* Parallel XML reads need it, so they never load a whole file.
|
|
11
|
+
*/
|
|
12
|
+
read?(start: number, end: number): Promise<Uint8Array>;
|
|
13
|
+
}
|
|
14
|
+
export interface ImportRow {
|
|
15
|
+
index: number;
|
|
16
|
+
record: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface ImportProgress {
|
|
19
|
+
bytes_read: number;
|
|
20
|
+
total_bytes: number;
|
|
21
|
+
rows: number;
|
|
22
|
+
}
|
|
23
|
+
/** A dedicated `Worker`, or a worker_threads adapter from `createNodeImportWorker`. */
|
|
24
|
+
export interface ImportWorker {
|
|
25
|
+
postMessage(message: unknown, transfer: Transferable[]): void;
|
|
26
|
+
addEventListener(
|
|
27
|
+
type: "message" | "messageerror" | "error",
|
|
28
|
+
listener: (event: any) => void
|
|
29
|
+
): void;
|
|
30
|
+
terminate(): unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Execution diagnostics for one read or scan. Never part of an ImportReport: results are identical
|
|
34
|
+
* with any worker count.
|
|
35
|
+
*/
|
|
36
|
+
export interface ImportWorkerStatus {
|
|
37
|
+
/** Workers chosen before startup; 0 reads on the calling thread. */
|
|
38
|
+
requested: number;
|
|
39
|
+
/** Workers that completed the readiness handshake; 0 reads on the calling thread. */
|
|
40
|
+
actual: number;
|
|
41
|
+
/** Why the read is sequential, or why fewer workers started than requested. */
|
|
42
|
+
reason?: string;
|
|
43
|
+
/** Sent in a second status when workers stopped and the rest was read on the calling thread. */
|
|
44
|
+
fallback?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ImportOptions {
|
|
47
|
+
format?: ImportFormat | "auto";
|
|
48
|
+
/** Optional XML filter; omitted imports all direct root children plus bounded root context. */
|
|
49
|
+
record_path?: string;
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
onprogress?: (progress: ImportProgress) => void;
|
|
52
|
+
/**
|
|
53
|
+
* XML worker count for complete reads (readImportRows and full scans) of sources with `read`.
|
|
54
|
+
* Default "auto": two workers for 32 MiB or more on four or more logical processors. 0 reads on
|
|
55
|
+
* the calling thread; 1 to 16 skips the size and processor checks. Other values reject.
|
|
56
|
+
*/
|
|
57
|
+
workers?: "auto" | number;
|
|
58
|
+
/** Starts one worker running this package's worker entry. Without it reads are sequential. */
|
|
59
|
+
create_worker?: () => ImportWorker;
|
|
60
|
+
/** Called when the execution mode is known, and again if workers fall back. */
|
|
61
|
+
onworkers?: (status: ImportWorkerStatus) => void;
|
|
62
|
+
}
|
|
63
|
+
export interface Detection {
|
|
64
|
+
format: ImportFormat;
|
|
65
|
+
is_sampled: boolean;
|
|
66
|
+
bytes_read: number;
|
|
67
|
+
xml?: {
|
|
68
|
+
root_name: string | null;
|
|
69
|
+
record_paths: Array<{ path: string; count: number }>;
|
|
70
|
+
recommended_path: string | null;
|
|
71
|
+
};
|
|
72
|
+
warnings: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface FieldProfile {
|
|
75
|
+
path: string;
|
|
76
|
+
label: string;
|
|
77
|
+
types: string[];
|
|
78
|
+
present: number;
|
|
79
|
+
missing: number;
|
|
80
|
+
}
|
|
81
|
+
export interface TimestampCandidate {
|
|
82
|
+
path: string;
|
|
83
|
+
label: string;
|
|
84
|
+
valid: number;
|
|
85
|
+
invalid: number;
|
|
86
|
+
missing: number;
|
|
87
|
+
ambiguous: number;
|
|
88
|
+
min: string | null;
|
|
89
|
+
max: string | null;
|
|
90
|
+
}
|
|
91
|
+
export interface ImportReport {
|
|
92
|
+
format: ImportFormat;
|
|
93
|
+
is_sampled: boolean;
|
|
94
|
+
is_complete: boolean;
|
|
95
|
+
bytes_read: number;
|
|
96
|
+
total_bytes: number;
|
|
97
|
+
row_count: number;
|
|
98
|
+
preview: ImportRow[];
|
|
99
|
+
fields: FieldProfile[];
|
|
100
|
+
timestamp_candidates: TimestampCandidate[];
|
|
101
|
+
xml?: NonNullable<Detection["xml"]> & { record_path?: string };
|
|
102
|
+
warnings: string[];
|
|
103
|
+
max_row_bytes: number;
|
|
104
|
+
}
|
|
105
|
+
export interface ImportScanOptions extends ImportOptions {
|
|
106
|
+
is_full?: boolean;
|
|
107
|
+
/** Selected timestamps must be valid, explicit-zone values between the Unix epoch and now. */
|
|
108
|
+
timestamp_field?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface ImportBatchOptions {
|
|
111
|
+
/** Selected timestamps must be valid, explicit-zone values between the Unix epoch and now. */
|
|
112
|
+
timestamp_field?: string;
|
|
113
|
+
max_bytes?: number;
|
|
114
|
+
max_rows?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface ImportBatch {
|
|
117
|
+
index: number;
|
|
118
|
+
body: string;
|
|
119
|
+
bytes: number;
|
|
120
|
+
rows: ImportRow[];
|
|
121
|
+
timestamp: string | null;
|
|
122
|
+
}
|
|
123
|
+
export const IMPORT_BATCH_BYTES: number;
|
|
124
|
+
export const IMPORT_BATCH_ROWS: number;
|
|
125
|
+
export const IMPORT_JSON_BYTES: number;
|
|
126
|
+
export const IMPORT_MAX_WORKERS: number;
|
|
127
|
+
export function createBlobSource(blob: Blob, name?: string): ImportSource;
|
|
128
|
+
export function detectImport(source: ImportSource, options?: ImportOptions): Promise<Detection>;
|
|
129
|
+
export function readImportRows(
|
|
130
|
+
source: ImportSource,
|
|
131
|
+
options?: ImportOptions
|
|
132
|
+
): AsyncGenerator<ImportRow>;
|
|
133
|
+
export function scanImport(
|
|
134
|
+
source: ImportSource,
|
|
135
|
+
options?: ImportScanOptions
|
|
136
|
+
): Promise<ImportReport>;
|
|
137
|
+
/** JSON pointer, or an exact top-level key. Never traverses inherited properties. */
|
|
138
|
+
export function getImportField(record: Record<string, unknown>, path: string): unknown;
|
|
139
|
+
/** Explicit-zone ISO/Apple dates, ten-digit epoch seconds or thirteen-digit epoch milliseconds. */
|
|
140
|
+
export function parseImportTimestamp(value: unknown): string | null;
|
|
141
|
+
/** The line excludes its trailing newline; bytes includes that newline. */
|
|
142
|
+
export function serializeImportRow(row: ImportRow): { row: ImportRow; line: string; bytes: number };
|
|
143
|
+
export function createImportBatches(
|
|
144
|
+
rows: AsyncIterable<ImportRow> | Iterable<ImportRow>,
|
|
145
|
+
options?: ImportBatchOptions
|
|
146
|
+
): AsyncGenerator<ImportBatch>;
|
|
147
|
+
|
|
148
|
+
/** HTTP statuses treated as explicit batch rejection by import delivery clients. */
|
|
149
|
+
export const IMPORT_REJECTED_STATUSES: readonly number[];
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Start a worker_threads worker for parallel XML reads. Pass `() => createNodeImportWorker()` as
|
|
153
|
+
* `create_worker`; bundled callers pass the URL of their bundled `src/worker.node.js`.
|
|
154
|
+
*/
|
|
155
|
+
export function createNodeImportWorker(entry?: URL | string): ImportWorker;
|