
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.
aql-builder
Advanced tools
A simple dynamic query-builder for ArangoDB, written in Typescript.
npm i --save aql-builder
AQL Builder consists of a small cluster of types, and a helper class to make using them easier.
AqQuery, a JSON structure that describes a complete AQL queryAqProperty, a JSON structure that describes a single property or attribute of an Arango documentAqFilter, AqAggregate, and AqSort; all subtypes of AqPropertybuildQuery, a function that turns an AqQuery JSON object into a GeneratedAqlQuery that can be run via arangojsAqBuilder, a class that lets you build an AqQuery using chainable helper methods.import { AqBuilder } from 'aql-builder';
const aqlQuery = new AqBuilder('responses')
.filterBy('url.protocol') // Defaults to '!= null'
.filterBy('url.domain', ['example.com', 'test.com'])
.groupBy('status')
.groupBy('mime')
.count('total')
.filterBy('status', [200, 404])
.sortBy('total', 'desc')
.build();
console.log(aqlQuery);
// GeneratedAqlQuery
//
// query: 'FOR item IN responses\n' +
// 'FILTER item.url.protocol != @value0\n' +
// 'FILTER item.url.domain IN @value1\n' +
// 'COLLECT\n' +
// ' status = item.status,\n' +
// ' mime = item.mime\n' +
// 'WITH COUNT INTO total\n' +
// 'FILTER status IN @value2\n' +
// 'SORT total DESC\n' +
// 'RETURN { status, mime, total }',
// bindVars: {
// value0: null,
// value1: [ 'example.com', 'test.com' ],
// value2: [ 200, 404 ]
// }
//}
Queries can also be described in JSON and passed straight to the builder function; the structure below generates a query identical to the chained method approach above.
import { AqQuery, buildQuery } from 'aql-builder';
const aq: AqQuery = {
collection: 'responses',
filters: [
{ name: 'url.protocol', eq: null, negate: true },
{ name: 'url.domain', in: ['example.com', 'test.com'] },
{ name: 'status', in: [200, 404], document: false },
],
aggregates: [
{ name: 'status', function: 'collect' },
{ name: 'mime', function: 'collect' },
],
count: 'total',
sorts: [
{ name: 'total', direction: 'desc' },
],
};
const aqlQuery = buildQuery(aq);
Finally, the AqQuery structure supports shorthand versions of common filter, aggregate, sort, and return definitions. For example, return: [{ name: 'prop.name' }] can be written as return: ['prop.name']. These shorthand versions can be mixed and matched as needed.
import { AqQuery, buildQuery } from 'aql-builder';
const aq: AqQuery = {
collection: 'responses',
filters: [
'url.protocol', // Expanded to 'equals null, negated' filter
{ name: 'url.domain', in: ['example.com', 'test.com'] },
{ name: 'status', in: [200, 404], documemt: false },
],
aggregates: ['status', 'mime'], // Expanded to 'collect' aggregates
count: 'total',
sorts: ['total'] // Expanded to 'desc' sorts
};
const aqlQuery = buildQuery(aq);
AqBuilder can be instantiated with an existing AqQuery object; that makes it possible to store a reusable query in JSON format, set up an AqBuilder instance with it, and customize the query with the builder object's chainable methods.
import { AqQuery, AqBuilder } from 'aql-builder';
const aq: AqQuery = {
collection: 'responses',
filters: [
'url.protocol',
{ name: 'url.domain', in: ['example.com', 'test.com'] },
{ name: 'status', in: [200, 404], documemt: false },
],
aggregates: ['status', 'mime'],
count: 'total'
};
const query = new AqBuilder(aq)
.sort('total', 'asc')
.build();
Although the fluent methods on the AqBuilder class are handy, some types of query structures are only supported with manually-created AqQuery objects:
Examples can be found in INTERNALS.md.
As noted above, the AqBuilder class doesn't support the full range of features that are possible with AqQuery, and AqQuery only supports a subset of the full AQL spec. In particular:
filters and returnFilters that run after aggregation.FAQs
Dynamic query-builder for ArangoDB
The npm package aql-builder receives a total of 59 weekly downloads. As such, aql-builder popularity was classified as not popular.
We found that aql-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.