forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproject.ts
More file actions
158 lines (139 loc) · 3.67 KB
/
project.ts
File metadata and controls
158 lines (139 loc) · 3.67 KB
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
155
156
157
158
import {
IPublicTypeProjectSchema,
IPublicTypeDisposable,
IPublicTypeRootSchema,
IPublicTypePropsTransducer,
IPublicTypeAppConfig,
} from '../type';
import { IPublicEnumTransformStage } from '../enum';
import { IPublicApiSimulatorHost } from './';
import { IPublicModelDocumentModel } from '../model';
export interface IBaseApiProject<DocumentModel> {
/**
* 获取当前的 document
* get current document
*/
get currentDocument(): DocumentModel | null;
/**
* 获取当前 project 下所有 documents
* get all documents of this project
* @returns
*/
get documents(): DocumentModel[];
/**
* 获取模拟器的 host
* get simulator host
*/
get simulatorHost(): IPublicApiSimulatorHost | null;
/**
* 打开一个 document
* open a document
* @param doc
* @returns
*/
openDocument(
doc?: string | IPublicTypeRootSchema | undefined,
): DocumentModel | null;
/**
* 创建一个 document
* create a document
* @param data
* @returns
*/
createDocument(data?: IPublicTypeRootSchema): DocumentModel | null;
/**
* 删除一个 document
* remove a document
* @param doc
*/
removeDocument(doc: DocumentModel): void;
/**
* 根据 fileName 获取 document
* get a document by filename
* @param fileName
* @returns
*/
getDocumentByFileName(fileName: string): DocumentModel | null;
/**
* 根据 id 获取 document
* get a document by id
* @param id
* @returns
*/
getDocumentById(id: string): DocumentModel | null;
/**
* 导出 project
* export project to schema
* @returns
*/
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeProjectSchema;
/**
* 导入 project schema
* import schema to project
* @param schema 待导入的 project 数据
*/
importSchema(schema?: IPublicTypeProjectSchema): void;
/**
* 获取当前的 document
* get current document
* @returns
*/
getCurrentDocument(): DocumentModel | null;
/**
* 增加一个属性的管道处理函数
* add a transducer to process prop
* @param transducer
* @param stage
*/
addPropsTransducer(
transducer: IPublicTypePropsTransducer,
stage: IPublicEnumTransformStage,
): void;
/**
* 绑定删除文档事件
* set callback for event onDocumentRemoved
* @param fn
* @since v1.0.16
*/
onRemoveDocument(fn: (data: { id: string }) => void): IPublicTypeDisposable;
/**
* 当前 project 内的 document 变更事件
* set callback for event onDocumentChanged
*/
onChangeDocument(fn: (doc: DocumentModel) => void): IPublicTypeDisposable;
/**
* 当前 project 的模拟器 ready 事件
* set callback for event onSimulatorHostReady
*/
onSimulatorHostReady(
fn: (host: IPublicApiSimulatorHost) => void,
): IPublicTypeDisposable;
/**
* 当前 project 的渲染器 ready 事件
* set callback for event onSimulatorRendererReady
*/
onSimulatorRendererReady(fn: () => void): IPublicTypeDisposable;
/**
* 设置多语言语料
* 数据格式参考 https://github.com/fe-lce/lowcode-engine/blob/main/specs/lowcode-spec.md#2434%E5%9B%BD%E9%99%85%E5%8C%96%E5%A4%9A%E8%AF%AD%E8%A8%80%E7%B1%BB%E5%9E%8Baa
*
* set I18n data for this project
* @param value object
* @since v1.0.17
*/
setI18n(value: object): void;
/**
* 设置当前项目配置
*
* set config data for this project
* @param value object
* @since v1.1.4
*/
setConfig<T extends keyof IPublicTypeAppConfig>(
key: T,
value: IPublicTypeAppConfig[T],
): void;
setConfig(value: IPublicTypeAppConfig): void;
}
export interface IPublicApiProject
extends IBaseApiProject<IPublicModelDocumentModel> {}