first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { ApplicationError } from '@n8n/errors';
import type { FilterConditionValue, FilterOptionsValue, FilterValue, INodeProperties } from '../interfaces';
type FilterConditionMetadata = {
index: number;
unresolvedExpressions: boolean;
itemIndex: number;
errorFormat: 'full' | 'inline';
};
export declare class FilterError extends ApplicationError {
readonly description: string;
constructor(message: string, description: string);
}
export declare function arrayContainsValue(array: unknown[], value: unknown, ignoreCase: boolean): boolean;
export declare function executeFilterCondition(condition: FilterConditionValue, filterOptions: FilterOptionsValue, metadata?: Partial<FilterConditionMetadata>): boolean;
type ExecuteFilterOptions = {
itemIndex?: number;
};
export declare function executeFilter(value: FilterValue, { itemIndex }?: ExecuteFilterOptions): boolean;
export declare const validateFilterParameter: (nodeProperties: INodeProperties, value: FilterValue) => Record<string, string[]>;
export {};
//# sourceMappingURL=filter-parameter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"filter-parameter.d.ts","sourceRoot":"","sources":["../../../src/node-parameters/filter-parameter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACX,oBAAoB,EAEpB,kBAAkB,EAClB,WAAW,EACX,eAAe,EAEf,MAAM,eAAe,CAAC;AAKvB,KAAK,uBAAuB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC/B,CAAC;AAEF,qBAAa,WAAY,SAAQ,gBAAgB;IAG/C,QAAQ,CAAC,WAAW,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACN,WAAW,EAAE,MAAM;CAI7B;AA2KD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAUjG;AAGD,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,oBAAoB,EAC/B,aAAa,EAAE,kBAAkB,EACjC,QAAQ,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAC7C,OAAO,CAkLT;AAED,KAAK,oBAAoB,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,wBAAgB,aAAa,CAC5B,KAAK,EAAE,WAAW,EAClB,EAAE,SAAS,EAAE,GAAE,oBAAyB,GACtC,OAAO,CAaT;AAED,eAAO,MAAM,uBAAuB,GACnC,gBAAgB,eAAe,EAC/B,OAAO,WAAW,KAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAqBzB,CAAC"}

View File

