@calenderjs/event-dsl 0.0.1
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/README.md +176 -0
- package/dist/ast/index.d.ts +5 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/types.d.ts +166 -0
- package/dist/ast/types.d.ts.map +1 -0
- package/dist/compiler.d.ts +49 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/generators/index.d.ts +8 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/json-schema.d.ts +22 -0
- package/dist/generators/json-schema.d.ts.map +1 -0
- package/dist/generators/typescript.d.ts +23 -0
- package/dist/generators/typescript.d.ts.map +1 -0
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1013 -0
- package/dist/index.mjs.map +1 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/parse.d.ts +9 -0
- package/dist/parser/parse.d.ts.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# @calenderjs/event-dsl
|
|
2
|
+
|
|
3
|
+
Event DSL - 领域特定语言,用于定义事件类型和业务规则。
|
|
4
|
+
|
|
5
|
+
**架构说明**:
|
|
6
|
+
- Event DSL 编译成 Data Model (Event 对象,包含规则和数据)
|
|
7
|
+
- Event Data Model 是 SSOT,定义了 Event 接口结构(在 @calenderjs/event-model 中)
|
|
8
|
+
- DSL 通过 EventDSLCompiler 编译成 Data Model (Event 对象,包含规则和数据)
|
|
9
|
+
|
|
10
|
+
**包职责**:
|
|
11
|
+
本包包含以下组件:
|
|
12
|
+
1. **DSL 定义**(核心):
|
|
13
|
+
- DSL 语法定义(`.pegjs` 文件)
|
|
14
|
+
- DSL 解析器(将文本解析为 AST)
|
|
15
|
+
- AST 类型定义(抽象语法树结构)
|
|
16
|
+
|
|
17
|
+
2. **DSL 工具**(执行引擎):
|
|
18
|
+
- **编译器**(`EventDSLCompiler`):编译 DSL → Data Model (Event 对象,包含规则和数据)
|
|
19
|
+
- **运行时引擎**(`EventRuntime`):使用编译后的 Data Model 进行验证、渲染和行为检查(**应用层使用**,在 `@calenderjs/event-runtime` 包中)
|
|
20
|
+
|
|
21
|
+
**验证架构**:
|
|
22
|
+
1. **编译时验证**(EventDSLCompiler,在 `@calenderjs/event-dsl` 包中):
|
|
23
|
+
- 验证 DSL 语法是否正确
|
|
24
|
+
- 如果编译失败,返回错误
|
|
25
|
+
- 生成验证器函数(基于字段定义,如 `required`、`min`、`max`)
|
|
26
|
+
|
|
27
|
+
2. **JSON Schema 验证**(EventValidator,在 `@calenderjs/event-model` 包中):
|
|
28
|
+
- 验证 Event 对象是否符合 Event 接口结构
|
|
29
|
+
- 验证 Event.extra 是否符合 JSON Schema(结构验证)
|
|
30
|
+
- 无法验证业务规则(如 `attendees.count between 1 and 50` 需要计算数组长度)
|
|
31
|
+
|
|
32
|
+
3. **运行时验证**(EventRuntime,在 `@calenderjs/event-runtime` 包中):
|
|
33
|
+
- 执行 DSL 中定义的业务规则(如 `attendees.count between 1 and 50`)
|
|
34
|
+
- 验证的是 Event 数据模型的数据(`@calenderjs/event-model` 中的 Event 对象)
|
|
35
|
+
- 需要运行时数据(event.extra.attendees.length)
|
|
36
|
+
- 需要上下文信息(context.events, context.now, context.user)
|
|
37
|
+
- 无法在编译时验证(数据是动态的)
|
|
38
|
+
- 无法通过 JSON Schema 验证(JSON Schema 只能验证结构,不能验证业务逻辑)
|
|
39
|
+
|
|
40
|
+
**重要**:
|
|
41
|
+
- 运行时**不在**数据模型包中(`@calenderjs/event-model`)
|
|
42
|
+
- 运行时在 DSL 包中(`@calenderjs/event-dsl`)
|
|
43
|
+
- 但运行时验证的是 Event 数据模型的数据
|
|
44
|
+
|
|
45
|
+
**重要说明**:
|
|
46
|
+
- **DSL 的主要用途**:编译成 Data Model (Event 对象,包含规则和数据)
|
|
47
|
+
- **Calendar 组件**:直接使用 Event 对象(event.color, event.icon, event.title),**不需要运行时**
|
|
48
|
+
- **运行时的用途**(应用层):
|
|
49
|
+
1. **业务规则验证**:执行 DSL 中定义的业务规则(如 `attendees.count between 1 and 50`、`no conflict with other events`)
|
|
50
|
+
2. **权限检查**:检查用户是否可以执行某个操作(draggable, editable, deletable)
|
|
51
|
+
3. **动态渲染**(可选):根据 DSL 规则动态生成显示属性(但 Event 已有 color/icon)
|
|
52
|
+
|
|
53
|
+
**数据流程**:
|
|
54
|
+
```
|
|
55
|
+
DSL 文本
|
|
56
|
+
→ Peggy 解析器
|
|
57
|
+
→ AST
|
|
58
|
+
→ EventDSLCompiler
|
|
59
|
+
→ Data Model (Event 对象,包含规则和数据)
|
|
60
|
+
→ Calendar 组件(直接使用)
|
|
61
|
+
|
|
62
|
+
验证流程:
|
|
63
|
+
1. 编译时验证(EventDSLCompiler):验证 DSL 语法,编译成 Data Model
|
|
64
|
+
2. JSON Schema 验证(EventValidator):使用 Data Model 中的标准 JSON Schema 验证 Event 结构
|
|
65
|
+
3. 运行时验证(EventRuntime):使用 Data Model 中的业务规则验证业务逻辑(应用层使用,在 `@calenderjs/event-runtime` 包中)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 安装
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm add @calenderjs/event-dsl
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 快速开始
|
|
75
|
+
|
|
76
|
+
### 1. 定义事件类型
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { EventTypeDefinition } from '@calenderjs/event-dsl';
|
|
80
|
+
|
|
81
|
+
const meetingType: EventTypeDefinition = {
|
|
82
|
+
id: 'meeting',
|
|
83
|
+
name: '会议',
|
|
84
|
+
fields: [
|
|
85
|
+
{
|
|
86
|
+
name: 'title',
|
|
87
|
+
type: 'string',
|
|
88
|
+
required: true,
|
|
89
|
+
validation: [
|
|
90
|
+
{ type: 'minLength', value: 1, errorMessage: '标题不能为空' }
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'attendees',
|
|
95
|
+
type: 'array',
|
|
96
|
+
items: { type: 'string' }
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
display: {
|
|
100
|
+
color: '#4285f4',
|
|
101
|
+
titleTemplate: '${title}',
|
|
102
|
+
descriptionTemplate: '${attendees.length} 人'
|
|
103
|
+
},
|
|
104
|
+
behavior: {
|
|
105
|
+
draggable: true,
|
|
106
|
+
minDuration: 15,
|
|
107
|
+
timeConstraints: [
|
|
108
|
+
{
|
|
109
|
+
type: 'workingHours',
|
|
110
|
+
value: { start: '09:00', end: '18:00' },
|
|
111
|
+
errorMessage: '会议只能在工作时间内安排'
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 2. 编译 DSL
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { EventDSLCompiler } from '@calenderjs/event-dsl';
|
|
122
|
+
|
|
123
|
+
const dsl: EventDSL = {
|
|
124
|
+
types: [meetingType]
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const compiler = new EventDSLCompiler();
|
|
128
|
+
const compiled = compiler.compile(dsl);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 3. 使用编译后的 Data Model
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import type { Event } from '@calenderjs/event-model';
|
|
135
|
+
|
|
136
|
+
// Data Model 是 Event 对象,包含规则和数据
|
|
137
|
+
// compiled.types[0] 是 CompiledType (Data Model)
|
|
138
|
+
const dataModel = compiled.types[0];
|
|
139
|
+
|
|
140
|
+
// Data Model 包含:
|
|
141
|
+
// - extraSchema: JSON Schema (用于验证 Event.extra 结构)
|
|
142
|
+
// - validationRules: 业务规则 (用于验证业务逻辑)
|
|
143
|
+
// - validator, renderer, behavior 等
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 4. 验证 Event 对象
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { EventValidator } from '@calenderjs/event-model';
|
|
150
|
+
import { EventRuntime } from '@calenderjs/event-runtime';
|
|
151
|
+
import { EventDSLCompiler } from '@calenderjs/event-dsl';
|
|
152
|
+
|
|
153
|
+
// 使用 Event Data Model 验证器验证基础结构
|
|
154
|
+
const eventValidator = new EventValidator();
|
|
155
|
+
const baseValidation = eventValidator.validateBase(event);
|
|
156
|
+
|
|
157
|
+
// 使用运行时验证业务规则
|
|
158
|
+
const compiler = new EventDSLCompiler();
|
|
159
|
+
const dataModel = compiler.compileFromAST([ast]);
|
|
160
|
+
const runtime = new EventRuntime(dataModel.types[0]);
|
|
161
|
+
const runtimeValidation = runtime.validate(event, context);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## API
|
|
165
|
+
|
|
166
|
+
### EventDSLCompiler
|
|
167
|
+
|
|
168
|
+
编译 DSL 定义,生成可执行的验证器和渲染器。
|
|
169
|
+
|
|
170
|
+
### EventRuntime
|
|
171
|
+
|
|
172
|
+
运行时系统,使用编译后的 Data Model 进行验证、渲染和行为配置查询。
|
|
173
|
+
|
|
174
|
+
## 更多示例
|
|
175
|
+
|
|
176
|
+
查看 `docs/examples/appointment-dsl-examples.ts` 获取更多示例。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event DSL AST 类型定义
|
|
3
|
+
*
|
|
4
|
+
* 根据 RFC-0001 定义
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Event Type AST 根节点
|
|
8
|
+
*/
|
|
9
|
+
export interface EventTypeAST {
|
|
10
|
+
type: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
fields: FieldDefinition[];
|
|
14
|
+
validate: ValidationRule[];
|
|
15
|
+
display: DisplayRule[];
|
|
16
|
+
behavior: BehaviorRule[];
|
|
17
|
+
constraints?: ConstraintRule[];
|
|
18
|
+
recurring?: RecurringDefinition;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 字段定义
|
|
22
|
+
*/
|
|
23
|
+
export interface FieldDefinition {
|
|
24
|
+
name: string;
|
|
25
|
+
type: FieldType;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
default?: any;
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 字段类型
|
|
33
|
+
*/
|
|
34
|
+
export type FieldType = 'string' | 'number' | 'boolean' | 'email' | 'text' | {
|
|
35
|
+
type: 'list';
|
|
36
|
+
itemType: FieldType;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'enum';
|
|
39
|
+
values: string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 验证规则
|
|
43
|
+
*/
|
|
44
|
+
export type ValidationRule = BetweenRule | ComparisonRule | ConflictRule | WhenRule | LogicalRule;
|
|
45
|
+
/**
|
|
46
|
+
* Between 规则
|
|
47
|
+
*/
|
|
48
|
+
export interface BetweenRule {
|
|
49
|
+
type: 'Between';
|
|
50
|
+
field: FieldAccess;
|
|
51
|
+
min: any;
|
|
52
|
+
max: any;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Comparison 规则
|
|
56
|
+
*/
|
|
57
|
+
export interface ComparisonRule {
|
|
58
|
+
type: 'Comparison';
|
|
59
|
+
operator: string;
|
|
60
|
+
left: FieldAccess | Expression;
|
|
61
|
+
right: any;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* ModComparison 规则(用于 startTime.minute mod 15 is 0 等)
|
|
65
|
+
*/
|
|
66
|
+
export interface ModComparisonRule {
|
|
67
|
+
type: 'ModComparison';
|
|
68
|
+
left: FieldAccess;
|
|
69
|
+
modValue: any;
|
|
70
|
+
operator: string;
|
|
71
|
+
right: any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In 规则(用于 dayOfWeek in [1,2,3,4,5] 等)
|
|
75
|
+
*/
|
|
76
|
+
export interface InRule {
|
|
77
|
+
type: 'In';
|
|
78
|
+
field: FieldAccess;
|
|
79
|
+
values: any[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Conflict 规则
|
|
83
|
+
*/
|
|
84
|
+
export interface ConflictRule {
|
|
85
|
+
type: 'NoConflict' | 'Conflict';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* When 规则
|
|
89
|
+
*/
|
|
90
|
+
export interface WhenRule {
|
|
91
|
+
type: 'When';
|
|
92
|
+
condition: Expression;
|
|
93
|
+
rules: ValidationRule[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 逻辑规则
|
|
97
|
+
*/
|
|
98
|
+
export interface LogicalRule {
|
|
99
|
+
type: 'BinaryExpression' | 'UnaryExpression';
|
|
100
|
+
operator: 'and' | 'or' | 'not';
|
|
101
|
+
left?: Expression;
|
|
102
|
+
right?: Expression;
|
|
103
|
+
argument?: Expression;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 字段访问
|
|
107
|
+
*/
|
|
108
|
+
export interface FieldAccess {
|
|
109
|
+
type: 'FieldAccess';
|
|
110
|
+
path: string[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 表达式类型
|
|
114
|
+
*/
|
|
115
|
+
export type Expression = FieldAccess | ComparisonRule | LogicalRule | InRule | ModComparisonRule | any;
|
|
116
|
+
/**
|
|
117
|
+
* 显示规则
|
|
118
|
+
*/
|
|
119
|
+
export interface DisplayRule {
|
|
120
|
+
name: 'color' | 'icon' | 'title' | 'description';
|
|
121
|
+
value: string | ConditionalValue | TemplateValue;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 条件值
|
|
125
|
+
*/
|
|
126
|
+
export interface ConditionalValue {
|
|
127
|
+
type: 'Conditional';
|
|
128
|
+
condition: Expression;
|
|
129
|
+
consequent: any;
|
|
130
|
+
alternate?: any;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 模板值
|
|
134
|
+
*/
|
|
135
|
+
export interface TemplateValue {
|
|
136
|
+
type: 'Template';
|
|
137
|
+
parts: Array<string | FieldAccess>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 行为规则
|
|
141
|
+
*/
|
|
142
|
+
export interface BehaviorRule {
|
|
143
|
+
name: 'draggable' | 'resizable' | 'editable' | 'deletable';
|
|
144
|
+
value: boolean | Expression;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 约束规则
|
|
148
|
+
*/
|
|
149
|
+
export interface ConstraintRule {
|
|
150
|
+
name: string;
|
|
151
|
+
value: any;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 重复事件定义
|
|
155
|
+
*/
|
|
156
|
+
export interface RecurringDefinition {
|
|
157
|
+
frequency: 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
158
|
+
interval: number;
|
|
159
|
+
endDate?: string;
|
|
160
|
+
count?: number;
|
|
161
|
+
daysOfWeek?: number[];
|
|
162
|
+
dayOfMonth?: number;
|
|
163
|
+
excludeDates?: string[];
|
|
164
|
+
timeZone?: string;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EventTypeAST } from './ast/types';
|
|
2
|
+
import { EventDSLDataModel } from '@calenderjs/event-model';
|
|
3
|
+
/**
|
|
4
|
+
* Event DSL 编译器
|
|
5
|
+
*
|
|
6
|
+
* 将 DSL AST 编译成 Data Model (Event 对象,包含规则和数据)
|
|
7
|
+
*/
|
|
8
|
+
export declare class EventDSLCompiler {
|
|
9
|
+
/**
|
|
10
|
+
* 从 DSL 文本编译成 Data Model(推荐方法)
|
|
11
|
+
*
|
|
12
|
+
* @param dslText - Event DSL 文本
|
|
13
|
+
* @returns 编译后的 Data Model
|
|
14
|
+
*/
|
|
15
|
+
compileDSL(dslText: string): EventDSLDataModel;
|
|
16
|
+
/**
|
|
17
|
+
* 从 AST 编译成 Data Model
|
|
18
|
+
*
|
|
19
|
+
* @param asts - Event DSL AST 数组
|
|
20
|
+
* @returns 编译后的 Data Model
|
|
21
|
+
*/
|
|
22
|
+
compileFromAST(asts: EventTypeAST[]): EventDSLDataModel;
|
|
23
|
+
/**
|
|
24
|
+
* 编译单个事件类型 AST 为 Data Model
|
|
25
|
+
*
|
|
26
|
+
* @param ast - Event DSL AST
|
|
27
|
+
* @returns 编译后的 Data Model (EventTypeDataModel)
|
|
28
|
+
*/
|
|
29
|
+
private compileType;
|
|
30
|
+
/**
|
|
31
|
+
* 生成验证器函数(基础字段验证)
|
|
32
|
+
*
|
|
33
|
+
* 注意:业务规则验证由 EventRuntime 处理
|
|
34
|
+
*/
|
|
35
|
+
private generateValidator;
|
|
36
|
+
/**
|
|
37
|
+
* 生成渲染器函数
|
|
38
|
+
*/
|
|
39
|
+
private generateRenderer;
|
|
40
|
+
/**
|
|
41
|
+
* 生成行为配置
|
|
42
|
+
*/
|
|
43
|
+
private generateBehavior;
|
|
44
|
+
/**
|
|
45
|
+
* 编译验证器列表
|
|
46
|
+
*/
|
|
47
|
+
private compileValidators;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAQR,iBAAiB,EACpB,MAAM,yBAAyB,CAAC;AAMjC;;;;GAIG;AACH,qBAAa,gBAAgB;IACzB;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAK9C;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,iBAAiB;IAOvD;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IA2CnB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAwBzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAwBxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2BxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAQ5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventTypeAST } from '../ast/types';
|
|
2
|
+
import { JSONSchema } from '@calenderjs/event-model';
|
|
3
|
+
/**
|
|
4
|
+
* JSON Schema 生成器选项
|
|
5
|
+
*/
|
|
6
|
+
export interface JSONSchemaGeneratorOptions {
|
|
7
|
+
/** 是否包含 $schema 字段 */
|
|
8
|
+
includeSchema?: boolean;
|
|
9
|
+
/** 是否包含 title 字段 */
|
|
10
|
+
includeTitle?: boolean;
|
|
11
|
+
/** 是否包含 description 字段 */
|
|
12
|
+
includeDescription?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 从 Event DSL AST 生成 JSON Schema
|
|
16
|
+
*
|
|
17
|
+
* @param ast - Event DSL AST
|
|
18
|
+
* @param options - 生成器选项
|
|
19
|
+
* @returns JSON Schema(用于验证 Event.extra 字段)
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateJSONSchema(ast: EventTypeAST, options?: JSONSchemaGeneratorOptions): JSONSchema;
|
|
22
|
+
//# sourceMappingURL=json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/generators/json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA8B,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,sBAAsB;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,YAAY,EACjB,OAAO,GAAE,0BAA+B,GACvC,UAAU,CAkDZ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EventTypeAST } from '../ast/types';
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript 生成器选项
|
|
4
|
+
*/
|
|
5
|
+
export interface TypeScriptGeneratorOptions {
|
|
6
|
+
/** 是否包含 JSDoc 注释 */
|
|
7
|
+
includeJSDoc?: boolean;
|
|
8
|
+
/** 是否导出类型 */
|
|
9
|
+
exportType?: boolean;
|
|
10
|
+
/** 类型名称前缀 */
|
|
11
|
+
typeNamePrefix?: string;
|
|
12
|
+
/** 类型名称后缀 */
|
|
13
|
+
typeNameSuffix?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 从 Event DSL AST 生成 TypeScript 类型定义
|
|
17
|
+
*
|
|
18
|
+
* @param ast - Event DSL AST
|
|
19
|
+
* @param options - 生成器选项
|
|
20
|
+
* @returns TypeScript 类型定义字符串
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateTypeScript(ast: EventTypeAST, options?: TypeScriptGeneratorOptions): string;
|
|
23
|
+
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/generators/typescript.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA8B,MAAM,cAAc,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACvC,oBAAoB;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAC9B,GAAG,EAAE,YAAY,EACjB,OAAO,GAAE,0BAA+B,GACzC,MAAM,CAkER"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Kf(f,p){function r(){this.constructor=f}r.prototype=p.prototype,f.prototype=new r}function U(f,p,r,v){var h=Error.call(this,f);return Object.setPrototypeOf&&Object.setPrototypeOf(h,U.prototype),h.expected=p,h.found=r,h.location=v,h.name="SyntaxError",h}Kf(U,Error);function Ee(f,p,r){return r=r||" ",f.length>p?f:(p-=f.length,r+=r.repeat(p),f+r.slice(0,p))}U.prototype.format=function(f){var p="Error: "+this.message;if(this.location){var r=null,v;for(v=0;v<f.length;v++)if(f[v].source===this.location.source){r=f[v].text.split(/\r\n|\n|\r/g);break}var h=this.location.start,d=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(h):h,x=this.location.source+":"+d.line+":"+d.column;if(r){var b=this.location.end,C=Ee("",d.line.toString().length," "),$=r[h.line-1],m=h.line===b.line?b.column:$.length+1,A=m-h.column||1;p+=`
|
|
2
|
+
--> `+x+`
|
|
3
|
+
`+C+` |
|
|
4
|
+
`+d.line+" | "+$+`
|
|
5
|
+
`+C+" | "+Ee("",h.column-1," ")+Ee("",A,"^")}else p+=`
|
|
6
|
+
at `+x}return p};U.buildMessage=function(f,p){var r={literal:function($){return'"'+h($.text)+'"'},class:function($){var m=$.parts.map(function(A){return Array.isArray(A)?d(A[0])+"-"+d(A[1]):d(A)});return"["+($.inverted?"^":"")+m.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function($){return $.description}};function v($){return $.charCodeAt(0).toString(16).toUpperCase()}function h($){return $.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(m){return"\\x0"+v(m)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(m){return"\\x"+v(m)})}function d($){return $.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(m){return"\\x0"+v(m)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(m){return"\\x"+v(m)})}function x($){return r[$.type]($)}function b($){var m=$.map(x),A,O;if(m.sort(),m.length>0){for(A=1,O=1;A<m.length;A++)m[A-1]!==m[A]&&(m[O]=m[A],O++);m.length=O}switch(m.length){case 1:return m[0];case 2:return m[0]+" or "+m[1];default:return m.slice(0,-1).join(", ")+", or "+m[m.length-1]}}function C($){return $?'"'+h($)+'"':"end of input"}return"Expected "+b(f)+" but "+C(p)+" found."};function Xf(f,p){p=p!==void 0?p:{};var r={},v=p.grammarSource,h={EventTypeDefinition:gs},d=gs,x="type:",b="name:",C="description:",$="fields:",m="-",A=":",O="string",q="number",J="boolean",De="email",Se="text",Fe="list of ",Te="enum(",Ls=")",D=",",Re="required",je="default:",Oe="min:",qe="max:",Le="validate:",H="display:",K="behavior:",X="constraints:",G="recurring:",Q="when",Pe="in",Y="[",ee="]",Ve="between",V="and",ze="no",re="conflict",se="with",ie="other",ae="events",fe="or",Ne="not",z="is",N="equals",B="is not",Z="not equals",Be=">",k=">=",Ze="<",I="<=",te="mod",ke="color",Ie="icon",Me="title",We="description",Ue="else:",_e="draggable",Je="resizable",He="editable",Ke="deletable",ne="true",le="false",Xe="timeZone",Ge="allowedTimeZones",Qe="timePrecision",Ye="minAdvanceTime",er="maxAdvanceTime",rr="allowCrossDay",sr="maxCrossDayDuration",ir="minDuration",ar="maxDuration",fr="allowedHours",tr="allowedDays",nr="to",lr="frequency:",or="interval:",cr="endDate:",ur="count:",pr="daysOfWeek:",gr="dayOfMonth:",vr="excludeDates:",$r="timeZone:",hr="daily",mr="weekly",dr="monthly",br="yearly",yr=".",Ar="minutes",xr="minute",Cr="hours",wr="hour",Er="days",Dr="day",Sr="weeks",Fr="week",oe='"',Ps="{",Vs="}",zs="#",Tr=/^[0-9]/,Rr=/^[^"]/,jr=/^[^{}]/,Ns=/^[a-zA-Z_]/,Or=/^[a-zA-Z0-9_]/,Bs=/^[<>]/,Zs=/^[ \t\n\r]/,qr=/^[^\n]/,Lr=u("type:",!1),Pr=u("name:",!1),Vr=u("description:",!1),zr=u("fields:",!1),ks=u("-",!1),M=u(":",!1),Is=u("string",!1),Ms=u("number",!1),Ws=u("boolean",!1),Us=u("email",!1),_s=u("text",!1),Js=u("list of ",!1),Hs=u("enum(",!1),Ks=u(")",!1),S=u(",",!1),Xs=u("required",!1),Gs=u("default:",!1),Qs=u("min:",!1),Ys=u("max:",!1),ei=u("validate:",!1),Nr=u("display:",!1),Br=u("behavior:",!1),Zr=u("constraints:",!1),kr=u("recurring:",!1),Ir=u("when",!1),ri=u("in",!1),ce=u("[",!1),ue=u("]",!1),si=u("between",!1),he=u("and",!1),ii=u("no",!1),Mr=u("conflict",!1),Wr=u("with",!1),Ur=u("other",!1),_r=u("events",!1),Jr=u("or",!1),ai=u("not",!1),me=u("is",!1),de=u("equals",!1),be=u("is not",!1),ye=u("not equals",!1),Hr=u(">",!1),Ae=u(">=",!1),Kr=u("<",!1),xe=u("<=",!1),Xr=u("mod",!1),fi=u("color",!1),ti=u("icon",!1),ni=u("title",!1),li=u("description",!1),oi=u("else:",!1),ci=u("draggable",!1),ui=u("resizable",!1),pi=u("editable",!1),gi=u("deletable",!1),Gr=u("true",!1),Qr=u("false",!1),vi=u("timeZone",!1),$i=u("allowedTimeZones",!1),hi=u("timePrecision",!1),mi=u("minAdvanceTime",!1),di=u("maxAdvanceTime",!1),bi=u("allowCrossDay",!1),yi=u("maxCrossDayDuration",!1),Ai=u("minDuration",!1),xi=u("maxDuration",!1),Ci=u("allowedHours",!1),wi=u("allowedDays",!1),Ei=u("to",!1),Di=u("frequency:",!1),Si=u("interval:",!1),Fi=u("endDate:",!1),Ti=u("count:",!1),Ri=u("daysOfWeek:",!1),ji=u("dayOfMonth:",!1),Oi=u("excludeDates:",!1),qi=u("timeZone:",!1),Li=u("daily",!1),Pi=u("weekly",!1),Vi=u("monthly",!1),zi=u("yearly",!1),Yr=u(".",!1),Ni=u("minutes",!1),Bi=u("minute",!1),Zi=u("hours",!1),ki=u("hour",!1),Ii=u("days",!1),Mi=u("day",!1),Wi=u("weeks",!1),Ui=u("week",!1),es=L([["0","9"]],!1,!1),pe=u('"',!1),rs=L(['"'],!0,!1),_i=u("{",!1),Ji=u("}",!1),ss=L(["{","}"],!0,!1),Hi=L([["a","z"],["A","Z"],"_"],!1,!1),is=L([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),Ki=L(["<",">"],!1,!1),Xi=L([" "," ",`
|
|
7
|
+
`,"\r"],!1,!1),Gi=u("#",!1),as=L([`
|
|
8
|
+
`],!0,!1),Qi=function(e){const i={};return e.forEach(a=>{i[a.name]=a.value}),i},Yi=function(e){return{name:"type",value:e}},ea=function(e){return{name:"name",value:e}},ra=function(e){return{name:"description",value:e}},sa=function(e){return{name:"fields",value:e}},ia=function(e,i,a){return{name:e,type:i,...Object.assign({},...a)}},aa=function(e){return{type:"list",itemType:e}},fa=function(e){return{type:"enum",values:e}},fs=function(e,i){return i},ta=function(e,i){return[e,...i]},na=function(){return{required:!0}},la=function(e){return{default:e}},oa=function(e){return{min:e}},ca=function(e){return{max:e}},ua=function(e){return{name:"validate",value:e}},pa=function(e){return e},ga=function(e,i){return{type:"When",condition:e,rules:i}},va=function(e,i){return{type:"In",field:e,values:i}},ts=function(e,i){return i},$a=function(e,i){return[e,...i]},ha=function(e,i,a){return{type:"Between",field:e,min:i,max:a}},ma=function(e,i,a){return{type:"Comparison",operator:i,left:e,right:a}},da=function(){return{type:"NoConflict"}},ba=function(){return{type:"Conflict"}},ns=function(e,i,a){return[i,a]},ya=function(e,i){return Hf(e,i)},Aa=function(e){return{type:"UnaryExpression",operator:"not",argument:e}},xa=function(e,i,a){return{type:"Comparison",operator:i,left:e,right:a}},Ca=function(e,i,a,t){return{type:"ModComparison",left:e,modValue:i,operator:a,right:t}},wa=function(e){return{name:"display",value:e}},Ea=function(e,i){return{name:e,value:i}},Da=function(e,i,a){return a},Sa=function(e,i,a){return{type:"Conditional",condition:e,consequent:i,alternate:a}},Fa=function(e){return{name:"behavior",value:e}},Ta=function(e,i){return{name:e,value:i}},Ra=function(){return!0},ja=function(){return!1},Oa=function(e){return{name:"constraints",value:e}},qa=function(e,i){return{name:e,value:i}},La=function(){return"timeZone"},Pa=function(){return"allowedTimeZones"},Va=function(){return"timePrecision"},za=function(){return"minAdvanceTime"},Na=function(){return"maxAdvanceTime"},Ba=function(){return"allowCrossDay"},Za=function(){return"maxCrossDayDuration"},ka=function(){return"minDuration"},Ia=function(){return"maxDuration"},Ma=function(){return"allowedHours"},Wa=function(){return"allowedDays"},Ua=function(e,i){return{type:"Range",min:e,max:i}},_a=function(e){return{name:"recurring",value:Object.assign({},...e)}},Ja=function(e){return{frequency:e}},Ha=function(e){return{interval:e}},Ka=function(e){return{endDate:e}},Xa=function(e){return{count:e}},Ga=function(e){return{daysOfWeek:e}},Qa=function(e){return{dayOfMonth:e}},Ya=function(e){return{excludeDates:e}},ef=function(e){return{timeZone:e}},rf=function(){return"daily"},sf=function(){return"weekly"},af=function(){return"monthly"},ff=function(){return"yearly"},ls=function(e,i){return i},tf=function(e,i){return[e,...i]},os=function(e,i){return i},nf=function(e,i){return[e,...i]},cs=function(e,i){return i},lf=function(e,i){return{type:"FieldAccess",path:[e,...i]}},of=function(e){return e},cf=function(e,i){return{type:"Duration",value:e,unit:i==="minute"?"minutes":i==="hour"?"hours":i==="day"?"days":i==="week"?"weeks":i}},uf=function(e){return parseInt(e.join(""),10)},pf=function(e){return e.join("")},gf=function(e){return{type:"Template",parts:e}},vf=function(e){return e},$f=function(e){return e.join("")},hf=function(){return!0},mf=function(){return!1},df=function(e,i){return e+i.join("")},s=p.peg$currPos|0,W=[{line:1,column:1}],F=s,ge=p.peg$maxFailExpected||[],n=p.peg$silentFails|0,_;if(p.startRule){if(!(p.startRule in h))throw new Error(`Can't start parsing from rule "`+p.startRule+'".');d=h[p.startRule]}function u(e,i){return{type:"literal",text:e,ignoreCase:i}}function L(e,i,a){return{type:"class",parts:e,inverted:i,ignoreCase:a}}function bf(){return{type:"end"}}function us(e){var i=W[e],a;if(i)return i;if(e>=W.length)a=W.length-1;else for(a=e;!W[--a];);for(i=W[a],i={line:i.line,column:i.column};a<e;)f.charCodeAt(a)===10?(i.line++,i.column=1):i.column++,a++;return W[e]=i,i}function ps(e,i,a){var t=us(e),o=us(i),g={source:v,start:{offset:e,line:t.line,column:t.column},end:{offset:i,line:o.line,column:o.column}};return g}function l(e){s<F||(s>F&&(F=s,ge=[]),ge.push(e))}function yf(e,i,a){return new U(U.buildMessage(e,i),e,i,a)}function gs(){var e,i,a;for(e=s,c(),i=[],a=vs();a!==r;)i.push(a),a=vs();return a=c(),e=Qi(i),e}function vs(){var e;return e=Af(),e===r&&(e=xf(),e===r&&(e=Cf(),e===r&&(e=wf(),e===r&&(e=Df(),e===r&&(e=Lf(),e===r&&(e=Vf(),e===r&&(e=Nf(),e===r&&(e=If())))))))),e}function Af(){var e,i,a;return e=s,f.substr(s,5)===x?(i=x,s+=5):(i=r,n===0&&l(Lr)),i!==r?(c(),a=T(),a!==r?(c(),e=Yi(a)):(s=e,e=r)):(s=e,e=r),e}function xf(){var e,i,a;return e=s,f.substr(s,5)===b?(i=b,s+=5):(i=r,n===0&&l(Pr)),i!==r?(c(),a=j(),a!==r?(c(),e=ea(a)):(s=e,e=r)):(s=e,e=r),e}function Cf(){var e,i,a;return e=s,f.substr(s,12)===C?(i=C,s+=12):(i=r,n===0&&l(Vr)),i!==r?(c(),a=j(),a!==r?(c(),e=ra(a)):(s=e,e=r)):(s=e,e=r),e}function wf(){var e,i,a,t;if(e=s,f.substr(s,7)===$?(i=$,s+=7):(i=r,n===0&&l(zr)),i!==r){if(c(),a=[],t=$s(),t!==r)for(;t!==r;)a.push(t),t=$s();else a=r;a!==r?e=sa(a):(s=e,e=r)}else s=e,e=r;return e}function $s(){var e,i,a,t,o,g,y;if(e=s,c(),f.charCodeAt(s)===45?(i=m,s++):(i=r,n===0&&l(ks)),i!==r)if(c(),a=T(),a!==r)if(f.charCodeAt(s)===58?(t=A,s++):(t=r,n===0&&l(M)),t!==r)if(c(),o=hs(),o!==r){for(g=[],y=ms();y!==r;)g.push(y),y=ms();y=c(),e=ia(a,o,g)}else s=e,e=r;else s=e,e=r;else s=e,e=r;else s=e,e=r;return e}function hs(){var e,i,a,t;return f.substr(s,6)===O?(e=O,s+=6):(e=r,n===0&&l(Is)),e===r&&(f.substr(s,6)===q?(e=q,s+=6):(e=r,n===0&&l(Ms)),e===r&&(f.substr(s,7)===J?(e=J,s+=7):(e=r,n===0&&l(Ws)),e===r&&(f.substr(s,5)===De?(e=De,s+=5):(e=r,n===0&&l(Us)),e===r&&(f.substr(s,4)===Se?(e=Se,s+=4):(e=r,n===0&&l(_s)),e===r&&(e=s,f.substr(s,8)===Fe?(i=Fe,s+=8):(i=r,n===0&&l(Js)),i!==r?(a=hs(),a!==r?e=aa(a):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,f.substr(s,5)===Te?(i=Te,s+=5):(i=r,n===0&&l(Hs)),i!==r?(a=Ef(),a!==r?(f.charCodeAt(s)===41?(t=Ls,s++):(t=r,n===0&&l(Ks)),t!==r?e=fa(a):(s=e,e=r)):(s=e,e=r)):(s=e,e=r))))))),e}function Ef(){var e,i,a,t,o,g;if(e=s,i=T(),i!==r){for(a=[],t=s,f.charCodeAt(s)===44?(o=D,s++):(o=r,n===0&&l(S)),o!==r?(c(),g=T(),g!==r?t=fs(i,g):(s=t,t=r)):(s=t,t=r);t!==r;)a.push(t),t=s,f.charCodeAt(s)===44?(o=D,s++):(o=r,n===0&&l(S)),o!==r?(c(),g=T(),g!==r?t=fs(i,g):(s=t,t=r)):(s=t,t=r);e=ta(i,a)}else s=e,e=r;return e}function ms(){var e,i,a,t;return e=s,f.charCodeAt(s)===44?(i=D,s++):(i=r,n===0&&l(S)),i!==r?(c(),f.substr(s,8)===Re?(a=Re,s+=8):(a=r,n===0&&l(Xs)),a!==r?e=na():(s=e,e=r)):(s=e,e=r),e===r&&(e=s,f.charCodeAt(s)===44?(i=D,s++):(i=r,n===0&&l(S)),i!==r?(c(),f.substr(s,8)===je?(a=je,s+=8):(a=r,n===0&&l(Gs)),a!==r?(c(),t=R(),t!==r?e=la(t):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,f.charCodeAt(s)===44?(i=D,s++):(i=r,n===0&&l(S)),i!==r?(c(),f.substr(s,4)===Oe?(a=Oe,s+=4):(a=r,n===0&&l(Qs)),a!==r?(c(),t=E(),t!==r?e=oa(t):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,f.charCodeAt(s)===44?(i=D,s++):(i=r,n===0&&l(S)),i!==r?(c(),f.substr(s,4)===qe?(a=qe,s+=4):(a=r,n===0&&l(Ys)),a!==r?(c(),t=E(),t!==r?e=ca(t):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)))),e}function Df(){var e,i,a,t;if(e=s,f.substr(s,9)===Le?(i=Le,s+=9):(i=r,n===0&&l(ei)),i!==r){for(c(),a=[],t=ve();t!==r;)a.push(t),t=ve();e=ua(a)}else s=e,e=r;return e}function ve(){var e,i,a;return e=s,c(),i=s,n++,f.substr(s,8)===H?(a=H,s+=8):(a=r,n===0&&l(Nr)),a===r&&(f.substr(s,9)===K?(a=K,s+=9):(a=r,n===0&&l(Br)),a===r&&(f.substr(s,12)===X?(a=X,s+=12):(a=r,n===0&&l(Zr)),a===r&&(f.substr(s,10)===G?(a=G,s+=10):(a=r,n===0&&l(kr)),a===r&&(f.substr(s,5)===x?(a=x,s+=5):(a=r,n===0&&l(Lr)),a===r&&(f.substr(s,5)===b?(a=b,s+=5):(a=r,n===0&&l(Pr)),a===r&&(f.substr(s,12)===C?(a=C,s+=12):(a=r,n===0&&l(Vr)),a===r&&(f.substr(s,7)===$?(a=$,s+=7):(a=r,n===0&&l(zr))))))))),n--,a===r?i=void 0:(s=i,i=r),i!==r?(a=Sf(),a===r&&(a=Ff()),a!==r?e=pa(a):(s=e,e=r)):(s=e,e=r),e}function Sf(){var e,i,a,t,o,g;if(e=s,f.substr(s,4)===Q?(i=Q,s+=4):(i=r,n===0&&l(Ir)),i!==r)if(c(),a=$e(),a!==r)if(f.charCodeAt(s)===58?(t=A,s++):(t=r,n===0&&l(M)),t!==r){if(c(),o=[],g=ve(),g!==r)for(;g!==r;)o.push(g),g=ve();else o=r;o!==r?e=ga(a,o):(s=e,e=r)}else s=e,e=r;else s=e,e=r;else s=e,e=r;return e}function Ff(){var e;return e=Tf(),e===r&&(e=Rf(),e===r&&(e=jf(),e===r&&(e=Of(),e===r&&(e=$e())))),e}function Tf(){var e,i,a,t,o,g;return e=s,i=P(),i!==r?(c(),f.substr(s,2)===Pe?(a=Pe,s+=2):(a=r,n===0&&l(ri)),a!==r?(c(),f.charCodeAt(s)===91?(t=Y,s++):(t=r,n===0&&l(ce)),t!==r?(c(),o=ds(),o!==r?(c(),f.charCodeAt(s)===93?(g=ee,s++):(g=r,n===0&&l(ue)),g!==r?(c(),e=va(i,o)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function ds(){var e,i,a,t,o,g;if(e=s,i=R(),i!==r){for(a=[],t=s,c(),f.charCodeAt(s)===44?(o=D,s++):(o=r,n===0&&l(S)),o!==r?(c(),g=R(),g!==r?t=ts(i,g):(s=t,t=r)):(s=t,t=r);t!==r;)a.push(t),t=s,c(),f.charCodeAt(s)===44?(o=D,s++):(o=r,n===0&&l(S)),o!==r?(c(),g=R(),g!==r?t=ts(i,g):(s=t,t=r)):(s=t,t=r);e=$a(i,a)}else s=e,e=r;return e}function Rf(){var e,i,a,t,o,g;return e=s,i=P(),i!==r?(c(),f.substr(s,7)===Ve?(a=Ve,s+=7):(a=r,n===0&&l(si)),a!==r?(c(),t=R(),t!==r?(c(),f.substr(s,3)===V?(o=V,s+=3):(o=r,n===0&&l(he)),o!==r?(c(),g=R(),g!==r?(c(),e=ha(i,t,g)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function jf(){var e,i,a,t;return e=s,i=P(),i!==r?(c(),a=Jf(),a!==r?(c(),t=R(),t!==r?(c(),e=ma(i,a,t)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function Of(){var e,i,a,t,o,g;return e=s,f.substr(s,2)===ze?(i=ze,s+=2):(i=r,n===0&&l(ii)),i!==r?(c(),f.substr(s,8)===re?(a=re,s+=8):(a=r,n===0&&l(Mr)),a!==r?(c(),f.substr(s,4)===se?(t=se,s+=4):(t=r,n===0&&l(Wr)),t!==r?(c(),f.substr(s,5)===ie?(o=ie,s+=5):(o=r,n===0&&l(Ur)),o!==r?(c(),f.substr(s,6)===ae?(g=ae,s+=6):(g=r,n===0&&l(_r)),g!==r?(c(),e=da()):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,f.substr(s,8)===re?(i=re,s+=8):(i=r,n===0&&l(Mr)),i!==r?(c(),f.substr(s,4)===se?(a=se,s+=4):(a=r,n===0&&l(Wr)),a!==r?(c(),f.substr(s,5)===ie?(t=ie,s+=5):(t=r,n===0&&l(Ur)),t!==r?(c(),f.substr(s,6)===ae?(o=ae,s+=6):(o=r,n===0&&l(_r)),o!==r?(c(),e=ba()):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)),e}function $e(){var e,i,a,t,o,g;if(e=s,i=Ce(),i!==r){for(a=[],t=s,c(),f.substr(s,3)===V?(o=V,s+=3):(o=r,n===0&&l(he)),o===r&&(f.substr(s,2)===fe?(o=fe,s+=2):(o=r,n===0&&l(Jr))),o!==r?(c(),g=Ce(),g!==r?t=ns(i,o,g):(s=t,t=r)):(s=t,t=r);t!==r;)a.push(t),t=s,c(),f.substr(s,3)===V?(o=V,s+=3):(o=r,n===0&&l(he)),o===r&&(f.substr(s,2)===fe?(o=fe,s+=2):(o=r,n===0&&l(Jr))),o!==r?(c(),g=Ce(),g!==r?t=ns(i,o,g):(s=t,t=r)):(s=t,t=r);e=ya(i,a)}else s=e,e=r;return e}function Ce(){var e,i,a;return e=s,f.substr(s,3)===Ne?(i=Ne,s+=3):(i=r,n===0&&l(ai)),i!==r?(c(),a=bs(),a!==r?e=Aa(a):(s=e,e=r)):(s=e,e=r),e===r&&(e=bs()),e}function bs(){var e,i,a,t,o;return e=qf(),e===r&&(e=s,i=P(),i!==r?(a=c(),f.substr(s,2)===z?(t=z,s+=2):(t=r,n===0&&l(me)),t===r&&(f.substr(s,6)===N?(t=N,s+=6):(t=r,n===0&&l(de)),t===r&&(f.substr(s,6)===B?(t=B,s+=6):(t=r,n===0&&l(be)),t===r&&(f.substr(s,10)===Z?(t=Z,s+=10):(t=r,n===0&&l(ye)),t===r&&(f.charCodeAt(s)===62?(t=Be,s++):(t=r,n===0&&l(Hr)),t===r&&(f.substr(s,2)===k?(t=k,s+=2):(t=r,n===0&&l(Ae)),t===r&&(f.charCodeAt(s)===60?(t=Ze,s++):(t=r,n===0&&l(Kr)),t===r&&(f.substr(s,2)===I?(t=I,s+=2):(t=r,n===0&&l(xe))))))))),t!==r?(c(),o=R(),o!==r?(c(),e=xa(i,t,o)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,i=P(),i!==r?(a=c(),i=[i,a],e=i):(s=e,e=r))),e}function qf(){var e,i,a,t,o,g;return e=s,i=P(),i!==r?(c(),f.substr(s,3)===te?(a=te,s+=3):(a=r,n===0&&l(Xr)),a!==r?(c(),t=R(),t!==r?(c(),f.substr(s,2)===z?(o=z,s+=2):(o=r,n===0&&l(me)),o===r&&(f.substr(s,6)===N?(o=N,s+=6):(o=r,n===0&&l(de)),o===r&&(f.substr(s,6)===B?(o=B,s+=6):(o=r,n===0&&l(be)),o===r&&(f.substr(s,10)===Z?(o=Z,s+=10):(o=r,n===0&&l(ye)),o===r&&(f.charCodeAt(s)===62?(o=Be,s++):(o=r,n===0&&l(Hr)),o===r&&(f.substr(s,2)===k?(o=k,s+=2):(o=r,n===0&&l(Ae)),o===r&&(f.charCodeAt(s)===60?(o=Ze,s++):(o=r,n===0&&l(Kr)),o===r&&(f.substr(s,2)===I?(o=I,s+=2):(o=r,n===0&&l(xe))))))))),o!==r?(c(),g=R(),g!==r?(c(),e=Ca(i,t,o,g)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function Lf(){var e,i,a,t;if(e=s,f.substr(s,8)===H?(i=H,s+=8):(i=r,n===0&&l(Nr)),i!==r){if(c(),a=[],t=ys(),t!==r)for(;t!==r;)a.push(t),t=ys();else a=r;a!==r?e=wa(a):(s=e,e=r)}else s=e,e=r;return e}function ys(){var e,i,a,t;return e=s,c(),f.substr(s,5)===ke?(i=ke,s+=5):(i=r,n===0&&l(fi)),i===r&&(f.substr(s,4)===Ie?(i=Ie,s+=4):(i=r,n===0&&l(ti)),i===r&&(f.substr(s,5)===Me?(i=Me,s+=5):(i=r,n===0&&l(ni)),i===r&&(f.substr(s,11)===We?(i=We,s+=11):(i=r,n===0&&l(li))))),i!==r?(f.charCodeAt(s)===58?(a=A,s++):(a=r,n===0&&l(M)),a!==r?(c(),t=we(),t!==r?(c(),e=Ea(i,t)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function we(){var e;return e=Pf(),e===r&&(e=_f(),e===r&&(e=j())),e}function Pf(){var e,i,a,t,o,g,y,w;return e=s,f.substr(s,4)===Q?(i=Q,s+=4):(i=r,n===0&&l(Ir)),i!==r?(c(),a=$e(),a!==r?(f.charCodeAt(s)===58?(t=A,s++):(t=r,n===0&&l(M)),t!==r?(c(),o=we(),o!==r?(g=s,c(),f.substr(s,5)===Ue?(y=Ue,s+=5):(y=r,n===0&&l(oi)),y!==r?(c(),w=we(),w!==r?g=Da(a,o,w):(s=g,g=r)):(s=g,g=r),g===r&&(g=null),e=Sa(a,o,g)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function Vf(){var e,i,a,t;if(e=s,f.substr(s,9)===K?(i=K,s+=9):(i=r,n===0&&l(Br)),i!==r){if(c(),a=[],t=As(),t!==r)for(;t!==r;)a.push(t),t=As();else a=r;a!==r?e=Fa(a):(s=e,e=r)}else s=e,e=r;return e}function As(){var e,i,a,t;return e=s,c(),f.substr(s,9)===_e?(i=_e,s+=9):(i=r,n===0&&l(ci)),i===r&&(f.substr(s,9)===Je?(i=Je,s+=9):(i=r,n===0&&l(ui)),i===r&&(f.substr(s,8)===He?(i=He,s+=8):(i=r,n===0&&l(pi)),i===r&&(f.substr(s,9)===Ke?(i=Ke,s+=9):(i=r,n===0&&l(gi))))),i!==r?(f.charCodeAt(s)===58?(a=A,s++):(a=r,n===0&&l(M)),a!==r?(c(),t=zf(),t!==r?(c(),e=Ta(i,t)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function zf(){var e,i;return e=s,f.substr(s,4)===ne?(i=ne,s+=4):(i=r,n===0&&l(Gr)),i!==r&&(i=Ra()),e=i,e===r&&(e=s,f.substr(s,5)===le?(i=le,s+=5):(i=r,n===0&&l(Qr)),i!==r&&(i=ja()),e=i,e===r&&(e=$e())),e}function Nf(){var e,i,a,t;if(e=s,f.substr(s,12)===X?(i=X,s+=12):(i=r,n===0&&l(Zr)),i!==r){if(c(),a=[],t=xs(),t!==r)for(;t!==r;)a.push(t),t=xs();else a=r;a!==r?e=Oa(a):(s=e,e=r)}else s=e,e=r;return e}function xs(){var e,i,a,t;return e=s,c(),i=Bf(),i!==r?(f.charCodeAt(s)===58?(a=A,s++):(a=r,n===0&&l(M)),a!==r?(c(),t=Zf(),t!==r?(c(),e=qa(i,t)):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function Bf(){var e,i;return e=s,f.substr(s,8)===Xe?(i=Xe,s+=8):(i=r,n===0&&l(vi)),i!==r&&(i=La()),e=i,e===r&&(e=s,f.substr(s,16)===Ge?(i=Ge,s+=16):(i=r,n===0&&l($i)),i!==r&&(i=Pa()),e=i,e===r&&(e=s,f.substr(s,13)===Qe?(i=Qe,s+=13):(i=r,n===0&&l(hi)),i!==r&&(i=Va()),e=i,e===r&&(e=s,f.substr(s,14)===Ye?(i=Ye,s+=14):(i=r,n===0&&l(mi)),i!==r&&(i=za()),e=i,e===r&&(e=s,f.substr(s,14)===er?(i=er,s+=14):(i=r,n===0&&l(di)),i!==r&&(i=Na()),e=i,e===r&&(e=s,f.substr(s,13)===rr?(i=rr,s+=13):(i=r,n===0&&l(bi)),i!==r&&(i=Ba()),e=i,e===r&&(e=s,f.substr(s,19)===sr?(i=sr,s+=19):(i=r,n===0&&l(yi)),i!==r&&(i=Za()),e=i,e===r&&(e=s,f.substr(s,11)===ir?(i=ir,s+=11):(i=r,n===0&&l(Ai)),i!==r&&(i=ka()),e=i,e===r&&(e=s,f.substr(s,11)===ar?(i=ar,s+=11):(i=r,n===0&&l(xi)),i!==r&&(i=Ia()),e=i,e===r&&(e=s,f.substr(s,12)===fr?(i=fr,s+=12):(i=r,n===0&&l(Ci)),i!==r&&(i=Ma()),e=i,e===r&&(e=s,f.substr(s,11)===tr?(i=tr,s+=11):(i=r,n===0&&l(wi)),i!==r&&(i=Wa()),e=i,e===r&&(e=T()))))))))))),e}function Zf(){var e;return e=ws(),e===r&&(e=kf(),e===r&&(e=Es(),e===r&&(e=j(),e===r&&(e=E(),e===r&&(e=Ss(),e===r&&(e=T())))))),e}function kf(){var e,i,a,t;return e=s,i=E(),i!==r?(c(),f.substr(s,2)===nr?(a=nr,s+=2):(a=r,n===0&&l(Ei)),a!==r?(c(),t=E(),t!==r?e=Ua(i,t):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function If(){var e,i,a,t;if(e=s,f.substr(s,10)===G?(i=G,s+=10):(i=r,n===0&&l(kr)),i!==r){if(c(),a=[],t=Cs(),t!==r)for(;t!==r;)a.push(t),t=Cs();else a=r;a!==r?e=_a(a):(s=e,e=r)}else s=e,e=r;return e}function Cs(){var e,i,a;return e=s,c(),f.substr(s,10)===lr?(i=lr,s+=10):(i=r,n===0&&l(Di)),i!==r?(c(),a=Mf(),a!==r?(c(),e=Ja(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,9)===or?(i=or,s+=9):(i=r,n===0&&l(Si)),i!==r?(c(),a=E(),a!==r?(c(),e=Ha(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,8)===cr?(i=cr,s+=8):(i=r,n===0&&l(Fi)),i!==r?(c(),a=j(),a!==r?(c(),e=Ka(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,6)===ur?(i=ur,s+=6):(i=r,n===0&&l(Ti)),i!==r?(c(),a=E(),a!==r?(c(),e=Xa(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,11)===pr?(i=pr,s+=11):(i=r,n===0&&l(Ri)),i!==r?(c(),a=Wf(),a!==r?(c(),e=Ga(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,11)===gr?(i=gr,s+=11):(i=r,n===0&&l(ji)),i!==r?(c(),a=E(),a!==r?(c(),e=Qa(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,13)===vr?(i=vr,s+=13):(i=r,n===0&&l(Oi)),i!==r?(c(),a=Uf(),a!==r?(c(),e=Ya(a)):(s=e,e=r)):(s=e,e=r),e===r&&(e=s,c(),f.substr(s,9)===$r?(i=$r,s+=9):(i=r,n===0&&l(qi)),i!==r?(c(),a=j(),a!==r?(c(),e=ef(a)):(s=e,e=r)):(s=e,e=r)))))))),e}function Mf(){var e,i;return e=s,f.substr(s,5)===hr?(i=hr,s+=5):(i=r,n===0&&l(Li)),i!==r&&(i=rf()),e=i,e===r&&(e=s,f.substr(s,6)===mr?(i=mr,s+=6):(i=r,n===0&&l(Pi)),i!==r&&(i=sf()),e=i,e===r&&(e=s,f.substr(s,7)===dr?(i=dr,s+=7):(i=r,n===0&&l(Vi)),i!==r&&(i=af()),e=i,e===r&&(e=s,f.substr(s,6)===br?(i=br,s+=6):(i=r,n===0&&l(zi)),i!==r&&(i=ff()),e=i))),e}function Wf(){var e,i,a,t,o,g,y,w;if(e=s,f.charCodeAt(s)===91?(i=Y,s++):(i=r,n===0&&l(ce)),i!==r)if(c(),a=E(),a!==r){for(t=[],o=s,g=c(),f.charCodeAt(s)===44?(y=D,s++):(y=r,n===0&&l(S)),y!==r?(c(),w=E(),w!==r?o=ls(a,w):(s=o,o=r)):(s=o,o=r);o!==r;)t.push(o),o=s,g=c(),f.charCodeAt(s)===44?(y=D,s++):(y=r,n===0&&l(S)),y!==r?(c(),w=E(),w!==r?o=ls(a,w):(s=o,o=r)):(s=o,o=r);o=c(),f.charCodeAt(s)===93?(g=ee,s++):(g=r,n===0&&l(ue)),g!==r?e=tf(a,t):(s=e,e=r)}else s=e,e=r;else s=e,e=r;return e}function Uf(){var e,i,a,t,o,g,y,w;if(e=s,f.charCodeAt(s)===91?(i=Y,s++):(i=r,n===0&&l(ce)),i!==r)if(c(),a=j(),a!==r){for(t=[],o=s,g=c(),f.charCodeAt(s)===44?(y=D,s++):(y=r,n===0&&l(S)),y!==r?(c(),w=j(),w!==r?o=os(a,w):(s=o,o=r)):(s=o,o=r);o!==r;)t.push(o),o=s,g=c(),f.charCodeAt(s)===44?(y=D,s++):(y=r,n===0&&l(S)),y!==r?(c(),w=j(),w!==r?o=os(a,w):(s=o,o=r)):(s=o,o=r);o=c(),f.charCodeAt(s)===93?(g=ee,s++):(g=r,n===0&&l(ue)),g!==r?e=nf(a,t):(s=e,e=r)}else s=e,e=r;else s=e,e=r;return e}function P(){var e,i,a,t,o,g;if(e=s,i=T(),i!==r){for(a=[],t=s,f.charCodeAt(s)===46?(o=yr,s++):(o=r,n===0&&l(Yr)),o!==r?(g=T(),g!==r?t=cs(i,g):(s=t,t=r)):(s=t,t=r);t!==r;)a.push(t),t=s,f.charCodeAt(s)===46?(o=yr,s++):(o=r,n===0&&l(Yr)),o!==r?(g=T(),g!==r?t=cs(i,g):(s=t,t=r)):(s=t,t=r);e=lf(i,a)}else s=e,e=r;return e}function R(){var e;return e=ws(),e===r&&(e=Es(),e===r&&(e=E(),e===r&&(e=j(),e===r&&(e=Ss(),e===r&&(e=T()))))),e}function ws(){var e,i,a,t;return e=s,f.charCodeAt(s)===91?(i=Y,s++):(i=r,n===0&&l(ce)),i!==r?(c(),a=ds(),a!==r?(c(),f.charCodeAt(s)===93?(t=ee,s++):(t=r,n===0&&l(ue)),t!==r?e=of(a):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e}function Es(){var e,i,a;return e=s,i=E(),i!==r?(c(),f.substr(s,7)===Ar?(a=Ar,s+=7):(a=r,n===0&&l(Ni)),a===r&&(f.substr(s,6)===xr?(a=xr,s+=6):(a=r,n===0&&l(Bi)),a===r&&(f.substr(s,5)===Cr?(a=Cr,s+=5):(a=r,n===0&&l(Zi)),a===r&&(f.substr(s,4)===wr?(a=wr,s+=4):(a=r,n===0&&l(ki)),a===r&&(f.substr(s,4)===Er?(a=Er,s+=4):(a=r,n===0&&l(Ii)),a===r&&(f.substr(s,3)===Dr?(a=Dr,s+=3):(a=r,n===0&&l(Mi)),a===r&&(f.substr(s,5)===Sr?(a=Sr,s+=5):(a=r,n===0&&l(Wi)),a===r&&(f.substr(s,4)===Fr?(a=Fr,s+=4):(a=r,n===0&&l(Ui))))))))),a!==r?e=cf(i,a):(s=e,e=r)):(s=e,e=r),e}function E(){var e,i,a;if(e=s,i=[],a=f.charAt(s),Tr.test(a)?s++:(a=r,n===0&&l(es)),a!==r)for(;a!==r;)i.push(a),a=f.charAt(s),Tr.test(a)?s++:(a=r,n===0&&l(es));else i=r;return i!==r&&(i=uf(i)),e=i,e}function j(){var e,i,a,t;if(e=s,f.charCodeAt(s)===34?(i=oe,s++):(i=r,n===0&&l(pe)),i!==r){for(a=[],t=f.charAt(s),Rr.test(t)?s++:(t=r,n===0&&l(rs));t!==r;)a.push(t),t=f.charAt(s),Rr.test(t)?s++:(t=r,n===0&&l(rs));f.charCodeAt(s)===34?(t=oe,s++):(t=r,n===0&&l(pe)),t!==r?e=pf(a):(s=e,e=r)}else s=e,e=r;return e}function _f(){var e,i,a,t;if(e=s,f.charCodeAt(s)===34?(i=oe,s++):(i=r,n===0&&l(pe)),i!==r){if(a=[],t=Ds(),t!==r)for(;t!==r;)a.push(t),t=Ds();else a=r;a!==r?(f.charCodeAt(s)===34?(t=oe,s++):(t=r,n===0&&l(pe)),t!==r?e=gf(a):(s=e,e=r)):(s=e,e=r)}else s=e,e=r;return e}function Ds(){var e,i,a,t;if(e=s,f.charCodeAt(s)===123?(i=Ps,s++):(i=r,n===0&&l(_i)),i!==r?(a=P(),a!==r?(f.charCodeAt(s)===125?(t=Vs,s++):(t=r,n===0&&l(Ji)),t!==r?e=vf(a):(s=e,e=r)):(s=e,e=r)):(s=e,e=r),e===r){if(e=s,i=[],a=f.charAt(s),jr.test(a)?s++:(a=r,n===0&&l(ss)),a!==r)for(;a!==r;)i.push(a),a=f.charAt(s),jr.test(a)?s++:(a=r,n===0&&l(ss));else i=r;i!==r&&(i=$f(i)),e=i}return e}function Ss(){var e,i;return e=s,f.substr(s,4)===ne?(i=ne,s+=4):(i=r,n===0&&l(Gr)),i!==r&&(i=hf()),e=i,e===r&&(e=s,f.substr(s,5)===le?(i=le,s+=5):(i=r,n===0&&l(Qr)),i!==r&&(i=mf()),e=i),e}function T(){var e,i,a,t;if(e=s,i=f.charAt(s),Ns.test(i)?s++:(i=r,n===0&&l(Hi)),i!==r){for(a=[],t=f.charAt(s),Or.test(t)?s++:(t=r,n===0&&l(is));t!==r;)a.push(t),t=f.charAt(s),Or.test(t)?s++:(t=r,n===0&&l(is));e=df(i,a)}else s=e,e=r;return e}function Jf(){var e;return f.substr(s,2)===k?(e=k,s+=2):(e=r,n===0&&l(Ae)),e===r&&(f.substr(s,2)===I?(e=I,s+=2):(e=r,n===0&&l(xe)),e===r&&(e=f.charAt(s),Bs.test(e)?s++:(e=r,n===0&&l(Ki)),e===r&&(f.substr(s,2)===z?(e=z,s+=2):(e=r,n===0&&l(me)),e===r&&(f.substr(s,6)===N?(e=N,s+=6):(e=r,n===0&&l(de)),e===r&&(f.substr(s,6)===B?(e=B,s+=6):(e=r,n===0&&l(be)),e===r&&(f.substr(s,10)===Z?(e=Z,s+=10):(e=r,n===0&&l(ye)),e===r&&(f.substr(s,3)===te?(e=te,s+=3):(e=r,n===0&&l(Xr))))))))),e}function c(){var e,i;for(e=[],i=Fs(),i===r&&(i=Ts());i!==r;)e.push(i),i=Fs(),i===r&&(i=Ts());return e}function Fs(){var e;return e=f.charAt(s),Zs.test(e)?s++:(e=r,n===0&&l(Xi)),e}function Ts(){var e,i,a,t;if(e=s,f.charCodeAt(s)===35?(i=zs,s++):(i=r,n===0&&l(Gi)),i!==r){for(a=[],t=f.charAt(s),qr.test(t)?s++:(t=r,n===0&&l(as));t!==r;)a.push(t),t=f.charAt(s),qr.test(t)?s++:(t=r,n===0&&l(as));i=[i,a],e=i}else s=e,e=r;return e}function Hf(e,i){return i.reduce((a,[t,o])=>({type:"BinaryExpression",operator:t,left:a,right:o}),e)}if(_=d(),p.peg$library)return{peg$result:_,peg$currPos:s,peg$FAILED:r,peg$maxFailExpected:ge,peg$maxFailPos:F};if(_!==r&&s===f.length)return _;throw _!==r&&s<f.length&&l(bf()),yf(ge,F<f.length?f.charAt(F):null,F<f.length?ps(F,F+1):ps(F,F))}function Rs(f){try{const p=Xf(f);return Gf(p)}catch(p){throw new Error(`Failed to parse Event DSL: ${p.message}`)}}function Gf(f){const p=(f.validate||[]).map(v=>Array.isArray(v)&&v.length===2&&Array.isArray(v[0])?v[1]:v),r=(f.behavior||[]).map(v=>{if(v&&typeof v=="object"&&"value"in v){const h=v.value;if(Array.isArray(h)&&h.length===2){const d=h[0],x=h[1];if(d?.type==="FieldAccess"&&Array.isArray(d.path)&&d.path.length===1){const b=d.path[0];if(b==="true"&&(!x||x.length===0))return{...v,value:!0};if(b==="false"&&(!x||x.length===0))return{...v,value:!1}}}}return v});return{type:f.type||"",name:f.name||"",description:f.description,fields:f.fields||[],validate:p,display:f.display||[],behavior:r,constraints:f.constraints||[],recurring:f.recurring}}function js(f,p={}){const{includeSchema:r=!0,includeTitle:v=!0,includeDescription:h=!0}=p,d={type:"object"};r&&(d.$schema="http://json-schema.org/draft-07/schema#"),v&&f.name&&(d.title=f.name),h&&f.description&&(d.description=f.description);const x={},b=[];return f.fields.forEach(C=>{const $=Qf(C);x[C.name]=$,C.required&&b.push(C.name)}),d.properties=x,b.length>0&&(d.required=b),d.additionalProperties=!1,d}function Qf(f){const p={},r=Os(f.type);return Object.assign(p,r),f.default!==void 0&&(p.default=f.default),f.min!==void 0&&(p.type==="array"?p.minItems=f.min:p.type==="number"?p.minimum=f.min:p.type==="string"&&(p.minLength=f.min)),f.max!==void 0&&(p.type==="array"?p.maxItems=f.max:p.type==="number"?p.maximum=f.max:p.type==="string"&&(p.maxLength=f.max)),p}function Os(f){return f==="string"?{type:"string"}:f==="number"?{type:"number"}:f==="boolean"?{type:"boolean"}:f==="email"?{type:"string",format:"email"}:f==="text"?{type:"string"}:typeof f=="object"&&f.type==="list"?{type:"array",items:Os(f.itemType)}:typeof f=="object"&&f.type==="enum"?{type:"string",enum:f.values}:{type:"string"}}class Yf{compileDSL(p){const r=Rs(p);return this.compileFromAST([r])}compileFromAST(p){return{types:p.map(r=>this.compileType(r)),validators:[]}}compileType(p){const r=js(p),v=p.validate||[],h=p.display||[],d=p.behavior||[],x=p.constraints||[],b=p.recurring,C=this.generateValidator(p),$=this.generateRenderer(p),m=this.generateBehavior(p);return{id:p.type,name:p.name,extraSchema:r,validationRules:v,displayRules:h,behaviorRules:d,constraints:x,recurring:b,validator:C,renderer:$,behavior:m}}generateValidator(p){return r=>{const v=[];return p.fields.forEach(h=>{const d=r.extra?.[h.name];h.required&&(d==null||d==="")&&v.push(`${h.name} 是必填字段`)}),{valid:v.length===0,errors:v.length>0?v:void 0}}}generateRenderer(p){return r=>{const v={title:r.title||p.name,color:r.color||"#4285f4",description:""};return(p.display||[]).forEach(h=>{h.name==="color"&&typeof h.value=="string"&&(v.color=h.value),h.name==="icon"&&typeof h.value=="string"&&(v.icon=h.value)}),v}}generateBehavior(p){const r={draggable:!0,resizable:!1,editable:!0,deletable:!0};return(p.behavior||[]).forEach(v=>{v.name==="draggable"&&typeof v.value=="boolean"&&(r.draggable=v.value),v.name==="resizable"&&typeof v.value=="boolean"&&(r.resizable=v.value),v.name==="editable"&&typeof v.value=="boolean"&&(r.editable=v.value),v.name==="deletable"&&typeof v.value=="boolean"&&(r.deletable=v.value)}),r}compileValidators(p){return p.map(r=>({name:r.name,validate:r.validate}))}}function et(f,p={}){const{includeJSDoc:r=!0,exportType:v=!0,typeNamePrefix:h="",typeNameSuffix:d="Extra"}=p,x=`${h}${st(f.type)}${d}`,b=[];r&&(b.push("/**"),f.name&&b.push(` * ${f.name}`),f.description&&b.push(` * ${f.description}`),b.push(" *"),b.push(" * 从 Event DSL 自动生成"),b.push(" */"));const C=v?"export ":"";return b.push(`${C}interface ${x} {`),f.fields.forEach($=>{const m=rt($),A=$.required?"":"?",O=$.name;if(r){const q=[];$.default!==void 0&&q.push(`@default ${JSON.stringify($.default)}`),$.min!==void 0&&q.push(`@min ${$.min}`),$.max!==void 0&&q.push(`@max ${$.max}`),q.length>0&&(b.push(" /**"),q.forEach(J=>{b.push(` * ${J}`)}),b.push(" */"))}b.push(` ${O}${A}: ${m};`)}),b.push("}"),b.join(`
|
|
9
|
+
`)}function rt(f){return qs(f.type)}function qs(f){if(typeof f=="string")switch(f){case"string":case"text":return"string";case"number":return"number";case"boolean":return"boolean";case"email":return"string";default:return"string"}if(typeof f=="object"){if(f.type==="list")return`${qs(f.itemType)}[]`;if(f.type==="enum")return f.values.map(r=>`'${r}'`).join(" | ")}return"unknown"}function st(f){return f.split(/[-_\s]/).map(p=>p.charAt(0).toUpperCase()+p.slice(1).toLowerCase()).join("")}exports.EventDSLCompiler=Yf;exports.generateJSONSchema=js;exports.generateTypeScript=et;exports.parseEventDSL=Rs;
|
|
10
|
+
//# sourceMappingURL=index.cjs.map
|