@mongosh/service-provider-core 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makePrintableBson = exports.bsonStringifiers = void 0;
4
4
  const bson_export_1 = require("./bson-export");
5
- const util_1 = require("util");
6
5
  const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
7
6
  function removeNewFromInspectResult(str) {
8
7
  return String(str).replace(/^(\s*)(new )/, '$1');
@@ -13,15 +12,11 @@ function makeClasslessInspect(className) {
13
12
  return removeNewFromInspectResult(originalInspect.apply(this, args));
14
13
  };
15
14
  }
15
+ const binaryInspect = makeClasslessInspect('Binary');
16
16
  exports.bsonStringifiers = {
17
17
  ObjectId: makeClasslessInspect('ObjectId'),
18
18
  ObjectID: makeClasslessInspect('ObjectId'),
19
- DBRef: function (depth, options) {
20
- return (`DBRef("${this.collection}", ` +
21
- (0, util_1.inspect)(this.oid, options) +
22
- (this.db ? `, ${(0, util_1.inspect)(this.db, options)}` : '') +
23
- ')');
24
- },
19
+ DBRef: makeClasslessInspect('DBRef'),
25
20
  MaxKey: makeClasslessInspect('MaxKey'),
26
21
  MinKey: makeClasslessInspect('MinKey'),
27
22
  Timestamp: makeClasslessInspect('Timestamp'),
@@ -32,21 +27,21 @@ exports.bsonStringifiers = {
32
27
  Long: makeClasslessInspect('Long'),
33
28
  Double: makeClasslessInspect('Double'),
34
29
  BSONRegExp: makeClasslessInspect('BSONRegExp'),
35
- Binary: function () {
30
+ Binary: function (...args) {
36
31
  const hexString = this.toString('hex');
37
32
  switch (this.sub_type) {
38
33
  case bson_export_1.bson.Binary.SUBTYPE_MD5:
39
- return `MD5("${hexString}")`;
34
+ return `MD5('${hexString}')`;
40
35
  case bson_export_1.bson.Binary.SUBTYPE_UUID:
41
36
  if (hexString.length === 32) {
42
37
  const asUUID = /^(.{8})(.{4})(.{4})(.{4})(.{12})$/
43
38
  .exec(hexString)
44
39
  .slice(1, 6)
45
40
  .join('-');
46
- return `UUID("${asUUID}")`;
41
+ return `UUID('${asUUID}')`;
47
42
  }
48
43
  default:
49
- return `Binary.createFromBase64("${this.toString('base64')}", ${this.sub_type})`;
44
+ return binaryInspect.apply(this, args);
50
45
  }
51
46
  },
52
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"printable-bson.js","sourceRoot":"","sources":["../src/printable-bson.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAC7C,+BAA+B;AAC/B,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAO/D,SAAS,0BAA0B,CAAC,GAAW;IAC7C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC;AAKD,SAAS,oBAAoB,CAAyB,SAAY;IAChE,MAAM,eAAe,GAAG,kBAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;IAC1D,OAAO,UAEL,GAAG,IAAS;QAEZ,OAAO,0BAA0B,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,gBAAgB,GAGzB;IACF,QAAQ,EAAE,oBAAoB,CAAC,UAAU,CAAC;IAC1C,QAAQ,EAAE,oBAAoB,CAAC,UAAU,CAAC;IAC1C,KAAK,EAAE,UAEL,KAAU,EACV,OAAY;QAEZ,OAAO,CACL,UAAU,IAAI,CAAC,UAAU,KAAK;YAC9B,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;YAC1B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,GAAG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D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAwB,CAAC,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE;YAC3C,GAAW,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;SAC3C;KACF;AACH,CAAC;AAdD,8CAcC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/service-provider-core",
3
- "version": "2.0.2",
3
+ "version": "2.1.1",
4
4
  "description": "MongoDB Shell Core Service Provider Package",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@aws-sdk/credential-providers": "^3.347.1",
47
- "@mongosh/errors": "2.0.2",
48
- "bson": "^6.1.0",
49
- "mongodb": "^6.0.0",
50
- "mongodb-build-info": "^1.6.2",
47
+ "@mongosh/errors": "2.1.1",
48
+ "bson": "^6.2.0",
49
+ "mongodb": "^6.3.0",
50
+ "mongodb-build-info": "^1.7.1",
51
51
  "mongodb-client-encryption": "^6.0.0"
52
52
  },
53
53
  "optionalDependencies": {
@@ -61,5 +61,5 @@
61
61
  "eslint": "^7.25.0",
62
62
  "prettier": "^2.8.8"
63
63
  },
64
- "gitHead": "5737e60cdbcd551f6a355b38fc9b5b6cc19ac5a4"
64
+ "gitHead": "c7e70b65988d21c9020abf2bbd253a94b1d3316c"
65
65
  }
@@ -10,7 +10,7 @@ describe('BSON printers', function () {
10
10
 
11
11
  it('formats ObjectIds correctly', function () {
12
12
  expect(inspect(new bson.ObjectId('5fa5694f88211043b23c7f11'))).to.equal(
13
- 'ObjectId("5fa5694f88211043b23c7f11")'
13
+ "ObjectId('5fa5694f88211043b23c7f11')"
14
14
  );
15
15
  });
16
16
 
@@ -19,12 +19,12 @@ describe('BSON printers', function () {
19
19
  inspect(
20
20
  new bson.DBRef('a', new bson.ObjectId('5f16b8bebe434dc98cdfc9cb'), 'db')
21
21
  )
22
- ).to.equal('DBRef("a", ObjectId("5f16b8bebe434dc98cdfc9cb"), \'db\')');
22
+ ).to.equal("DBRef('a', ObjectId('5f16b8bebe434dc98cdfc9cb'), 'db')");
23
23
  expect(inspect(new bson.DBRef('a', 'foo' as any, 'db'))).to.equal(
24
- "DBRef(\"a\", 'foo', 'db')"
24
+ "DBRef('a', 'foo', 'db')"
25
25
  );
26
26
  expect(inspect(new bson.DBRef('a', { x: 1 } as any, 'db'))).to.equal(
27
- 'DBRef("a", { x: 1 }, \'db\')'
27
+ "DBRef('a', { x: 1 }, 'db')"
28
28
  );
29
29
  });
30
30
 
@@ -38,18 +38,18 @@ describe('BSON printers', function () {
38
38
  });
39
39
 
40
40
  it('formats NumberLong correctly', function () {
41
- expect(inspect(bson.Long.fromString('64'))).to.equal('Long("64")');
41
+ expect(inspect(bson.Long.fromString('64'))).to.equal("Long('64')");
42
42
  });
43
43
 
44
44
  it('formats unsigned NumberLong correctly', function () {
45
45
  expect(inspect(bson.Long.fromString('64', true))).to.equal(
46
- 'Long("64", true)'
46
+ "Long('64', true)"
47
47
  );
48
48
  });
49
49
 
50
50
  it('formats NumberDecimal correctly', function () {
51
51
  expect(inspect(bson.Decimal128.fromString('1'))).to.equal(
52
- 'Decimal128("1")'
52
+ "Decimal128('1')"
53
53
  );
54
54
  });
55
55
 
@@ -60,16 +60,16 @@ describe('BSON printers', function () {
60
60
  });
61
61
 
62
62
  it('formats Symbol correctly', function () {
63
- expect(inspect(new bson.BSONSymbol('abc'))).to.equal('BSONSymbol("abc")');
63
+ expect(inspect(new bson.BSONSymbol('abc'))).to.equal("BSONSymbol('abc')");
64
64
  });
65
65
 
66
66
  it('formats Code correctly', function () {
67
- expect(inspect(new bson.Code('abc'))).to.equal('Code("abc")');
67
+ expect(inspect(new bson.Code('abc'))).to.equal("Code('abc')");
68
68
  });
69
69
 
70
70
  it('formats BSONRegExp correctly', function () {
71
71
  expect(inspect(new bson.BSONRegExp('(?-i)AA_', 'im'))).to.equal(
72
- 'BSONRegExp("(?-i)AA_", "im")'
72
+ "BSONRegExp('(?-i)AA_', 'im')"
73
73
  );
74
74
  });
75
75
 
@@ -81,7 +81,7 @@ describe('BSON printers', function () {
81
81
  4
82
82
  )
83
83
  )
84
- ).to.equal('UUID("01234567-89ab-cdef-0123-456789abcdef")');
84
+ ).to.equal("UUID('01234567-89ab-cdef-0123-456789abcdef')");
85
85
  });
