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

Function wrapConstExpr

frontend/src/plugins/cel/logic/build.ts:146–181  ·  view source on GitHub ↗
(value: number | string | boolean | Date)

Source from the content-addressed store, hash-verified

144};
145
146const wrapConstExpr = (value: number | string | boolean | Date): CELExpr => {
147 if (typeof value === "string") {
148 return wrapCELExpr({
149 case: "constExpr",
150 value: create(ConstantSchema, {
151 constantKind: {
152 case: "stringValue",
153 value,
154 },
155 }),
156 });
157 }
158 if (typeof value === "number") {
159 return wrapCELExpr({
160 case: "constExpr",
161 value: create(ConstantSchema, {
162 constantKind: {
163 case: "int64Value",
164 value: BigInt(value),
165 },
166 }),
167 });
168 }
169 if (typeof value === "boolean") {
170 return wrapCELExpr({
171 case: "constExpr",
172 value: create(ConstantSchema, {
173 constantKind: {
174 case: "boolValue",
175 value,
176 },
177 }),
178 });
179 }
180 throw new Error(`unexpected value "${value}"`);
181};
182
183const wrapListExpr = (values: string[] | number[]): CELExpr => {
184 return wrapCELExpr({

Callers 1

convertConditionFunction · 0.85

Calls 1

wrapCELExprFunction · 0.85

Tested by

no test coverage detected