1
- // import type * as _BSON from 'bson';
2
- // let BSON: typeof _BSON = require('bson');
3
- // try {
4
- // BSON = require('bson-ext');
5
- // } catch {} // eslint-disable-line
1
+ import type {
2
+ serialize as serializeFn ,
3
+ deserialize as deserializeFn ,
4
+ calculateObjectSize as calculateObjectSizeFn
5
+ } from 'bson' ;
6
+
7
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
8
+ let BSON = require ( 'bson' ) ;
9
+ try {
10
+ BSON = require ( 'bson-ext' ) ;
11
+ } catch { } // eslint-disable-line
6
12
7
- // export = BSON;
13
+ /** @internal */
14
+ export const deserialize = BSON . deserialize as typeof deserializeFn ;
15
+ /** @internal */
16
+ export const serialize = BSON . serialize as typeof serializeFn ;
17
+ /** @internal */
18
+ export const calculateObjectSize = BSON . calculateObjectSize as typeof calculateObjectSizeFn ;
8
19
9
20
export {
10
21
Long ,
@@ -21,38 +32,27 @@ export {
21
32
BSONRegExp ,
22
33
BSONSymbol ,
23
34
Map ,
24
- deserialize ,
25
- serialize ,
26
- calculateObjectSize
35
+ Document
27
36
} from 'bson' ;
28
37
29
- /** @public */
30
- export interface Document {
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- [ key : string ] : any ;
33
- }
38
+ import type { DeserializeOptions , SerializeOptions } from 'bson' ;
34
39
35
- import type { SerializeOptions } from 'bson' ;
36
-
37
- // TODO: Remove me when types from BSON are updated
38
40
/**
39
41
* BSON Serialization options.
40
42
* @public
41
43
*/
42
- export interface BSONSerializeOptions extends Omit < SerializeOptions , 'index' > {
43
- /** Return document results as raw BSON buffers */
44
- fieldsAsRaw ?: { [ key : string ] : boolean } ;
45
- /** Promotes BSON values to native types where possible, set to false to only receive wrapper types */
46
- promoteValues ?: boolean ;
47
- /** Promotes Binary BSON values to native Node Buffers */
48
- promoteBuffers ?: boolean ;
49
- /** Promotes long values to number if they fit inside the 53 bits resolution */
50
- promoteLongs ?: boolean ;
51
- /** Serialize functions on any object */
52
- serializeFunctions ?: boolean ;
53
- /** Specify if the BSON serializer should ignore undefined fields */
54
- ignoreUndefined ?: boolean ;
55
-
44
+ export interface BSONSerializeOptions
45
+ extends Omit < SerializeOptions , 'index' > ,
46
+ Omit <
47
+ DeserializeOptions ,
48
+ | 'evalFunctions'
49
+ | 'cacheFunctions'
50
+ | 'cacheFunctionsCrc32'
51
+ | 'bsonRegExp'
52
+ | 'allowObjectSmallerThanBufferSize'
53
+ | 'index'
54
+ > {
55
+ /** Return BSON filled buffers from operations */
56
56
raw ?: boolean ;
57
57
}
58
58
0 commit comments