<commit_before>/* globals Query, Panel, Select, Input*/
'use strict'

let Aggregate = {}

Aggregate.name = 'aggregate'

Query.registerMode(Aggregate)

/**
 * Valid operation types
 * @property {Object<Object>}
 */
Aggregate.operatorTypes = {
	object: {
		prefix: '{',
		posfix: '}',
		getValue(input) {
			return Panel.processJSInEl(input, false, true)
		}
	},
	uint: {
		getValue(input) {
			return Number(input.value)
		}
	},
	field: {
		prefix: '\'$',
		posfix: '\'',
		getValue(input) {
			return '$' + input.value
		}
	},
	optionalObject: {
		prefix: '{',
		posfix: '}',
		mayBeEmpty: true,
		getValue(input) {
			return Aggregate.operatorTypes.object.getValue(input) || {}
		}
	},
	string: {
		prefix: '\'',
		posfix: '\'',
		getValue(input) {
			return input.value
		}
	},
	expression: {
		prefix: '',
		posfix: '',
		getValue(input) {
			return Panel.processJSInEl(input, false, false)
		}
	}
}

/**
 * Valid operations
 * A map from operation name to operator type and default placeholder
 * @property {Object<Array<string>>}
 */
Aggregate.operators = {
	addFields: ['object', '<newField>: <expression>, ...'],
	bucket: ['object', 'groupBy: <expression>, boundaries: [<lowerBound>, ...], default: <literal>, output: {<field>: {<accumulator>: <expression>}, ...}'],
	bucketAuto: ['object', 'groupBy: <expression>, buckets: <number>, output: {<field>: {<accumulator>: <expression>}, ...}, granularity: <string>'],
	collStats: ['object', 'latencyStats: {histograms: <boolean>}, storageStats: {}, count: {}'],
	count: ['string', '<outputField>'],
	currOp: ['object', 'allUsers: <boolean>, idleConnections: <boolean>'],
	facet: ['object', '<outputField>: [<stage>, ...], ...'],
	geoNear: ['object', '<options>'],
	graphLookup: ['object', 'from: <collection>, startWith: <expression>, connectFromField: <string>, connectToField: <string>, as: <string>, maxDepth: <number>, depthField: <string>, restrictSearchWithMatch: <document>'],
	group: ['object', '_id: <expression>, <field>: {<accumulator>: <expression>}, ...'],
	indexStats: ['optionalObject', ''],
	limit: ['uint', ''],
	listLocalSessions: ['optionalObject', ''],
	listSessions: ['optionalObject', ''],
	lookup: ['object', 'from: <collection>, localField: <string>, foreignField: <string>, as: <string>'],
	'lookup (join)': ['object', 'from: <collection>, let: {<var>: <expression>, ...}, pipeline: [<stage>, ...], as: <string>'],
	match: ['object', '<query>'],
	project: ['object', '<specification(s)>'],
	redact: ['object', '<expression>'],
	replaceRoot: ['object', 'newRoot: <replacementDocument>'],
	sample: ['object', 'size: <number>'],
	skip: ['uint', ''],
	sort: ['object', '<field>: <order>, ...'],
	sortByCount: ['expression', '<expression>'],
	unwind: ['field', ''],
	'unwind (object)': ['object', 'path: <path>, includeArrayIndex: <string>, preserveNullAndEmptyArrays: <boolean>']
}

/**
 * @typedef {Object} Stage
 * @property {HTMLElement} el<commit_msg>Change placeholder text in Aggregate so that double click select them<commit_after>/* globals Query, Panel, Select, Input*/
'use strict'

let Aggregate = {}

Aggregate.name = 'aggregate'

Query.registerMode(Aggregate)

/**
 * Valid operation types
 * @property {Object<Object>}
 */
Aggregate.operatorTypes = {
	object: {
		prefix: '{',
		posfix: '}',
		getValue(input) {
			return Panel.processJSInEl(input, false, true)
		}
	},
	uint: {
		getValue(input) {
			return Number(input.value)
		}
	},
	field: {
		prefix: '\'$',
		posfix: '\'',
		getValue(input) {
			return '$' + input.value
		}
	},
	optionalObject: {
		prefix: '{',
		posfix: '}',
		mayBeEmpty: true,
		getValue(input) {
			return Aggregate.operatorTypes.object.getValue(input) || {}
		}
	},
	string: {
		prefix: '\'',
		posfix: '\'',
		getValue(input) {
			return input.value
		}
	},
	expression: {
		prefix: '',
		posfix: '',
		getValue(input) {
			return Panel.processJSInEl(input, false, false)
		}
	}
}

/**
 * Valid operations
 * A map from operation name to operator type and default placeholder
 * @property {Object<Array<string>>}
 */
Aggregate.operators = {
	addFields: ['object', '_newField_: _expression_, _etc_'],
	bucket: ['object', 'groupBy: _expression_, boundaries: [_lowerBound_, _etc_], default: _literal_, output: {_field_: {_accumulator_: _expression_}, _etc_}'],
	bucketAuto: ['object', 'groupBy: _expression_, buckets: _number_, output: {_field_: {_accumulator_: _expression_}, _etc_}, granularity: _string_'],
	collStats: ['object', 'latencyStats: {histograms: _boolean_}, storageStats: {}, count: {}'],
	count: ['string', '_outputField_'],
	currOp: ['object', 'allUsers: _boolean_, idleConnections: _boolean_'],
	facet: ['object', '_outputField_: [_stage_, _etc_], _etc_'],
	geoNear: ['object', '_options_'],
	graphLookup: ['object', 'from: _collection_, startWith: _expression_, connectFromField: _string_, connectToField: _string_, as: _string_, maxDepth: _number_, depthField: _string_, restrictSearchWithMatch: _document_'],
	group: ['object', '_id: _expression_, _field_: {_accumulator_: _expression_}, _etc_'],
	indexStats: ['optionalObject', ''],
	limit: ['uint', ''],
	listLocalSessions: ['optionalObject', ''],
	listSessions: ['optionalObject', ''],
	lookup: ['object', 'from: _collection_, localField: _string_, foreignField: _string_, as: _string_'],
	'lookup (join)': ['object', 'from: _collection_, let: {_var_: _expression_, _etc_}, pipeline: [_stage_, _etc_], as: _string_'],
	match: ['object', '_query_'],
	project: ['object', '_specification(s)_'],
	redact: ['object', '_expression_'],
	replaceRoot: ['object', 'newRoot: _replacementDocument_'],
	sample: ['object', 'size: _number_'],
	skip: ['uint', ''],
	sort: ['object', '_field_: _order_, _etc_'],
	sortByCount: ['expression', '_expression_'],
	unwind: ['field', ''],
	'unwind (object)': ['object', 'path: _path_, includeArrayIndex: _string_, preserveNullAndEmptyArrays: _boolean_']
}

/**
 * @typedef {Object} Stage
 * @property {HTMLElement} el
{'fraction_non_alphanumeric': 0.20694304010785305, 'fraction_numerical': 0.0, 'mean_word_length': 5.4440825190010855, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4583383', 'n_tokens_mistral': 2063, 'n_tokens_neox': 1974, 'n_words': 467}