@saptools/cf-debugger 0.1.15 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ interface SessionKey {
3
3
  readonly org: string;
4
4
  readonly space: string;
5
5
  readonly app: string;
6
+ /** Cloud Foundry process name (for example `web`), not an operating-system process. */
6
7
  readonly process?: string;
7
8
  readonly instance?: number;
8
9
  readonly apiEndpoint?: string;
@@ -18,7 +19,11 @@ interface ActiveSession extends SessionKey {
18
19
  /** Compatibility alias for the currently active controller or tunnel PID. */
19
20
  readonly pid: number;
20
21
  readonly controllerPid?: number;
22
+ /** Optional OS process birth token; absent records retain PID-only compatibility. */
23
+ readonly controllerProcessIdentity?: string;
21
24
  readonly tunnelPid?: number;
25
+ /** Optional OS process birth token; absent records retain PID-only compatibility. */
26
+ readonly tunnelProcessIdentity?: string;
22
27
  readonly hostname: string;
23
28
  readonly localPort: number;
24
29
  readonly remotePort: number;
@@ -27,6 +32,8 @@ interface ActiveSession extends SessionKey {
27
32
  readonly startedAt: string;
28
33
  readonly status: SessionStatus;
29
34
  readonly remoteNodePid?: number;
35
+ /** Startup budget used for stale-session evaluation; absent records use the supported maximum. */
36
+ readonly startupTimeoutMs?: number;
30
37
  readonly stopRequestedAt?: string;
31
38
  readonly message?: string;
32
39
  }
@@ -34,8 +41,10 @@ interface StartDebuggerOptions extends SessionKey {
34
41
  readonly email?: string;
35
42
  readonly password?: string;
36
43
  readonly preferredPort?: number;
44
+ readonly remotePort?: number;
37
45
  readonly tunnelReadyTimeoutMs?: number;
38
- /** Set false when the caller must not enable SSH or restart the deployed app. Defaults to true. */
46
+ readonly startupTimeoutMs?: number;
47
+ /** Set true to permit app-level SSH enablement and an app restart. Defaults to false. */
39
48
  readonly allowSshEnableRestart?: boolean;
40
49
  readonly verbose?: boolean;
41
50
  readonly onStatus?: (status: SessionStatus, message?: string) => void;
@@ -54,27 +63,99 @@ declare class CfDebuggerError extends Error {
54
63
 
55
64
  declare function startDebugger(options: StartDebuggerOptions): Promise<DebuggerHandle>;
56
65
 
66
+ type SessionHealthStatus = "healthy" | "stale" | "unverified";
67
+ interface SessionHealthVerdict {
68
+ readonly status: SessionHealthStatus;
69
+ readonly reason: string;
70
+ }
71
+
72
+ declare function sessionKeyString(key: SessionKey): string;
73
+
74
+ type DoctorCleanupStatus = "not-requested" | "not-eligible" | "removed" | "skipped" | "failed";
75
+ interface DoctorSessionFinding {
76
+ readonly session: ActiveSession;
77
+ readonly health: SessionHealthVerdict;
78
+ }
79
+ interface DoctorHomeFinding {
80
+ readonly sessionId: string;
81
+ readonly path: string;
82
+ readonly cleanupEligible: boolean;
83
+ readonly cleanupStatus: DoctorCleanupStatus;
84
+ }
85
+ interface DoctorPortFinding {
86
+ readonly port: number;
87
+ readonly pids: readonly number[];
88
+ readonly ownerStatus: "found" | "unverified";
89
+ readonly reason?: string;
90
+ }
91
+ type DoctorArtifactKind = "state-temp" | "state-lock" | "state-recovery" | "stop-intent" | "corrupt-backup";
92
+ interface DoctorArtifactFinding {
93
+ readonly kind: DoctorArtifactKind;
94
+ readonly path: string;
95
+ readonly ageMs: number;
96
+ readonly cleanupEligible: boolean;
97
+ readonly cleanupStatus: DoctorCleanupStatus;
98
+ readonly cleanupError?: string;
99
+ }
100
+ interface DoctorLegacyFinding {
101
+ readonly statePath: string;
102
+ readonly statePresent: boolean;
103
+ readonly homesPath: string;
104
+ readonly homesPresent: boolean;
105
+ readonly warning?: string;
106
+ readonly manualRemovalCommand?: string;
107
+ }
108
+ interface DoctorReport {
109
+ readonly sessions: readonly DoctorSessionFinding[];
110
+ readonly orphanHomes: readonly DoctorHomeFinding[];
111
+ readonly unclaimedPorts: readonly DoctorPortFinding[];
112
+ readonly artifacts: readonly DoctorArtifactFinding[];
113
+ readonly legacy: DoctorLegacyFinding;
114
+ readonly warnings: readonly string[];
115
+ readonly cleanedPaths: readonly string[];
116
+ }
117
+ interface DoctorOptions {
118
+ readonly cleanup?: boolean;
119
+ }
120
+ declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
121
+
57
122
  interface StopOptions {
58
123
  readonly sessionId?: string;
59
124
  readonly key?: SessionKey;
125
+ readonly force?: boolean;
60
126
  }
61
127
  interface StopDebuggerResult extends ActiveSession {
62
128
  readonly stale: boolean;
63
129
  readonly pending: boolean;
130
+ readonly forced: boolean;
131
+ readonly warning?: string;
132
+ }
133
+ interface StopAllOutcome {
134
+ readonly sessionId: string;
135
+ readonly app: string;
136
+ readonly status: "failed" | "pending" | "stale" | "stopped";
137
+ readonly result?: StopDebuggerResult;
138
+ readonly error?: CfDebuggerError;
139
+ }
140
+ interface StopAllResult {
141
+ readonly outcomes: readonly StopAllOutcome[];
142
+ readonly failed: number;
143
+ readonly pending: number;
144
+ readonly stale: number;
145
+ readonly stopped: number;
64
146
  }
65
147
  declare function stopDebugger(options: StopOptions): Promise<StopDebuggerResult | undefined>;
66
- declare function stopAllDebuggers(): Promise<number>;
148
+ declare function stopAllDebuggers(force?: boolean): Promise<StopAllResult>;
67
149
  declare function listSessions(): Promise<readonly ActiveSession[]>;
68
150
  declare function getSession(key: SessionKey): Promise<ActiveSession | undefined>;
69
151
 
70
- declare function resolveApiEndpoint(regionKey: string, override?: string): string;
152
+ declare function resolveApiEndpoint(regionKey: string, override?: string, onWarning?: (warning: string) => void): string;
71
153
  declare function listKnownRegionKeys(): readonly string[];
72
154
 
73
- declare function sessionKeyString(key: SessionKey): string;
74
-
75
155
  interface CurrentCfTargetReadOptions {
76
156
  readonly command?: string;
77
157
  readonly env?: NodeJS.ProcessEnv;
158
+ readonly signal?: AbortSignal;
78
159
  readonly timeoutMs?: number;
79
160
  }
80
161
  interface CurrentCfTarget {
@@ -86,7 +167,10 @@ interface CurrentCfTarget {
86
167
  declare function readCurrentCfTarget(options?: CurrentCfTargetReadOptions): Promise<CurrentCfTarget | undefined>;
87
168
  declare function parseCurrentCfTarget(stdout: string): CurrentCfTarget | undefined;
88
169
  declare function requireCurrentCfRegion(target: Pick<CurrentCfTarget, "apiEndpoint" | "region">, instruction?: string): string;
170
+ declare function regionKeyForApiEndpoint(apiEndpoint: string): string | undefined;
171
+ declare function regionKeyFromSapApiEndpoint(apiEndpoint: string): string | undefined;
89
172
 
173
+ declare const DEFAULT_NODE_INSPECTOR_PORT = 9229;
90
174
  interface NodeTargetSelectors {
91
175
  readonly process?: string;
92
176
  readonly instance?: number;
@@ -101,7 +185,7 @@ interface NodeProcessSelection {
101
185
  readonly remoteNodePid: number;
102
186
  }
103
187
  declare function resolveNodeTarget(input: NodeTargetSelectors): ResolvedNodeTarget;
104
- declare function buildNodeInspectorCommand(nodePid?: number): string;
105
- declare function parseNodeInspectorMarkers(stdout: string): NodeProcessSelection;
188
+ declare function buildNodeInspectorCommand(nodePid?: number, remotePort?: number): string;
189
+ declare function parseNodeInspectorMarkers(stdout: string, remotePort?: number): NodeProcessSelection;
106
190
 
107
- export { type ActiveSession, CfDebuggerError, type CurrentCfTarget, type CurrentCfTargetReadOptions, type DebuggerHandle, type NodeProcessSelection, type NodeTargetSelectors, type ResolvedNodeTarget, type ResolvedSessionKey, type SessionKey, type SessionStatus, type StartDebuggerOptions, buildNodeInspectorCommand, getSession, listKnownRegionKeys, listSessions, parseCurrentCfTarget, parseNodeInspectorMarkers, readCurrentCfTarget, requireCurrentCfRegion, resolveApiEndpoint, resolveNodeTarget, sessionKeyString, startDebugger, stopAllDebuggers, stopDebugger };
191
+ export { type ActiveSession, CfDebuggerError, type CurrentCfTarget, type CurrentCfTargetReadOptions, DEFAULT_NODE_INSPECTOR_PORT, type DebuggerHandle, type DoctorArtifactFinding, type DoctorArtifactKind, type DoctorCleanupStatus, type DoctorHomeFinding, type DoctorLegacyFinding, type DoctorOptions, type DoctorPortFinding, type DoctorReport, type DoctorSessionFinding, type NodeProcessSelection, type NodeTargetSelectors, type ResolvedNodeTarget, type ResolvedSessionKey, type SessionKey, type SessionStatus, type StartDebuggerOptions, type StopAllOutcome, type StopAllResult, type StopDebuggerResult, type StopOptions, buildNodeInspectorCommand, getSession, listKnownRegionKeys, listSessions, parseCurrentCfTarget, parseNodeInspectorMarkers, readCurrentCfTarget, regionKeyForApiEndpoint, regionKeyFromSapApiEndpoint, requireCurrentCfRegion, resolveApiEndpoint, resolveNodeTarget, runDoctor, sessionKeyString, startDebugger, stopAllDebuggers, stopDebugger };