You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
const either = require("@validatem/either");
|
|
const arrayOf = require("@validatem/array-of");
|
|
|
|
const tagAsType = require("../tag-as-type");
|
|
|
|
module.exports = function (operations) {
|
|
const isObjectType = require("./is-object-type")(operations);
|
|
const isExpressionList = require("./is-expression-list")(operations);
|
|
const isConditionList = require("./is-condition-list")(operations);
|
|
const isWhereObjectList = require("./is-where-object-list")(operations);
|
|
const isConditionValue = require("./is-condition-value")(operations);
|
|
|
|
return either([
|
|
// Boolean AND/OR
|
|
[ isExpressionList, tagAsType("expressions") ],
|
|
// Combine (JOIN)
|
|
// FIXME?
|
|
// ...
|
|
// Value-expression-only conditions (eg. `moreThan(anyOf(...))`)
|
|
[ either([
|
|
arrayOf(isConditionValue),
|
|
isObjectType("placeholder"), // for dynamically specified array of values
|
|
isObjectType("sqlExpression"), // FIXME: Verify that this should be treated as a value, not an expression
|
|
]), tagAsType("values") ],
|
|
// Multiple-choice conditions
|
|
[ isWhereObjectList, tagAsType("expressions") ],
|
|
[ isConditionList, tagAsType("conditions") ],
|
|
]);
|
|
};
|