Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Composer/packages/tools/built-in-functions/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/* eslint-disable @typescript-eslint/no-var-requires */

const { createConfig } = require('@botframework-composer/test-utils');

module.exports = createConfig('built-in-functions', 'node');
6 changes: 5 additions & 1 deletion Composer/packages/tools/built-in-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"description": "",
"main": "lib/index.js",
"scripts": {
"build": "rimraf ./lib && tsc --build tsconfig.build.json"
"build": "rimraf ./lib && tsc --build tsconfig.build.json",
"test": "jest"
},
"devDependencies": {
"@botframework-composer/test-utils": "*"
},
"author": "Microsoft",
"license": "MIT"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { builtInFunctionsGrouping } from '../builtInFunctionsGrouping';
import { getBuiltInFunctionInsertText } from '../builtInFunctionsUtils';

// List of all built in functions
const builtInFunctionNames = builtInFunctionsGrouping.reduce((acc, item) => {
acc.push(...item.children);
return acc;
}, []);

describe('Built-in functions', () => {
test.each(builtInFunctionNames)('given %p as function name, returns function call insert text', (functionName) => {
const result = getBuiltInFunctionInsertText(functionName);
// Expect it to have a string value that is not empty
expect(!!result).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
[
'contains',
new FunctionEntity(
['collection: stirng|Array|Map', 'value: stirng|Array|Map'],
['collection: string|Array|Map', 'value: string|Array|Map'],
ReturnType.Boolean,
'Works to find an item in a string or to find an item in an array or to find a parameter in a complex object. E.g. contains(‘hello world, ‘hello); contains([‘1’, ‘2’], ‘1’); contains({“foo”:”bar”}, “foo”).'
),
Expand Down Expand Up @@ -502,7 +502,6 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
'Return string version of the specified value.'
),
],
['jsonStringfy', new FunctionEntity(['value: any'], ReturnType.String, 'Return the string version of a value.')],
['EOL', new FunctionEntity([], ReturnType.String, 'Return the end of line (EOL) sequence text.')],
[
'bool',
Expand Down Expand Up @@ -754,15 +753,15 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
),
],
[
'convertFromUtc',
'convertFromUTC',
new FunctionEntity(
['timestamp: string', 'destinationTimeZone: string', 'format?: string', 'locale?: string'],
ReturnType.String,
'Convert a timestamp from Universal Time Coordinated(UTC) to target time zone.'
),
],
[
'convertToUtc',
'convertToUTC',
new FunctionEntity(
['timestamp: string', 'sourceTimeZone: string', 'format?: string', 'locale?: string'],
ReturnType.String,
Expand Down Expand Up @@ -880,7 +879,7 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
[
'where',
new FunctionEntity(
['collection: Array | Object', 'iteratorName: string', 'confitionFunction: any'],
['collection: Array | Object', 'iteratorName: string', 'conditionFunction: any'],
ReturnType.Object,
'Filter on each element and return the new collection of filtered elements which match specific condition.'
),
Expand All @@ -893,6 +892,15 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
'Sort elements in the collection with ascending order and return the sorted collection.'
),
],
['unique', new FunctionEntity(['collection: Array'], ReturnType.Array, 'Remove all duplicates from an array.')],
[
'flatten',
new FunctionEntity(
['collection: Array', 'depth: Number'],
ReturnType.Object,
'Flatten an array into non-array values. You can optionally set the maximum depth to flatten to.'
),
],
[
'sortByDescending',
new FunctionEntity(
Expand All @@ -917,6 +925,14 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
'Check JSON or JSON string for nodes or value that match a path expression, and return the matching nodes.'
),
],
[
'xPath',
new FunctionEntity(
['xml: any', 'xPath: any'],
ReturnType.Object,
'C# only. Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values. An XPath expression (referred to as XPath) helps you navigate an XML document structure so that you can select nodes or compute values in the XML content.'
),
],
[
'setPathToValue',
new FunctionEntity(
Expand All @@ -934,7 +950,7 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
),
],

//type checing functions
//type checking functions
[
'isInteger',
new FunctionEntity(['input: any'], ReturnType.Boolean, 'determine whether a given input is an integer number.'),
Expand Down Expand Up @@ -993,6 +1009,62 @@ export const buildInFunctionsMap: Map<string, FunctionEntity> = new Map<string,
'Return whether a given template name is included in the evaluator.'
),
],
[
'isDate',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to a valid date. Valid dates contain the month and dayOfMonth, or contain the dayOfWeek.'
),
],
[
'isDateRange',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to a valid date range.'
),
],
[
'isDefinite',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to a valid date. Valid dates contain the year, month and dayOfMonth.'
),
],
[
'isDuration',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to a valid duration.'
),
],
[
'isPresent',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to the present.'
),
],
[
'isTime',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to a valid time. Valid time contains hours, minutes and seconds.'
),
],
[
'isTimeRange',
new FunctionEntity(
['input: string|object'],
ReturnType.Boolean,
'Return true if a given TimexProperty or Timex expression refers to a valid time range Valid time ranges contain partOfDay.'
),
],
[
'ActivityAttachment',
new FunctionEntity(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
/* Options used for building production code (tests excluded) */
"extends": "./tsconfig.json",
"include": [
"./src/**/*"
]
"include": ["./src/**/*"],
"exclude": ["node_modules", "**/__tests__/**"]
}