@qp-mongosh/service-provider-core 0.0.0-dev.5 → 0.0.0-dev.7

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.
Files changed (86) hide show
  1. package/.eslintignore +2 -2
  2. package/.eslintrc.js +1 -1
  3. package/AUTHORS +11 -11
  4. package/LICENSE +200 -200
  5. package/lib/admin.d.ts +28 -28
  6. package/lib/admin.js +2 -2
  7. package/lib/all-fle-types.d.ts +2 -2
  8. package/lib/all-fle-types.js +2 -2
  9. package/lib/all-transport-types.d.ts +1 -1
  10. package/lib/all-transport-types.js +2 -2
  11. package/lib/bulk-write-result.d.ts +16 -0
  12. package/lib/bulk-write-result.js +3 -0
  13. package/lib/bulk-write-result.js.map +1 -0
  14. package/lib/cli-options.d.ts +43 -43
  15. package/lib/cli-options.js +2 -2
  16. package/lib/closable.d.ts +4 -4
  17. package/lib/closable.js +2 -2
  18. package/lib/command-options.d.ts +4 -0
  19. package/lib/command-options.js +3 -0
  20. package/lib/command-options.js.map +1 -0
  21. package/lib/connect-info.d.ts +19 -19
  22. package/lib/connect-info.js +34 -34
  23. package/lib/cursor.d.ts +34 -0
  24. package/lib/cursor.js +3 -0
  25. package/lib/cursor.js.map +1 -0
  26. package/lib/database-options.d.ts +8 -0
  27. package/lib/database-options.js +3 -0
  28. package/lib/database-options.js.map +1 -0
  29. package/lib/document.d.ts +3 -0
  30. package/lib/document.js +3 -0
  31. package/lib/document.js.map +1 -0
  32. package/lib/fast-failure-connect.d.ts +1 -0
  33. package/lib/fast-failure-connect.js +15 -0
  34. package/lib/fast-failure-connect.js.map +1 -0
  35. package/lib/index.d.ts +31 -31
  36. package/lib/index.js +55 -55
  37. package/lib/platform.d.ts +6 -6
  38. package/lib/platform.js +10 -10
  39. package/lib/printable-bson.d.ts +3 -3
  40. package/lib/printable-bson.js +81 -81
  41. package/lib/read-concern.d.ts +3 -0
  42. package/lib/read-concern.js +3 -0
  43. package/lib/read-concern.js.map +1 -0
  44. package/lib/read-preference.d.ts +4 -0
  45. package/lib/read-preference.js +3 -0
  46. package/lib/read-preference.js.map +1 -0
  47. package/lib/readable.d.ts +18 -18
  48. package/lib/readable.js +2 -2
  49. package/lib/result.d.ts +2 -0
  50. package/lib/result.js +3 -0
  51. package/lib/result.js.map +1 -0
  52. package/lib/service-provider.d.ts +11 -11
  53. package/lib/service-provider.js +18 -18
  54. package/lib/shell-auth-options.d.ts +7 -7
  55. package/lib/shell-auth-options.js +2 -2
  56. package/lib/textencoder-polyfill.d.ts +2 -2
  57. package/lib/textencoder-polyfill.js +21 -21
  58. package/lib/uri-generator.d.ts +8 -8
  59. package/lib/uri-generator.js +175 -175
  60. package/lib/writable.d.ts +22 -22
  61. package/lib/writable.js +2 -2
  62. package/lib/write-concern.d.ts +5 -0
  63. package/lib/write-concern.js +3 -0
  64. package/lib/write-concern.js.map +1 -0
  65. package/package.json +54 -54
  66. package/src/admin.ts +119 -119
  67. package/src/all-fle-types.ts +17 -17
  68. package/src/all-transport-types.ts +80 -80
  69. package/src/cli-options.ts +49 -49
  70. package/src/closable.ts +14 -14
  71. package/src/connect-info.spec.ts +192 -192
  72. package/src/connect-info.ts +57 -57
  73. package/src/index.ts +62 -62
  74. package/src/platform.ts +6 -6
  75. package/src/printable-bson.spec.ts +75 -75
  76. package/src/printable-bson.ts +103 -103
  77. package/src/readable.ts +242 -242
  78. package/src/service-provider.ts +23 -23
  79. package/src/shell-auth-options.ts +7 -7
  80. package/src/textencoder-polyfill.spec.ts +11 -11
  81. package/src/textencoder-polyfill.ts +30 -30
  82. package/src/uri-generator.spec.ts +481 -481
  83. package/src/uri-generator.ts +265 -265
  84. package/src/writable.ts +367 -367
  85. package/tsconfig.json +12 -12
  86. package/tsconfig.lint.json +8 -8
