mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(editor): Add sections to autocomplete dropdown (#8720)
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
@@ -219,27 +219,35 @@ function plus(
|
||||
endOfMonth.doc = {
|
||||
name: 'endOfMonth',
|
||||
returnType: 'Date',
|
||||
hidden: true,
|
||||
description: 'Transforms a date to the last possible moment that lies within the month.',
|
||||
section: 'edit',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-endOfMonth',
|
||||
};
|
||||
|
||||
isDst.doc = {
|
||||
name: 'isDst',
|
||||
returnType: 'boolean',
|
||||
hidden: true,
|
||||
description: 'Checks if a Date is within Daylight Savings Time.',
|
||||
section: 'query',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isDst',
|
||||
};
|
||||
|
||||
isWeekend.doc = {
|
||||
name: 'isWeekend',
|
||||
returnType: 'boolean',
|
||||
hidden: true,
|
||||
description: 'Checks if the Date falls on a Saturday or Sunday.',
|
||||
section: 'query',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isWeekend',
|
||||
};
|
||||
|
||||
beginningOf.doc = {
|
||||
name: 'beginningOf',
|
||||
description: 'Transform a Date to the start of the given time period. Default unit is `week`.',
|
||||
section: 'edit',
|
||||
hidden: true,
|
||||
returnType: 'Date',
|
||||
args: [{ name: 'unit?', type: 'DurationUnit' }],
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-beginningOf',
|
||||
@@ -248,6 +256,7 @@ beginningOf.doc = {
|
||||
extract.doc = {
|
||||
name: 'extract',
|
||||
description: 'Extracts the part defined in `datePart` from a Date. Default unit is `week`.',
|
||||
section: 'query',
|
||||
returnType: 'number',
|
||||
args: [{ name: 'datePart?', type: 'DurationUnit' }],
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-extract',
|
||||
@@ -257,6 +266,7 @@ format.doc = {
|
||||
name: 'format',
|
||||
description: 'Formats a Date in the given structure.',
|
||||
returnType: 'string',
|
||||
section: 'format',
|
||||
args: [{ name: 'fmt', type: 'TimeFormat' }],
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-format',
|
||||
};
|
||||
@@ -264,6 +274,7 @@ format.doc = {
|
||||
isBetween.doc = {
|
||||
name: 'isBetween',
|
||||
description: 'Checks if a Date is between two given dates.',
|
||||
section: 'query',
|
||||
returnType: 'boolean',
|
||||
args: [
|
||||
{ name: 'date1', type: 'Date|string' },
|
||||
@@ -275,6 +286,7 @@ isBetween.doc = {
|
||||
isInLast.doc = {
|
||||
name: 'isInLast',
|
||||
description: 'Checks if a Date is within a given time period. Default unit is `minute`.',
|
||||
section: 'query',
|
||||
returnType: 'boolean',
|
||||
args: [
|
||||
{ name: 'n', type: 'number' },
|
||||
@@ -286,6 +298,7 @@ isInLast.doc = {
|
||||
minus.doc = {
|
||||
name: 'minus',
|
||||
description: 'Subtracts a given time period from a Date. Default unit is `milliseconds`.',
|
||||
section: 'edit',
|
||||
returnType: 'Date',
|
||||
args: [
|
||||
{ name: 'n', type: 'number' },
|
||||
@@ -297,6 +310,7 @@ minus.doc = {
|
||||
plus.doc = {
|
||||
name: 'plus',
|
||||
description: 'Adds a given time period to a Date. Default unit is `milliseconds`.',
|
||||
section: 'edit',
|
||||
returnType: 'Date',
|
||||
args: [
|
||||
{ name: 'n', type: 'number' },
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
export interface ExtensionMap {
|
||||
typeName: string;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
functions: Record<string, Function & { doc?: DocMetadata }>;
|
||||
functions: Record<string, Extension>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export type Extension = Function & { doc?: DocMetadata };
|
||||
|
||||
export type NativeDoc = {
|
||||
typeName: string;
|
||||
properties?: Record<string, { doc?: DocMetadata }>;
|
||||
@@ -14,6 +16,8 @@ export type DocMetadata = {
|
||||
name: string;
|
||||
returnType: string;
|
||||
description?: string;
|
||||
section?: string;
|
||||
hidden?: boolean;
|
||||
aliases?: string[];
|
||||
args?: Array<{ name: string; type?: string }>;
|
||||
docURL?: string;
|
||||
|
||||
@@ -9,6 +9,14 @@ function isNotEmpty(value: object): boolean {
|
||||
return !isEmpty(value);
|
||||
}
|
||||
|
||||
function keys(value: object): string[] {
|
||||
return Object.keys(value);
|
||||
}
|
||||
|
||||
function values(value: object): unknown[] {
|
||||
return Object.values(value);
|
||||
}
|
||||
|
||||
function hasField(value: object, extraArgs: string[]): boolean {
|
||||
const [name] = extraArgs;
|
||||
return name in value;
|
||||
@@ -146,6 +154,20 @@ keepFieldsContaining.doc = {
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/objects/#object-keepFieldsContaining',
|
||||
};
|
||||
|
||||
keys.doc = {
|
||||
name: 'keys',
|
||||
description: "Returns an array of a given object's own enumerable string-keyed property names.",
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/objects/#object-keys',
|
||||
returnType: 'Array',
|
||||
};
|
||||
|
||||
values.doc = {
|
||||
name: 'values',
|
||||
description: "Returns an array of a given object's own enumerable string-keyed property values.",
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/objects/#object-values',
|
||||
returnType: 'Array',
|
||||
};
|
||||
|
||||
export const objectExtensions: ExtensionMap = {
|
||||
typeName: 'Object',
|
||||
functions: {
|
||||
@@ -157,5 +179,7 @@ export const objectExtensions: ExtensionMap = {
|
||||
keepFieldsContaining,
|
||||
compact,
|
||||
urlEncode,
|
||||
keys,
|
||||
values,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import SHA from 'jssha';
|
||||
import MD5 from 'md5';
|
||||
import { encode } from 'js-base64';
|
||||
import { titleCase } from 'title-case';
|
||||
import type { ExtensionMap } from './Extensions';
|
||||
import type { Extension, ExtensionMap } from './Extensions';
|
||||
import { transliterate } from 'transliteration';
|
||||
import { ExpressionExtensionError } from '../errors/expression-extension.error';
|
||||
|
||||
@@ -362,6 +362,7 @@ function extractUrl(value: string) {
|
||||
removeMarkdown.doc = {
|
||||
name: 'removeMarkdown',
|
||||
description: 'Removes Markdown formatting from a string.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeMarkdown',
|
||||
@@ -370,6 +371,7 @@ removeMarkdown.doc = {
|
||||
removeTags.doc = {
|
||||
name: 'removeTags',
|
||||
description: 'Removes tags, such as HTML or XML, from a string.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeTags',
|
||||
@@ -378,6 +380,7 @@ removeTags.doc = {
|
||||
toDate.doc = {
|
||||
name: 'toDate',
|
||||
description: 'Converts a string to a date.',
|
||||
section: 'cast',
|
||||
returnType: 'Date',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDate',
|
||||
};
|
||||
@@ -385,6 +388,7 @@ toDate.doc = {
|
||||
toFloat.doc = {
|
||||
name: 'toFloat',
|
||||
description: 'Converts a string to a decimal number.',
|
||||
section: 'cast',
|
||||
returnType: 'number',
|
||||
aliases: ['toDecimalNumber'],
|
||||
docURL:
|
||||
@@ -394,6 +398,7 @@ toFloat.doc = {
|
||||
toInt.doc = {
|
||||
name: 'toInt',
|
||||
description: 'Converts a string to an integer.',
|
||||
section: 'cast',
|
||||
returnType: 'number',
|
||||
args: [{ name: 'radix?', type: 'number' }],
|
||||
aliases: ['toWholeNumber'],
|
||||
@@ -403,6 +408,7 @@ toInt.doc = {
|
||||
toSentenceCase.doc = {
|
||||
name: 'toSentenceCase',
|
||||
description: 'Formats a string to sentence case. Example: "This is a sentence".',
|
||||
section: 'case',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSentenceCase',
|
||||
@@ -411,6 +417,7 @@ toSentenceCase.doc = {
|
||||
toSnakeCase.doc = {
|
||||
name: 'toSnakeCase',
|
||||
description: 'Formats a string to snake case. Example: "this_is_snake_case".',
|
||||
section: 'case',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSnakeCase',
|
||||
@@ -420,6 +427,7 @@ toTitleCase.doc = {
|
||||
name: 'toTitleCase',
|
||||
description:
|
||||
'Formats a string to title case. Example: "This Is a Title". Will not change already uppercase letters to prevent losing information from acronyms and trademarks such as iPhone or FAANG.',
|
||||
section: 'case',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toTitleCase',
|
||||
@@ -428,6 +436,7 @@ toTitleCase.doc = {
|
||||
urlEncode.doc = {
|
||||
name: 'urlEncode',
|
||||
description: 'Encodes a string to be used/included in a URL.',
|
||||
section: 'edit',
|
||||
args: [{ name: 'entireString?', type: 'boolean' }],
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
@@ -438,6 +447,7 @@ urlDecode.doc = {
|
||||
name: 'urlDecode',
|
||||
description:
|
||||
'Decodes a URL-encoded string. It decodes any percent-encoded characters in the input string, and replaces them with their original characters.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlDecode',
|
||||
@@ -446,6 +456,7 @@ urlDecode.doc = {
|
||||
replaceSpecialChars.doc = {
|
||||
name: 'replaceSpecialChars',
|
||||
description: 'Replaces non-ASCII characters in a string with an ASCII representation.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-replaceSpecialChars',
|
||||
@@ -453,6 +464,8 @@ replaceSpecialChars.doc = {
|
||||
|
||||
length.doc = {
|
||||
name: 'length',
|
||||
section: 'query',
|
||||
hidden: true,
|
||||
description: 'Returns the character count of a string.',
|
||||
returnType: 'number',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings',
|
||||
@@ -461,6 +474,7 @@ length.doc = {
|
||||
isDomain.doc = {
|
||||
name: 'isDomain',
|
||||
description: 'Checks if a string is a domain.',
|
||||
section: 'validation',
|
||||
returnType: 'boolean',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isDomain',
|
||||
};
|
||||
@@ -468,13 +482,15 @@ isDomain.doc = {
|
||||
isEmail.doc = {
|
||||
name: 'isEmail',
|
||||
description: 'Checks if a string is an email.',
|
||||
section: 'validation',
|
||||
returnType: 'boolean',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmail',
|
||||
};
|
||||
|
||||
isNumeric.doc = {
|
||||
name: 'isEmail',
|
||||
name: 'isNumeric',
|
||||
description: 'Checks if a string only contains digits.',
|
||||
section: 'validation',
|
||||
returnType: 'boolean',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNumeric',
|
||||
@@ -483,6 +499,7 @@ isNumeric.doc = {
|
||||
isUrl.doc = {
|
||||
name: 'isUrl',
|
||||
description: 'Checks if a string is a valid URL.',
|
||||
section: 'validation',
|
||||
returnType: 'boolean',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isUrl',
|
||||
};
|
||||
@@ -490,6 +507,7 @@ isUrl.doc = {
|
||||
isEmpty.doc = {
|
||||
name: 'isEmpty',
|
||||
description: 'Checks if a string is empty.',
|
||||
section: 'validation',
|
||||
returnType: 'boolean',
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmpty',
|
||||
};
|
||||
@@ -497,6 +515,7 @@ isEmpty.doc = {
|
||||
isNotEmpty.doc = {
|
||||
name: 'isNotEmpty',
|
||||
description: 'Checks if a string has content.',
|
||||
section: 'validation',
|
||||
returnType: 'boolean',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNotEmpty',
|
||||
@@ -505,6 +524,7 @@ isNotEmpty.doc = {
|
||||
extractEmail.doc = {
|
||||
name: 'extractEmail',
|
||||
description: 'Extracts an email from a string. Returns undefined if none is found.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractEmail',
|
||||
@@ -514,6 +534,7 @@ extractDomain.doc = {
|
||||
name: 'extractDomain',
|
||||
description:
|
||||
'Extracts a domain from a string containing a valid URL. Returns undefined if none is found.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractDomain',
|
||||
@@ -522,6 +543,7 @@ extractDomain.doc = {
|
||||
extractUrl.doc = {
|
||||
name: 'extractUrl',
|
||||
description: 'Extracts a URL from a string. Returns undefined if none is found.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
docURL:
|
||||
'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrl',
|
||||
@@ -530,6 +552,7 @@ extractUrl.doc = {
|
||||
hash.doc = {
|
||||
name: 'hash',
|
||||
description: 'Returns a string hashed with the given algorithm. Default algorithm is `md5`.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
args: [{ name: 'algo?', type: 'Algorithm' }],
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-hash',
|
||||
@@ -538,11 +561,17 @@ hash.doc = {
|
||||
quote.doc = {
|
||||
name: 'quote',
|
||||
description: 'Returns a string wrapped in the quotation marks. Default quotation is `"`.',
|
||||
section: 'edit',
|
||||
returnType: 'string',
|
||||
args: [{ name: 'mark?', type: 'string' }],
|
||||
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-quote',
|
||||
};
|
||||
|
||||
const toDecimalNumber: Extension = toFloat.bind({});
|
||||
toDecimalNumber.doc = { ...toFloat.doc, hidden: true };
|
||||
const toWholeNumber: Extension = toInt.bind({});
|
||||
toWholeNumber.doc = { ...toInt.doc, hidden: true };
|
||||
|
||||
export const stringExtensions: ExtensionMap = {
|
||||
typeName: 'String',
|
||||
functions: {
|
||||
@@ -550,10 +579,10 @@ export const stringExtensions: ExtensionMap = {
|
||||
removeMarkdown,
|
||||
removeTags,
|
||||
toDate,
|
||||
toDecimalNumber: toFloat,
|
||||
toDecimalNumber,
|
||||
toFloat,
|
||||
toInt,
|
||||
toWholeNumber: toInt,
|
||||
toWholeNumber,
|
||||
toSentenceCase,
|
||||
toSnakeCase,
|
||||
toTitleCase,
|
||||
|
||||
@@ -2,26 +2,5 @@ import type { NativeDoc } from '@/Extensions/Extensions';
|
||||
|
||||
export const objectMethods: NativeDoc = {
|
||||
typeName: 'Object',
|
||||
functions: {
|
||||
keys: {
|
||||
doc: {
|
||||
name: 'keys',
|
||||
description:
|
||||
"Returns an array of a given object's own enumerable string-keyed property names.",
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys',
|
||||
returnType: 'Array',
|
||||
},
|
||||
},
|
||||
values: {
|
||||
doc: {
|
||||
name: 'values',
|
||||
description:
|
||||
"Returns an array of a given object's own enumerable string-keyed property values.",
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values',
|
||||
returnType: 'Array',
|
||||
},
|
||||
},
|
||||
},
|
||||
functions: {},
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'length',
|
||||
description: 'Returns the number of characters in the string.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length',
|
||||
returnType: 'number',
|
||||
@@ -18,6 +19,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'concat',
|
||||
description: 'Concatenates the string arguments to the calling string.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat',
|
||||
returnType: 'string',
|
||||
@@ -27,6 +29,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'endsWith',
|
||||
description: 'Checks if a string ends with `searchString`.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith',
|
||||
returnType: 'boolean',
|
||||
@@ -37,6 +40,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'indexOf',
|
||||
description: 'Returns the index of the first occurrence of `searchString`.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf',
|
||||
returnType: 'number',
|
||||
@@ -50,6 +54,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'lastIndexOf',
|
||||
description: 'Returns the index of the last occurrence of `searchString`.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf',
|
||||
returnType: 'number',
|
||||
@@ -63,6 +68,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'match',
|
||||
description: 'Retrieves the result of matching a string against a regular expression.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match',
|
||||
returnType: 'Array',
|
||||
@@ -73,6 +79,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'includes',
|
||||
description: 'Checks if `searchString` may be found within the calling string.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes',
|
||||
returnType: 'boolean',
|
||||
@@ -87,6 +94,7 @@ export const stringMethods: NativeDoc = {
|
||||
name: 'replace',
|
||||
description:
|
||||
'Returns a string with matches of a `pattern` replaced by a `replacement`. If `pattern` is a string, only the first occurrence will be replaced.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace',
|
||||
returnType: 'string',
|
||||
@@ -100,6 +108,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'replaceAll',
|
||||
description: 'Returns a string with matches of a `pattern` replaced by a `replacement`.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll',
|
||||
returnType: 'string',
|
||||
@@ -113,6 +122,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'search',
|
||||
description: 'Returns a string that matches `pattern` within the given string.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search',
|
||||
returnType: 'string',
|
||||
@@ -124,6 +134,7 @@ export const stringMethods: NativeDoc = {
|
||||
name: 'slice',
|
||||
description:
|
||||
'Returns a section of a string. `indexEnd` defaults to the length of the string if not given.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice',
|
||||
returnType: 'string',
|
||||
@@ -138,6 +149,7 @@ export const stringMethods: NativeDoc = {
|
||||
name: 'split',
|
||||
description:
|
||||
'Returns the substrings that result from dividing the given string with `separator`.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split',
|
||||
returnType: 'Array',
|
||||
@@ -151,6 +163,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'startsWith',
|
||||
description: 'Checks if the string begins with `searchString`.',
|
||||
section: 'query',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith',
|
||||
returnType: 'boolean',
|
||||
@@ -165,6 +178,7 @@ export const stringMethods: NativeDoc = {
|
||||
name: 'substring',
|
||||
description:
|
||||
'Returns the part of the string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring',
|
||||
returnType: 'string',
|
||||
@@ -178,6 +192,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'toLowerCase',
|
||||
description: 'Formats a string to lowercase. Example: "this is lowercase”.',
|
||||
section: 'case',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase',
|
||||
returnType: 'string',
|
||||
@@ -187,6 +202,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'toUpperCase',
|
||||
description: 'Formats a string to lowercase. Example: "THIS IS UPPERCASE”.',
|
||||
section: 'case',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase',
|
||||
returnType: 'string',
|
||||
@@ -196,6 +212,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'trim',
|
||||
description: 'Removes whitespace from both ends of a string and returns a new string.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim',
|
||||
returnType: 'string',
|
||||
@@ -205,6 +222,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'trimEnd',
|
||||
description: 'Removes whitespace from the end of a string and returns a new string.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd',
|
||||
returnType: 'string',
|
||||
@@ -214,6 +232,7 @@ export const stringMethods: NativeDoc = {
|
||||
doc: {
|
||||
name: 'trimStart',
|
||||
description: 'Removes whitespace from the beginning of a string and returns a new string.',
|
||||
section: 'edit',
|
||||
docURL:
|
||||
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart',
|
||||
returnType: 'string',
|
||||
|
||||
@@ -81,5 +81,13 @@ describe('Data Transformation Functions', () => {
|
||||
test('.urlEncode should work on an object', () => {
|
||||
expect(evaluate('={{ ({ test1: 1, test2: "2" }).urlEncode() }}')).toEqual('test1=1&test2=2');
|
||||
});
|
||||
|
||||
test('.keys should work on an object', () => {
|
||||
expect(evaluate('={{ ({ test1: 1, test2: "2" }).keys() }}')).toEqual(['test1', 'test2']);
|
||||
});
|
||||
|
||||
test('.values should work on an object', () => {
|
||||
expect(evaluate('={{ ({ test1: 1, test2: "2" }).values() }}')).toEqual([1, '2']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user