@mongosh/service-provider-server
Advanced tools
Comparing version 1.3.1 to 1.4.1
import { MongoClient, ReadPreference, ClientMetadata, ReadPreferenceFromOptions, ReadPreferenceLike, OperationOptions } from 'mongodb'; | ||
import { ServiceProvider, getConnectInfo, ReplPlatform, ServiceProviderCore, ShellAuthOptions, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult, ClientSessionOptions, CollStatsOptions, Collection, CountDocumentsOptions, CountOptions, CreateCollectionOptions, CreateIndexesOptions, FindCursor, Db, DbOptions, DeleteOptions, DeleteResult, DistinctOptions, Document, DropCollectionOptions, DropDatabaseOptions, EstimatedDocumentCountOptions, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, FindOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, ListCollectionsOptions, ListDatabasesOptions, ListIndexesOptions, MongoClientOptions, ReadConcern, RenameOptions, ReplaceOptions, RunCommandOptions, ClientSession, UpdateOptions, UpdateResult, WriteConcern, ChangeStreamOptions, ChangeStream, FLE, AutoEncryptionOptions } from '@mongosh/service-provider-core'; | ||
import { ServiceProvider, getConnectInfo, ReplPlatform, ServiceProviderCore, ShellAuthOptions, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult, ClientSessionOptions, Collection, CountDocumentsOptions, CountOptions, CreateCollectionOptions, CreateIndexesOptions, FindCursor, Db, DbOptions, DeleteOptions, DeleteResult, DistinctOptions, Document, DropCollectionOptions, DropDatabaseOptions, EstimatedDocumentCountOptions, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, FindOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, ListCollectionsOptions, ListDatabasesOptions, ListIndexesOptions, MongoClientOptions, ReadConcern, RenameOptions, ReplaceOptions, RunCommandOptions, ClientSession, UpdateOptions, UpdateResult, WriteConcern, ChangeStreamOptions, ChangeStream, FLE, AutoEncryptionOptions } from '@mongosh/service-provider-core'; | ||
import { DevtoolsConnectOptions } from '@mongodb-js/devtools-connect'; | ||
@@ -55,3 +55,2 @@ import type { MongoshBus } from '@mongosh/types'; | ||
insertOne(database: string, collection: string, doc?: Document, options?: InsertOneOptions, dbOptions?: DbOptions): Promise<InsertOneResult>; | ||
isCapped(database: string, collection: string, dbOptions?: DbOptions): Promise<boolean>; | ||
remove(database: string, collection: string, query?: Document, options?: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>; | ||
@@ -69,3 +68,2 @@ replaceOne(database: string, collection: string, filter?: Document, replacement?: Document, options?: ReplaceOptions, dbOptions?: DbOptions): Promise<UpdateResult>; | ||
listCollections(database: string, filter?: Document, options?: ListCollectionsOptions, dbOptions?: DbOptions): Promise<Document[]>; | ||
stats(database: string, collection: string, options?: CollStatsOptions, dbOptions?: DbOptions): Promise<Document>; | ||
dropCollection(database: string, collection: string, options?: DropCollectionOptions, dbOptions?: DbOptions): Promise<boolean>; | ||
@@ -72,0 +70,0 @@ authenticate(authDoc: ShellAuthOptions): Promise<{ |
@@ -58,2 +58,22 @@ "use strict"; | ||
this.fle = require('mongodb-client-encryption'); | ||
const origExtension = this.fle.extension; | ||
this.fle.extension = (mongodb) => { | ||
const exports = origExtension(mongodb); | ||
const OrigAutoEncrypter = exports.AutoEncrypter; | ||
exports.AutoEncrypter = class AutoEncrypter extends OrigAutoEncrypter { | ||
constructor(client, options) { | ||
super(client, options); | ||
if (options === null || options === void 0 ? void 0 : options.bypassQueryAnalysis) { | ||
this._bypassQueryAnalysis = true; | ||
} | ||
} | ||
init(callback) { | ||
if (this._bypassQueryAnalysis) { | ||
return callback(); | ||
} | ||
super.init(callback); | ||
} | ||
}; | ||
return exports; | ||
}; | ||
} | ||
@@ -252,5 +272,2 @@ catch (_a) { } | ||
} | ||
isCapped(database, collection, dbOptions) { | ||
return this.db(database, dbOptions).collection(collection).isCapped(); | ||
} | ||
remove(database, collection, query = {}, options = {}, dbOptions) { | ||
@@ -322,8 +339,2 @@ options = { ...this.baseCmdOptions, ...options }; | ||
} | ||
async stats(database, collection, options = {}, dbOptions) { | ||
options = { ...this.baseCmdOptions, ...options }; | ||
return await this.db(database, dbOptions) | ||
.collection(collection) | ||
.stats(options); | ||
} | ||
async dropCollection(database, collection, options = {}, dbOptions) { | ||
@@ -330,0 +341,0 @@ return this.db(database, dbOptions) |
@@ -1,4 +0,3 @@ | ||
import CliServiceProvider, { DevtoolsConnectOptions } from './cli-service-provider'; | ||
import CliServiceProvider from './cli-service-provider'; | ||
import CompassServiceProvider from './compass/compass-service-provider'; | ||
import { DEFAULT_DB, CliOptions, generateUri, MongoClientOptions } from '@mongosh/service-provider-core'; | ||
export { CliServiceProvider, CompassServiceProvider, DEFAULT_DB, CliOptions, generateUri, MongoClientOptions, DevtoolsConnectOptions }; | ||
export { CliServiceProvider, CompassServiceProvider }; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateUri = exports.DEFAULT_DB = exports.CompassServiceProvider = exports.CliServiceProvider = void 0; | ||
exports.CompassServiceProvider = exports.CliServiceProvider = void 0; | ||
const cli_service_provider_1 = __importDefault(require("./cli-service-provider")); | ||
@@ -12,5 +12,2 @@ exports.CliServiceProvider = cli_service_provider_1.default; | ||
exports.CompassServiceProvider = compass_service_provider_1.default; | ||
const service_provider_core_1 = require("@mongosh/service-provider-core"); | ||
Object.defineProperty(exports, "DEFAULT_DB", { enumerable: true, get: function () { return service_provider_core_1.DEFAULT_DB; } }); | ||
Object.defineProperty(exports, "generateUri", { enumerable: true, get: function () { return service_provider_core_1.generateUri; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -57,3 +57,3 @@ "use strict"; | ||
c.destroy({ force: true }); | ||
c.handleIssue({ destroy: new Error('connection canceled by force close') }); | ||
c.onError(new Error('connection canceled by force close')); | ||
} | ||
@@ -60,0 +60,0 @@ if (originalCallback) { |
{ | ||
"name": "@mongosh/service-provider-server", | ||
"version": "1.3.1", | ||
"version": "1.4.1", | ||
"description": "MongoDB Shell Server Service Provider Package", | ||
@@ -40,11 +40,27 @@ "main": "lib/index.js", | ||
}, | ||
"mongosh": { | ||
"ciRequiredOptionalDependencies": { | ||
"mongodb-client-encryption": [ | ||
"darwin", | ||
"linux", | ||
"win32" | ||
], | ||
"kerberos": [ | ||
"darwin", | ||
"linux", | ||
"win32" | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"@mongodb-js/devtools-connect": "^1.2.4", | ||
"@mongosh/errors": "1.3.1", | ||
"@mongosh/service-provider-core": "1.3.1", | ||
"@mongosh/types": "1.3.1", | ||
"@mongodb-js/devtools-connect": "^1.4.2", | ||
"@mongosh/errors": "1.4.1", | ||
"@mongosh/service-provider-core": "1.4.1", | ||
"@mongosh/types": "1.4.1", | ||
"@types/sinon-chai": "^3.2.3", | ||
"aws4": "^1.11.0", | ||
"mongodb": "^4.4.0", | ||
"mongodb-connection-string-url": "^2.3.2", | ||
"kerberos": "^2.0.0", | ||
"mongodb": "^4.6.0", | ||
"mongodb-client-encryption": "^2.2.0-alpha.0", | ||
"mongodb-connection-string-url": "^2.5.2", | ||
"saslprep": "mongodb-js/saslprep#v1.0.4" | ||
@@ -54,5 +70,5 @@ }, | ||
"kerberos": "^2.0.0", | ||
"mongodb-client-encryption": "^2.0.0" | ||
"mongodb-client-encryption": "^2.2.0-alpha.0" | ||
}, | ||
"gitHead": "29a1453899120580f7ee669ec5952810b86d11b7" | ||
"gitHead": "4e88ce238c93af5f2eb5ad9f9e3a2ac5ef1eb2e0" | ||
} |
@@ -5,2 +5,3 @@ import CliServiceProvider from './cli-service-provider'; | ||
import { MongoClient } from 'mongodb'; | ||
import type { Db } from 'mongodb'; | ||
import { startTestServer, skipIfServerVersion } from '../../../testing/integration-testing-hooks'; | ||
@@ -16,3 +17,3 @@ import { DbOptions, MongoClientOptions } from '@mongosh/service-provider-core'; | ||
let dbName: string; | ||
let db; | ||
let db: Db; | ||
let connectionString: string; | ||
@@ -410,16 +411,2 @@ let bus: EventEmitter; | ||
describe('#isCapped', () => { | ||
context('for regular collections', () => { | ||
let result; | ||
beforeEach(async() => { | ||
result = await serviceProvider.isCapped('music', 'bands'); | ||
}); | ||
it('returns false', () => { | ||
expect(result).to.equal(false); | ||
}); | ||
}); | ||
}); | ||
describe('#listDatabases', () => { | ||
@@ -611,28 +598,2 @@ let result; | ||
describe('stats', () => { | ||
it('returns collection stats', async() => { | ||
const collName = 'coll1'; | ||
await db.createCollection(collName); | ||
const stats = await serviceProvider.stats( | ||
dbName, | ||
collName | ||
); | ||
expect(Object.keys(stats)).to.contain.members([ | ||
'ns', | ||
'size', | ||
'count', | ||
'storageSize', | ||
'capped', | ||
'wiredTiger', | ||
'nindexes', | ||
'indexDetails', | ||
'totalIndexSize', | ||
'indexSizes', | ||
'ok' | ||
]); | ||
}); | ||
}); | ||
describe('#listCollections', () => { | ||
@@ -707,2 +668,49 @@ it('returns the list of collections', async() => { | ||
}); | ||
context('post-5.3', () => { | ||
skipIfServerVersion(testServer, '< 5.3'); | ||
it('allows clustered indexes on collections', async() => { | ||
await db.createCollection( | ||
'coll1', | ||
// TODO: Remove `any` usage once there is driver type support | ||
// for clustered collection indexes. NODE-4189 | ||
{ | ||
clusteredIndex: { | ||
key: { _id: 1 }, | ||
unique: true | ||
} | ||
} as any | ||
); | ||
const collections = await serviceProvider.listCollections(dbName, {}, {}); | ||
const matchingCollection = collections.find(collection => collection.name === 'coll1'); | ||
expect(matchingCollection).to.not.be.undefined; | ||
expect( | ||
matchingCollection.options | ||
).to.deep.contain({ | ||
clusteredIndex: { | ||
v: 2, | ||
key: { _id: 1 }, | ||
name: '_id_', | ||
unique: true | ||
} | ||
}); | ||
const indexes = await serviceProvider.getIndexes(dbName, 'coll1'); | ||
expect( | ||
indexes | ||
).to.deep.contain({ | ||
key: { | ||
_id: 1 | ||
}, | ||
name: '_id_', | ||
v: 2, | ||
clustered: true, | ||
unique: true | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -709,0 +717,0 @@ |
@@ -546,22 +546,2 @@ import { CommonErrors } from '@mongosh/errors'; | ||
describe('#stats', () => { | ||
let options; | ||
let expectedResult; | ||
beforeEach(() => { | ||
options = { ...DEFAULT_BASE_OPTS, scale: 1 }; | ||
expectedResult = { ok: 1 }; | ||
collectionStub = stubInterface<Collection>(); | ||
collectionStub.stats.resolves(expectedResult); | ||
serviceProvider = new CliServiceProvider(createClientStub(collectionStub), bus); | ||
}); | ||
it('executes the command against the database', async() => { | ||
const result = await serviceProvider.stats('db1', 'coll1', options); | ||
expect(result).to.deep.equal(expectedResult); | ||
expect(collectionStub.stats).to.have.been.calledWith(options); | ||
}); | ||
}); | ||
describe('#renameCollection', () => { | ||
@@ -568,0 +548,0 @@ let dbStub: StubbedInstance<Db>; |
@@ -39,3 +39,2 @@ import { | ||
ClientSessionOptions, | ||
CollStatsOptions, | ||
Collection, | ||
@@ -218,2 +217,31 @@ CountDocumentsOptions, | ||
this.fle = require('mongodb-client-encryption'); | ||
// Monkey-patch to work around missing NODE-4242 | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
const origExtension = this.fle.extension; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.fle.extension = (mongodb) => { | ||
const exports = origExtension(mongodb); | ||
const OrigAutoEncrypter = exports.AutoEncrypter; | ||
exports.AutoEncrypter = class AutoEncrypter extends OrigAutoEncrypter { | ||
_bypassQueryAnalysis?: boolean; | ||
constructor(client: any, options: any) { | ||
super(client, options); | ||
if (options?.bypassQueryAnalysis) { | ||
this._bypassQueryAnalysis = true; | ||
} | ||
} | ||
init(callback: any) { | ||
if (this._bypassQueryAnalysis) { | ||
return callback(); | ||
} | ||
super.init(callback); | ||
} | ||
}; | ||
return exports; | ||
}; | ||
} catch { /* not empty */ } | ||
@@ -737,17 +765,2 @@ } | ||
/** | ||
* Is the collection capped? | ||
* | ||
* @param {String} database - The database name. | ||
* @param {String} collection - The collection name. | ||
* @param dbOptions | ||
* @returns {Promise} The promise of the result. | ||
*/ | ||
isCapped( | ||
database: string, | ||
collection: string, | ||
dbOptions?: DbOptions): Promise<boolean> { | ||
return this.db(database, dbOptions).collection(collection).isCapped(); | ||
} | ||
/** | ||
* Deprecated remove command. | ||
@@ -1014,22 +1027,2 @@ * | ||
/** | ||
* Get all the collection statistics. | ||
* | ||
* @param {String} database - The db name. | ||
* @param {String} collection - The collection name. | ||
* @param {Object} options - The count options. | ||
* @param {Object} dbOptions - The database options | ||
* @return {Promise} returns Promise | ||
*/ | ||
async stats( | ||
database: string, | ||
collection: string, | ||
options: CollStatsOptions = {}, | ||
dbOptions?: DbOptions): Promise<Document> { | ||
options = { ...this.baseCmdOptions, ...options }; | ||
return await this.db(database, dbOptions) | ||
.collection(collection) | ||
.stats(options as { scale: 1 }); | ||
} | ||
/** | ||
* Drops a the collection. | ||
@@ -1052,3 +1045,3 @@ * | ||
.collection(collection) | ||
.drop({ ...this.baseCmdOptions, ...options } as DropCollectionOptions); | ||
.drop({ ...this.baseCmdOptions, ...options }); | ||
} | ||
@@ -1055,0 +1048,0 @@ |
@@ -1,12 +0,6 @@ | ||
import CliServiceProvider, { DevtoolsConnectOptions } from './cli-service-provider'; | ||
import CliServiceProvider from './cli-service-provider'; | ||
import CompassServiceProvider from './compass/compass-service-provider'; | ||
import { DEFAULT_DB, CliOptions, generateUri, MongoClientOptions } from '@mongosh/service-provider-core'; | ||
export { | ||
CliServiceProvider, | ||
CompassServiceProvider, | ||
DEFAULT_DB, | ||
CliOptions, | ||
generateUri, | ||
MongoClientOptions, | ||
DevtoolsConnectOptions | ||
CompassServiceProvider | ||
}; |
@@ -79,3 +79,3 @@ import { MongoshInternalError } from '@mongosh/errors'; | ||
// supposed to destroy the connection (which is a no-op at this point). | ||
c.handleIssue({ destroy: new Error('connection canceled by force close') }); | ||
c.onError(new Error('connection canceled by force close')); | ||
} | ||
@@ -82,0 +82,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152737
13
3092
+ Addedkerberos@^2.0.0
+ Added@mongosh/errors@1.4.1(transitive)
+ Added@mongosh/service-provider-core@1.4.1(transitive)
+ Added@mongosh/types@1.4.1(transitive)
- Removed@mongosh/errors@1.3.1(transitive)
- Removed@mongosh/i18n@1.3.1(transitive)
- Removed@mongosh/service-provider-core@1.3.1(transitive)
- Removed@mongosh/types@1.3.1(transitive)
- Removedmustache@4.2.0(transitive)
Updated@mongosh/errors@1.4.1
Updated@mongosh/types@1.4.1
Updatedmongodb@^4.6.0