@@ -1,75 +1,75 @@
1
- import { expect } from 'chai';
2
- import { bson } from './index';
3
- import { inspect } from 'util';
4
- import makePrintableBson from './printable-bson';
5
-
6
- describe('BSON printers', function() {
7
- before('make BSON objects printable', function() {
8
- makePrintableBson(bson);
9
- });
10
-
11
- it('formats ObjectIds correctly', function() {
12
- expect(inspect(new bson.ObjectId('5fa5694f88211043b23c7f11')))
13
- .to.equal('ObjectId("5fa5694f88211043b23c7f11")');
14
- });
15
-
16
- it('formats DBRefs correctly', function() {
17
- expect(inspect(new bson.DBRef('a', new bson.ObjectId('5f16b8bebe434dc98cdfc9cb'), 'db')))
18
- .to.equal('DBRef("a", ObjectId("5f16b8bebe434dc98cdfc9cb"), "db")');
19
- expect(inspect(new bson.DBRef('a', 'foo' as any, 'db')))
20
- .to.equal('DBRef("a", \'foo\', "db")');
21
- expect(inspect(new bson.DBRef('a', { x: 1 } as any, 'db')))
22
- .to.equal('DBRef("a", { x: 1 }, "db")');
23
- });
24
-
25
- it('formats MinKey and MaxKey correctly', function() {
26
- expect(inspect(new bson.MinKey())).to.equal('MinKey()');
27
- expect(inspect(new bson.MaxKey())).to.equal('MaxKey()');
28
- });
29
-
30
- it('formats NumberInt correctly', function() {
31
- expect(inspect(new bson.Int32(32))).to.equal('Int32(32)');
32
- });
33
-
34
- it('formats NumberLong correctly', function() {
35
- expect(inspect(bson.Long.fromString('64'))).to.equal('Long("64")');
36
- });
37
-
38
- it('formats unsigned NumberLong correctly', function() {
39
- expect(inspect(bson.Long.fromString('64', true))).to.equal('Long("64", true)');
40
- });
41
-
42
- it('formats NumberDecimal correctly', function() {
43
- expect(inspect(bson.Decimal128.fromString('1'))).to.equal('Decimal128("1")');
44
- });
45
-
46
- it('formats Timestamp correctly', function() {
47
- expect(inspect(new bson.Timestamp(new bson.Long(100, 1)))).to.equal('Timestamp({ t: 1, i: 100 })');
48
- });
49
-
50
- it('formats Symbol correctly', function() {
51
- expect(inspect(new bson.BSONSymbol('abc'))).to.equal('BSONSymbol("abc")');
52
- });
53
-
54
- it('formats Code correctly', function() {
55
- expect(inspect(new bson.Code('abc'))).to.equal('Code("abc")');
56
- });
57
-
58
- it('formats BinData correctly', function() {
59
- expect(inspect(new bson.Binary('abc'))).to.equal('Binary(Buffer.from("616263", "hex"), 0)');
60
- });
61
-
62
- it('formats BSONRegExp correctly', function() {
63
- expect(inspect(new bson.BSONRegExp('(?-i)AA_', 'im'))).to.equal('BSONRegExp("(?-i)AA_", "im")');
64
- });
65
-
66
- it('formats UUIDs correctly', function() {
67
- expect(inspect(new bson.Binary(Buffer.from('0123456789abcdef0123456789abcdef', 'hex'), 4)))
68
- .to.equal('UUID("01234567-89ab-cdef-0123-456789abcdef")');
69
- });
70
-
71
- it('formats MD5s correctly', function() {
72
- expect(inspect(new bson.Binary(Buffer.from('0123456789abcdef0123456789abcdef', 'hex'), 5)))
73
- .to.equal('MD5("0123456789abcdef0123456789abcdef")');
74
- });
75
- });
1
+ import { expect } from 'chai';
2
+ import { bson } from './index';
3
+ import { inspect } from 'util';
4
+ import makePrintableBson from './printable-bson';
5
+
6
+ describe('BSON printers', function() {
7
+ before('make BSON objects printable', function() {
8
+ makePrintableBson(bson);
9
+ });
10
+
11
+ it('formats ObjectIds correctly', function() {
12
+ expect(inspect(new bson.ObjectId('5fa5694f88211043b23c7f11')))
13
+ .to.equal('ObjectId("5fa5694f88211043b23c7f11")');
14
+ });
15
+
16
+ it('formats DBRefs correctly', function() {
17
+ expect(inspect(new bson.DBRef('a', new bson.ObjectId('5f16b8bebe434dc98cdfc9cb'), 'db')))
18
+ .to.equal('DBRef("a", ObjectId("5f16b8bebe434dc98cdfc9cb"), "db")');
19
+ expect(inspect(new bson.DBRef('a', 'foo' as any, 'db')))
20
+ .to.equal('DBRef("a", \'foo\', "db")');
21
+ expect(inspect(new bson.DBRef('a', { x: 1 } as any, 'db')))
22
+ .to.equal('DBRef("a", { x: 1 }, "db")');
23
+ });
24
+
25
+ it('formats MinKey and MaxKey correctly', function() {
26
+ expect(inspect(new bson.MinKey())).to.equal('MinKey()');
27
+ expect(inspect(new bson.MaxKey())).to.equal('MaxKey()');
28
+ });
29
+
30
+ it('formats NumberInt correctly', function() {
31
+ expect(inspect(new bson.Int32(32))).to.equal('Int32(32)');
32
+ });
33
+
34
+ it('formats NumberLong correctly', function() {
35
+ expect(inspect(bson.Long.fromString('64'))).to.equal('Long("64")');
36
+ });
37
+
38
+ it('formats unsigned NumberLong correctly', function() {
39
+ expect(inspect(bson.Long.fromString('64', true))).to.equal('Long("64", true)');
40
+ });
41
+
42
+ it('formats NumberDecimal correctly', function() {
43
+ expect(inspect(bson.Decimal128.fromString('1'))).to.equal('Decimal128("1")');
44
+ });
45
+
46
+ it('formats Timestamp correctly', function() {
47
+ expect(inspect(new bson.Timestamp(new bson.Long(100, 1)))).to.equal('Timestamp({ t: 1, i: 100 })');
48
+ });
49
+
50
+ it('formats Symbol correctly', function() {
51
+ expect(inspect(new bson.BSONSymbol('abc'))).to.equal('BSONSymbol("abc")');
52
+ });
53
+
54
+ it('formats Code correctly', function() {
55
+ expect(inspect(new bson.Code('abc'))).to.equal('Code("abc")');
56
+ });
57
+
58
+ it('formats BinData correctly', function() {
59
+ expect(inspect(new bson.Binary('abc'))).to.equal('Binary(Buffer.from("616263", "hex"), 0)');
60
+ });
61
+
62
+ it('formats BSONRegExp correctly', function() {
63
+ expect(inspect(new bson.BSONRegExp('(?-i)AA_', 'im'))).to.equal('BSONRegExp("(?-i)AA_", "im")');
64
+ });
65
+
66
+ it('formats UUIDs correctly', function() {
67
+ expect(inspect(new bson.Binary(Buffer.from('0123456789abcdef0123456789abcdef', 'hex'), 4)))
68
+ .to.equal('UUID("01234567-89ab-cdef-0123-456789abcdef")');
69
+ });
70
+
71
+ it('formats MD5s correctly', function() {
72
+ expect(inspect(new bson.Binary(Buffer.from('0123456789abcdef0123456789abcdef', 'hex'), 5)))
73
+ .to.equal('MD5("0123456789abcdef0123456789abcdef")');
74
+ });
75
+ });
@@ -1,103 +1,103 @@
1
- import { bson as BSON } from './index';
2
- import { inspect } from 'util';
3
- const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
4
-
5
- export const bsonStringifiers: Record<string, (this: any, depth: any, options: any) => string> = {
6
- ObjectId: function(): string {
7
- return `ObjectId("${this.toHexString()}")`;
8
- },
9
-
10
- DBRef: function(depth: any, options: any): string {
11
- return `DBRef("${this.namespace}", ` +
12
- inspect(this.oid, options) +
13
- (this.db ? `, "${this.db}"` : '') +
14
- ')';
15
- },
16
-
17
- MaxKey: function(): string {
18
- return 'MaxKey()';
19
- },
20
-
21
- MinKey: function(): string {
22
- return 'MinKey()';
23
- },
24
-
25
- Timestamp: function(): string {
26
- return `Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
27
- },
28
-
29
- BSONSymbol: function(): string {
30
- return `BSONSymbol("${this.valueOf()}")`;
31
- },
32
-
33
- Code: function(): string {
34
- const j = this.toJSON();
35
- return `Code("${j.code}"${j.scope ? `, ${JSON.stringify(j.scope)}` : ''})`;
36
- },
37
-
38
- Decimal128: function(): string {
39
- return `Decimal128("${this.toString()}")`;
40
- },
41
-
42
- Int32: function(): string {
43
- return `Int32(${this.valueOf()})`;
44
- },
45
-
46
- Long: function(): string {
47
- return `Long("${this.toString()}"${this.unsigned ? ', true' : ''})`;
48
- },
49
-
50
- BSONRegExp: function(): string {
51
- return `BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
52
- },
53
-
54
- Binary: function(): string {
55
- const asBuffer = this.value(true);
56
- switch (this.sub_type) {
57
- case BSON.Binary.SUBTYPE_MD5:
58
- return `MD5("${asBuffer.toString('hex')}")`;
59
- case BSON.Binary.SUBTYPE_UUID:
60
- if (asBuffer.length === 16) {
61
- // Format '0123456789abcdef0123456789abcdef' into
62
- // '01234567-89ab-cdef-0123-456789abcdef'.
63
- const hex = asBuffer.toString('hex');
64
- const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
65
- .slice(1, 6).join('-');
66
- return `UUID("${asUUID}")`;
67
- }
68
- // In case somebody did something weird and used an UUID with a
69
- // non-standard length, fall through.
70
- default:
71
- return `Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
72
- }
73
- },
74
- };
75
- bsonStringifiers.ObjectID = bsonStringifiers.ObjectId;
76
-
77
- /**
78
- * This method modifies the BSON class passed in as argument. This is required so that
79
- * we can have the driver return our BSON classes without having to write our own serializer.
80
- * @param {Object} bson
81
- */
82
- export default function(bson?: typeof BSON): void {
83
- if (!bson) {
84
- bson = BSON;
85
- }
86
-
87
- for (const [ key, stringifier ] of Object.entries(bsonStringifiers)) {
88
- if (!(key in bson)) {
89
- continue;
90
- }
91
- const cls = bson[key as keyof typeof BSON];
92
- for (const key of [inspectCustom, 'inspect']) {
93
- try {
94
- (cls as any).prototype[key] = stringifier;
95
- } catch {
96
- // This may fail because bson.ObjectId.prototype[toString] can exist as a
97
- // read-only property. https://github.com/mongodb/js-bson/pull/412 takes
98
- // care of this. In the CLI repl and Compass this still works fine, because
99
- // those are on bson@1.x.
100
- }
101
- }
102
- }
103
- }
1
+ import { bson as BSON } from './index';
2
+ import { inspect } from 'util';
3
+ const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
4
+
5
+ export const bsonStringifiers: Record<string, (this: any, depth: any, options: any) => string> = {
6
+ ObjectId: function(): string {
7
+ return `ObjectId("${this.toHexString()}")`;
8
+ },
9
+
10
+ DBRef: function(depth: any, options: any): string {
11
+ return `DBRef("${this.namespace}", ` +
12
+ inspect(this.oid, options) +
13
+ (this.db ? `, "${this.db}"` : '') +
14
+ ')';
15
+ },
16
+
17
+ MaxKey: function(): string {
18
+ return 'MaxKey()';
19
+ },
20
+
21
+ MinKey: function(): string {
22
+ return 'MinKey()';
23
+ },
24
+
25
+ Timestamp: function(): string {
26
+ return `Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
27
+ },
28
+
29
+ BSONSymbol: function(): string {
30
+ return `BSONSymbol("${this.valueOf()}")`;
31
+ },
32
+
33
+ Code: function(): string {
34
+ const j = this.toJSON();
35
+ return `Code("${j.code}"${j.scope ? `, ${JSON.stringify(j.scope)}` : ''})`;
36
+ },
37
+
38
+ Decimal128: function(): string {
39
+ return `Decimal128("${this.toString()}")`;
40
+ },
41
+
42
+ Int32: function(): string {
43
+ return `Int32(${this.valueOf()})`;
44
+ },
45
+
46
+ Long: function(): string {
47
+ return `Long("${this.toString()}"${this.unsigned ? ', true' : ''})`;
48
+ },
49
+
50
+ BSONRegExp: function(): string {
51
+ return `BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
52
+ },
53
+
54
+ Binary: function(): string {
55
+ const asBuffer = this.value(true);
56
+ switch (this.sub_type) {
57
+ case BSON.Binary.SUBTYPE_MD5:
58
+ return `MD5("${asBuffer.toString('hex')}")`;
59
+ case BSON.Binary.SUBTYPE_UUID:
60
+ if (asBuffer.length === 16) {
61
+ // Format '0123456789abcdef0123456789abcdef' into
62
+ // '01234567-89ab-cdef-0123-456789abcdef'.
63
+ const hex = asBuffer.toString('hex');
64
+ const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
65
+ .slice(1, 6).join('-');
66
+ return `UUID("${asUUID}")`;
67
+ }
68
+ // In case somebody did something weird and used an UUID with a
69
+ // non-standard length, fall through.
70
+ default:
71
+ return `Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
72
+ }
73
+ },
74
+ };
75
+ bsonStringifiers.ObjectID = bsonStringifiers.ObjectId;
76
+
77
+ /**
78
+ * This method modifies the BSON class passed in as argument. This is required so that
79
+ * we can have the driver return our BSON classes without having to write our own serializer.
80
+ * @param {Object} bson
81
+ */
82
+ export default function(bson?: typeof BSON): void {
83
+ if (!bson) {
84
+ bson = BSON;
85
+ }
86
+
87
+ for (const [ key, stringifier ] of Object.entries(bsonStringifiers)) {
88
+ if (!(key in bson)) {
89
+ continue;
90
+ }
91
+ const cls = bson[key as keyof typeof BSON];
92
+ for (const key of [inspectCustom, 'inspect']) {
93
+ try {
94
+ (cls as any).prototype[key] = stringifier;
95
+ } catch {
96
+ // This may fail because bson.ObjectId.prototype[toString] can exist as a
97
+ // read-only property. https://github.com/mongodb/js-bson/pull/412 takes
98
+ // care of this. In the CLI repl and Compass this still works fine, because
99
+ // those are on bson@1.x.
100
+ }
101
+ }
102
+ }
103
+ }