
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@mongodb-js/compass-aggregations
Advanced tools
Compass Plugin for the MongoDB Aggregation Pipeline Builder.
src/components/aggregations The primary export is connected componentsrc/modules/ is where action happens
ducks patternsrc/stores/store is where plugin listens+responds to events of interest from other pluginsconfigureStore()src/*/<module>.spec.jsHow does clicking on export to language button in aggregation builder show the modal that has code in it?
The aggregation builder in Compass actually involves 2 Compass plugins:
<Aggregation /> Plugin for primary UI<ExportToLanguage /> Modal plugin that connects <Aggregation /> to bson-transpilers for actual compiling to another languageHere's how these 2 plugins come together:
./src/modules/export-to-language.js appRegistry.emit('open-aggregation-export-to-language', generatePipelineAsString())compass-export-to-language/src/stores/store.js Listener for 'export to lang' event via appRegistry and renders its modal.compass-export-to-language/src/modules/export-query.js has reducer for calling bson-transpilers.compile() which populates the code in the modal dialog.mongodb-data-service ProviderSee ./examples-data-service-provider.js for details on what data-service functions are used and the applicable options for each.
If you're interested in helping with the Aggregation Builder plugin, we'd be over the moon excited! Here are a few ideas if you're interested but not sure where to start:
README'sjsdoc html to include in GitHub pages<ExportToLanguage /> Modal plugin that connects <Aggregation /> to bson-transpilers for actual compiling to another languagemongodb-js/stage-validator Aggregation Pipeline Stage grammar.bson-transpilers Read the amazing: Compiler in JavaScript using ANTLR@mongodb-js/compass-editor Reusable Compass editor component based on ace-editor with MongoDB-specific ace modes, themes, and autocompleters.This plugin uses an instance of a Redux store and not the traditional singleton, so the store instance must be passed to the plugin. The plugin exports a function to initialise the store instance, which decorates it with various methods to conveniently set any values it uses.
This is for:
@mongodb-js/compass-aggregations 4.0.0-beta.11@mongodb-js/compass-export-to-language 4.0.2Setting values via configure:
import AppRegistry from 'hadron-app-registry';
import AggregationsPlugin, {
configureStore as configureAggregationsStore
} from '@mongodb-js/compass-aggregations';
import ExportToLanguagePlugin, {
configureStore as configureExportToLanguageStore
} from '@mongodb-js/compass-export-to-language';
const handleOut = (namespace) => {
window.open(`https://cloud.mongodb.com/${namespace}`, '_new');
};
const handleCopy = (query) => {
alert(query);
};
const appRegistry = new AppRegistry();
const aggregationsStore = configureAggregationsStore({
dataProvider: {
error: null,
dataProvider: dataProvider
},
namespace: 'db.coll',
serverVersion: '4.2.0',
fields: [],
outResultsFn: handleOut,
env: 'atlas',
localAppRegistry: appRegistry
});
const exportToLanguageStore = configureExportToLanguageStore({
localAppRegistry: appRegistry,
copyToClipboardFn: handleCopy
});
<AggregationsPlugin store={aggregationsStore} />
<ExportToLanguagePlugin store={exportToLanguageStore} />
const role = appRegistry.getRole('Collection.Tab')[0];
const Plugin = role.component;
const configureStore = role.configureStore;
const store = configureStore({
globalAppRegistry: appRegistry,
localAppRegistry: localAppRegistry,
dataProvider: {
error: null,
dataProvider: dataProvider,
},
env: 'on-prem',
namespace: 'db.coll',
serverVersion: '4.2.0',
fields: [],
});
<Plugin store={store} />;
The fields array must be an array of objects that the ACE editor autocompleter understands. See This example for what that array looks like.
The data provider is an object that must adhere to the following interface:
/**
* Get a count of documents.
*
* @param {String} namespace - The namespace in "db.collection" format.
* @param {Object} filter - The MQL query filter.
* @param {Object} options - The query options.
* @param {Function} callback - Gets error and integer count as params.
*/
provider.count(namespace, filter, options, callback);
/**
* Execute an aggregation pipeline.
*
* @param {String} namespace - The namespace in "db.collection" format.
* @param {Array} pipeline - The pipeline.
* @param {Object} options - The agg options.
* @param {Function} callback - Gets error and cursor as params. Cursor must
* implement #toArray (which takes a callback with error and an array of result docs)
* and #close
*/
provider.aggregate(namespace, pipeline, options, callback);
Various actions within this plugin will emit events for other parts of the
application can be listened to via hadron-app-registry.
Local events are scoped to a Tab.
Global events are scoped to the whole Compass application.
Create View is to be opened.export-to-language was opened. source refers to the module it is opened
from, in this case Aggregations.Create View is successful, when
$merge are to be shown, when $out results are to be shown.metadata refers to information about the
pipeline.metadata refers to data about the pipeline. Sends pipeline data to metrics.$out. Sends pipeline data to metrics.export-to-language plugin is to opened. pipeline refers to the pipeline to
be exported.Create View is being opened.Create View is to be opened. Opens a Create View modal.refresh-dataopen-create-viewagg-pipeline-savedagg-pipeline-deletedagg-pipeline-executedagg-pipeline-out-executednpm run test
npm start
npm run analyze
npm i -S @mongodb-js/compass-aggregations
FAQs
Compass Aggregation Pipeline Builder
We found that @mongodb-js/compass-aggregations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 33 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.