Skip to content

Commit

Permalink
Add operator keyword to schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Apr 12, 2023
1 parent 26a08f3 commit 82cf6ac
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/expressions/lib/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ajv = new Ajv({
strict: true
})
addFormats(ajv)

ajv.addKeyword('operator')

// Delegate property access to the schema definition
const DelegateToDefinition = {
Expand Down
3 changes: 2 additions & 1 deletion packages/expressions/schemas/Add.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/Add.schema.json",
"title": "Add",
"description": "Add two values",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "+",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/Divide.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/Divide.schema.json",
"title": "Divide",
"description": "Divide two values",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "/",
"$ref": "schema.json#/definitions/operation"
}
5 changes: 2 additions & 3 deletions packages/expressions/schemas/Duration.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
"items": [
{ "$ref": "schema.json#/definitions/number" },
{
"title": "Unit",
"anyOf": [
{
"title": "Unit",
"type": "string",
"enum": ["seconds", "minutes", "hours", "days", "weeks", "months", "years"],
"default": "seconds"
"enum": ["seconds", "minutes", "hours", "days", "weeks", "months", "years"]
},
{ "$ref": "schema.json#/definitions/function" }
]
Expand Down
3 changes: 2 additions & 1 deletion packages/expressions/schemas/Equal.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/Equal.schema.json",
"title": "Equal",
"description": "Compare two values for equality",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "==",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/GreaterThan.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/GreaterThan.schema.json",
"title": "GreaterThan",
"description": "Compare if the first argument is > the second argument.",
"$ref": "schema.json#/definitions/arguments-two"
"operator": ">",
"$ref": "schema.json#/definitions/operation"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/GreaterThanOrEqualTo.schema.json",
"title": "GreaterThanOrEqualTo",
"description": "Compare if the first argument is >= the second argument.",
"$ref": "schema.json#/definitions/arguments-two"
"operator": ">=",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/LessThan.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/LessThan.schema.json",
"title": "LessThan",
"description": "Compare if the first argument is < the second argument.",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "<",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/LessThanOrEqualTo.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/LessThanOrEqualTo.schema.json",
"title": "LessThanOrEqualTo",
"description": "Compare if the first argument is < the second argument.",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "<=",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/Multiply.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/Multiply.schema.json",
"title": "Multiply",
"description": "Multiply two values",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "*",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/NotEqual.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/NotEqual.schema.json",
"title": "NotEqual",
"description": "Compare two values for equality",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "!=",
"$ref": "schema.json#/definitions/operation"
}
3 changes: 2 additions & 1 deletion packages/expressions/schemas/Subtract.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"$id": "https://www.flippercloud.io/expressions/Subtract.schema.json",
"title": "Subtract",
"description": "Subtract two values",
"$ref": "schema.json#/definitions/arguments-two"
"operator": "-",
"$ref": "schema.json#/definitions/operation"
}
7 changes: 4 additions & 3 deletions packages/expressions/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
{
"title": "Boolean",
"type": "boolean"
"type": "boolean",
"enum": [true, false]
}
]
},
Expand Down Expand Up @@ -82,8 +83,8 @@
"items": { "$ref": "#" },
"minItems": 0
},
"arguments-two": {
"title": "Comparison",
"operation": {
"title": "Operation",
"description": "An array with exactly two expressions",
"type": "array",
"items": { "$ref": "#" },
Expand Down

0 comments on commit 82cf6ac

Please sign in to comment.