Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add special @tool displayOption #14318

Merged
merged 2 commits into from
Apr 4, 2025
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
1 change: 1 addition & 0 deletions packages/cli/src/credentials-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export class CredentialsHelper extends ICredentialsHelper {
true,
false,
null,
null,
) as ICredentialDataDecryptedObject;

if (decryptedDataOriginal.oauthTokenData !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export abstract class NodeExecutionContext implements Omit<FunctionsBase, 'getCr
additionalData.currentNodeParameters || node.parameters,
nodeCredentialDescription,
node,
nodeType.description,
node.parameters,
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ function findPropertyFromParameterName(
return options.find(
(i) =>
i.name === name &&
NodeHelpers.displayParameterPath(nodeParameters, i, currentParamPath, node),
NodeHelpers.displayParameterPath(
nodeParameters,
i,
currentParamPath,
node,
nodeType.description,
),
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export const validateValueAgainstSchema = (

const propertyDescription = nodeType.description.properties.find(
(prop) =>
parameterPath[0] === prop.name && NodeHelpers.displayParameter(node.parameters, prop, node),
parameterPath[0] === prop.name &&
NodeHelpers.displayParameter(node.parameters, prop, node, nodeType.description),
);

if (!propertyDescription) {
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/execution-engine/routing-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,16 @@ export class RoutingNode {
};
let basePath = path ? `${path}.` : '';

const { node } = this.context;
if (!NodeHelpers.displayParameter(node.parameters, nodeProperties, node, node.parameters)) {
const { node, nodeType } = this.context;
if (
!NodeHelpers.displayParameter(
node.parameters,
nodeProperties,
node,
nodeType.description,
node.parameters,
)
) {
return undefined;
}
if (nodeProperties.routing) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/execution-engine/workflow-execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ export class WorkflowExecute {
nodeIssues = NodeHelpers.getNodeParametersIssues(
nodeType.description.properties,
node,
nodeType.description,
inputData.pinDataNodeNames,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ async function saveCredential(): Promise<ICredentialsResponse | null> {
false,
false,
null,
null,
);

assert(credentialTypeName.value);
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/editor-ui/src/components/NodeSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ const removeMismatchedOptionValues = (
);
}

if (!hasValidOptions && displayParameter(nodeParameterValues, prop, node.value)) {
if (!hasValidOptions && displayParameter(nodeParameterValues, prop, node.value, nodeType)) {
unset(nodeParameterValues as object, prop.name);
}
});
Expand Down Expand Up @@ -395,6 +395,7 @@ const valueChanged = (parameterData: IUpdateInformation) => {
false,
false,
_node,
nodeType,
);

const oldNodeParameters = Object.assign({}, nodeParameters);
Expand Down Expand Up @@ -453,6 +454,7 @@ const valueChanged = (parameterData: IUpdateInformation) => {
true,
false,
_node,
nodeType,
);

for (const key of Object.keys(nodeParameters as object)) {
Expand Down Expand Up @@ -487,6 +489,7 @@ const valueChanged = (parameterData: IUpdateInformation) => {
false,
false,
_node,
nodeType,
);
const oldNodeParameters = Object.assign({}, nodeParameters);

Expand Down Expand Up @@ -535,6 +538,7 @@ const valueChanged = (parameterData: IUpdateInformation) => {
true,
false,
_node,
nodeType,
);

for (const key of Object.keys(nodeParameters as object)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('ParameterInput.vue', () => {
};
mockNodeTypesState = {
allNodeTypes: [],
getNodeType: vi.fn().mockReturnValue(null),
};
createAppModals();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ const getIssues = computed<string[]>(() => {
node.value.parameters,
newPath.join('.'),
node.value,
nodeTypesStore.getNodeType(node.value.type, node.value.typeVersion),
);

if (props.parameter.type === 'credentialsSelect' && displayValue.value === '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,13 @@ function getParameterIssues(parameter: INodeProperties): string[] {
if (!node.value || !showIssuesInLabelFor.includes(parameter.type)) {
return [];
}
const issues = NodeHelpers.getParameterIssues(parameter, node.value.parameters, '', node.value);
const issues = NodeHelpers.getParameterIssues(
parameter,
node.value.parameters,
'',
node.value,
nodeType.value,
);

return issues.parameters?.[parameter.name] ?? [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ function updateNodeIssues(): void {
const parameterIssues = NodeHelpers.getNodeParametersIssues(
nodeType.value?.properties ?? [],
props.node,
nodeType.value,
);
if (parameterIssues) {
ndvStore.updateNodeParameterIssues(parameterIssues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
true,
false,
node,
nodeTypeDescription,
);

node.parameters = nodeParameters ?? {};
Expand Down
15 changes: 13 additions & 2 deletions packages/frontend/editor-ui/src/composables/useNodeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@ export function useNodeHelpers() {
node: INodeUi | null,
displayKey: 'displayOptions' | 'disabledOptions' = 'displayOptions',
) {
return NodeHelpers.displayParameterPath(nodeValues, parameter, path, node, displayKey);
const nodeTypeDescription = node?.type
? nodeTypesStore.getNodeType(node.type, node.typeVersion)
: null;
return NodeHelpers.displayParameterPath(
nodeValues,
parameter,
path,
node,
nodeTypeDescription,
displayKey,
);
}

function getNodeIssues(
Expand Down Expand Up @@ -137,7 +147,7 @@ export function useNodeHelpers() {

// Add potential parameter issues
if (!ignoreIssues.includes('parameters')) {
nodeIssues = NodeHelpers.getNodeParametersIssues(nodeType.properties, node);
nodeIssues = NodeHelpers.getNodeParametersIssues(nodeType.properties, node, nodeType);
}

if (!ignoreIssues.includes('credentials')) {
Expand Down Expand Up @@ -287,6 +297,7 @@ export function useNodeHelpers() {
const fullNodeIssues: INodeIssues | null = NodeHelpers.getNodeParametersIssues(
localNodeType.properties,
node,
nodeType ?? null,
);

let newIssues: INodeIssueObjectProperty | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
isCredentialOnly,
false,
node,
nodeType,
);
nodeData.parameters = nodeParameters !== null ? nodeParameters : {};

Expand Down
1 change: 1 addition & 0 deletions packages/frontend/editor-ui/src/stores/workflows.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
true,
false,
latestNode,
nodeType,
);

if (latestNode) {
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/editor-ui/src/utils/nodeViewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ export function getGenericHints({
true,
false,
node,
undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to set onlySimpleTypes to undefined rather than the default false. Old signature:

	node: Pick<INode, 'typeVersion'> | null,
	onlySimpleTypes = false,
	dataIsResolved = false,
	nodeValuesRoot?: INodeParameters,
	parentType?: string,
	parameterDependencies?: IParameterDependencies,
): INodeParameters | null {

Only usage in the body is if (onlySimpleTypes) { so this should be safe to drop.

false,
nodeType,
);

const assignments =
Expand Down
12 changes: 9 additions & 3 deletions packages/frontend/editor-ui/src/utils/nodes/nodeTransforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ export function getNodeTypeDisplayableCredentials(
// credentials can have conditional requirements that depend on
// node parameters.
const nodeParameters =
NodeHelpers.getNodeParameters(nodeType.properties, node.parameters, true, false, node) ??
node.parameters;
NodeHelpers.getNodeParameters(
nodeType.properties,
node.parameters,
true,
false,
node,
nodeType,
) ?? node.parameters;

const displayableCredentials = nodeTypeCreds.filter((credentialTypeDescription) => {
return NodeHelpers.displayParameter(nodeParameters, credentialTypeDescription, node);
return NodeHelpers.displayParameter(nodeParameters, credentialTypeDescription, node, nodeType);
});

return displayableCredentials;
Expand Down
1 change: 1 addition & 0 deletions packages/workflow/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ export interface IDisplayOptions {
};
show?: {
'@version'?: Array<number | DisplayCondition>;
'@tool'?: [boolean];
[key: string]: Array<NodeParameterValue | DisplayCondition> | undefined;
};

Expand Down
Loading
Loading