Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,22 @@ function createComparisonDefinition(
],
returnType: 'boolean',
},
...['date', 'number'].flatMap((type) => [
{
params: [
{ name: 'left', type: 'version' },
{ name: 'right', type: 'version' },
],
returnType: 'boolean',
},
// constant strings okay because of implicit casting for
// string to version and ip
//
// boolean casting is handled on the specific comparison function
// that support booleans
//
// date casting is handled in the validation routine since it's a
// general rule. Look in compareLiteralType()
...['ip', 'version'].flatMap((type) => [
{
params: [
{ name: 'left', type },
Expand Down Expand Up @@ -214,6 +229,21 @@ export const builtinFunctions: FunctionDefinition[] = [
],
returnType: 'boolean',
},
// constant strings okay because of implicit casting
{
params: [
{ name: 'left', type: 'boolean' },
{ name: 'right', type: 'string', constantOnly: true },
],
returnType: 'boolean',
},
{
params: [
{ name: 'right', type: 'string', constantOnly: true },
{ name: 'right', type: 'boolean' },
],
returnType: 'boolean',
},
],
},
{
Expand All @@ -232,6 +262,21 @@ export const builtinFunctions: FunctionDefinition[] = [
],
returnType: 'boolean',
},
// constant strings okay because of implicit casting
{
params: [
{ name: 'left', type: 'boolean' },
{ name: 'right', type: 'string', constantOnly: true },
],
returnType: 'boolean',
},
{
params: [
{ name: 'right', type: 'string', constantOnly: true },
{ name: 'right', type: 'boolean' },
],
returnType: 'boolean',
},
],
},
{
Expand Down Expand Up @@ -318,6 +363,15 @@ export const builtinFunctions: FunctionDefinition[] = [
},
{ name: 'not_in', description: '' },
].map<FunctionDefinition>(({ name, description }) => ({
// set all arrays to type "any" for now
// this only applies to the "in" operator
// e.g. "foo" in ( "foo", "bar" )
//
// we did this because the "in" operator now supports
// mixed-type arrays like ( "1.2.3", versionVar )
// because of implicit casting.
//
// we need to revisit with more robust validation
type: 'builtin',
ignoreAsSuggestion: /not/.test(name),
name,
Expand All @@ -327,28 +381,43 @@ export const builtinFunctions: FunctionDefinition[] = [
{
params: [
{ name: 'left', type: 'number' },
{ name: 'right', type: 'number[]' },

{ name: 'right', type: 'any[]' },
],
returnType: 'boolean',
},
{
params: [
{ name: 'left', type: 'string' },
{ name: 'right', type: 'string[]' },
{ name: 'right', type: 'any[]' },
],
returnType: 'boolean',
},
{
params: [
{ name: 'left', type: 'boolean' },
{ name: 'right', type: 'boolean[]' },
{ name: 'right', type: 'any[]' },
],
returnType: 'boolean',
},
{
params: [
{ name: 'left', type: 'date' },
{ name: 'right', type: 'date[]' },
{ name: 'right', type: 'any[]' },
],
returnType: 'boolean',
},
{
params: [
{ name: 'left', type: 'version' },
{ name: 'right', type: 'any[]' },
],
returnType: 'boolean',
},
{
params: [
{ name: 'left', type: 'ip' },
{ name: 'right', type: 'any[]' },
],
returnType: 'boolean',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [
signatures: [
{
params: [{ name: 'field', type: 'string' }],
returnType: 'string',
returnType: 'version',
examples: [`from index | EVAL version = to_version(stringField)`],
},
],
Expand Down
Loading