diff --git a/package.json b/package.json index d08c2bbdd..bb309d0d7 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ ], "scripts": { "build": "tsc -p tsconfig.build.json", - "lint": "prettier --write '{src,test}/**/*.{t,j}s'", - "lint:check": "prettier --check '{src,test}/**/*.{t,j}s'", + "lint": "prettier --write {src,test}/**/*.{t,j}s", + "lint:check": "prettier --check {src,test}/**/*.{t,j}s", "test": "jest", "prepare": "npm run build" }, diff --git a/src/argument.ts b/src/argument.ts index 13f2523a5..6e974509a 100755 --- a/src/argument.ts +++ b/src/argument.ts @@ -39,13 +39,13 @@ export class Argument { this.context = context this.value = argument if ( - this.argumentInfo.type === MirArgumentType.Boolean || - this.argumentInfo.type === MirArgumentType.Float || - this.argumentInfo.type === MirArgumentType.Integer || - this.argumentInfo.type === MirArgumentType.String + this.argumentInfo?.type === MirArgumentType.Boolean || + this.argumentInfo?.type === MirArgumentType.Float || + this.argumentInfo?.type === MirArgumentType.Integer || + this.argumentInfo?.type === MirArgumentType.String ) { this.argument = null - } else if (this.argumentInfo.type === MirArgumentType.FilterFunction) { + } else if (this.argumentInfo?.type === MirArgumentType.FilterFunction) { // Check if it's custom filter to know if contains a subscript or a filter function if (Array.isArray(argument) && Array.isArray(argument[1])) { this.argument = new Argument( @@ -60,13 +60,13 @@ export class Argument { (argument as [Filter, boolean | string | number])[1] ) } - } else if (this.argumentInfo.type === MirArgumentType.ReducerFunction) { + } else if (this.argumentInfo?.type === MirArgumentType.ReducerFunction) { this.argument = new Argument( this.context, { name: 'by', optional: false, type: MirArgumentType.String }, argument as Reducer ) - } else if (this.argumentInfo.type === MirArgumentType.Subscript) { + } else if (this.argumentInfo?.type === MirArgumentType.Subscript) { this.argument = new Script( this.context, argument as MirScript, diff --git a/src/constants.ts b/src/constants.ts index ec681098b..ef37d92e4 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,6 +6,7 @@ export const DEFAULT_SCRIPT_FIRST_TYPE = OutputType.String export const KIND_OPTIONS = [Kind.HttpGet, Kind.RNG, Kind.HttpPost] export const CONTENT_TYPE_OPTIONS = { [Kind.HttpGet]: 'JSON API', + [Kind.HttpHead]: 'JSON API', [Kind.HttpPost]: 'JSON API', [Kind.RNG]: 'Binary file', } diff --git a/src/structures.ts b/src/structures.ts index 34da13e4a..33c5af057 100644 --- a/src/structures.ts +++ b/src/structures.ts @@ -25,7 +25,7 @@ export const typeSystem: TypeSystem = { [Type.Array]: { [ArrayOperatorName.Count]: [OperatorCode.ArrayCount, OutputType.Integer], [ArrayOperatorName.Filter]: [OperatorCode.ArrayFilter, OutputType.Same], - //[ArrayOperatorName.Flatten]: [OperatorCode.ArrayFlatten, OutputType.Array], + [ArrayOperatorName.Join]: [OperatorCode.ArrayJoin, OutputType.JoinOutput], [ArrayOperatorName.GetArray]: [OperatorCode.ArrayGetArray, OutputType.Array], [ArrayOperatorName.GetBoolean]: [OperatorCode.ArrayGetBoolean, OutputType.Boolean], [ArrayOperatorName.GetBytes]: [OperatorCode.ArrayGetBytes, OutputType.Bytes], @@ -35,36 +35,33 @@ export const typeSystem: TypeSystem = { [ArrayOperatorName.GetString]: [OperatorCode.ArrayGetString, OutputType.String], [ArrayOperatorName.Map]: [OperatorCode.ArrayMap, OutputType.ArrayMap], [ArrayOperatorName.Reduce]: [OperatorCode.ArrayReduce, OutputType.Inner], - //[ArrayOperatorName.Some]: [OperatorCode.ArraySome, OutputType.FilterOutput], [ArrayOperatorName.Sort]: [OperatorCode.ArraySort, OutputType.Same], - //[ArrayOperatorName.Take]: [OperatorCode.ArrayTake, OutputType.Array], }, [Type.Boolean]: { - [BooleanOperatorName.AsString]: [OperatorCode.BooleanAsString, OutputType.String], - //[BooleanOperatorName.Match]: [OperatorCode.BooleanMatch, OutputType.MatchOutput], + [BooleanOperatorName.ToString]: [OperatorCode.BooleanToString, OutputType.String], [BooleanOperatorName.Negate]: [OperatorCode.BooleanNegate, OutputType.Boolean], }, [Type.Bytes]: { - [BytesOperatorName.AsString]: [OperatorCode.BytesAsString, OutputType.String], + [BytesOperatorName.AsInteger]: [OperatorCode.BytesAsInteger, OutputType.Integer], [BytesOperatorName.Hash]: [OperatorCode.BytesHash, OutputType.Bytes], + [BytesOperatorName.Length]: [OperatorCode.BytesLength, OutputType.Integer], + [BytesOperatorName.Slice]: [OperatorCode.BytesSlice, OutputType.Bytes], + [BytesOperatorName.Stringify]: [OperatorCode.BytesStringify, OutputType.String], }, [Type.Integer]: { [IntegerOperatorName.Absolute]: [OperatorCode.IntegerAbsolute, OutputType.Integer], - [IntegerOperatorName.AsFloat]: [OperatorCode.IntegerAsFloat, OutputType.Float], - [IntegerOperatorName.AsString]: [OperatorCode.IntegerAsString, OutputType.String], [IntegerOperatorName.GreaterThan]: [OperatorCode.IntegerGreaterThan, OutputType.Boolean], [IntegerOperatorName.LessThan]: [OperatorCode.IntegerLessThan, OutputType.Boolean], - // [IntegerOperatorName.Match]: [OperatorCode.IntegerMatch, OutputType.MatchOutput], [IntegerOperatorName.Modulo]: [OperatorCode.IntegerModulo, OutputType.Integer], [IntegerOperatorName.Multiply]: [OperatorCode.IntegerMultiply, OutputType.Integer], [IntegerOperatorName.Negate]: [OperatorCode.IntegerNegate, OutputType.Integer], [IntegerOperatorName.Power]: [OperatorCode.IntegerPower, OutputType.Integer], - //[IntegerOperatorName.Reciprocal]: [OperatorCode.IntegerReciprocal, OutputType.Float], - //[IntegerOperatorName.Sum]: [OperatorCode.IntegerSum, OutputType.Integer], + [IntegerOperatorName.ToBytes]: [OperatorCode.IntegerToBytes, OutputType.Bytes], + [IntegerOperatorName.ToFloat]: [OperatorCode.IntegerToFloat, OutputType.Float], + [IntegerOperatorName.ToString]: [OperatorCode.IntegerToString, OutputType.String], }, [Type.Float]: { [FloatOperatorName.Absolute]: [OperatorCode.FloatAbsolute, OutputType.Float], - [FloatOperatorName.AsString]: [OperatorCode.FloatAsString, OutputType.String], [FloatOperatorName.Ceiling]: [OperatorCode.FloatCeiling, OutputType.Integer], [FloatOperatorName.GreaterThan]: [OperatorCode.FloatGreaterThan, OutputType.Boolean], [FloatOperatorName.Floor]: [OperatorCode.FloatFloor, OutputType.Integer], @@ -73,9 +70,8 @@ export const typeSystem: TypeSystem = { [FloatOperatorName.Multiply]: [OperatorCode.FloatMultiply, OutputType.Float], [FloatOperatorName.Negate]: [OperatorCode.FloatNegate, OutputType.Float], [FloatOperatorName.Power]: [OperatorCode.FloatPower, OutputType.Float], - //[FloatOperatorName.Reciprocal]: [OperatorCode.FloatReciprocal, OutputType.Float], [FloatOperatorName.Round]: [OperatorCode.FloatRound, OutputType.Integer], - //[FloatOperatorName.Sum]: [OperatorCode.Floatsum, OutputType.Float], + [FloatOperatorName.ToString]: [OperatorCode.FloatToString, OutputType.String], [FloatOperatorName.Truncate]: [OperatorCode.FloatTruncate, OutputType.Integer], }, [Type.Map]: { @@ -92,7 +88,7 @@ export const typeSystem: TypeSystem = { }, [Type.String]: { [StringOperatorName.AsBoolean]: [OperatorCode.StringAsBoolean, OutputType.Boolean], - //[StringOperatorName.AsBytes]: [OperatorCode.StringAsBytes, OutputType.Bytes], + [StringOperatorName.AsBytes]: [OperatorCode.StringAsBytes, OutputType.Bytes], [StringOperatorName.AsFloat]: [OperatorCode.StringAsFloat, OutputType.Float], [StringOperatorName.AsInteger]: [OperatorCode.StringAsInteger, OutputType.Integer], [StringOperatorName.Length]: [OperatorCode.StringLength, OutputType.Integer], @@ -102,6 +98,9 @@ export const typeSystem: TypeSystem = { [StringOperatorName.ParseXmlMap]: [OperatorCode.StringParseXmlMap, OutputType.Map], [StringOperatorName.ToLowerCase]: [OperatorCode.StringToLowerCase, OutputType.String], [StringOperatorName.ToUpperCase]: [OperatorCode.StringToUpperCase, OutputType.String], + [StringOperatorName.Replace]: [OperatorCode.StringReplace, OutputType.String], + [StringOperatorName.Slice]: [OperatorCode.StringSlice, OutputType.String], + [StringOperatorName.Split]: [OperatorCode.StringSplit, OutputType.String], }, } @@ -169,20 +168,22 @@ export const operatorInfos: OperatorInfos = { (filter: string = 'filter') => i18n.t('operator_info_description.array.filter', { filter }), }, - /*[OperatorCode.ArrayFlatten]: { + [OperatorCode.ArrayJoin]: { type: Type.Array, - name: ArrayOperatorName.Flatten, + name: ArrayOperatorName.Join, arguments: [ { - name: 'depth', + name: 'separator', optional: true, - type: MirArgumentType.Integer, + type: MirArgumentType.String, }, ], outputType: OutputType.Inner, - description: (i18n: I18n) => (depth: string = 'depth') => - i18n.t('operator_info_description.array.flatten', { depth }), - },*/ + description: + (i18n: I18n) => + (separator: string = '') => + i18n.t('operator_info_description.array.join', { separator }), + }, [OperatorCode.ArrayGetArray]: { type: Type.Array, name: ArrayOperatorName.GetArray, @@ -351,9 +352,9 @@ export const operatorInfos: OperatorInfos = { description: (i18n: I18n) => (min, max) => i18n.t('operator_info_description.array.take', { min, max }), },*/ - [OperatorCode.BooleanAsString]: { + [OperatorCode.BooleanToString]: { type: Type.Boolean, - name: BooleanOperatorName.AsString, + name: BooleanOperatorName.ToString, arguments: [], outputType: OutputType.String, description: (i18n: I18n) => () => descriptions.cast(i18n)('Boolean', 'String'), @@ -384,10 +385,16 @@ export const operatorInfos: OperatorInfos = { outputType: OutputType.Boolean, description: (i18n: I18n) => () => i18n.t('operator_info_description.boolean.negate'), }, - [OperatorCode.BytesAsString]: { + [OperatorCode.BytesStringify]: { type: Type.Bytes, - name: BytesOperatorName.AsString, - arguments: [], + name: BytesOperatorName.Stringify, + arguments: [ + { + name: 'encoding', + optional: true, + type: MirArgumentType.Integer, + }, + ], outputType: OutputType.String, description: (i18n: I18n) => () => descriptions.cast(i18n)('Bytes', 'String'), }, @@ -398,6 +405,30 @@ export const operatorInfos: OperatorInfos = { outputType: OutputType.Bytes, description: (i18n: I18n) => () => i18n.t('operator_info_description.bytes.hash'), }, + [OperatorCode.BytesAsInteger]: { + type: Type.Bytes, + name: BytesOperatorName.AsInteger, + arguments: [], + outputType: OutputType.Integer, + description: (i18n: I18n) => () => descriptions.cast(i18n)('Bytes', 'Integer'), + }, + [OperatorCode.BytesLength]: { + type: Type.Bytes, + name: BytesOperatorName.Length, + arguments: [], + outputType: OutputType.Integer, + description: (i18n: I18n) => () => i18n.t('operator_info_description.bytes.length'), + }, + [OperatorCode.BytesSlice]: { + type: Type.Bytes, + name: BytesOperatorName.Slice, + arguments: [], + outputType: OutputType.Bytes, + description: + (i18n: I18n) => + (startIndex: number = 0, endIndex: number) => + i18n.t('operator_info_description.bytes.slice', { startIndex, endIndex }), + }, [OperatorCode.IntegerAbsolute]: { type: Type.Integer, name: IntegerOperatorName.Absolute, @@ -405,16 +436,23 @@ export const operatorInfos: OperatorInfos = { outputType: OutputType.Integer, description: (i18n: I18n) => () => i18n.t('operator_info_description.integer.absolute'), }, - [OperatorCode.IntegerAsFloat]: { + [OperatorCode.IntegerToBytes]: { + type: Type.Integer, + name: IntegerOperatorName.ToBytes, + arguments: [], + outputType: OutputType.Bytes, + description: (i18n: I18n) => () => descriptions.cast(i18n)('Integer', 'Bytes'), + }, + [OperatorCode.IntegerToFloat]: { type: Type.Integer, - name: IntegerOperatorName.AsFloat, + name: IntegerOperatorName.ToFloat, arguments: [], outputType: OutputType.Float, description: (i18n: I18n) => () => descriptions.cast(i18n)('Integer', 'Float'), }, - [OperatorCode.IntegerAsString]: { + [OperatorCode.IntegerToString]: { type: Type.Integer, - name: IntegerOperatorName.AsString, + name: IntegerOperatorName.ToString, arguments: [], outputType: OutputType.String, description: (i18n: I18n) => () => descriptions.cast(i18n)('Integer', 'String'), @@ -553,9 +591,9 @@ export const operatorInfos: OperatorInfos = { outputType: OutputType.Float, description: (i18n: I18n) => () => i18n.t('operator_info_description.float.absolute'), }, - [OperatorCode.FloatAsString]: { + [OperatorCode.FloatToString]: { type: Type.Float, - name: FloatOperatorName.AsString, + name: FloatOperatorName.ToString, arguments: [ { name: 'decimals', @@ -863,13 +901,19 @@ export const operatorInfos: OperatorInfos = { outputType: OutputType.Boolean, description: (i18n: I18n) => () => descriptions.cast(i18n)('String', 'Boolean'), }, - /*[OperatorCode.StringAsBytes]: { + [OperatorCode.StringAsBytes]: { type: Type.String, name: StringOperatorName.AsBytes, - arguments: [], + arguments: [ + { + name: 'encoding', + optional: true, + type: MirArgumentType.Integer, + }, + ], outputType: OutputType.Bytes, description: (i18n: I18n) => () => descriptions.cast(i18n)('String', 'Bytes'), - },*/ + }, [OperatorCode.StringAsFloat]: { type: Type.String, name: StringOperatorName.AsFloat, @@ -947,6 +991,64 @@ export const operatorInfos: OperatorInfos = { outputType: OutputType.String, description: (i18n: I18n) => () => i18n.t('operator_info_description.string.to_upper_case'), }, + [OperatorCode.StringReplace]: { + type: Type.String, + name: StringOperatorName.Replace, + arguments: [ + { + name: 'pattern', + optional: false, + type: MirArgumentType.String, + }, + { + name: 'replacement', + optional: false, + type: MirArgumentType.String, + }, + ], + outputType: OutputType.String, + description: + (i18n: I18n) => + (pattern: string = '', replacement: string = '') => + i18n.t('operator_info_description.string.replace', { pattern, replacement }), + }, + [OperatorCode.StringSlice]: { + type: Type.String, + name: StringOperatorName.Slice, + arguments: [ + { + name: 'startIndex', + optional: false, + type: MirArgumentType.Integer, + }, + { + name: 'endIndex', + optional: true, + type: MirArgumentType.Integer, + }, + ], + outputType: OutputType.String, + description: + (i18n: I18n) => + (startIndex: number = 0, endIndex: number) => + i18n.t('operator_info_description.string.slice', { startIndex, endIndex }), + }, + [OperatorCode.StringSplit]: { + type: Type.String, + name: StringOperatorName.Split, + arguments: [ + { + name: 'regex', + optional: true, + type: MirArgumentType.String, + }, + ], + outputType: OutputType.ArrayString, + description: + (i18n: I18n) => + (regex: string = '\r') => + i18n.t('operator_info_description.string.split', { regex }), + }, } export class Cache { diff --git a/src/types.ts b/src/types.ts index 6795fa8f0..d5ec34ce0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -118,6 +118,7 @@ export enum OutputType { Same = 'same', String = 'string', SubscriptOutput = 'subscriptOutput', + JoinOutput = 'joinOutput', } export enum MarkupHierarchicalType { @@ -220,13 +221,14 @@ export type KindOptions = Array export enum Kind { HttpGet = 'HTTP-GET', HttpPost = 'HTTP-POST', + HttpHead = 'HTTP-HEAD', RNG = 'RNG', } export enum OperatorCode { ArrayCount = 0x10, ArrayFilter = 0x11, - //ArrayFlatten = 0x12, + ArrayJoin = 0x12, ArrayGetArray = 0x13, ArrayGetBoolean = 0x14, ArrayGetBytes = 0x15, @@ -236,44 +238,39 @@ export enum OperatorCode { ArrayGetString = 0x19, ArrayMap = 0x1a, ArrayReduce = 0x1b, - //ArraySome = 0x1c, ArraySort = 0x1d, - //ArrayTake = 0x1e, - BooleanAsString = 0x20, - //BooleanMatch = 0x21, BooleanNegate = 0x22, + BooleanToString = 0x20, - BytesAsString = 0x30, + BytesAsInteger = 0x32, BytesHash = 0x31, - //BytesLength = 0x32, + BytesLength = 0x34, + BytesSlice = 0x3c, + BytesStringify = 0x30, IntegerAbsolute = 0x40, - IntegerAsFloat = 0x41, - IntegerAsString = 0x42, IntegerGreaterThan = 0x43, IntegerLessThan = 0x44, - // IntegerMatch = 0x45, IntegerModulo = 0x46, IntegerMultiply = 0x47, IntegerNegate = 0x48, IntegerPower = 0x49, - //IntegerReciprocal = 0x4a, - //IntegerSum = 0x4b, + IntegerToBytes = 0x4a, + IntegerToFloat = 0x41, + IntegerToString = 0x42, FloatAbsolute = 0x50, - FloatAsString = 0x51, FloatCeiling = 0x52, - FloatGreaterThan = 0x53, FloatFloor = 0x54, + FloatGreaterThan = 0x53, FloatLessThan = 0x55, FloatModulo = 0x56, FloatMultiply = 0x57, FloatNegate = 0x58, FloatPower = 0x59, - //FloatReciprocal = 0x5a, FloatRound = 0x5b, - //Floatsum = 0x5c, + FloatToString = 0x51, FloatTruncate = 0x5d, //MapEntries = 0x60, @@ -288,7 +285,7 @@ export enum OperatorCode { MapValues = 0x69, StringAsBoolean = 0x70, - //StringAsBytes = 0x71, + StringAsBytes = 0x71, StringAsFloat = 0x72, StringAsInteger = 0x73, StringLength = 0x74, @@ -296,6 +293,9 @@ export enum OperatorCode { StringParseJsonArray = 0x76, StringParseJsonMap = 0x77, StringParseXmlMap = 0x78, + StringReplace = 0x7b, + StringSlice = 0x7c, + StringSplit = 0x7d, StringToLowerCase = 0x79, StringToUpperCase = 0x7a, } @@ -416,7 +416,7 @@ export type OperatorInfos = { export enum ArrayOperatorName { Count = 'count', Filter = 'filter', - //Flatten = 'flatten', + Join = 'join', GetArray = 'getArray', GetBoolean = 'getBoolean', GetBytes = 'getBytes', @@ -426,40 +426,37 @@ export enum ArrayOperatorName { GetString = 'getString', Map = 'map', Reduce = 'reduce', - //Some = 'some', Sort = 'sort', - //Take = 'take', } export enum BooleanOperatorName { - AsString = 'asString', Negate = 'negate', - //Match = 'match', + ToString = 'toString', } export enum BytesOperatorName { - AsString = 'asString', + AsInteger = 'asInteger', Hash = 'hash', + Length = 'length', + Slice = 'slice', + Stringify = 'stringify', } export enum IntegerOperatorName { Absolute = 'absolute', - AsFloat = 'asFloat', - AsString = 'asString', GreaterThan = 'greaterThan', LessThan = 'lessThan', - // Match = 'match', Modulo = 'modulo', Multiply = 'multiply', Negate = 'negate', Power = 'power', - //Reciprocal = 'reciprocal', - //Sum = 'sum', + ToBytes = 'toBytes', + ToFloat = 'toFloat', + ToString = 'stringify', } export enum FloatOperatorName { Absolute = 'absolute', - AsString = 'asString', Ceiling = 'ceiling', GreaterThan = 'greaterThan', Floor = 'floor', @@ -468,14 +465,12 @@ export enum FloatOperatorName { Multiply = 'multiply', Negate = 'negate', Power = 'power', - //Reciprocal = 'reciprocal', Round = 'round', - //Sum = 'sum', + ToString = 'stringify', Truncate = 'truncate', } export enum MapOperatorName { - //Entries = 'entries', GetArray = 'getArray', GetBoolean = 'getBoolean', GetBytes = 'getBytes', @@ -489,7 +484,7 @@ export enum MapOperatorName { export enum StringOperatorName { AsBoolean = 'asBoolean', - //AsBytes = 'asBytes', + AsBytes = 'asBytes', AsFloat = 'asFloat', AsInteger = 'asInteger', Length = 'length', @@ -497,6 +492,9 @@ export enum StringOperatorName { ParseJsonArray = 'parseJSONArray', ParseJsonMap = 'parseJSONMap', ParseXmlMap = 'parseXMLMap', + Replace = 'replace', + Slice = 'slice', + Split = 'split', ToLowerCase = 'toLowerCase', ToUpperCase = 'toUpperCase', } diff --git a/src/utils.ts b/src/utils.ts index 0ca16efd7..d6b054111 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ -import prettier from 'prettier/standalone' -import parserBabel from 'prettier/parser-babel' +// import prettier from 'prettier/standalone' +// import parserBabel from 'prettier/parser-babel' import { ArgumentInfo, @@ -59,7 +59,7 @@ export function fromOutputTypeToType(type: OutputType): Type | null { } export function formatJs(source: string) { - return prettier.format(source, { semi: false, plugins: [parserBabel], parser: 'babel' }) + return source //prettier.format(source, { semi: false, plugins: [parserBabel], parser: 'babel' }) } export function getEnumNames(e: any): Array { @@ -83,13 +83,13 @@ export function getMarkupInputTypeFromArgumentType(argumentType: MirArgumentType } export function getArgumentInfoType(info: ArgumentInfo): MarkupArgumentType { - if (info.type === MirArgumentType.FilterFunction) { + if (info?.type === MirArgumentType.FilterFunction) { return MarkupArgumentType.SelectFilter - } else if (info.type === MirArgumentType.ReducerFunction) { + } else if (info?.type === MirArgumentType.ReducerFunction) { return MarkupArgumentType.SelectReduce - } else if (info.type === MirArgumentType.Subscript) { + } else if (info?.type === MirArgumentType.Subscript) { return MarkupArgumentType.Subscript - } else if (info.type === MirArgumentType.Boolean) { + } else if (info?.type === MirArgumentType.Boolean) { return MarkupArgumentType.SelectBoolean } else { return MarkupArgumentType.Input @@ -123,9 +123,9 @@ export function getDefaultMirOperatorByType(type: Type): MirOperator { case Type.Array: return OperatorCode.ArrayCount case Type.Boolean: - return OperatorCode.BooleanAsString + return OperatorCode.BooleanToString case Type.Bytes: - return OperatorCode.BytesAsString + return OperatorCode.BytesStringify case Type.Float: return OperatorCode.FloatAbsolute case Type.Integer: diff --git a/test/src/argument.spec.ts b/test/src/argument.spec.ts index 66ec0015d..a4ec066c4 100644 --- a/test/src/argument.spec.ts +++ b/test/src/argument.spec.ts @@ -172,7 +172,7 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -184,7 +184,7 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -202,7 +202,7 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -388,13 +388,13 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, @@ -730,7 +730,7 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -742,7 +742,7 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -760,7 +760,7 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -946,13 +946,13 @@ describe('Argument methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, diff --git a/test/src/operator.spec.ts b/test/src/operator.spec.ts index 372d27d0e..3b584fe82 100644 --- a/test/src/operator.spec.ts +++ b/test/src/operator.spec.ts @@ -39,7 +39,7 @@ describe('Operator methods', () => { }) it('bytes', () => { - const op = OperatorCode.BytesAsString + const op = OperatorCode.BytesStringify const context: Context = { cache: new Cache(), i18n: new I18n() } const operator = new Operator(context, 0, OutputType.Bytes, op, { emit: () => {} }) @@ -211,7 +211,7 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -223,7 +223,7 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -241,7 +241,7 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -427,13 +427,13 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, @@ -565,7 +565,7 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -577,7 +577,7 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -595,7 +595,7 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -781,13 +781,13 @@ describe('Operator methods', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, @@ -909,7 +909,7 @@ describe('Operator methods', () => { }) it('bytes', () => { - const op = OperatorCode.BytesAsString + const op = OperatorCode.BytesStringify const context: Context = { cache: new Cache(), i18n: new I18n() } const operator = new Operator(context, 0, OutputType.Bytes, op, { emit: () => {} }) @@ -1079,7 +1079,7 @@ describe('Operator methods', () => { }) it('bytes', () => { - const op = OperatorCode.BytesAsString + const op = OperatorCode.BytesStringify const context: Context = { cache: new Cache(), i18n: new I18n() } const operator = new Operator(context, 0, OutputType.Bytes, op, { emit: () => {} }) @@ -1158,7 +1158,7 @@ describe('Operator methods', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() const operator = new Operator(context, 0, null, null, { emit: emitMock }) - const newOperatorCode = OperatorCode.BooleanAsString + const newOperatorCode = OperatorCode.BooleanToString expect(operator.default).toBe(true) @@ -1176,7 +1176,7 @@ describe('Operator methods', () => { const emitMock = jest.fn() const op = OperatorCode.ArrayCount const operator = new Operator(context, 0, OutputType.Array, op, { emit: emitMock }) - const newOperatorCode = OperatorCode.BooleanAsString + const newOperatorCode = OperatorCode.BooleanToString operator.update(newOperatorCode) @@ -1189,7 +1189,7 @@ describe('Operator methods', () => { it('boolean', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() - const op = OperatorCode.BooleanAsString + const op = OperatorCode.BooleanToString const operator = new Operator(context, 0, OutputType.Boolean, op, { emit: emitMock }) const newOperatorCode = OperatorCode.ArrayCount @@ -1204,7 +1204,7 @@ describe('Operator methods', () => { it('bytes', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() - const op = OperatorCode.BytesAsString + const op = OperatorCode.BytesStringify const operator = new Operator(context, 0, OutputType.Bytes, op, { emit: emitMock }) const newOperatorCode = OperatorCode.ArrayCount @@ -1219,7 +1219,7 @@ describe('Operator methods', () => { it('integer', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() - const op = OperatorCode.IntegerAsString + const op = OperatorCode.IntegerToString const operator = new Operator(context, 0, OutputType.Integer, op, { emit: emitMock }) const newOperatorCode = OperatorCode.FloatGreaterThan @@ -1299,7 +1299,7 @@ describe('Operator methods', () => { it('boolean', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() - const operatorName = 'BooleanAsString' + const operatorName = 'BooleanToString' const operator = new Operator(context, 0, OutputType.Boolean, OperatorCode[operatorName], { emit: emitMock, }) @@ -1317,7 +1317,7 @@ describe('Operator methods', () => { it('bytes', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() - const operatorName = 'BytesAsString' + const operatorName = 'BytesStringify' const operator = new Operator(context, 0, OutputType.Bytes, OperatorCode[operatorName], { emit: emitMock, }) @@ -1334,7 +1334,7 @@ describe('Operator methods', () => { it('integer', () => { const context: Context = { cache: new Cache(), i18n: new I18n() } const emitMock = jest.fn() - const operatorName = 'IntegerAsString' + const operatorName = 'IntegerToString' const operator = new Operator(context, 0, OutputType.Integer, OperatorCode[operatorName], { emit: emitMock, }) diff --git a/test/src/radon.spec.ts b/test/src/radon.spec.ts index 2d8a27325..6f723c080 100755 --- a/test/src/radon.spec.ts +++ b/test/src/radon.spec.ts @@ -1181,7 +1181,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -1193,7 +1193,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -1211,7 +1211,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -1397,13 +1397,13 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, @@ -1781,7 +1781,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -1793,7 +1793,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -1811,7 +1811,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -1997,13 +1997,13 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, @@ -2245,7 +2245,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -2257,7 +2257,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'BytesAsString', + label: 'BytesStringify', markupType: 'option', outputType: 'string', }, @@ -2275,7 +2275,7 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'FloatAsString', + label: 'FloatToString', markupType: 'option', outputType: 'string', }, @@ -2461,13 +2461,13 @@ describe('Radon', () => { }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsFloat', + label: 'IntegerToFloat', markupType: 'option', outputType: 'float', }, { hierarchicalType: 'operatorOption', - label: 'IntegerAsString', + label: 'IntegerToString', markupType: 'option', outputType: 'string', }, @@ -2637,7 +2637,7 @@ describe('Radon', () => { options: [ { hierarchicalType: 'operatorOption', - label: 'BooleanAsString', + label: 'BooleanToString', markupType: 'option', outputType: 'string', }, @@ -3106,7 +3106,7 @@ describe('Radon', () => { script: [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ], }, { @@ -3119,7 +3119,7 @@ describe('Radon', () => { script: [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ], }, ], @@ -3236,7 +3236,7 @@ describe('Radon', () => { script: [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ], }, { @@ -3249,7 +3249,7 @@ describe('Radon', () => { script: [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ], }, ], diff --git a/test/src/script.spec.ts b/test/src/script.spec.ts index 633c31aae..3f924f329 100644 --- a/test/src/script.spec.ts +++ b/test/src/script.spec.ts @@ -16,11 +16,11 @@ describe('Script methods', () => { script.addOperator() expect(script.operators[script.operators.length - 1].code).toStrictEqual( - OperatorCode.BooleanAsString + OperatorCode.BooleanToString ) }) it('last type is a pseudotype', () => { - const mirScript: MirScript = [OperatorCode.StringAsBoolean, OperatorCode.BooleanAsString] + const mirScript: MirScript = [OperatorCode.StringAsBoolean, OperatorCode.BooleanToString] const context = { cache: new Cache(), i18n: new I18n() } const script = new Script(context, mirScript, Kind.HttpGet) script.addOperator() @@ -33,7 +33,7 @@ describe('Script methods', () => { describe('deleteOperator method', () => { it('deletes operator by id', () => { - const mirScript: MirScript = [OperatorCode.StringAsBoolean, OperatorCode.BooleanAsString] + const mirScript: MirScript = [OperatorCode.StringAsBoolean, OperatorCode.BooleanToString] const context = { cache: new Cache(), i18n: new I18n() } const script = new Script(context, mirScript, Kind.HttpGet) const firstOperatorId = script.operators[0].id @@ -57,7 +57,7 @@ describe('Script methods', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const context = { cache: new Cache(), i18n: new I18n() } const script = new Script(context, mirScript, Kind.HttpGet) @@ -98,7 +98,7 @@ describe('Script methods', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const script = new Script(context, mirScript, Kind.HttpGet) @@ -155,7 +155,7 @@ describe('Script methods', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const script = new Script(context, mirScript, Kind.HttpGet) @@ -247,7 +247,7 @@ describe('Script methods', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const script = new Script(context, mirScript, Kind.HttpGet) @@ -285,7 +285,7 @@ describe('Script methods', () => { const script = new Script(context, mirScript, Kind.HttpGet) - script.push(OperatorCode.BooleanAsString) + script.push(OperatorCode.BooleanToString) const expectedCode = 32 const expectedArguments: any = [] diff --git a/test/src/source.spec.ts b/test/src/source.spec.ts index 00071bbeb..541017a74 100644 --- a/test/src/source.spec.ts +++ b/test/src/source.spec.ts @@ -44,7 +44,7 @@ describe('Source', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const mirSource = { @@ -104,7 +104,7 @@ describe('Source', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const mirSource = { @@ -226,7 +226,7 @@ describe('Source', () => { const mirScript: MirScript = [ OperatorCode.StringAsBoolean, OperatorCode.BooleanNegate, - OperatorCode.BooleanAsString, + OperatorCode.BooleanToString, ] const mirSource = {