@zeng-alt/vue-spel-query-builder 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/assets/vue-spel-query-builder.css +480 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.cjs +3111 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm +3095 -0
- package/dist/index.esm.map +1 -0
- package/dist/src/components/RuleTree/ExpressionEditor.vue.d.ts +23 -0
- package/dist/src/components/RuleTree/RuleTree.vue.d.ts +13 -0
- package/dist/src/components/RuleTree/RuleTreeNode.vue.d.ts +27 -0
- package/dist/src/components/SpelEditor/SpelEditor.vue.d.ts +17 -0
- package/dist/src/components/SpelEditor/spel-autocomplete-ext.d.ts +7 -0
- package/dist/src/components/SpelEditor/spel-autocomplete-style.d.ts +10 -0
- package/dist/src/components/SpelEditor/spel-autocomplete-tooltip.d.ts +2 -0
- package/dist/src/components/SpelEditor/spel-completions.d.ts +9 -0
- package/dist/src/components/SpelEditor/spel-parser.d.ts +8 -0
- package/dist/src/components/SpelEditor/spel-theme.d.ts +15 -0
- package/dist/src/components/SpelEditor/spel-types.d.ts +92 -0
- package/dist/src/components/index.d.ts +3 -0
- package/dist/src/composables/index.d.ts +2 -0
- package/dist/src/composables/useRuleTree.d.ts +11 -0
- package/dist/src/composables/useSpelEditor.d.ts +23 -0
- package/dist/src/constants/index.d.ts +9 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/spel-service.d.ts +9 -0
- package/dist/src/types/index.d.ts +108 -0
- package/dist/src/utils/index.d.ts +26 -0
- package/package.json +107 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RuleTreeProps, RuleTreeInstance } from '../../types';
|
|
2
|
+
declare const __VLS_export: import('vue').DefineComponent<RuleTreeProps, RuleTreeInstance, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
|
+
"update:modelValue": (value: import('../..').RuleNode) => any;
|
|
4
|
+
change: (value: import('../..').RuleNode) => any;
|
|
5
|
+
}, string, import('vue').PublicProps, Readonly<RuleTreeProps> & Readonly<{
|
|
6
|
+
"onUpdate:modelValue"?: ((value: import('../..').RuleNode) => any) | undefined;
|
|
7
|
+
onChange?: ((value: import('../..').RuleNode) => any) | undefined;
|
|
8
|
+
}>, {
|
|
9
|
+
size: import('../..').ComponentSize;
|
|
10
|
+
theme: "light" | "dark";
|
|
11
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RuleNode, ComponentSize } from '../../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: RuleNode;
|
|
4
|
+
authentication?: Record<string, any>;
|
|
5
|
+
principal?: Record<string, any>;
|
|
6
|
+
locals?: Record<string, any>;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
level?: number;
|
|
9
|
+
theme?: 'light' | 'dark';
|
|
10
|
+
size?: ComponentSize;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
13
|
+
"add-condition": (id: string) => any;
|
|
14
|
+
"add-group": (id: string) => any;
|
|
15
|
+
"remove-node": (id: string) => any;
|
|
16
|
+
"update-node": (id: string, updates: Partial<RuleNode>) => any;
|
|
17
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
"onAdd-condition"?: ((id: string) => any) | undefined;
|
|
19
|
+
"onAdd-group"?: ((id: string) => any) | undefined;
|
|
20
|
+
"onRemove-node"?: ((id: string) => any) | undefined;
|
|
21
|
+
"onUpdate-node"?: ((id: string, updates: Partial<RuleNode>) => any) | undefined;
|
|
22
|
+
}>, {
|
|
23
|
+
size: ComponentSize;
|
|
24
|
+
theme: "light" | "dark";
|
|
25
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SpelEditorProps, SpelEditorInstance, ComponentSize } from '../../types';
|
|
2
|
+
declare const __VLS_export: import('vue').DefineComponent<SpelEditorProps, SpelEditorInstance, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
|
+
"update:modelValue": (value: string) => any;
|
|
4
|
+
change: (value: string) => any;
|
|
5
|
+
validate: (isValid: boolean, error?: string | undefined) => any;
|
|
6
|
+
run: (result: any, error?: string | undefined) => any;
|
|
7
|
+
}, string, import('vue').PublicProps, Readonly<SpelEditorProps> & Readonly<{
|
|
8
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
9
|
+
onChange?: ((value: string) => any) | undefined;
|
|
10
|
+
onValidate?: ((isValid: boolean, error?: string | undefined) => any) | undefined;
|
|
11
|
+
onRun?: ((result: any, error?: string | undefined) => any) | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
size: ComponentSize;
|
|
14
|
+
theme: "dark" | "light";
|
|
15
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { hoverTooltip } from '@codemirror/view';
|
|
2
|
+
import { CompletionSource } from '@codemirror/autocomplete';
|
|
3
|
+
import { ThemeTokens } from './spel-types';
|
|
4
|
+
export { buildHoverTooltipDom } from './spel-autocomplete-tooltip';
|
|
5
|
+
export declare function buildExtensions(T: ThemeTokens, isDark: boolean, fontSize: number, source: CompletionSource, tooltip: ReturnType<typeof hoverTooltip>): ({
|
|
6
|
+
extension: import('@codemirror/state').Extension;
|
|
7
|
+
} | readonly import('@codemirror/state').Extension[] | import('@codemirror/language').StreamLanguage<{}>)[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThemeTokens } from './spel-types';
|
|
2
|
+
export declare function injectAutocompleteStyle(T: ThemeTokens): void;
|
|
3
|
+
export declare function getTokenAt(doc: {
|
|
4
|
+
sliceString: (a: number, b: number) => string;
|
|
5
|
+
length: number;
|
|
6
|
+
}, pos: number): {
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
text: string;
|
|
10
|
+
} | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SpelEntry, ArrayMeta, ElementField } from './spel-types';
|
|
2
|
+
export declare function buildEntries(authentication?: Record<string, any>, principal?: Record<string, any>, locals?: Record<string, any>): SpelEntry[];
|
|
3
|
+
export declare function buildTypeMap(authentication?: Record<string, any>, principal?: Record<string, any>, locals?: Record<string, any>): Record<string, string>;
|
|
4
|
+
export declare function buildElementFields(obj: any): ElementField[];
|
|
5
|
+
export declare function buildArrayMeta(authentication?: Record<string, any>, principal?: Record<string, any>, locals?: Record<string, any>): Record<string, ArrayMeta>;
|
|
6
|
+
export declare function buildStringMethodEntries(): SpelEntry[];
|
|
7
|
+
export declare function buildArrayMethodEntries(am?: ArrayMeta): SpelEntry[];
|
|
8
|
+
export declare function buildFilterFieldEntries(fields: ElementField[], prefix?: string): SpelEntry[];
|
|
9
|
+
export declare function resolveFieldPath(fields: ElementField[], path: string): ElementField | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StreamLanguage } from '@codemirror/language';
|
|
2
|
+
/**
|
|
3
|
+
* SpEL StreamLanguage 解析器
|
|
4
|
+
* 用于语法高亮、括号匹配等
|
|
5
|
+
*/
|
|
6
|
+
export declare const SPEL_KEYWORDS: Set<string>;
|
|
7
|
+
export declare const SPEL_BUILTIN_FNS: Set<string>;
|
|
8
|
+
export declare const spelLanguage: StreamLanguage<{}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
2
|
+
import { ThemeTokens } from './spel-types';
|
|
3
|
+
/**
|
|
4
|
+
* 编辑器主题色板
|
|
5
|
+
*/
|
|
6
|
+
export declare const DARK: ThemeTokens;
|
|
7
|
+
export declare const LIGHT: ThemeTokens;
|
|
8
|
+
/**
|
|
9
|
+
* 创建语法高亮样式(随主题响应式重建)
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSpelHighlightStyle(T: ThemeTokens): HighlightStyle;
|
|
12
|
+
/**
|
|
13
|
+
* 创建编辑器 UI 主题(随主题响应式重建)
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSpelTheme(T: ThemeTokens, isDark: boolean, fontSize: number): import('@codemirror/state').Extension;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 补全条目接口
|
|
3
|
+
*/
|
|
4
|
+
export interface SpelEntry {
|
|
5
|
+
label: string;
|
|
6
|
+
type: 'variable' | 'property' | 'keyword' | 'function';
|
|
7
|
+
detail: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
extra?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 对象数组元素中的递归字段
|
|
13
|
+
*/
|
|
14
|
+
export interface ElementField {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
type: string;
|
|
18
|
+
children?: ElementField[];
|
|
19
|
+
elementType?: string;
|
|
20
|
+
elementFields?: ElementField[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 数组元信息(路径 → 元素类型/字段)
|
|
24
|
+
*/
|
|
25
|
+
export interface ArrayMeta {
|
|
26
|
+
elementType: string;
|
|
27
|
+
elementFields?: ElementField[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 编辑器主题色板
|
|
31
|
+
*/
|
|
32
|
+
export interface ThemeTokens {
|
|
33
|
+
editorBg: string;
|
|
34
|
+
gutterBg: string;
|
|
35
|
+
gutterBorder: string;
|
|
36
|
+
gutterFg: string;
|
|
37
|
+
contentFg: string;
|
|
38
|
+
activeLine: string;
|
|
39
|
+
activeGutter: string;
|
|
40
|
+
selectionBg: string;
|
|
41
|
+
cursor: string;
|
|
42
|
+
matchBracket: string;
|
|
43
|
+
matchBracketBg: string;
|
|
44
|
+
keyword: string;
|
|
45
|
+
operator: string;
|
|
46
|
+
string: string;
|
|
47
|
+
number: string;
|
|
48
|
+
atom: string;
|
|
49
|
+
variable: string;
|
|
50
|
+
definition: string;
|
|
51
|
+
property: string;
|
|
52
|
+
comment: string;
|
|
53
|
+
acBg: string;
|
|
54
|
+
acBorder: string;
|
|
55
|
+
acScrollThumb: string;
|
|
56
|
+
acItemFg: string;
|
|
57
|
+
acItemHoverBg: string;
|
|
58
|
+
acIconVar: string;
|
|
59
|
+
acIconVarBg: string;
|
|
60
|
+
acIconProp: string;
|
|
61
|
+
acIconPropBg: string;
|
|
62
|
+
acIconKey: string;
|
|
63
|
+
acIconKeyBg: string;
|
|
64
|
+
acIconFn: string;
|
|
65
|
+
acIconFnBg: string;
|
|
66
|
+
acLabel: string;
|
|
67
|
+
acLabelHover: string;
|
|
68
|
+
acDetail: string;
|
|
69
|
+
acDetailHover: string;
|
|
70
|
+
acDetailBorder: string;
|
|
71
|
+
ttBg: string;
|
|
72
|
+
ttBorder: string;
|
|
73
|
+
ttFg: string;
|
|
74
|
+
ttLabelFg: string;
|
|
75
|
+
ttDivider: string;
|
|
76
|
+
ttCodeBg: string;
|
|
77
|
+
ttCodeFg: string;
|
|
78
|
+
ttCodeBorder: string;
|
|
79
|
+
badgeVarBg: string;
|
|
80
|
+
badgeVarFg: string;
|
|
81
|
+
badgePropBg: string;
|
|
82
|
+
badgePropFg: string;
|
|
83
|
+
badgeKeyBg: string;
|
|
84
|
+
badgeKeyFg: string;
|
|
85
|
+
badgeFnBg: string;
|
|
86
|
+
badgeFnFg: string;
|
|
87
|
+
headerFrom: string;
|
|
88
|
+
headerTo: string;
|
|
89
|
+
errBg: string;
|
|
90
|
+
errBorder: string;
|
|
91
|
+
errFg: string;
|
|
92
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RuleNode, RuleTreeProps } from '../types';
|
|
2
|
+
export declare function useRuleTree(props: RuleTreeProps, emit: any): {
|
|
3
|
+
getSpelExpression: () => string;
|
|
4
|
+
setSpelExpression: (_expression: string) => void;
|
|
5
|
+
addCondition: (parentId: string) => void;
|
|
6
|
+
addGroup: (parentId: string, operator?: "and" | "or") => void;
|
|
7
|
+
removeNode: (nodeId: string) => void;
|
|
8
|
+
updateNode: (nodeId: string, updates: Partial<RuleNode>) => void;
|
|
9
|
+
validate: () => boolean;
|
|
10
|
+
run: (props: RuleTreeProps, sepl: string) => any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SpelEditorProps } from '../types';
|
|
2
|
+
export declare function useSpelEditor(props: SpelEditorProps, emit: any): {
|
|
3
|
+
internalValue: import('vue').Ref<string, string>;
|
|
4
|
+
isFocused: import('vue').Ref<boolean, boolean>;
|
|
5
|
+
validation: import('vue').Ref<{
|
|
6
|
+
valid: boolean;
|
|
7
|
+
error?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
} | {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
error?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
heightStyle: import('vue').ComputedRef<{
|
|
16
|
+
height: string;
|
|
17
|
+
}>;
|
|
18
|
+
handleInput: (value: string) => void;
|
|
19
|
+
handleValidate: () => Promise<boolean>;
|
|
20
|
+
setValue: (value: string) => void;
|
|
21
|
+
getValue: () => string;
|
|
22
|
+
run: () => Promise<any>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Comparator } from '../types';
|
|
2
|
+
export declare const DEFAULT_COMPARATORS: Comparator[];
|
|
3
|
+
export declare const GROUP_OPERATORS: {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
export declare const EDITOR_THEME = "one-dark";
|
|
8
|
+
export declare const EDITOR_DEFAULT_HEIGHT = "400px";
|
|
9
|
+
export declare const RULE_TREE_DEFAULT_HEIGHT = "500px";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { spelService } from './spel-service';
|
|
2
|
+
export { SpelEditor, RuleTree } from './components';
|
|
3
|
+
export type { SpelEditorProps, SpelEditorEmits, SpelEditorInstance, RuleTreeProps, RuleTreeEmits, RuleTreeInstance, RuleNode, ContextVariable, Comparator, ComponentSize, } from './types';
|
|
4
|
+
export { useSpelEditor, useRuleTree } from './composables';
|
|
5
|
+
export { validateSpelExpression, evalSpelExpression, ruleNodeToSpel, createEmptyCondition, createEmptyGroup, generateId, } from './utils';
|
|
6
|
+
export { DEFAULT_COMPARATORS, GROUP_OPERATORS, EDITOR_THEME, EDITOR_DEFAULT_HEIGHT, RULE_TREE_DEFAULT_HEIGHT, } from './constants';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare class SpelService {
|
|
2
|
+
private context;
|
|
3
|
+
setContext(authentication?: any, principal?: any): void;
|
|
4
|
+
getContext(): any;
|
|
5
|
+
compile(expression: string): import('spel2js').CompiledExpression;
|
|
6
|
+
eval(expression: string, locals?: Record<string, any>): any;
|
|
7
|
+
}
|
|
8
|
+
export declare const spelService: SpelService;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export type ComponentSize = 'tiny' | 'small' | 'medium' | 'large';
|
|
2
|
+
export interface SpelEditorProps {
|
|
3
|
+
modelValue: string;
|
|
4
|
+
authentication?: Record<string, any>;
|
|
5
|
+
principal?: Record<string, any>;
|
|
6
|
+
locals?: Record<string, any>;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
readonly?: boolean;
|
|
9
|
+
height?: string | number;
|
|
10
|
+
theme?: 'dark' | 'light';
|
|
11
|
+
size?: ComponentSize;
|
|
12
|
+
}
|
|
13
|
+
export interface SpelEditorEmits {
|
|
14
|
+
(e: 'update:modelValue', value: string): void;
|
|
15
|
+
(e: 'change', value: string): void;
|
|
16
|
+
(e: 'validate', isValid: boolean, error?: string): void;
|
|
17
|
+
(e: 'run', result: any, error?: string): void;
|
|
18
|
+
}
|
|
19
|
+
export interface FunctionArgument {
|
|
20
|
+
type: 'value' | 'field' | 'function';
|
|
21
|
+
value?: string;
|
|
22
|
+
functionArgument?: FunctionArgument;
|
|
23
|
+
}
|
|
24
|
+
export type ValueSource = 'value' | 'field' | 'function';
|
|
25
|
+
export type FieldSource = 'field' | 'function';
|
|
26
|
+
export type LogicalOperator = 'and' | 'or' | 'not';
|
|
27
|
+
export interface FieldOption {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string | number;
|
|
30
|
+
type?: string;
|
|
31
|
+
children?: FieldOption[];
|
|
32
|
+
elementType?: string;
|
|
33
|
+
elementChildren?: FieldOption[];
|
|
34
|
+
}
|
|
35
|
+
export type Expression = {
|
|
36
|
+
type: 'literal';
|
|
37
|
+
value: string;
|
|
38
|
+
literalType?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'field';
|
|
41
|
+
path: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'function';
|
|
44
|
+
call: FunctionCall;
|
|
45
|
+
};
|
|
46
|
+
export interface FunctionCall {
|
|
47
|
+
method: string;
|
|
48
|
+
base?: Expression;
|
|
49
|
+
args: Expression[];
|
|
50
|
+
}
|
|
51
|
+
export interface FunctionDef {
|
|
52
|
+
label: string;
|
|
53
|
+
value: string;
|
|
54
|
+
argumentCount: number;
|
|
55
|
+
hasBase: boolean;
|
|
56
|
+
baseType?: string;
|
|
57
|
+
returnType?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ListFilter {
|
|
60
|
+
comparator: string;
|
|
61
|
+
value?: Expression;
|
|
62
|
+
fieldPath?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface RuleNode {
|
|
65
|
+
id: string;
|
|
66
|
+
type: 'condition' | 'group';
|
|
67
|
+
operator?: LogicalOperator;
|
|
68
|
+
children?: RuleNode[];
|
|
69
|
+
left?: Expression;
|
|
70
|
+
comparator?: string;
|
|
71
|
+
right?: Expression;
|
|
72
|
+
listFilter?: ListFilter;
|
|
73
|
+
}
|
|
74
|
+
export interface RuleTreeProps {
|
|
75
|
+
modelValue: RuleNode;
|
|
76
|
+
authentication?: Record<string, any>;
|
|
77
|
+
principal?: Record<string, any>;
|
|
78
|
+
locals?: Record<string, any>;
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
theme?: 'light' | 'dark';
|
|
81
|
+
size?: ComponentSize;
|
|
82
|
+
}
|
|
83
|
+
export interface RuleTreeEmits {
|
|
84
|
+
(e: 'update:modelValue', value: RuleNode): void;
|
|
85
|
+
(e: 'change', value: RuleNode): void;
|
|
86
|
+
}
|
|
87
|
+
export interface ContextVariable {
|
|
88
|
+
name: string;
|
|
89
|
+
type: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface Comparator {
|
|
93
|
+
value: string;
|
|
94
|
+
label: string;
|
|
95
|
+
types: string[];
|
|
96
|
+
}
|
|
97
|
+
export interface SpelEditorInstance {
|
|
98
|
+
getValue: () => string;
|
|
99
|
+
setValue: (value: string) => void;
|
|
100
|
+
validate: () => Promise<boolean>;
|
|
101
|
+
run: () => Promise<any>;
|
|
102
|
+
focus: () => void;
|
|
103
|
+
}
|
|
104
|
+
export interface RuleTreeInstance {
|
|
105
|
+
getSpelExpression: () => string;
|
|
106
|
+
setSpelExpression: (expression: string) => void;
|
|
107
|
+
validate: () => boolean;
|
|
108
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RuleNode, LogicalOperator, Expression } from '../types';
|
|
2
|
+
export declare function generateId(): string;
|
|
3
|
+
export declare function validateSpelExpression(expression: string): {
|
|
4
|
+
valid: boolean;
|
|
5
|
+
error?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function evalSpelExpression(expression: string, locals: Record<string, any>): any;
|
|
8
|
+
/**
|
|
9
|
+
* 将 RuleNode 树转换为 SpEL 表达式字符串
|
|
10
|
+
*/
|
|
11
|
+
export declare function ruleNodeToSpel(node: RuleNode): string;
|
|
12
|
+
/**
|
|
13
|
+
* 格式化 Expression 为 SpEL 字符串
|
|
14
|
+
* - 字面量:'字符串',数字不加引号(这里简单处理,所有字面量加单引号,数字可后续增强)
|
|
15
|
+
* - 字段:直接使用路径
|
|
16
|
+
* - 函数:base.method(arg1, arg2, ...)
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatExpression(expr?: Expression): string;
|
|
19
|
+
/**
|
|
20
|
+
* 创建一个新的空白条件节点
|
|
21
|
+
*/
|
|
22
|
+
export declare function createEmptyCondition(): RuleNode;
|
|
23
|
+
/**
|
|
24
|
+
* 创建一个新的空白分组节点
|
|
25
|
+
*/
|
|
26
|
+
export declare function createEmptyGroup(operator?: LogicalOperator): RuleNode;
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zeng-alt/vue-spel-query-builder",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vue3 SpEL Query Builder - A visual rule tree and code editor for SpEL expressions",
|
|
5
|
+
"author": "zeng-alt",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zeng-alt/vue-spel-query-builder.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/zeng-alt/vue-spel-query-builder/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/zeng-alt/vue-spel-query-builder#readme",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vue3",
|
|
18
|
+
"spel",
|
|
19
|
+
"query-builder",
|
|
20
|
+
"rule-engine",
|
|
21
|
+
"codemirror",
|
|
22
|
+
"naive-ui"
|
|
23
|
+
],
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.esm",
|
|
26
|
+
"types": "./dist/src/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/src/index.d.ts",
|
|
30
|
+
"import": "./dist/index.esm",
|
|
31
|
+
"require": "./dist/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./style.css": "./dist/assets/vue-spel-query-builder.css"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"sideEffects": [
|
|
42
|
+
"**/*.css"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"dev": "vite --config vite.config.ts",
|
|
46
|
+
"build": "vite build --config vite.lib.config.ts",
|
|
47
|
+
"build:all": "run-p type-check \"build-only {@}\" --",
|
|
48
|
+
"preview": "vite preview --config vite.config.ts",
|
|
49
|
+
"test:unit": "vitest",
|
|
50
|
+
"build-only": "vite build --config vite.lib.config.ts",
|
|
51
|
+
"type-check": "vue-tsc --build",
|
|
52
|
+
"lint": "run-s lint:*",
|
|
53
|
+
"lint:oxlint": "oxlint . --fix",
|
|
54
|
+
"lint:eslint": "eslint . --fix --cache",
|
|
55
|
+
"format": "prettier --write --experimental-cli src/",
|
|
56
|
+
"prepublishOnly": "npm run build"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"naive-ui": "^2.44.0",
|
|
60
|
+
"vue": "^3.5.0"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@codemirror/autocomplete": "^6.0.0",
|
|
64
|
+
"@codemirror/commands": "^6.10.3",
|
|
65
|
+
"@codemirror/language": "^6.9.2",
|
|
66
|
+
"@codemirror/state": "^6.5.2",
|
|
67
|
+
"@codemirror/view": "^6.38.2",
|
|
68
|
+
"@lezer/highlight": "^1.2.0",
|
|
69
|
+
"@unocss/vite": "^66.6.8",
|
|
70
|
+
"codemirror": "^6.0.1",
|
|
71
|
+
"spel2js": "^0.2.9",
|
|
72
|
+
"unocss": "^66.6.8",
|
|
73
|
+
"vite-plugin-dts": "^5.0.0",
|
|
74
|
+
"vue-codemirror": "^6.1.1"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@iconify-json/carbon": "^1.2.8",
|
|
78
|
+
"@tsconfig/node24": "^24.0.4",
|
|
79
|
+
"@types/jsdom": "^28.0.1",
|
|
80
|
+
"@types/node": "^24.12.2",
|
|
81
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
82
|
+
"@vitejs/plugin-vue-jsx": "^5.1.5",
|
|
83
|
+
"@vitest/eslint-plugin": "^1.6.16",
|
|
84
|
+
"@vue/eslint-config-typescript": "^14.7.0",
|
|
85
|
+
"@vue/test-utils": "^2.4.6",
|
|
86
|
+
"@vue/tsconfig": "^0.9.1",
|
|
87
|
+
"eslint": "^10.2.1",
|
|
88
|
+
"eslint-config-prettier": "^10.1.8",
|
|
89
|
+
"eslint-plugin-oxlint": "~1.60.0",
|
|
90
|
+
"eslint-plugin-vue": "~10.8.0",
|
|
91
|
+
"jiti": "^2.6.1",
|
|
92
|
+
"jsdom": "^29.0.2",
|
|
93
|
+
"naive-ui": "^2.44.1",
|
|
94
|
+
"npm-run-all2": "^8.0.4",
|
|
95
|
+
"oxlint": "~1.60.0",
|
|
96
|
+
"prettier": "3.8.3",
|
|
97
|
+
"typescript": "~6.0.0",
|
|
98
|
+
"vite": "^8.0.8",
|
|
99
|
+
"vite-plugin-vue-devtools": "^8.1.1",
|
|
100
|
+
"vitest": "^4.1.4",
|
|
101
|
+
"vue": "^3.5.32",
|
|
102
|
+
"vue-tsc": "^3.2.6"
|
|
103
|
+
},
|
|
104
|
+
"engines": {
|
|
105
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
106
|
+
}
|
|
107
|
+
}
|