@@ -0,0 +1,382 @@
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "@n8n/errors", "../logger-proxy", "../type-validation"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateFilterParameter = exports.FilterError = void 0;
exports.arrayContainsValue = arrayContainsValue;
exports.executeFilterCondition = executeFilterCondition;
exports.executeFilter = executeFilter;
const errors_1 = require("@n8n/errors");
const LoggerProxy = __importStar(require("../logger-proxy"));
const type_validation_1 = require("../type-validation");
class FilterError extends errors_1.ApplicationError {
description;
constructor(message, description) {
super(message, { level: 'warning' });
this.description = description;
}
}
exports.FilterError = FilterError;
function parseSingleFilterValue(value, type, strict = false, version = 1) {
if (type === 'any' || value === null || value === undefined) {
return { valid: true, newValue: value };
}
if (type === 'boolean' && !strict) {
if (version >= 2) {
const result = (0, type_validation_1.validateFieldType)('filter', value, type);
if (result.valid)
return result;
}
return { valid: true, newValue: Boolean(value) };
}
if (type === 'number' && Number.isNaN(value)) {
return { valid: true, newValue: value };
}
return (0, type_validation_1.validateFieldType)('filter', value, type, { strict, parseStrings: true });
}
const withIndefiniteArticle = (noun) => {
const article = 'aeiou'.includes(noun.charAt(0)) ? 'an' : 'a';
return `${article} ${noun}`;
};
function parseFilterConditionValues(condition, options, metadata) {
const index = metadata.index ?? 0;
const itemIndex = metadata.itemIndex ?? 0;
const errorFormat = metadata.errorFormat ?? 'full';
const strict = options.typeValidation === 'strict';
const version = options.version ?? 1;
const { operator } = condition;
const rightType = operator.rightType ?? operator.type;
const parsedLeftValue = parseSingleFilterValue(condition.leftValue, operator.type, strict, version);
const parsedRightValue = parseSingleFilterValue(condition.rightValue, rightType, strict, version);
const leftValid = parsedLeftValue.valid ||
(metadata.unresolvedExpressions &&
typeof condition.leftValue === 'string' &&
condition.leftValue.startsWith('='));
const rightValid = parsedRightValue.valid ||
!!operator.singleValue ||
(metadata.unresolvedExpressions &&
typeof condition.rightValue === 'string' &&
condition.rightValue.startsWith('='));
const leftValueString = String(condition.leftValue);
const rightValueString = String(condition.rightValue);
const suffix = errorFormat === 'full' ? `[condition ${index}, item ${itemIndex}]` : `[item ${itemIndex}]`;
const composeInvalidTypeMessage = (type, fromType, value) => {
fromType = fromType.toLocaleLowerCase();
if (strict) {
return `Wrong type: '${value}' is ${withIndefiniteArticle(fromType)} but was expecting ${withIndefiniteArticle(type)} ${suffix}`;
}
return `Conversion error: the ${fromType} '${value}' can't be converted to ${withIndefiniteArticle(type)} ${suffix}`;
};
const getTypeDescription = (isStrict) => {
if (isStrict)
return "Try changing the type of comparison. Alternatively you can enable 'Convert types where required'.";
return 'Try changing the type of the comparison.';
};
const composeInvalidTypeDescription = (type, fromType, valuePosition) => {
fromType = fromType.toLocaleLowerCase();
const expectedType = withIndefiniteArticle(type);
let convertionFunction = '';
if (type === 'string') {
convertionFunction = '.toString()';
}
else if (type === 'number') {
convertionFunction = '.toNumber()';
}
else if (type === 'boolean') {
convertionFunction = '.toBoolean()';
}
if (strict && convertionFunction) {
const suggestFunction = ` by adding <code>${convertionFunction}</code>`;
return `
<p>Try either:</p>
<ol>
<li>Enabling 'Convert types where required'</li>
<li>Converting the ${valuePosition} field to ${expectedType}${suggestFunction}</li>
</ol>
`;
}
return getTypeDescription(strict);
};
if (!leftValid && !rightValid && typeof condition.leftValue === typeof condition.rightValue) {
return {
ok: false,
error: new FilterError(`Comparison type expects ${withIndefiniteArticle(operator.type)} but both fields are ${withIndefiniteArticle(typeof condition.leftValue)}`, getTypeDescription(strict)),
};
}
if (!leftValid) {
return {
ok: false,
error: new FilterError(composeInvalidTypeMessage(operator.type, typeof condition.leftValue, leftValueString), composeInvalidTypeDescription(operator.type, typeof condition.leftValue, 'first')),
};
}
if (!rightValid) {
return {
ok: false,
error: new FilterError(composeInvalidTypeMessage(rightType, typeof condition.rightValue, rightValueString), composeInvalidTypeDescription(rightType, typeof condition.rightValue, 'second')),
};
}
return {
ok: true,
result: {
left: parsedLeftValue.valid ? parsedLeftValue.newValue : undefined,
right: parsedRightValue.valid ? parsedRightValue.newValue : undefined,
},
};
}
function parseRegexPattern(pattern) {
const regexMatch = (pattern || '').match(new RegExp('^/(.*?)/([gimusy]*)$'));
let regex;
if (!regexMatch) {
regex = new RegExp((pattern || '').toString());
}
else {
regex = new RegExp(regexMatch[1], regexMatch[2]);
}
return regex;
}
function arrayContainsValue(array, value, ignoreCase) {
if (ignoreCase && typeof value === 'string') {
return array.some((item) => {
if (typeof item !== 'string') {
return false;
}
return item.toString().toLocaleLowerCase() === value.toLocaleLowerCase();
});
}
return array.includes(value);
}
// eslint-disable-next-line complexity
function executeFilterCondition(condition, filterOptions, metadata = {}) {
const ignoreCase = !filterOptions.caseSensitive;
const { operator } = condition;
const parsedValues = parseFilterConditionValues(condition, filterOptions, metadata);
if (!parsedValues.ok) {
throw parsedValues.error;
}
let { left: leftValue, right: rightValue } = parsedValues.result;
const exists = leftValue !== undefined && leftValue !== null && !Number.isNaN(leftValue);
if (condition.operator.operation === 'exists') {
return exists;
}
else if (condition.operator.operation === 'notExists') {
return !exists;
}
switch (operator.type) {
case 'string': {
if (ignoreCase) {
if (typeof leftValue === 'string') {
leftValue = leftValue.toLocaleLowerCase();
}
if (typeof rightValue === 'string' &&
!(condition.operator.operation === 'regex' || condition.operator.operation === 'notRegex')) {
rightValue = rightValue.toLocaleLowerCase();
}
}
const left = (leftValue ?? '');
const right = (rightValue ?? '');
switch (condition.operator.operation) {
case 'empty':
return left.length === 0;
case 'notEmpty':
return left.length !== 0;
case 'equals':
return left === right;
case 'notEquals':
return left !== right;
case 'contains':
return left.includes(right);
case 'notContains':
return !left.includes(right);
case 'startsWith':
return left.startsWith(right);
case 'notStartsWith':
return !left.startsWith(right);
case 'endsWith':
return left.endsWith(right);
case 'notEndsWith':
return !left.endsWith(right);
case 'regex':
return parseRegexPattern(right).test(left);
case 'notRegex':
return !parseRegexPattern(right).test(left);
}
break;
}
case 'number': {
const left = leftValue;
const right = rightValue;
switch (condition.operator.operation) {
case 'empty':
return !exists;
case 'notEmpty':
return exists;
case 'equals':
return left === right;
case 'notEquals':
return left !== right;
case 'gt':
return left > right;
case 'lt':
return left < right;
case 'gte':
return left >= right;
case 'lte':
return left <= right;
}
}
case 'dateTime': {
const left = leftValue;
const right = rightValue;
if (condition.operator.operation === 'empty') {
return !exists;
}
else if (condition.operator.operation === 'notEmpty') {
return exists;
}
if (!left || !right) {
return false;
}
switch (condition.operator.operation) {
case 'equals':
return left.toMillis() === right.toMillis();
case 'notEquals':
return left.toMillis() !== right.toMillis();
case 'after':
return left.toMillis() > right.toMillis();
case 'before':
return left.toMillis() < right.toMillis();
case 'afterOrEquals':
return left.toMillis() >= right.toMillis();
case 'beforeOrEquals':
return left.toMillis() <= right.toMillis();
}
}
case 'boolean': {
const left = leftValue;
const right = rightValue;
switch (condition.operator.operation) {
case 'empty':
return !exists;
case 'notEmpty':
return exists;
case 'true':
return left;
case 'false':
return !left;
case 'equals':
return left === right;
case 'notEquals':
return left !== right;
}
}
case 'array': {
const left = (leftValue ?? []);
const rightNumber = rightValue;
switch (condition.operator.operation) {
case 'contains':
return arrayContainsValue(left, rightValue, ignoreCase);
case 'notContains':
return !arrayContainsValue(left, rightValue, ignoreCase);
case 'lengthEquals':
return left.length === rightNumber;
case 'lengthNotEquals':
return left.length !== rightNumber;
case 'lengthGt':
return left.length > rightNumber;
case 'lengthLt':
return left.length < rightNumber;
case 'lengthGte':
return left.length >= rightNumber;
case 'lengthLte':
return left.length <= rightNumber;
case 'empty':
return left.length === 0;
case 'notEmpty':
return left.length !== 0;
}
}
case 'object': {
const left = leftValue;
switch (condition.operator.operation) {
case 'empty':
return !left || Object.keys(left).length === 0;
case 'notEmpty':
return !!left && Object.keys(left).length !== 0;
}
}
}
LoggerProxy.warn(`Unknown filter parameter operator "${operator.type}:${operator.operation}"`);
return false;
}
function executeFilter(value, { itemIndex } = {}) {
const conditionPass = (condition, index) => executeFilterCondition(condition, value.options, { index, itemIndex });
if (value.combinator === 'and') {
return value.conditions.every(conditionPass);
}
else if (value.combinator === 'or') {
return value.conditions.some(conditionPass);
}
LoggerProxy.warn(`Unknown filter combinator "${value.combinator}"`);
return false;
}
const validateFilterParameter = (nodeProperties, value) => {
return value.conditions.reduce((issues, condition, index) => {
const key = `${nodeProperties.name}.${index}`;
try {
parseFilterConditionValues(condition, value.options, {
index,
unresolvedExpressions: true,
errorFormat: 'inline',
});
}
catch (error) {
if (error instanceof FilterError) {
issues[key].push(error.message);
}
}
return issues;
}, {});
};
exports.validateFilterParameter = validateFilterParameter;
});
//# sourceMappingURL=filter-parameter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
import type { INode } from '../interfaces';
type ParameterType = 'string' | 'boolean' | 'number' | 'resource-locator' | 'string[]' | 'number[]' | 'boolean[]' | 'object';
export declare function assertParamIsNumber(parameterName: string, value: unknown, node: INode): asserts value is number;
export declare function assertParamIsString(parameterName: string, value: unknown, node: INode): asserts value is string;
export declare function assertParamIsBoolean(parameterName: string, value: unknown, node: INode): asserts value is boolean;
type TypeofMap = {
string: string;
number: number;
boolean: boolean;
};
export declare function assertParamIsOfAnyTypes<T extends ReadonlyArray<keyof TypeofMap>>(parameterName: string, value: unknown, types: T, node: INode): asserts value is TypeofMap[T[number]];
export declare function assertParamIsArray<T>(parameterName: string, value: unknown, validator: (val: unknown) => val is T, node: INode): asserts value is T[];
type InferParameterType<T extends ParameterType | ParameterType[]> = T extends ParameterType[] ? InferSingleParameterType<T[number]> : T extends ParameterType ? InferSingleParameterType<T> : never;
type InferSingleParameterType<T extends ParameterType> = T extends 'string' ? string : T extends 'boolean' ? boolean : T extends 'number' ? number : T extends 'resource-locator' ? Record<string, unknown> : T extends 'string[]' ? string[] : T extends 'number[]' ? number[] : T extends 'boolean[]' ? boolean[] : T extends 'object' ? Record<string, unknown> : unknown;
export declare function validateNodeParameters<T extends Record<string, {
type: ParameterType | ParameterType[];
required?: boolean;
}>>(value: unknown, parameters: T, node: INode): asserts value is {
[K in keyof T]: T[K]['required'] extends true ? InferParameterType<T[K]['type']> : InferParameterType<T[K]['type']> | undefined;
};
export {};
//# sourceMappingURL=parameter-type-validation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parameter-type-validation.d.ts","sourceRoot":"","sources":["../../../src/node-parameters/parameter-type-validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C,KAAK,aAAa,GACf,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,kBAAkB,GAClB,UAAU,GACV,UAAU,GACV,WAAW,GACX,QAAQ,CAAC;AA0BZ,wBAAgB,mBAAmB,CAClC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,IAAI,MAAM,CAEzB;AAED,wBAAgB,mBAAmB,CAClC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,IAAI,MAAM,CAEzB;AAED,wBAAgB,oBAAoB,CACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,IAAI,OAAO,CAE1B;AAED,KAAK,SAAS,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,SAAS,CAAC,EAC/E,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAMvC;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OA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CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS;CAC/C,CAgBA"}

