@ruiapp/rapid-core 0.1.83 → 0.2.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/dist/bootstrapApplicationConfig.d.ts +6 -0
- package/dist/helpers/metaHelper.d.ts +3 -3
- package/dist/index.js +56 -24
- package/dist/plugins/webhooks/pluginConfig.d.ts +1 -0
- package/dist/types.d.ts +19 -1
- package/package.json +1 -1
- package/rollup.config.js +16 -16
- package/src/bootstrapApplicationConfig.ts +615 -602
- package/src/core/actionHandler.ts +22 -22
- package/src/core/eventManager.ts +20 -20
- package/src/core/facility.ts +7 -7
- package/src/core/http/formDataParser.ts +89 -89
- package/src/core/pluginManager.ts +175 -175
- package/src/core/providers/runtimeProvider.ts +5 -5
- package/src/core/request.ts +86 -86
- package/src/core/response.ts +76 -76
- package/src/core/routeContext.ts +43 -43
- package/src/core/routesBuilder.ts +88 -88
- package/src/core/server.ts +142 -142
- package/src/dataAccess/columnTypeMapper.ts +22 -22
- package/src/dataAccess/dataAccessTypes.ts +151 -151
- package/src/dataAccess/dataAccessor.ts +137 -137
- package/src/dataAccess/entityManager.ts +1499 -1505
- package/src/dataAccess/entityMapper.ts +100 -100
- package/src/dataAccess/propertyMapper.ts +28 -28
- package/src/deno-std/datetime/to_imf.ts +32 -32
- package/src/deno-std/encoding/base64.ts +141 -141
- package/src/deno-std/http/cookie.ts +372 -372
- package/src/facilities/log/LogFacility.ts +35 -35
- package/src/helpers/entityHelpers.ts +76 -76
- package/src/helpers/filterHelper.ts +47 -47
- package/src/helpers/metaHelper.ts +80 -76
- package/src/helpers/runCollectionEntityActionHandler.ts +27 -27
- package/src/index.ts +46 -46
- package/src/plugins/auth/AuthPlugin.ts +85 -85
- package/src/plugins/auth/actionHandlers/changePassword.ts +54 -54
- package/src/plugins/auth/actionHandlers/createSession.ts +63 -63
- package/src/plugins/auth/actionHandlers/deleteSession.ts +18 -18
- package/src/plugins/auth/actionHandlers/getMyProfile.ts +35 -35
- package/src/plugins/auth/actionHandlers/index.ts +8 -8
- package/src/plugins/auth/actionHandlers/resetPassword.ts +38 -38
- package/src/plugins/auth/models/AccessToken.ts +56 -56
- package/src/plugins/auth/models/index.ts +3 -3
- package/src/plugins/auth/routes/changePassword.ts +15 -15
- package/src/plugins/auth/routes/getMyProfile.ts +15 -15
- package/src/plugins/auth/routes/index.ts +7 -7
- package/src/plugins/auth/routes/resetPassword.ts +15 -15
- package/src/plugins/auth/routes/signin.ts +15 -15
- package/src/plugins/auth/routes/signout.ts +15 -15
- package/src/plugins/cronJob/CronJobPlugin.ts +112 -112
- package/src/plugins/cronJob/CronJobPluginTypes.ts +49 -49
- package/src/plugins/cronJob/actionHandlers/index.ts +4 -4
- package/src/plugins/cronJob/actionHandlers/runCronJob.ts +29 -29
- package/src/plugins/cronJob/routes/index.ts +3 -3
- package/src/plugins/cronJob/routes/runCronJob.ts +15 -15
- package/src/plugins/dataManage/DataManagePlugin.ts +163 -163
- package/src/plugins/dataManage/actionHandlers/addEntityRelations.ts +20 -20
- package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +15 -15
- package/src/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.ts +42 -42
- package/src/plugins/dataManage/actionHandlers/createCollectionEntity.ts +24 -24
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntities.ts +38 -38
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntityById.ts +22 -22
- package/src/plugins/dataManage/actionHandlers/findCollectionEntities.ts +26 -26
- package/src/plugins/dataManage/actionHandlers/findCollectionEntityById.ts +21 -21
- package/src/plugins/dataManage/actionHandlers/queryDatabase.ts +22 -22
- package/src/plugins/dataManage/actionHandlers/removeEntityRelations.ts +20 -20
- package/src/plugins/dataManage/actionHandlers/updateCollectionEntityById.ts +35 -35
- package/src/plugins/entityAccessControl/EntityAccessControlPlugin.ts +146 -146
- package/src/plugins/fileManage/FileManagePlugin.ts +52 -52
- package/src/plugins/fileManage/actionHandlers/downloadDocument.ts +36 -36
- package/src/plugins/fileManage/actionHandlers/downloadFile.ts +44 -44
- package/src/plugins/fileManage/actionHandlers/uploadFile.ts +33 -33
- package/src/plugins/fileManage/routes/downloadDocument.ts +15 -15
- package/src/plugins/fileManage/routes/downloadFile.ts +15 -15
- package/src/plugins/fileManage/routes/index.ts +5 -5
- package/src/plugins/fileManage/routes/uploadFile.ts +15 -15
- package/src/plugins/metaManage/MetaManagePlugin.ts +500 -488
- package/src/plugins/metaManage/actionHandlers/getMetaModelDetail.ts +10 -10
- package/src/plugins/metaManage/actionHandlers/listMetaModels.ts +9 -9
- package/src/plugins/metaManage/actionHandlers/listMetaRoutes.ts +9 -9
- package/src/plugins/routeManage/RouteManagePlugin.ts +62 -62
- package/src/plugins/routeManage/actionHandlers/httpProxy.ts +13 -13
- package/src/plugins/sequence/SequencePlugin.ts +136 -136
- package/src/plugins/sequence/SequencePluginTypes.ts +69 -69
- package/src/plugins/sequence/SequenceService.ts +81 -81
- package/src/plugins/sequence/actionHandlers/generateSn.ts +32 -32
- package/src/plugins/sequence/actionHandlers/index.ts +4 -4
- package/src/plugins/sequence/models/SequenceAutoIncrementRecord.ts +49 -49
- package/src/plugins/sequence/models/SequenceRule.ts +42 -42
- package/src/plugins/sequence/models/index.ts +4 -4
- package/src/plugins/sequence/routes/generateSn.ts +15 -15
- package/src/plugins/sequence/routes/index.ts +3 -3
- package/src/plugins/sequence/segment-utility.ts +11 -11
- package/src/plugins/sequence/segments/autoIncrement.ts +78 -78
- package/src/plugins/sequence/segments/dayOfMonth.ts +17 -17
- package/src/plugins/sequence/segments/index.ts +9 -9
- package/src/plugins/sequence/segments/literal.ts +14 -14
- package/src/plugins/sequence/segments/month.ts +17 -17
- package/src/plugins/sequence/segments/parameter.ts +18 -18
- package/src/plugins/sequence/segments/year.ts +17 -17
- package/src/plugins/serverOperation/ServerOperationPlugin.ts +91 -91
- package/src/plugins/serverOperation/ServerOperationPluginTypes.ts +15 -15
- package/src/plugins/serverOperation/actionHandlers/index.ts +4 -4
- package/src/plugins/setting/SettingPlugin.ts +68 -68
- package/src/plugins/setting/SettingPluginTypes.ts +37 -37
- package/src/plugins/setting/SettingService.ts +213 -213
- package/src/plugins/setting/actionHandlers/getSystemSettingValues.ts +30 -30
- package/src/plugins/setting/actionHandlers/getUserSettingValues.ts +38 -38
- package/src/plugins/setting/actionHandlers/index.ts +6 -6
- package/src/plugins/setting/actionHandlers/setSystemSettingValues.ts +30 -30
- package/src/plugins/setting/models/SystemSettingGroupSetting.ts +57 -57
- package/src/plugins/setting/models/SystemSettingItem.ts +42 -42
- package/src/plugins/setting/models/SystemSettingItemSetting.ts +73 -73
- package/src/plugins/setting/models/UserSettingGroupSetting.ts +57 -57
- package/src/plugins/setting/models/UserSettingItem.ts +49 -49
- package/src/plugins/setting/models/UserSettingItemSetting.ts +73 -73
- package/src/plugins/setting/models/index.ts +8 -8
- package/src/plugins/setting/routes/getSystemSettingValues.ts +15 -15
- package/src/plugins/setting/routes/getUserSettingValues.ts +15 -15
- package/src/plugins/setting/routes/index.ts +5 -5
- package/src/plugins/setting/routes/setSystemSettingValues.ts +15 -15
- package/src/plugins/stateMachine/StateMachinePlugin.ts +186 -186
- package/src/plugins/stateMachine/StateMachinePluginTypes.ts +48 -48
- package/src/plugins/stateMachine/actionHandlers/index.ts +4 -4
- package/src/plugins/stateMachine/actionHandlers/sendStateMachineEvent.ts +51 -51
- package/src/plugins/stateMachine/models/StateMachine.ts +42 -42
- package/src/plugins/stateMachine/models/index.ts +3 -3
- package/src/plugins/stateMachine/routes/index.ts +3 -3
- package/src/plugins/stateMachine/routes/sendStateMachineEvent.ts +15 -15
- package/src/plugins/webhooks/WebhooksPlugin.ts +148 -148
- package/src/plugins/webhooks/pluginConfig.ts +1 -0
- package/src/polyfill.ts +5 -5
- package/src/proxy/mod.ts +38 -38
- package/src/queryBuilder/queryBuilder.ts +637 -637
- package/src/server.ts +463 -451
- package/src/types.ts +659 -637
- package/src/utilities/accessControlUtility.ts +33 -33
- package/src/utilities/errorUtility.ts +15 -15
- package/src/utilities/fsUtility.ts +61 -61
- package/src/utilities/httpUtility.ts +19 -19
- package/src/utilities/jwtUtility.ts +26 -26
- package/src/utilities/timeUtility.ts +9 -9
- package/tsconfig.json +19 -19
package/src/types.ts
CHANGED
|
@@ -1,637 +1,659 @@
|
|
|
1
|
-
import { RouteContext } from "./core/routeContext";
|
|
2
|
-
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
3
|
-
import { ColumnSelectOptions, CountRowOptions, FindRowOptions, RowFilterOptions } from "./dataAccess/dataAccessTypes";
|
|
4
|
-
|
|
5
|
-
export type RapidServerConfig = {
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
sessionCookieName: string;
|
|
8
|
-
jwtKey: string;
|
|
9
|
-
localFileStoragePath: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface IDatabaseConfig {
|
|
13
|
-
dbHost?: string;
|
|
14
|
-
dbPort?: number;
|
|
15
|
-
dbName?: string;
|
|
16
|
-
dbUser?: string;
|
|
17
|
-
dbPassword?: string;
|
|
18
|
-
dbDefaultSchema?: string;
|
|
19
|
-
dbPoolConnections?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type DatabaseQuery = {
|
|
23
|
-
command: string;
|
|
24
|
-
params?: unknown[] | Record<string, unknown>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export interface IDatabaseAccessor {
|
|
28
|
-
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface RunEntityActionHandlerOptions {
|
|
32
|
-
/** 模型所在的命名空间 */
|
|
33
|
-
namespace: string;
|
|
34
|
-
/** 模型Code的单数表示 */
|
|
35
|
-
singularCode: string;
|
|
36
|
-
/** 默认输入 */
|
|
37
|
-
defaultInput: Record<string, any>;
|
|
38
|
-
/** 固定输入 */
|
|
39
|
-
fixedInput: Record<string, any>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface RunQueryDatabaseHandlerOptions {
|
|
43
|
-
sql: string;
|
|
44
|
-
|
|
45
|
-
querySingle?: boolean;
|
|
46
|
-
|
|
47
|
-
/** 默认输入 */
|
|
48
|
-
defaultInput: Record<string, any>;
|
|
49
|
-
/** 固定输入 */
|
|
50
|
-
fixedInput: Record<string, any>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface RunProxyHandlerOptions {
|
|
54
|
-
/** Timeout milli seconds, default as 60000 */
|
|
55
|
-
timeout?: number;
|
|
56
|
-
/** Target url to proxy */
|
|
57
|
-
target: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface GetDataAccessorOptions {
|
|
61
|
-
namespace?: string;
|
|
62
|
-
singularCode: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface GetModelOptions {
|
|
66
|
-
namespace?: string;
|
|
67
|
-
singularCode: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type RpdServerEventTypes = {
|
|
71
|
-
"entity.beforeCreate": [RapidPlugin, RpdEntityBeforeCreateEventPayload, RouteContext?];
|
|
72
|
-
"entity.create": [RapidPlugin, RpdEntityCreateEventPayload, RouteContext?];
|
|
73
|
-
"entity.beforeUpdate": [RapidPlugin, RpdEntityBeforeUpdateEventPayload, RouteContext?];
|
|
74
|
-
"entity.update": [RapidPlugin, RpdEntityUpdateEventPayload, RouteContext?];
|
|
75
|
-
"entity.beforeDelete": [RapidPlugin, RpdEntityBeforeDeleteEventPayload, RouteContext?];
|
|
76
|
-
"entity.delete": [RapidPlugin, RpdEntityDeleteEventPayload, RouteContext?];
|
|
77
|
-
"entity.addRelations": [RapidPlugin, RpdEntityAddRelationsEventPayload, RouteContext?];
|
|
78
|
-
"entity.removeRelations": [RapidPlugin, RpdEntityRemoveRelationsEventPayload, RouteContext?];
|
|
79
|
-
"entity.beforeResponse": [RapidPlugin, RpdEntityBeforeResponseEventPayload, RouteContext?];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export interface RpdEntityBeforeCreateEventPayload {
|
|
83
|
-
namespace: string;
|
|
84
|
-
modelSingularCode: string;
|
|
85
|
-
baseModelSingularCode?: string;
|
|
86
|
-
before: any;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface RpdEntityCreateEventPayload {
|
|
90
|
-
namespace: string;
|
|
91
|
-
modelSingularCode: string;
|
|
92
|
-
baseModelSingularCode?: string;
|
|
93
|
-
after: any;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface RpdEntityBeforeUpdateEventPayload {
|
|
97
|
-
namespace: string;
|
|
98
|
-
modelSingularCode: string;
|
|
99
|
-
baseModelSingularCode?: string;
|
|
100
|
-
before: any;
|
|
101
|
-
changes: any;
|
|
102
|
-
operation?: {
|
|
103
|
-
type: string;
|
|
104
|
-
};
|
|
105
|
-
stateProperties?: string[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface RpdEntityUpdateEventPayload {
|
|
109
|
-
namespace: string;
|
|
110
|
-
modelSingularCode: string;
|
|
111
|
-
baseModelSingularCode?: string;
|
|
112
|
-
before: any;
|
|
113
|
-
after: any;
|
|
114
|
-
changes: any;
|
|
115
|
-
operation?: {
|
|
116
|
-
type: string;
|
|
117
|
-
};
|
|
118
|
-
stateProperties?: string[];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface RpdEntityBeforeDeleteEventPayload {
|
|
122
|
-
namespace: string;
|
|
123
|
-
modelSingularCode: string;
|
|
124
|
-
baseModelSingularCode?: string;
|
|
125
|
-
before: any;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface RpdEntityDeleteEventPayload {
|
|
129
|
-
namespace: string;
|
|
130
|
-
modelSingularCode: string;
|
|
131
|
-
baseModelSingularCode?: string;
|
|
132
|
-
before: any;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface RpdEntityAddRelationsEventPayload {
|
|
136
|
-
namespace: string;
|
|
137
|
-
modelSingularCode: string;
|
|
138
|
-
baseModelSingularCode?: string;
|
|
139
|
-
entity: any;
|
|
140
|
-
property: string;
|
|
141
|
-
relations: any[];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface RpdEntityRemoveRelationsEventPayload {
|
|
145
|
-
namespace: string;
|
|
146
|
-
modelSingularCode: string;
|
|
147
|
-
baseModelSingularCode?: string;
|
|
148
|
-
entity: any;
|
|
149
|
-
property: string;
|
|
150
|
-
relations: any[];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export interface RpdEntityBeforeResponseEventPayload {
|
|
154
|
-
namespace: string;
|
|
155
|
-
modelSingularCode: string;
|
|
156
|
-
baseModelSingularCode?: string;
|
|
157
|
-
entities: any[];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export type EmitServerEventOptions<TEventName extends keyof RpdServerEventTypes> = {
|
|
161
|
-
eventName: TEventName;
|
|
162
|
-
payload: RpdServerEventTypes[TEventName][1];
|
|
163
|
-
sender?: RapidPlugin;
|
|
164
|
-
routeContext?: RouteContext;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export interface QuoteTableOptions {
|
|
168
|
-
schema?: string;
|
|
169
|
-
tableName: string;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export interface IQueryBuilder {
|
|
173
|
-
quoteTable: (options: QuoteTableOptions) => string;
|
|
174
|
-
quoteObject: (name: string) => string;
|
|
175
|
-
buildFiltersExpression(model: RpdDataModel, filters: RowFilterOptions[]);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface RpdApplicationConfig {
|
|
179
|
-
code?: string;
|
|
180
|
-
name?: string;
|
|
181
|
-
models: RpdDataModel[];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
* 当 relation 为
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
| "
|
|
309
|
-
| "
|
|
310
|
-
| "
|
|
311
|
-
| "
|
|
312
|
-
| "
|
|
313
|
-
| "
|
|
314
|
-
| "
|
|
315
|
-
| "
|
|
316
|
-
| "
|
|
317
|
-
| "
|
|
318
|
-
| "
|
|
319
|
-
| "
|
|
320
|
-
| "
|
|
321
|
-
| "
|
|
322
|
-
| "
|
|
323
|
-
| "
|
|
324
|
-
| "
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
export interface
|
|
409
|
-
name
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
export type
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
|
464
|
-
|
|
|
465
|
-
|
|
|
466
|
-
|
|
|
467
|
-
|
|
|
468
|
-
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
|
472
|
-
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
export type
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
export
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
export interface
|
|
600
|
-
routeContext?: RouteContext;
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
export interface
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
export
|
|
636
|
-
|
|
637
|
-
|
|
1
|
+
import { RouteContext } from "./core/routeContext";
|
|
2
|
+
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
3
|
+
import { ColumnSelectOptions, CountRowOptions, FindRowOptions, RowFilterOptions } from "./dataAccess/dataAccessTypes";
|
|
4
|
+
|
|
5
|
+
export type RapidServerConfig = {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
sessionCookieName: string;
|
|
8
|
+
jwtKey: string;
|
|
9
|
+
localFileStoragePath: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface IDatabaseConfig {
|
|
13
|
+
dbHost?: string;
|
|
14
|
+
dbPort?: number;
|
|
15
|
+
dbName?: string;
|
|
16
|
+
dbUser?: string;
|
|
17
|
+
dbPassword?: string;
|
|
18
|
+
dbDefaultSchema?: string;
|
|
19
|
+
dbPoolConnections?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type DatabaseQuery = {
|
|
23
|
+
command: string;
|
|
24
|
+
params?: unknown[] | Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export interface IDatabaseAccessor {
|
|
28
|
+
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>) => Promise<any[]>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RunEntityActionHandlerOptions {
|
|
32
|
+
/** 模型所在的命名空间 */
|
|
33
|
+
namespace: string;
|
|
34
|
+
/** 模型Code的单数表示 */
|
|
35
|
+
singularCode: string;
|
|
36
|
+
/** 默认输入 */
|
|
37
|
+
defaultInput: Record<string, any>;
|
|
38
|
+
/** 固定输入 */
|
|
39
|
+
fixedInput: Record<string, any>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RunQueryDatabaseHandlerOptions {
|
|
43
|
+
sql: string;
|
|
44
|
+
|
|
45
|
+
querySingle?: boolean;
|
|
46
|
+
|
|
47
|
+
/** 默认输入 */
|
|
48
|
+
defaultInput: Record<string, any>;
|
|
49
|
+
/** 固定输入 */
|
|
50
|
+
fixedInput: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RunProxyHandlerOptions {
|
|
54
|
+
/** Timeout milli seconds, default as 60000 */
|
|
55
|
+
timeout?: number;
|
|
56
|
+
/** Target url to proxy */
|
|
57
|
+
target: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface GetDataAccessorOptions {
|
|
61
|
+
namespace?: string;
|
|
62
|
+
singularCode: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface GetModelOptions {
|
|
66
|
+
namespace?: string;
|
|
67
|
+
singularCode: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type RpdServerEventTypes = {
|
|
71
|
+
"entity.beforeCreate": [RapidPlugin, RpdEntityBeforeCreateEventPayload, RouteContext?];
|
|
72
|
+
"entity.create": [RapidPlugin, RpdEntityCreateEventPayload, RouteContext?];
|
|
73
|
+
"entity.beforeUpdate": [RapidPlugin, RpdEntityBeforeUpdateEventPayload, RouteContext?];
|
|
74
|
+
"entity.update": [RapidPlugin, RpdEntityUpdateEventPayload, RouteContext?];
|
|
75
|
+
"entity.beforeDelete": [RapidPlugin, RpdEntityBeforeDeleteEventPayload, RouteContext?];
|
|
76
|
+
"entity.delete": [RapidPlugin, RpdEntityDeleteEventPayload, RouteContext?];
|
|
77
|
+
"entity.addRelations": [RapidPlugin, RpdEntityAddRelationsEventPayload, RouteContext?];
|
|
78
|
+
"entity.removeRelations": [RapidPlugin, RpdEntityRemoveRelationsEventPayload, RouteContext?];
|
|
79
|
+
"entity.beforeResponse": [RapidPlugin, RpdEntityBeforeResponseEventPayload, RouteContext?];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export interface RpdEntityBeforeCreateEventPayload {
|
|
83
|
+
namespace: string;
|
|
84
|
+
modelSingularCode: string;
|
|
85
|
+
baseModelSingularCode?: string;
|
|
86
|
+
before: any;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface RpdEntityCreateEventPayload {
|
|
90
|
+
namespace: string;
|
|
91
|
+
modelSingularCode: string;
|
|
92
|
+
baseModelSingularCode?: string;
|
|
93
|
+
after: any;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface RpdEntityBeforeUpdateEventPayload {
|
|
97
|
+
namespace: string;
|
|
98
|
+
modelSingularCode: string;
|
|
99
|
+
baseModelSingularCode?: string;
|
|
100
|
+
before: any;
|
|
101
|
+
changes: any;
|
|
102
|
+
operation?: {
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
105
|
+
stateProperties?: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface RpdEntityUpdateEventPayload {
|
|
109
|
+
namespace: string;
|
|
110
|
+
modelSingularCode: string;
|
|
111
|
+
baseModelSingularCode?: string;
|
|
112
|
+
before: any;
|
|
113
|
+
after: any;
|
|
114
|
+
changes: any;
|
|
115
|
+
operation?: {
|
|
116
|
+
type: string;
|
|
117
|
+
};
|
|
118
|
+
stateProperties?: string[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface RpdEntityBeforeDeleteEventPayload {
|
|
122
|
+
namespace: string;
|
|
123
|
+
modelSingularCode: string;
|
|
124
|
+
baseModelSingularCode?: string;
|
|
125
|
+
before: any;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface RpdEntityDeleteEventPayload {
|
|
129
|
+
namespace: string;
|
|
130
|
+
modelSingularCode: string;
|
|
131
|
+
baseModelSingularCode?: string;
|
|
132
|
+
before: any;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface RpdEntityAddRelationsEventPayload {
|
|
136
|
+
namespace: string;
|
|
137
|
+
modelSingularCode: string;
|
|
138
|
+
baseModelSingularCode?: string;
|
|
139
|
+
entity: any;
|
|
140
|
+
property: string;
|
|
141
|
+
relations: any[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface RpdEntityRemoveRelationsEventPayload {
|
|
145
|
+
namespace: string;
|
|
146
|
+
modelSingularCode: string;
|
|
147
|
+
baseModelSingularCode?: string;
|
|
148
|
+
entity: any;
|
|
149
|
+
property: string;
|
|
150
|
+
relations: any[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface RpdEntityBeforeResponseEventPayload {
|
|
154
|
+
namespace: string;
|
|
155
|
+
modelSingularCode: string;
|
|
156
|
+
baseModelSingularCode?: string;
|
|
157
|
+
entities: any[];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type EmitServerEventOptions<TEventName extends keyof RpdServerEventTypes> = {
|
|
161
|
+
eventName: TEventName;
|
|
162
|
+
payload: RpdServerEventTypes[TEventName][1];
|
|
163
|
+
sender?: RapidPlugin;
|
|
164
|
+
routeContext?: RouteContext;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export interface QuoteTableOptions {
|
|
168
|
+
schema?: string;
|
|
169
|
+
tableName: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface IQueryBuilder {
|
|
173
|
+
quoteTable: (options: QuoteTableOptions) => string;
|
|
174
|
+
quoteObject: (name: string) => string;
|
|
175
|
+
buildFiltersExpression(model: RpdDataModel, filters: RowFilterOptions[]);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface RpdApplicationConfig {
|
|
179
|
+
code?: string;
|
|
180
|
+
name?: string;
|
|
181
|
+
models: RpdDataModel[];
|
|
182
|
+
dataDictionaries: RpdDataDictionary[];
|
|
183
|
+
routes: RpdRoute[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface RpdDataModel {
|
|
187
|
+
maintainedBy?: string;
|
|
188
|
+
name: string;
|
|
189
|
+
namespace: string;
|
|
190
|
+
code?: string;
|
|
191
|
+
singularCode: string;
|
|
192
|
+
pluralCode: string;
|
|
193
|
+
schema?: string;
|
|
194
|
+
tableName: string;
|
|
195
|
+
/**
|
|
196
|
+
* Configure the singular code of base entity.
|
|
197
|
+
*/
|
|
198
|
+
base?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Configure the type of derived entity.
|
|
201
|
+
*/
|
|
202
|
+
derivedType?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Configure the property code to save derived type for base entity.
|
|
205
|
+
*/
|
|
206
|
+
derivedTypePropertyCode?: string;
|
|
207
|
+
/**
|
|
208
|
+
* Configure the property code used to display the entity.
|
|
209
|
+
*/
|
|
210
|
+
displayPropertyCode?: string;
|
|
211
|
+
properties: RpdDataModelProperty[];
|
|
212
|
+
indexes?: RpdDataModelIndex[];
|
|
213
|
+
extensions?: RpdDataModelExtension[];
|
|
214
|
+
permissionPolicies?: RpdDataModelPermissionPolicies;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface RpdDataModelPermissionPolicies {
|
|
218
|
+
find?: PermissionPolicy;
|
|
219
|
+
create?: PermissionPolicy;
|
|
220
|
+
update?: PermissionPolicy;
|
|
221
|
+
delete?: PermissionPolicy;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface PermissionPolicy {
|
|
225
|
+
any?: string[];
|
|
226
|
+
all?: string[];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface RpdDataModelProperty {
|
|
230
|
+
/**
|
|
231
|
+
* 表示此属性由谁来维护
|
|
232
|
+
*/
|
|
233
|
+
maintainedBy?: string;
|
|
234
|
+
/**
|
|
235
|
+
* 表示是否基础属性
|
|
236
|
+
*/
|
|
237
|
+
isBaseProperty?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* 字段名称。可以包含中文。
|
|
240
|
+
*/
|
|
241
|
+
name: string;
|
|
242
|
+
/**
|
|
243
|
+
* 字段代码。会用于数据表列名和 API 的字段名。
|
|
244
|
+
*/
|
|
245
|
+
code: string;
|
|
246
|
+
/**
|
|
247
|
+
* 数据表列名。如果没有设置则使用 code。
|
|
248
|
+
*/
|
|
249
|
+
columnName?: string;
|
|
250
|
+
/**
|
|
251
|
+
* 字段类型。
|
|
252
|
+
*/
|
|
253
|
+
type: RpdDataPropertyTypes;
|
|
254
|
+
/**
|
|
255
|
+
* 是否必须有值。默认为 false。
|
|
256
|
+
*/
|
|
257
|
+
required?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* 默认值。使用默认值的 SQL 表达式表示。
|
|
260
|
+
*/
|
|
261
|
+
defaultValue?: string;
|
|
262
|
+
/**
|
|
263
|
+
* 属性配置。
|
|
264
|
+
*/
|
|
265
|
+
// deno-lint-ignore no-explicit-any
|
|
266
|
+
config?: Record<string, any>;
|
|
267
|
+
/**
|
|
268
|
+
* 是否自增长。
|
|
269
|
+
*/
|
|
270
|
+
autoIncrement?: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* 字段值的最小长度。
|
|
273
|
+
*/
|
|
274
|
+
minLength?: number;
|
|
275
|
+
/**
|
|
276
|
+
* 字段值的最大长度。
|
|
277
|
+
*/
|
|
278
|
+
maxLength?: number;
|
|
279
|
+
/**
|
|
280
|
+
* 当 type 为 relation 时,设置关联实体为一个还是多个。
|
|
281
|
+
*/
|
|
282
|
+
relation?: "one" | "many";
|
|
283
|
+
/**
|
|
284
|
+
* 关联实体的singular code,不管 relation 为 one 或者 many 都需要设置。
|
|
285
|
+
*/
|
|
286
|
+
targetSingularCode?: string;
|
|
287
|
+
/**
|
|
288
|
+
* 当 relation 为 one 时,设置当前模型表中表示关联实体 id 的列名。
|
|
289
|
+
* 当 relation 为 many,并且使用关联关系表保存关联信息时,设置关联关系表中表示关联实体 id 的列名。
|
|
290
|
+
* 当 relation 为 many,并且不使用关联关系表保存关联信息时,关联实体 id 的列名默认为`id`,此时可以不设置 targetIdColumnName。
|
|
291
|
+
*/
|
|
292
|
+
targetIdColumnName?: string;
|
|
293
|
+
/**
|
|
294
|
+
* 当 relation 为 many 时,设置目标模型表或关联关系表中表示自身实体 id 的列名。
|
|
295
|
+
*/
|
|
296
|
+
selfIdColumnName?: string;
|
|
297
|
+
/**
|
|
298
|
+
* 当 relation 为 many 时,可以使用关联关系表保存关联信息,此时需要设置关联关系表的名称。
|
|
299
|
+
*/
|
|
300
|
+
linkTableName?: string;
|
|
301
|
+
/**
|
|
302
|
+
* 当设置了 linkTableName 时,可以设置关联关系表所在的 Schema。
|
|
303
|
+
*/
|
|
304
|
+
linkSchema?: string;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export type RpdDataPropertyTypes =
|
|
308
|
+
| "integer"
|
|
309
|
+
| "long"
|
|
310
|
+
| "float"
|
|
311
|
+
| "double"
|
|
312
|
+
| "decimal"
|
|
313
|
+
| "text"
|
|
314
|
+
| "boolean"
|
|
315
|
+
| "date"
|
|
316
|
+
| "time"
|
|
317
|
+
| "datetime"
|
|
318
|
+
| "json"
|
|
319
|
+
| "relation"
|
|
320
|
+
| "relation[]"
|
|
321
|
+
| "option"
|
|
322
|
+
| "option[]"
|
|
323
|
+
| "file"
|
|
324
|
+
| "file[]"
|
|
325
|
+
| "image"
|
|
326
|
+
| "image[]";
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 数据字典
|
|
330
|
+
*/
|
|
331
|
+
export type RpdDataDictionary = {
|
|
332
|
+
/**
|
|
333
|
+
* 字典编码
|
|
334
|
+
*/
|
|
335
|
+
code: string;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 字典名称
|
|
339
|
+
*/
|
|
340
|
+
name?: string;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* 描述
|
|
344
|
+
*/
|
|
345
|
+
description?: string;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 字典项值类型
|
|
349
|
+
*/
|
|
350
|
+
valueType: "string" | "integer";
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* 字典级别
|
|
354
|
+
*/
|
|
355
|
+
level: "sys" | "app" | "user";
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* 字典项
|
|
359
|
+
*/
|
|
360
|
+
entries: RpdDataDictionaryEntry[];
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 数据字典项
|
|
365
|
+
*/
|
|
366
|
+
export type RpdDataDictionaryEntry = {
|
|
367
|
+
/**
|
|
368
|
+
* 名称
|
|
369
|
+
*/
|
|
370
|
+
name: string;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* 值
|
|
374
|
+
*/
|
|
375
|
+
value: string;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* 颜色
|
|
379
|
+
*/
|
|
380
|
+
color?: string;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* 图标
|
|
384
|
+
*/
|
|
385
|
+
icon?: string;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 描述
|
|
389
|
+
*/
|
|
390
|
+
description?: string;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 排序号
|
|
394
|
+
*/
|
|
395
|
+
orderNum: number;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* 是否禁用
|
|
399
|
+
*/
|
|
400
|
+
disabled: boolean;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export interface RpdDataModelExtension {
|
|
404
|
+
code: string;
|
|
405
|
+
config: any;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface RpdDataModelIndex {
|
|
409
|
+
name?: string;
|
|
410
|
+
unique?: boolean;
|
|
411
|
+
properties: RpdDataModelIndexPropertyConfig[];
|
|
412
|
+
conditions?: RpdDataModelIndexOptions[];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export type RpdDataModelIndexPropertyConfig =
|
|
416
|
+
| string
|
|
417
|
+
| {
|
|
418
|
+
code: string;
|
|
419
|
+
order?: "asc" | "desc";
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
export type RpdDataModelIndexOptions =
|
|
423
|
+
| FindEntityRelationalFilterOptions
|
|
424
|
+
| FindEntitySetFilterOptions
|
|
425
|
+
| FindEntityLogicalFilterOptions<RpdDataModelIndexOptions>
|
|
426
|
+
| FindEntityUnaryFilterOptions;
|
|
427
|
+
|
|
428
|
+
export type EventHandler<T = any> = (sender: RapidPlugin, payload: T) => void;
|
|
429
|
+
|
|
430
|
+
export interface RpdRoute {
|
|
431
|
+
name: string;
|
|
432
|
+
namespace: string;
|
|
433
|
+
code: string;
|
|
434
|
+
type: "RESTful";
|
|
435
|
+
method: RpdHttpMethod;
|
|
436
|
+
endpoint: string;
|
|
437
|
+
actions: RpdRouteActionConfig[];
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export type RpdHttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
441
|
+
|
|
442
|
+
export interface RpdRouteActionConfig {
|
|
443
|
+
code: string;
|
|
444
|
+
config?: any;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface IRpdDataAccessor<T = any> {
|
|
448
|
+
getModel(): RpdDataModel;
|
|
449
|
+
create(entity: any): Promise<any>;
|
|
450
|
+
updateById(id: any, entity: any): Promise<any>;
|
|
451
|
+
find(options: FindRowOptions): Promise<T[]>;
|
|
452
|
+
findOne(options: FindRowOptions): Promise<T | null>;
|
|
453
|
+
findById(id: any): Promise<T | null>;
|
|
454
|
+
count(options: CountRowOptions): Promise<any>;
|
|
455
|
+
deleteById(id: any): Promise<void>;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export type EntityFilterRelationalOperators =
|
|
459
|
+
| "eq"
|
|
460
|
+
| "ne"
|
|
461
|
+
| "lt"
|
|
462
|
+
| "lte"
|
|
463
|
+
| "gt"
|
|
464
|
+
| "gte"
|
|
465
|
+
| "contains"
|
|
466
|
+
| "notContains"
|
|
467
|
+
| "containsCS"
|
|
468
|
+
| "notContainsCS"
|
|
469
|
+
| "startsWith"
|
|
470
|
+
| "notStartsWith"
|
|
471
|
+
| "endsWith"
|
|
472
|
+
| "notEndsWith";
|
|
473
|
+
|
|
474
|
+
export type EntityFilterArrayOperators = "arrayContains" | "arrayOverlap";
|
|
475
|
+
|
|
476
|
+
export type EntityFilterSetOperators = "in" | "notIn";
|
|
477
|
+
|
|
478
|
+
export type EntityFilterLogicalOperators = "or" | "and";
|
|
479
|
+
|
|
480
|
+
export type EntityFilterUnaryOperators = "null" | "notNull";
|
|
481
|
+
|
|
482
|
+
export type EntityFilterExistenceOperators = "exists" | "notExists";
|
|
483
|
+
|
|
484
|
+
export type EntityFilterOperators =
|
|
485
|
+
| EntityFilterRelationalOperators
|
|
486
|
+
| EntityFilterArrayOperators
|
|
487
|
+
| EntityFilterSetOperators
|
|
488
|
+
| EntityFilterLogicalOperators
|
|
489
|
+
| EntityFilterUnaryOperators
|
|
490
|
+
| EntityFilterExistenceOperators;
|
|
491
|
+
|
|
492
|
+
export type EntityFilterOptions =
|
|
493
|
+
| FindEntityRelationalFilterOptions
|
|
494
|
+
| FindEntityArrayFilterOptions
|
|
495
|
+
| FindEntitySetFilterOptions
|
|
496
|
+
| FindEntityLogicalFilterOptions
|
|
497
|
+
| FindEntityUnaryFilterOptions
|
|
498
|
+
| FindEntityExistenceFilterOptions;
|
|
499
|
+
|
|
500
|
+
export type EntityNonRelationPropertyFilterOptions =
|
|
501
|
+
| FindEntityRelationalFilterOptions
|
|
502
|
+
| FindEntityArrayFilterOptions
|
|
503
|
+
| FindEntitySetFilterOptions
|
|
504
|
+
| FindEntityUnaryFilterOptions;
|
|
505
|
+
|
|
506
|
+
export interface FindEntityOptions {
|
|
507
|
+
routeContext?: RouteContext;
|
|
508
|
+
filters?: EntityFilterOptions[];
|
|
509
|
+
orderBy?: FindEntityOrderByOptions[];
|
|
510
|
+
pagination?: FindEntityPaginationOptions;
|
|
511
|
+
properties?: string[];
|
|
512
|
+
relations?: Record<string, FindEntitySelectRelationOptions>;
|
|
513
|
+
extraColumnsToSelect?: ColumnSelectOptions[];
|
|
514
|
+
keepNonPropertyFields?: boolean;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export interface FindEntityByIdOptions {
|
|
518
|
+
routeContext?: RouteContext;
|
|
519
|
+
id: any;
|
|
520
|
+
properties?: string[];
|
|
521
|
+
relations?: Record<string, FindEntitySelectRelationOptions>;
|
|
522
|
+
keepNonPropertyFields?: boolean;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export interface FindEntityRelationalFilterOptions {
|
|
526
|
+
field: string;
|
|
527
|
+
operator: EntityFilterRelationalOperators;
|
|
528
|
+
value: any;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export interface FindEntityArrayFilterOptions {
|
|
532
|
+
field: string;
|
|
533
|
+
operator: EntityFilterArrayOperators;
|
|
534
|
+
value: any[];
|
|
535
|
+
itemType?: string;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export interface FindEntitySetFilterOptions {
|
|
539
|
+
field: string;
|
|
540
|
+
operator: EntityFilterSetOperators;
|
|
541
|
+
value: any[];
|
|
542
|
+
itemType?: string;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export interface FindEntityLogicalFilterOptions<TFilter = EntityFilterOptions> {
|
|
546
|
+
operator: EntityFilterLogicalOperators;
|
|
547
|
+
filters: TFilter[];
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export interface FindEntityUnaryFilterOptions {
|
|
551
|
+
field: string;
|
|
552
|
+
operator: EntityFilterUnaryOperators;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export interface FindEntityExistenceFilterOptions {
|
|
556
|
+
field: string;
|
|
557
|
+
operator: EntityFilterExistenceOperators;
|
|
558
|
+
filters: EntityFilterOptions[];
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export interface FindEntityPaginationOptions {
|
|
562
|
+
offset: number;
|
|
563
|
+
limit: number;
|
|
564
|
+
withoutTotal?: boolean;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export type FindEntitySelectRelationOptions =
|
|
568
|
+
| true
|
|
569
|
+
| {
|
|
570
|
+
properties?: string[];
|
|
571
|
+
relations?: Record<string, FindEntitySelectRelationOptions>;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
export interface FindEntityOrderByOptions {
|
|
575
|
+
field: string;
|
|
576
|
+
desc?: boolean;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export interface CountEntityOptions {
|
|
580
|
+
routeContext?: RouteContext;
|
|
581
|
+
filters?: EntityFilterOptions[];
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export interface CountEntityResult {
|
|
585
|
+
count: number;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export interface DeleteEntityByIdOptions {
|
|
589
|
+
routeContext?: RouteContext;
|
|
590
|
+
id: any;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export interface CreateEntityOptions {
|
|
594
|
+
routeContext?: RouteContext;
|
|
595
|
+
entity: any;
|
|
596
|
+
postponeUniquenessCheck?: boolean;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export interface UpdateEntityOptions {
|
|
600
|
+
routeContext?: RouteContext;
|
|
601
|
+
filters?: EntityFilterOptions[];
|
|
602
|
+
entity: any;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export interface UpdateEntityByIdOptions {
|
|
606
|
+
routeContext?: RouteContext;
|
|
607
|
+
id: any;
|
|
608
|
+
entityToSave: any;
|
|
609
|
+
operation?: {
|
|
610
|
+
type: string;
|
|
611
|
+
};
|
|
612
|
+
stateProperties?: string[];
|
|
613
|
+
postponeUniquenessCheck?: boolean;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export interface DeleteEntityOptions {
|
|
617
|
+
routeContext?: RouteContext;
|
|
618
|
+
filters?: EntityFilterOptions[];
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface AddEntityRelationsOptions {
|
|
622
|
+
routeContext?: RouteContext;
|
|
623
|
+
id: number;
|
|
624
|
+
property: string;
|
|
625
|
+
relations: { id?: number; [k: string]: any }[];
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export interface RemoveEntityRelationsOptions {
|
|
629
|
+
routeContext?: RouteContext;
|
|
630
|
+
id: number;
|
|
631
|
+
property: string;
|
|
632
|
+
relations: { id?: number; [k: string]: any }[];
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export type EntityWatcherType =
|
|
636
|
+
| EntityWatcher<"entity.create">
|
|
637
|
+
| EntityWatcher<"entity.update">
|
|
638
|
+
| EntityWatcher<"entity.delete">
|
|
639
|
+
| EntityWatcher<"entity.addRelations">
|
|
640
|
+
| EntityWatcher<"entity.removeRelations">
|
|
641
|
+
| EntityWatcher<any>;
|
|
642
|
+
|
|
643
|
+
export interface EntityWatcher<TEventName extends keyof RpdServerEventTypes = any> {
|
|
644
|
+
eventName: TEventName;
|
|
645
|
+
modelSingularCode: string;
|
|
646
|
+
handler: EntityWatchHandler<TEventName>;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export type EntityWatchHandler<TEventName extends keyof RpdServerEventTypes> = (ctx: EntityWatchHandlerContext<TEventName>) => Promise<void>;
|
|
650
|
+
|
|
651
|
+
export type EntityWatchHandlerContext<TEventName extends keyof RpdServerEventTypes> = {
|
|
652
|
+
server: IRpdServer;
|
|
653
|
+
payload: RpdServerEventTypes[TEventName][1];
|
|
654
|
+
routerContext?: RouteContext;
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
export interface EntityWatchPluginInitOptions {
|
|
658
|
+
watchers: EntityWatcherType[];
|
|
659
|
+
}
|