(expr: SimpleExpr)
| 36 | expr: SimpleExpr |
| 37 | ): Promise<CELExpr | undefined> => { |
| 38 | const convert = async (expr: SimpleExpr): Promise<CELExpr | undefined> => { |
| 39 | if (isConditionGroupExpr(expr)) return convertGroup(expr); |
| 40 | if (isConditionExpr(expr)) return convertCondition(expr); |
| 41 | if (isRawStringExpr(expr)) { |
| 42 | if (!expr.content) { |
| 43 | return undefined; |
| 44 | } |
| 45 | const request = create(BatchParseRequestSchema, { |
| 46 | expressions: [expr.content], |
| 47 | }); |
| 48 | const response = await celServiceClientConnect.batchParse(request, { |
| 49 | contextValues: createContextValues().set(silentContextKey, true), |
| 50 | }); |
| 51 | return head(response.expressions); |
| 52 | } |
| 53 | throw new Error(`unexpected type "${String(expr)}"`); |
| 54 | }; |
| 55 | const convertCondition = (condition: ConditionExpr): CELExpr => { |
| 56 | if (isEqualityExpr(condition)) { |
| 57 | const { operator, args } = condition; |
no test coverage detected