@qp-mongosh/service-provider-core 0.0.0-dev.0 → 0.0.0-dev.3
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.
- package/.eslintignore +2 -2
- package/.eslintrc.js +1 -1
- package/AUTHORS +11 -11
- package/LICENSE +200 -200
- package/lib/admin.d.ts +28 -28
- package/lib/admin.js +2 -2
- package/lib/all-fle-types.d.ts +2 -2
- package/lib/all-fle-types.js +2 -2
- package/lib/all-transport-types.d.ts +1 -1
- package/lib/all-transport-types.js +2 -2
- package/lib/cli-options.d.ts +43 -43
- package/lib/cli-options.js +2 -2
- package/lib/closable.d.ts +4 -4
- package/lib/closable.js +2 -2
- package/lib/connect-info.d.ts +19 -19
- package/lib/connect-info.js +34 -34
- package/lib/index.d.ts +31 -31
- package/lib/index.js +55 -55
- package/lib/platform.d.ts +6 -6
- package/lib/platform.js +10 -10
- package/lib/printable-bson.d.ts +3 -3
- package/lib/printable-bson.js +81 -81
- package/lib/readable.d.ts +18 -18
- package/lib/readable.js +2 -2
- package/lib/service-provider.d.ts +11 -11
- package/lib/service-provider.js +18 -18
- package/lib/shell-auth-options.d.ts +7 -7
- package/lib/shell-auth-options.js +2 -2
- package/lib/textencoder-polyfill.d.ts +2 -2
- package/lib/textencoder-polyfill.js +21 -21
- package/lib/uri-generator.d.ts +8 -8
- package/lib/uri-generator.js +175 -175
- package/lib/writable.d.ts +22 -22
- package/lib/writable.js +2 -2
- package/package.json +54 -54
- package/src/admin.ts +119 -119
- package/src/all-fle-types.ts +17 -17
- package/src/all-transport-types.ts +80 -80
- package/src/cli-options.ts +49 -49
- package/src/closable.ts +14 -14
- package/src/connect-info.spec.ts +192 -192
- package/src/connect-info.ts +57 -57
- package/src/index.ts +62 -62
- package/src/platform.ts +6 -6
- package/src/printable-bson.spec.ts +75 -75
- package/src/printable-bson.ts +103 -103
- package/src/readable.ts +242 -242
- package/src/service-provider.ts +23 -23
- package/src/shell-auth-options.ts +7 -7
- package/src/textencoder-polyfill.spec.ts +11 -11
- package/src/textencoder-polyfill.ts +30 -30
- package/src/uri-generator.spec.ts +481 -481
- package/src/uri-generator.ts +265 -265
- package/src/writable.ts +367 -367
- package/tsconfig.json +12 -12
- package/tsconfig.lint.json +8 -8
package/src/connect-info.spec.ts
CHANGED
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
/* eslint camelcase: 0, camelcase: 0 */
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import getConnectInfo from './connect-info';
|
|
4
|
-
|
|
5
|
-
describe('getConnectInfo', function() {
|
|
6
|
-
const BUILD_INFO = {
|
|
7
|
-
'version': '3.2.0-rc2',
|
|
8
|
-
'gitVersion': '8a3acb42742182c5e314636041c2df368232bbc5',
|
|
9
|
-
'modules': [
|
|
10
|
-
'enterprise'
|
|
11
|
-
],
|
|
12
|
-
'allocator': 'system',
|
|
13
|
-
'javascriptEngine': 'mozjs',
|
|
14
|
-
'sysInfo': 'deprecated',
|
|
15
|
-
'versionArray': [
|
|
16
|
-
3,
|
|
17
|
-
2,
|
|
18
|
-
0,
|
|
19
|
-
-48
|
|
20
|
-
],
|
|
21
|
-
'openssl': {
|
|
22
|
-
'running': 'OpenSSL 0.9.8zg 14 July 2015',
|
|
23
|
-
'compiled': 'OpenSSL 0.9.8y 5 Feb 2013'
|
|
24
|
-
},
|
|
25
|
-
'buildEnvironment': {
|
|
26
|
-
'distmod': '',
|
|
27
|
-
'distarch': 'x86_64',
|
|
28
|
-
'cc': 'gcc: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)',
|
|
29
|
-
'ccflags': '-fno-omit-frame-pointer -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -O2 -Wno-unused-function -Wno-unused-private-field -Wno-deprecated-declarations -Wno-tautological-constant-out-of-range-compare -Wno-unused-const-variable -Wno-missing-braces -mmacosx-version-min=10.7 -fno-builtin-memcmp',
|
|
30
|
-
'cxx': 'g++: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)',
|
|
31
|
-
'cxxflags': '-Wnon-virtual-dtor -Woverloaded-virtual -stdlib=libc++ -std=c++11',
|
|
32
|
-
'linkflags': '-fPIC -pthread -Wl,-bind_at_load -mmacosx-version-min=10.7 -stdlib=libc++ -fuse-ld=gold',
|
|
33
|
-
'target_arch': 'x86_64',
|
|
34
|
-
'target_os': 'osx'
|
|
35
|
-
},
|
|
36
|
-
'bits': 64,
|
|
37
|
-
'debug': false,
|
|
38
|
-
'maxBsonObjectSize': 16777216,
|
|
39
|
-
'storageEngines': [
|
|
40
|
-
'devnull',
|
|
41
|
-
'ephemeralForTest',
|
|
42
|
-
'inMemory',
|
|
43
|
-
'mmapv1',
|
|
44
|
-
'wiredTiger'
|
|
45
|
-
],
|
|
46
|
-
'ok': 1
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const CMD_LINE_OPTS = {
|
|
50
|
-
'argv': [
|
|
51
|
-
'/opt/mongodb-osx-x86_64-enterprise-3.6.3/bin/mongod',
|
|
52
|
-
'--dbpath=/Users/user/testdata'
|
|
53
|
-
],
|
|
54
|
-
'parsed': {
|
|
55
|
-
'storage': {
|
|
56
|
-
'dbPath': '/Users/user/testdata'
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
'ok': 1
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const ATLAS_VERSION = {
|
|
63
|
-
'atlasVersion': '20210330.0.0.1617063608',
|
|
64
|
-
'gitVersion': '8f7e5bdde713391e8123a463895bb7fb660a5ffd'
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const TOPOLOGY_WITH_CREDENTIALS = {
|
|
68
|
-
's': {
|
|
69
|
-
'credentials': {
|
|
70
|
-
'mechanism': 'LDAP'
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const TOPOLOGY_NO_CREDENTIALS = {
|
|
76
|
-
's': {}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const ATLAS_URI = 'mongodb+srv://admin:catscatscats@cat-data-sets.cats.example.net/admin';
|
|
80
|
-
|
|
81
|
-
it('reports on an enterprise version >=3.2 of mongodb with credentials', function() {
|
|
82
|
-
const output = {
|
|
83
|
-
is_atlas: true,
|
|
84
|
-
is_localhost: false,
|
|
85
|
-
is_do: false,
|
|
86
|
-
server_version: '3.2.0-rc2',
|
|
87
|
-
mongosh_version: '0.0.6',
|
|
88
|
-
is_enterprise: true,
|
|
89
|
-
auth_type: 'LDAP',
|
|
90
|
-
is_data_lake: false,
|
|
91
|
-
dl_version: null,
|
|
92
|
-
atlas_version: '20210330.0.0.1617063608',
|
|
93
|
-
is_genuine: true,
|
|
94
|
-
non_genuine_server_name: 'mongodb',
|
|
95
|
-
server_arch: 'x86_64',
|
|
96
|
-
node_version: process.version,
|
|
97
|
-
server_os: 'osx',
|
|
98
|
-
uri: ATLAS_URI
|
|
99
|
-
};
|
|
100
|
-
expect(getConnectInfo(
|
|
101
|
-
ATLAS_URI,
|
|
102
|
-
'0.0.6',
|
|
103
|
-
BUILD_INFO,
|
|
104
|
-
CMD_LINE_OPTS,
|
|
105
|
-
ATLAS_VERSION,
|
|
106
|
-
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('reports on an enterprise version >=3.2 of mongodb with no credentials', function() {
|
|
110
|
-
const output = {
|
|
111
|
-
is_atlas: true,
|
|
112
|
-
is_localhost: false,
|
|
113
|
-
is_do: false,
|
|
114
|
-
server_version: '3.2.0-rc2',
|
|
115
|
-
mongosh_version: '0.0.6',
|
|
116
|
-
is_enterprise: true,
|
|
117
|
-
auth_type: null,
|
|
118
|
-
is_data_lake: false,
|
|
119
|
-
dl_version: null,
|
|
120
|
-
atlas_version: '20210330.0.0.1617063608',
|
|
121
|
-
is_genuine: true,
|
|
122
|
-
non_genuine_server_name: 'mongodb',
|
|
123
|
-
server_arch: 'x86_64',
|
|
124
|
-
node_version: process.version,
|
|
125
|
-
server_os: 'osx',
|
|
126
|
-
uri: ATLAS_URI
|
|
127
|
-
};
|
|
128
|
-
expect(getConnectInfo(
|
|
129
|
-
ATLAS_URI,
|
|
130
|
-
'0.0.6',
|
|
131
|
-
BUILD_INFO,
|
|
132
|
-
CMD_LINE_OPTS,
|
|
133
|
-
ATLAS_VERSION,
|
|
134
|
-
TOPOLOGY_NO_CREDENTIALS)).to.deep.equal(output);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('reports correct information when an empty uri is passed', function() {
|
|
138
|
-
const output = {
|
|
139
|
-
is_atlas: false,
|
|
140
|
-
is_localhost: false,
|
|
141
|
-
is_do: false,
|
|
142
|
-
server_version: '3.2.0-rc2',
|
|
143
|
-
mongosh_version: '0.0.6',
|
|
144
|
-
is_enterprise: true,
|
|
145
|
-
auth_type: 'LDAP',
|
|
146
|
-
is_data_lake: false,
|
|
147
|
-
dl_version: null,
|
|
148
|
-
atlas_version: null,
|
|
149
|
-
is_genuine: true,
|
|
150
|
-
non_genuine_server_name: 'mongodb',
|
|
151
|
-
server_arch: 'x86_64',
|
|
152
|
-
node_version: process.version,
|
|
153
|
-
server_os: 'osx',
|
|
154
|
-
uri: ''
|
|
155
|
-
};
|
|
156
|
-
expect(getConnectInfo(
|
|
157
|
-
'',
|
|
158
|
-
'0.0.6',
|
|
159
|
-
BUILD_INFO,
|
|
160
|
-
CMD_LINE_OPTS,
|
|
161
|
-
null,
|
|
162
|
-
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('does not fail when buildInfo is unavailable', function() {
|
|
166
|
-
const output = {
|
|
167
|
-
is_atlas: false,
|
|
168
|
-
is_localhost: false,
|
|
169
|
-
is_do: false,
|
|
170
|
-
server_version: undefined,
|
|
171
|
-
mongosh_version: '0.0.6',
|
|
172
|
-
is_enterprise: false,
|
|
173
|
-
auth_type: 'LDAP',
|
|
174
|
-
is_data_lake: false,
|
|
175
|
-
dl_version: null,
|
|
176
|
-
atlas_version: null,
|
|
177
|
-
is_genuine: true,
|
|
178
|
-
non_genuine_server_name: 'mongodb',
|
|
179
|
-
server_arch: null,
|
|
180
|
-
node_version: process.version,
|
|
181
|
-
server_os: null,
|
|
182
|
-
uri: ''
|
|
183
|
-
};
|
|
184
|
-
expect(getConnectInfo(
|
|
185
|
-
'',
|
|
186
|
-
'0.0.6',
|
|
187
|
-
null,
|
|
188
|
-
CMD_LINE_OPTS,
|
|
189
|
-
null,
|
|
190
|
-
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
1
|
+
/* eslint camelcase: 0, camelcase: 0 */
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import getConnectInfo from './connect-info';
|
|
4
|
+
|
|
5
|
+
describe('getConnectInfo', function() {
|
|
6
|
+
const BUILD_INFO = {
|
|
7
|
+
'version': '3.2.0-rc2',
|
|
8
|
+
'gitVersion': '8a3acb42742182c5e314636041c2df368232bbc5',
|
|
9
|
+
'modules': [
|
|
10
|
+
'enterprise'
|
|
11
|
+
],
|
|
12
|
+
'allocator': 'system',
|
|
13
|
+
'javascriptEngine': 'mozjs',
|
|
14
|
+
'sysInfo': 'deprecated',
|
|
15
|
+
'versionArray': [
|
|
16
|
+
3,
|
|
17
|
+
2,
|
|
18
|
+
0,
|
|
19
|
+
-48
|
|
20
|
+
],
|
|
21
|
+
'openssl': {
|
|
22
|
+
'running': 'OpenSSL 0.9.8zg 14 July 2015',
|
|
23
|
+
'compiled': 'OpenSSL 0.9.8y 5 Feb 2013'
|
|
24
|
+
},
|
|
25
|
+
'buildEnvironment': {
|
|
26
|
+
'distmod': '',
|
|
27
|
+
'distarch': 'x86_64',
|
|
28
|
+
'cc': 'gcc: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)',
|
|
29
|
+
'ccflags': '-fno-omit-frame-pointer -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -O2 -Wno-unused-function -Wno-unused-private-field -Wno-deprecated-declarations -Wno-tautological-constant-out-of-range-compare -Wno-unused-const-variable -Wno-missing-braces -mmacosx-version-min=10.7 -fno-builtin-memcmp',
|
|
30
|
+
'cxx': 'g++: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)',
|
|
31
|
+
'cxxflags': '-Wnon-virtual-dtor -Woverloaded-virtual -stdlib=libc++ -std=c++11',
|
|
32
|
+
'linkflags': '-fPIC -pthread -Wl,-bind_at_load -mmacosx-version-min=10.7 -stdlib=libc++ -fuse-ld=gold',
|
|
33
|
+
'target_arch': 'x86_64',
|
|
34
|
+
'target_os': 'osx'
|
|
35
|
+
},
|
|
36
|
+
'bits': 64,
|
|
37
|
+
'debug': false,
|
|
38
|
+
'maxBsonObjectSize': 16777216,
|
|
39
|
+
'storageEngines': [
|
|
40
|
+
'devnull',
|
|
41
|
+
'ephemeralForTest',
|
|
42
|
+
'inMemory',
|
|
43
|
+
'mmapv1',
|
|
44
|
+
'wiredTiger'
|
|
45
|
+
],
|
|
46
|
+
'ok': 1
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const CMD_LINE_OPTS = {
|
|
50
|
+
'argv': [
|
|
51
|
+
'/opt/mongodb-osx-x86_64-enterprise-3.6.3/bin/mongod',
|
|
52
|
+
'--dbpath=/Users/user/testdata'
|
|
53
|
+
],
|
|
54
|
+
'parsed': {
|
|
55
|
+
'storage': {
|
|
56
|
+
'dbPath': '/Users/user/testdata'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
'ok': 1
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const ATLAS_VERSION = {
|
|
63
|
+
'atlasVersion': '20210330.0.0.1617063608',
|
|
64
|
+
'gitVersion': '8f7e5bdde713391e8123a463895bb7fb660a5ffd'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const TOPOLOGY_WITH_CREDENTIALS = {
|
|
68
|
+
's': {
|
|
69
|
+
'credentials': {
|
|
70
|
+
'mechanism': 'LDAP'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const TOPOLOGY_NO_CREDENTIALS = {
|
|
76
|
+
's': {}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const ATLAS_URI = 'mongodb+srv://admin:catscatscats@cat-data-sets.cats.example.net/admin';
|
|
80
|
+
|
|
81
|
+
it('reports on an enterprise version >=3.2 of mongodb with credentials', function() {
|
|
82
|
+
const output = {
|
|
83
|
+
is_atlas: true,
|
|
84
|
+
is_localhost: false,
|
|
85
|
+
is_do: false,
|
|
86
|
+
server_version: '3.2.0-rc2',
|
|
87
|
+
mongosh_version: '0.0.6',
|
|
88
|
+
is_enterprise: true,
|
|
89
|
+
auth_type: 'LDAP',
|
|
90
|
+
is_data_lake: false,
|
|
91
|
+
dl_version: null,
|
|
92
|
+
atlas_version: '20210330.0.0.1617063608',
|
|
93
|
+
is_genuine: true,
|
|
94
|
+
non_genuine_server_name: 'mongodb',
|
|
95
|
+
server_arch: 'x86_64',
|
|
96
|
+
node_version: process.version,
|
|
97
|
+
server_os: 'osx',
|
|
98
|
+
uri: ATLAS_URI
|
|
99
|
+
};
|
|
100
|
+
expect(getConnectInfo(
|
|
101
|
+
ATLAS_URI,
|
|
102
|
+
'0.0.6',
|
|
103
|
+
BUILD_INFO,
|
|
104
|
+
CMD_LINE_OPTS,
|
|
105
|
+
ATLAS_VERSION,
|
|
106
|
+
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('reports on an enterprise version >=3.2 of mongodb with no credentials', function() {
|
|
110
|
+
const output = {
|
|
111
|
+
is_atlas: true,
|
|
112
|
+
is_localhost: false,
|
|
113
|
+
is_do: false,
|
|
114
|
+
server_version: '3.2.0-rc2',
|
|
115
|
+
mongosh_version: '0.0.6',
|
|
116
|
+
is_enterprise: true,
|
|
117
|
+
auth_type: null,
|
|
118
|
+
is_data_lake: false,
|
|
119
|
+
dl_version: null,
|
|
120
|
+
atlas_version: '20210330.0.0.1617063608',
|
|
121
|
+
is_genuine: true,
|
|
122
|
+
non_genuine_server_name: 'mongodb',
|
|
123
|
+
server_arch: 'x86_64',
|
|
124
|
+
node_version: process.version,
|
|
125
|
+
server_os: 'osx',
|
|
126
|
+
uri: ATLAS_URI
|
|
127
|
+
};
|
|
128
|
+
expect(getConnectInfo(
|
|
129
|
+
ATLAS_URI,
|
|
130
|
+
'0.0.6',
|
|
131
|
+
BUILD_INFO,
|
|
132
|
+
CMD_LINE_OPTS,
|
|
133
|
+
ATLAS_VERSION,
|
|
134
|
+
TOPOLOGY_NO_CREDENTIALS)).to.deep.equal(output);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('reports correct information when an empty uri is passed', function() {
|
|
138
|
+
const output = {
|
|
139
|
+
is_atlas: false,
|
|
140
|
+
is_localhost: false,
|
|
141
|
+
is_do: false,
|
|
142
|
+
server_version: '3.2.0-rc2',
|
|
143
|
+
mongosh_version: '0.0.6',
|
|
144
|
+
is_enterprise: true,
|
|
145
|
+
auth_type: 'LDAP',
|
|
146
|
+
is_data_lake: false,
|
|
147
|
+
dl_version: null,
|
|
148
|
+
atlas_version: null,
|
|
149
|
+
is_genuine: true,
|
|
150
|
+
non_genuine_server_name: 'mongodb',
|
|
151
|
+
server_arch: 'x86_64',
|
|
152
|
+
node_version: process.version,
|
|
153
|
+
server_os: 'osx',
|
|
154
|
+
uri: ''
|
|
155
|
+
};
|
|
156
|
+
expect(getConnectInfo(
|
|
157
|
+
'',
|
|
158
|
+
'0.0.6',
|
|
159
|
+
BUILD_INFO,
|
|
160
|
+
CMD_LINE_OPTS,
|
|
161
|
+
null,
|
|
162
|
+
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('does not fail when buildInfo is unavailable', function() {
|
|
166
|
+
const output = {
|
|
167
|
+
is_atlas: false,
|
|
168
|
+
is_localhost: false,
|
|
169
|
+
is_do: false,
|
|
170
|
+
server_version: undefined,
|
|
171
|
+
mongosh_version: '0.0.6',
|
|
172
|
+
is_enterprise: false,
|
|
173
|
+
auth_type: 'LDAP',
|
|
174
|
+
is_data_lake: false,
|
|
175
|
+
dl_version: null,
|
|
176
|
+
atlas_version: null,
|
|
177
|
+
is_genuine: true,
|
|
178
|
+
non_genuine_server_name: 'mongodb',
|
|
179
|
+
server_arch: null,
|
|
180
|
+
node_version: process.version,
|
|
181
|
+
server_os: null,
|
|
182
|
+
uri: ''
|
|
183
|
+
};
|
|
184
|
+
expect(getConnectInfo(
|
|
185
|
+
'',
|
|
186
|
+
'0.0.6',
|
|
187
|
+
null,
|
|
188
|
+
CMD_LINE_OPTS,
|
|
189
|
+
null,
|
|
190
|
+
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
|
|
191
|
+
});
|
|
192
|
+
});
|
package/src/connect-info.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
// ^ segment data is in snake_case: forgive me javascript, for i have sinned.
|
|
3
|
-
|
|
4
|
-
import getBuildInfo from 'mongodb-build-info';
|
|
5
|
-
|
|
6
|
-
export interface ConnectInfo {
|
|
7
|
-
is_atlas: boolean;
|
|
8
|
-
is_localhost: boolean;
|
|
9
|
-
is_do: boolean;
|
|
10
|
-
server_version: string;
|
|
11
|
-
mongosh_version: string;
|
|
12
|
-
server_os?: string;
|
|
13
|
-
server_arch?: string;
|
|
14
|
-
is_enterprise: boolean;
|
|
15
|
-
auth_type?: string;
|
|
16
|
-
is_data_lake: boolean;
|
|
17
|
-
dl_version?: string;
|
|
18
|
-
atlas_version?: string;
|
|
19
|
-
is_genuine: boolean;
|
|
20
|
-
non_genuine_server_name: string;
|
|
21
|
-
node_version: string;
|
|
22
|
-
uri: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default function getConnectInfo(uri: string, mongoshVersion: string, buildInfo: any, cmdLineOpts: any, atlasVersion: any, topology: any): ConnectInfo {
|
|
26
|
-
buildInfo ??= {}; // We're currently not getting buildInfo with --apiStrict.
|
|
27
|
-
const { isGenuine: is_genuine, serverName: non_genuine_server_name } =
|
|
28
|
-
getBuildInfo.getGenuineMongoDB(buildInfo, cmdLineOpts);
|
|
29
|
-
const { isDataLake: is_data_lake, dlVersion: dl_version }
|
|
30
|
-
= getBuildInfo.getDataLake(buildInfo);
|
|
31
|
-
|
|
32
|
-
// get this information from topology rather than cmdLineOpts, since not all
|
|
33
|
-
// connections are able to run getCmdLineOpts command
|
|
34
|
-
const auth_type = topology.s.credentials
|
|
35
|
-
? topology.s.credentials.mechanism : null;
|
|
36
|
-
const { serverOs: server_os, serverArch: server_arch }
|
|
37
|
-
= getBuildInfo.getBuildEnv(buildInfo);
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
is_atlas: !!atlasVersion?.atlasVersion || getBuildInfo.isAtlas(uri),
|
|
41
|
-
is_localhost: getBuildInfo.isLocalhost(uri),
|
|
42
|
-
is_do: getBuildInfo.isDigitalOcean(uri),
|
|
43
|
-
server_version: buildInfo.version,
|
|
44
|
-
node_version: process.version,
|
|
45
|
-
mongosh_version: mongoshVersion,
|
|
46
|
-
server_os,
|
|
47
|
-
uri,
|
|
48
|
-
server_arch,
|
|
49
|
-
is_enterprise: getBuildInfo.isEnterprise(buildInfo),
|
|
50
|
-
auth_type,
|
|
51
|
-
is_data_lake,
|
|
52
|
-
dl_version,
|
|
53
|
-
atlas_version: atlasVersion?.atlasVersion ?? null,
|
|
54
|
-
is_genuine,
|
|
55
|
-
non_genuine_server_name
|
|
56
|
-
};
|
|
57
|
-
}
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
// ^ segment data is in snake_case: forgive me javascript, for i have sinned.
|
|
3
|
+
|
|
4
|
+
import getBuildInfo from 'mongodb-build-info';
|
|
5
|
+
|
|
6
|
+
export interface ConnectInfo {
|
|
7
|
+
is_atlas: boolean;
|
|
8
|
+
is_localhost: boolean;
|
|
9
|
+
is_do: boolean;
|
|
10
|
+
server_version: string;
|
|
11
|
+
mongosh_version: string;
|
|
12
|
+
server_os?: string;
|
|
13
|
+
server_arch?: string;
|
|
14
|
+
is_enterprise: boolean;
|
|
15
|
+
auth_type?: string;
|
|
16
|
+
is_data_lake: boolean;
|
|
17
|
+
dl_version?: string;
|
|
18
|
+
atlas_version?: string;
|
|
19
|
+
is_genuine: boolean;
|
|
20
|
+
non_genuine_server_name: string;
|
|
21
|
+
node_version: string;
|
|
22
|
+
uri: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function getConnectInfo(uri: string, mongoshVersion: string, buildInfo: any, cmdLineOpts: any, atlasVersion: any, topology: any): ConnectInfo {
|
|
26
|
+
buildInfo ??= {}; // We're currently not getting buildInfo with --apiStrict.
|
|
27
|
+
const { isGenuine: is_genuine, serverName: non_genuine_server_name } =
|
|
28
|
+
getBuildInfo.getGenuineMongoDB(buildInfo, cmdLineOpts);
|
|
29
|
+
const { isDataLake: is_data_lake, dlVersion: dl_version }
|
|
30
|
+
= getBuildInfo.getDataLake(buildInfo);
|
|
31
|
+
|
|
32
|
+
// get this information from topology rather than cmdLineOpts, since not all
|
|
33
|
+
// connections are able to run getCmdLineOpts command
|
|
34
|
+
const auth_type = topology.s.credentials
|
|
35
|
+
? topology.s.credentials.mechanism : null;
|
|
36
|
+
const { serverOs: server_os, serverArch: server_arch }
|
|
37
|
+
= getBuildInfo.getBuildEnv(buildInfo);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
is_atlas: !!atlasVersion?.atlasVersion || getBuildInfo.isAtlas(uri),
|
|
41
|
+
is_localhost: getBuildInfo.isLocalhost(uri),
|
|
42
|
+
is_do: getBuildInfo.isDigitalOcean(uri),
|
|
43
|
+
server_version: buildInfo.version,
|
|
44
|
+
node_version: process.version,
|
|
45
|
+
mongosh_version: mongoshVersion,
|
|
46
|
+
server_os,
|
|
47
|
+
uri,
|
|
48
|
+
server_arch,
|
|
49
|
+
is_enterprise: getBuildInfo.isEnterprise(buildInfo),
|
|
50
|
+
auth_type,
|
|
51
|
+
is_data_lake,
|
|
52
|
+
dl_version,
|
|
53
|
+
atlas_version: atlasVersion?.atlasVersion ?? null,
|
|
54
|
+
is_genuine,
|
|
55
|
+
non_genuine_server_name
|
|
56
|
+
};
|
|
57
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import './textencoder-polyfill'; // for mongodb-connection-string-url in the java-shell
|
|
2
|
-
import ServiceProvider, { ServiceProviderCore } from './service-provider';
|
|
3
|
-
import getConnectInfo, { ConnectInfo } from './connect-info';
|
|
4
|
-
import { ReplPlatform } from './platform';
|
|
5
|
-
import CliOptions from './cli-options';
|
|
6
|
-
import generateUri from './uri-generator';
|
|
7
|
-
const DEFAULT_DB = 'test';
|
|
8
|
-
import {
|
|
9
|
-
ObjectId,
|
|
10
|
-
DBRef,
|
|
11
|
-
MaxKey,
|
|
12
|
-
MinKey,
|
|
13
|
-
Timestamp,
|
|
14
|
-
BSONSymbol,
|
|
15
|
-
Code,
|
|
16
|
-
Decimal128,
|
|
17
|
-
Int32,
|
|
18
|
-
Long,
|
|
19
|
-
Binary,
|
|
20
|
-
Map,
|
|
21
|
-
calculateObjectSize,
|
|
22
|
-
Double,
|
|
23
|
-
EJSON,
|
|
24
|
-
BSONRegExp
|
|
25
|
-
} from 'bson';
|
|
26
|
-
import { bsonStringifiers } from './printable-bson';
|
|
27
|
-
import ShellAuthOptions from './shell-auth-options';
|
|
28
|
-
export * from './all-transport-types';
|
|
29
|
-
export * from './all-fle-types';
|
|
30
|
-
|
|
31
|
-
const bson = {
|
|
32
|
-
ObjectId,
|
|
33
|
-
DBRef,
|
|
34
|
-
MaxKey,
|
|
35
|
-
MinKey,
|
|
36
|
-
Timestamp,
|
|
37
|
-
BSONSymbol,
|
|
38
|
-
Code,
|
|
39
|
-
Decimal128,
|
|
40
|
-
Int32,
|
|
41
|
-
Long,
|
|
42
|
-
Binary,
|
|
43
|
-
Map,
|
|
44
|
-
calculateObjectSize,
|
|
45
|
-
Double,
|
|
46
|
-
EJSON,
|
|
47
|
-
BSONRegExp
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
ServiceProvider,
|
|
52
|
-
ShellAuthOptions,
|
|
53
|
-
getConnectInfo,
|
|
54
|
-
ReplPlatform,
|
|
55
|
-
CliOptions,
|
|
56
|
-
generateUri,
|
|
57
|
-
DEFAULT_DB,
|
|
58
|
-
ServiceProviderCore,
|
|
59
|
-
bson,
|
|
60
|
-
bsonStringifiers,
|
|
61
|
-
ConnectInfo
|
|
62
|
-
};
|
|
1
|
+
import './textencoder-polyfill'; // for mongodb-connection-string-url in the java-shell
|
|
2
|
+
import ServiceProvider, { ServiceProviderCore } from './service-provider';
|
|
3
|
+
import getConnectInfo, { ConnectInfo } from './connect-info';
|
|
4
|
+
import { ReplPlatform } from './platform';
|
|
5
|
+
import CliOptions from './cli-options';
|
|
6
|
+
import generateUri from './uri-generator';
|
|
7
|
+
const DEFAULT_DB = 'test';
|
|
8
|
+
import {
|
|
9
|
+
ObjectId,
|
|
10
|
+
DBRef,
|
|
11
|
+
MaxKey,
|
|
12
|
+
MinKey,
|
|
13
|
+
Timestamp,
|
|
14
|
+
BSONSymbol,
|
|
15
|
+
Code,
|
|
16
|
+
Decimal128,
|
|
17
|
+
Int32,
|
|
18
|
+
Long,
|
|
19
|
+
Binary,
|
|
20
|
+
Map,
|
|
21
|
+
calculateObjectSize,
|
|
22
|
+
Double,
|
|
23
|
+
EJSON,
|
|
24
|
+
BSONRegExp
|
|
25
|
+
} from 'bson';
|
|
26
|
+
import { bsonStringifiers } from './printable-bson';
|
|
27
|
+
import ShellAuthOptions from './shell-auth-options';
|
|
28
|
+
export * from './all-transport-types';
|
|
29
|
+
export * from './all-fle-types';
|
|
30
|
+
|
|
31
|
+
const bson = {
|
|
32
|
+
ObjectId,
|
|
33
|
+
DBRef,
|
|
34
|
+
MaxKey,
|
|
35
|
+
MinKey,
|
|
36
|
+
Timestamp,
|
|
37
|
+
BSONSymbol,
|
|
38
|
+
Code,
|
|
39
|
+
Decimal128,
|
|
40
|
+
Int32,
|
|
41
|
+
Long,
|
|
42
|
+
Binary,
|
|
43
|
+
Map,
|
|
44
|
+
calculateObjectSize,
|
|
45
|
+
Double,
|
|
46
|
+
EJSON,
|
|
47
|
+
BSONRegExp
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
ServiceProvider,
|
|
52
|
+
ShellAuthOptions,
|
|
53
|
+
getConnectInfo,
|
|
54
|
+
ReplPlatform,
|
|
55
|
+
CliOptions,
|
|
56
|
+
generateUri,
|
|
57
|
+
DEFAULT_DB,
|
|
58
|
+
ServiceProviderCore,
|
|
59
|
+
bson,
|
|
60
|
+
bsonStringifiers,
|
|
61
|
+
ConnectInfo
|
|
62
|
+
};
|
package/src/platform.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export enum ReplPlatform {
|
|
2
|
-
Compass,
|
|
3
|
-
Browser,
|
|
4
|
-
CLI,
|
|
5
|
-
JavaShell
|
|
6
|
-
}
|
|
1
|
+
export enum ReplPlatform {
|
|
2
|
+
Compass,
|
|
3
|
+
Browser,
|
|
4
|
+
CLI,
|
|
5
|
+
JavaShell
|
|
6
|
+
}
|