-
Notifications
You must be signed in to change notification settings - Fork 302
/
index.d.ts
154 lines (136 loc) · 3.34 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
declare module '@opentiny/tiny-engine-dsl-vue' {
export function generateCode(param: { pageInfo: any; componentsMap?: Array<any>; blocksData?: Array<any> }): {
[key: string]: any
}
export type defaultPlugins =
| 'template'
| 'block'
| 'page'
| 'dataSource'
| 'dependencies'
| 'globalState'
| 'i18n'
| 'router'
| 'utils'
| 'formatCode'
| 'parseSchema'
export type IPluginFun = (schema: IAppSchema, context: IContext) => void
export interface IConfig {
customPlugins?: {
[key in defaultPlugins]?: IPluginFun
} & {
[key in 'transformStart' | 'transform' | 'transformEnd']?: Array<IPluginFun>
}
pluginConfig?: {
[k in defaultPlugins]: Record<string, any>
}
customContext?: Record<string, any>
}
export interface IContext {
config: Record<string, any>
genResult: Array<IFile>
genLogs: Array<any>
error: Array<any>
}
export function generateApp(config?: IConfig): codeGenInstance
export interface codeGenInstance {
generate(schema: IAppSchema): ICodeGenResult
}
export interface ICodeGenResult {
errors: Array<any>
genResult: Array<IFile>
genLogs: Array<any>
}
export interface IFile {
fileType: string
fileName: string
path: string
fileContent: string
}
export interface IAppSchema {
i18n: {
en_US: Record<string, any>
zh_CN: Record<string, any>
}
utils: Array<IUtilsItem>
dataSource: IDataSource
globalState: Array<IGlobalStateItem>
pageSchema: Array<IPageSchema | IFolderItem>
blockSchema: Array<IPageSchema>
componentsMap: Array<IComponentMapItem>
meta: IMetaInfo
}
export interface IUtilsItem {
name: string
type: 'npm' | 'function'
content: object
}
export interface IDataSource {
list: Array<{ id: number; name: string; data: object }>
dataHandler?: IFuncType
errorHandler?: IFuncType
willFetch?: IFuncType
}
export interface IFuncType {
type: 'JSFunction'
value: string
}
export interface IExpressionType {
type: 'JSExpression'
value: string
}
export interface IGlobalStateItem {
id: string
state: Record<string, any>
actions: Record<string, IFuncType>
getters: Record<string, IFuncType>
}
export interface IPageSchema {
componentName: 'Page' | 'Block'
css: string
fileName: string
lifeCycles: {
[key: string]: Record<string, IFuncType>
}
methods: Record<string, IFuncType>
props: Record<string, any>
state: Array<Record<string, any>>
meta: {
id: number
isHome: boolean
parentId: string
rootElement: string
route: string
}
children: Array<ISchemaChildrenItem>
schema?: {
properties: Array<Record<string, any>>
events: Record<string, any>
}
}
export interface IFolderItem {
componentName: 'Folder'
depth: number
folderName: string
id: string
parentId: string
router: string
}
export interface ISchemaChildrenItem {
children: Array<ISchemaChildrenItem>
componentName: string
id: string
props: Record<string, any>
}
export interface IComponentMapItem {
componentName: string
destructuring: boolean
exportName?: string
package?: string
version: string
}
export interface IMetaInfo {
name: string
description: string
}
}