@saptools/cf-live-trace 0.1.5 → 0.1.8
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 +26 -7
- package/dist/cli.js +1267 -92
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +139 -7
- package/dist/index.js +1085 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const CF_LIVE_TRACE_GLOBAL_NAME = "__SAPTOOLS_CF_LIVE_TRACE__";
|
|
2
|
-
declare const CF_LIVE_TRACE_RUNTIME_VERSION =
|
|
2
|
+
declare const CF_LIVE_TRACE_RUNTIME_VERSION = 3;
|
|
3
3
|
interface RuntimeInstallOptions {
|
|
4
4
|
readonly appId: string;
|
|
5
5
|
readonly instance: string;
|
|
@@ -14,7 +14,7 @@ interface StopExpressionOptions {
|
|
|
14
14
|
}
|
|
15
15
|
declare const CF_LIVE_TRACE_RUNTIME_SOURCE: string;
|
|
16
16
|
declare function buildInstallExpression(options: RuntimeInstallOptions): string;
|
|
17
|
-
declare function buildDrainExpression(maxCount: number, maxTransportBodyBytes: number): string;
|
|
17
|
+
declare function buildDrainExpression(maxCount: number, maxTransportBodyBytes: number, acknowledgedDrainId?: string | null): string;
|
|
18
18
|
declare function buildStopExpression(options: StopExpressionOptions): string;
|
|
19
19
|
|
|
20
20
|
type LiveTraceLifecycleState = "idle" | "preparing" | "enabling-ssh" | "starting-inspector" | "opening-tunnel" | "injecting" | "streaming" | "stopping" | "stopped" | "error";
|
|
@@ -87,6 +87,7 @@ interface LiveTraceUrlSummary {
|
|
|
87
87
|
readonly latestSeenAt: string;
|
|
88
88
|
}
|
|
89
89
|
interface DrainParseResult {
|
|
90
|
+
readonly drainId: string | null;
|
|
90
91
|
readonly events: readonly LiveTraceEvent[];
|
|
91
92
|
readonly droppedCount: number;
|
|
92
93
|
readonly queueSize: number;
|
|
@@ -133,11 +134,137 @@ interface PreviewTruncationResult {
|
|
|
133
134
|
readonly preview: string;
|
|
134
135
|
readonly truncated: boolean;
|
|
135
136
|
}
|
|
136
|
-
declare function truncatePreview(preview: string,
|
|
137
|
+
declare function truncatePreview(preview: string, maxBytes: number): PreviewTruncationResult;
|
|
137
138
|
|
|
138
139
|
declare function buildUrlSummaries(events: readonly LiveTraceEvent[]): LiveTraceUrlSummary[];
|
|
139
140
|
declare function normalizeEventUrl(event: LiveTraceEvent): string;
|
|
140
141
|
|
|
142
|
+
interface TraceTargetIdentity {
|
|
143
|
+
readonly region?: string;
|
|
144
|
+
readonly apiEndpoint?: string;
|
|
145
|
+
readonly org: string;
|
|
146
|
+
readonly space: string;
|
|
147
|
+
readonly app: string;
|
|
148
|
+
readonly instance: string;
|
|
149
|
+
}
|
|
150
|
+
interface TraceSession {
|
|
151
|
+
readonly sessionId: string;
|
|
152
|
+
readonly createdAt: string;
|
|
153
|
+
readonly target: TraceTargetIdentity;
|
|
154
|
+
readonly directory: string;
|
|
155
|
+
readonly eventsDirectory: string;
|
|
156
|
+
readonly manifestPath: string;
|
|
157
|
+
}
|
|
158
|
+
interface StoredTraceEvent {
|
|
159
|
+
readonly version: 1;
|
|
160
|
+
readonly sessionId: string;
|
|
161
|
+
readonly requestId: string;
|
|
162
|
+
readonly createdAt: string;
|
|
163
|
+
readonly expiresAt: string;
|
|
164
|
+
readonly target: TraceTargetIdentity;
|
|
165
|
+
readonly requestBodyFormat: TraceBodyFormat;
|
|
166
|
+
readonly responseBodyFormat: TraceBodyFormat;
|
|
167
|
+
readonly event: LiveTraceEvent;
|
|
168
|
+
}
|
|
169
|
+
interface StoredTraceEventFile extends StoredTraceEvent {
|
|
170
|
+
readonly backupPath: string;
|
|
171
|
+
}
|
|
172
|
+
interface TraceSessionSummary {
|
|
173
|
+
readonly sessionId: string;
|
|
174
|
+
readonly createdAt: string;
|
|
175
|
+
readonly target: TraceTargetIdentity;
|
|
176
|
+
readonly eventCount: number;
|
|
177
|
+
readonly directory: string;
|
|
178
|
+
}
|
|
179
|
+
interface CreateTraceSessionInput {
|
|
180
|
+
readonly target: CfLiveTraceTarget;
|
|
181
|
+
}
|
|
182
|
+
interface TraceStoreOptions {
|
|
183
|
+
readonly saptoolsRoot?: string;
|
|
184
|
+
readonly now?: () => Date;
|
|
185
|
+
readonly sessionId?: string;
|
|
186
|
+
readonly requestId?: () => string;
|
|
187
|
+
}
|
|
188
|
+
type TraceEventVisitor = (record: StoredTraceEventFile) => boolean | Promise<boolean>;
|
|
189
|
+
declare function traceSessionsRoot(saptoolsRoot?: string): string;
|
|
190
|
+
declare function createTraceSession(input: CreateTraceSessionInput, options?: TraceStoreOptions): Promise<TraceSession>;
|
|
191
|
+
declare function writeTraceEvent(session: TraceSession, event: LiveTraceEvent, options?: TraceStoreOptions): Promise<StoredTraceEventFile>;
|
|
192
|
+
declare function readTraceEvent(sessionId: string, requestId: string, options?: TraceStoreOptions): Promise<StoredTraceEventFile>;
|
|
193
|
+
declare function listTraceEvents(sessionId: string, options?: TraceStoreOptions): Promise<readonly StoredTraceEventFile[]>;
|
|
194
|
+
declare function visitTraceEvents(sessionId: string, visitor: TraceEventVisitor, options?: TraceStoreOptions): Promise<void>;
|
|
195
|
+
declare function listTraceSessions(options?: TraceStoreOptions): Promise<readonly TraceSessionSummary[]>;
|
|
196
|
+
declare function pruneTraceSessions(options?: TraceStoreOptions): Promise<number>;
|
|
197
|
+
|
|
198
|
+
type TraceBodyFormat = "empty" | "json" | "xml" | "html" | "form" | "text" | "binary" | "unknown";
|
|
199
|
+
interface CompactTraceEvent {
|
|
200
|
+
readonly id: string;
|
|
201
|
+
readonly sessionId: string;
|
|
202
|
+
readonly requestId: string;
|
|
203
|
+
readonly timestamp: string;
|
|
204
|
+
readonly instance: string;
|
|
205
|
+
readonly method: string;
|
|
206
|
+
readonly path: string;
|
|
207
|
+
readonly url: string;
|
|
208
|
+
readonly normalizedUrl: string;
|
|
209
|
+
readonly status: number | null;
|
|
210
|
+
readonly durationMs: number | null;
|
|
211
|
+
readonly requestBytes: number;
|
|
212
|
+
readonly responseBytes: number;
|
|
213
|
+
readonly requestBodyFormat: TraceBodyFormat;
|
|
214
|
+
readonly responseBodyFormat: TraceBodyFormat;
|
|
215
|
+
readonly requestBodyPreview: string;
|
|
216
|
+
readonly requestBodyPreviewRemainingChars: number;
|
|
217
|
+
readonly responseBodyPreview: string;
|
|
218
|
+
readonly responseBodyPreviewRemainingChars: number;
|
|
219
|
+
readonly requestBodyTruncated: boolean;
|
|
220
|
+
readonly responseBodyTruncated: boolean;
|
|
221
|
+
readonly droppedBeforeEvent: number;
|
|
222
|
+
readonly source: "runtime-http";
|
|
223
|
+
readonly traceId: string;
|
|
224
|
+
readonly correlationId: string | null;
|
|
225
|
+
}
|
|
226
|
+
declare function detectBodyFormat(body: string, headers: Record<string, string>): TraceBodyFormat;
|
|
227
|
+
declare function compactTraceEvent(record: StoredTraceEvent): CompactTraceEvent;
|
|
228
|
+
|
|
229
|
+
type TraceBodySide = "request" | "response";
|
|
230
|
+
type TraceSearchBodySide = TraceBodySide | "both";
|
|
231
|
+
interface TraceBodyInspectionOptions {
|
|
232
|
+
readonly body: TraceBodySide;
|
|
233
|
+
readonly path?: string;
|
|
234
|
+
readonly limit?: number;
|
|
235
|
+
readonly maxRows?: number;
|
|
236
|
+
}
|
|
237
|
+
interface TraceBodyInspectionRow {
|
|
238
|
+
readonly path: string;
|
|
239
|
+
readonly type: string;
|
|
240
|
+
readonly value: string;
|
|
241
|
+
}
|
|
242
|
+
interface TraceBodyInspectionResult {
|
|
243
|
+
readonly rows: readonly TraceBodyInspectionRow[];
|
|
244
|
+
readonly totalRows: number;
|
|
245
|
+
readonly rowsTruncated: boolean;
|
|
246
|
+
}
|
|
247
|
+
interface TraceSearchOptions {
|
|
248
|
+
readonly body: TraceSearchBodySide;
|
|
249
|
+
readonly limit: number;
|
|
250
|
+
readonly previewLength?: number;
|
|
251
|
+
}
|
|
252
|
+
interface TraceSearchMatch {
|
|
253
|
+
readonly sessionId: string;
|
|
254
|
+
readonly requestId: string;
|
|
255
|
+
readonly timestamp: string;
|
|
256
|
+
readonly method: string;
|
|
257
|
+
readonly normalizedUrl: string;
|
|
258
|
+
readonly status: number | null;
|
|
259
|
+
readonly body: TraceBodySide;
|
|
260
|
+
readonly path: string;
|
|
261
|
+
readonly offset?: number;
|
|
262
|
+
readonly preview: string;
|
|
263
|
+
}
|
|
264
|
+
declare function inspectTraceBody(record: StoredTraceEvent, options: TraceBodyInspectionOptions): readonly TraceBodyInspectionRow[];
|
|
265
|
+
declare function inspectTraceBodyResult(record: StoredTraceEvent, options: TraceBodyInspectionOptions): TraceBodyInspectionResult;
|
|
266
|
+
declare function searchTraceRecords(records: readonly StoredTraceEvent[], searchTerm: string, options: TraceSearchOptions): readonly TraceSearchMatch[];
|
|
267
|
+
|
|
141
268
|
interface RunCfOptions {
|
|
142
269
|
readonly cfHomeDir?: string;
|
|
143
270
|
readonly command?: string;
|
|
@@ -181,7 +308,7 @@ declare function createSecretRedactor(secrets: readonly string[]): (message: str
|
|
|
181
308
|
interface LiveTraceSessionOptions {
|
|
182
309
|
readonly target: CfLiveTraceTarget;
|
|
183
310
|
readonly onState?: (event: LiveTraceStateEvent) => void;
|
|
184
|
-
readonly onEvents?: (events: readonly LiveTraceEvent[]) => void
|
|
311
|
+
readonly onEvents?: (events: readonly LiveTraceEvent[]) => void | Promise<void>;
|
|
185
312
|
readonly onSummary?: (summary: ReturnType<typeof buildUrlSummaries>) => void;
|
|
186
313
|
readonly onLog?: (message: string) => void;
|
|
187
314
|
}
|
|
@@ -197,11 +324,12 @@ interface LiveTraceDependencies {
|
|
|
197
324
|
declare class LiveTraceSession {
|
|
198
325
|
private readonly options;
|
|
199
326
|
private readonly dependencies;
|
|
200
|
-
private readonly
|
|
327
|
+
private readonly summaryEvents;
|
|
201
328
|
private consecutiveDrainTimeouts;
|
|
202
|
-
private
|
|
329
|
+
private drainTask;
|
|
203
330
|
private inspectorClient;
|
|
204
331
|
private pollTimer;
|
|
332
|
+
private pendingDrainAcknowledgement;
|
|
205
333
|
private state;
|
|
206
334
|
private stopRequested;
|
|
207
335
|
private tunnelHandle;
|
|
@@ -214,9 +342,13 @@ declare class LiveTraceSession {
|
|
|
214
342
|
private attachInspector;
|
|
215
343
|
private installRuntimeHook;
|
|
216
344
|
private startPolling;
|
|
345
|
+
private startDrain;
|
|
346
|
+
private clearDrainTask;
|
|
217
347
|
private drainTraceEvents;
|
|
218
348
|
private publishDrainedEvents;
|
|
349
|
+
private publishSummary;
|
|
219
350
|
private handleDrainFailure;
|
|
351
|
+
private handleEventHandlerFailure;
|
|
220
352
|
private stopRuntimeTrace;
|
|
221
353
|
private closeInspectorClient;
|
|
222
354
|
private stopTunnel;
|
|
@@ -229,4 +361,4 @@ declare class LiveTraceSession {
|
|
|
229
361
|
private reportInspectorStartup;
|
|
230
362
|
}
|
|
231
363
|
|
|
232
|
-
export { CF_LIVE_TRACE_GLOBAL_NAME, CF_LIVE_TRACE_RUNTIME_SOURCE, CF_LIVE_TRACE_RUNTIME_VERSION, type CfDependencies, type CfLiveTraceTarget, type DrainParseOptions, type DrainParseResult, type InspectorRuntimeClient, type InspectorStartupResult, type LiveTraceDependencies, type LiveTraceEvent, type LiveTraceLifecycleState, LiveTraceSession, type LiveTraceSessionOptions, type LiveTraceStartOptions, type LiveTraceStateEvent, type LiveTraceStopOptions, type LiveTraceStopReason, type LiveTraceUrlSummary, type PortForwardHandle, type PortForwardParams, type PortForwardProcess, type PreviewTruncationResult, type RunCfOptions, type RuntimeInstallOptions, type StopExpressionOptions, type TunnelDependencies, type TunnelOpenResult, type TunnelReadyResult, buildCfSshArgs, buildDrainExpression, buildInspectorSignalCommand, buildInstallExpression, buildStopExpression, buildUrlSummaries, createSecretRedactor, normalizeEventUrl, openInspectorTunnel, parseDrainResult, prepareCfSession, startNodeInspector, truncatePreview, tryStartNodeInspector };
|
|
364
|
+
export { CF_LIVE_TRACE_GLOBAL_NAME, CF_LIVE_TRACE_RUNTIME_SOURCE, CF_LIVE_TRACE_RUNTIME_VERSION, type CfDependencies, type CfLiveTraceTarget, type CompactTraceEvent, type CreateTraceSessionInput, type DrainParseOptions, type DrainParseResult, type InspectorRuntimeClient, type InspectorStartupResult, type LiveTraceDependencies, type LiveTraceEvent, type LiveTraceLifecycleState, LiveTraceSession, type LiveTraceSessionOptions, type LiveTraceStartOptions, type LiveTraceStateEvent, type LiveTraceStopOptions, type LiveTraceStopReason, type LiveTraceUrlSummary, type PortForwardHandle, type PortForwardParams, type PortForwardProcess, type PreviewTruncationResult, type RunCfOptions, type RuntimeInstallOptions, type StopExpressionOptions, type StoredTraceEvent, type StoredTraceEventFile, type TraceBodyFormat, type TraceBodyInspectionOptions, type TraceBodyInspectionResult, type TraceBodyInspectionRow, type TraceBodySide, type TraceEventVisitor, type TraceSearchBodySide, type TraceSearchMatch, type TraceSearchOptions, type TraceSession, type TraceSessionSummary, type TraceStoreOptions, type TraceTargetIdentity, type TunnelDependencies, type TunnelOpenResult, type TunnelReadyResult, buildCfSshArgs, buildDrainExpression, buildInspectorSignalCommand, buildInstallExpression, buildStopExpression, buildUrlSummaries, compactTraceEvent, createSecretRedactor, createTraceSession, detectBodyFormat, inspectTraceBody, inspectTraceBodyResult, listTraceEvents, listTraceSessions, normalizeEventUrl, openInspectorTunnel, parseDrainResult, prepareCfSession, pruneTraceSessions, readTraceEvent, searchTraceRecords, startNodeInspector, traceSessionsRoot, truncatePreview, tryStartNodeInspector, visitTraceEvents, writeTraceEvent };
|