/** Utilities for working with FetchXml. */ export enum Operator { eq = "eq", neq = "neq", ne = "ne", gt = "gt", ge = "ge", le = "le", lt = "lt", like = "like", notLike = "not-like", _in = "in", notIn = "not-in", between = "between", notBetween = "not-between", _null = "null", notNull = "not-null", // ... beginsWith = "begins-with", notBeginWith = "not-begin-with", endsWith = "ends-with", notEndWith = "not-end-with", under = "under", eqOrUnder = "eq-or-under", notUnder = "notUnder", above = "above", eqOrAbove = "eq-or-above", } /* */ /** OperatorMetadata.argCount = UNLIMITED_ARGS means list. */ export const UNLIMITED_ARGS = -1 export interface OperatorMetadata { /** Enumeration name in fetchxml xsd */ op: Operator /** Number of arguments needed for operator. */ argCount: number /** Javascript that it applies to, can be multiple. Values are returned from typeof. */ appliesTo: string | Array /** Non-intln display name. */ displayName?: string /** Description. */ description?: string } export const OperatorMetadata: Array = [ {op: Operator.eq, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator.neq, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.ne, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.gt, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator.ge, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator.le, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator.lt, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator.like, argCount: 1, appliesTo: ["string"]}, {op: Operator.notLike, argCount: 1, appliesTo: ["string"]}, {op: Operator._in, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.notIn, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.between, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator.notBetween, argCount: 2, appliesTo: ["number", "string"]}, {op: Operator._null, argCount: 0, appliesTo: ["number", "string"]}, {op: Operator.notNull, argCount: 0, appliesTo: ["number", "string"]}, // ... {op: Operator.beginsWith, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.notBeginWith, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.endsWith, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.notEndWith, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.under, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.eqOrUnder, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.notUnder, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.above, argCount: 1, appliesTo: ["number", "string"]}, {op: Operator.eqOrAbove, argCount: 1, appliesTo: ["number", "string"]}, ]