@ruiapp/rapid-core 0.11.6 → 0.11.7
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/CHANGELOG.md +11 -11
- package/dist/core/pluginManager.d.ts +2 -0
- package/dist/core/server.d.ts +3 -0
- package/dist/dataAccess/entityManager.d.ts +3 -3
- package/dist/index.js +102 -38
- package/dist/server.d.ts +1 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/rollup.config.js +16 -16
- package/src/bootstrapApplicationConfig.ts +904 -904
- package/src/core/ExpressionInterpreter.ts +45 -45
- package/src/core/actionHandler.ts +24 -24
- package/src/core/actionHandlers/ifActionHandler.ts +27 -27
- package/src/core/eventManager.ts +20 -20
- package/src/core/facility.ts +7 -7
- package/src/core/http/formDataParser.ts +87 -87
- package/src/core/http-types.ts +4 -4
- package/src/core/pluginManager.ts +202 -193
- package/src/core/providers/runtimeProvider.ts +5 -5
- package/src/core/request.ts +96 -96
- package/src/core/response.ts +84 -84
- package/src/core/routeContext.ts +127 -127
- package/src/core/routes/healthz.ts +20 -20
- package/src/core/routes/index.ts +3 -3
- package/src/core/routesBuilder.ts +129 -122
- package/src/core/server.ts +161 -158
- package/src/dataAccess/columnTypeMapper.ts +22 -22
- package/src/dataAccess/dataAccessTypes.ts +165 -165
- package/src/dataAccess/dataAccessor.ts +135 -135
- package/src/dataAccess/entityManager.ts +2031 -1996
- package/src/dataAccess/entityMapper.ts +111 -111
- package/src/dataAccess/entityValidator.ts +33 -33
- package/src/dataAccess/propertyMapper.ts +28 -28
- package/src/deno-std/assert/assert.ts +9 -9
- package/src/deno-std/assert/assertion_error.ts +7 -7
- 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/cache/CacheFacilityTypes.ts +29 -29
- package/src/facilities/cache/CacheFactory.ts +31 -31
- package/src/facilities/cache/MemoryCache.ts +58 -58
- package/src/facilities/cache/MemoryCacheProvider.ts +15 -15
- package/src/facilities/log/LogFacility.ts +35 -35
- package/src/helpers/dbTransactionHelper.ts +42 -42
- package/src/helpers/entityHelper.ts +89 -89
- package/src/helpers/filterHelper.ts +148 -148
- package/src/helpers/inputHelper.ts +11 -11
- package/src/helpers/licenseHelper.ts +29 -29
- package/src/helpers/metaHelper.ts +111 -111
- package/src/helpers/runCollectionEntityActionHandler.ts +58 -58
- package/src/index.ts +85 -85
- package/src/plugins/auth/AuthPlugin.ts +107 -107
- package/src/plugins/auth/AuthPluginTypes.ts +11 -11
- package/src/plugins/auth/actionHandlers/changePassword.ts +61 -61
- package/src/plugins/auth/actionHandlers/createSession.ts +68 -68
- package/src/plugins/auth/actionHandlers/deleteSession.ts +18 -18
- package/src/plugins/auth/actionHandlers/getMyProfile.ts +28 -28
- package/src/plugins/auth/actionHandlers/index.ts +8 -8
- package/src/plugins/auth/actionHandlers/resetPassword.ts +45 -45
- 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/auth/services/AuthService.ts +66 -66
- package/src/plugins/cronJob/CronJobPlugin.ts +104 -104
- package/src/plugins/cronJob/CronJobPluginTypes.ts +44 -44
- package/src/plugins/cronJob/actionHandlers/index.ts +4 -4
- package/src/plugins/cronJob/actionHandlers/runCronJob.ts +32 -32
- package/src/plugins/cronJob/entityWatchers/cronJobEntityWatchers.ts +24 -24
- package/src/plugins/cronJob/entityWatchers/index.ts +4 -4
- package/src/plugins/cronJob/models/CronJob.ts +129 -129
- package/src/plugins/cronJob/models/index.ts +3 -3
- package/src/plugins/cronJob/routes/index.ts +3 -3
- package/src/plugins/cronJob/routes/runCronJob.ts +15 -15
- package/src/plugins/cronJob/services/CronJobService.ts +255 -255
- package/src/plugins/dataManage/DataManagePlugin.ts +165 -165
- package/src/plugins/dataManage/actionHandlers/addEntityRelations.ts +15 -15
- package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +17 -17
- package/src/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.ts +81 -81
- package/src/plugins/dataManage/actionHandlers/createCollectionEntity.ts +20 -20
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntities.ts +47 -45
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntityById.ts +20 -20
- package/src/plugins/dataManage/actionHandlers/findCollectionEntities.ts +27 -27
- package/src/plugins/dataManage/actionHandlers/findCollectionEntityById.ts +30 -30
- package/src/plugins/dataManage/actionHandlers/queryDatabase.ts +22 -22
- package/src/plugins/dataManage/actionHandlers/removeEntityRelations.ts +15 -15
- package/src/plugins/dataManage/actionHandlers/saveEntity.ts +46 -46
- package/src/plugins/dataManage/actionHandlers/updateCollectionEntityById.ts +38 -38
- package/src/plugins/entityAccessControl/EntityAccessControlPlugin.ts +146 -146
- package/src/plugins/fileManage/FileManagePlugin.ts +52 -52
- package/src/plugins/fileManage/actionHandlers/downloadDocument.ts +65 -65
- 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/license/LicensePlugin.ts +79 -79
- package/src/plugins/license/LicensePluginTypes.ts +95 -95
- package/src/plugins/license/LicenseService.ts +141 -141
- package/src/plugins/license/actionHandlers/getLicense.ts +18 -18
- package/src/plugins/license/actionHandlers/index.ts +5 -5
- package/src/plugins/license/actionHandlers/updateLicense.ts +24 -24
- package/src/plugins/license/helpers/certHelper.ts +21 -21
- package/src/plugins/license/helpers/cryptoHelper.ts +47 -47
- package/src/plugins/license/models/index.ts +1 -1
- package/src/plugins/license/routes/getLicense.ts +15 -15
- package/src/plugins/license/routes/index.ts +4 -4
- package/src/plugins/license/routes/updateLicense.ts +15 -15
- package/src/plugins/mail/MailPlugin.ts +74 -74
- package/src/plugins/mail/MailPluginTypes.ts +27 -27
- package/src/plugins/mail/MailService.ts +38 -38
- package/src/plugins/mail/actionHandlers/index.ts +3 -3
- package/src/plugins/mail/models/index.ts +1 -1
- package/src/plugins/mail/routes/index.ts +1 -1
- package/src/plugins/metaManage/MetaManagePlugin.ts +198 -198
- package/src/plugins/metaManage/actionHandlers/getMetaModelDetail.ts +10 -10
- package/src/plugins/metaManage/actionHandlers/listMetaModels.ts +10 -10
- package/src/plugins/metaManage/actionHandlers/listMetaRoutes.ts +10 -10
- package/src/plugins/metaManage/services/MetaService.ts +376 -376
- package/src/plugins/notification/NotificationPlugin.ts +68 -68
- package/src/plugins/notification/NotificationPluginTypes.ts +13 -13
- package/src/plugins/notification/NotificationService.ts +25 -25
- package/src/plugins/notification/actionHandlers/index.ts +3 -3
- package/src/plugins/notification/models/Notification.ts +60 -60
- package/src/plugins/notification/models/index.ts +3 -3
- package/src/plugins/notification/routes/index.ts +1 -1
- package/src/plugins/routeManage/RouteManagePlugin.ts +64 -64
- package/src/plugins/routeManage/actionHandlers/httpProxy.ts +13 -13
- package/src/plugins/routeManage/actionHandlers/mock.ts +28 -28
- package/src/plugins/sequence/SequencePlugin.ts +146 -146
- package/src/plugins/sequence/SequencePluginTypes.ts +69 -69
- package/src/plugins/sequence/SequenceService.ts +92 -92
- 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 +90 -90
- package/src/plugins/sequence/segments/dayOfMonth.ts +19 -19
- package/src/plugins/sequence/segments/index.ts +9 -9
- package/src/plugins/sequence/segments/literal.ts +16 -16
- package/src/plugins/sequence/segments/month.ts +19 -19
- package/src/plugins/sequence/segments/parameter.ts +20 -20
- package/src/plugins/sequence/segments/year.ts +19 -19
- package/src/plugins/serverOperation/ServerOperationPlugin.ts +93 -93
- package/src/plugins/serverOperation/ServerOperationPluginTypes.ts +25 -25
- package/src/plugins/serverOperation/actionHandlers/index.ts +4 -4
- package/src/plugins/serverOperation/actionHandlers/runServerOperation.ts +20 -20
- package/src/plugins/setting/SettingPlugin.ts +68 -68
- package/src/plugins/setting/SettingPluginTypes.ts +37 -37
- package/src/plugins/setting/SettingService.ts +222 -222
- 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 +48 -48
- 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 +55 -55
- 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 +196 -196
- package/src/plugins/stateMachine/StateMachinePluginTypes.ts +48 -48
- package/src/plugins/stateMachine/actionHandlers/index.ts +4 -4
- package/src/plugins/stateMachine/actionHandlers/sendStateMachineEvent.ts +54 -54
- 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/stateMachine/stateMachineHelper.ts +36 -36
- package/src/plugins/webhooks/WebhooksPlugin.ts +148 -148
- package/src/plugins/webhooks/pluginConfig.ts +75 -75
- package/src/polyfill.ts +5 -5
- package/src/proxy/mod.ts +38 -38
- package/src/proxy/types.ts +21 -21
- package/src/queryBuilder/index.ts +1 -1
- package/src/queryBuilder/queryBuilder.ts +755 -755
- package/src/server.ts +567 -556
- package/src/types/cron-job-types.ts +71 -71
- package/src/types.ts +884 -882
- package/src/utilities/accessControlUtility.ts +33 -33
- package/src/utilities/entityUtility.ts +18 -18
- package/src/utilities/errorUtility.ts +15 -15
- package/src/utilities/fsUtility.ts +137 -137
- package/src/utilities/httpUtility.ts +19 -19
- package/src/utilities/jwtUtility.ts +26 -26
- package/src/utilities/passwordUtility.ts +26 -26
- package/src/utilities/pathUtility.ts +14 -14
- package/src/utilities/timeUtility.ts +17 -17
- package/src/utilities/typeUtility.ts +15 -15
- package/tsconfig.json +19 -19
package/src/types.ts
CHANGED
|
@@ -1,882 +1,884 @@
|
|
|
1
|
-
import { ActionHandlerContext } from "./core/actionHandler";
|
|
2
|
-
import { RouteContext } from "./core/routeContext";
|
|
3
|
-
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
4
|
-
import { ColumnSelectOptions, CountRowOptions, FindRowOptions, RowFilterOptions } from "./dataAccess/dataAccessTypes";
|
|
5
|
-
|
|
6
|
-
export type RapidServerConfig = {
|
|
7
|
-
baseUrl?: string;
|
|
8
|
-
sessionCookieName: string;
|
|
9
|
-
jwtKey: string;
|
|
10
|
-
localFileStoragePath: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export interface IDatabaseConfig {
|
|
14
|
-
dbHost?: string;
|
|
15
|
-
dbPort?: number;
|
|
16
|
-
dbName?: string;
|
|
17
|
-
dbUser?: string;
|
|
18
|
-
dbPassword?: string;
|
|
19
|
-
dbDefaultSchema?: string;
|
|
20
|
-
dbPoolConnections?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type DatabaseQuery = {
|
|
24
|
-
command: string;
|
|
25
|
-
params?: unknown[] | Record<string, unknown>;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export interface IDatabaseClient {
|
|
29
|
-
release();
|
|
30
|
-
query(sql: any, params?: any): Promise<any>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface IDatabaseAccessor {
|
|
34
|
-
getClient(): Promise<IDatabaseClient>;
|
|
35
|
-
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>, client?: IDatabaseClient) => Promise<any[]>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type RunActionHandlersOptions = {
|
|
39
|
-
actions: RpdRouteActionConfig[];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export interface RunEntityActionHandlerOptions {
|
|
43
|
-
/** 模型所在的命名空间 */
|
|
44
|
-
namespace: string;
|
|
45
|
-
/** 模型Code的单数表示 */
|
|
46
|
-
singularCode: string;
|
|
47
|
-
/** 默认输入 */
|
|
48
|
-
defaultInput: Record<string, any>;
|
|
49
|
-
/** 固定输入 */
|
|
50
|
-
fixedInput: Record<string, any>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface RunQueryDatabaseHandlerOptions {
|
|
54
|
-
sql: string;
|
|
55
|
-
|
|
56
|
-
querySingle?: boolean;
|
|
57
|
-
|
|
58
|
-
/** 默认输入 */
|
|
59
|
-
defaultInput: Record<string, any>;
|
|
60
|
-
/** 固定输入 */
|
|
61
|
-
fixedInput: Record<string, any>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface RunProxyHandlerOptions {
|
|
65
|
-
/** Timeout milli seconds, default as 60000 */
|
|
66
|
-
timeout?: number;
|
|
67
|
-
/** Target url to proxy */
|
|
68
|
-
target: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface RunMockHandlerOptions {
|
|
72
|
-
/**
|
|
73
|
-
* 响应时间,毫秒
|
|
74
|
-
*/
|
|
75
|
-
responseTime?: number;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 响应状态
|
|
79
|
-
*/
|
|
80
|
-
responseStatus?: number;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 响应头
|
|
84
|
-
*/
|
|
85
|
-
responseHeaders?: Record<string, string>;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 响应体
|
|
89
|
-
*/
|
|
90
|
-
responseBody?: any;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface GetDataAccessorOptions {
|
|
94
|
-
namespace?: string;
|
|
95
|
-
singularCode: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface GetModelOptions {
|
|
99
|
-
namespace?: string;
|
|
100
|
-
singularCode: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type RpdServerEventTypes = {
|
|
104
|
-
"entity.beforeCreate": [RapidPlugin, RpdEntityBeforeCreateEventPayload, RouteContext?];
|
|
105
|
-
"entity.create": [RapidPlugin, RpdEntityCreateEventPayload, RouteContext?];
|
|
106
|
-
"entity.beforeUpdate": [RapidPlugin, RpdEntityBeforeUpdateEventPayload, RouteContext?];
|
|
107
|
-
"entity.update": [RapidPlugin, RpdEntityUpdateEventPayload, RouteContext?];
|
|
108
|
-
"entity.beforeDelete": [RapidPlugin, RpdEntityBeforeDeleteEventPayload, RouteContext?];
|
|
109
|
-
"entity.delete": [RapidPlugin, RpdEntityDeleteEventPayload, RouteContext?];
|
|
110
|
-
"entity.addRelations": [RapidPlugin, RpdEntityAddRelationsEventPayload, RouteContext?];
|
|
111
|
-
"entity.removeRelations": [RapidPlugin, RpdEntityRemoveRelationsEventPayload, RouteContext?];
|
|
112
|
-
"entity.beforeResponse": [RapidPlugin, RpdEntityBeforeResponseEventPayload, RouteContext?];
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export interface RpdEntityBeforeCreateEventPayload {
|
|
116
|
-
namespace: string;
|
|
117
|
-
modelSingularCode: string;
|
|
118
|
-
baseModelSingularCode?: string;
|
|
119
|
-
before: any;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface RpdEntityCreateEventPayload {
|
|
123
|
-
namespace: string;
|
|
124
|
-
modelSingularCode: string;
|
|
125
|
-
baseModelSingularCode?: string;
|
|
126
|
-
after: any;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface RpdEntityBeforeUpdateEventPayload {
|
|
130
|
-
namespace: string;
|
|
131
|
-
modelSingularCode: string;
|
|
132
|
-
baseModelSingularCode?: string;
|
|
133
|
-
before: any;
|
|
134
|
-
changes: any;
|
|
135
|
-
operation?: {
|
|
136
|
-
type: string;
|
|
137
|
-
};
|
|
138
|
-
stateProperties?: string[];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface RpdEntityUpdateEventPayload {
|
|
142
|
-
namespace: string;
|
|
143
|
-
modelSingularCode: string;
|
|
144
|
-
baseModelSingularCode?: string;
|
|
145
|
-
before: any;
|
|
146
|
-
after: any;
|
|
147
|
-
changes: any;
|
|
148
|
-
operation?: {
|
|
149
|
-
type: string;
|
|
150
|
-
};
|
|
151
|
-
stateProperties?: string[];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export interface RpdEntityBeforeDeleteEventPayload {
|
|
155
|
-
namespace: string;
|
|
156
|
-
modelSingularCode: string;
|
|
157
|
-
baseModelSingularCode?: string;
|
|
158
|
-
before: any;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export interface RpdEntityDeleteEventPayload {
|
|
162
|
-
namespace: string;
|
|
163
|
-
modelSingularCode: string;
|
|
164
|
-
baseModelSingularCode?: string;
|
|
165
|
-
before: any;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface RpdEntityAddRelationsEventPayload {
|
|
169
|
-
namespace: string;
|
|
170
|
-
modelSingularCode: string;
|
|
171
|
-
baseModelSingularCode?: string;
|
|
172
|
-
entity: any;
|
|
173
|
-
property: string;
|
|
174
|
-
relations: any[];
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
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
|
-
* 当 relation 为
|
|
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
|
-
|
|
409
|
-
|
|
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
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
-
|
|
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
|
-
export
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
export
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
| "
|
|
630
|
-
| "
|
|
631
|
-
| "
|
|
632
|
-
| "
|
|
633
|
-
| "
|
|
634
|
-
| "
|
|
635
|
-
| "
|
|
636
|
-
| "
|
|
637
|
-
| "
|
|
638
|
-
| "
|
|
639
|
-
| "
|
|
640
|
-
| "
|
|
641
|
-
| "
|
|
642
|
-
| "
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
export type
|
|
647
|
-
|
|
648
|
-
export type
|
|
649
|
-
|
|
650
|
-
export type
|
|
651
|
-
|
|
652
|
-
export type
|
|
653
|
-
|
|
654
|
-
export type
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
|
658
|
-
|
|
|
659
|
-
|
|
|
660
|
-
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
|
666
|
-
|
|
|
667
|
-
|
|
|
668
|
-
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
|
674
|
-
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
export type FindEntityFindOneRelationEntitiesOptions
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
| EntityWatcher<"entity.
|
|
851
|
-
| EntityWatcher<"entity.
|
|
852
|
-
| EntityWatcher<"entity.
|
|
853
|
-
| EntityWatcher<"entity.
|
|
854
|
-
| EntityWatcher<"entity.
|
|
855
|
-
| EntityWatcher<"entity.
|
|
856
|
-
| EntityWatcher<"entity.
|
|
857
|
-
| EntityWatcher<
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
export type
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1
|
+
import { ActionHandlerContext } from "./core/actionHandler";
|
|
2
|
+
import { RouteContext } from "./core/routeContext";
|
|
3
|
+
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
4
|
+
import { ColumnSelectOptions, CountRowOptions, FindRowOptions, RowFilterOptions } from "./dataAccess/dataAccessTypes";
|
|
5
|
+
|
|
6
|
+
export type RapidServerConfig = {
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
sessionCookieName: string;
|
|
9
|
+
jwtKey: string;
|
|
10
|
+
localFileStoragePath: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface IDatabaseConfig {
|
|
14
|
+
dbHost?: string;
|
|
15
|
+
dbPort?: number;
|
|
16
|
+
dbName?: string;
|
|
17
|
+
dbUser?: string;
|
|
18
|
+
dbPassword?: string;
|
|
19
|
+
dbDefaultSchema?: string;
|
|
20
|
+
dbPoolConnections?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type DatabaseQuery = {
|
|
24
|
+
command: string;
|
|
25
|
+
params?: unknown[] | Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export interface IDatabaseClient {
|
|
29
|
+
release();
|
|
30
|
+
query(sql: any, params?: any): Promise<any>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IDatabaseAccessor {
|
|
34
|
+
getClient(): Promise<IDatabaseClient>;
|
|
35
|
+
queryDatabaseObject: (sql: string, params?: unknown[] | Record<string, unknown>, client?: IDatabaseClient) => Promise<any[]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type RunActionHandlersOptions = {
|
|
39
|
+
actions: RpdRouteActionConfig[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export interface RunEntityActionHandlerOptions {
|
|
43
|
+
/** 模型所在的命名空间 */
|
|
44
|
+
namespace: string;
|
|
45
|
+
/** 模型Code的单数表示 */
|
|
46
|
+
singularCode: string;
|
|
47
|
+
/** 默认输入 */
|
|
48
|
+
defaultInput: Record<string, any>;
|
|
49
|
+
/** 固定输入 */
|
|
50
|
+
fixedInput: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RunQueryDatabaseHandlerOptions {
|
|
54
|
+
sql: string;
|
|
55
|
+
|
|
56
|
+
querySingle?: boolean;
|
|
57
|
+
|
|
58
|
+
/** 默认输入 */
|
|
59
|
+
defaultInput: Record<string, any>;
|
|
60
|
+
/** 固定输入 */
|
|
61
|
+
fixedInput: Record<string, any>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface RunProxyHandlerOptions {
|
|
65
|
+
/** Timeout milli seconds, default as 60000 */
|
|
66
|
+
timeout?: number;
|
|
67
|
+
/** Target url to proxy */
|
|
68
|
+
target: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface RunMockHandlerOptions {
|
|
72
|
+
/**
|
|
73
|
+
* 响应时间,毫秒
|
|
74
|
+
*/
|
|
75
|
+
responseTime?: number;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 响应状态
|
|
79
|
+
*/
|
|
80
|
+
responseStatus?: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 响应头
|
|
84
|
+
*/
|
|
85
|
+
responseHeaders?: Record<string, string>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 响应体
|
|
89
|
+
*/
|
|
90
|
+
responseBody?: any;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface GetDataAccessorOptions {
|
|
94
|
+
namespace?: string;
|
|
95
|
+
singularCode: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface GetModelOptions {
|
|
99
|
+
namespace?: string;
|
|
100
|
+
singularCode: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export type RpdServerEventTypes = {
|
|
104
|
+
"entity.beforeCreate": [RapidPlugin, RpdEntityBeforeCreateEventPayload, RouteContext?];
|
|
105
|
+
"entity.create": [RapidPlugin, RpdEntityCreateEventPayload, RouteContext?];
|
|
106
|
+
"entity.beforeUpdate": [RapidPlugin, RpdEntityBeforeUpdateEventPayload, RouteContext?];
|
|
107
|
+
"entity.update": [RapidPlugin, RpdEntityUpdateEventPayload, RouteContext?];
|
|
108
|
+
"entity.beforeDelete": [RapidPlugin, RpdEntityBeforeDeleteEventPayload, RouteContext?];
|
|
109
|
+
"entity.delete": [RapidPlugin, RpdEntityDeleteEventPayload, RouteContext?];
|
|
110
|
+
"entity.addRelations": [RapidPlugin, RpdEntityAddRelationsEventPayload, RouteContext?];
|
|
111
|
+
"entity.removeRelations": [RapidPlugin, RpdEntityRemoveRelationsEventPayload, RouteContext?];
|
|
112
|
+
"entity.beforeResponse": [RapidPlugin, RpdEntityBeforeResponseEventPayload, RouteContext?];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export interface RpdEntityBeforeCreateEventPayload {
|
|
116
|
+
namespace: string;
|
|
117
|
+
modelSingularCode: string;
|
|
118
|
+
baseModelSingularCode?: string;
|
|
119
|
+
before: any;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface RpdEntityCreateEventPayload {
|
|
123
|
+
namespace: string;
|
|
124
|
+
modelSingularCode: string;
|
|
125
|
+
baseModelSingularCode?: string;
|
|
126
|
+
after: any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface RpdEntityBeforeUpdateEventPayload {
|
|
130
|
+
namespace: string;
|
|
131
|
+
modelSingularCode: string;
|
|
132
|
+
baseModelSingularCode?: string;
|
|
133
|
+
before: any;
|
|
134
|
+
changes: any;
|
|
135
|
+
operation?: {
|
|
136
|
+
type: string;
|
|
137
|
+
};
|
|
138
|
+
stateProperties?: string[];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface RpdEntityUpdateEventPayload {
|
|
142
|
+
namespace: string;
|
|
143
|
+
modelSingularCode: string;
|
|
144
|
+
baseModelSingularCode?: string;
|
|
145
|
+
before: any;
|
|
146
|
+
after: any;
|
|
147
|
+
changes: any;
|
|
148
|
+
operation?: {
|
|
149
|
+
type: string;
|
|
150
|
+
};
|
|
151
|
+
stateProperties?: string[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface RpdEntityBeforeDeleteEventPayload {
|
|
155
|
+
namespace: string;
|
|
156
|
+
modelSingularCode: string;
|
|
157
|
+
baseModelSingularCode?: string;
|
|
158
|
+
before: any;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface RpdEntityDeleteEventPayload {
|
|
162
|
+
namespace: string;
|
|
163
|
+
modelSingularCode: string;
|
|
164
|
+
baseModelSingularCode?: string;
|
|
165
|
+
before: any;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface RpdEntityAddRelationsEventPayload {
|
|
169
|
+
namespace: string;
|
|
170
|
+
modelSingularCode: string;
|
|
171
|
+
baseModelSingularCode?: string;
|
|
172
|
+
entity: any;
|
|
173
|
+
property: string;
|
|
174
|
+
relations: any[];
|
|
175
|
+
relationTargetEntities: any[];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface RpdEntityRemoveRelationsEventPayload {
|
|
179
|
+
namespace: string;
|
|
180
|
+
modelSingularCode: string;
|
|
181
|
+
baseModelSingularCode?: string;
|
|
182
|
+
entity: any;
|
|
183
|
+
property: string;
|
|
184
|
+
relations: any[];
|
|
185
|
+
relationTargetEntities: any[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface RpdEntityBeforeResponseEventPayload {
|
|
189
|
+
namespace: string;
|
|
190
|
+
modelSingularCode: string;
|
|
191
|
+
baseModelSingularCode?: string;
|
|
192
|
+
entities: any[];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type EmitServerEventOptions<TEventName extends keyof RpdServerEventTypes> = {
|
|
196
|
+
eventName: TEventName;
|
|
197
|
+
payload: RpdServerEventTypes[TEventName][1];
|
|
198
|
+
sender?: RapidPlugin;
|
|
199
|
+
routeContext?: RouteContext;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export interface QuoteTableOptions {
|
|
203
|
+
schema?: string;
|
|
204
|
+
tableName: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface IQueryBuilder {
|
|
208
|
+
quoteTable: (options: QuoteTableOptions) => string;
|
|
209
|
+
quoteObject: (name: string) => string;
|
|
210
|
+
buildFiltersExpression(model: RpdDataModel, filters: RowFilterOptions[]);
|
|
211
|
+
formatValueToSqlLiteral: (value: any) => string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface RpdApplicationConfig {
|
|
215
|
+
code?: string;
|
|
216
|
+
name?: string;
|
|
217
|
+
models: RpdDataModel[];
|
|
218
|
+
dataDictionaries: RpdDataDictionary[];
|
|
219
|
+
routes: RpdRoute[];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface RpdDataModel {
|
|
223
|
+
maintainedBy?: string;
|
|
224
|
+
name: string;
|
|
225
|
+
namespace: string;
|
|
226
|
+
code?: string;
|
|
227
|
+
singularCode: string;
|
|
228
|
+
pluralCode: string;
|
|
229
|
+
schema?: string;
|
|
230
|
+
tableName: string;
|
|
231
|
+
/**
|
|
232
|
+
* Configure the singular code of base entity.
|
|
233
|
+
*/
|
|
234
|
+
base?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Configure the type of derived entity.
|
|
237
|
+
*/
|
|
238
|
+
derivedType?: string;
|
|
239
|
+
/**
|
|
240
|
+
* Configure the property code to save derived type for base entity.
|
|
241
|
+
*/
|
|
242
|
+
derivedTypePropertyCode?: string;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Indicates whether the entity is deprecated.
|
|
246
|
+
*/
|
|
247
|
+
deprecated?: boolean;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Configure the property code used to display the entity.
|
|
251
|
+
*/
|
|
252
|
+
displayPropertyCode?: string;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 默认排序方式
|
|
256
|
+
*/
|
|
257
|
+
defaultOrderBy?: FindEntityOrderByOptions[];
|
|
258
|
+
|
|
259
|
+
properties: RpdDataModelProperty[];
|
|
260
|
+
indexes?: RpdDataModelIndex[];
|
|
261
|
+
extensions?: RpdDataModelExtension[];
|
|
262
|
+
permissionPolicies?: RpdDataModelPermissionPolicies;
|
|
263
|
+
/**
|
|
264
|
+
* 是否使用软删除
|
|
265
|
+
*/
|
|
266
|
+
softDelete?: boolean;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 多语言配置
|
|
270
|
+
*/
|
|
271
|
+
i18n?: Record<string, string>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 本地化资源
|
|
275
|
+
*/
|
|
276
|
+
locales?: Record<string, RpdDataModelLocale>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 实体本地化资源配置
|
|
281
|
+
*/
|
|
282
|
+
export type RpdDataModelLocale = {
|
|
283
|
+
name: string;
|
|
284
|
+
description?: string;
|
|
285
|
+
properties?: Record<string, RpdDataModelPropertyLocale>;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export interface RpdDataModelPermissionPolicies {
|
|
289
|
+
find?: PermissionPolicy;
|
|
290
|
+
create?: PermissionPolicy;
|
|
291
|
+
update?: PermissionPolicy;
|
|
292
|
+
delete?: PermissionPolicy;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface PermissionPolicy {
|
|
296
|
+
any?: string[];
|
|
297
|
+
all?: string[];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface RpdDataModelProperty {
|
|
301
|
+
/**
|
|
302
|
+
* 表示此属性由谁来维护
|
|
303
|
+
*/
|
|
304
|
+
maintainedBy?: string;
|
|
305
|
+
/**
|
|
306
|
+
* 表示是否基础属性
|
|
307
|
+
*/
|
|
308
|
+
isBaseProperty?: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* 字段名称。可以包含中文。
|
|
311
|
+
*/
|
|
312
|
+
name: string;
|
|
313
|
+
/**
|
|
314
|
+
* 字段代码。会用于数据表列名和 API 的字段名。
|
|
315
|
+
*/
|
|
316
|
+
code: string;
|
|
317
|
+
/**
|
|
318
|
+
* 字段描述。
|
|
319
|
+
*/
|
|
320
|
+
description?: string;
|
|
321
|
+
/**
|
|
322
|
+
* 数据表列名。如果没有设置则使用 code。
|
|
323
|
+
*/
|
|
324
|
+
columnName?: string;
|
|
325
|
+
/**
|
|
326
|
+
* 字段类型。
|
|
327
|
+
*/
|
|
328
|
+
type: RpdDataPropertyTypes;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Indicates whether the property is deprecated.
|
|
332
|
+
*/
|
|
333
|
+
deprecated?: boolean;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 是否必须有值。默认为 false。
|
|
337
|
+
*/
|
|
338
|
+
required?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* 默认值。使用默认值的 SQL 表达式表示。
|
|
341
|
+
*/
|
|
342
|
+
defaultValue?: string;
|
|
343
|
+
/**
|
|
344
|
+
* 属性配置。
|
|
345
|
+
*/
|
|
346
|
+
// deno-lint-ignore no-explicit-any
|
|
347
|
+
config?: Record<string, any>;
|
|
348
|
+
/**
|
|
349
|
+
* 是否自增长。
|
|
350
|
+
*/
|
|
351
|
+
autoIncrement?: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* 字段值的最小长度。
|
|
354
|
+
*/
|
|
355
|
+
minLength?: number;
|
|
356
|
+
/**
|
|
357
|
+
* 字段值的最大长度。
|
|
358
|
+
*/
|
|
359
|
+
maxLength?: number;
|
|
360
|
+
/**
|
|
361
|
+
* 当 type 为 relation 时,设置关联实体为一个还是多个。
|
|
362
|
+
*/
|
|
363
|
+
relation?: "one" | "many";
|
|
364
|
+
/**
|
|
365
|
+
* 关联实体的singular code,不管 relation 为 one 或者 many 都需要设置。
|
|
366
|
+
*/
|
|
367
|
+
targetSingularCode?: string;
|
|
368
|
+
/**
|
|
369
|
+
* 保存关联实体类型的字段名。当设置 targetTypeColumnName 时,表示关联实体类型不固定,可以关联不同类型的实体。
|
|
370
|
+
*/
|
|
371
|
+
targetTypeColumnName?: string;
|
|
372
|
+
/**
|
|
373
|
+
* 当 relation 为 one 时,设置当前模型表中表示关联实体 id 的列名。
|
|
374
|
+
* 当 relation 为 many,并且使用关联关系表保存关联信息时,设置关联关系表中表示关联实体 id 的列名。
|
|
375
|
+
* 当 relation 为 many,并且不使用关联关系表保存关联信息时,关联实体 id 的列名默认为`id`,此时可以不设置 targetIdColumnName。
|
|
376
|
+
*/
|
|
377
|
+
targetIdColumnName?: string;
|
|
378
|
+
/**
|
|
379
|
+
* 当 relation 为 many 时,设置目标模型表或关联关系表中表示自身实体 id 的列名。
|
|
380
|
+
*/
|
|
381
|
+
selfIdColumnName?: string;
|
|
382
|
+
/**
|
|
383
|
+
* 当 relation 为 many 时,可以使用关联关系表保存关联信息,此时需要设置关联关系表的名称。
|
|
384
|
+
*/
|
|
385
|
+
linkTableName?: string;
|
|
386
|
+
/**
|
|
387
|
+
* 当设置了 linkTableName 时,可以设置关联关系表所在的 Schema。
|
|
388
|
+
*/
|
|
389
|
+
linkSchema?: string;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* 数据字典编码。当类型为option时设置
|
|
393
|
+
*/
|
|
394
|
+
dataDictionary?: string;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* 当删除实体时,针对关系属性的联动处理。
|
|
398
|
+
*/
|
|
399
|
+
entityDeletingReaction?: RpdEntityDeleteRelationPropertyReaction;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* 当设置为`true`时,仅允许在创建时设置此属性的值,不允许更新。
|
|
403
|
+
*/
|
|
404
|
+
readonly?: boolean;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* 多语言配置
|
|
408
|
+
*/
|
|
409
|
+
i18n?: Record<string, string>;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* 本地化资源
|
|
413
|
+
*/
|
|
414
|
+
locales?: Record<string, RpdDataModelPropertyLocale>;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* 实体属性本地化资源配置
|
|
419
|
+
*/
|
|
420
|
+
export type RpdDataModelPropertyLocale = {
|
|
421
|
+
name: string;
|
|
422
|
+
description?: string;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export type RpdDataPropertyTypes =
|
|
426
|
+
| "integer"
|
|
427
|
+
| "long"
|
|
428
|
+
| "float"
|
|
429
|
+
| "double"
|
|
430
|
+
| "decimal"
|
|
431
|
+
| "text"
|
|
432
|
+
| "boolean"
|
|
433
|
+
| "date"
|
|
434
|
+
| "time"
|
|
435
|
+
| "datetime"
|
|
436
|
+
| "json"
|
|
437
|
+
| "relation"
|
|
438
|
+
| "relation[]"
|
|
439
|
+
| "option"
|
|
440
|
+
| "option[]"
|
|
441
|
+
| "file"
|
|
442
|
+
| "file[]"
|
|
443
|
+
| "image"
|
|
444
|
+
| "image[]";
|
|
445
|
+
|
|
446
|
+
export type RpdEntityDeleteRelationPropertyReaction = "doNothing" | "unlink" | "cascadingDelete";
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* 数据字典
|
|
450
|
+
*/
|
|
451
|
+
export type RpdDataDictionary = {
|
|
452
|
+
/**
|
|
453
|
+
* 字典编码
|
|
454
|
+
*/
|
|
455
|
+
code: string;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* 字典名称
|
|
459
|
+
*/
|
|
460
|
+
name?: string;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* 描述
|
|
464
|
+
*/
|
|
465
|
+
description?: string;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* 字典项值类型
|
|
469
|
+
*/
|
|
470
|
+
valueType: "string" | "integer";
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* 字典级别
|
|
474
|
+
*/
|
|
475
|
+
level: "sys" | "app" | "user";
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* 字典项
|
|
479
|
+
*/
|
|
480
|
+
entries: RpdDataDictionaryEntry[];
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* 多语言配置
|
|
484
|
+
*/
|
|
485
|
+
i18n?: Record<string, string>;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* 本地化资源
|
|
489
|
+
*/
|
|
490
|
+
locales?: Record<string, RpdDataDictionaryLocale>;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Indicates whether the data dictionary is deprecated.
|
|
494
|
+
*/
|
|
495
|
+
deprecated?: boolean;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export type RpdDataDictionaryLocale = {
|
|
499
|
+
name: string;
|
|
500
|
+
description?: string;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* 数据字典项
|
|
505
|
+
*/
|
|
506
|
+
export type RpdDataDictionaryEntry = {
|
|
507
|
+
/**
|
|
508
|
+
* 名称
|
|
509
|
+
*/
|
|
510
|
+
name: string;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* 值
|
|
514
|
+
*/
|
|
515
|
+
value: string;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* 颜色
|
|
519
|
+
*/
|
|
520
|
+
color?: string;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* 图标
|
|
524
|
+
*/
|
|
525
|
+
icon?: string;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* 描述
|
|
529
|
+
*/
|
|
530
|
+
description?: string;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* 排序号
|
|
534
|
+
*/
|
|
535
|
+
orderNum: number;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* 是否禁用
|
|
539
|
+
*/
|
|
540
|
+
disabled: boolean;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* 多语言配置
|
|
544
|
+
*/
|
|
545
|
+
i18n?: Record<string, string>;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* 本地化资源
|
|
549
|
+
*/
|
|
550
|
+
locales?: Record<string, RpdDataDictionaryEntryLocale>;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Indicates whether the data dictionary entry is deprecated.
|
|
554
|
+
*/
|
|
555
|
+
deprecated?: boolean;
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* 数据字典项本地化资源配置
|
|
560
|
+
*/
|
|
561
|
+
export type RpdDataDictionaryEntryLocale = {
|
|
562
|
+
name: string;
|
|
563
|
+
description?: string;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
export interface RpdDataModelExtension {
|
|
567
|
+
code: string;
|
|
568
|
+
config: any;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export interface RpdDataModelIndex {
|
|
572
|
+
name?: string;
|
|
573
|
+
unique?: boolean;
|
|
574
|
+
properties: RpdDataModelIndexPropertyConfig[];
|
|
575
|
+
conditions?: RpdDataModelIndexOptions[];
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* 重复时的错误信息。
|
|
579
|
+
*/
|
|
580
|
+
duplicateErrorMessage?: string;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export type RpdDataModelIndexPropertyConfig =
|
|
584
|
+
| string
|
|
585
|
+
| {
|
|
586
|
+
code: string;
|
|
587
|
+
order?: "asc" | "desc";
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
export type RpdDataModelIndexOptions =
|
|
591
|
+
| FindEntityRelationalFilterOptions
|
|
592
|
+
| FindEntitySetFilterOptions
|
|
593
|
+
| FindEntityLogicalFilterOptions<RpdDataModelIndexOptions>
|
|
594
|
+
| FindEntityUnaryFilterOptions;
|
|
595
|
+
|
|
596
|
+
export type EventHandler<T = any> = (sender: RapidPlugin, payload: T) => void;
|
|
597
|
+
|
|
598
|
+
export interface RpdRoute {
|
|
599
|
+
name: string;
|
|
600
|
+
namespace: string;
|
|
601
|
+
code: string;
|
|
602
|
+
type: "RESTful";
|
|
603
|
+
method: RpdHttpMethod;
|
|
604
|
+
endpoint: string;
|
|
605
|
+
executeInDbTransaction?: boolean;
|
|
606
|
+
actions?: RpdRouteActionConfig[];
|
|
607
|
+
handler?: string | ((ctx: ActionHandlerContext) => Promise<void>);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export type RpdHttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
611
|
+
|
|
612
|
+
export interface RpdRouteActionConfig {
|
|
613
|
+
code: string;
|
|
614
|
+
config?: any;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export interface IRpdDataAccessor<T = any> {
|
|
618
|
+
getModel(): RpdDataModel;
|
|
619
|
+
create(entity: any, databaseClient: IDatabaseClient | null): Promise<any>;
|
|
620
|
+
updateById(id: any, entity: any, databaseClient: IDatabaseClient | null): Promise<any>;
|
|
621
|
+
find(options: FindRowOptions, databaseClient: IDatabaseClient | null): Promise<T[]>;
|
|
622
|
+
findOne(options: FindRowOptions, databaseClient: IDatabaseClient | null): Promise<T | null>;
|
|
623
|
+
findById(id: any, databaseClient: IDatabaseClient | null): Promise<T | null>;
|
|
624
|
+
count(options: CountRowOptions, databaseClient: IDatabaseClient | null): Promise<number>;
|
|
625
|
+
deleteById(id: any, databaseClient: IDatabaseClient | null): Promise<void>;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export type EntityFilterRelationalOperators =
|
|
629
|
+
| "eq"
|
|
630
|
+
| "ne"
|
|
631
|
+
| "lt"
|
|
632
|
+
| "lte"
|
|
633
|
+
| "gt"
|
|
634
|
+
| "gte"
|
|
635
|
+
| "matches"
|
|
636
|
+
| "matchesCS"
|
|
637
|
+
| "contains"
|
|
638
|
+
| "notContains"
|
|
639
|
+
| "containsCS"
|
|
640
|
+
| "notContainsCS"
|
|
641
|
+
| "startsWith"
|
|
642
|
+
| "notStartsWith"
|
|
643
|
+
| "endsWith"
|
|
644
|
+
| "notEndsWith";
|
|
645
|
+
|
|
646
|
+
export type EntityFilterArrayOperators = "arrayContains" | "arrayOverlap";
|
|
647
|
+
|
|
648
|
+
export type EntityFilterSetOperators = "in" | "notIn";
|
|
649
|
+
|
|
650
|
+
export type EntityFilterLogicalOperators = "or" | "and";
|
|
651
|
+
|
|
652
|
+
export type EntityFilterUnaryOperators = "null" | "notNull";
|
|
653
|
+
|
|
654
|
+
export type EntityFilterExistenceOperators = "exists" | "notExists";
|
|
655
|
+
|
|
656
|
+
export type EntityFilterOperators =
|
|
657
|
+
| EntityFilterRelationalOperators
|
|
658
|
+
| EntityFilterArrayOperators
|
|
659
|
+
| EntityFilterSetOperators
|
|
660
|
+
| EntityFilterLogicalOperators
|
|
661
|
+
| EntityFilterUnaryOperators
|
|
662
|
+
| EntityFilterExistenceOperators;
|
|
663
|
+
|
|
664
|
+
export type EntityFilterOptions =
|
|
665
|
+
| FindEntityRelationalFilterOptions
|
|
666
|
+
| FindEntityArrayFilterOptions
|
|
667
|
+
| FindEntitySetFilterOptions
|
|
668
|
+
| FindEntityLogicalFilterOptions
|
|
669
|
+
| FindEntityUnaryFilterOptions
|
|
670
|
+
| FindEntityExistenceFilterOptions;
|
|
671
|
+
|
|
672
|
+
export type EntityNonRelationPropertyFilterOptions =
|
|
673
|
+
| FindEntityRelationalFilterOptions
|
|
674
|
+
| FindEntityArrayFilterOptions
|
|
675
|
+
| FindEntitySetFilterOptions
|
|
676
|
+
| FindEntityUnaryFilterOptions;
|
|
677
|
+
|
|
678
|
+
export interface FindEntityOptions {
|
|
679
|
+
routeContext?: RouteContext;
|
|
680
|
+
filters?: EntityFilterOptions[];
|
|
681
|
+
orderBy?: FindEntityOrderByOptions[];
|
|
682
|
+
pagination?: FindEntityPaginationOptions;
|
|
683
|
+
properties?: string[];
|
|
684
|
+
relations?: Record<string, FindEntityFindRelationEntitiesOptions>;
|
|
685
|
+
extraColumnsToSelect?: ColumnSelectOptions[];
|
|
686
|
+
keepNonPropertyFields?: boolean;
|
|
687
|
+
/**
|
|
688
|
+
* 是否包含已经软删除的实体
|
|
689
|
+
*/
|
|
690
|
+
includingSoftDeleted?: boolean;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export interface FindEntityByIdOptions {
|
|
694
|
+
routeContext?: RouteContext;
|
|
695
|
+
id: any;
|
|
696
|
+
properties?: string[];
|
|
697
|
+
relations?: Record<string, FindEntityFindRelationEntitiesOptions>;
|
|
698
|
+
keepNonPropertyFields?: boolean;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface FindEntityRelationalFilterOptions {
|
|
702
|
+
field: string;
|
|
703
|
+
operator: EntityFilterRelationalOperators;
|
|
704
|
+
value: any;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export interface FindEntityArrayFilterOptions {
|
|
708
|
+
field: string;
|
|
709
|
+
operator: EntityFilterArrayOperators;
|
|
710
|
+
value: any[];
|
|
711
|
+
itemType?: string;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export interface FindEntitySetFilterOptions {
|
|
715
|
+
field: string;
|
|
716
|
+
operator: EntityFilterSetOperators;
|
|
717
|
+
value: any[];
|
|
718
|
+
itemType?: string;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
export interface FindEntityLogicalFilterOptions<TFilter = EntityFilterOptions> {
|
|
722
|
+
operator: EntityFilterLogicalOperators;
|
|
723
|
+
filters: TFilter[];
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export interface FindEntityUnaryFilterOptions {
|
|
727
|
+
field: string;
|
|
728
|
+
operator: EntityFilterUnaryOperators;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export interface FindEntityExistenceFilterOptions {
|
|
732
|
+
field: string;
|
|
733
|
+
operator: EntityFilterExistenceOperators;
|
|
734
|
+
filters: EntityFilterOptions[];
|
|
735
|
+
includingSoftDeleted?: boolean;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export interface FindEntityPaginationOptions {
|
|
739
|
+
offset: number;
|
|
740
|
+
limit: number;
|
|
741
|
+
withoutTotal?: boolean;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
export type FindEntityFindRelationEntitiesOptions = FindEntityFindOneRelationEntitiesOptions | FindEntityFindManyRelationEntitiesOptions;
|
|
745
|
+
|
|
746
|
+
export type FindEntityFindOneRelationEntitiesOptions =
|
|
747
|
+
| true
|
|
748
|
+
| {
|
|
749
|
+
properties?: string[];
|
|
750
|
+
relations?: Record<string, FindEntityFindRelationEntitiesOptions>;
|
|
751
|
+
keepNonPropertyFields?: boolean;
|
|
752
|
+
includingSoftDeleted?: boolean;
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
export type FindEntityFindManyRelationEntitiesOptions =
|
|
756
|
+
| true
|
|
757
|
+
| {
|
|
758
|
+
properties?: string[];
|
|
759
|
+
relations?: Record<string, FindEntityFindRelationEntitiesOptions>;
|
|
760
|
+
filters?: EntityFilterOptions[];
|
|
761
|
+
orderBy?: FindEntityOrderByOptions[];
|
|
762
|
+
pagination?: FindEntityPaginationOptions;
|
|
763
|
+
keepNonPropertyFields?: boolean;
|
|
764
|
+
includingSoftDeleted?: boolean;
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
export interface FindEntityOrderByOptions {
|
|
768
|
+
field: string;
|
|
769
|
+
desc?: boolean;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
export interface CountEntityOptions {
|
|
773
|
+
routeContext?: RouteContext;
|
|
774
|
+
filters?: EntityFilterOptions[];
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
export interface CountEntityResult {
|
|
778
|
+
count: number;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
export interface DeleteEntityByIdOptions {
|
|
782
|
+
routeContext?: RouteContext;
|
|
783
|
+
id: any;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export interface CreateEntityOptions {
|
|
787
|
+
routeContext?: RouteContext;
|
|
788
|
+
entity: any;
|
|
789
|
+
postponeUniquenessCheck?: boolean;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
export interface UpdateEntityOptions {
|
|
793
|
+
routeContext?: RouteContext;
|
|
794
|
+
filters?: EntityFilterOptions[];
|
|
795
|
+
entity: any;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
export interface UpdateEntityByIdOptions {
|
|
799
|
+
routeContext?: RouteContext;
|
|
800
|
+
id: any;
|
|
801
|
+
entityToSave: any;
|
|
802
|
+
operation?: {
|
|
803
|
+
type: string;
|
|
804
|
+
};
|
|
805
|
+
/**
|
|
806
|
+
* 指定需要更新那几个状态属性(配置了`config.stateMachine`的属性)。当不指定时默认更新全部状态属性。
|
|
807
|
+
*/
|
|
808
|
+
stateProperties?: string[];
|
|
809
|
+
postponeUniquenessCheck?: boolean;
|
|
810
|
+
/**
|
|
811
|
+
* 指定需要更新关联对象的哪些属性。更新实体时,会创建关联对象,但是默认不更新关联对象的属性。
|
|
812
|
+
*/
|
|
813
|
+
relationPropertiesToUpdate?: Record<string, UpdateRelationPropertyOptions>;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
export type UpdateRelationPropertyOptions =
|
|
817
|
+
| true
|
|
818
|
+
| {
|
|
819
|
+
// TODO: impl savingMode 'patch'
|
|
820
|
+
// savingMode?: "overwrite" | "patch";
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* 当需移除关系时是删除关联实体,还是取消关联。默认为`delete`。此配置仅对没有配置`linkTableName`的属性有效。
|
|
824
|
+
*/
|
|
825
|
+
relationRemoveMode?: "unlink" | "delete";
|
|
826
|
+
propertiesToUpdate?: string[];
|
|
827
|
+
relationPropertiesToUpdate?: Record<string, UpdateRelationPropertyOptions>;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
export interface DeleteEntityOptions {
|
|
831
|
+
routeContext?: RouteContext;
|
|
832
|
+
filters?: EntityFilterOptions[];
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
export interface AddEntityRelationsOptions {
|
|
836
|
+
routeContext?: RouteContext;
|
|
837
|
+
id: number;
|
|
838
|
+
property: string;
|
|
839
|
+
relations: { id?: number; [k: string]: any }[];
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export interface RemoveEntityRelationsOptions {
|
|
843
|
+
routeContext?: RouteContext;
|
|
844
|
+
id: number;
|
|
845
|
+
property: string;
|
|
846
|
+
relations: { id?: number; [k: string]: any }[];
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export type EntityWatcherType =
|
|
850
|
+
| EntityWatcher<"entity.beforeCreate">
|
|
851
|
+
| EntityWatcher<"entity.create">
|
|
852
|
+
| EntityWatcher<"entity.beforeUpdate">
|
|
853
|
+
| EntityWatcher<"entity.update">
|
|
854
|
+
| EntityWatcher<"entity.beforeDelete">
|
|
855
|
+
| EntityWatcher<"entity.delete">
|
|
856
|
+
| EntityWatcher<"entity.addRelations">
|
|
857
|
+
| EntityWatcher<"entity.removeRelations">
|
|
858
|
+
| EntityWatcher<"entity.beforeResponse">
|
|
859
|
+
| EntityWatcher<any>;
|
|
860
|
+
|
|
861
|
+
export interface EntityWatcher<TEventName extends keyof RpdServerEventTypes> {
|
|
862
|
+
eventName: TEventName;
|
|
863
|
+
modelSingularCode: string;
|
|
864
|
+
handler: EntityWatchHandler<TEventName>;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
export type EntityWatchHandler<TEventName extends keyof RpdServerEventTypes> = (ctx: EntityWatchHandlerContext<TEventName>) => Promise<void>;
|
|
868
|
+
|
|
869
|
+
export type EntityWatchHandlerContext<TEventName extends keyof RpdServerEventTypes> = {
|
|
870
|
+
server: IRpdServer;
|
|
871
|
+
payload: RpdServerEventTypes[TEventName][1];
|
|
872
|
+
routerContext: RouteContext;
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
export interface EntityWatchPluginInitOptions {
|
|
876
|
+
watchers: EntityWatcherType[];
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
export interface LocaleString {
|
|
880
|
+
namespace: string;
|
|
881
|
+
name: string;
|
|
882
|
+
lingual: string;
|
|
883
|
+
text?: string;
|
|
884
|
+
}
|