@mongosh/service-provider-core 1.10.1 → 1.10.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/.depcheckrc +11 -0
- package/.eslintrc.js +10 -1
- package/.prettierignore +6 -0
- package/.prettierrc.json +1 -0
- package/lib/admin.d.ts +2 -2
- package/lib/all-fle-types.d.ts +2 -2
- package/lib/all-transport-types.d.ts +1 -1
- package/lib/connect-info.d.ts +1 -1
- package/lib/connect-info.js +5 -4
- package/lib/connect-info.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/map-reduce-options.d.ts +1 -1
- package/lib/platform.d.ts +1 -1
- package/lib/printable-bson.js +6 -4
- package/lib/printable-bson.js.map +1 -1
- package/lib/readable.d.ts +1 -1
- package/lib/service-provider.d.ts +4 -4
- package/lib/service-provider.js.map +1 -1
- package/lib/textencoder-polyfill.js +2 -1
- package/lib/textencoder-polyfill.js.map +1 -1
- package/lib/writable.d.ts +1 -1
- package/package.json +22 -21
- package/src/admin.ts +22 -13
- package/src/all-fle-types.ts +1 -1
- package/src/all-transport-types.ts +1 -1
- package/src/connect-info.spec.ts +72 -93
- package/src/connect-info.ts +15 -11
- package/src/index.ts +7 -4
- package/src/map-reduce-options.ts +12 -2
- package/src/printable-bson.spec.ts +61 -33
- package/src/printable-bson.ts +35 -22
- package/src/readable.ts +22 -12
- package/src/service-provider.ts +9 -5
- package/src/textencoder-polyfill.spec.ts +5 -3
- package/src/textencoder-polyfill.ts +4 -2
- package/src/writable.ts +35 -24
- package/tsconfig-lint.json +5 -0
- package/tsconfig.json +3 -7
- package/tsconfig.lint.json +0 -8
package/src/readable.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
ReadPreferenceFromOptions,
|
|
15
15
|
ReadPreferenceLike,
|
|
16
16
|
} from './all-transport-types';
|
|
17
|
-
import { ChangeStream, ChangeStreamOptions } from './all-transport-types';
|
|
17
|
+
import type { ChangeStream, ChangeStreamOptions } from './all-transport-types';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Interface for read operations in the CRUD specification.
|
|
@@ -36,7 +36,8 @@ export default interface Readable {
|
|
|
36
36
|
collection: string,
|
|
37
37
|
pipeline: Document[],
|
|
38
38
|
options?: AggregateOptions,
|
|
39
|
-
dbOptions?: DbOptions
|
|
39
|
+
dbOptions?: DbOptions
|
|
40
|
+
): AggregationCursor;
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* Run an aggregation pipeline on the DB.
|
|
@@ -74,7 +75,8 @@ export default interface Readable {
|
|
|
74
75
|
coll: string,
|
|
75
76
|
query?: Document,
|
|
76
77
|
options?: CountOptions,
|
|
77
|
-
dbOptions?: DbOptions
|
|
78
|
+
dbOptions?: DbOptions
|
|
79
|
+
): Promise<number>;
|
|
78
80
|
|
|
79
81
|
/**
|
|
80
82
|
* Get an exact document count from the collection.
|
|
@@ -92,7 +94,8 @@ export default interface Readable {
|
|
|
92
94
|
collection: string,
|
|
93
95
|
filter?: Document,
|
|
94
96
|
options?: CountDocumentsOptions,
|
|
95
|
-
dbOptions?: DbOptions
|
|
97
|
+
dbOptions?: DbOptions
|
|
98
|
+
): Promise<number>;
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
101
|
* Get distinct values for the field.
|
|
@@ -112,7 +115,8 @@ export default interface Readable {
|
|
|
112
115
|
fieldName: string,
|
|
113
116
|
filter?: Document,
|
|
114
117
|
options?: DistinctOptions,
|
|
115
|
-
dbOptions?: DbOptions
|
|
118
|
+
dbOptions?: DbOptions
|
|
119
|
+
): Promise<Document>;
|
|
116
120
|
|
|
117
121
|
/**
|
|
118
122
|
* Get an estimated document count from the collection.
|
|
@@ -128,7 +132,8 @@ export default interface Readable {
|
|
|
128
132
|
database: string,
|
|
129
133
|
collection: string,
|
|
130
134
|
options?: EstimatedDocumentCountOptions,
|
|
131
|
-
dbOptions?: DbOptions
|
|
135
|
+
dbOptions?: DbOptions
|
|
136
|
+
): Promise<number>;
|
|
132
137
|
|
|
133
138
|
/**
|
|
134
139
|
* Find documents in the collection.
|
|
@@ -146,7 +151,8 @@ export default interface Readable {
|
|
|
146
151
|
collection: string,
|
|
147
152
|
filter?: Document,
|
|
148
153
|
options?: FindOptions,
|
|
149
|
-
dbOptions?: DbOptions
|
|
154
|
+
dbOptions?: DbOptions
|
|
155
|
+
): FindCursor;
|
|
150
156
|
|
|
151
157
|
/**
|
|
152
158
|
* Get currently known topology information.
|
|
@@ -168,7 +174,8 @@ export default interface Readable {
|
|
|
168
174
|
database: string,
|
|
169
175
|
collection: string,
|
|
170
176
|
options: ListIndexesOptions,
|
|
171
|
-
dbOptions?: DbOptions
|
|
177
|
+
dbOptions?: DbOptions
|
|
178
|
+
): Promise<Document[]>;
|
|
172
179
|
|
|
173
180
|
/**
|
|
174
181
|
* Returns an array of collection infos
|
|
@@ -184,12 +191,15 @@ export default interface Readable {
|
|
|
184
191
|
database: string,
|
|
185
192
|
filter?: Document,
|
|
186
193
|
options?: ListCollectionsOptions,
|
|
187
|
-
dbOptions?: DbOptions
|
|
194
|
+
dbOptions?: DbOptions
|
|
195
|
+
): Promise<Document[]>;
|
|
188
196
|
|
|
189
197
|
/**
|
|
190
198
|
* Create a ReadPreference object from a set of options
|
|
191
199
|
*/
|
|
192
|
-
readPreferenceFromOptions(
|
|
200
|
+
readPreferenceFromOptions(
|
|
201
|
+
options?: Omit<ReadPreferenceFromOptions, 'session'>
|
|
202
|
+
): ReadPreferenceLike | undefined;
|
|
193
203
|
|
|
194
204
|
/**
|
|
195
205
|
* Start a change stream cursor on either the client, db, or collection.
|
|
@@ -224,6 +234,6 @@ export default interface Readable {
|
|
|
224
234
|
indexName?: string,
|
|
225
235
|
// TODO(MONGOSH-1471): use ListSearchIndexesOptions once available
|
|
226
236
|
options?: Document,
|
|
227
|
-
dbOptions?: DbOptions
|
|
237
|
+
dbOptions?: DbOptions
|
|
238
|
+
): Promise<Document[]>;
|
|
228
239
|
}
|
|
229
|
-
|
package/src/service-provider.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { MongoshInternalError } from '@mongosh/errors';
|
|
2
|
-
import Admin from './admin';
|
|
3
|
-
import Closable from './closable';
|
|
2
|
+
import type Admin from './admin';
|
|
3
|
+
import type Closable from './closable';
|
|
4
4
|
import makePrintableBson from './printable-bson';
|
|
5
|
-
import Readable from './readable';
|
|
6
|
-
import Writable from './writable';
|
|
5
|
+
import type Readable from './readable';
|
|
6
|
+
import type Writable from './writable';
|
|
7
7
|
import type { bson as BSON } from './index';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Interface for all service providers.
|
|
11
11
|
*/
|
|
12
|
-
export default interface ServiceProvider
|
|
12
|
+
export default interface ServiceProvider
|
|
13
|
+
extends Readable,
|
|
14
|
+
Writable,
|
|
15
|
+
Closable,
|
|
16
|
+
Admin {}
|
|
13
17
|
|
|
14
18
|
export class ServiceProviderCore {
|
|
15
19
|
public bsonLibrary: typeof BSON;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { textEncodingPolyfill } from './textencoder-polyfill';
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
|
|
4
|
-
describe('TextDecoder/TextEncoder polyfill', ()
|
|
5
|
-
it('does simplistic UTF-8 encoding/decoding', ()
|
|
4
|
+
describe('TextDecoder/TextEncoder polyfill', function () {
|
|
5
|
+
it('does simplistic UTF-8 encoding/decoding', function () {
|
|
6
6
|
const { TextEncoder, TextDecoder } = textEncodingPolyfill();
|
|
7
7
|
// This test was written in winter.
|
|
8
8
|
const str = '☃️';
|
|
9
|
-
expect(new TextDecoder().decode(new TextEncoder().encode(str))).to.equal(
|
|
9
|
+
expect(new TextDecoder().decode(new TextEncoder().encode(str))).to.equal(
|
|
10
|
+
str
|
|
11
|
+
);
|
|
10
12
|
});
|
|
11
13
|
});
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
if (
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
typeof TextDecoder !== 'function' ||
|
|
8
|
+
typeof TextDecoder !== 'function' ||
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
typeof TextEncoder !== 'function'
|
|
9
12
|
) {
|
|
10
|
-
// eslint-disable-next-line no-new-func
|
|
11
13
|
Object.assign(Function('return this')(), textEncodingPolyfill());
|
|
12
14
|
}
|
|
13
15
|
|
package/src/writable.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunCommandCursor, RunCursorCommandOptions } from 'mongodb';
|
|
1
|
+
import type { RunCommandCursor, RunCursorCommandOptions } from 'mongodb';
|
|
2
2
|
import type {
|
|
3
3
|
Document,
|
|
4
4
|
InsertOneOptions,
|
|
@@ -23,14 +23,13 @@ import type {
|
|
|
23
23
|
RunCommandOptions,
|
|
24
24
|
DbOptions,
|
|
25
25
|
OrderedBulkOperation,
|
|
26
|
-
UnorderedBulkOperation
|
|
26
|
+
UnorderedBulkOperation,
|
|
27
27
|
} from './all-transport-types';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Interface for write operations in the CRUD specification.
|
|
31
31
|
*/
|
|
32
32
|
export default interface Writable {
|
|
33
|
-
|
|
34
33
|
/**
|
|
35
34
|
* @param {String} db - the db name
|
|
36
35
|
* @param spec
|
|
@@ -104,7 +103,8 @@ export default interface Writable {
|
|
|
104
103
|
collection: string,
|
|
105
104
|
requests: AnyBulkWriteOperation[],
|
|
106
105
|
options: BulkWriteOptions,
|
|
107
|
-
dbOptions?: DbOptions
|
|
106
|
+
dbOptions?: DbOptions
|
|
107
|
+
): Promise<BulkWriteResult>;
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Delete multiple documents from the collection.
|
|
@@ -122,7 +122,8 @@ export default interface Writable {
|
|
|
122
122
|
collection: string,
|
|
123
123
|
filter: Document,
|
|
124
124
|
options: DeleteOptions,
|
|
125
|
-
dbOptions?: DbOptions
|
|
125
|
+
dbOptions?: DbOptions
|
|
126
|
+
): Promise<DeleteResult>;
|
|
126
127
|
|
|
127
128
|
/**
|
|
128
129
|
* Delete one document from the collection.
|
|
@@ -140,7 +141,8 @@ export default interface Writable {
|
|
|
140
141
|
collection: string,
|
|
141
142
|
filter: Document,
|
|
142
143
|
options: DeleteOptions,
|
|
143
|
-
dbOptions?: DbOptions
|
|
144
|
+
dbOptions?: DbOptions
|
|
145
|
+
): Promise<DeleteResult>;
|
|
144
146
|
|
|
145
147
|
/**
|
|
146
148
|
* Find one document and delete it.
|
|
@@ -158,7 +160,8 @@ export default interface Writable {
|
|
|
158
160
|
collection: string,
|
|
159
161
|
filter: Document,
|
|
160
162
|
options: FindOneAndDeleteOptions,
|
|
161
|
-
dbOptions?: DbOptions
|
|
163
|
+
dbOptions?: DbOptions
|
|
164
|
+
): Promise<Document>;
|
|
162
165
|
|
|
163
166
|
/**
|
|
164
167
|
* Find one document and replace it.
|
|
@@ -178,7 +181,8 @@ export default interface Writable {
|
|
|
178
181
|
filter: Document,
|
|
179
182
|
replacement: Document,
|
|
180
183
|
options: FindOneAndReplaceOptions,
|
|
181
|
-
dbOptions?: DbOptions
|
|
184
|
+
dbOptions?: DbOptions
|
|
185
|
+
): Promise<Document>;
|
|
182
186
|
|
|
183
187
|
/**
|
|
184
188
|
* Find one document and update it.
|
|
@@ -198,7 +202,8 @@ export default interface Writable {
|
|
|
198
202
|
filter: Document,
|
|
199
203
|
update: Document | Document[],
|
|
200
204
|
options: FindOneAndUpdateOptions,
|
|
201
|
-
dbOptions?: DbOptions
|
|
205
|
+
dbOptions?: DbOptions
|
|
206
|
+
): Promise<Document>;
|
|
202
207
|
|
|
203
208
|
/**
|
|
204
209
|
* Insert many documents into the colleciton.
|
|
@@ -216,7 +221,8 @@ export default interface Writable {
|
|
|
216
221
|
collection: string,
|
|
217
222
|
docs: Document[],
|
|
218
223
|
options: BulkWriteOptions,
|
|
219
|
-
dbOptions?: DbOptions
|
|
224
|
+
dbOptions?: DbOptions
|
|
225
|
+
): Promise<InsertManyResult>;
|
|
220
226
|
|
|
221
227
|
/**
|
|
222
228
|
* Insert one document into the collection.
|
|
@@ -234,7 +240,8 @@ export default interface Writable {
|
|
|
234
240
|
collection: string,
|
|
235
241
|
doc: Document,
|
|
236
242
|
options: InsertOneOptions,
|
|
237
|
-
dbOptions?: DbOptions
|
|
243
|
+
dbOptions?: DbOptions
|
|
244
|
+
): Promise<InsertOneResult>;
|
|
238
245
|
|
|
239
246
|
/**
|
|
240
247
|
* Replace a document with another.
|
|
@@ -254,7 +261,8 @@ export default interface Writable {
|
|
|
254
261
|
filter: Document,
|
|
255
262
|
replacement: Document,
|
|
256
263
|
options?: ReplaceOptions,
|
|
257
|
-
dbOptions?: DbOptions
|
|
264
|
+
dbOptions?: DbOptions
|
|
265
|
+
): Promise<UpdateResult>;
|
|
258
266
|
|
|
259
267
|
/**
|
|
260
268
|
* Update many document.
|
|
@@ -274,7 +282,8 @@ export default interface Writable {
|
|
|
274
282
|
filter: Document,
|
|
275
283
|
update: Document,
|
|
276
284
|
options?: UpdateOptions,
|
|
277
|
-
dbOptions?: DbOptions
|
|
285
|
+
dbOptions?: DbOptions
|
|
286
|
+
): Promise<UpdateResult>;
|
|
278
287
|
|
|
279
288
|
/**
|
|
280
289
|
* Update a document.
|
|
@@ -294,7 +303,8 @@ export default interface Writable {
|
|
|
294
303
|
filter: Document,
|
|
295
304
|
update: Document,
|
|
296
305
|
options?: UpdateOptions,
|
|
297
|
-
dbOptions?: DbOptions
|
|
306
|
+
dbOptions?: DbOptions
|
|
307
|
+
): Promise<UpdateResult>;
|
|
298
308
|
|
|
299
309
|
/**
|
|
300
310
|
* Adds new indexes to a collection.
|
|
@@ -311,7 +321,8 @@ export default interface Writable {
|
|
|
311
321
|
collection: string,
|
|
312
322
|
indexSpecs: Document[],
|
|
313
323
|
options?: CreateIndexesOptions,
|
|
314
|
-
dbOptions?: DbOptions
|
|
324
|
+
dbOptions?: DbOptions
|
|
325
|
+
): Promise<string[]>;
|
|
315
326
|
|
|
316
327
|
/**
|
|
317
328
|
* Drops a collection.
|
|
@@ -342,7 +353,8 @@ export default interface Writable {
|
|
|
342
353
|
oldName: string,
|
|
343
354
|
newName: string,
|
|
344
355
|
options?: RenameOptions,
|
|
345
|
-
dbOptions?: DbOptions
|
|
356
|
+
dbOptions?: DbOptions
|
|
357
|
+
): Promise<Collection>;
|
|
346
358
|
|
|
347
359
|
/**
|
|
348
360
|
* Initialize a bulk operation.
|
|
@@ -368,14 +380,14 @@ export default interface Writable {
|
|
|
368
380
|
* @param {String} collection - The collection name.
|
|
369
381
|
* @param {Object[]} descriptions - The specs of the indexes to be created.
|
|
370
382
|
* @param {DbOptions} dbOptions - The database options
|
|
371
|
-
|
|
383
|
+
*/
|
|
372
384
|
createSearchIndexes(
|
|
373
385
|
database: string,
|
|
374
386
|
collection: string,
|
|
375
387
|
// TODO(MONGOSH-1471): use SearchIndexDescription[] once available
|
|
376
|
-
specs: {name: string
|
|
388
|
+
specs: { name: string; definition: Document }[],
|
|
377
389
|
dbOptions?: DbOptions
|
|
378
|
-
): Promise<string[]
|
|
390
|
+
): Promise<string[]>;
|
|
379
391
|
|
|
380
392
|
/**
|
|
381
393
|
* Drops a search index.
|
|
@@ -384,13 +396,13 @@ export default interface Writable {
|
|
|
384
396
|
* @param {String} collection - The collection name.
|
|
385
397
|
* @param {String} indexName - The index name
|
|
386
398
|
* @param {DbOptions} dbOptions - The database options
|
|
387
|
-
|
|
399
|
+
*/
|
|
388
400
|
dropSearchIndex(
|
|
389
401
|
database: string,
|
|
390
402
|
collection: string,
|
|
391
403
|
index: string,
|
|
392
404
|
dbOptions?: DbOptions
|
|
393
|
-
): Promise<void
|
|
405
|
+
): Promise<void>;
|
|
394
406
|
|
|
395
407
|
/**
|
|
396
408
|
* Update a search index.
|
|
@@ -400,7 +412,7 @@ export default interface Writable {
|
|
|
400
412
|
* @param {String} indexName - The index name.
|
|
401
413
|
* @param {Object} description - The update.
|
|
402
414
|
* @param {DbOptions} dbOptions - The database options
|
|
403
|
-
|
|
415
|
+
*/
|
|
404
416
|
updateSearchIndex(
|
|
405
417
|
database: string,
|
|
406
418
|
collection: string,
|
|
@@ -408,6 +420,5 @@ export default interface Writable {
|
|
|
408
420
|
// TODO(MONGOSH-1471): use SearchIndexDescription once available
|
|
409
421
|
definition: Document,
|
|
410
422
|
dbOptions?: DbOptions
|
|
411
|
-
): Promise<void
|
|
423
|
+
): Promise<void>;
|
|
412
424
|
}
|
|
413
|
-
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "@mongodb-js/tsconfig-mongosh/tsconfig.common.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "./lib"
|
|
5
5
|
},
|
|
6
|
-
"include": [
|
|
7
|
-
|
|
8
|
-
],
|
|
9
|
-
"exclude": [
|
|
10
|
-
"./src/**/*.spec.*"
|
|
11
|
-
]
|
|
6
|
+
"include": ["src/**/*"],
|
|
7
|
+
"exclude": ["./src/**/*.spec.*"]
|
|
12
8
|
}
|