mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
* dbeaver/pro#8307 updates yarn lock * updates eslint * updates graphql libs * updates @types/whatwg-mimetype * updates whatwg-mimetype * covers evaluate with unit tests * updates subscript * removes Rollup CVE * removes CVE for storybook * removes CVE for koa * removes CVE for minimatch * removes CVE for ajv * removes redundant types * cleanup * updates yarn.lock * reverts eslint * updates yarn.lock * updates yarn lock * reverts subscript version * fixes immutable CVE * fixes serialize-javascript CVE * updates yarn lock --------- Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com> Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> Co-authored-by: Serge Rider <serge@jkiss.org>
30 lines
808 B
TypeScript
30 lines
808 B
TypeScript
/*
|
|
* CloudBeaver - Cloud Database Manager
|
|
* Copyright (C) 2020-2026 DBeaver Corp and others
|
|
*
|
|
* Licensed under the Apache License, Version 2.0.
|
|
* you may not use this file except in compliance with the License.
|
|
*/
|
|
|
|
import subscript from 'subscript';
|
|
import { err, token } from 'subscript/parse';
|
|
|
|
import 'subscript/feature/bool.js';
|
|
|
|
const UNDEFINED_MAPPER_VALUE = new Array(2).fill(undefined, 1);
|
|
token('undefined', 20, a => (a ? err() : UNDEFINED_MAPPER_VALUE));
|
|
token('null', 20, a => (a ? err() : UNDEFINED_MAPPER_VALUE));
|
|
|
|
interface IContext {
|
|
object: Record<string, any>;
|
|
}
|
|
|
|
export function evaluate(expression: string, object: Record<string, any>): boolean {
|
|
const fn = subscript(expression);
|
|
const context: IContext = {
|
|
object,
|
|
};
|
|
const result = fn(context);
|
|
return !!result;
|
|
}
|