View File

@@ -0,0 +1,141 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../errors", "../utils"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertParamIsNumber = assertParamIsNumber;
exports.assertParamIsString = assertParamIsString;
exports.assertParamIsBoolean = assertParamIsBoolean;
exports.assertParamIsOfAnyTypes = assertParamIsOfAnyTypes;
exports.assertParamIsArray = assertParamIsArray;
exports.validateNodeParameters = validateNodeParameters;
const errors_1 = require("../errors");
const utils_1 = require("../utils");
function assertUserInput(condition, message, node) {
try {
(0, utils_1.assert)(condition, message);
}
catch (e) {
if (e instanceof Error) {
// Use level 'info' to prevent reporting to Sentry (only 'error' and 'fatal' levels are reported)
const nodeError = new errors_1.NodeOperationError(node, e.message, { level: 'info' });
nodeError.stack = e.stack;
throw nodeError;
}
throw e;
}
}
function assertParamIsType(parameterName, value, type, node) {
assertUserInput(typeof value === type, `Parameter "${parameterName}" is not ${type}`, node);
}
function assertParamIsNumber(parameterName, value, node) {
assertParamIsType(parameterName, value, 'number', node);
}
function assertParamIsString(parameterName, value, node) {
assertParamIsType(parameterName, value, 'string', node);
}
function assertParamIsBoolean(parameterName, value, node) {
assertParamIsType(parameterName, value, 'boolean', node);
}
function assertParamIsOfAnyTypes(parameterName, value, types, node) {
const isValid = types.some((type) => typeof value === type);
if (!isValid) {
const typeList = types.join(' or ');
assertUserInput(false, `Parameter "${parameterName}" must be ${typeList}`, node);
}
}
function assertParamIsArray(parameterName, value, validator, node) {
assertUserInput(Array.isArray(value), `Parameter "${parameterName}" is not an array`, node);
// Use for loop instead of .every() to properly handle sparse arrays
// .every() skips empty/sparse indices, which could allow invalid arrays to pass
for (let i = 0; i < value.length; i++) {
if (!validator(value[i])) {
assertUserInput(false, `Parameter "${parameterName}" has elements that don't match expected types`, node);
}
}
}
function assertIsValidObject(value, node) {
assertUserInput(typeof value === 'object' && value !== null, 'Value is not a valid object', node);
}
function assertIsRequiredParameter(parameterName, value, isRequired, node) {
if (isRequired && value === undefined) {
assertUserInput(false, `Required parameter "${parameterName}" is missing`, node);
}
}
function assertIsResourceLocator(parameterName, value, node) {
assertUserInput(typeof value === 'object' &&
value !== null &&
'__rl' in value &&
'mode' in value &&
'value' in value, `Parameter "${parameterName}" is not a valid resource locator object`, node);
}
function assertParamIsObject(parameterName, value, node) {
assertUserInput(typeof value === 'object' && value !== null, `Parameter "${parameterName}" is not a valid object`, node);
}
function createElementValidator(elementType) {
return (val) => typeof val === elementType;
}
function assertParamIsArrayOfType(parameterName, value, arrayType, node) {
const baseType = arrayType.slice(0, -2);
const elementType = baseType === 'string' || baseType === 'number' || baseType === 'boolean' ? baseType : 'string';
const validator = createElementValidator(elementType);
assertParamIsArray(parameterName, value, validator, node);
}
function assertParamIsPrimitive(parameterName, value, type, node) {
assertUserInput(typeof value === type, `Parameter "${parameterName}" is not a valid ${type}`, node);
}
function validateParameterType(parameterName, value, type, node) {
try {
if (type === 'resource-locator') {
assertIsResourceLocator(parameterName, value, node);
}
else if (type === 'object') {
assertParamIsObject(parameterName, value, node);
}
else if (type.endsWith('[]')) {
assertParamIsArrayOfType(parameterName, value, type, node);
}
else {
assertParamIsPrimitive(parameterName, value, type, node);
}
return true;
}
catch {
return false;
}
}
function validateParameterAgainstTypes(parameterName, value, types, node) {
let isValid = false;
for (const type of types) {
if (validateParameterType(parameterName, value, type, node)) {
isValid = true;
break;
}
}
if (!isValid) {
const typeList = types.join(' or ');
assertUserInput(false, `Parameter "${parameterName}" does not match any of the expected types: ${typeList}`, node);
}
}
function validateNodeParameters(value, parameters, node) {
assertIsValidObject(value, node);
Object.keys(parameters).forEach((key) => {
const param = parameters[key];
const paramValue = value[key];
assertIsRequiredParameter(key, paramValue, param.required ?? false, node);
// If required, value cannot be undefined and must be validated
// If not required, value can be undefined but should be validated when present
if (param.required || paramValue !== undefined) {
const types = Array.isArray(param.type) ? param.type : [param.type];
validateParameterAgainstTypes(key, paramValue, types, node);
}
});
}
});
//# sourceMappingURL=parameter-type-validation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parameter-type-validation.js","sourceRoot":"","sources":["../../../src/node-parameters/parameter-type-validation.ts"],"names":[],"mappings":";;;;;;;;;;;IAsCA,kDAMC;IAED,kDAMC;IAED,oDAMC;IAQD,0DAWC;IAED,gDAmBC;IAiJD,wDA0BC;IA/QD,sCAA+C;IAE/C,oCAAkC;IAYlC,SAAS,eAAe,CAAI,SAAY,EAAE,OAAe,EAAE,IAAW;QACrE,IAAI,CAAC;YACJ,IAAA,cAAM,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACrB,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACxB,iGAAiG;gBACjG,MAAM,SAAS,GAAG,IAAI,2BAAkB,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC7E,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;gBAC1B,MAAM,SAAS,CAAC;YACjB,CAAC;YAED,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;IAED,SAAS,iBAAiB,CACzB,aAAqB,EACrB,KAAc,EACd,IAAqC,EACrC,IAAW;QAEX,eAAe,CAAC,OAAO,KAAK,KAAK,IAAI,EAAE,cAAc,aAAa,YAAY,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7F,CAAC;IAED,SAAgB,mBAAmB,CAClC,aAAqB,EACrB,KAAc,EACd,IAAW;QAEX,iBAAiB,CAAS,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IAED,SAAgB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M;YACP,CAAC;QACF,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpC,eAAe,CACd,KAAK,EACL,cAAc,aAAa,+CAA+C,QAAQ,EAAE,EACpF,IAAI,CACJ,CAAC;QACH,CAAC;IACF,CAAC;IA0BD,SAAgB,sBAAsB,CAGrC,KAAc,EACd,UAAa,EACb,IAAW;QAMX,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEjC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACvC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAE9B,yBAAyB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC;YAE1E,+DAA+D;YAC/D,+EAA+E;YAC/E,IAAI,KAAK,CAAC,QAAQ,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAChD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACpE,6BAA6B,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC7D,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC"}

