@gvnrdao/dh-lit-actions 0.0.3 โ 0.0.4
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/package.json +3 -3
- package/pkg-dist/utils/chunks/connection-helpers.d.ts +99 -0
- package/pkg-dist/utils/chunks/connection-helpers.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/connection-helpers.js +362 -0
- package/pkg-dist/utils/chunks/connection-helpers.js.map +1 -0
- package/pkg-dist/utils/chunks/debug-logger.d.ts +93 -0
- package/pkg-dist/utils/chunks/debug-logger.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/debug-logger.js +264 -0
- package/pkg-dist/utils/chunks/debug-logger.js.map +1 -0
- package/pkg-dist/utils/chunks/error-classification.d.ts +97 -0
- package/pkg-dist/utils/chunks/error-classification.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/error-classification.js +385 -0
- package/pkg-dist/utils/chunks/error-classification.js.map +1 -0
- package/pkg-dist/utils/chunks/session-signature-cache.d.ts +84 -0
- package/pkg-dist/utils/chunks/session-signature-cache.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/session-signature-cache.js +194 -0
- package/pkg-dist/utils/chunks/session-signature-cache.js.map +1 -0
- package/pkg-dist/utils/index.d.ts +4 -0
- package/pkg-dist/utils/index.d.ts.map +1 -1
- package/pkg-dist/utils/index.js +4 -0
- package/pkg-dist/utils/index.js.map +1 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced Debug Logger for LIT Protocol Operations
|
|
4
|
+
* Provides detailed logging for debugging network and protocol issues
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.networkMetrics = exports.PerformanceTracker = exports.DEFAULT_DEBUG_CONFIG = exports.LogLevel = void 0;
|
|
8
|
+
exports.configureDebugLogging = configureDebugLogging;
|
|
9
|
+
exports.debugError = debugError;
|
|
10
|
+
exports.debugWarn = debugWarn;
|
|
11
|
+
exports.debugInfo = debugInfo;
|
|
12
|
+
exports.debugLog = debugLog;
|
|
13
|
+
exports.debugTrace = debugTrace;
|
|
14
|
+
exports.logRequest = logRequest;
|
|
15
|
+
exports.logResponse = logResponse;
|
|
16
|
+
exports.logError = logError;
|
|
17
|
+
exports.logConnectionAttempt = logConnectionAttempt;
|
|
18
|
+
exports.logConnectionSuccess = logConnectionSuccess;
|
|
19
|
+
exports.logConnectionFailure = logConnectionFailure;
|
|
20
|
+
exports.logPkpOperation = logPkpOperation;
|
|
21
|
+
exports.logSessionSignatures = logSessionSignatures;
|
|
22
|
+
exports.logLitActionExecution = logLitActionExecution;
|
|
23
|
+
exports.logLitActionResult = logLitActionResult;
|
|
24
|
+
exports.logTestStart = logTestStart;
|
|
25
|
+
exports.logTestEnd = logTestEnd;
|
|
26
|
+
var LogLevel;
|
|
27
|
+
(function (LogLevel) {
|
|
28
|
+
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
|
|
29
|
+
LogLevel[LogLevel["WARN"] = 1] = "WARN";
|
|
30
|
+
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
31
|
+
LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
|
|
32
|
+
LogLevel[LogLevel["TRACE"] = 4] = "TRACE";
|
|
33
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
34
|
+
exports.DEFAULT_DEBUG_CONFIG = {
|
|
35
|
+
level: LogLevel.INFO,
|
|
36
|
+
enableTimestamps: true,
|
|
37
|
+
enablePerformanceMetrics: true,
|
|
38
|
+
enableRequestLogging: true,
|
|
39
|
+
enableNetworkMetrics: true
|
|
40
|
+
};
|
|
41
|
+
let debugConfig = { ...exports.DEFAULT_DEBUG_CONFIG };
|
|
42
|
+
/**
|
|
43
|
+
* Configure debug logging
|
|
44
|
+
*/
|
|
45
|
+
function configureDebugLogging(config) {
|
|
46
|
+
debugConfig = { ...debugConfig, ...config };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get current timestamp string
|
|
50
|
+
*/
|
|
51
|
+
function getTimestamp() {
|
|
52
|
+
return new Date().toISOString();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Format log message with metadata
|
|
56
|
+
*/
|
|
57
|
+
function formatMessage(level, component, message, metadata) {
|
|
58
|
+
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : '';
|
|
59
|
+
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : '';
|
|
60
|
+
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Performance metrics tracker
|
|
64
|
+
*/
|
|
65
|
+
class PerformanceTracker {
|
|
66
|
+
constructor(operationName) {
|
|
67
|
+
this.operationName = operationName;
|
|
68
|
+
this.markers = new Map();
|
|
69
|
+
this.startTime = Date.now();
|
|
70
|
+
this.log('PERF', `Started: ${operationName}`);
|
|
71
|
+
}
|
|
72
|
+
mark(label) {
|
|
73
|
+
const elapsed = Date.now() - this.startTime;
|
|
74
|
+
this.markers.set(label, elapsed);
|
|
75
|
+
this.log('PERF', `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
76
|
+
}
|
|
77
|
+
end(success = true) {
|
|
78
|
+
const totalTime = Date.now() - this.startTime;
|
|
79
|
+
const status = success ? 'SUCCESS' : 'FAILED';
|
|
80
|
+
this.log('PERF', `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
81
|
+
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
82
|
+
console.log(`๐ Performance Breakdown for ${this.operationName}:`);
|
|
83
|
+
for (const [label, time] of this.markers) {
|
|
84
|
+
console.log(` ${label}: ${time}ms`);
|
|
85
|
+
}
|
|
86
|
+
console.log(` Total: ${totalTime}ms`);
|
|
87
|
+
}
|
|
88
|
+
return totalTime;
|
|
89
|
+
}
|
|
90
|
+
log(level, message) {
|
|
91
|
+
if (debugConfig.enablePerformanceMetrics) {
|
|
92
|
+
console.log(formatMessage(level, 'PERFORMANCE', message));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.PerformanceTracker = PerformanceTracker;
|
|
97
|
+
class NetworkMetricsCollector {
|
|
98
|
+
constructor() {
|
|
99
|
+
this.metrics = new Map();
|
|
100
|
+
}
|
|
101
|
+
getMetrics(operation) {
|
|
102
|
+
if (!this.metrics.has(operation)) {
|
|
103
|
+
this.metrics.set(operation, {
|
|
104
|
+
requestCount: 0,
|
|
105
|
+
successCount: 0,
|
|
106
|
+
failureCount: 0,
|
|
107
|
+
averageLatency: 0,
|
|
108
|
+
startTime: Date.now()
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return this.metrics.get(operation);
|
|
112
|
+
}
|
|
113
|
+
recordRequest(operation, success, latency, error) {
|
|
114
|
+
const metrics = this.getMetrics(operation);
|
|
115
|
+
metrics.requestCount++;
|
|
116
|
+
if (success) {
|
|
117
|
+
metrics.successCount++;
|
|
118
|
+
// Update average latency
|
|
119
|
+
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
metrics.failureCount++;
|
|
123
|
+
if (error)
|
|
124
|
+
metrics.lastError = error;
|
|
125
|
+
}
|
|
126
|
+
if (debugConfig.enableNetworkMetrics) {
|
|
127
|
+
const successRate = ((metrics.successCount / metrics.requestCount) * 100).toFixed(1);
|
|
128
|
+
debugLog('NETWORK', `${operation} - Success: ${success}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
printSummary() {
|
|
132
|
+
if (!debugConfig.enableNetworkMetrics)
|
|
133
|
+
return;
|
|
134
|
+
console.log('\n๐ Network Metrics Summary:');
|
|
135
|
+
for (const [operation, metrics] of this.metrics) {
|
|
136
|
+
const successRate = ((metrics.successCount / metrics.requestCount) * 100).toFixed(1);
|
|
137
|
+
const runtime = Date.now() - metrics.startTime;
|
|
138
|
+
console.log(` ${operation}:`);
|
|
139
|
+
console.log(` Requests: ${metrics.requestCount}`);
|
|
140
|
+
console.log(` Success Rate: ${successRate}%`);
|
|
141
|
+
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
142
|
+
console.log(` Runtime: ${runtime}ms`);
|
|
143
|
+
if (metrics.lastError) {
|
|
144
|
+
console.log(` Last Error: ${metrics.lastError}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.networkMetrics = new NetworkMetricsCollector();
|
|
150
|
+
/**
|
|
151
|
+
* Debug logging functions
|
|
152
|
+
*/
|
|
153
|
+
function debugError(component, message, metadata) {
|
|
154
|
+
if (debugConfig.level >= LogLevel.ERROR) {
|
|
155
|
+
console.error(formatMessage('ERROR', component, message, metadata));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function debugWarn(component, message, metadata) {
|
|
159
|
+
if (debugConfig.level >= LogLevel.WARN) {
|
|
160
|
+
console.warn(formatMessage('WARN', component, message, metadata));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function debugInfo(component, message, metadata) {
|
|
164
|
+
if (debugConfig.level >= LogLevel.INFO) {
|
|
165
|
+
console.log(formatMessage('INFO', component, message, metadata));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function debugLog(component, message, metadata) {
|
|
169
|
+
if (debugConfig.level >= LogLevel.DEBUG) {
|
|
170
|
+
console.log(formatMessage('DEBUG', component, message, metadata));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function debugTrace(component, message, metadata) {
|
|
174
|
+
if (debugConfig.level >= LogLevel.TRACE) {
|
|
175
|
+
console.log(formatMessage('TRACE', component, message, metadata));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Request/Response logger for LIT Protocol operations
|
|
180
|
+
*/
|
|
181
|
+
function logRequest(component, operation, params) {
|
|
182
|
+
if (!debugConfig.enableRequestLogging)
|
|
183
|
+
return;
|
|
184
|
+
debugLog(component, `๐ Request: ${operation}`, {
|
|
185
|
+
operation,
|
|
186
|
+
params: JSON.stringify(params, null, 2)
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function logResponse(component, operation, response, duration) {
|
|
190
|
+
if (!debugConfig.enableRequestLogging)
|
|
191
|
+
return;
|
|
192
|
+
debugLog(component, `โ
Response: ${operation} (${duration}ms)`, {
|
|
193
|
+
operation,
|
|
194
|
+
duration,
|
|
195
|
+
response: typeof response === 'object' ? JSON.stringify(response, null, 2) : response
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function logError(component, operation, error, duration) {
|
|
199
|
+
const durationStr = duration ? ` (${duration}ms)` : '';
|
|
200
|
+
debugError(component, `โ Error: ${operation}${durationStr}`, {
|
|
201
|
+
operation,
|
|
202
|
+
duration,
|
|
203
|
+
error: error?.message || error?.toString() || 'Unknown error',
|
|
204
|
+
stack: error?.stack
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Network connection logger
|
|
209
|
+
*/
|
|
210
|
+
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
211
|
+
debugInfo('CONNECTION', `๐ Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
212
|
+
}
|
|
213
|
+
function logConnectionSuccess(network, latency) {
|
|
214
|
+
debugInfo('CONNECTION', `โ
Connected to ${network} (${latency}ms)`);
|
|
215
|
+
exports.networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
216
|
+
}
|
|
217
|
+
function logConnectionFailure(network, error, attempt) {
|
|
218
|
+
debugError('CONNECTION', `โ Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
219
|
+
exports.networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* PKP operation logger
|
|
223
|
+
*/
|
|
224
|
+
function logPkpOperation(operation, pkpId, details) {
|
|
225
|
+
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : '';
|
|
226
|
+
debugInfo('PKP', `๐ ${operation}${pkpStr}`, details);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Session signature logger
|
|
230
|
+
*/
|
|
231
|
+
function logSessionSignatures(count, expiration) {
|
|
232
|
+
debugInfo('SESSION', `๐ Generated ${count} session signatures (expires: ${expiration})`);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* LIT Action execution logger
|
|
236
|
+
*/
|
|
237
|
+
function logLitActionExecution(cid, params) {
|
|
238
|
+
debugInfo('LIT_ACTION', `โก Executing LIT Action: ${cid}`, {
|
|
239
|
+
cid,
|
|
240
|
+
params
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function logLitActionResult(cid, success, duration, result) {
|
|
244
|
+
const status = success ? 'โ
' : 'โ';
|
|
245
|
+
debugInfo('LIT_ACTION', `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
246
|
+
cid,
|
|
247
|
+
success,
|
|
248
|
+
duration,
|
|
249
|
+
result: success && result ? JSON.stringify(result, null, 2) : undefined
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Test lifecycle logger
|
|
254
|
+
*/
|
|
255
|
+
function logTestStart(testName) {
|
|
256
|
+
debugInfo('TEST', `๐งช Starting test: ${testName}`);
|
|
257
|
+
return new PerformanceTracker(testName);
|
|
258
|
+
}
|
|
259
|
+
function logTestEnd(testName, success, duration) {
|
|
260
|
+
const status = success ? 'โ
' : 'โ';
|
|
261
|
+
debugInfo('TEST', `${status} Test completed: ${testName} (${duration}ms)`);
|
|
262
|
+
exports.networkMetrics.printSummary();
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=debug-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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
+
* Provides detailed error categorization and specific retry strategies
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Error categories for different types of failures
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ErrorCategory {
|
|
9
|
+
NETWORK = "network",
|
|
10
|
+
PROTOCOL = "protocol",
|
|
11
|
+
AUTHENTICATION = "authentication",
|
|
12
|
+
RESOURCE = "resource",
|
|
13
|
+
VALIDATION = "validation",
|
|
14
|
+
TIMEOUT = "timeout",
|
|
15
|
+
RATE_LIMIT = "rate_limit",
|
|
16
|
+
CONFIGURATION = "configuration",
|
|
17
|
+
UNKNOWN = "unknown"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Retry strategy types
|
|
21
|
+
*/
|
|
22
|
+
export declare enum RetryStrategy {
|
|
23
|
+
AGGRESSIVE = "aggressive",// Fast retries for transient issues
|
|
24
|
+
CONSERVATIVE = "conservative",// Slower retries for resource issues
|
|
25
|
+
EXPONENTIAL = "exponential",// Standard exponential backoff
|
|
26
|
+
LINEAR = "linear",// Linear delay increase
|
|
27
|
+
NONE = "none"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error classification result
|
|
31
|
+
*/
|
|
32
|
+
export interface ErrorClassification {
|
|
33
|
+
category: ErrorCategory;
|
|
34
|
+
retryStrategy: RetryStrategy;
|
|
35
|
+
isRetryable: boolean;
|
|
36
|
+
maxAttempts: number;
|
|
37
|
+
baseDelayMs: number;
|
|
38
|
+
maxDelayMs: number;
|
|
39
|
+
description: string;
|
|
40
|
+
troubleshooting?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Classify an error and determine retry strategy
|
|
44
|
+
*/
|
|
45
|
+
export declare function classifyError(error: any): ErrorClassification;
|
|
46
|
+
/**
|
|
47
|
+
* Get retry configuration from error classification
|
|
48
|
+
*/
|
|
49
|
+
export declare function getRetryConfigFromClassification(classification: ErrorClassification): {
|
|
50
|
+
maxAttempts: number;
|
|
51
|
+
initialDelayMs: number;
|
|
52
|
+
maxDelayMs: number;
|
|
53
|
+
backoffMultiplier: number;
|
|
54
|
+
retryableErrors: string[];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Enhanced error analyzer for detailed error information
|
|
58
|
+
*/
|
|
59
|
+
export declare function analyzeError(error: any): {
|
|
60
|
+
originalError: any;
|
|
61
|
+
errorMessage: any;
|
|
62
|
+
errorStack: any;
|
|
63
|
+
timestamp: string;
|
|
64
|
+
retryConfig: {
|
|
65
|
+
maxAttempts: number;
|
|
66
|
+
initialDelayMs: number;
|
|
67
|
+
maxDelayMs: number;
|
|
68
|
+
backoffMultiplier: number;
|
|
69
|
+
retryableErrors: string[];
|
|
70
|
+
};
|
|
71
|
+
category: ErrorCategory;
|
|
72
|
+
retryStrategy: RetryStrategy;
|
|
73
|
+
isRetryable: boolean;
|
|
74
|
+
maxAttempts: number;
|
|
75
|
+
baseDelayMs: number;
|
|
76
|
+
maxDelayMs: number;
|
|
77
|
+
description: string;
|
|
78
|
+
troubleshooting?: string[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Create a human-readable error report
|
|
82
|
+
*/
|
|
83
|
+
export declare function createErrorReport(error: any): string;
|
|
84
|
+
/**
|
|
85
|
+
* LIT Protocol specific error matchers
|
|
86
|
+
*/
|
|
87
|
+
export declare const litProtocolErrors: {
|
|
88
|
+
isNetworkError: (error: any) => boolean;
|
|
89
|
+
isProtocolError: (error: any) => boolean;
|
|
90
|
+
isAuthenticationError: (error: any) => boolean;
|
|
91
|
+
isResourceError: (error: any) => boolean;
|
|
92
|
+
isTimeoutError: (error: any) => boolean;
|
|
93
|
+
isRateLimitError: (error: any) => boolean;
|
|
94
|
+
isConfigurationError: (error: any) => boolean;
|
|
95
|
+
isRetryable: (error: any) => boolean;
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=error-classification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classification.d.ts","sour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