86
86
 
87
87
  it('formats MD5s correctly', function () {
@@ -92,12 +92,12 @@ describe('BSON printers', function () {
92
92
  5
93
93
  )
94
94
  )
95
- ).to.equal('MD5("0123456789abcdef0123456789abcdef")');
95
+ ).to.equal("MD5('0123456789abcdef0123456789abcdef')");
96
96
  });
97
97
 
98
98
  it('formats any other value with the new format using createfromBase64', function () {
99
99
  expect(
100
100
  inspect(bson.Binary.createFromBase64('SGVsbG8sIFdvcmxkIQo='))
101
- ).to.equal('Binary.createFromBase64("SGVsbG8sIFdvcmxkIQo=", 0)');
101
+ ).to.equal("Binary.createFromBase64('SGVsbG8sIFdvcmxkIQo=', 0)");
102
102
  });
103
103
  });
@@ -1,5 +1,4 @@
1
1
  import { bson as BSON } from './bson-export';
2
- import { inspect } from 'util';
3
2
  const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
4
3
  type BSONClassKey = (typeof BSON)[Exclude<
5
4
  keyof typeof BSON,
@@ -24,24 +23,14 @@ function makeClasslessInspect<K extends BSONClassKey>(className: K) {
24
23
  };
25
24
  }
