@fincity/kirun-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/.prettierrc +9 -0
  2. package/__tests__/engine/function/system/array/AddFirstTest.ts +235 -0
  3. package/__tests__/engine/function/system/array/AddTest.ts +126 -0
  4. package/__tests__/engine/function/system/array/BinarySearchTest.ts +135 -0
  5. package/__tests__/engine/function/system/array/CompareTest.ts +48 -0
  6. package/__tests__/engine/function/system/array/CopyTest.ts +86 -0
  7. package/__tests__/engine/function/system/array/DeleteFirstTest.ts +103 -0
  8. package/__tests__/engine/function/system/array/DeleteFromTest.ts +232 -0
  9. package/__tests__/engine/function/system/array/DeleteLastTest.ts +103 -0
  10. package/__tests__/engine/function/system/array/DeleteTest.ts +110 -0
  11. package/__tests__/engine/function/system/array/DisjointTest.ts +184 -0
  12. package/__tests__/engine/function/system/array/Equals.ts +67 -0
  13. package/__tests__/engine/function/system/array/FillTest.ts +36 -0
  14. package/__tests__/engine/function/system/array/FrequencyTest.ts +97 -0
  15. package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +347 -0
  16. package/__tests__/engine/function/system/array/IndexOfTest.ts +267 -0
  17. package/__tests__/engine/function/system/array/InsertTest.ts +229 -0
  18. package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +213 -0
  19. package/__tests__/engine/function/system/array/LastIndexOfTest.ts +253 -0
  20. package/__tests__/engine/function/system/array/MaxTest.ts +98 -0
  21. package/__tests__/engine/function/system/array/MinTest.ts +99 -0
  22. package/__tests__/engine/function/system/array/MisMatchTest.ts +215 -0
  23. package/__tests__/engine/function/system/array/ReverseTest.ts +235 -0
  24. package/__tests__/engine/function/system/array/RotateTest.ts +137 -0
  25. package/__tests__/engine/function/system/array/ShuffleTest.ts +154 -0
  26. package/__tests__/engine/function/system/array/SortTest.ts +130 -0
  27. package/__tests__/engine/function/system/array/SubArrayTest.ts +236 -0
  28. package/__tests__/engine/function/system/math/AddTest.ts +12 -0
  29. package/__tests__/engine/function/system/string/ConcatenateTest.ts +46 -0
  30. package/__tests__/engine/function/system/string/DeleteForGivenLengthTest.ts +38 -0
  31. package/__tests__/engine/function/system/string/InsertAtGivenPositionTest.ts +53 -0
  32. package/__tests__/engine/function/system/string/PostPadTest.ts +54 -0
  33. package/__tests__/engine/function/system/string/PrePadTest.ts +54 -0
  34. package/__tests__/engine/function/system/string/RegionMatchesTest.ts +78 -0
  35. package/__tests__/engine/function/system/string/ReverseTest.ts +36 -0
  36. package/__tests__/engine/function/system/string/SplitTest.ts +61 -0
  37. package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +126 -0
  38. package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +54 -0
  39. package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +146 -0
  40. package/__tests__/engine/function/system/string/ToStringTest.ts +43 -0
  41. package/__tests__/engine/function/system/string/TrimToTest.ts +28 -0
  42. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +26 -0
  43. package/__tests__/engine/runtime/KIRuntimeTest.ts +351 -0
  44. package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +128 -0
  45. package/__tests__/engine/runtime/expression/ExpressionTest.ts +33 -0
  46. package/__tests__/engine/runtime/expression/tokenextractor/OutputMapTokenValueExtractorTest.ts +44 -0
  47. package/__tests__/engine/runtime/expression/tokenextractor/TokenValueExtractorTest.ts +72 -0
  48. package/__tests__/engine/util/LinkedListTest.ts +29 -0
  49. package/__tests__/engine/util/string/StringFormatterTest.ts +17 -0
  50. package/__tests__/indexTest.ts +33 -0
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/module.js +2 -0
  54. package/dist/module.js.map +1 -0
  55. package/dist/types.d.ts +430 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/package.json +54 -0
  58. package/src/engine/HybridRepository.ts +18 -0
  59. package/src/engine/Repository.ts +3 -0
  60. package/src/engine/constant/KIRunConstants.ts +7 -0
  61. package/src/engine/exception/ExecutionException.ts +12 -0
  62. package/src/engine/exception/KIRuntimeException.ts +12 -0
  63. package/src/engine/function/AbstractFunction.ts +76 -0
  64. package/src/engine/function/Function.ts +13 -0
  65. package/src/engine/function/system/GenerateEvent.ts +76 -0
  66. package/src/engine/function/system/If.ts +40 -0
  67. package/src/engine/function/system/array/AbstractArrayFunction.ts +158 -0
  68. package/src/engine/function/system/array/Add.ts +31 -0
  69. package/src/engine/function/system/array/AddFirst.ts +44 -0
  70. package/src/engine/function/system/array/BinarySearch.ts +66 -0
  71. package/src/engine/function/system/array/Compare.ts +150 -0
  72. package/src/engine/function/system/array/Copy.ts +56 -0
  73. package/src/engine/function/system/array/Delete.ts +63 -0
  74. package/src/engine/function/system/array/DeleteFirst.ts +22 -0
  75. package/src/engine/function/system/array/DeleteFrom.ts +51 -0
  76. package/src/engine/function/system/array/DeleteLast.ts +23 -0
  77. package/src/engine/function/system/array/Disjoint.ts +85 -0
  78. package/src/engine/function/system/array/Equals.ts +36 -0
  79. package/src/engine/function/system/array/Fill.ts +51 -0
  80. package/src/engine/function/system/array/Frequency.ts +68 -0
  81. package/src/engine/function/system/array/IndexOf.ts +56 -0
  82. package/src/engine/function/system/array/IndexOfArray.ts +67 -0
  83. package/src/engine/function/system/array/Insert.ts +48 -0
  84. package/src/engine/function/system/array/LastIndexOf.ts +62 -0
  85. package/src/engine/function/system/array/LastIndexOfArray.ts +70 -0
  86. package/src/engine/function/system/array/Max.ts +31 -0
  87. package/src/engine/function/system/array/Min.ts +32 -0
  88. package/src/engine/function/system/array/MisMatch.ts +66 -0
  89. package/src/engine/function/system/array/Reverse.ts +50 -0
  90. package/src/engine/function/system/array/Rotate.ts +43 -0
  91. package/src/engine/function/system/array/Shuffle.ts +31 -0
  92. package/src/engine/function/system/array/Sort.ts +70 -0
  93. package/src/engine/function/system/array/SubArray.ts +48 -0
  94. package/src/engine/function/system/context/Create.ts +73 -0
  95. package/src/engine/function/system/context/Get.ts +55 -0
  96. package/src/engine/function/system/context/SetFunction.ts +244 -0
  97. package/src/engine/function/system/loop/CountLoop.ts +55 -0
  98. package/src/engine/function/system/loop/RangeLoop.ts +120 -0
  99. package/src/engine/function/system/math/Add.ts +34 -0
  100. package/src/engine/function/system/math/GenericMathFunction.ts +80 -0
  101. package/src/engine/function/system/math/Hypotenuse.ts +57 -0
  102. package/src/engine/function/system/math/MathFunctionRepository.ts +63 -0
  103. package/src/engine/function/system/math/Maximum.ts +38 -0
  104. package/src/engine/function/system/math/Minimum.ts +38 -0
  105. package/src/engine/function/system/math/Random.ts +27 -0
  106. package/src/engine/function/system/string/AbstractStringFunction.ts +409 -0
  107. package/src/engine/function/system/string/Concatenate.ts +57 -0
  108. package/src/engine/function/system/string/DeleteForGivenLength.ts +82 -0
  109. package/src/engine/function/system/string/InsertAtGivenPosition.ts +72 -0
  110. package/src/engine/function/system/string/PostPad.ts +83 -0
  111. package/src/engine/function/system/string/PrePad.ts +73 -0
  112. package/src/engine/function/system/string/RegionMatches.ts +119 -0
  113. package/src/engine/function/system/string/ReplaceAtGivenPosition.ts +101 -0
  114. package/src/engine/function/system/string/Reverse.ts +62 -0
  115. package/src/engine/function/system/string/Split.ts +53 -0
  116. package/src/engine/function/system/string/StringFunctionRepository.ts +60 -0
  117. package/src/engine/function/system/string/ToString.ts +45 -0
  118. package/src/engine/function/system/string/TrimTo.ts +55 -0
  119. package/src/engine/json/JsonExpression.ts +11 -0
  120. package/src/engine/json/schema/Schema.ts +670 -0
  121. package/src/engine/json/schema/SchemaUtil.ts +145 -0
  122. package/src/engine/json/schema/array/ArraySchemaType.ts +44 -0
  123. package/src/engine/json/schema/object/AdditionalPropertiesType.ts +32 -0
  124. package/src/engine/json/schema/string/StringFormat.ts +7 -0
  125. package/src/engine/json/schema/type/MultipleType.ts +28 -0
  126. package/src/engine/json/schema/type/SchemaType.ts +11 -0
  127. package/src/engine/json/schema/type/SingleType.ts +23 -0
  128. package/src/engine/json/schema/type/Type.ts +6 -0
  129. package/src/engine/json/schema/type/TypeUtil.ts +25 -0
  130. package/src/engine/json/schema/validator/AnyOfAllOfOneOfValidator.ts +108 -0
  131. package/src/engine/json/schema/validator/ArrayValidator.ts +145 -0
  132. package/src/engine/json/schema/validator/BooleanValidator.ts +24 -0
  133. package/src/engine/json/schema/validator/NullValidator.ts +17 -0
  134. package/src/engine/json/schema/validator/NumberValidator.ts +115 -0
  135. package/src/engine/json/schema/validator/ObjectValidator.ts +184 -0
  136. package/src/engine/json/schema/validator/SchemaValidator.ts +141 -0
  137. package/src/engine/json/schema/validator/StringValidator.ts +97 -0
  138. package/src/engine/json/schema/validator/TypeValidator.ts +49 -0
  139. package/src/engine/json/schema/validator/exception/SchemaReferenceException.ts +19 -0
  140. package/src/engine/json/schema/validator/exception/SchemaValidationException.ts +22 -0
  141. package/src/engine/model/AbstractStatement.ts +29 -0
  142. package/src/engine/model/Argument.ts +36 -0
  143. package/src/engine/model/Event.ts +62 -0
  144. package/src/engine/model/EventResult.ts +34 -0
  145. package/src/engine/model/FunctionDefinition.ts +69 -0
  146. package/src/engine/model/FunctionOutput.ts +37 -0
  147. package/src/engine/model/FunctionOutputGenerator.ts +5 -0
  148. package/src/engine/model/FunctionSignature.ts +67 -0
  149. package/src/engine/model/Parameter.ts +97 -0
  150. package/src/engine/model/ParameterReference.ts +57 -0
  151. package/src/engine/model/ParameterReferenceType.ts +4 -0
  152. package/src/engine/model/ParameterType.ts +4 -0
  153. package/src/engine/model/Position.ts +40 -0
  154. package/src/engine/model/Statement.ts +101 -0
  155. package/src/engine/model/StatementGroup.ts +37 -0
  156. package/src/engine/namespaces/Namespaces.ts +11 -0
  157. package/src/engine/repository/KIRunFunctionRepository.ts +37 -0
  158. package/src/engine/repository/KIRunSchemaRepository.ts +24 -0
  159. package/src/engine/runtime/ContextElement.ts +28 -0
  160. package/src/engine/runtime/FunctionExecutionParameters.ts +74 -0
  161. package/src/engine/runtime/KIRuntime.ts +653 -0
  162. package/src/engine/runtime/StatementExecution.ts +61 -0
  163. package/src/engine/runtime/StatementMessage.ts +30 -0
  164. package/src/engine/runtime/StatementMessageType.ts +5 -0
  165. package/src/engine/runtime/expression/Expression.ts +330 -0
  166. package/src/engine/runtime/expression/ExpressionEvaluator.ts +305 -0
  167. package/src/engine/runtime/expression/ExpressionToken.ts +15 -0
  168. package/src/engine/runtime/expression/ExpressionTokenValue.ts +23 -0
  169. package/src/engine/runtime/expression/Operation.ts +190 -0
  170. package/src/engine/runtime/expression/exception/ExpressionEvaluationException.ts +15 -0
  171. package/src/engine/runtime/expression/operators/binary/ArithmeticAdditionOperator.ts +9 -0
  172. package/src/engine/runtime/expression/operators/binary/ArithmeticDivisionOperator.ts +9 -0
  173. package/src/engine/runtime/expression/operators/binary/ArithmeticInetgerDivisionOperator.ts +9 -0
  174. package/src/engine/runtime/expression/operators/binary/ArithmeticModulusOperator.ts +9 -0
  175. package/src/engine/runtime/expression/operators/binary/ArithmeticMultiplicationOperator.ts +9 -0
  176. package/src/engine/runtime/expression/operators/binary/ArithmeticSubtractionOperator.ts +9 -0
  177. package/src/engine/runtime/expression/operators/binary/ArrayOperator.ts +31 -0
  178. package/src/engine/runtime/expression/operators/binary/BinaryOperator.ts +15 -0
  179. package/src/engine/runtime/expression/operators/binary/BitwiseAndOperator.ts +9 -0
  180. package/src/engine/runtime/expression/operators/binary/BitwiseLeftShiftOperator.ts +9 -0
  181. package/src/engine/runtime/expression/operators/binary/BitwiseOrOperator.ts +9 -0
  182. package/src/engine/runtime/expression/operators/binary/BitwiseRightShiftOperator.ts +9 -0
  183. package/src/engine/runtime/expression/operators/binary/BitwiseUnsignedRightShiftOperator.ts +9 -0
  184. package/src/engine/runtime/expression/operators/binary/BitwiseXorOperator.ts +9 -0
  185. package/src/engine/runtime/expression/operators/binary/LogicalAndOperator.ts +25 -0
  186. package/src/engine/runtime/expression/operators/binary/LogicalEqualOperator.ts +13 -0
  187. package/src/engine/runtime/expression/operators/binary/LogicalGreaterThanEqualOperator.ts +24 -0
  188. package/src/engine/runtime/expression/operators/binary/LogicalGreaterThanOperator.ts +24 -0
  189. package/src/engine/runtime/expression/operators/binary/LogicalLessThanEqualOperator.ts +24 -0
  190. package/src/engine/runtime/expression/operators/binary/LogicalLessThanOperator.ts +24 -0
  191. package/src/engine/runtime/expression/operators/binary/LogicalNotEqualOperator.ts +13 -0
  192. package/src/engine/runtime/expression/operators/binary/LogicalOrOperator.ts +25 -0
  193. package/src/engine/runtime/expression/operators/binary/ObjectOperator.ts +24 -0
  194. package/src/engine/runtime/expression/operators/unary/ArithmeticUnaryMinusOperator.ts +13 -0
  195. package/src/engine/runtime/expression/operators/unary/ArithmeticUnaryPlusOperator.ts +13 -0
  196. package/src/engine/runtime/expression/operators/unary/BitwiseComplementOperator.ts +22 -0
  197. package/src/engine/runtime/expression/operators/unary/LogicalNotOperator.ts +22 -0
  198. package/src/engine/runtime/expression/operators/unary/UnaryOperator.ts +15 -0
  199. package/src/engine/runtime/expression/tokenextractor/LiteralTokenValueExtractor.ts +64 -0
  200. package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +136 -0
  201. package/src/engine/runtime/graph/ExecutionGraph.ts +81 -0
  202. package/src/engine/runtime/graph/GraphVertex.ts +118 -0
  203. package/src/engine/runtime/graph/GraphVertexType.ts +4 -0
  204. package/src/engine/runtime/tokenextractor/ArgumentsTokenValueExtractor.ts +22 -0
  205. package/src/engine/runtime/tokenextractor/ContextTokenValueExtractor.ts +37 -0
  206. package/src/engine/runtime/tokenextractor/OutputMapTokenValueExtractor.ts +32 -0
  207. package/src/engine/util/ArrayUtil.ts +23 -0
  208. package/src/engine/util/LinkedList.ts +229 -0
  209. package/src/engine/util/MapUtil.ts +86 -0
  210. package/src/engine/util/NullCheck.ts +3 -0
  211. package/src/engine/util/Tuples.ts +43 -0
  212. package/src/engine/util/primitive/PrimitiveUtil.ts +143 -0
  213. package/src/engine/util/string/StringBuilder.ts +59 -0
  214. package/src/engine/util/string/StringFormatter.ts +25 -0
  215. package/src/engine/util/string/StringUtil.ts +48 -0
  216. package/src/index.ts +13 -0
  217. package/tsconfig.json +6 -0
