Skip to content

Commit d85d1a2

Browse files
authored
chore(devtools-connect): align MongoLogWriter interfaces between packages (#570)
Because the OIDC plugin's `MongoLogWriter` class has an optional `debug()` method and the devtools-connect one didn't, we accidentally missed adding this debug method in mongodb-js/mongosh@b340d790ed9c159. Aligning these interfaces should prevent this from happening again in the future.
1 parent 2bbe0a7 commit d85d1a2

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

packages/devtools-connect/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export type {
77
AgentWithInitialize,
88
ConnectMongoClientResult,
99
} from './connect';
10-
export { hookLogger } from './log-hook';
10+
export { hookLogger, MongoLogWriter } from './log-hook';
1111
export { oidcServerRequestHandler } from './oidc/handler';

packages/devtools-connect/src/log-hook.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ import type {
1111
ConnectRetryAfterTLSErrorEvent,
1212
} from './types';
1313

14-
import { hookLoggerToMongoLogWriter as oidcHookLogger } from '@mongodb-js/oidc-plugin';
15-
import { hookLogger as proxyHookLogger } from '@mongodb-js/devtools-proxy-support';
14+
import {
15+
hookLoggerToMongoLogWriter as oidcHookLogger,
16+
MongoLogWriter as OIDCMongoLogWriter,
17+
} from '@mongodb-js/oidc-plugin';
18+
import {
19+
hookLogger as proxyHookLogger,
20+
MongoLogWriter as ProxyMongoLogWriter,
21+
} from '@mongodb-js/devtools-proxy-support';
1622

17-
interface MongoLogWriter {
18-
info(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
19-
warn(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
20-
error(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
21-
mongoLogId(this: void, id: number): unknown;
22-
}
23+
export interface MongoLogWriter
24+
extends OIDCMongoLogWriter,
25+
ProxyMongoLogWriter {}
2326

2427
export function hookLogger(
2528
emitter: ConnectLogEmitter,

packages/devtools-proxy-support/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ export {
1313
RequestInfo,
1414
RequestInit,
1515
} from './fetch';
16-
export { ProxyEventMap, ProxyLogEmitter, hookLogger } from './logging';
16+
export {
17+
ProxyEventMap,
18+
ProxyLogEmitter,
19+
hookLogger,
20+
MongoLogWriter,
21+
} from './logging';
1722
export { systemCA, resetSystemCACache } from './system-ca';

packages/devtools-proxy-support/src/logging.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ export interface ProxyLogEmitter {
7777
): unknown;
7878
}
7979

80-
interface MongoLogWriter {
81-
info(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
82-
warn(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
83-
error(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
80+
export interface MongoLogWriter {
81+
info(c: string, id: unknown, ctx: string, msg: string, attr?: unknown): void;
82+
warn(c: string, id: unknown, ctx: string, msg: string, attr?: unknown): void;
83+
error(c: string, id: unknown, ctx: string, msg: string, attr?: unknown): void;
8484
mongoLogId(this: void, id: number): unknown;
8585
}
8686

0 commit comments

Comments
 (0)