MCPcopy Create free account
hub / github.com/bytebase/bytebase / resolveCollectionExpr

Function resolveCollectionExpr

frontend/src/plugins/cel/logic/resolve.ts:221–263  ·  view source on GitHub ↗
(
  expr: CELExpr,
  negative: boolean = false
)

Source from the content-addressed store, hash-verified

219};
220
221const resolveCollectionExpr = (
222 expr: CELExpr,
223 negative: boolean = false
224): CollectionExpr => {
225 const callExpr =
226 expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;
227 if (!callExpr)
228 throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);
229 let operator = callExpr.function as CollectionOperator;
230 if (negative && operator === "@in") {
231 operator = "@not_in";
232 }
233 const [factorExpr, valuesExpr] = callExpr.args;
234 const factor = getFactorName(factorExpr);
235
236 if (isNumberFactor(factor)) {
237 return {
238 type: ExprType.Condition,
239 operator,
240 args: [
241 factor,
242 valuesExpr.exprKind?.case === "listExpr"
243 ? (valuesExpr.exprKind.value.elements?.map(getConstantInt64Value) ??
244 [])
245 : [],
246 ],
247 };
248 }
249 if (isStringFactor(factor)) {
250 return {
251 type: ExprType.Condition,
252 operator,
253 args: [
254 factor,
255 valuesExpr.exprKind?.case === "listExpr"
256 ? (valuesExpr.exprKind.value.elements?.map(getConstantStringValue) ??
257 [])
258 : [],
259 ],
260 };
261 }
262 throw new Error(`cannot resolve expr ${JSON.stringify(expr)}`);
263};
264
265const resolveRawStringExpr = (expr: CELExpr): RawStringExpr => {
266 return {

Callers 1

dfsFunction · 0.85

Calls 3

isNumberFactorFunction · 0.90
isStringFactorFunction · 0.90
getFactorNameFunction · 0.85

Tested by

no test coverage detected