View File

@@ -0,0 +1,11 @@
/**
* Resolve relative paths starting in & in the context of a given full path including parameters,
* which will be dropped in the process.
* If `candidateRelativePath` is not relative, it is returned unchanged.
*
* `parameters.a.b.c`, `&d` -> `a.b.d`
* `parameters.a.b[0].c`, `&d` -> `a.b[0].d`
* `parameters.a.b.c`, `d` -> `d`
*/
export declare function resolveRelativePath(fullPathWithParameters: string, candidateRelativePath: string): string;
//# sourceMappingURL=path-utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../../src/node-parameters/path-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,sBAAsB,EAAE,MAAM,EAC9B,qBAAqB,EAAE,MAAM,GAC3B,MAAM,CAWR"}

View File

@@ -0,0 +1,33 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveRelativePath = resolveRelativePath;
/**
* Resolve relative paths starting in & in the context of a given full path including parameters,
* which will be dropped in the process.
* If `candidateRelativePath` is not relative, it is returned unchanged.
*
* `parameters.a.b.c`, `&d` -> `a.b.d`
* `parameters.a.b[0].c`, `&d` -> `a.b[0].d`
* `parameters.a.b.c`, `d` -> `d`
*/
function resolveRelativePath(fullPathWithParameters, candidateRelativePath) {
if (candidateRelativePath.startsWith('&')) {
const resolvedLeaf = candidateRelativePath.slice(1);
const pathToLeaf = fullPathWithParameters.split('.').slice(1, -1).join('.');
if (!pathToLeaf)
return resolvedLeaf;
return `${pathToLeaf}.${resolvedLeaf}`;
}
return candidateRelativePath;
}
});
//# sourceMappingURL=path-utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../../src/node-parameters/path-utils.ts"],"names":[],"mappings":";;;;;;;;;;;IASA,kDAcC;IAvBD;;;;;;;;OAQG;IACH,SAAgB,mBAAmB,CAClC,sBAA8B,EAC9B,qBAA6B;QAE7B,IAAI,qBAAqB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,YAAY,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE5E,IAAI,CAAC,UAAU;gBAAE,OAAO,YAAY,CAAC;YAErC,OAAO,GAAG,UAAU,IAAI,YAAY,EAAE,CAAC;QACxC,CAAC;QAED,OAAO,qBAAqB,CAAC;IAC9B,CAAC"}