@@ -0,0 +1,72 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { Namespaces } from '../../../namespaces/Namespaces';
8
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
+ import { AbstractFunction } from '../../AbstractFunction';
10
+
11
+ export class InsertAtGivenPosition extends AbstractFunction {
12
+ public static readonly PARAMETER_STRING_NAME: string = 'string';
13
+
14
+ public static readonly PARAMETER_AT_POSITION_NAME: string = 'position';
15
+
16
+ public static readonly PARAMETER_INSERT_STRING_NAME: string = 'insertString';
17
+
18
+ protected readonly EVENT_RESULT_NAME: string = 'result';
19
+
20
+ protected readonly PARAMETER_STRING: Parameter =new Parameter(InsertAtGivenPosition.PARAMETER_STRING_NAME,Schema.ofString(InsertAtGivenPosition.PARAMETER_STRING_NAME));
21
+
22
+ protected readonly PARAMETER_AT_POSITION: Parameter =new Parameter(InsertAtGivenPosition.PARAMETER_AT_POSITION_NAME,Schema.ofInteger(InsertAtGivenPosition.PARAMETER_AT_POSITION_NAME));
23
+
24
+ protected readonly PARAMETER_INSERT_STRING: Parameter =new Parameter(InsertAtGivenPosition.PARAMETER_INSERT_STRING_NAME,Schema.ofString(InsertAtGivenPosition.PARAMETER_INSERT_STRING_NAME));
25
+
26
+ protected readonly EVENT_STRING: Event =new Event(Event.OUTPUT,
27
+ new Map([[this.EVENT_RESULT_NAME, Schema.ofString(this.EVENT_RESULT_NAME)]]),
28
+ );
29
+
30
+ private signature: FunctionSignature = new FunctionSignature('InsertAtGivenPosition')
31
+ .setNamespace(Namespaces.STRING)
32
+ .setParameters(
33
+ new Map([
34
+ [this.PARAMETER_STRING.getParameterName(), this.PARAMETER_STRING],
35
+ [this.PARAMETER_AT_POSITION.getParameterName(), this.PARAMETER_AT_POSITION],
36
+ [this.PARAMETER_INSERT_STRING.getParameterName(), this.PARAMETER_INSERT_STRING],
37
+ ]),
38
+ )
39
+ .setEvents(
40
+ new Map([
41
+ Event.outputEventMapEntry(
42
+ new Map([[this.EVENT_RESULT_NAME, Schema.ofString(this.EVENT_RESULT_NAME)]]),
43
+ ),
44
+ ]),
45
+ );
46
+
47
+ public getSignature(): FunctionSignature {
48
+ return this.signature;
49
+ }
50
+
51
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
52
+ let inputString: string = context
53
+ ?.getArguments()
54
+ ?.get(InsertAtGivenPosition.PARAMETER_STRING_NAME);
55
+ let at: number = context
56
+ ?.getArguments()
57
+ ?.get(InsertAtGivenPosition.PARAMETER_AT_POSITION_NAME);
58
+ let insertString: string = context
59
+ ?.getArguments()
60
+ ?.get(InsertAtGivenPosition.PARAMETER_INSERT_STRING_NAME);
61
+
62
+ let outputString: string = '';
63
+
64
+ outputString += inputString.substring(0, at);
65
+ outputString += insertString;
66
+ outputString += inputString.substring(at);
67
+
68
+ return new FunctionOutput([
69
+ EventResult.outputOf(new Map([[this.EVENT_RESULT_NAME, outputString]])),
70
+ ]);
71
+ }
72
+ }
@@ -0,0 +1,83 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { Namespaces } from '../../../namespaces/Namespaces';
8
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
+ import { AbstractFunction } from '../../AbstractFunction';
10
+
11
+ export class PostPad extends AbstractFunction {
12
+ protected static readonly PARAMETER_STRING_NAME: string = 'string';
13
+
14
+ protected static readonly PARAMETER_POSTPAD_STRING_NAME: string = 'postpadString';
15
+
16
+ protected static readonly PARAMETER_LENGTH_NAME: string = 'length';
17
+
18
+ protected static readonly EVENT_RESULT_NAME: string = 'result';
19
+
20
+ protected static PARAMETER_STRING: Parameter =new Parameter(PostPad.PARAMETER_STRING_NAME,Schema.ofString(PostPad.PARAMETER_STRING_NAME));
21
+
22
+ protected static PARAMETER_POSTPAD_STRING: Parameter =new Parameter(PostPad.PARAMETER_POSTPAD_STRING_NAME,Schema.ofString(PostPad.PARAMETER_POSTPAD_STRING_NAME));
23
+
24
+ protected static PARAMETER_LENGTH: Parameter =new Parameter(PostPad.PARAMETER_LENGTH_NAME,Schema.ofInteger(PostPad.PARAMETER_LENGTH_NAME));
25
+
26
+ protected static EVENT_STRING: Event =new Event(Event.OUTPUT,
27
+ new Map([[PostPad.EVENT_RESULT_NAME, Schema.ofString(PostPad.EVENT_RESULT_NAME)]]),
28
+ );
29
+
30
+ private signature: FunctionSignature = new FunctionSignature('PostPad')
31
+ .setNamespace(Namespaces.STRING)
32
+ .setParameters(
33
+ new Map([
34
+ [PostPad.PARAMETER_STRING.getParameterName(), PostPad.PARAMETER_STRING],
35
+ [
36
+ PostPad.PARAMETER_POSTPAD_STRING.getParameterName(),
37
+ PostPad.PARAMETER_POSTPAD_STRING,
38
+ ],
39
+ [PostPad.PARAMETER_LENGTH.getParameterName(), PostPad.PARAMETER_LENGTH],
40
+ ]),
41
+ )
42
+ .setEvents(new Map([[PostPad.EVENT_STRING.getName(), PostPad.EVENT_STRING]]));
43
+
44
+ public constructor() {
45
+ super();
46
+ }
47
+
48
+ public getSignature(): FunctionSignature {
49
+ return this.signature;
50
+ }
51
+
52
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
53
+ let inputString: string = context.getArguments()?.get(PostPad.PARAMETER_STRING_NAME);
54
+ let postpadString: string = context
55
+ ?.getArguments()
56
+ ?.get(PostPad.PARAMETER_POSTPAD_STRING_NAME);
57
+
58
+ let length: number = context.getArguments()?.get(PostPad.PARAMETER_LENGTH_NAME);
59
+ let outputString: string = '';
60
+ let prepadStringLength: number = postpadString.length;
61
+
62
+ outputString += inputString;
63
+
64
+ while (prepadStringLength <= length) {
65
+ outputString += postpadString;
66
+ prepadStringLength += postpadString.length;
67
+ }
68
+
69
+ if (outputString.length - inputString.length < length) {
70
+ outputString += postpadString.substring(
71
+ 0,
72
+ length - (outputString.length - inputString.length),
73
+ );
74
+ }
75
+
76
+ return new FunctionOutput([
77
+ EventResult.of(
78
+ PostPad.EVENT_RESULT_NAME,
79
+ new Map([[PostPad.EVENT_RESULT_NAME, outputString.toString()]]),
80
+ ),
81
+ ]);
82
+ }
83
+ }
@@ -0,0 +1,73 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { Namespaces } from '../../../namespaces/Namespaces';
8
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
+ import { AbstractFunction } from '../../AbstractFunction';
10
+
11
+ export class PrePad extends AbstractFunction {
12
+ public static readonly PARAMETER_STRING_NAME: string = 'string';
13
+
14
+ public static readonly PARAMETER_PREPAD_STRING_NAME: string = 'prepadString';
15
+
16
+ public static readonly PARAMETER_LENGTH_NAME: string = 'length';
17
+
18
+ public static readonly EVENT_RESULT_NAME: string = 'result';
19
+
20
+ protected static readonly PARAMETER_STRING: Parameter =new Parameter(PrePad.PARAMETER_STRING_NAME,Schema.ofString(PrePad.PARAMETER_STRING_NAME));
21
+
22
+ protected static readonly PARAMETER_PREPAD_STRING: Parameter =new Parameter(PrePad.PARAMETER_PREPAD_STRING_NAME,Schema.ofString(PrePad.PARAMETER_PREPAD_STRING_NAME));
23
+
24
+ protected static readonly PARAMETER_LENGTH: Parameter =new Parameter(PrePad.PARAMETER_LENGTH_NAME,Schema.ofInteger(PrePad.PARAMETER_LENGTH_NAME));
25
+
26
+ protected static readonly EVENT_STRING: Event =new Event(Event.OUTPUT,
27
+ new Map([[PrePad.EVENT_RESULT_NAME, Schema.ofString(PrePad.EVENT_RESULT_NAME)]]),
28
+ );
29
+
30
+ private readonly signature: FunctionSignature = new FunctionSignature('PrePad')
31
+ .setNamespace(Namespaces.STRING)
32
+ .setParameters(
33
+ new Map([
34
+ [PrePad.PARAMETER_STRING.getParameterName(), PrePad.PARAMETER_STRING],
35
+ [PrePad.PARAMETER_PREPAD_STRING.getParameterName(), PrePad.PARAMETER_PREPAD_STRING],
36
+ [PrePad.PARAMETER_LENGTH.getParameterName(), PrePad.PARAMETER_LENGTH],
37
+ ]),
38
+ )
39
+ .setEvents(new Map([[PrePad.EVENT_STRING.getName(), PrePad.EVENT_STRING]]));
40
+
41
+ public getSignature(): FunctionSignature {
42
+ return this.signature;
43
+ }
44
+
45
+ public constructor() {
46
+ super();
47
+ }
48
+
49
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
50
+ let inputString: string = context.getArguments()?.get(PrePad.PARAMETER_STRING_NAME);
51
+ let prepadString: string = context.getArguments()?.get(PrePad.PARAMETER_PREPAD_STRING_NAME);
52
+ let length: number = context.getArguments()?.get(PrePad.PARAMETER_LENGTH_NAME);
53
+ let outputString: string = '';
54
+ let prepadStringLength: number = prepadString.length;
55
+
56
+ while (prepadStringLength <= length) {
57
+ outputString += prepadString;
58
+ prepadStringLength += prepadString.length;
59
+ }
60
+
61
+ if (outputString.length < length) {
62
+ outputString += prepadString.substring(0, length - outputString.length);
63
+ }
64
+
65
+ outputString += inputString;
66
+ return new FunctionOutput([
67
+ EventResult.of(
68
+ PrePad.EVENT_RESULT_NAME,
69
+ new Map([[PrePad.EVENT_RESULT_NAME, outputString]]),
70
+ ),
71
+ ]);
72
+ }
73
+ }
@@ -0,0 +1,119 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { Namespaces } from '../../../namespaces/Namespaces';
8
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
+ import { AbstractFunction } from '../../AbstractFunction';
10
+
11
+ export class RegionMatches extends AbstractFunction {
12
+ public static readonly PARAMETER_STRING_NAME: string = 'string';
13
+
14
+ public static readonly PARAMETER_BOOLEAN_NAME: string = 'boolean';
15
+
16
+ public static readonly PARAMETER_FIRST_OFFSET_NAME: string = 'firstOffset';
17
+
18
+ public static readonly PARAMETER_OTHER_STRING_NAME: string = 'otherString';
19
+
20
+ public static readonly PARAMETER_SECOND_OFFSET_NAME: string = 'secondOffset';
21
+
22
+ public static readonly PARAMETER_INTEGER_NAME: string = 'length';
23
+
24
+ public static readonly EVENT_RESULT_NAME: string = 'result';
25
+
26
+ public static PARAMETER_STRING: Parameter =new Parameter(RegionMatches.PARAMETER_STRING_NAME,Schema.ofString(RegionMatches.PARAMETER_STRING_NAME));
27
+
28
+ protected static PARAMETER_OTHER_STRING: Parameter =new Parameter(RegionMatches.PARAMETER_OTHER_STRING_NAME,Schema.ofString(RegionMatches.PARAMETER_OTHER_STRING_NAME));
29
+
30
+ protected static PARAMETER_FIRST_OFFSET: Parameter =new Parameter(RegionMatches.PARAMETER_FIRST_OFFSET_NAME,Schema.ofInteger(RegionMatches.PARAMETER_FIRST_OFFSET_NAME));
31
+
32
+ protected static PARAMETER_SECOND_OFFSET: Parameter =new Parameter(RegionMatches.PARAMETER_SECOND_OFFSET_NAME,Schema.ofInteger(RegionMatches.PARAMETER_SECOND_OFFSET_NAME));
33
+
34
+ protected static PARAMETER_INTEGER: Parameter =new Parameter(RegionMatches.PARAMETER_INTEGER_NAME,Schema.ofInteger(RegionMatches.PARAMETER_INTEGER_NAME));
35
+
36
+ protected static PARAMETER_BOOLEAN: Parameter =new Parameter(RegionMatches.PARAMETER_BOOLEAN_NAME,Schema.ofBoolean(RegionMatches.PARAMETER_BOOLEAN_NAME));
37
+
38
+ protected static EVENT_BOOLEAN: Event =new Event(Event.OUTPUT,
39
+ new Map([
40
+ [
41
+ RegionMatches.EVENT_RESULT_NAME,
42
+ Schema.ofBoolean(RegionMatches.EVENT_RESULT_NAME),
43
+ ],
44
+ ]),
45
+ );
46
+
47
+ private signature: FunctionSignature = new FunctionSignature('RegionMatches')
48
+ .setNamespace(Namespaces.STRING)
49
+ .setParameters(
50
+ new Map([
51
+ [RegionMatches.PARAMETER_STRING.getParameterName(), RegionMatches.PARAMETER_STRING],
52
+ [
53
+ RegionMatches.PARAMETER_BOOLEAN.getParameterName(),
54
+ RegionMatches.PARAMETER_BOOLEAN,
55
+ ],
56
+ [
57
+ RegionMatches.PARAMETER_FIRST_OFFSET.getParameterName(),
58
+ RegionMatches.PARAMETER_FIRST_OFFSET,
59
+ ],
60
+ [
61
+ RegionMatches.PARAMETER_OTHER_STRING.getParameterName(),
62
+ RegionMatches.PARAMETER_OTHER_STRING,
63
+ ],
64
+ [
65
+ RegionMatches.PARAMETER_SECOND_OFFSET.getParameterName(),
66
+ RegionMatches.PARAMETER_SECOND_OFFSET,
67
+ ],
68
+ [
69
+ RegionMatches.PARAMETER_INTEGER.getParameterName(),
70
+ RegionMatches.PARAMETER_INTEGER,
71
+ ],
72
+ ]),
73
+ )
74
+ .setEvents(new Map([[RegionMatches.EVENT_BOOLEAN.getName(), RegionMatches.EVENT_BOOLEAN]]));
75
+
76
+ public getSignature(): FunctionSignature {
77
+ return this.signature;
78
+ }
79
+
80
+ public constructor() {
81
+ super();
82
+ }
83
+
84
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
85
+ let inputString: string = context.getArguments()?.get(RegionMatches.PARAMETER_STRING_NAME);
86
+ let ignoreCase: boolean = context.getArguments()?.get(RegionMatches.PARAMETER_BOOLEAN_NAME);
87
+ let toffSet: number = context.getArguments()?.get(RegionMatches.PARAMETER_FIRST_OFFSET_NAME);
88
+ let otherString: string = context
89
+ ?.getArguments()
90
+ ?.get(RegionMatches.PARAMETER_OTHER_STRING_NAME);
91
+ let oOffSet: number = context
92
+ ?.getArguments()
93
+ ?.get(RegionMatches.PARAMETER_SECOND_OFFSET_NAME);
94
+ let length: number = context.getArguments()?.get(RegionMatches.PARAMETER_INTEGER_NAME);
95
+
96
+ let matches: boolean = false;
97
+
98
+ if (
99
+ toffSet < 0 ||
100
+ oOffSet < 0 ||
101
+ toffSet + length > inputString.length ||
102
+ oOffSet + length > otherString.length
103
+ )
104
+ matches = false;
105
+ else if (ignoreCase) {
106
+ inputString = inputString.substring(toffSet, toffSet + length).toUpperCase();
107
+ let s2: string = otherString.substring(oOffSet, oOffSet + length).toUpperCase();
108
+ matches = inputString == s2;
109
+ } else {
110
+ inputString = inputString.substring(toffSet, toffSet + length);
111
+ let s2: string = otherString.substring(oOffSet, length);
112
+ matches = inputString == s2;
113
+ }
114
+
115
+ return new FunctionOutput([
116
+ EventResult.outputOf(new Map([[RegionMatches.EVENT_RESULT_NAME, matches]])),
117
+ ]);
118
+ }
119
+ }
@@ -0,0 +1,101 @@
1
+ import { AbstractFunction, Namespaces, Schema } from '../../../..';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
8
+ import { StringBuilder } from '../../../util/string/StringBuilder';
9
+
10
+ export class ReplaceAtGivenPosition extends AbstractFunction {
11
+ protected static readonly PARAMETER_STRING_NAME: string = 'string';
12
+
13
+ protected static readonly PARAMETER_AT_START_NAME: string = 'startPosition';
14
+
15
+ protected static readonly PARAMETER_AT_LENGTH_NAME: string = 'lengthPosition';
16
+
17
+ protected static readonly PARAMETER_REPLACE_STRING_NAME: string = 'replaceString';
18
+
19
+ protected static readonly EVENT_RESULT_NAME: string = 'result';
20
+
21
+ protected static PARAMETER_STRING: Parameter =new Parameter(ReplaceAtGivenPosition.PARAMETER_STRING_NAME,Schema.ofString(ReplaceAtGivenPosition.PARAMETER_STRING_NAME));
22
+
23
+ protected static PARAMETER_AT_START: Parameter =new Parameter(ReplaceAtGivenPosition.PARAMETER_AT_START_NAME,Schema.ofInteger(ReplaceAtGivenPosition.PARAMETER_AT_START_NAME));
24
+
25
+ protected static PARAMETER_AT_LENGTH: Parameter =new Parameter(ReplaceAtGivenPosition.PARAMETER_AT_LENGTH_NAME,Schema.ofInteger(ReplaceAtGivenPosition.PARAMETER_AT_LENGTH_NAME));
26
+
27
+ protected static PARAMETER_REPLACE_STRING: Parameter =new Parameter(ReplaceAtGivenPosition.PARAMETER_REPLACE_STRING_NAME,Schema.ofString(ReplaceAtGivenPosition.PARAMETER_REPLACE_STRING_NAME));
28
+
29
+ protected static EVENT_STRING: Event =new Event(Event.OUTPUT,
30
+ new Map([
31
+ [
32
+ ReplaceAtGivenPosition.EVENT_RESULT_NAME,
33
+ Schema.ofString(ReplaceAtGivenPosition.EVENT_RESULT_NAME),
34
+ ],
35
+ ]),
36
+ );
37
+
38
+ private signature: FunctionSignature = new FunctionSignature('ReplaceAtGivenPosition')
39
+ .setNamespace(Namespaces.STRING)
40
+ .setParameters(
41
+ new Map([
42
+ [
43
+ ReplaceAtGivenPosition.PARAMETER_STRING.getParameterName(),
44
+ ReplaceAtGivenPosition.PARAMETER_STRING,
45
+ ],
46
+ [
47
+ ReplaceAtGivenPosition.PARAMETER_AT_START.getParameterName(),
48
+ ReplaceAtGivenPosition.PARAMETER_AT_START,
49
+ ],
50
+ [
51
+ ReplaceAtGivenPosition.PARAMETER_AT_LENGTH.getParameterName(),
52
+ ReplaceAtGivenPosition.PARAMETER_AT_LENGTH,
53
+ ],
54
+ [
55
+ ReplaceAtGivenPosition.PARAMETER_REPLACE_STRING.getParameterName(),
56
+ ReplaceAtGivenPosition.PARAMETER_REPLACE_STRING,
57
+ ],
58
+ ]),
59
+ )
60
+ .setEvents(
61
+ new Map([
62
+ [
63
+ ReplaceAtGivenPosition.EVENT_STRING.getName(),
64
+ ReplaceAtGivenPosition.EVENT_STRING,
65
+ ],
66
+ ]),
67
+ );
68
+
69
+ public getSignature(): FunctionSignature {
70
+ return this.signature;
71
+ }
72
+
73
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
74
+ let inputString: string = context
75
+ ?.getArguments()
76
+ ?.get(ReplaceAtGivenPosition.PARAMETER_STRING_NAME);
77
+ let startPosition: number = context
78
+ ?.getArguments()
79
+ ?.get(ReplaceAtGivenPosition.PARAMETER_AT_START_NAME);
80
+ let length: number = context
81
+ ?.getArguments()
82
+ ?.get(ReplaceAtGivenPosition.PARAMETER_AT_LENGTH_NAME);
83
+ let replaceString: string = context
84
+ ?.getArguments()
85
+ ?.get(ReplaceAtGivenPosition.PARAMETER_REPLACE_STRING_NAME);
86
+ let inputStringLength: number = inputString.length;
87
+
88
+ if (startPosition < length) {
89
+ let outputString: string = '';
90
+ outputString += inputString.substring(0, startPosition);
91
+ outputString += replaceString;
92
+ outputString += inputString.substring(startPosition + length);
93
+ }
94
+
95
+ return new FunctionOutput([
96
+ EventResult.outputOf(
97
+ new Map([[ReplaceAtGivenPosition.EVENT_RESULT_NAME, inputString]]),
98
+ ),
99
+ ]);
100
+ }
101
+ }
@@ -0,0 +1,62 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionSignature } from '../../../model/FunctionSignature';
5
+ import { Parameter } from '../../../model/Parameter';
6
+ import { Namespaces } from '../../../namespaces/Namespaces';
7
+ import { AbstractFunction } from '../../AbstractFunction';
8
+ import { MapUtil } from '../../../util/MapUtil';
9
+ import { FunctionOutput } from '../../../model/FunctionOutput';
10
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
11
+ import { TypeUtil } from '../../../json/schema/type/TypeUtil';
12
+ import { SchemaType } from '../../../json/schema/type/SchemaType';
13
+
14
+ export class Reverse extends AbstractFunction {
15
+ protected readonly VALUE: string = 'value';
16
+
17
+ private readonly SIGNATURE: FunctionSignature = new FunctionSignature('Reverse')
18
+ .setNamespace(Namespaces.STRING)
19
+ .setParameters(
20
+ new Map([
21
+ [
22
+ this.VALUE,
23
+ new Parameter(this.VALUE,Schema.ofString(this.VALUE))
24
+ .setVariableArgument(true),
25
+ ],
26
+ ]),
27
+ )
28
+ .setEvents(
29
+ new Map([
30
+ Event.outputEventMapEntry(
31
+ new Map([
32
+ [
33
+ this.VALUE,
34
+ new Schema()
35
+ .setType(TypeUtil.of(SchemaType.STRING))
36
+ .setName(this.VALUE),
37
+ ],
38
+ ]),
39
+ ),
40
+ ]),
41
+ );
42
+
43
+ public constructor() {
44
+ super();
45
+ }
46
+
47
+ public getSignature(): FunctionSignature {
48
+ return this.SIGNATURE;
49
+ }
50
+
51
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
52
+ let acutalString: string = context.getArguments()?.get(this.VALUE);
53
+ let stringLength: number = acutalString.length - 1;
54
+ let reversedString: string = '';
55
+
56
+ while (stringLength >= 0) {
57
+ reversedString += acutalString.charAt(stringLength--);
58
+ }
59
+
60
+ return new FunctionOutput([EventResult.outputOf(MapUtil.of(this.VALUE, reversedString))]);
61
+ }
62
+ }
@@ -0,0 +1,53 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { Namespaces } from '../../../namespaces/Namespaces';
8
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
+ import { MapUtil } from '../../../util/MapUtil';
10
+ import { AbstractFunction } from '../../AbstractFunction';
11
+
12
+ export class Split extends AbstractFunction {
13
+ protected readonly PARAMETER_STRING_NAME: string = 'string';
14
+ protected readonly PARAMETER_SPLIT_STRING_NAME: string = 'searchString';
15
+ protected readonly EVENT_RESULT_NAME: string = 'result';
16
+
17
+ protected readonly PARAMETER_STRING: Parameter =new Parameter(this.PARAMETER_STRING_NAME,Schema.ofString(this.PARAMETER_STRING_NAME));
18
+
19
+ protected readonly PARAMETER_SPLIT_STRING: Parameter =new Parameter(this.PARAMETER_SPLIT_STRING_NAME,Schema.ofString(this.PARAMETER_SPLIT_STRING_NAME));
20
+
21
+ protected readonly EVENT_ARRAY: Event =new Event(Event.OUTPUT,MapUtil.of(this.EVENT_RESULT_NAME, Schema.ofArray(this.EVENT_RESULT_NAME)));
22
+
23
+ public getSignature(): FunctionSignature {
24
+ return new FunctionSignature('Split')
25
+ .setNamespace(Namespaces.STRING)
26
+ .setParameters(
27
+ new Map([
28
+ [this.PARAMETER_STRING_NAME, this.PARAMETER_STRING],
29
+ [this.PARAMETER_SPLIT_STRING_NAME, this.PARAMETER_SPLIT_STRING],
30
+ ]),
31
+ )
32
+ .setEvents(
33
+ new Map([
34
+ Event.outputEventMapEntry(
35
+ new Map([[this.EVENT_RESULT_NAME, Schema.ofArray(this.EVENT_RESULT_NAME)]]),
36
+ ) as [string, Event],
37
+ ]),
38
+ );
39
+ }
40
+
41
+ public constructor() {
42
+ super();
43
+ }
44
+
45
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
46
+ let s1: string = context.getArguments()?.get(this.PARAMETER_STRING_NAME);
47
+ let s2: string = context.getArguments()?.get(this.PARAMETER_SPLIT_STRING_NAME);
48
+
49
+ return new FunctionOutput([
50
+ EventResult.outputOf(MapUtil.of(this.EVENT_ARRAY.getName(), s1.split(s2))),
51
+ ]);
52
+ }
53
+ }
@@ -0,0 +1,60 @@
1
+ import { Namespaces } from '../../../namespaces/Namespaces';
2
+ import { Repository } from '../../../Repository';
3
+ import { MapUtil } from '../../../util/MapUtil';
4
+ import { Function } from '../../Function';
5
+ import { AbstractStringFunction } from './AbstractStringFunction';
6
+
7
+ export class StringFunctionRepository implements Repository<Function> {
8
+ private static readonly repoMap: Map<string, Function> = MapUtil.ofArrayEntries(
9
+ AbstractStringFunction.ofEntryString('Trim', (e) => e.trim()),
10
+ AbstractStringFunction.ofEntryString('LowerCase', (e) => e.toLocaleLowerCase()),
11
+ AbstractStringFunction.ofEntryString('UpperCase', (e) => e.toUpperCase()),
12
+ AbstractStringFunction.ofEntryStringBooleanOutput('Blank', (e) => e.trim() == ''),
13
+ AbstractStringFunction.ofEntryStringBooleanOutput('Empty', (e) => e == ''),
14
+
15
+ AbstractStringFunction.ofEntryAsStringBooleanOutput(
16
+ 'Contains',
17
+ (a, b) => a.indexOf(b) != -1,
18
+ ),
19
+ AbstractStringFunction.ofEntryAsStringBooleanOutput('EndsWith', (a, b) => a.endsWith(b)),
20
+ AbstractStringFunction.ofEntryAsStringBooleanOutput(
21
+ 'EqualsIgnoreCase',
22
+ (a, b) => a.toUpperCase() == b.toUpperCase(),
23
+ ),
24
+ AbstractStringFunction.ofEntryAsStringBooleanOutput('Matches', (a, b) =>
25
+ new RegExp(b).test(a),
26
+ ),
27
+ AbstractStringFunction.ofEntryAsStringIntegerOutput('IndexOf', (a, b) => a.indexOf(b)),
28
+ AbstractStringFunction.ofEntryAsStringIntegerOutput('LastIndexOf', (a, b) =>
29
+ a.lastIndexOf(b),
30
+ ),
31
+ AbstractStringFunction.ofEntryAsStringAndIntegerStringOutput('Repeat', (a, b) =>
32
+ a.repeat(b),
33
+ ),
34
+
35
+ AbstractStringFunction.ofEntryAsStringStringIntegerIntegerOutput(
36
+ 'IndexOfWithStartPoint',
37
+ (a, b, c) => a.indexOf(b, c),
38
+ ),
39
+ AbstractStringFunction.ofEntryAsStringStringIntegerIntegerOutput(
40
+ 'LastIndexOfWithStartPoint',
41
+ (a, b, c) => a.lastIndexOf(b, c),
42
+ ),
43
+ AbstractStringFunction.ofEntryAsStringStringStringStringOutput('Replace', (a, b, c) => {
44
+ return a;
45
+ }),
46
+ AbstractStringFunction.ofEntryAsStringStringStringStringOutput('ReplaceFirst', (a, b, c) =>
47
+ a.replace(b, c),
48
+ ),
49
+ AbstractStringFunction.ofEntryAsStringIntegerIntegerStringOutput('SubString', (a, b, c) =>
50
+ a.substring(b, c),
51
+ ),
52
+ );
53
+
54
+ public find(namespace: string, name: string): Function | undefined {
55
+ if (namespace != Namespaces.STRING) {
56
+ return undefined;
57
+ }
58
+ return StringFunctionRepository.repoMap.get(name);
59
+ }
60
+ }
@@ -0,0 +1,45 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { Event } from '../../../model/Event';
3
+ import { EventResult } from '../../../model/EventResult';
4
+ import { FunctionOutput } from '../../../model/FunctionOutput';
5
+ import { FunctionSignature } from '../../../model/FunctionSignature';
6
+ import { Parameter } from '../../../model/Parameter';
7
+ import { Namespaces } from '../../../namespaces/Namespaces';
8
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
+ import { AbstractFunction } from '../../AbstractFunction';
10
+
11
+ export class ToString extends AbstractFunction {
12
+ protected readonly PARAMETER_INPUT_ANYTYPE_NAME: string = 'anytype';
13
+
14
+ protected readonly EVENT_RESULT_NAME: string = 'result';
15
+
16
+ protected readonly PARAMETER_INPUT_ANYTYPE: Parameter =new Parameter(this.PARAMETER_INPUT_ANYTYPE_NAME,Schema.ofAny(this.PARAMETER_INPUT_ANYTYPE_NAME));
17
+
18
+ protected readonly EVENT_STRING: Event =new Event(Event.OUTPUT,
19
+ new Map([[this.EVENT_RESULT_NAME, Schema.ofString(this.EVENT_RESULT_NAME)]]),
20
+ );
21
+
22
+ public getSignature(): FunctionSignature {
23
+ return new FunctionSignature('ToString')
24
+ .setNamespace(Namespaces.STRING)
25
+ .setParameters(
26
+ new Map([
27
+ [this.PARAMETER_INPUT_ANYTYPE.getParameterName(), this.PARAMETER_INPUT_ANYTYPE],
28
+ ]),
29
+ )
30
+ .setEvents(new Map([[this.EVENT_STRING.getName(), this.EVENT_STRING]]));
31
+ }
32
+
33
+ public constructor() {
34
+ super();
35
+ }
36
+
37
+ protected internalExecute(context: FunctionExecutionParameters): FunctionOutput {
38
+ let input: any = context.getArguments()?.get(this.PARAMETER_INPUT_ANYTYPE_NAME);
39
+ let output: string = input + '';
40
+
41
+ return new FunctionOutput([
42
+ EventResult.outputOf(new Map([[this.EVENT_RESULT_NAME, output]])),
43
+ ]);
44
+ }
45
+ }