@@ -107,7 +107,7 @@ export class LimitedSizeDocument {
107107 }
108108}
109109
110- type MakeClientMetadataOptions = Pick < MongoOptions , 'appName' | 'additionalDriverInfo' > ;
110+ type MakeClientMetadataOptions = Pick < MongoOptions , 'appName' > ;
111111/**
112112 * From the specs:
113113 * Implementors SHOULD cumulatively update fields in the following order until the document is under the size limit:
@@ -116,15 +116,17 @@ type MakeClientMetadataOptions = Pick<MongoOptions, 'appName' | 'additionalDrive
116116 * 3. Omit the `env` document entirely.
117117 * 4. Truncate `platform`. -- special we do not truncate this field
118118 */
119- export function makeClientMetadata ( options : MakeClientMetadataOptions ) : ClientMetadata {
119+ export function makeClientMetadata (
120+ driverInfos : DriverInfo [ ] ,
121+ { appName = '' } : MakeClientMetadataOptions
122+ ) : ClientMetadata {
120123 const metadataDocument = new LimitedSizeDocument ( 512 ) ;
121124
122- const { appName = '' } = options ;
123125 // Add app name first, it must be sent
124126 if ( appName . length > 0 ) {
125127 const name =
126128 Buffer . byteLength ( appName , 'utf8' ) <= 128
127- ? options . appName
129+ ? appName
128130 : Buffer . from ( appName , 'utf8' ) . subarray ( 0 , 128 ) . toString ( 'utf8' ) ;
129131 metadataDocument . ifItFitsItSits ( 'application' , { name } ) ;
130132 }
@@ -135,7 +137,7 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
135137 } ;
136138
137139 // This is where we handle additional driver info added after client construction.
138- for ( const { name : n = '' , version : v = '' } of options . additionalDriverInfo ) {
140+ for ( const { name : n = '' , version : v = '' } of driverInfos ) {
139141 if ( n . length > 0 ) {
140142 driverInfo . name = `${ driverInfo . name } |${ n } ` ;
141143 }
@@ -152,7 +154,7 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
152154
153155 let runtimeInfo = getRuntimeInfo ( ) ;
154156 // This is where we handle additional driver info added after client construction.
155- for ( const { platform = '' } of options . additionalDriverInfo ) {
157+ for ( const { platform = '' } of driverInfos ) {
156158 if ( platform . length > 0 ) {
157159 runtimeInfo = `${ runtimeInfo } |${ platform } ` ;
158160 }
0 commit comments