@@ -107,7 +107,7 @@ export class LimitedSizeDocument {
107
107
}
108
108
}
109
109
110
- type MakeClientMetadataOptions = Pick < MongoOptions , 'appName' | 'additionalDriverInfo' > ;
110
+ type MakeClientMetadataOptions = Pick < MongoOptions , 'appName' > ;
111
111
/**
112
112
* From the specs:
113
113
* 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
116
116
* 3. Omit the `env` document entirely.
117
117
* 4. Truncate `platform`. -- special we do not truncate this field
118
118
*/
119
- export function makeClientMetadata ( options : MakeClientMetadataOptions ) : ClientMetadata {
119
+ export function makeClientMetadata (
120
+ driverInfos : DriverInfo [ ] ,
121
+ { appName = '' } : MakeClientMetadataOptions
122
+ ) : ClientMetadata {
120
123
const metadataDocument = new LimitedSizeDocument ( 512 ) ;
121
124
122
- const { appName = '' } = options ;
123
125
// Add app name first, it must be sent
124
126
if ( appName . length > 0 ) {
125
127
const name =
126
128
Buffer . byteLength ( appName , 'utf8' ) <= 128
127
- ? options . appName
129
+ ? appName
128
130
: Buffer . from ( appName , 'utf8' ) . subarray ( 0 , 128 ) . toString ( 'utf8' ) ;
129
131
metadataDocument . ifItFitsItSits ( 'application' , { name } ) ;
130
132
}
@@ -135,7 +137,7 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
135
137
} ;
136
138
137
139
// 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 ) {
139
141
if ( n . length > 0 ) {
140
142
driverInfo . name = `${ driverInfo . name } |${ n } ` ;
141
143
}
@@ -152,7 +154,7 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
152
154
153
155
let runtimeInfo = getRuntimeInfo ( ) ;
154
156
// 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 ) {
156
158
if ( platform . length > 0 ) {
157
159
runtimeInfo = `${ runtimeInfo } |${ platform } ` ;
158
160
}
0 commit comments