Skip to content

Commit

Permalink
docs: Update docs links for data transformation functions and ifEmpty (
Browse files Browse the repository at this point in the history
…#7758)

Github issue / Community forum post (link here to close automatically):
  • Loading branch information
StarfallProjects authored Nov 20, 2023
1 parent 8d12c1a commit ad04986
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 112 deletions.
56 changes: 19 additions & 37 deletions packages/workflow/src/Extensions/ArrayExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,89 +323,78 @@ average.doc = {
name: 'average',
description: 'Returns the mean average of all values in the array.',
returnType: 'number',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-average',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-average',
};

compact.doc = {
name: 'compact',
description: 'Removes all empty values from the array.',
returnType: 'Array',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-compact',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-compact',
};

isEmpty.doc = {
name: 'isEmpty',
description: 'Checks if the array doesn’t have any elements.',
returnType: 'boolean',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-isEmpty',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-isEmpty',
};

isNotEmpty.doc = {
name: 'isNotEmpty',
description: 'Checks if the array has elements.',
returnType: 'boolean',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-isNotEmpty',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-isNotEmpty',
};

first.doc = {
name: 'first',
description: 'Returns the first element of the array.',
returnType: 'Element',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-first',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-first',
};

last.doc = {
name: 'last',
description: 'Returns the last element of the array.',
returnType: 'Element',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-last',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-last',
};

max.doc = {
name: 'max',
description: 'Gets the maximum value from a number-only array.',
returnType: 'number',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-max',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-max',
};

min.doc = {
name: 'min',
description: 'Gets the minimum value from a number-only array.',
returnType: 'number',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-min',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-min',
};

randomItem.doc = {
name: 'randomItem',
description: 'Returns a random element from an array.',
returnType: 'Element',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-randomItem',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-randomItem',
};

sum.doc = {
name: 'sum',
description: 'Returns the total sum all the values in an array of parsable numbers.',
returnType: 'number',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-sum',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-sum',
};

chunk.doc = {
name: 'chunk',
description: 'Splits arrays into chunks with a length of `size`.',
returnType: 'Array',
args: [{ name: 'size', type: 'number' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-chunk',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-chunk',
};

difference.doc = {
Expand All @@ -414,8 +403,7 @@ difference.doc = {
'Compares two arrays. Returns all elements in the base array that aren’t present in `arr`.',
returnType: 'Array',
args: [{ name: 'arr', type: 'Array' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-difference',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-difference',
};

intersection.doc = {
Expand All @@ -425,7 +413,7 @@ intersection.doc = {
returnType: 'Array',
args: [{ name: 'arr', type: 'Array' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-intersection',
'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-intersection',
};

merge.doc = {
Expand All @@ -434,8 +422,7 @@ merge.doc = {
'Merges two Object-arrays into one array by merging the key-value pairs of each element.',
returnType: 'array',
args: [{ name: 'arr', type: 'Array' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-merge',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-merge',
};

pluck.doc = {
Expand All @@ -448,8 +435,7 @@ pluck.doc = {
{ name: '...' },
{ name: 'fieldNameN?', type: 'string' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-pluck',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-pluck',
};

renameKeys.doc = {
Expand All @@ -465,8 +451,7 @@ renameKeys.doc = {
{ name: 'fromN?', type: 'string' },
{ name: 'toN?', type: 'string' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-renameKeys',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-renameKeys',
};

smartJoin.doc = {
Expand All @@ -478,26 +463,23 @@ smartJoin.doc = {
{ name: 'keyField', type: 'string' },
{ name: 'nameField', type: 'string' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-smartJoin',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-smartJoin',
};

union.doc = {
name: 'union',
description: 'Concatenates two arrays and then removes duplicates.',
returnType: 'Array',
args: [{ name: 'arr', type: 'Array' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-union',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-union',
};

unique.doc = {
name: 'unique',
description: 'Remove duplicates from an array. ',
returnType: 'Element',
aliases: ['removeDuplicates'],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/arrays/#array-unique',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-unique',
};

export const arrayExtensions: ExtensionMap = {
Expand Down
30 changes: 10 additions & 20 deletions packages/workflow/src/Extensions/DateExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,51 +220,45 @@ endOfMonth.doc = {
name: 'endOfMonth',
returnType: 'Date',
description: 'Transforms a date to the last possible moment that lies within the month.',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-endOfMonth',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-endOfMonth',
};

isDst.doc = {
name: 'isDst',
returnType: 'boolean',
description: 'Checks if a Date is within Daylight Savings Time.',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isDst',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isDst',
};

isWeekend.doc = {
name: 'isWeekend',
returnType: 'boolean',
description: 'Checks if the Date falls on a Saturday or Sunday.',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isWeekend',
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`.',
returnType: 'Date',
args: [{ name: 'unit?', type: 'DurationUnit' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-beginningOf',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-beginningOf',
};

extract.doc = {
name: 'extract',
description: 'Extracts the part defined in `datePart` from a Date. Default unit is `week`.',
returnType: 'number',
args: [{ name: 'datePart?', type: 'DurationUnit' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-extract',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-extract',
};

format.doc = {
name: 'format',
description: 'Formats a Date in the given structure.',
returnType: 'string',
args: [{ name: 'fmt', type: 'TimeFormat' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-format',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-format',
};

isBetween.doc = {
Expand All @@ -275,8 +269,7 @@ isBetween.doc = {
{ name: 'date1', type: 'Date|string' },
{ name: 'date2', type: 'Date|string' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isBetween',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isBetween',
};

isInLast.doc = {
Expand All @@ -287,8 +280,7 @@ isInLast.doc = {
{ name: 'n', type: 'number' },
{ name: 'unit?', type: 'DurationUnit' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isInLast',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isInLast',
};

minus.doc = {
Expand All @@ -299,8 +291,7 @@ minus.doc = {
{ name: 'n', type: 'number' },
{ name: 'unit?', type: 'DurationUnit' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-minus',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-minus',
};

plus.doc = {
Expand All @@ -311,8 +302,7 @@ plus.doc = {
{ name: 'n', type: 'number' },
{ name: 'unit?', type: 'DurationUnit' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-plus',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-plus',
};

export const dateExtensions: ExtensionMap = {
Expand Down
2 changes: 1 addition & 1 deletion packages/workflow/src/Extensions/ExtendedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ifEmpty.doc = {
{ name: 'value', type: 'any' },
{ name: 'defaultValue', type: 'any' },
],
docURL: 'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/#if-empty',
docURL: 'https://docs.n8n.io/code/builtin/convenience',
};

export const extendedFunctions = {
Expand Down
18 changes: 6 additions & 12 deletions packages/workflow/src/Extensions/NumberExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,28 @@ ceil.doc = {
name: 'ceil',
description: 'Rounds up a number to a whole number.',
returnType: 'number',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/numbers/#number-ceil',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/numbers/#number-ceil',
};

floor.doc = {
name: 'floor',
description: 'Rounds down a number to a whole number.',
returnType: 'number',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/numbers/#number-floor',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/numbers/#number-floor',
};

isEven.doc = {
name: 'isEven',
description: 'Returns true if the number is even. Only works on whole numbers.',
returnType: 'boolean',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/numbers/#number-isEven',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/numbers/#number-isEven',
};

isOdd.doc = {
name: 'isOdd',
description: 'Returns true if the number is odd. Only works on whole numbers.',
returnType: 'boolean',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/numbers/#number-isOdd',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/numbers/#number-isOdd',
};

format.doc = {
Expand All @@ -81,8 +77,7 @@ format.doc = {
{ name: 'locales?', type: 'LanguageCode' },
{ name: 'options?', type: 'FormatOptions' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/numbers/#number-format',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/numbers/#number-format',
};

round.doc = {
Expand All @@ -91,8 +86,7 @@ round.doc = {
'Returns the value of a number rounded to the nearest whole number, unless a decimal place is specified. Defaults to 0 decimal places if no argument is given.',
returnType: 'number',
args: [{ name: 'decimalPlaces?', type: 'number' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/numbers/#number-round',
docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/numbers/#number-round',
};

export const numberExtensions: ExtensionMap = {
Expand Down
Loading

0 comments on commit ad04986

Please sign in to comment.