Skip to content
Merged
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
23 changes: 18 additions & 5 deletions src/util/schema.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export const getSchema = (
}
}

// Check primitive literal union first (e.g., "a" | "b" | "c") or a single
// string/number literal (e.g., "GET"). A bare literal has only one allowed
// value, so it should still surface as a select rather than a free-form text/number input.
if (isPrimitiveLiteralUnion(parameterType) || isStringOrNumberLiteral(parameterType)) {
return {input: "select", ...combinedSuggestions};
}

// Check individual primitive types
if (isBoolean(parameterType)) {
return {input: "boolean", ...combinedSuggestions};
Expand All @@ -185,11 +192,6 @@ export const getSchema = (
return {input: "text", ...combinedSuggestions};
}

// Check primitive literal union first (e.g., "a" | "b" | "c")
if (isPrimitiveLiteralUnion(parameterType)) {
return {input: "select", ...combinedSuggestions};
}

// Check if type has call signatures (is callable/sub-flow)
if (isSubFlow(parameterType)) {
return {input: "sub-flow", ...combinedSuggestions};
Expand Down Expand Up @@ -334,6 +336,17 @@ function isPrimitive(type: ts.Type): boolean {
return isString(type) || isNumber(type) || isBoolean(type);
}

/**
* Checks if a type is a single string or number literal (e.g. "GET" or 42).
* Boolean literals are excluded so that types like `true` continue to render as a boolean input.
*/
function isStringOrNumberLiteral(type: ts.Type): boolean {
return (
(type.flags & ts.TypeFlags.StringLiteral) !== 0 ||
(type.flags & ts.TypeFlags.NumberLiteral) !== 0
);
}

/**
* Checks if a type is a union of primitive types only.
*
Expand Down