View File

@@ -0,0 +1,3 @@
import type { INode, NodeParameterValueType } from '../interfaces';
export declare function renameFormFields(node: INode, renameField: (v: NodeParameterValueType) => NodeParameterValueType): void;
//# sourceMappingURL=rename-node-utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rename-node-utils.d.ts","sourceRoot":"","sources":["../../../src/node-parameters/rename-node-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEnE,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,CAAC,CAAC,EAAE,sBAAsB,KAAK,sBAAsB,GAChE,IAAI,CAuBN"}

View File

@@ -0,0 +1,36 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renameFormFields = renameFormFields;
function renameFormFields(node, renameField) {
const formFields = node.parameters?.formFields;
const values = formFields &&
typeof formFields === 'object' &&
'values' in formFields &&
typeof formFields.values === 'object' &&
// TypeScript thinks this is `Array.values` and gets very confused here
// eslint-disable-next-line @typescript-eslint/unbound-method
Array.isArray(formFields.values)
? // eslint-disable-next-line @typescript-eslint/unbound-method
(formFields.values ?? [])
: [];
for (const formFieldValue of values) {
if (!formFieldValue || typeof formFieldValue !== 'object')
continue;
if ('fieldType' in formFieldValue && formFieldValue.fieldType === 'html') {
if ('html' in formFieldValue) {
formFieldValue.html = renameField(formFieldValue.html);
}
}
}
}
});
//# sourceMappingURL=rename-node-utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rename-node-utils.js","sourceRoot":"","sources":["../../../src/node-parameters/rename-node-utils.ts"],"names":[],"mappings":";;;;;;;;;;;IAEA,4CA0BC;IA1BD,SAAgB,gBAAgB,CAC/B,IAAW,EACX,WAAkE;QAElE,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;QAE/C,MAAM,MAAM,GACX,UAAU;YACV,OAAO,UAAU,KAAK,QAAQ;YAC9B,QAAQ,IAAI,UAAU;YACtB,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ;YACrC,uEAAuE;YACvE,6DAA6D;YAC7D,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAC/B,CAAC,CAAC,6DAA6D;gBAC9D,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;YAC1B,CAAC,CAAC,EAAE,CAAC;QAEP,KAAK,MAAM,cAAc,IAAI,MAAM,EAAE,CAAC;YACrC,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ;gBAAE,SAAS;YACpE,IAAI,WAAW,IAAI,cAAc,IAAI,cAAc,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;gBAC1E,IAAI,MAAM,IAAI,cAAc,EAAE,CAAC;oBAC9B,cAAc,CAAC,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBACxD,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC"}