From 8d10deade02d388268f0108d15a48349183fbbe9 Mon Sep 17 00:00:00 2001 From: Maurizio Casimirri Date: Tue, 3 Oct 2023 19:54:46 +0200 Subject: [PATCH] feat: remove useNewUrlParser and useUnifiedTopology from export to language COMPASS-4897 (#4837) * feat: remove useNewUrlParser and useUnifiedTopology COMPASS-4897 * fix spaces --- .../lib/symbol-table/pythontojavascript.js | 2 +- .../lib/symbol-table/shelltojavascript.js | 2 +- .../bson-transpilers/symbols/javascript/templates.yaml | 3 +-- packages/bson-transpilers/test/yaml/driver-syntax.yaml | 9 +++------ .../src/modules/transpiler.spec.ts | 6 ++---- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js b/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js index 7bb0ba8e967..ca335bab4cd 100644 --- a/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js +++ b/packages/bson-transpilers/lib/symbol-table/pythontojavascript.js @@ -1 +1 @@ -module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n# Javascript Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n DriverTemplate: &DriverTemplate !!js/function |\n (spec) => {\n const comment = `/*\n * Requires the MongoDB Node.js Driver\n * https://mongodb.github.io/node-mongodb-native\n */`;\n const translateKey = {\n project: 'projection'\n };\n\n let cmd;\n let defs;\n if ('aggregation' in spec) {\n const agg = spec.aggregation;\n cmd = `const cursor = coll.aggregate(agg);`;\n defs = `const agg = ${agg};\\n`;\n } else {\n let opts = '';\n const args = {};\n Object.keys(spec).forEach((k) => {\n if (k !== 'options') {\n args[k in translateKey ? translateKey[k] : k] = spec[k];\n }\n });\n\n if (Object.keys(args).length > 0) {\n defs = Object.keys(args).reduce((s, k) => {\n if (k !== 'filter') {\n if (opts === '') {\n opts = `${k}`;\n } else {\n opts = `${opts}, ${k}`;\n }\n }\n return `${s}const ${k} = ${args[k]};\\n`;\n }, '');\n opts = opts === '' ? '' : `, { ${opts} }`;\n }\n cmd = `const cursor = coll.find(filter${opts});`;\n }\n return `${comment}\\n\\n${defs}\n const client = await MongoClient.connect(\n '${spec.options.uri}',\n { useNewUrlParser: true, useUnifiedTopology: true }\n );\n const coll = client.db('${spec.options.database}').collection('${spec.options.collection}');\n ${cmd}\n const result = await cursor.toArray();\n await client.close();`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n } else if (op === '==' || op === '===' || op === 'is') {\n return `${lhs} === ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '!==';\n if (op.includes('!') || op.includes('not')) {\n str = '===';\n }\n return `${rhs}.indexOf(${lhs}) ${str} -1`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `Math.floor(${s}, ${rhs})`;\n case '**':\n return `Math.pow(${s}, ${rhs})`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Date.now, Decimal128/NumberDecimal, Long/NumberLong]\n noNew = [200.1, 112, 106];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])}: ${arg[1]}`;\n }).join(', ');\n\n return `{${pairs}${closingIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.sub_type`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.db`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.namespace`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.oid`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongEqualsTemplate: &LongEqualsTemplate null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate null\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate null\n LongAddTemplate: &LongAddTemplate null\n LongAddArgsTemplate: &LongAddArgsTemplate null\n LongSubtractTemplate: &LongSubtractTemplate null\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate null\n LongMultiplyTemplate: &LongMultiplyTemplate null\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate null\n LongDivTemplate: &LongDivTemplate null\n LongDivArgsTemplate: &LongDivArgsTemplate null\n LongModuloTemplate: &LongModuloTemplate null\n LongModuloArgsTemplate: &LongModuloArgsTemplate null\n LongAndTemplate: &LongAndTemplate null\n LongAndArgsTemplate: &LongAndArgsTemplate null\n LongOrTemplate: &LongOrTemplate null\n LongOrArgsTemplate: &LongOrArgsTemplate null\n LongXorTemplate: &LongXorTemplate null\n LongXorArgsTemplate: &LongXorArgsTemplate null\n LongShiftLeftTemplate: &LongShiftLeftTemplate null\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate null\n LongShiftRightTemplate: &LongShiftRightTemplate null\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate null\n LongCompareTemplate: &LongCompareTemplate null\n LongCompareArgsTemplate: &LongCompareArgsTemplate null\n LongIsOddTemplate: &LongIsOddTemplate null\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate null\n LongIsZeroTemplate: &LongIsZeroTemplate null\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate null\n LongIsNegativeTemplate: &LongIsNegativeTemplate null\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate null\n LongNegateTemplate: &LongNegateTemplate null\n LongNegateArgsTemplate: &LongNegateArgsTemplate null\n LongNotTemplate: &LongNotTemplate null\n LongNotArgsTemplate: &LongNotArgsTemplate null\n LongNotEqualsTemplate: &LongNotEqualsTemplate null\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate null\n LongGreaterThanTemplate: &LongGreaterThanTemplate null\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate null\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate null\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate null\n LongLessThanTemplate: &LongLessThanTemplate null\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate null\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate null\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate null\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toNumber()`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate null\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate null\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate null\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate null\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate null\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate null\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate null\n TimestampLessThanTemplate: &TimestampLessThanTemplate null\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate null\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate null\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate null\n SymbolValueOfTemplate: &SymbolValueOfTemplate null\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate null\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate null\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n code = code === undefined ? '\\'\\'' : code;\n scope = scope === undefined ? '' : `, ${scope}`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `('${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}')`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'Binary';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, buffer, subtype) => {\n return `(${buffer.toString('base64')}, '${subtype}')`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return 'Double';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'Int32';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_string') {\n return `Long.fromString(${arg})`;\n }\n return `Long.fromNumber(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate null\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate null\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate null\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate null\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate null\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate null\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate null\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate null\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}'`;\n }\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.fromString(${arg})`;\n }\n return `.fromString('${arg}')`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.createFromTime`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg}.getTime() / 1000)`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.isValid`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg;\n return `(${arg})`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const bson = [];\n const other = [];\n Object.keys(args).map(\n (m) => {\n if (m > 99 && m < 200) {\n bson.push(args[m]);\n } else {\n other.push(args[m]);\n }\n }\n );\n if (bson.length) {\n other.push(`import {\\n ${bson.join(',\\n ')}\\n} from 'mongodb';`);\n }\n return other.join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `import { MongoClient } from 'mongodb';`;\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return 'Code';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'Binary';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'DBRef';\n }\n 104ImportTemplate: &104ImportTemplate !!js/function >\n () => {\n return 'Double';\n }\n 105ImportTemplate: &105ImportTemplate !!js/function >\n () => {\n return 'Int32';\n }\n 106ImportTemplate: &106ImportTemplate !!js/function >\n () => {\n return 'Long';\n }\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'MinKey';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'MaxKey';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'Timestamp';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n int: &intType\n <<: *__type\n id: \"int\"\n code: 105\n type: *IntegerType\n attr: {}\n float: &floatType\n <<: *__type\n id: \"float\"\n code: 104\n type: *IntegerType\n attr: {}\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *ObjectType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n binary:\n callable: *var\n args: null\n attr: null\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n generation_time:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *DateType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n Binary: &BinaryType # Not currently supported\n <<: *__type\n id: \"Binary\"\n code: 102\n type: *ObjectType\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n database:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n collection:\n callable: *var\n args: null\n attr: null\n id: \"collection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n id:\n callable: *var\n args: null\n attr: null\n id: \"id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n Int64: &LongType\n <<: *__type\n id: \"Int64\"\n code: 106\n type: *ObjectType\n attr: {}\n MinKey: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKey: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Regex: &BSONRegExpType\n <<: *__type\n id: \"BSONRegExp\"\n code: 109\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"Timestamp\"\n code: 110\n type: *ObjectType\n attr:\n time:\n callable: *var\n args: null\n attr: null\n id: \"time\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n inc:\n callable: *var\n args: null\n attr: null\n id: \"inc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n as_datetime:\n <<: *__func\n id: \"inc\"\n type: *DateType\n template: *TimestampAsDateTemplate\n argsTemplate: *TimestampAsDateArgsTemplate\n Decimal128: &Decimal128Type\n <<: *__type\n id: \"Decimal128\"\n code: 112\n type: *ObjectType\n attr: {}\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectType, null ]\n namedArgs:\n scope:\n default: {}\n type: [ *ObjectType ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n namedArgs:\n oid:\n default: null\n type: [ *StringType, *ObjectIdType ]\n type: *ObjectIdType\n attr:\n from_datetime:\n <<: *__func\n id: \"ObjectIdfrom_datetime\"\n args:\n - [ \"Date\" ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n is_valid:\n <<: *__func\n id: \"is_valid\"\n args:\n - [ *StringType, ]\n type: *BoolType\n template: *ObjectIdIsValidTemplate\n argsTemplate: *ObjectIdIsValidArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n Binary: &BinarySymbol # Not currently supported\n id: \"Binary\"\n code: 102\n callable: *constructor\n args: null\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType, *StringType ]\n - [ *StringType, null ]\n namedArgs:\n database:\n default: null\n type: [ *StringType ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n Int64:\n id: \"Int64\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Regex:\n id: \"Regex\"\n code: 109\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *StringType, *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *StringType, *IntegerType ]\n type: *BSONRegExpType\n attr:\n from_native:\n <<: *__func\n id: \"from_native\"\n args:\n - [ *RegexType ]\n type: *BSONRegExpType\n template: null\n argsTemplate: null\n template: *BSONRegExpSymbolTemplate\n argsTemplate: *BSONRegExpSymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Decimal128:\n id: \"Decimal128\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n datetime: # Needs process method\n id: \"datetime\"\n code: 200\n callable: *constructor\n args:\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: {} # TODO: add more date funcs?\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n re:\n id: \"re\"\n code: 8\n callable: *var\n args: null\n type: null\n attr:\n compile:\n id: \"compile\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *IntegerType ]\n type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n id: 're.A'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n id: 're.ASCII'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n id: 're.I'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n id: 're.IGNORECASE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n id: 're.DEBUG'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n id: 're.L'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n id: 're.LOCAL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n id: 're.M'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n id: 're.MULTILINE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n id: 're.S'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n id: 're.DOTALL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n id: 're.X'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\n id: 're.VERBOSE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n template: !!js/function >\n () => {\n return '';\n }\n argsTemplate: null\n float:\n id: \"float\"\n code: 104\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *floatType\n attr: {}\n template: *DoubleSymbolTemplate\n argsTemplate: *DoubleSymbolArgsTemplate\n int:\n id: \"int\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *intType\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n"; +module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n# Javascript Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n DriverTemplate: &DriverTemplate !!js/function |\n (spec) => {\n const comment = `/*\n * Requires the MongoDB Node.js Driver\n * https://mongodb.github.io/node-mongodb-native\n */`;\n const translateKey = {\n project: 'projection'\n };\n\n let cmd;\n let defs;\n if ('aggregation' in spec) {\n const agg = spec.aggregation;\n cmd = `const cursor = coll.aggregate(agg);`;\n defs = `const agg = ${agg};\\n`;\n } else {\n let opts = '';\n const args = {};\n Object.keys(spec).forEach((k) => {\n if (k !== 'options') {\n args[k in translateKey ? translateKey[k] : k] = spec[k];\n }\n });\n\n if (Object.keys(args).length > 0) {\n defs = Object.keys(args).reduce((s, k) => {\n if (k !== 'filter') {\n if (opts === '') {\n opts = `${k}`;\n } else {\n opts = `${opts}, ${k}`;\n }\n }\n return `${s}const ${k} = ${args[k]};\\n`;\n }, '');\n opts = opts === '' ? '' : `, { ${opts} }`;\n }\n cmd = `const cursor = coll.find(filter${opts});`;\n }\n return `${comment}\\n\\n${defs}\n const client = await MongoClient.connect(\n '${spec.options.uri}'\n );\n const coll = client.db('${spec.options.database}').collection('${spec.options.collection}');\n ${cmd}\n const result = await cursor.toArray();\n await client.close();`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n } else if (op === '==' || op === '===' || op === 'is') {\n return `${lhs} === ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '!==';\n if (op.includes('!') || op.includes('not')) {\n str = '===';\n }\n return `${rhs}.indexOf(${lhs}) ${str} -1`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `Math.floor(${s}, ${rhs})`;\n case '**':\n return `Math.pow(${s}, ${rhs})`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Date.now, Decimal128/NumberDecimal, Long/NumberLong]\n noNew = [200.1, 112, 106];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])}: ${arg[1]}`;\n }).join(', ');\n\n return `{${pairs}${closingIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.sub_type`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.db`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.namespace`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.oid`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongEqualsTemplate: &LongEqualsTemplate null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate null\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate null\n LongAddTemplate: &LongAddTemplate null\n LongAddArgsTemplate: &LongAddArgsTemplate null\n LongSubtractTemplate: &LongSubtractTemplate null\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate null\n LongMultiplyTemplate: &LongMultiplyTemplate null\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate null\n LongDivTemplate: &LongDivTemplate null\n LongDivArgsTemplate: &LongDivArgsTemplate null\n LongModuloTemplate: &LongModuloTemplate null\n LongModuloArgsTemplate: &LongModuloArgsTemplate null\n LongAndTemplate: &LongAndTemplate null\n LongAndArgsTemplate: &LongAndArgsTemplate null\n LongOrTemplate: &LongOrTemplate null\n LongOrArgsTemplate: &LongOrArgsTemplate null\n LongXorTemplate: &LongXorTemplate null\n LongXorArgsTemplate: &LongXorArgsTemplate null\n LongShiftLeftTemplate: &LongShiftLeftTemplate null\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate null\n LongShiftRightTemplate: &LongShiftRightTemplate null\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate null\n LongCompareTemplate: &LongCompareTemplate null\n LongCompareArgsTemplate: &LongCompareArgsTemplate null\n LongIsOddTemplate: &LongIsOddTemplate null\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate null\n LongIsZeroTemplate: &LongIsZeroTemplate null\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate null\n LongIsNegativeTemplate: &LongIsNegativeTemplate null\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate null\n LongNegateTemplate: &LongNegateTemplate null\n LongNegateArgsTemplate: &LongNegateArgsTemplate null\n LongNotTemplate: &LongNotTemplate null\n LongNotArgsTemplate: &LongNotArgsTemplate null\n LongNotEqualsTemplate: &LongNotEqualsTemplate null\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate null\n LongGreaterThanTemplate: &LongGreaterThanTemplate null\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate null\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate null\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate null\n LongLessThanTemplate: &LongLessThanTemplate null\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate null\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate null\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate null\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toNumber()`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate null\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate null\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate null\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate null\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate null\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate null\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate null\n TimestampLessThanTemplate: &TimestampLessThanTemplate null\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate null\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate null\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate null\n SymbolValueOfTemplate: &SymbolValueOfTemplate null\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate null\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate null\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n code = code === undefined ? '\\'\\'' : code;\n scope = scope === undefined ? '' : `, ${scope}`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `('${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}')`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'Binary';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, buffer, subtype) => {\n return `(${buffer.toString('base64')}, '${subtype}')`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return 'Double';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'Int32';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_string') {\n return `Long.fromString(${arg})`;\n }\n return `Long.fromNumber(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate null\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate null\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate null\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate null\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate null\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate null\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate null\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate null\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}'`;\n }\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.fromString(${arg})`;\n }\n return `.fromString('${arg}')`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.createFromTime`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg}.getTime() / 1000)`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.isValid`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg;\n return `(${arg})`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const bson = [];\n const other = [];\n Object.keys(args).map(\n (m) => {\n if (m > 99 && m < 200) {\n bson.push(args[m]);\n } else {\n other.push(args[m]);\n }\n }\n );\n if (bson.length) {\n other.push(`import {\\n ${bson.join(',\\n ')}\\n} from 'mongodb';`);\n }\n return other.join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `import { MongoClient } from 'mongodb';`;\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return 'Code';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'Binary';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'DBRef';\n }\n 104ImportTemplate: &104ImportTemplate !!js/function >\n () => {\n return 'Double';\n }\n 105ImportTemplate: &105ImportTemplate !!js/function >\n () => {\n return 'Int32';\n }\n 106ImportTemplate: &106ImportTemplate !!js/function >\n () => {\n return 'Long';\n }\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'MinKey';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'MaxKey';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'Timestamp';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n int: &intType\n <<: *__type\n id: \"int\"\n code: 105\n type: *IntegerType\n attr: {}\n float: &floatType\n <<: *__type\n id: \"float\"\n code: 104\n type: *IntegerType\n attr: {}\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *ObjectType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n binary:\n callable: *var\n args: null\n attr: null\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n generation_time:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *DateType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n Binary: &BinaryType # Not currently supported\n <<: *__type\n id: \"Binary\"\n code: 102\n type: *ObjectType\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n database:\n callable: *var\n args: null\n attr: null\n id: \"db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n collection:\n callable: *var\n args: null\n attr: null\n id: \"collection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n id:\n callable: *var\n args: null\n attr: null\n id: \"id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n Int64: &LongType\n <<: *__type\n id: \"Int64\"\n code: 106\n type: *ObjectType\n attr: {}\n MinKey: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKey: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Regex: &BSONRegExpType\n <<: *__type\n id: \"BSONRegExp\"\n code: 109\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"Timestamp\"\n code: 110\n type: *ObjectType\n attr:\n time:\n callable: *var\n args: null\n attr: null\n id: \"time\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n inc:\n callable: *var\n args: null\n attr: null\n id: \"inc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n as_datetime:\n <<: *__func\n id: \"inc\"\n type: *DateType\n template: *TimestampAsDateTemplate\n argsTemplate: *TimestampAsDateArgsTemplate\n Decimal128: &Decimal128Type\n <<: *__type\n id: \"Decimal128\"\n code: 112\n type: *ObjectType\n attr: {}\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectType, null ]\n namedArgs:\n scope:\n default: {}\n type: [ *ObjectType ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n namedArgs:\n oid:\n default: null\n type: [ *StringType, *ObjectIdType ]\n type: *ObjectIdType\n attr:\n from_datetime:\n <<: *__func\n id: \"ObjectIdfrom_datetime\"\n args:\n - [ \"Date\" ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n is_valid:\n <<: *__func\n id: \"is_valid\"\n args:\n - [ *StringType, ]\n type: *BoolType\n template: *ObjectIdIsValidTemplate\n argsTemplate: *ObjectIdIsValidArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n Binary: &BinarySymbol # Not currently supported\n id: \"Binary\"\n code: 102\n callable: *constructor\n args: null\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType, *StringType ]\n - [ *StringType, null ]\n namedArgs:\n database:\n default: null\n type: [ *StringType ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n Int64:\n id: \"Int64\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Regex:\n id: \"Regex\"\n code: 109\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *StringType, *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *StringType, *IntegerType ]\n type: *BSONRegExpType\n attr:\n from_native:\n <<: *__func\n id: \"from_native\"\n args:\n - [ *RegexType ]\n type: *BSONRegExpType\n template: null\n argsTemplate: null\n template: *BSONRegExpSymbolTemplate\n argsTemplate: *BSONRegExpSymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *IntegerType ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Decimal128:\n id: \"Decimal128\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n datetime: # Needs process method\n id: \"datetime\"\n code: 200\n callable: *constructor\n args:\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: {} # TODO: add more date funcs?\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n re:\n id: \"re\"\n code: 8\n callable: *var\n args: null\n type: null\n attr:\n compile:\n id: \"compile\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *IntegerType, null ]\n namedArgs:\n flags:\n default: 0\n type: [ *IntegerType ]\n type: *RegexType\n attr: {}\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n A:\n <<: *__type\n id: 're.A'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n ASCII:\n <<: *__type\n id: 're.ASCII'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '256';\n }\n I:\n <<: *__type\n id: 're.I'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n IGNORECASE:\n <<: *__type\n id: 're.IGNORECASE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '2';\n }\n DEBUG:\n <<: *__type\n id: 're.DEBUG'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '128';\n }\n L:\n <<: *__type\n id: 're.L'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n LOCAL:\n <<: *__type\n id: 're.LOCAL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '4';\n }\n M:\n <<: *__type\n id: 're.M'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n MULTILINE:\n <<: *__type\n id: 're.MULTILINE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '8';\n }\n S:\n <<: *__type\n id: 're.S'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n DOTALL:\n <<: *__type\n id: 're.DOTALL'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '16';\n }\n X:\n <<: *__type\n id: 're.X'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n VERBOSE:\n <<: *__type\n id: 're.VERBOSE'\n type: *IntegerType\n template: !!js/function >\n () => {\n return '64';\n }\n template: !!js/function >\n () => {\n return '';\n }\n argsTemplate: null\n float:\n id: \"float\"\n code: 104\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *floatType\n attr: {}\n template: *DoubleSymbolTemplate\n argsTemplate: *DoubleSymbolArgsTemplate\n int:\n id: \"int\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *intType\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n"; diff --git a/packages/bson-transpilers/lib/symbol-table/shelltojavascript.js b/packages/bson-transpilers/lib/symbol-table/shelltojavascript.js index da0a57f2bf5..36ea912f25e 100644 --- a/packages/bson-transpilers/lib/symbol-table/shelltojavascript.js +++ b/packages/bson-transpilers/lib/symbol-table/shelltojavascript.js @@ -1 +1 @@ -module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n# Javascript Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n DriverTemplate: &DriverTemplate !!js/function |\n (spec) => {\n const comment = `/*\n * Requires the MongoDB Node.js Driver\n * https://mongodb.github.io/node-mongodb-native\n */`;\n const translateKey = {\n project: 'projection'\n };\n\n let cmd;\n let defs;\n if ('aggregation' in spec) {\n const agg = spec.aggregation;\n cmd = `const cursor = coll.aggregate(agg);`;\n defs = `const agg = ${agg};\\n`;\n } else {\n let opts = '';\n const args = {};\n Object.keys(spec).forEach((k) => {\n if (k !== 'options') {\n args[k in translateKey ? translateKey[k] : k] = spec[k];\n }\n });\n\n if (Object.keys(args).length > 0) {\n defs = Object.keys(args).reduce((s, k) => {\n if (k !== 'filter') {\n if (opts === '') {\n opts = `${k}`;\n } else {\n opts = `${opts}, ${k}`;\n }\n }\n return `${s}const ${k} = ${args[k]};\\n`;\n }, '');\n opts = opts === '' ? '' : `, { ${opts} }`;\n }\n cmd = `const cursor = coll.find(filter${opts});`;\n }\n return `${comment}\\n\\n${defs}\n const client = await MongoClient.connect(\n '${spec.options.uri}',\n { useNewUrlParser: true, useUnifiedTopology: true }\n );\n const coll = client.db('${spec.options.database}').collection('${spec.options.collection}');\n ${cmd}\n const result = await cursor.toArray();\n await client.close();`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n } else if (op === '==' || op === '===' || op === 'is') {\n return `${lhs} === ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '!==';\n if (op.includes('!') || op.includes('not')) {\n str = '===';\n }\n return `${rhs}.indexOf(${lhs}) ${str} -1`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `Math.floor(${s}, ${rhs})`;\n case '**':\n return `Math.pow(${s}, ${rhs})`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Date.now, Decimal128/NumberDecimal, Long/NumberLong]\n noNew = [200.1, 112, 106];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])}: ${arg[1]}`;\n }).join(', ');\n\n return `{${pairs}${closingIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.sub_type`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.db`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.namespace`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.oid`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongEqualsTemplate: &LongEqualsTemplate null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate null\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate null\n LongAddTemplate: &LongAddTemplate null\n LongAddArgsTemplate: &LongAddArgsTemplate null\n LongSubtractTemplate: &LongSubtractTemplate null\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate null\n LongMultiplyTemplate: &LongMultiplyTemplate null\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate null\n LongDivTemplate: &LongDivTemplate null\n LongDivArgsTemplate: &LongDivArgsTemplate null\n LongModuloTemplate: &LongModuloTemplate null\n LongModuloArgsTemplate: &LongModuloArgsTemplate null\n LongAndTemplate: &LongAndTemplate null\n LongAndArgsTemplate: &LongAndArgsTemplate null\n LongOrTemplate: &LongOrTemplate null\n LongOrArgsTemplate: &LongOrArgsTemplate null\n LongXorTemplate: &LongXorTemplate null\n LongXorArgsTemplate: &LongXorArgsTemplate null\n LongShiftLeftTemplate: &LongShiftLeftTemplate null\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate null\n LongShiftRightTemplate: &LongShiftRightTemplate null\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate null\n LongCompareTemplate: &LongCompareTemplate null\n LongCompareArgsTemplate: &LongCompareArgsTemplate null\n LongIsOddTemplate: &LongIsOddTemplate null\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate null\n LongIsZeroTemplate: &LongIsZeroTemplate null\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate null\n LongIsNegativeTemplate: &LongIsNegativeTemplate null\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate null\n LongNegateTemplate: &LongNegateTemplate null\n LongNegateArgsTemplate: &LongNegateArgsTemplate null\n LongNotTemplate: &LongNotTemplate null\n LongNotArgsTemplate: &LongNotArgsTemplate null\n LongNotEqualsTemplate: &LongNotEqualsTemplate null\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate null\n LongGreaterThanTemplate: &LongGreaterThanTemplate null\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate null\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate null\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate null\n LongLessThanTemplate: &LongLessThanTemplate null\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate null\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate null\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate null\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toNumber()`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate null\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate null\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate null\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate null\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate null\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate null\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate null\n TimestampLessThanTemplate: &TimestampLessThanTemplate null\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate null\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate null\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate null\n SymbolValueOfTemplate: &SymbolValueOfTemplate null\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate null\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate null\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n code = code === undefined ? '\\'\\'' : code;\n scope = scope === undefined ? '' : `, ${scope}`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `('${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}')`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'Binary';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, buffer, subtype) => {\n return `(${buffer.toString('base64')}, '${subtype}')`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return 'Double';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'Int32';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_string') {\n return `Long.fromString(${arg})`;\n }\n return `Long.fromNumber(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate null\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate null\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate null\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate null\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate null\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate null\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate null\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate null\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}'`;\n }\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.fromString(${arg})`;\n }\n return `.fromString('${arg}')`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.createFromTime`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg}.getTime() / 1000)`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.isValid`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg;\n return `(${arg})`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const bson = [];\n const other = [];\n Object.keys(args).map(\n (m) => {\n if (m > 99 && m < 200) {\n bson.push(args[m]);\n } else {\n other.push(args[m]);\n }\n }\n );\n if (bson.length) {\n other.push(`import {\\n ${bson.join(',\\n ')}\\n} from 'mongodb';`);\n }\n return other.join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `import { MongoClient } from 'mongodb';`;\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return 'Code';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'Binary';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'DBRef';\n }\n 104ImportTemplate: &104ImportTemplate !!js/function >\n () => {\n return 'Double';\n }\n 105ImportTemplate: &105ImportTemplate !!js/function >\n () => {\n return 'Int32';\n }\n 106ImportTemplate: &106ImportTemplate !!js/function >\n () => {\n return 'Long';\n }\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'MinKey';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'MaxKey';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'Timestamp';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n type: *StringType\n top:\n callable: *var\n args: null\n attr: null\n id: \"top\"\n type: *IntegerType\n template: *LongTopTemplate\n argsTemplate: null\n bottom:\n callable: *var\n args: null\n attr: null\n id: \"bottom\"\n type: *IntegerType\n template: *LongBottomTemplate\n argsTemplate: null\n floatApprox:\n callable: *var\n args: null\n attr: null\n id: \"floatApprox\"\n type: *IntegerType\n template: *LongFloatApproxTemplate\n argsTemplate: null\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"TimestampFromShell\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n getTime:\n <<: *__func\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getInc:\n <<: *__func\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n t:\n callable: *var\n args: null\n attr: null\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n i:\n callable: *var\n args: null\n attr: null\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n Symbol: &SymbolType\n <<: *__type\n id: \"Symbol\"\n code: 111\n type: *ObjectType\n NumberDecimal: &Decimal128Type\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr: {}\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *ObjectIdType\n attr:\n fromDate:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; +module.exports="SymbolTypes:\n VAR: &var 0\n CONSTRUCTOR: &constructor 1\n FUNC: &func 2\n# Internal patterns to save typing\n__type: &__type\n id: null\n callable: *var\n args: null\n type: null\n attr: {}\n template: null\n argsTemplate: null\n__func: &__func\n callable: *func\n args: []\n attr: {}\n template: null\n argsTemplate: null\n\n# Javascript Templates\nTemplates:\n # Misc\n RegexFlags: &RegexFlags\n i: 'i'\n m: 'm'\n u: 'u'\n y: 'y'\n g: 'g'\n BSONRegexFlags: &BSONRegexFlags\n i: 'i'\n m: 'm'\n x: 'x'\n s: 's'\n l: 'l'\n u: 'u'\n # Syntax\n DriverTemplate: &DriverTemplate !!js/function |\n (spec) => {\n const comment = `/*\n * Requires the MongoDB Node.js Driver\n * https://mongodb.github.io/node-mongodb-native\n */`;\n const translateKey = {\n project: 'projection'\n };\n\n let cmd;\n let defs;\n if ('aggregation' in spec) {\n const agg = spec.aggregation;\n cmd = `const cursor = coll.aggregate(agg);`;\n defs = `const agg = ${agg};\\n`;\n } else {\n let opts = '';\n const args = {};\n Object.keys(spec).forEach((k) => {\n if (k !== 'options') {\n args[k in translateKey ? translateKey[k] : k] = spec[k];\n }\n });\n\n if (Object.keys(args).length > 0) {\n defs = Object.keys(args).reduce((s, k) => {\n if (k !== 'filter') {\n if (opts === '') {\n opts = `${k}`;\n } else {\n opts = `${opts}, ${k}`;\n }\n }\n return `${s}const ${k} = ${args[k]};\\n`;\n }, '');\n opts = opts === '' ? '' : `, { ${opts} }`;\n }\n cmd = `const cursor = coll.find(filter${opts});`;\n }\n return `${comment}\\n\\n${defs}\n const client = await MongoClient.connect(\n '${spec.options.uri}'\n );\n const coll = client.db('${spec.options.database}').collection('${spec.options.collection}');\n ${cmd}\n const result = await cursor.toArray();\n await client.close();`;\n }\n EqualitySyntaxTemplate: &EqualitySyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n if (op.includes('!') || op.includes('not')) {\n return `${lhs} !== ${rhs}`;\n } else if (op === '==' || op === '===' || op === 'is') {\n return `${lhs} === ${rhs}`;\n }\n return `${lhs} ${op} ${rhs}`;\n }\n InSyntaxTemplate: &InSyntaxTemplate !!js/function >\n (lhs, op, rhs) => {\n let str = '!==';\n if (op.includes('!') || op.includes('not')) {\n str = '===';\n }\n return `${rhs}.indexOf(${lhs}) ${str} -1`\n }\n AndSyntaxTemplate: &AndSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' && ');\n }\n OrSyntaxTemplate: &OrSyntaxTemplate !!js/function >\n (args) => {\n return args.join(' || ');\n }\n NotSyntaxTemplate: &NotSyntaxTemplate !!js/function >\n (arg) => {\n return `!${arg}`;\n }\n UnarySyntaxTemplate: &UnarySyntaxTemplate null\n BinarySyntaxTemplate: &BinarySyntaxTemplate !!js/function >\n (args) => {\n return args.reduce((s, op, i, arr) => {\n if (i % 2 === 0) {\n return s;\n }\n const rhs = arr[i + 1];\n switch(op) {\n case '//':\n return `Math.floor(${s}, ${rhs})`;\n case '**':\n return `Math.pow(${s}, ${rhs})`;\n default:\n return `${s} ${op} ${rhs}`;\n }\n }, args[0]);\n }\n ParensSyntaxTemplate: &ParensSyntaxTemplate null\n EosSyntaxTemplate: &EosSyntaxTemplate null\n EofSyntaxTemplate: &EofSyntaxTemplate null\n NewTemplate: &NewSyntaxTemplate !!js/function >\n (expr, skip, code) => {\n // Add classes that don't use \"new\" to array.\n // So far: [Date.now, Decimal128/NumberDecimal, Long/NumberLong]\n noNew = [200.1, 112, 106];\n if (skip || (code && noNew.indexOf(code) !== -1)) {\n return expr;\n }\n return `new ${expr}`;\n }\n # BSON Object Type templates\n CodeTypeTemplate: &CodeTypeTemplate null\n StringTypeTemplate: &StringTypeTemplate !!js/function >\n (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n RegexTypeTemplate: &RegexTypeTemplate !!js/function >\n (pattern, flags) => {\n const str = pattern;\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n pattern = `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n return `RegExp(${pattern}${flags ? ', ' + '\\'' + flags + '\\'': ''})`;\n }\n BoolTypeTemplate: &BoolTypeTemplate !!js/function >\n (literal) => {\n return literal.toLowerCase();\n }\n IntegerTypeTemplate: &IntegerTypeTemplate null\n DecimalTypeTemplate: &DecimalTypeTemplate null\n LongBasicTypeTemplate: &LongBasicTypeTemplate null\n HexTypeTemplate: &HexTypeTemplate null\n OctalTypeTemplate: &OctalTypeTemplate null\n NumericTypeTemplate: &NumericTypeTemplate null\n ArrayTypeTemplate: &ArrayTypeTemplate !!js/function >\n (literal, depth) => {\n depth++;\n if (literal === '') {\n return '[]'\n }\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n\n return `[${indent}${literal}${closingIndent}]`;\n }\n ArrayTypeArgsTemplate: &ArrayTypeArgsTemplate null\n NullTypeTemplate: &NullTypeTemplate !!js/function >\n () => {\n return 'null';\n }\n UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >\n () => {\n return 'undefined';\n }\n ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >\n (literal) => {\n if (literal === '') {\n return '{}';\n }\n return literal;\n }\n ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >\n (args, depth) => {\n if (args.length === 0) {\n return '{}';\n }\n depth++;\n const indent = '\\n' + ' '.repeat(depth);\n const closingIndent = '\\n' + ' '.repeat(depth - 1);\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2')}'`;\n }\n const pairs = args.map((arg) => {\n return `${indent}${singleStringify(arg[0])}: ${arg[1]}`;\n }).join(', ');\n\n return `{${pairs}${closingIndent}}`\n }\n # BSON Object Method templates\n CodeCodeTemplate: &CodeCodeTemplate null\n CodeCodeArgsTemplate: &CodeCodeArgsTemplate null\n CodeScopeTemplate: &CodeScopeTemplate null\n CodeScopeArgsTemplate: &CodeScopeArgsTemplate null\n ObjectIdToStringTemplate: &ObjectIdToStringTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toString()`;\n }\n ObjectIdToStringArgsTemplate: &ObjectIdToStringArgsTemplate !!js/function >\n () => {\n return '';\n }\n ObjectIdEqualsTemplate: &ObjectIdEqualsTemplate null\n ObjectIdEqualsArgsTemplate: &ObjectIdEqualsArgsTemplate null\n ObjectIdGetTimestampTemplate: &ObjectIdGetTimestampTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getTimestamp()`;\n }\n ObjectIdGetTimestampArgsTemplate: &ObjectIdGetTimestampArgsTemplate !!js/function >\n () => {\n return '';\n }\n BinaryValueTemplate: &BinaryValueTemplate null\n BinaryValueArgsTemplate: &BinaryValueArgsTemplate null\n BinaryLengthTemplate: &BinaryLengthTemplate null\n BinaryLengthArgsTemplate: &BinaryLengthArgsTemplate null\n BinaryToStringTemplate: &BinaryToStringTemplate null\n BinaryToStringArgsTemplate: &BinaryToStringArgsTemplate null\n BinarySubtypeTemplate: &BinarySubtypeTemplate !!js/function >\n (lhs) => {\n return `${lhs}.sub_type`;\n }\n BinarySubtypeArgsTemplate: &BinarySubtypeArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetDBTemplate: &DBRefGetDBTemplate !!js/function >\n (lhs) => {\n return `${lhs}.db`;\n }\n DBRefGetCollectionTemplate: &DBRefGetCollectionTemplate !!js/function >\n (lhs) => {\n return `${lhs}.namespace`;\n }\n DBRefGetIdTemplate: &DBRefGetIdTemplate !!js/function >\n (lhs) => {\n return `${lhs}.oid`;\n }\n DBRefGetDBArgsTemplate: &DBRefGetDBArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetCollectionArgsTemplate: &DBRefGetCollectionArgsTemplate !!js/function >\n () => {\n return '';\n }\n DBRefGetIdArgsTemplate: &DBRefGetIdArgsTemplate !!js/function >\n () => {\n return '';\n }\n LongEqualsTemplate: &LongEqualsTemplate null\n LongEqualsArgsTemplate: &LongEqualsArgsTemplate null\n LongToStringTemplate: &LongToStringTemplate null\n LongToStringArgsTemplate: &LongToStringArgsTemplate null\n LongToIntTemplate: &LongToIntTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toInt`;\n }\n LongToIntArgsTemplate: &LongToIntArgsTemplate null\n LongToNumberTemplate: &LongToNumberTemplate null\n LongToNumberArgsTemplate: &LongToNumberArgsTemplate null\n LongAddTemplate: &LongAddTemplate null\n LongAddArgsTemplate: &LongAddArgsTemplate null\n LongSubtractTemplate: &LongSubtractTemplate null\n LongSubtractArgsTemplate: &LongSubtractArgsTemplate null\n LongMultiplyTemplate: &LongMultiplyTemplate null\n LongMultiplyArgsTemplate: &LongMultiplyArgsTemplate null\n LongDivTemplate: &LongDivTemplate null\n LongDivArgsTemplate: &LongDivArgsTemplate null\n LongModuloTemplate: &LongModuloTemplate null\n LongModuloArgsTemplate: &LongModuloArgsTemplate null\n LongAndTemplate: &LongAndTemplate null\n LongAndArgsTemplate: &LongAndArgsTemplate null\n LongOrTemplate: &LongOrTemplate null\n LongOrArgsTemplate: &LongOrArgsTemplate null\n LongXorTemplate: &LongXorTemplate null\n LongXorArgsTemplate: &LongXorArgsTemplate null\n LongShiftLeftTemplate: &LongShiftLeftTemplate null\n LongShiftLeftArgsTemplate: &LongShiftLeftArgsTemplate null\n LongShiftRightTemplate: &LongShiftRightTemplate null\n LongShiftRightArgsTemplate: &LongShiftRightArgsTemplate null\n LongCompareTemplate: &LongCompareTemplate null\n LongCompareArgsTemplate: &LongCompareArgsTemplate null\n LongIsOddTemplate: &LongIsOddTemplate null\n LongIsOddArgsTemplate: &LongIsOddArgsTemplate null\n LongIsZeroTemplate: &LongIsZeroTemplate null\n LongIsZeroArgsTemplate: &LongIsZeroArgsTemplate null\n LongIsNegativeTemplate: &LongIsNegativeTemplate null\n LongIsNegativeArgsTemplate: &LongIsNegativeArgsTemplate null\n LongNegateTemplate: &LongNegateTemplate null\n LongNegateArgsTemplate: &LongNegateArgsTemplate null\n LongNotTemplate: &LongNotTemplate null\n LongNotArgsTemplate: &LongNotArgsTemplate null\n LongNotEqualsTemplate: &LongNotEqualsTemplate null\n LongNotEqualsArgsTemplate: &LongNotEqualsArgsTemplate null\n LongGreaterThanTemplate: &LongGreaterThanTemplate null\n LongGreaterThanArgsTemplate: &LongGreaterThanArgsTemplate null\n LongGreaterThanOrEqualTemplate: &LongGreaterThanOrEqualTemplate null\n LongGreaterThanOrEqualArgsTemplate: &LongGreaterThanOrEqualArgsTemplate null\n LongLessThanTemplate: &LongLessThanTemplate null\n LongLessThanArgsTemplate: &LongLessThanArgsTemplate null\n LongLessThanOrEqualTemplate: &LongLessThanOrEqualTemplate null\n LongLessThanOrEqualArgsTemplate: &LongLessThanOrEqualArgsTemplate null\n LongFloatApproxTemplate: &LongFloatApproxTemplate !!js/function >\n (lhs) => {\n return `${lhs}.toNumber()`;\n }\n LongTopTemplate: &LongTopTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n LongBottomTemplate: &LongBottomTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampToStringTemplate: &TimestampToStringTemplate null\n TimestampToStringArgsTemplate: &TimestampToStringArgsTemplate null\n TimestampEqualsTemplate: &TimestampEqualsTemplate null\n TimestampEqualsArgsTemplate: &TimestampEqualsArgsTemplate null\n TimestampGetLowBitsTemplate: &TimestampGetLowBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits`;\n }\n TimestampGetLowBitsArgsTemplate: &TimestampGetLowBitsArgsTemplate null\n TimestampGetHighBitsTemplate: &TimestampGetHighBitsTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits`;\n }\n TimestampGetHighBitsArgsTemplate: &TimestampGetHighBitsArgsTemplate null\n TimestampTTemplate: &TimestampTTemplate !!js/function >\n (lhs) => {\n return `${lhs}.getLowBits()`;\n }\n TimestampITemplate: &TimestampITemplate !!js/function >\n (lhs) => {\n return `${lhs}.getHighBits()`;\n }\n TimestampAsDateTemplate: &TimestampAsDateTemplate !!js/function >\n (lhs) => {\n return `new Date(${lhs}.getHighBits() * 1000)`;\n }\n TimestampAsDateArgsTemplate: &TimestampAsDateArgsTemplate !!js/function >\n () => {\n return '';\n }\n TimestampCompareTemplate: &TimestampCompareTemplate null\n TimestampCompareArgsTemplate: &TimestampCompareArgsTemplate null\n TimestampNotEqualsTemplate: &TimestampNotEqualsTemplate null\n TimestampNotEqualsArgsTemplate: &TimestampNotEqualsArgsTemplate null\n TimestampGreaterThanTemplate: &TimestampGreaterThanTemplate null\n TimestampGreaterThanArgsTemplate: &TimestampGreaterThanArgsTemplate null\n TimestampGreaterThanOrEqualTemplate: &TimestampGreaterThanOrEqualTemplate null\n TimestampGreaterThanOrEqualArgsTemplate: &TimestampGreaterThanOrEqualArgsTemplate null\n TimestampLessThanTemplate: &TimestampLessThanTemplate null\n TimestampLessThanArgsTemplate: &TimestampLessThanArgsTemplate null\n TimestampLessThanOrEqualTemplate: &TimestampLessThanOrEqualTemplate null\n TimestampLessThanOrEqualArgsTemplate: &TimestampLessThanOrEqualArgsTemplate null\n SymbolValueOfTemplate: &SymbolValueOfTemplate null\n SymbolValueOfArgsTemplate: &SymbolValueOfArgsTemplate null\n SymbolInspectTemplate: &SymbolInspectTemplate null\n SymbolInspectArgsTemplate: &SymbolInspectArgsTemplate null\n SymbolToStringTemplate: &SymbolToStringTemplate null\n SymbolToStringArgsTemplate: &SymbolToStringArgsTemplate null\n # Symbol Templates\n CodeSymbolTemplate: &CodeSymbolTemplate null\n CodeSymbolArgsTemplate: &CodeSymbolArgsTemplate !!js/function >\n (lhs, code, scope) => {\n code = code === undefined ? '\\'\\'' : code;\n scope = scope === undefined ? '' : `, ${scope}`;\n return `(${code}${scope})`;\n }\n ObjectIdSymbolTemplate: &ObjectIdSymbolTemplate null\n ObjectIdSymbolArgsTemplate: &ObjectIdSymbolArgsTemplate !!js/function >\n (lhs, str) => {\n if (!str || str.length === 0) {\n return '()';\n }\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `('${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}')`;\n }\n BinarySymbolTemplate: &BinarySymbolTemplate !!js/function >\n () => {\n return 'Binary';\n }\n BinarySymbolArgsTemplate: &BinarySymbolArgsTemplate !!js/function >\n (lhs, buffer, subtype) => {\n return `(${buffer.toString('base64')}, '${subtype}')`;\n }\n BinarySymbolSubtypeDefaultTemplate: &BinarySymbolSubtypeDefaultTemplate null\n BinarySymbolSubtypeFunctionTemplate: &BinarySymbolSubtypeFunctionTemplate null\n BinarySymbolSubtypeByteArrayTemplate: &BinarySymbolSubtypeByteArrayTemplate null\n BinarySymbolSubtypeUuidOldTemplate: &BinarySymbolSubtypeUuidOldTemplate null\n BinarySymbolSubtypeUuidTemplate: &BinarySymbolSubtypeUuidTemplate null\n BinarySymbolSubtypeMd5Template: &BinarySymbolSubtypeMd5Template null\n BinarySymbolSubtypeUserDefinedTemplate: &BinarySymbolSubtypeUserDefinedTemplate null\n DBRefSymbolTemplate: &DBRefSymbolTemplate null\n DBRefSymbolArgsTemplate: &DBRefSymbolArgsTemplate null\n DoubleSymbolTemplate: &DoubleSymbolTemplate !!js/function >\n () => {\n return 'Double';\n }\n DoubleSymbolArgsTemplate: &DoubleSymbolArgsTemplate null\n Int32SymbolTemplate: &Int32SymbolTemplate !!js/function >\n () => {\n return 'Int32';\n }\n Int32SymbolArgsTemplate: &Int32SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? 0 : arg;\n return `(${arg})`;\n }\n LongSymbolTemplate: &LongSymbolTemplate !!js/function >\n () => {\n return '';\n }\n LongSymbolArgsTemplate: &LongSymbolArgsTemplate !!js/function >\n (lhs, arg, type) => {\n arg = arg === undefined ? 0 : arg;\n if (type === '_string') {\n return `Long.fromString(${arg})`;\n }\n return `Long.fromNumber(${arg})`;\n }\n LongSymbolMaxTemplate: &LongSymbolMaxTemplate null\n LongSymbolMaxArgsTemplate: &LongSymbolMaxArgsTemplate null\n LongSymbolMinTemplate: &LongSymbolMinTemplate null\n LongSymbolMinArgsTemplate: &LongSymbolMinArgsTemplate null\n LongSymbolZeroTemplate: &LongSymbolZeroTemplate null\n LongSymbolZeroArgsTemplate: &LongSymbolZeroArgsTemplate null\n LongSymbolOneTemplate: &LongSymbolOneTemplate null\n LongSymbolOneArgsTemplate: &LongSymbolOneArgsTemplate null\n LongSymbolNegOneTemplate: &LongSymbolNegOneTemplate null\n LongSymbolNegOneArgsTemplate: &LongSymbolNegOneArgsTemplate null\n LongSymbolFromBitsTemplate: &LongSymbolFromBitsTemplate null\n LongSymbolFromBitsArgsTemplate: &LongSymbolFromBitsArgsTemplate null\n LongSymbolFromIntTemplate: &LongSymbolFromIntTemplate null\n LongSymbolFromIntArgsTemplate: &LongSymbolFromIntArgsTemplate null\n LongSymbolFromNumberTemplate: &LongSymbolFromNumberTemplate null\n LongSymbolFromNumberArgsTemplate: &LongSymbolFromNumberArgsTemplate null\n LongSymbolFromStringTemplate: &LongSymbolFromStringTemplate null\n LongSymbolFromStringArgsTemplate: &LongSymbolFromStringArgsTemplate null\n MinKeySymbolTemplate: &MinKeySymbolTemplate null\n MinKeySymbolArgsTemplate: &MinKeySymbolArgsTemplate null\n MaxKeySymbolTemplate: &MaxKeySymbolTemplate null\n MaxKeySymbolArgsTemplate: &MaxKeySymbolArgsTemplate null\n TimestampSymbolTemplate: &TimestampSymbolTemplate null\n TimestampSymbolArgsTemplate: &TimestampSymbolArgsTemplate !!js/function >\n (lhs, arg1, arg2) => {\n return `(${arg1 === undefined ? 0 : arg1}, ${arg2 === undefined ? 0 : arg2})`;\n }\n SymbolSymbolTemplate: &SymbolSymbolTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n SymbolSymbolArgsTemplate: &SymbolSymbolArgsTemplate null\n BSONRegExpSymbolTemplate: &BSONRegExpSymbolTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n BSONRegExpSymbolArgsTemplate: &BSONRegExpSymbolArgsTemplate !!js/function >\n (lhs, pattern, flags) => {\n const singleStringify = (str) => {\n let newStr = str;\n if (\n (str.charAt(0) === '\\'' && str.charAt(str.length - 1) === '\\'') ||\n (str.charAt(0) === '\"' && str.charAt(str.length - 1) === '\"')) {\n newStr = str.substr(1, str.length - 2);\n }\n return `'${newStr.replace(/\\\\([\\s\\S])|(\")/g, '\\\\$1$2')}'`;\n }\n return `(${singleStringify(pattern)}${flags ? ', ' + singleStringify(flags) : ''})`;\n }\n Decimal128SymbolTemplate: &Decimal128SymbolTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n Decimal128SymbolArgsTemplate: &Decimal128SymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg.toString();\n if (arg.charAt(0) === '\\'' && arg.charAt(arg.length - 1) === '\\'') {\n return `.fromString(${arg})`;\n }\n return `.fromString('${arg}')`;\n }\n Decimal128SymbolFromStringTemplate: &Decimal128SymbolFromStringTemplate null\n Decimal128SymbolFromStringArgsTemplate: &Decimal128SymbolFromStringArgsTemplate null\n Decimal128ToStringTemplate: &Decimal128ToStringTemplate null\n Decimal128ToStringArgsTemplate: &Decimal128ToStringArgsTemplate null\n # BSON Util Templates\n ObjectIdCreateFromHexStringTemplate: &ObjectIdCreateFromHexStringTemplate null\n ObjectIdCreateFromHexStringArgsTemplate: &ObjectIdCreateFromHexStringArgsTemplate null\n ObjectIdCreateFromTimeTemplate: &ObjectIdCreateFromTimeTemplate !!js/function >\n () => {\n return `ObjectId.createFromTime`;\n }\n ObjectIdCreateFromTimeArgsTemplate: &ObjectIdCreateFromTimeArgsTemplate !!js/function >\n (lhs, arg, isNumber) => {\n if (!isNumber) {\n return `(${arg}.getTime() / 1000)`;\n }\n return `(${arg})`;\n }\n ObjectIdIsValidTemplate: &ObjectIdIsValidTemplate !!js/function >\n (lhs) => {\n return `${lhs}.isValid`;\n }\n ObjectIdIsValidArgsTemplate: &ObjectIdIsValidArgsTemplate null\n # JS Symbol Templates\n NumberSymbolTemplate: &NumberSymbolTemplate !!js/function >\n () => {\n return 'Number';\n }\n NumberSymbolArgsTemplate: &NumberSymbolArgsTemplate !!js/function >\n (lhs, arg) => {\n arg = arg === undefined ? '0' : arg;\n return `(${arg})`;\n }\n DateSymbolTemplate: &DateSymbolTemplate !!js/function >\n () => {\n return 'Date';\n }\n DateSymbolArgsTemplate: &DateSymbolArgsTemplate null\n DateSymbolNowTemplate: &DateSymbolNowTemplate !!js/function >\n () => {\n return 'Date.now';\n }\n DateSymbolNowArgsTemplate: &DateSymbolNowArgsTemplate null\n RegExpSymbolTemplate: &RegExpSymbolTemplate !!js/function >\n () => {\n return 'RegExp';\n }\n RegExpSymbolArgsTemplate: &RegExpSymbolArgsTemplate null\n ImportTemplate: &ImportTemplate !!js/function >\n (args) => {\n const bson = [];\n const other = [];\n Object.keys(args).map(\n (m) => {\n if (m > 99 && m < 200) {\n bson.push(args[m]);\n } else {\n other.push(args[m]);\n }\n }\n );\n if (bson.length) {\n other.push(`import {\\n ${bson.join(',\\n ')}\\n} from 'mongodb';`);\n }\n return other.join('\\n');\n }\n DriverImportTemplate: &DriverImportTemplate !!js/function >\n () => {\n return `import { MongoClient } from 'mongodb';`;\n }\n 0ImportTemplate: &0ImportTemplate null\n 1ImportTemplate: &1ImportTemplate null\n 2ImportTemplate: &2ImportTemplate null\n 3ImportTemplate: &3ImportTemplate null\n 4ImportTemplate: &4ImportTemplate null\n 5ImportTemplate: &5ImportTemplate null\n 6ImportTemplate: &6ImportTemplate null\n 7ImportTemplate: &7ImportTemplate null\n 8ImportTemplate: &8ImportTemplate null\n 9ImportTemplate: &9ImportTemplate null\n 10ImportTemplate: &10ImportTemplate null\n 11ImportTemplate: &11ImportTemplate null\n 12ImportTemplate: &12ImportTemplate null\n 100ImportTemplate: &100ImportTemplate !!js/function >\n () => {\n return 'Code';\n }\n 101ImportTemplate: &101ImportTemplate !!js/function >\n () => {\n return 'ObjectId';\n }\n 102ImportTemplate: &102ImportTemplate !!js/function >\n () => {\n return 'Binary';\n }\n 103ImportTemplate: &103ImportTemplate !!js/function >\n () => {\n return 'DBRef';\n }\n 104ImportTemplate: &104ImportTemplate !!js/function >\n () => {\n return 'Double';\n }\n 105ImportTemplate: &105ImportTemplate !!js/function >\n () => {\n return 'Int32';\n }\n 106ImportTemplate: &106ImportTemplate !!js/function >\n () => {\n return 'Long';\n }\n 107ImportTemplate: &107ImportTemplate !!js/function >\n () => {\n return 'MinKey';\n }\n 108ImportTemplate: &108ImportTemplate !!js/function >\n () => {\n return 'MaxKey';\n }\n 109ImportTemplate: &109ImportTemplate !!js/function >\n () => {\n return 'BSONRegExp';\n }\n 110ImportTemplate: &110ImportTemplate !!js/function >\n () => {\n return 'Timestamp';\n }\n 111ImportTemplate: &111ImportTemplate !!js/function >\n () => {\n return 'BSONSymbol';\n }\n 112ImportTemplate: &112ImportTemplate !!js/function >\n () => {\n return 'Decimal128';\n }\n 113ImportTemplate: &113ImportTemplate null\n 114ImportTemplate: &114ImportTemplate null\n 200ImportTemplate: &200ImportTemplate null\n 201ImportTemplate: &201ImportTemplate null\n 300ImportTemplate: &300ImportTemplate null\n 301ImportTemplate: &301ImportTemplate null\n 302ImportTemplate: &302ImportTemplate null\n 303ImportTemplate: &303ImportTemplate null\n 304ImportTemplate: &304ImportTemplate null\n 305ImportTemplate: &305ImportTemplate null\n 306ImportTemplate: &306ImportTemplate null\n# Universal types\n# Everything inherits from StringType because we haven't implemented any of them.\nBasicTypes:\n # Universal basic types\n _bool: &BoolType\n <<: *__type\n id: \"_bool\"\n code: 0\n template: *BoolTypeTemplate\n _integer: &IntegerType\n <<: *__type\n id: \"_integer\"\n code: 1\n template: *IntegerTypeTemplate\n _long: &LongBasicType\n <<: *__type\n id: \"_long\"\n code: 2\n template: *LongBasicTypeTemplate\n _decimal: &DecimalType\n <<: *__type\n id: \"_decimal\"\n code: 3\n template: *DecimalTypeTemplate\n _hex: &HexType\n <<: *__type\n id: \"_hex\"\n code: 4\n template: *HexTypeTemplate\n _octal: &OctalType\n <<: *__type\n id: \"_octal\"\n code: 5\n template: *OctalTypeTemplate\n _numeric: &NumericType\n <<: *__type\n id: \"_numeric\"\n code: 6\n template: *NumericTypeTemplate\n _string: &StringType\n <<: *__type\n id: \"_string\"\n code: 7\n template: *StringTypeTemplate\n _regex: &RegexType\n <<: *__type\n id: \"_regex\"\n code: 8\n template: *RegexTypeTemplate\n _array: &ArrayType\n <<: *__type\n id: \"_array\"\n code: 9\n template: *ArrayTypeTemplate\n argsTemplate: *ArrayTypeArgsTemplate\n _object: &ObjectType\n <<: *__type\n id: \"_object\"\n code: 10\n template: *ObjectTypeTemplate\n argsTemplate: *ObjectTypeArgsTemplate\n _null: &NullType\n <<: *__type\n id: \"_null\"\n code: 11\n template: *NullTypeTemplate\n _undefined: &UndefinedType\n <<: *__type\n id: \"_undefined\"\n code: 12\n template: *UndefinedTypeTemplate\n\nSyntax:\n equality:\n template: *EqualitySyntaxTemplate\n in:\n template: *InSyntaxTemplate\n and:\n template: *AndSyntaxTemplate\n or:\n template: *OrSyntaxTemplate\n not:\n template: *NotSyntaxTemplate\n unary:\n template: *UnarySyntaxTemplate\n binary:\n template: *BinarySyntaxTemplate\n parens:\n template: *ParensSyntaxTemplate\n eos:\n template: *EosSyntaxTemplate\n eof:\n template: *EofSyntaxTemplate\n # The new template takes in expr, and an optional skip argument and optional\n # id argument. The skip argument is a boolean that if true then doesn't add\n # new. The code argument is the symbol code being called. The template will check\n # if it is an exception, i.e. a type that is a constructor but may not use new.\n new:\n template: *NewSyntaxTemplate\n # The regex flags that change symbols between languages can be defined here.\n # Flags that aren't defined can be left blank and will be ignored.\n regexFlags: *RegexFlags\n bsonRegexFlags: *BSONRegexFlags\n driver: *DriverTemplate\nImports:\n import:\n template: *ImportTemplate\n driver:\n template: *DriverImportTemplate\n 0:\n template: *0ImportTemplate\n 1:\n template: *1ImportTemplate\n 2:\n template: *2ImportTemplate\n 3:\n template: *3ImportTemplate\n 4:\n template: *4ImportTemplate\n 5:\n template: *5ImportTemplate\n 6:\n template: *6ImportTemplate\n 7:\n template: *7ImportTemplate\n 8:\n template: *8ImportTemplate\n 9:\n template: *9ImportTemplate\n 10:\n template: *10ImportTemplate\n 11:\n template: *11ImportTemplate\n 12:\n template: *12ImportTemplate\n 100:\n template: *100ImportTemplate\n 101:\n template: *101ImportTemplate\n 102:\n template: *102ImportTemplate\n 103:\n template: *103ImportTemplate\n 104:\n template: *104ImportTemplate\n 105:\n template: *105ImportTemplate\n 106:\n template: *106ImportTemplate\n 107:\n template: *107ImportTemplate\n 108:\n template: *108ImportTemplate\n 109:\n template: *109ImportTemplate\n 110:\n template: *110ImportTemplate\n 111:\n template: *111ImportTemplate\n 112:\n template: *112ImportTemplate\n 113:\n template: *113ImportTemplate\n 114:\n template: *114ImportTemplate\n 200:\n template: *200ImportTemplate\n 201:\n template: *201ImportTemplate\n 300:\n template: *300ImportTemplate\n 301:\n template: *301ImportTemplate\n 302:\n template: *302ImportTemplate\n 303:\n template: *303ImportTemplate\n 304:\n template: *304ImportTemplate\n 305:\n template: *305ImportTemplate\n 306:\n template: *306ImportTemplate\nBsonTypes:\n Code: &CodeType\n <<: *__type\n id: \"Code\"\n code: 100\n type: *ObjectType\n attr:\n code:\n callable: *var\n args: null\n attr: null\n id: \"code\"\n type: *StringType\n template: *CodeCodeTemplate\n argsTemplate: *CodeCodeArgsTemplate\n scope:\n callable: *var\n args: null\n attr: null\n id: \"scope\"\n type: *StringType\n template: *CodeScopeTemplate\n argsTemplate: *CodeScopeArgsTemplate\n ObjectId: &ObjectIdType\n <<: *__type\n id: \"ObjectId\"\n code: 101\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *ObjectIdToStringTemplate\n argsTemplate: *ObjectIdToStringArgsTemplate\n equals:\n <<: *__func\n id: \"equals\"\n args:\n - [ \"ObjectId\" ]\n type: *BoolType\n template: *ObjectIdEqualsTemplate\n argsTemplate: *ObjectIdEqualsArgsTemplate\n getTimestamp:\n <<: *__func\n id: \"getTimestamp\"\n type: *IntegerType\n template: *ObjectIdGetTimestampTemplate\n argsTemplate: *ObjectIdGetTimestampArgsTemplate\n BinData: &BinaryType\n <<: *__type\n id: \"BinData\"\n code: 102\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *BinaryToStringTemplate\n argsTemplate: *BinaryToStringArgsTemplate\n base64:\n <<: *__func\n id: \"base64\"\n type: *StringType\n template: *BinaryValueTemplate\n argsTemplate: *BinaryValueArgsTemplate\n length:\n <<: *__func\n id: \"length\"\n type: *IntegerType\n template: *BinaryLengthTemplate\n argsTemplate: *BinaryLengthArgsTemplate\n subtype:\n <<: *__func\n id: \"subtype\"\n type: *IntegerType\n template: *BinarySubtypeTemplate\n argsTemplate: *BinarySubtypeArgsTemplate\n DBRef: &DBRefType\n <<: *__type\n id: \"DBRef\"\n code: 103\n type: *ObjectType\n attr:\n getDb:\n <<: *__func\n id: \"getDb\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n $db:\n callable: *var\n args: null\n attr: null\n id: \"$db\"\n type: *StringType\n template: *DBRefGetDBTemplate\n argsTemplate: *DBRefGetDBArgsTemplate\n getCollection:\n <<: *__func\n id: \"getCollection\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getRef:\n <<: *__func\n id: \"getRef\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n $ref:\n callable: *var\n args: null\n attr: null\n id: \"$ref\"\n type: *StringType\n template: *DBRefGetCollectionTemplate\n argsTemplate: *DBRefGetCollectionArgsTemplate\n getId:\n <<: *__func\n id: \"getId\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n $id:\n callable: *var\n args: null\n attr: null\n id: \"$id\"\n type: *StringType\n template: *DBRefGetIdTemplate\n argsTemplate: *DBRefGetIdArgsTemplate\n NumberInt: &Int32Type\n <<: *__type\n id: \"NumberInt\"\n code: 105\n type: *ObjectType\n attr: {}\n NumberLong: &LongType\n <<: *__type\n id: \"NumberLong\"\n code: 106\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"LongtoString\" # Needs process method\n type: *StringType\n top:\n callable: *var\n args: null\n attr: null\n id: \"top\"\n type: *IntegerType\n template: *LongTopTemplate\n argsTemplate: null\n bottom:\n callable: *var\n args: null\n attr: null\n id: \"bottom\"\n type: *IntegerType\n template: *LongBottomTemplate\n argsTemplate: null\n floatApprox:\n callable: *var\n args: null\n attr: null\n id: \"floatApprox\"\n type: *IntegerType\n template: *LongFloatApproxTemplate\n argsTemplate: null\n MinKeyType: &MinKeyType\n <<: *__type\n id: \"MinKey\"\n code: 107\n type: *ObjectType\n MaxKeyType: &MaxKeyType\n <<: *__type\n id: \"MaxKey\"\n code: 108\n type: *ObjectType\n Timestamp: &TimestampType\n <<: *__type\n id: \"TimestampFromShell\"\n code: 110\n type: *ObjectType\n attr:\n toString:\n <<: *__func\n id: \"toString\"\n type: *StringType\n template: *TimestampToStringTemplate\n argsTemplate: *TimestampToStringArgsTemplate\n getTime:\n <<: *__func\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampGetLowBitsTemplate\n argsTemplate: *TimestampGetLowBitsArgsTemplate\n getInc:\n <<: *__func\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampGetHighBitsTemplate\n argsTemplate: *TimestampGetHighBitsArgsTemplate\n t:\n callable: *var\n args: null\n attr: null\n id: \"getTime\"\n type: *IntegerType\n template: *TimestampTTemplate\n argsTemplate: null\n i:\n callable: *var\n args: null\n attr: null\n id: \"getInc\"\n type: *IntegerType\n template: *TimestampITemplate\n argsTemplate: null\n Symbol: &SymbolType\n <<: *__type\n id: \"Symbol\"\n code: 111\n type: *ObjectType\n NumberDecimal: &Decimal128Type\n <<: *__type\n id: \"NumberDecimal\"\n code: 112\n type: *ObjectType\n attr: {}\n SUBTYPE_DEFAULT:\n id: \"SUBTYPE_DEFAULT\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeDefaultTemplate\n SUBTYPE_FUNCTION:\n id: \"SUBTYPE_FUNCTION\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeFunctionTemplate\n SUBTYPE_BYTE_ARRAY:\n id: \"SUBTYPE_BYTE_ARRAY\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeByteArrayTemplate\n SUBTYPE_UUID_OLD:\n id: \"SUBTYPE_UUID_OLD\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidOldTemplate\n SUBTYPE_UUID:\n id: \"SUBTYPE_UUID\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUuidTemplate\n SUBTYPE_MD5:\n id: \"SUBTYPE_MD5\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeMd5Template\n SUBTYPE_USER_DEFINED:\n id: \"SUBTYPE_USER_DEFINED\"\n callable: *var\n args: null\n code: 113\n type: *IntegerType\n template: *BinarySymbolSubtypeUserDefinedTemplate\nNativeTypes:\n Date: &DateType\n <<: *__type\n id: \"Date\"\n code: 200\n type: *ObjectType\n attr: {} # TODO: no built-in date methods added yet\n RegExp: &RegExpType\n <<: *__type\n id: \"RegExp\"\n code: 8\n type: *ObjectType\n attr: {}\n\n\n\n\nBsonSymbols:\n Code: &CodeSymbol\n id: \"Code\"\n code: 100\n callable: *constructor\n args:\n - [ *StringType, null ]\n - [ *ObjectType, null ]\n type: *CodeType\n attr: {}\n template: *CodeSymbolTemplate\n argsTemplate: *CodeSymbolArgsTemplate\n ObjectId: &ObjectIdSymbol\n id: \"ObjectId\"\n code: 101\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *ObjectIdType\n attr:\n fromDate:\n <<: *__func\n id: \"ObjectIdCreateFromTime\"\n args:\n - [ *DateType ]\n type: *ObjectIdType\n template: *ObjectIdCreateFromTimeTemplate\n argsTemplate: *ObjectIdCreateFromTimeArgsTemplate\n template: *ObjectIdSymbolTemplate\n argsTemplate: *ObjectIdSymbolArgsTemplate\n BinData: &BinarySymbol\n id: \"BinData\"\n code: 102\n callable: *constructor\n args:\n - [ *IntegerType ]\n - [ *StringType ]\n type: *BinaryType\n attr: {}\n template: *BinarySymbolTemplate\n argsTemplate: *BinarySymbolArgsTemplate\n DBRef:\n id: \"DBRef\"\n code: 103\n callable: *constructor\n args:\n - [ *StringType ]\n - [ *ObjectIdType ]\n - [ *StringType, null ]\n type: *DBRefType\n attr: {}\n template: *DBRefSymbolTemplate\n argsTemplate: *DBRefSymbolArgsTemplate\n NumberInt:\n id: \"Int32\"\n code: 105\n callable: *constructor\n args:\n - [ *NumericType, *StringType, null ]\n type: *Int32Type\n attr: {}\n template: *Int32SymbolTemplate\n argsTemplate: *Int32SymbolArgsTemplate\n NumberLong:\n id: \"NumberLong\"\n code: 106\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *LongType\n attr: {}\n template: *LongSymbolTemplate\n argsTemplate: *LongSymbolArgsTemplate\n MinKey:\n id: \"MinKey\"\n code: 107\n callable: *constructor\n args: []\n type: *MinKeyType\n attr: {}\n template: *MinKeySymbolTemplate\n argsTemplate: *MinKeySymbolArgsTemplate\n MaxKey:\n id: \"MaxKey\"\n code: 108\n callable: *constructor\n args: []\n type: *MaxKeyType\n attr: {}\n template: *MaxKeySymbolTemplate\n argsTemplate: *MaxKeySymbolArgsTemplate\n Timestamp:\n id: \"Timestamp\"\n code: 110\n callable: *constructor\n args:\n - [ *IntegerType, null ]\n - [ *IntegerType, null ]\n type: *TimestampType\n attr: {}\n template: *TimestampSymbolTemplate\n argsTemplate: *TimestampSymbolArgsTemplate\n Symbol:\n id: \"Symbol\"\n code: 111\n callable: *constructor\n args:\n - [ *StringType ]\n type: *SymbolType\n attr: {}\n template: *SymbolSymbolTemplate\n argsTemplate: *SymbolSymbolArgsTemplate\n NumberDecimal:\n id: \"NumberDecimal\"\n code: 112\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n type: *Decimal128Type\n attr: {}\n template: *Decimal128SymbolTemplate\n argsTemplate: *Decimal128SymbolArgsTemplate\n\nNativeSymbols:\n Number:\n id: \"Number\"\n code: 2\n callable: *constructor\n args:\n - [ *IntegerType, *StringType, null ]\n type: *NumericType\n attr: {} # TODO: no built-in number funcs added yet\n template: *NumberSymbolTemplate\n argsTemplate: *NumberSymbolArgsTemplate\n Date: # Needs emit method\n id: \"Date\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n - [ *NumericType, null ]\n type: *DateType\n attr: # TODO: add more date funcs?\n now:\n id: \"now\"\n code: 200.1\n callable: *func\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n ISODate: # Needs emit method\n id: \"ISODate\"\n code: 200\n callable: *constructor\n args:\n - [ *StringType, null ]\n type: *DateType\n attr:\n now:\n id: \"now\"\n callable: *constructor\n args: []\n type: *DateType\n attr: {}\n template: *DateSymbolNowTemplate\n argsTemplate: *DateSymbolNowArgsTemplate\n template: *DateSymbolTemplate\n argsTemplate: *DateSymbolArgsTemplate\n RegExp: # Needs process method\n id: \"RegExp\"\n code: 8\n callable: *constructor\n args:\n - [ *StringType, *RegexType ]\n - [ *StringType, null ]\n type: *RegExpType\n attr: {} # TODO: no built-in regex funcs added yet\n template: *RegExpSymbolTemplate\n argsTemplate: *RegExpSymbolArgsTemplate\n\n"; diff --git a/packages/bson-transpilers/symbols/javascript/templates.yaml b/packages/bson-transpilers/symbols/javascript/templates.yaml index 87143652ce4..5877c757530 100644 --- a/packages/bson-transpilers/symbols/javascript/templates.yaml +++ b/packages/bson-transpilers/symbols/javascript/templates.yaml @@ -57,8 +57,7 @@ Templates: } return `${comment}\n\n${defs} const client = await MongoClient.connect( - '${spec.options.uri}', - { useNewUrlParser: true, useUnifiedTopology: true } + '${spec.options.uri}' ); const coll = client.db('${spec.options.database}').collection('${spec.options.collection}'); ${cmd} diff --git a/packages/bson-transpilers/test/yaml/driver-syntax.yaml b/packages/bson-transpilers/test/yaml/driver-syntax.yaml index ba2cad6e55d..6b7046c212a 100644 --- a/packages/bson-transpilers/test/yaml/driver-syntax.yaml +++ b/packages/bson-transpilers/test/yaml/driver-syntax.yaml @@ -57,8 +57,7 @@ tests: }; const client = await MongoClient.connect( - 'mongodb://localhost:27017', - { useNewUrlParser: true, useUnifiedTopology: true } + 'mongodb://localhost:27017' ); const coll = client.db('db').collection('collection'); const cursor = coll.aggregate(agg); @@ -211,8 +210,7 @@ tests: }; const client = await MongoClient.connect( - 'mongodb://localhost:27017', - { useNewUrlParser: true, useUnifiedTopology: true } + 'mongodb://localhost:27017' ); const coll = client.db('db').collection('collection'); const cursor = coll.find(filter); @@ -425,8 +423,7 @@ tests: }; const client = await MongoClient.connect( - 'mongodb://localhost:27017', - { useNewUrlParser: true, useUnifiedTopology: true } + 'mongodb://localhost:27017' ); const coll = client.db('db').collection('collection'); const cursor = coll.find(filter, { projection, sort, skip, limit, maxTimeMS, collation }); diff --git a/packages/compass-export-to-language/src/modules/transpiler.spec.ts b/packages/compass-export-to-language/src/modules/transpiler.spec.ts index 7da4c4f07a7..7840a4c6005 100644 --- a/packages/compass-export-to-language/src/modules/transpiler.spec.ts +++ b/packages/compass-export-to-language/src/modules/transpiler.spec.ts @@ -102,8 +102,7 @@ const filter = { }; const client = await MongoClient.connect( - 'mongodb://foo:bar@mongodb.net', - { useNewUrlParser: true, useUnifiedTopology: true } + 'mongodb://foo:bar@mongodb.net' ); const coll = client.db('namespace').collection(''); const cursor = coll.find(filter); @@ -215,8 +214,7 @@ const filter = { }; const client = await MongoClient.connect( - '${uri}', - { useNewUrlParser: true, useUnifiedTopology: true } + '${uri}' ); const coll = client.db('namespace').collection(''); const cursor = coll.find(filter);