26
25
 
26
+ const binaryInspect = makeClasslessInspect('Binary');
27
27
  export const bsonStringifiers: Record<
28
28
  BSONClassKey | 'ObjectID',
29
29
  (this: any, depth: any, options: any) => string
30
30
  > = {
31
31
  ObjectId: makeClasslessInspect('ObjectId'),
32
32
  ObjectID: makeClasslessInspect('ObjectId'),
33
- DBRef: function (
34
- this: typeof BSON.DBRef.prototype,
35
- depth: any,
36
- options: any
37
- ): string {
38
- return (
39
- `DBRef("${this.collection}", ` +
40
- inspect(this.oid, options) + // The driver's inspect() does not account for non-ObjectID oid values
41
- (this.db ? `, ${inspect(this.db, options)}` : '') +
42
- ')'
43
- );
44
- },
33
+ DBRef: makeClasslessInspect('DBRef'),
45
34
  MaxKey: makeClasslessInspect('MaxKey'),
46
35
  MinKey: makeClasslessInspect('MinKey'),
47
36
  Timestamp: makeClasslessInspect('Timestamp'),
@@ -52,11 +41,14 @@ export const bsonStringifiers: Record<
52
41
  Long: makeClasslessInspect('Long'),
53
42
  Double: makeClasslessInspect('Double'),
54
43
  BSONRegExp: makeClasslessInspect('BSONRegExp'),
55
- Binary: function (this: typeof BSON.Binary.prototype): string {
44
+ Binary: function (
45
+ this: typeof BSON.Binary.prototype,
46
+ ...args: any[]
47
+ ): string {
56
48
  const hexString = this.toString('hex');
57
49
  switch (this.sub_type) {
58
50
  case BSON.Binary.SUBTYPE_MD5:
59
- return `MD5("${hexString}")`;
51
+ return `MD5('${hexString}')`;
60
52
  case BSON.Binary.SUBTYPE_UUID:
61
53
  if (hexString.length === 32) {
62
54
  // Format '0123456789abcdef0123456789abcdef' into
@@ -65,14 +57,12 @@ export const bsonStringifiers: Record<
65
57
  .exec(hexString)!
66
58
  .slice(1, 6)
67
59
  .join('-');
68
- return `UUID("${asUUID}")`;
60
+ return `UUID('${asUUID}')`;
69
61
  }
70
62
  // In case somebody did something weird and used an UUID with a
71
63
  // non-standard length, fall through.
72
64
  default:
73
- return `Binary.createFromBase64("${this.toString('base64')}", ${
74
- this.sub_type
75
- })`;
65
+ return binaryInspect.apply(this, args);
76
66
  }
77
67
  },
78
68
  };