gitlab-auto-reviewers 2.0.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/LICENSE +21 -0
- package/README.md +1878 -0
- package/dist/api/gitlab-api.d.ts +136 -0
- package/dist/api/gitlab-api.d.ts.map +1 -0
- package/dist/api/gitlab-api.js +334 -0
- package/dist/api/gitlab-api.js.map +1 -0
- package/dist/bin/cli.d.ts +10 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +186 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/deprecated-mcp.d.ts +12 -0
- package/dist/bin/deprecated-mcp.d.ts.map +1 -0
- package/dist/bin/deprecated-mcp.js +73 -0
- package/dist/bin/deprecated-mcp.js.map +1 -0
- package/dist/bin/index.d.ts +18 -0
- package/dist/bin/index.d.ts.map +1 -0
- package/dist/bin/index.js +78 -0
- package/dist/bin/index.js.map +1 -0
- package/dist/bin/mcp.d.ts +11 -0
- package/dist/bin/mcp.d.ts.map +1 -0
- package/dist/bin/mcp.js +43 -0
- package/dist/bin/mcp.js.map +1 -0
- package/dist/cache/cache.service.d.ts +113 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +213 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cli/commands.d.ts +40 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +142 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/output.d.ts +24 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +143 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/config/config.service.d.ts +89 -0
- package/dist/config/config.service.d.ts.map +1 -0
- package/dist/config/config.service.js +169 -0
- package/dist/config/config.service.js.map +1 -0
- package/dist/datasources/git-data-source.interface.d.ts +140 -0
- package/dist/datasources/git-data-source.interface.d.ts.map +1 -0
- package/dist/datasources/git-data-source.interface.js +2 -0
- package/dist/datasources/git-data-source.interface.js.map +1 -0
- package/dist/datasources/gitlab-api-data-source.d.ts +127 -0
- package/dist/datasources/gitlab-api-data-source.d.ts.map +1 -0
- package/dist/datasources/gitlab-api-data-source.js +248 -0
- package/dist/datasources/gitlab-api-data-source.js.map +1 -0
- package/dist/datasources/local-git-data-source.d.ts +124 -0
- package/dist/datasources/local-git-data-source.d.ts.map +1 -0
- package/dist/datasources/local-git-data-source.js +580 -0
- package/dist/datasources/local-git-data-source.js.map +1 -0
- package/dist/errors/error-handler.d.ts +113 -0
- package/dist/errors/error-handler.d.ts.map +1 -0
- package/dist/errors/error-handler.js +230 -0
- package/dist/errors/error-handler.js.map +1 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/example.d.ts +15 -0
- package/dist/logging/example.d.ts.map +1 -0
- package/dist/logging/example.js +79 -0
- package/dist/logging/example.js.map +1 -0
- package/dist/logging/index.d.ts +7 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +7 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.service.d.ts +98 -0
- package/dist/logging/logger.service.d.ts.map +1 -0
- package/dist/logging/logger.service.js +160 -0
- package/dist/logging/logger.service.js.map +1 -0
- package/dist/mcp/server.d.ts +67 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +213 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +22 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +176 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/services/blacklist.service.d.ts +32 -0
- package/dist/services/blacklist.service.d.ts.map +1 -0
- package/dist/services/blacklist.service.js +59 -0
- package/dist/services/blacklist.service.js.map +1 -0
- package/dist/services/codeowners.service.d.ts +45 -0
- package/dist/services/codeowners.service.d.ts.map +1 -0
- package/dist/services/codeowners.service.js +200 -0
- package/dist/services/codeowners.service.js.map +1 -0
- package/dist/services/comment-builder.service.d.ts +48 -0
- package/dist/services/comment-builder.service.d.ts.map +1 -0
- package/dist/services/comment-builder.service.js +61 -0
- package/dist/services/comment-builder.service.js.map +1 -0
- package/dist/services/contributors.service.d.ts +52 -0
- package/dist/services/contributors.service.d.ts.map +1 -0
- package/dist/services/contributors.service.js +144 -0
- package/dist/services/contributors.service.js.map +1 -0
- package/dist/services/reviewer-service.d.ts +125 -0
- package/dist/services/reviewer-service.d.ts.map +1 -0
- package/dist/services/reviewer-service.js +554 -0
- package/dist/services/reviewer-service.js.map +1 -0
- package/dist/services/team-members.service.d.ts +29 -0
- package/dist/services/team-members.service.d.ts.map +1 -0
- package/dist/services/team-members.service.js +45 -0
- package/dist/services/team-members.service.js.map +1 -0
- package/dist/services/whitelist.service.d.ts +31 -0
- package/dist/services/whitelist.service.d.ts.map +1 -0
- package/dist/services/whitelist.service.js +51 -0
- package/dist/services/whitelist.service.js.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +176 -0
- package/dist/tools.js.map +1 -0
- package/dist/types/index.d.ts +502 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +91 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types.d.ts +219 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Handler
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling with retry logic and clear error messages.
|
|
5
|
+
* Supports exponential backoff for transient failures.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Custom error class for MCP server errors
|
|
9
|
+
*/
|
|
10
|
+
export declare class MCPError extends Error {
|
|
11
|
+
code: string;
|
|
12
|
+
details?: Record<string, unknown> | undefined;
|
|
13
|
+
cause?: Error | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new MCP error
|
|
16
|
+
*
|
|
17
|
+
* @param message - Human-readable error message
|
|
18
|
+
* @param code - Error code for categorization (e.g., 'configuration', 'validation')
|
|
19
|
+
* @param details - Optional additional error details
|
|
20
|
+
* @param cause - Optional underlying error that caused this error
|
|
21
|
+
*/
|
|
22
|
+
constructor(message: string, code: string, details?: Record<string, unknown> | undefined, cause?: Error | undefined);
|
|
23
|
+
/**
|
|
24
|
+
* Convert error to JSON for logging/serialization
|
|
25
|
+
*/
|
|
26
|
+
toJSON(): Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error categories for classification
|
|
30
|
+
*/
|
|
31
|
+
export declare enum ErrorCategory {
|
|
32
|
+
CONFIGURATION = "configuration",
|
|
33
|
+
VALIDATION = "validation",
|
|
34
|
+
GIT_OPERATION = "git_operation",
|
|
35
|
+
API_CALL = "api_call",
|
|
36
|
+
NETWORK = "network",
|
|
37
|
+
PERMISSION = "permission",
|
|
38
|
+
NOT_FOUND = "not_found",
|
|
39
|
+
INTERNAL = "internal"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Retry options for operations
|
|
43
|
+
*
|
|
44
|
+
* @property maxRetries - Maximum number of retry attempts
|
|
45
|
+
* @property delayMs - Initial delay in milliseconds between retries
|
|
46
|
+
* @property backoffMultiplier - Multiplier for exponential backoff (e.g., 2 for doubling)
|
|
47
|
+
* @property onRetry - Optional callback function called on each retry attempt
|
|
48
|
+
*/
|
|
49
|
+
export interface RetryOptions {
|
|
50
|
+
maxRetries: number;
|
|
51
|
+
delayMs: number;
|
|
52
|
+
backoffMultiplier: number;
|
|
53
|
+
onRetry?: (attempt: number, error: Error) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Default retry options
|
|
57
|
+
*/
|
|
58
|
+
export declare const DEFAULT_RETRY_OPTIONS: RetryOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Error Handler utility class
|
|
61
|
+
*/
|
|
62
|
+
export declare class ErrorHandler {
|
|
63
|
+
private static logger;
|
|
64
|
+
/**
|
|
65
|
+
* Execute an operation with retry logic
|
|
66
|
+
*/
|
|
67
|
+
static withRetry<T>(operation: () => Promise<T>, options?: Partial<RetryOptions>): Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Check if an error is transient (retryable)
|
|
70
|
+
*/
|
|
71
|
+
static isTransient(error: Error): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Format an error for display
|
|
74
|
+
*/
|
|
75
|
+
static formatError(error: Error): string;
|
|
76
|
+
/**
|
|
77
|
+
* Create an MCPError from a generic error
|
|
78
|
+
*/
|
|
79
|
+
static toMCPError(error: unknown, code: string, details?: Record<string, unknown>): MCPError;
|
|
80
|
+
/**
|
|
81
|
+
* Wrap an operation with error handling
|
|
82
|
+
*/
|
|
83
|
+
static wrap<T>(operation: () => Promise<T>, errorCode: string, _errorMessage: string, details?: Record<string, unknown>): Promise<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Delay execution for a specified time
|
|
86
|
+
*/
|
|
87
|
+
private static delay;
|
|
88
|
+
/**
|
|
89
|
+
* Create a configuration error
|
|
90
|
+
*/
|
|
91
|
+
static configurationError(message: string, details?: Record<string, unknown>): MCPError;
|
|
92
|
+
/**
|
|
93
|
+
* Create a validation error
|
|
94
|
+
*/
|
|
95
|
+
static validationError(message: string, details?: Record<string, unknown>): MCPError;
|
|
96
|
+
/**
|
|
97
|
+
* Create a git operation error
|
|
98
|
+
*/
|
|
99
|
+
static gitOperationError(message: string, details?: Record<string, unknown>, cause?: Error): MCPError;
|
|
100
|
+
/**
|
|
101
|
+
* Create an API call error
|
|
102
|
+
*/
|
|
103
|
+
static apiCallError(message: string, details?: Record<string, unknown>, cause?: Error): MCPError;
|
|
104
|
+
/**
|
|
105
|
+
* Create a not found error
|
|
106
|
+
*/
|
|
107
|
+
static notFoundError(message: string, details?: Record<string, unknown>): MCPError;
|
|
108
|
+
/**
|
|
109
|
+
* Create a permission error
|
|
110
|
+
*/
|
|
111
|
+
static permissionError(message: string, details?: Record<string, unknown>): MCPError;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/errors/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAWxB,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjC,KAAK,CAAC,EAAE,KAAK;IAZtB;;;;;;;OAOG;gBAED,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA,EACjC,KAAK,CAAC,EAAE,KAAK,YAAA;IAWtB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlC;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,aAAa,kBAAkB;IAC/B,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,QAAQ,aAAa;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAInC,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,MAAM,CAA8B;IAEnD;;OAEG;WACU,SAAS,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,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,KAAK,CAAC,EAAE,KAAK,GACZ,QAAQ;IAIX;;OAEG;IACH,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,QAAQ;IAIX;;OAEG;IACH,MAAM,CAAC,eAAe,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,QAAQ;CAGZ"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Handler
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling with retry logic and clear error messages.
|
|
5
|
+
* Supports exponential backoff for transient failures.
|
|
6
|
+
*/
|
|
7
|
+
import { Logger } from '../logging/logger.service.js';
|
|
8
|
+
/**
|
|
9
|
+
* Custom error class for MCP server errors
|
|
10
|
+
*/
|
|
11
|
+
export class MCPError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
details;
|
|
14
|
+
cause;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new MCP error
|
|
17
|
+
*
|
|
18
|
+
* @param message - Human-readable error message
|
|
19
|
+
* @param code - Error code for categorization (e.g., 'configuration', 'validation')
|
|
20
|
+
* @param details - Optional additional error details
|
|
21
|
+
* @param cause - Optional underlying error that caused this error
|
|
22
|
+
*/
|
|
23
|
+
constructor(message, code, details, cause) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.details = details;
|
|
27
|
+
this.cause = cause;
|
|
28
|
+
this.name = 'MCPError';
|
|
29
|
+
// Maintain proper stack trace for where our error was thrown (only available on V8)
|
|
30
|
+
if (Error.captureStackTrace) {
|
|
31
|
+
Error.captureStackTrace(this, MCPError);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert error to JSON for logging/serialization
|
|
36
|
+
*/
|
|
37
|
+
toJSON() {
|
|
38
|
+
return {
|
|
39
|
+
name: this.name,
|
|
40
|
+
message: this.message,
|
|
41
|
+
code: this.code,
|
|
42
|
+
details: this.details,
|
|
43
|
+
cause: this.cause?.message,
|
|
44
|
+
stack: this.stack,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Error categories for classification
|
|
50
|
+
*/
|
|
51
|
+
export var ErrorCategory;
|
|
52
|
+
(function (ErrorCategory) {
|
|
53
|
+
ErrorCategory["CONFIGURATION"] = "configuration";
|
|
54
|
+
ErrorCategory["VALIDATION"] = "validation";
|
|
55
|
+
ErrorCategory["GIT_OPERATION"] = "git_operation";
|
|
56
|
+
ErrorCategory["API_CALL"] = "api_call";
|
|
57
|
+
ErrorCategory["NETWORK"] = "network";
|
|
58
|
+
ErrorCategory["PERMISSION"] = "permission";
|
|
59
|
+
ErrorCategory["NOT_FOUND"] = "not_found";
|
|
60
|
+
ErrorCategory["INTERNAL"] = "internal";
|
|
61
|
+
})(ErrorCategory || (ErrorCategory = {}));
|
|
62
|
+
/**
|
|
63
|
+
* Default retry options
|
|
64
|
+
*/
|
|
65
|
+
export const DEFAULT_RETRY_OPTIONS = {
|
|
66
|
+
maxRetries: 3,
|
|
67
|
+
delayMs: 1000,
|
|
68
|
+
backoffMultiplier: 2,
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Error Handler utility class
|
|
72
|
+
*/
|
|
73
|
+
export class ErrorHandler {
|
|
74
|
+
static logger = new Logger('ErrorHandler');
|
|
75
|
+
/**
|
|
76
|
+
* Execute an operation with retry logic
|
|
77
|
+
*/
|
|
78
|
+
static async withRetry(operation, options = {}) {
|
|
79
|
+
const opts = { ...DEFAULT_RETRY_OPTIONS, ...options };
|
|
80
|
+
let lastError;
|
|
81
|
+
for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
|
|
82
|
+
try {
|
|
83
|
+
return await operation();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
87
|
+
// Check if error is transient and we should retry
|
|
88
|
+
if (attempt < opts.maxRetries && this.isTransient(lastError)) {
|
|
89
|
+
const delay = opts.delayMs * Math.pow(opts.backoffMultiplier, attempt);
|
|
90
|
+
this.logger.warn(`Operation failed, retrying (attempt ${attempt + 1}/${opts.maxRetries})`, {
|
|
91
|
+
error: lastError.message,
|
|
92
|
+
delay,
|
|
93
|
+
attempt: attempt + 1,
|
|
94
|
+
maxRetries: opts.maxRetries,
|
|
95
|
+
});
|
|
96
|
+
// Call retry callback if provided
|
|
97
|
+
if (opts.onRetry) {
|
|
98
|
+
opts.onRetry(attempt + 1, lastError);
|
|
99
|
+
}
|
|
100
|
+
// Wait before retrying
|
|
101
|
+
await this.delay(delay);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Non-transient error or max retries reached
|
|
105
|
+
if (attempt >= opts.maxRetries) {
|
|
106
|
+
this.logger.error(`Operation failed after ${opts.maxRetries} retries`, lastError);
|
|
107
|
+
}
|
|
108
|
+
throw lastError;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Should never reach here, but TypeScript needs this
|
|
113
|
+
throw lastError || new Error('Operation failed with unknown error');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if an error is transient (retryable)
|
|
117
|
+
*/
|
|
118
|
+
static isTransient(error) {
|
|
119
|
+
const message = error.message.toLowerCase();
|
|
120
|
+
// Network-related errors
|
|
121
|
+
const networkErrors = [
|
|
122
|
+
'econnrefused',
|
|
123
|
+
'econnreset',
|
|
124
|
+
'etimedout',
|
|
125
|
+
'enotfound',
|
|
126
|
+
'enetunreach',
|
|
127
|
+
'socket hang up',
|
|
128
|
+
'network error',
|
|
129
|
+
'fetch failed',
|
|
130
|
+
];
|
|
131
|
+
// API rate limiting
|
|
132
|
+
const rateLimitErrors = ['rate limit', 'too many requests', '429'];
|
|
133
|
+
// Temporary server errors
|
|
134
|
+
const serverErrors = ['503', 'service unavailable', 'gateway timeout', '504'];
|
|
135
|
+
// Git-specific transient errors
|
|
136
|
+
const gitErrors = ['lock', 'unable to access', 'could not resolve host'];
|
|
137
|
+
const allTransientPatterns = [
|
|
138
|
+
...networkErrors,
|
|
139
|
+
...rateLimitErrors,
|
|
140
|
+
...serverErrors,
|
|
141
|
+
...gitErrors,
|
|
142
|
+
];
|
|
143
|
+
return allTransientPatterns.some((pattern) => message.includes(pattern));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Format an error for display
|
|
147
|
+
*/
|
|
148
|
+
static formatError(error) {
|
|
149
|
+
if (error instanceof MCPError) {
|
|
150
|
+
const parts = [`[${error.code}] ${error.message}`];
|
|
151
|
+
if (error.details && Object.keys(error.details).length > 0) {
|
|
152
|
+
parts.push(`Details: ${JSON.stringify(error.details, null, 2)}`);
|
|
153
|
+
}
|
|
154
|
+
if (error.cause) {
|
|
155
|
+
parts.push(`Caused by: ${error.cause.message}`);
|
|
156
|
+
}
|
|
157
|
+
return parts.join('\n');
|
|
158
|
+
}
|
|
159
|
+
return error.message;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Create an MCPError from a generic error
|
|
163
|
+
*/
|
|
164
|
+
static toMCPError(error, code, details) {
|
|
165
|
+
if (error instanceof MCPError) {
|
|
166
|
+
return error;
|
|
167
|
+
}
|
|
168
|
+
if (error instanceof Error) {
|
|
169
|
+
return new MCPError(error.message, code, details, error);
|
|
170
|
+
}
|
|
171
|
+
return new MCPError(String(error), code, details);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Wrap an operation with error handling
|
|
175
|
+
*/
|
|
176
|
+
static async wrap(operation, errorCode, _errorMessage, details) {
|
|
177
|
+
try {
|
|
178
|
+
return await operation();
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
throw this.toMCPError(error, errorCode, {
|
|
182
|
+
...details,
|
|
183
|
+
originalMessage: error instanceof Error ? error.message : String(error),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Delay execution for a specified time
|
|
189
|
+
*/
|
|
190
|
+
static delay(ms) {
|
|
191
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create a configuration error
|
|
195
|
+
*/
|
|
196
|
+
static configurationError(message, details) {
|
|
197
|
+
return new MCPError(message, ErrorCategory.CONFIGURATION, details);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Create a validation error
|
|
201
|
+
*/
|
|
202
|
+
static validationError(message, details) {
|
|
203
|
+
return new MCPError(message, ErrorCategory.VALIDATION, details);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Create a git operation error
|
|
207
|
+
*/
|
|
208
|
+
static gitOperationError(message, details, cause) {
|
|
209
|
+
return new MCPError(message, ErrorCategory.GIT_OPERATION, details, cause);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Create an API call error
|
|
213
|
+
*/
|
|
214
|
+
static apiCallError(message, details, cause) {
|
|
215
|
+
return new MCPError(message, ErrorCategory.API_CALL, details, cause);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Create a not found error
|
|
219
|
+
*/
|
|
220
|
+
static notFoundError(message, details) {
|
|
221
|
+
return new MCPError(message, ErrorCategory.NOT_FOUND, details);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Create a permission error
|
|
225
|
+
*/
|
|
226
|
+
static permissionError(message, details) {
|
|
227
|
+
return new MCPError(message, ErrorCategory.PERMISSION, details);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/errors/error-handler.ts"],"names":[],"m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Q,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CACpB,OAAe,EACf,OAAiC;QAEjC,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab Auto-Reviewers Shared Library
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive library for intelligent GitLab merge request reviewer suggestions.
|
|
5
|
+
* Provides data sources, services, and utilities for analyzing git history, team
|
|
6
|
+
* membership, code ownership, and reviewer workload to suggest optimal reviewers.
|
|
7
|
+
*
|
|
8
|
+
* @module gitlab-auto-reviewers
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Core data source interface for accessing git and GitLab data
|
|
13
|
+
* @see {@link GitDataSource}
|
|
14
|
+
*/
|
|
15
|
+
export { GitDataSource } from './datasources/git-data-source.interface.js';
|
|
16
|
+
/**
|
|
17
|
+
* GitLab API-based data source implementation
|
|
18
|
+
* Uses GitLab REST API for all operations (stateless, no local repository required)
|
|
19
|
+
* @see {@link GitLabAPIDataSource}
|
|
20
|
+
*/
|
|
21
|
+
export { GitLabAPIDataSource } from './datasources/gitlab-api-data-source.js';
|
|
22
|
+
/**
|
|
23
|
+
* Local git repository data source implementation
|
|
24
|
+
* Uses local git commands for faster operations, falls back to API when needed
|
|
25
|
+
* @see {@link LocalGitDataSource}
|
|
26
|
+
*/
|
|
27
|
+
export { LocalGitDataSource } from './datasources/local-git-data-source.js';
|
|
28
|
+
/**
|
|
29
|
+
* Main service for suggesting and managing merge request reviewers
|
|
30
|
+
* Orchestrates multiple analysis strategies (contributors, team members, code owners)
|
|
31
|
+
* @see {@link ReviewerService}
|
|
32
|
+
*/
|
|
33
|
+
export { ReviewerService } from './services/reviewer-service.js';
|
|
34
|
+
/**
|
|
35
|
+
* Service for analyzing previous contributors to modified code
|
|
36
|
+
* Uses git blame to identify who has worked on the changed files
|
|
37
|
+
* @see {@link ContributorsService}
|
|
38
|
+
*/
|
|
39
|
+
export { ContributorsService } from './services/contributors.service.js';
|
|
40
|
+
/**
|
|
41
|
+
* Service for managing code ownership rules from CODEOWNERS file
|
|
42
|
+
* Matches changed files to code owner patterns and applies approval requirements
|
|
43
|
+
* @see {@link CodeOwnersService}
|
|
44
|
+
*/
|
|
45
|
+
export { CodeOwnersService } from './services/codeowners.service.js';
|
|
46
|
+
/**
|
|
47
|
+
* Service for managing team membership and FTE-aware load balancing
|
|
48
|
+
* Distributes review assignments fairly based on team member availability
|
|
49
|
+
* @see {@link TeamMembersService}
|
|
50
|
+
*/
|
|
51
|
+
export { TeamMembersService } from './services/team-members.service.js';
|
|
52
|
+
/**
|
|
53
|
+
* Service for managing reviewer blacklist (exclusions)
|
|
54
|
+
* Filters out reviewers who should not be suggested (e.g., MR author, inactive users)
|
|
55
|
+
* @see {@link BlacklistService}
|
|
56
|
+
*/
|
|
57
|
+
export { BlacklistService } from './services/blacklist.service.js';
|
|
58
|
+
/**
|
|
59
|
+
* Service for managing reviewer whitelist (eligible reviewers)
|
|
60
|
+
* Defines the pool of eligible reviewers with team membership and FTE information
|
|
61
|
+
* @see {@link WhitelistService}
|
|
62
|
+
*/
|
|
63
|
+
export { WhitelistService } from './services/whitelist.service.js';
|
|
64
|
+
/**
|
|
65
|
+
* Service for building formatted reviewer suggestion comments
|
|
66
|
+
* Generates markdown comments for posting to GitLab merge requests
|
|
67
|
+
* @see {@link CommentBuilderService}
|
|
68
|
+
*/
|
|
69
|
+
export { CommentBuilderService } from './services/comment-builder.service.js';
|
|
70
|
+
/**
|
|
71
|
+
* GitLab REST API client
|
|
72
|
+
* Handles HTTP communication with GitLab API including authentication and error handling
|
|
73
|
+
* @see {@link GitLabAPI}
|
|
74
|
+
*/
|
|
75
|
+
export { GitLabAPI } from './api/gitlab-api.js';
|
|
76
|
+
/**
|
|
77
|
+
* Configuration service for managing application settings
|
|
78
|
+
* Handles environment variables, defaults, and configuration validation
|
|
79
|
+
* @see {@link ConfigService}
|
|
80
|
+
*/
|
|
81
|
+
export { ConfigService } from './config/config.service.js';
|
|
82
|
+
/**
|
|
83
|
+
* Structured logging service with multiple log levels
|
|
84
|
+
* Provides contextual logging with child loggers and performance timing
|
|
85
|
+
* @see {@link Logger}
|
|
86
|
+
*/
|
|
87
|
+
export { Logger } from './logging/logger.service.js';
|
|
88
|
+
/**
|
|
89
|
+
* Log level enumeration
|
|
90
|
+
* @see {@link LogLevel}
|
|
91
|
+
*/
|
|
92
|
+
export { LogLevel } from './logging/logger.service.js';
|
|
93
|
+
/**
|
|
94
|
+
* In-memory caching service with TTL support
|
|
95
|
+
* Improves performance by caching API responses and git operations
|
|
96
|
+
* @see {@link CacheService}
|
|
97
|
+
*/
|
|
98
|
+
export { CacheService } from './cache/cache.service.js';
|
|
99
|
+
/**
|
|
100
|
+
* Error handling utilities and custom error types
|
|
101
|
+
* Provides consistent error handling across the library
|
|
102
|
+
* @see {@link ErrorHandler}
|
|
103
|
+
*/
|
|
104
|
+
export { ErrorHandler } from './errors/error-handler.js';
|
|
105
|
+
/**
|
|
106
|
+
* Custom error class for MCP-specific errors
|
|
107
|
+
* @see {@link MCPError}
|
|
108
|
+
*/
|
|
109
|
+
export { MCPError } from './errors/error-handler.js';
|
|
110
|
+
/**
|
|
111
|
+
* Error category enumeration
|
|
112
|
+
* @see {@link ErrorCategory}
|
|
113
|
+
*/
|
|
114
|
+
export { ErrorCategory } from './errors/error-handler.js';
|
|
115
|
+
/**
|
|
116
|
+
* GitLab API response types
|
|
117
|
+
*/
|
|
118
|
+
export type { GitLabUser, MergeRequest, DiffRefs, MergeRequestDiff, BlameLine, GitLabBranch, GitLabCommit, GitLabNote, } from './types/index.js';
|
|
119
|
+
/**
|
|
120
|
+
* Reviewer suggestion types
|
|
121
|
+
*/
|
|
122
|
+
export type { ReviewerSuggestion, ContributorWithChanges, CodeOwnerGroup, TeamMember, TeamMemberWithScore, LoadBalancedTeam, CodeOwnerWithScores, ReviewerAnalysisResult, } from './types/index.js';
|
|
123
|
+
/**
|
|
124
|
+
* Parameter types for service methods
|
|
125
|
+
*/
|
|
126
|
+
export type { PostCommentParams, InviteReviewersParams, } from './types/index.js';
|
|
127
|
+
/**
|
|
128
|
+
* Type guards for runtime type checking
|
|
129
|
+
*/
|
|
130
|
+
export { isMergeRequest, isGitLabUser, isBlameLine, isGitLabBranch, isGitLabNote, isMergeRequestDiff, } from './types/index.js';
|
|
131
|
+
/**
|
|
132
|
+
* MCP tool parameter and result types
|
|
133
|
+
*/
|
|
134
|
+
export type { AutoReviewerParams, AutoReviewerResult, ContributorAnalysisParams, WorkloadAnalysisParams, Contributor, } from './types.js';
|
|
135
|
+
/**
|
|
136
|
+
* Default export provides the main ReviewerService for convenience
|
|
137
|
+
*/
|
|
138
|
+
export { ReviewerService as default } from './services/reviewer-service.js';
|
|
139
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAE3E;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAM5E;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;GAIG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE;;;;GAIG;AACH,O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d,YAAY,EACZ,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,WAAW,GACZ,MAAM,YAAY,CAAC;AAMpB;;GAEG;AACH,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab Auto-Reviewers Shared Library
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive library for intelligent GitLab merge request reviewer suggestions.
|
|
5
|
+
* Provides data sources, services, and utilities for analyzing git history, team
|
|
6
|
+
* membership, code ownership, and reviewer workload to suggest optimal reviewers.
|
|
7
|
+
*
|
|
8
|
+
* @module gitlab-auto-reviewers
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* GitLab API-based data source implementation
|
|
13
|
+
* Uses GitLab REST API for all operations (stateless, no local repository required)
|
|
14
|
+
* @see {@link GitLabAPIDataSource}
|
|
15
|
+
*/
|
|
16
|
+
export { GitLabAPIDataSource } from './datasources/gitlab-api-data-source.js';
|
|
17
|
+
/**
|
|
18
|
+
* Local git repository data source implementation
|
|
19
|
+
* Uses local git commands for faster operations, falls back to API when needed
|
|
20
|
+
* @see {@link LocalGitDataSource}
|
|
21
|
+
*/
|
|
22
|
+
export { LocalGitDataSource } from './datasources/local-git-data-source.js';
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Services
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Main service for suggesting and managing merge request reviewers
|
|
28
|
+
* Orchestrates multiple analysis strategies (contributors, team members, code owners)
|
|
29
|
+
* @see {@link ReviewerService}
|
|
30
|
+
*/
|
|
31
|
+
export { ReviewerService } from './services/reviewer-service.js';
|
|
32
|
+
/**
|
|
33
|
+
* Service for analyzing previous contributors to modified code
|
|
34
|
+
* Uses git blame to identify who has worked on the changed files
|
|
35
|
+
* @see {@link ContributorsService}
|
|
36
|
+
*/
|
|
37
|
+
export { ContributorsService } from './services/contributors.service.js';
|
|
38
|
+
/**
|
|
39
|
+
* Service for managing code ownership rules from CODEOWNERS file
|
|
40
|
+
* Matches changed files to code owner patterns and applies approval requirements
|
|
41
|
+
* @see {@link CodeOwnersService}
|
|
42
|
+
*/
|
|
43
|
+
export { CodeOwnersService } from './services/codeowners.service.js';
|
|
44
|
+
/**
|
|
45
|
+
* Service for managing team membership and FTE-aware load balancing
|
|
46
|
+
* Distributes review assignments fairly based on team member availability
|
|
47
|
+
* @see {@link TeamMembersService}
|
|
48
|
+
*/
|
|
49
|
+
export { TeamMembersService } from './services/team-members.service.js';
|
|
50
|
+
/**
|
|
51
|
+
* Service for managing reviewer blacklist (exclusions)
|
|
52
|
+
* Filters out reviewers who should not be suggested (e.g., MR author, inactive users)
|
|
53
|
+
* @see {@link BlacklistService}
|
|
54
|
+
*/
|
|
55
|
+
export { BlacklistService } from './services/blacklist.service.js';
|
|
56
|
+
/**
|
|
57
|
+
* Service for managing reviewer whitelist (eligible reviewers)
|
|
58
|
+
* Defines the pool of eligible reviewers with team membership and FTE information
|
|
59
|
+
* @see {@link WhitelistService}
|
|
60
|
+
*/
|
|
61
|
+
export { WhitelistService } from './services/whitelist.service.js';
|
|
62
|
+
/**
|
|
63
|
+
* Service for building formatted reviewer suggestion comments
|
|
64
|
+
* Generates markdown comments for posting to GitLab merge requests
|
|
65
|
+
* @see {@link CommentBuilderService}
|
|
66
|
+
*/
|
|
67
|
+
export { CommentBuilderService } from './services/comment-builder.service.js';
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// API Client
|
|
70
|
+
// ============================================================================
|
|
71
|
+
/**
|
|
72
|
+
* GitLab REST API client
|
|
73
|
+
* Handles HTTP communication with GitLab API including authentication and error handling
|
|
74
|
+
* @see {@link GitLabAPI}
|
|
75
|
+
*/
|
|
76
|
+
export { GitLabAPI } from './api/gitlab-api.js';
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// Configuration
|
|
79
|
+
// ============================================================================
|
|
80
|
+
/**
|
|
81
|
+
* Configuration service for managing application settings
|
|
82
|
+
* Handles environment variables, defaults, and configuration validation
|
|
83
|
+
* @see {@link ConfigService}
|
|
84
|
+
*/
|
|
85
|
+
export { ConfigService } from './config/config.service.js';
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Logging
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Structured logging service with multiple log levels
|
|
91
|
+
* Provides contextual logging with child loggers and performance timing
|
|
92
|
+
* @see {@link Logger}
|
|
93
|
+
*/
|
|
94
|
+
export { Logger } from './logging/logger.service.js';
|
|
95
|
+
/**
|
|
96
|
+
* Log level enumeration
|
|
97
|
+
* @see {@link LogLevel}
|
|
98
|
+
*/
|
|
99
|
+
export { LogLevel } from './logging/logger.service.js';
|
|
100
|
+
// ============================================================================
|
|
101
|
+
// Caching
|
|
102
|
+
// ============================================================================
|
|
103
|
+
/**
|
|
104
|
+
* In-memory caching service with TTL support
|
|
105
|
+
* Improves performance by caching API responses and git operations
|
|
106
|
+
* @see {@link CacheService}
|
|
107
|
+
*/
|
|
108
|
+
export { CacheService } from './cache/cache.service.js';
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// Error Handling
|
|
111
|
+
// ============================================================================
|
|
112
|
+
/**
|
|
113
|
+
* Error handling utilities and custom error types
|
|
114
|
+
* Provides consistent error handling across the library
|
|
115
|
+
* @see {@link ErrorHandler}
|
|
116
|
+
*/
|
|
117
|
+
export { ErrorHandler } from './errors/error-handler.js';
|
|
118
|
+
/**
|
|
119
|
+
* Custom error class for MCP-specific errors
|
|
120
|
+
* @see {@link MCPError}
|
|
121
|
+
*/
|
|
122
|
+
export { MCPError } from './errors/error-handler.js';
|
|
123
|
+
/**
|
|
124
|
+
* Error category enumeration
|
|
125
|
+
* @see {@link ErrorCategory}
|
|
126
|
+
*/
|
|
127
|
+
export { ErrorCategory } from './errors/error-handler.js';
|
|
128
|
+
/**
|
|
129
|
+
* Type guards for runtime type checking
|
|
130
|
+
*/
|
|
131
|
+
export { isMergeRequest, isGitLabUser, isBlameLine, isGitLabBranch, isGitLabNote, isMergeRequestDiff, } from './types/index.js';
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// Default Export
|
|
134
|
+
// ============================================================================
|
|
135
|
+
/**
|
|
136
|
+
* Default export provides the main ReviewerService for convenience
|
|
137
|
+
*/
|
|
138
|
+
export { ReviewerService as default } from './services/reviewer-service.js';
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;GAIG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;;;GAIG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AA0C1D;;GAEG;AACH,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,YAAY,EACZ,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAa1B,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;GAEG;AACH,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Usage Examples
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the Logger service.
|
|
5
|
+
* It is not part of the production code.
|
|
6
|
+
*/
|
|
7
|
+
declare function basicLoggingExample(): void;
|
|
8
|
+
declare function contextLoggingExample(): void;
|
|
9
|
+
declare function performanceTimingExample(): Promise<void>;
|
|
10
|
+
declare function childLoggerExample(): void;
|
|
11
|
+
declare function errorLoggingExample(): void;
|
|
12
|
+
declare function logLevelFilteringExample(): void;
|
|
13
|
+
declare function parseLogLevelExample(): void;
|
|
14
|
+
export { basicLoggingExample, contextLoggingExample, performanceTimingExample, childLoggerExample, errorLoggingExample, logLevelFilteringExample, parseLogLevelExample, };
|
|
15
|
+
//# sourceMappingURL=example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/logging/example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,iBAAS,mBAAmB,IAAI,IAAI,CAOnC;AAGD,iBAAS,qBAAqB,IAAI,IAAI,CAerC;AAGD,iBAAe,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CASvD;AAGD,iBAAS,kBAAkB,IAAI,IAAI,CAQlC;AAGD,iBAAS,mBAAmB,IAAI,IAAI,CAYnC;AAGD,iBAAS,wBAAwB,IAAI,IAAI,CAQxC;AAGD,iBAAS,oBAAoB,IAAI,IAAI,CAMpC;AAED,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,GACrB,CAAC"}
|