@basis-theory-labs/cli 4.2.0 → 4.4.0

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.
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_1 = require("../../../base");
5
+ const runtime_1 = require("../../../logs/runtime");
6
+ const time_1 = require("../../../logs/time");
7
+ class Tail extends base_1.BaseCommand {
8
+ async run() {
9
+ const now = Date.now();
10
+ const { flags: { 'management-key': apiKey, 'api-base-url': apiBaseUrl, 'trace-id': traceId, format, since, }, args: { id }, } = await this.parse(Tail);
11
+ if (!id.trim()) {
12
+ this.error('Reactor id must not be blank');
13
+ }
14
+ if (traceId !== undefined && !traceId.trim()) {
15
+ this.error('--trace-id must not be blank');
16
+ }
17
+ await (0, runtime_1.followEventLogs)({
18
+ apiKey,
19
+ apiBaseUrl,
20
+ resourceType: 'reactor',
21
+ resourceId: id,
22
+ traceId,
23
+ format: format,
24
+ window: (0, time_1.resolveTailWindow)({ since }, now),
25
+ });
26
+ // Cleanup has completed. Oclif's final flush would stall on a pending write.
27
+ if (process.stdout.writableLength > 0 && process.exitCode !== undefined) {
28
+ this.exit(process.exitCode);
29
+ }
30
+ }
31
+ }
32
+ exports.default = Tail;
33
+ Tail.description = 'Tail Reactor runtime logs through Events. Requires `event:read` and runtime logging already enabled.\n\n' +
34
+ 'Optional --trace-id matches the effective stored BT trace ID exactly and case-sensitively. A submitted header may be sanitized by Vault; the CLI does not normalize or trim it. A reused trace ID can match multiple invocations.\n\n' +
35
+ 'Starts watching from command time, regardless of filters. Supply --since to retrieve initial history before following new logs. Polls every five seconds with a rolling five-minute overlap that never reaches before the requested start. Time windows filter event batches, not individual record occurrence times; a newly arriving batch can contain records that occurred before command start. History is limited by server retention and tenant entitlements; the API clamps unavailable history. Large initial windows may hit bounded work limits and fail with partial output. Visibility is delayed and best-effort; output has no durable resume or global chronological ordering. Application logs come from the injected `logger`, not arbitrary stdout or `console.log`; collection requires resource opt-in and the platform runtime-log gate. Silence does not distinguish an idle resource, a wrong ID or filter, disabled collection, or delayed indexing. Runs until interrupted, output closes, or an error occurs.';
36
+ Tail.examples = [
37
+ '<%= config.bin %> reactors logs tail 03858bf5-32d3-4a2e-b74b-daeea0883bca',
38
+ '<%= config.bin %> reactors logs tail 03858bf5-32d3-4a2e-b74b-daeea0883bca --trace-id customer_Order-42',
39
+ '<%= config.bin %> reactors logs tail 03858bf5-32d3-4a2e-b74b-daeea0883bca --trace-id customer_Order-42 --since 30m --format json',
40
+ '<%= config.bin %> reactors logs tail 03858bf5-32d3-4a2e-b74b-daeea0883bca --since 30m --format json',
41
+ ];
42
+ Tail.args = {
43
+ id: core_1.Args.string({
44
+ description: 'Reactor id',
45
+ required: true,
46
+ }),
47
+ };
48
+ Tail.flags = {
49
+ 'trace-id': core_1.Flags.string({
50
+ description: 'exact, case-sensitive stored BT trace ID',
51
+ }),
52
+ since: core_1.Flags.string({
53
+ description: 'include initial history from a positive duration (30s, 5m, 2h, 1d, 1w) or ISO timestamp with timezone; omitted means watch from command start',
54
+ }),
55
+ format: core_1.Flags.string({
56
+ description: 'pretty: readable logs; json: compact objects; json-pretty: indented objects. Entries are separated by blank lines; colors are enabled in terminals',
57
+ options: ['pretty', 'json', 'json-pretty'],
58
+ default: 'pretty',
59
+ }),
60
+ };
@@ -19,7 +19,7 @@ class Logs extends base_1.BaseCommand {
19
19
  }
20
20
  }
21
21
  exports.default = Logs;
22
- Logs.description = 'Display live Reactor logs output. Requires `reactor:update` Management Application permissions';
22
+ Logs.description = 'Legacy tunnel-based Reactor logs. Opens a local tunnel and updates logging configuration. For v2/runtime debugging, use `bt reactors logs tail <id>` or `bt reactors logs read <id>`. Requires `reactor:update` Management Application permissions';
23
23
  Logs.examples = [
24
24
  '<%= config.bin %> <%= command.id %>',
25
25
  '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
@@ -0,0 +1,60 @@
1
+ type ResourceType = 'reactor' | 'proxy';
2
+ interface EventLogRecord {
3
+ event_id: string;
4
+ event_type: string;
5
+ event_timestamp: string;
6
+ tenant_id: string;
7
+ trace_id?: string;
8
+ resource_type: ResourceType;
9
+ resource_id: string;
10
+ invocation_id: string;
11
+ transform_type?: 'request_transform' | 'response_transform';
12
+ occurred_at: string;
13
+ sequence: number;
14
+ source: 'application' | 'platform';
15
+ record_type: 'log' | 'lifecycle';
16
+ level?: string;
17
+ message?: string | null;
18
+ attributes?: Record<string, unknown>;
19
+ error?: {
20
+ type: string;
21
+ message: string;
22
+ stack_trace?: string;
23
+ };
24
+ event?: string;
25
+ outcome?: string;
26
+ duration_ms?: number;
27
+ }
28
+ interface EventLogFilters {
29
+ traceId?: string;
30
+ transformType?: EventLogRecord['transform_type'];
31
+ }
32
+ interface EventLogPage {
33
+ batches: EventLogRecord[][];
34
+ next: string | null;
35
+ }
36
+ declare class EventsReadError extends Error {
37
+ readonly retryable: boolean;
38
+ readonly retryAfterMs?: number;
39
+ constructor(message: string, options?: {
40
+ retryable?: boolean;
41
+ retryAfterMs?: number;
42
+ });
43
+ }
44
+ /** Resolve and validate the API origin before any credential is sent. */
45
+ declare const resolveEventsOrigin: (apiBaseUrl?: string) => string;
46
+ interface ReadEventPageOptions extends EventLogFilters {
47
+ origin: string;
48
+ apiKey: string;
49
+ resourceType: ResourceType;
50
+ resourceId: string;
51
+ start: number;
52
+ end: number;
53
+ cursor?: string;
54
+ signal: AbortSignal;
55
+ onBytes: (bytes: number) => void;
56
+ }
57
+ /** Read and validate one Events page. Continuations contain only the opaque cursor. */
58
+ declare const readEventPage: (options: ReadEventPageOptions) => Promise<EventLogPage>;
59
+ export type { EventLogFilters, EventLogPage, EventLogRecord, ReadEventPageOptions, ResourceType, };
60
+ export { EventsReadError, readEventPage, resolveEventsOrigin };