@basis-theory-labs/cli 4.1.0 → 4.3.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,56 @@
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 Read extends base_1.BaseCommand {
8
+ async run() {
9
+ const now = Date.now();
10
+ const { flags: { 'management-key': apiKey, 'api-base-url': apiBaseUrl, format, since, until, }, args: { id }, } = await this.parse(Read);
11
+ if (!id.trim()) {
12
+ this.error('Reactor id must not be blank');
13
+ }
14
+ await (0, runtime_1.readEventLogs)({
15
+ apiKey,
16
+ apiBaseUrl,
17
+ resourceType: 'reactor',
18
+ resourceId: id,
19
+ format: format,
20
+ window: (0, time_1.resolveLogWindow)({
21
+ since,
22
+ until,
23
+ }, now),
24
+ });
25
+ // Cleanup has completed. Oclif's final flush would stall on a pending write.
26
+ if (process.stdout.writableLength > 0 && process.exitCode !== undefined) {
27
+ this.exit(process.exitCode);
28
+ }
29
+ }
30
+ }
31
+ exports.default = Read;
32
+ Read.description = 'Read a fixed window of Reactor runtime logs through Events and exit. Requires `event:read` and runtime logging already enabled.\n\n' +
33
+ 'Defaults to the five minutes preceding --until, or command start when --until is omitted. Explicit relative values use command-start time. Windows include their start and exclude their end, filtering event batch timestamps rather than individual record occurrence times. Each matching batch is expanded in record sequence; flattened output has no global chronological ordering. History is tenant-limited (24 hours by default, at most 30 days); the API clamps unavailable history. Indexing is asynchronous and pagination is not a snapshot, so empty or exhausted results do not prove complete coverage. Large windows may hit bounded work limits and fail with partial output. Application logs come from the injected `logger`, not arbitrary stdout or `console.log`; collection requires resource opt-in and the platform runtime-log gate. Does not enable logging or open a tunnel.';
34
+ Read.examples = [
35
+ '<%= config.bin %> reactors logs read 03858bf5-32d3-4a2e-b74b-daeea0883bca --since 1h --until 30m',
36
+ '<%= config.bin %> reactors logs read 03858bf5-32d3-4a2e-b74b-daeea0883bca --since 2026-10-01T10:00:00Z --until 2026-10-01T10:15:00Z --format json',
37
+ ];
38
+ Read.args = {
39
+ id: core_1.Args.string({
40
+ description: 'Reactor id',
41
+ required: true,
42
+ }),
43
+ };
44
+ Read.flags = {
45
+ since: core_1.Flags.string({
46
+ description: 'window start: positive duration (30s, 5m, 2h, 1d, 1w) or ISO timestamp with timezone; defaults to five minutes before the end',
47
+ }),
48
+ until: core_1.Flags.string({
49
+ description: 'window end (exclusive): positive duration or ISO timestamp with timezone; defaults to command start',
50
+ }),
51
+ format: core_1.Flags.string({
52
+ description: 'pretty: readable logs; json: compact objects; json-pretty: indented objects. Entries are separated by blank lines; colors are enabled in terminals',
53
+ options: ['pretty', 'json', 'json-pretty'],
54
+ default: 'pretty',
55
+ }),
56
+ };
@@ -0,0 +1,13 @@
1
+ import { BaseCommand } from '../../../base';
2
+ export default class Tail extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ since: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ format: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,50 @@
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, format, since, }, args: { id }, } = await this.parse(Tail);
11
+ if (!id.trim()) {
12
+ this.error('Reactor id must not be blank');
13
+ }
14
+ await (0, runtime_1.followEventLogs)({
15
+ apiKey,
16
+ apiBaseUrl,
17
+ resourceType: 'reactor',
18
+ resourceId: id,
19
+ format: format,
20
+ window: (0, time_1.resolveTailWindow)({ since }, now),
21
+ });
22
+ // Cleanup has completed. Oclif's final flush would stall on a pending write.
23
+ if (process.stdout.writableLength > 0 && process.exitCode !== undefined) {
24
+ this.exit(process.exitCode);
25
+ }
26
+ }
27
+ }
28
+ exports.default = Tail;
29
+ Tail.description = 'Tail Reactor runtime logs through Events. Requires `event:read` and runtime logging already enabled.\n\n' +
30
+ 'Starts watching from command time. 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 tenant-limited (24 hours by default, at most 30 days); 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, disabled collection, or delayed indexing. Runs until interrupted, output closes, or an error occurs.';
31
+ Tail.examples = [
32
+ '<%= config.bin %> reactors logs tail 03858bf5-32d3-4a2e-b74b-daeea0883bca',
33
+ '<%= config.bin %> reactors logs tail 03858bf5-32d3-4a2e-b74b-daeea0883bca --since 30m --format json',
34
+ ];
35
+ Tail.args = {
36
+ id: core_1.Args.string({
37
+ description: 'Reactor id',
38
+ required: true,
39
+ }),
40
+ };
41
+ Tail.flags = {
42
+ since: core_1.Flags.string({
43
+ description: 'include initial history from a positive duration (30s, 5m, 2h, 1d, 1w) or ISO timestamp with timezone; omitted means watch from command start',
44
+ }),
45
+ format: core_1.Flags.string({
46
+ description: 'pretty: readable logs; json: compact objects; json-pretty: indented objects. Entries are separated by blank lines; colors are enabled in terminals',
47
+ options: ['pretty', 'json', 'json-pretty'],
48
+ default: 'pretty',
49
+ }),
50
+ };
@@ -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,56 @@
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 EventLogPage {
29
+ batches: EventLogRecord[][];
30
+ next: string | null;
31
+ }
32
+ declare class EventsReadError extends Error {
33
+ readonly retryable: boolean;
34
+ readonly retryAfterMs?: number;
35
+ constructor(message: string, options?: {
36
+ retryable?: boolean;
37
+ retryAfterMs?: number;
38
+ });
39
+ }
40
+ /** Resolve and validate the API origin before any credential is sent. */
41
+ declare const resolveEventsOrigin: (apiBaseUrl?: string) => string;
42
+ interface ReadEventPageOptions {
43
+ origin: string;
44
+ apiKey: string;
45
+ resourceType: ResourceType;
46
+ resourceId: string;
47
+ start: number;
48
+ end: number;
49
+ cursor?: string;
50
+ signal: AbortSignal;
51
+ onBytes: (bytes: number) => void;
52
+ }
53
+ /** Read and validate one Events page. Continuations contain only the opaque cursor. */
54
+ declare const readEventPage: (options: ReadEventPageOptions) => Promise<EventLogPage>;
55
+ export type { EventLogPage, EventLogRecord, ReadEventPageOptions, ResourceType, };
56
+ export { EventsReadError, readEventPage, resolveEventsOrigin };