@capgo/cli
Version:
A CLI to upload to capgo servers
98 lines (97 loc) • 3.95 kB
TypeScript
/** Protocol version understood by this CLI. Bumped on breaking changes. */
export declare const ASC_PROTOCOL_VERSION = 1;
/** Analytics channel every forwarded helper event is sent on. */
export declare const ASC_KEY_CHANNEL = "app-store-connect-key";
/** A non-sensitive analytics event emitted by the helper. */
export interface AscEventLine {
capgoAscKey: number;
kind: 'event';
/** Milliseconds since the helper started. */
ts: number;
/** Correlates every line of a single helper run. */
runId: string;
/** snake_case event name, e.g. `step_changed`, `validation_succeeded`. */
name: string;
/** Non-sensitive properties. NEVER contains the private key. */
props: Record<string, unknown>;
}
/** Severity levels a helper diagnostic `log` line may carry. */
export declare const ASC_LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
export type AscLogLevel = (typeof ASC_LOG_LEVELS)[number];
/**
* A verbose diagnostic line. Unlike an `event` (which feeds PostHog analytics),
* a `log` line is routed into the CLI's **internal support log** — the bundle a
* user emails to support when a run goes wrong. Use it generously for anything
* that helps a human diagnose a stuck/failed run after the fact: a finder that
* matched nothing, an unexpected navigation, the detail of a validation error.
* It is NOT analytics and, like an event, NEVER carries the private key.
*/
export interface AscLogLine {
capgoAscKey: number;
kind: 'log';
/** Milliseconds since the helper started. */
ts: number;
/** Correlates every line of a single helper run. */
runId: string;
/** Severity, defaulting to `info` when the helper omits/garbles it. */
level: AscLogLevel;
/** Human-readable diagnostic message. */
message: string;
/** Optional structured context. NEVER contains the private key. */
props: Record<string, unknown>;
}
/** The captured credentials, delivered on the terminal success line. */
export interface AscCredentials {
keyId: string;
issuerId: string;
privateKey: string;
}
/** Terminal line: success carries credentials, failure carries an error. */
export interface AscResultLine {
capgoAscKey: number;
kind: 'result';
ts: number;
runId: string;
ok: boolean;
keyId?: string;
issuerId?: string;
privateKey?: string;
errorCode?: string;
message?: string;
}
export type AscProtocolLine = AscEventLine | AscLogLine | AscResultLine;
/**
* Parse a single raw stdout line into a protocol envelope, or `null` when the
* line is not part of the protocol (blank line, incidental chatter, wrong
* version, or malformed JSON). Never throws — a misbehaving helper must not
* crash the CLI.
*/
export declare function parseAscProtocolLine(line: string): AscProtocolLine | null;
/**
* Incremental line splitter for a streamed stdout. Push raw chunks as they
* arrive; get back the protocol lines completed by that chunk. Partial trailing
* data is buffered until its newline arrives. Call {@link flush} at EOF to parse
* any final newline-less remainder.
*/
export declare class AscProtocolParser {
private buffer;
push(chunk: string): AscProtocolLine[];
flush(): AscProtocolLine[];
}
/**
* Build the `trackEvent` tags for a forwarded helper event: the helper's
* `props` (secret-stripped + scalar-coerced) plus protocol context. Exported
* for testing.
*/
export declare function buildEventTags(event: AscEventLine): Record<string, string | number | boolean>;
/**
* Map a helper event line to a `trackEvent` input. The `event` field is a
* human-readable Title Case rendering of the snake_case name (e.g.
* `step_changed` -> "Step Changed"), under the {@link ASC_KEY_CHANNEL} channel.
*/
export declare function ascEventToTrack(event: AscEventLine): {
channel: string;
event: string;
icon: string;
tags: Record<string, string | number | boolean>;
};