1- import type { MongoServerEvents , MongoServerOptions } from './mongoserver' ;
1+ import type {
2+ MongoServerEvents ,
3+ MongoServerOptions ,
4+ SerializedServerProperties ,
5+ } from './mongoserver' ;
26import { MongoServer } from './mongoserver' ;
37import { ConnectionString } from 'mongodb-connection-string-url' ;
48import type { DownloadOptions } from '@mongodb-js/mongodb-downloader' ;
@@ -162,6 +166,16 @@ export type MongoClusterEvents = {
162166 removeListener : [ keyof MongoClusterEvents ] ;
163167} ;
164168
169+ export interface SerializedClusterProperties {
170+ topology : MongoClusterOptions [ 'topology' ] ;
171+ replSetName ?: string ;
172+ servers : SerializedServerProperties [ ] ;
173+ shards : SerializedClusterProperties [ ] ;
174+ oidcMockProviderProcess ?: ReturnType < OIDCMockProviderProcess [ 'serialize' ] > ;
175+ defaultConnectionOptions : Partial < MongoClientOptions > ;
176+ users : MongoDBUserDoc [ ] ;
177+ }
178+
165179function removePortArg ( [ ...args ] : string [ ] ) : string [ ] {
166180 let portArgIndex = - 1 ;
167181 if ( ( portArgIndex = args . indexOf ( '--port' ) ) !== - 1 ) {
@@ -309,7 +323,7 @@ export class MongoCluster extends EventEmitter<MongoClusterEvents> {
309323 } ) ;
310324 }
311325
312- serialize ( ) : unknown /* JSON-serializable */ {
326+ serialize ( ) : SerializedClusterProperties {
313327 return {
314328 topology : this . topology ,
315329 replSetName : this . replSetName ,
@@ -328,7 +342,9 @@ export class MongoCluster extends EventEmitter<MongoClusterEvents> {
328342 return true ;
329343 }
330344
331- static async deserialize ( serialized : any ) : Promise < MongoCluster > {
345+ static async deserialize (
346+ serialized : SerializedClusterProperties ,
347+ ) : Promise < MongoCluster > {
332348 const cluster = new MongoCluster ( ) ;
333349 cluster . topology = serialized . topology ;
334350 cluster . replSetName = serialized . replSetName ;
0 commit comments