@ruiapp/rapid-core 0.11.7 → 0.12.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/CHANGELOG.md +11 -11
- package/dist/index.js +54 -21
- package/dist/types.d.ts +32 -0
- package/package.json +1 -1
- package/rollup.config.js +16 -16
- package/src/bootstrapApplicationConfig.ts +919 -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 -202
- 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 -129
- package/src/core/server.ts +161 -161
- 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 +2050 -2031
- 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 -47
- 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 -567
- package/src/types/cron-job-types.ts +71 -71
- package/src/types.ts +919 -884
- 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/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# @ruiapp/rapid-core
|
|
2
|
-
|
|
3
|
-
## 0.7.0
|
|
4
|
-
|
|
5
|
-
- feature: added server.registerCronJob to allow plugins register cron jobs.
|
|
6
|
-
|
|
7
|
-
## 0.2.4
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- 146a99d: add between filterMode, range is deprecated
|
|
1
|
+
# @ruiapp/rapid-core
|
|
2
|
+
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
- feature: added server.registerCronJob to allow plugins register cron jobs.
|
|
6
|
+
|
|
7
|
+
## 0.2.4
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 146a99d: add between filterMode, range is deprecated
|
package/dist/index.js
CHANGED
|
@@ -1798,6 +1798,21 @@ var bootstrapApplicationConfig = {
|
|
|
1798
1798
|
required: true,
|
|
1799
1799
|
defaultValue: "false",
|
|
1800
1800
|
},
|
|
1801
|
+
{
|
|
1802
|
+
name: "enableEventLog",
|
|
1803
|
+
code: "enableEventLog",
|
|
1804
|
+
columnName: "enable_event_log",
|
|
1805
|
+
type: "boolean",
|
|
1806
|
+
required: true,
|
|
1807
|
+
defaultValue: "false",
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
name: "eventTypePolicy",
|
|
1811
|
+
code: "eventTypePolicy",
|
|
1812
|
+
columnName: "event_type_policy",
|
|
1813
|
+
type: "json",
|
|
1814
|
+
required: false,
|
|
1815
|
+
},
|
|
1801
1816
|
{
|
|
1802
1817
|
name: "defaultOrderBy",
|
|
1803
1818
|
code: "defaultOrderBy",
|
|
@@ -2975,6 +2990,17 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2975
2990
|
else {
|
|
2976
2991
|
propertiesToSelect = getEntityPropertiesIncludingBase(server, model).filter((property) => options.properties.includes(property.code) || relationPropertyCodes.includes(property.code));
|
|
2977
2992
|
}
|
|
2993
|
+
const isEntitySoftDeleteEnabled = baseModel ? baseModel.softDelete || model.softDelete : model.softDelete;
|
|
2994
|
+
if (options.includingSoftDeleted && isEntitySoftDeleteEnabled) {
|
|
2995
|
+
const deletedAtProp = getEntityPropertyByCode(server, model, "deletedAt");
|
|
2996
|
+
if (deletedAtProp && !lodash.find(propertiesToSelect, (p) => p.code === "deletedAt")) {
|
|
2997
|
+
propertiesToSelect.push(deletedAtProp);
|
|
2998
|
+
}
|
|
2999
|
+
const deletedByProp = getEntityPropertyByCode(server, model, "deletedBy");
|
|
3000
|
+
if (deletedByProp && !lodash.find(propertiesToSelect, (p) => p.code === "deletedBy")) {
|
|
3001
|
+
propertiesToSelect.push(deletedByProp);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
2978
3004
|
const columnsToSelect = [];
|
|
2979
3005
|
const relationPropertiesToSelect = [];
|
|
2980
3006
|
lodash.forEach(propertiesToSelect, (property) => {
|
|
@@ -3424,8 +3450,8 @@ async function findManyRelationLinksViaLinkTable(options) {
|
|
|
3424
3450
|
const command = `SELECT * FROM ${server.queryBuilder.quoteTable({
|
|
3425
3451
|
schema: relationProperty.linkSchema,
|
|
3426
3452
|
tableName: relationProperty.linkTableName,
|
|
3427
|
-
})} WHERE ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = ANY($1::int[])
|
|
3428
|
-
ORDER BY id
|
|
3453
|
+
})} WHERE ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = ANY($1::int[])
|
|
3454
|
+
ORDER BY id
|
|
3429
3455
|
`;
|
|
3430
3456
|
const params = [mainEntityIds];
|
|
3431
3457
|
const relationLinks = await server.queryDatabaseObject(command, params, routeContext?.getDbTransactionClient());
|
|
@@ -3444,6 +3470,7 @@ async function findManyRelationLinksViaLinkTable(options) {
|
|
|
3444
3470
|
},
|
|
3445
3471
|
],
|
|
3446
3472
|
keepNonPropertyFields: true,
|
|
3473
|
+
includingSoftDeleted: true,
|
|
3447
3474
|
};
|
|
3448
3475
|
if (selectRelationOptions) {
|
|
3449
3476
|
if (typeof selectRelationOptions !== "boolean") {
|
|
@@ -3497,6 +3524,7 @@ async function findManyRelatedEntitiesViaIdPropertyCode(options) {
|
|
|
3497
3524
|
],
|
|
3498
3525
|
extraColumnsToSelect: [relationProperty.selfIdColumnName],
|
|
3499
3526
|
keepNonPropertyFields: true,
|
|
3527
|
+
includingSoftDeleted: true,
|
|
3500
3528
|
};
|
|
3501
3529
|
if (selectRelationOptions) {
|
|
3502
3530
|
if (typeof selectRelationOptions !== "boolean") {
|
|
@@ -3540,6 +3568,7 @@ async function findOneRelatedEntitiesViaIdPropertyCode(options) {
|
|
|
3540
3568
|
},
|
|
3541
3569
|
],
|
|
3542
3570
|
keepNonPropertyFields: true,
|
|
3571
|
+
includingSoftDeleted: true,
|
|
3543
3572
|
};
|
|
3544
3573
|
if (selectRelationOptions) {
|
|
3545
3574
|
if (typeof selectRelationOptions !== "boolean") {
|
|
@@ -4078,7 +4107,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
4078
4107
|
await server.queryDatabaseObject(`DELETE FROM ${server.queryBuilder.quoteTable({
|
|
4079
4108
|
schema: property.linkSchema,
|
|
4080
4109
|
tableName: property.linkTableName,
|
|
4081
|
-
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
4110
|
+
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
4082
4111
|
AND ${server.queryBuilder.quoteObject(property.targetIdColumnName)} <> ALL($2::int[])`, [id, targetIdsToKeep], routeContext?.getDbTransactionClient());
|
|
4083
4112
|
}
|
|
4084
4113
|
else {
|
|
@@ -4107,8 +4136,8 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
4107
4136
|
await server.queryDatabaseObject(`UPDATE ${server.queryBuilder.quoteTable({
|
|
4108
4137
|
schema: relationModel.schema,
|
|
4109
4138
|
tableName: relationModel.tableName,
|
|
4110
|
-
})}
|
|
4111
|
-
SET ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = null
|
|
4139
|
+
})}
|
|
4140
|
+
SET ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = null
|
|
4112
4141
|
WHERE id = ANY($1::int[])`, [targetIdsToRemove], routeContext?.getDbTransactionClient());
|
|
4113
4142
|
}
|
|
4114
4143
|
else {
|
|
@@ -4406,7 +4435,7 @@ async function deleteEntityById(server, dataAccessor, options, plugin) {
|
|
|
4406
4435
|
await server.queryDatabaseObject(`DELETE FROM ${server.queryBuilder.quoteTable({
|
|
4407
4436
|
schema: relationProperty.linkSchema,
|
|
4408
4437
|
tableName: relationProperty.linkTableName,
|
|
4409
|
-
})}
|
|
4438
|
+
})}
|
|
4410
4439
|
WHERE ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = $1`, [id], routeContext?.getDbTransactionClient());
|
|
4411
4440
|
}
|
|
4412
4441
|
else {
|
|
@@ -4416,8 +4445,8 @@ async function deleteEntityById(server, dataAccessor, options, plugin) {
|
|
|
4416
4445
|
await server.queryDatabaseObject(`UPDATE ${server.queryBuilder.quoteTable({
|
|
4417
4446
|
schema: relationModel.schema,
|
|
4418
4447
|
tableName: relationModel.tableName,
|
|
4419
|
-
})}
|
|
4420
|
-
SET ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = null
|
|
4448
|
+
})}
|
|
4449
|
+
SET ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = null
|
|
4421
4450
|
WHERE ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = $1`, [id], routeContext?.getDbTransactionClient());
|
|
4422
4451
|
}
|
|
4423
4452
|
}
|
|
@@ -4483,8 +4512,12 @@ class EntityManager {
|
|
|
4483
4512
|
singularCode: model.base,
|
|
4484
4513
|
});
|
|
4485
4514
|
}
|
|
4515
|
+
let entityFilters = options.filters;
|
|
4516
|
+
if (!options.includingSoftDeleted) {
|
|
4517
|
+
entityFilters = tryAddUndeletedEntityFilter(model, baseModel, entityFilters);
|
|
4518
|
+
}
|
|
4486
4519
|
const countRowOptions = {
|
|
4487
|
-
filters: await convertEntityFiltersToRowFilters(routeContext, this.#server, model, baseModel,
|
|
4520
|
+
filters: await convertEntityFiltersToRowFilters(routeContext, this.#server, model, baseModel, entityFilters),
|
|
4488
4521
|
};
|
|
4489
4522
|
return await this.#dataAccessor.count(countRowOptions, routeContext?.getDbTransactionClient());
|
|
4490
4523
|
}
|
|
@@ -4517,11 +4550,11 @@ class EntityManager {
|
|
|
4517
4550
|
const command = `INSERT INTO ${queryBuilder.quoteTable({
|
|
4518
4551
|
schema: relationProperty.linkSchema,
|
|
4519
4552
|
tableName: relationProperty.linkTableName,
|
|
4520
|
-
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
4521
|
-
SELECT $1, $2 WHERE NOT EXISTS (
|
|
4522
|
-
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
4523
|
-
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
4524
|
-
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
4553
|
+
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
4554
|
+
SELECT $1, $2 WHERE NOT EXISTS (
|
|
4555
|
+
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
4556
|
+
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
4557
|
+
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
4525
4558
|
)`;
|
|
4526
4559
|
const targetId = relation[relationProperty.targetIdColumnName] || relation.id;
|
|
4527
4560
|
const params = [selfId, targetId];
|
|
@@ -4588,7 +4621,7 @@ class EntityManager {
|
|
|
4588
4621
|
const relationTargetEntities = [];
|
|
4589
4622
|
if (relationProperty.linkTableName) {
|
|
4590
4623
|
for (const relation of relations) {
|
|
4591
|
-
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
4624
|
+
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
4592
4625
|
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2;`;
|
|
4593
4626
|
const params = [id, relation.id];
|
|
4594
4627
|
const result = await server.queryDatabaseObject(command, params, routeContext?.getDbTransactionClient());
|
|
@@ -5965,9 +5998,9 @@ class MetaService {
|
|
|
5965
5998
|
await server.tryQueryDatabaseObject(`COMMENT ON TABLE ${queryBuilder.quoteTable(model)} IS ${queryBuilder.formatValueToSqlLiteral(model.name)};`, []);
|
|
5966
5999
|
}
|
|
5967
6000
|
}
|
|
5968
|
-
const sqlQueryColumnInformations = `SELECT c.table_schema, c.table_name, c.column_name, c.ordinal_position, d.description, c.data_type, c.udt_name, c.is_nullable, c.column_default, c.character_maximum_length, c.numeric_precision, c.numeric_scale
|
|
5969
|
-
FROM information_schema.columns c
|
|
5970
|
-
INNER JOIN pg_catalog.pg_statio_all_tables st ON (st.schemaname = c.table_schema and st.relname = c.table_name)
|
|
6001
|
+
const sqlQueryColumnInformations = `SELECT c.table_schema, c.table_name, c.column_name, c.ordinal_position, d.description, c.data_type, c.udt_name, c.is_nullable, c.column_default, c.character_maximum_length, c.numeric_precision, c.numeric_scale
|
|
6002
|
+
FROM information_schema.columns c
|
|
6003
|
+
INNER JOIN pg_catalog.pg_statio_all_tables st ON (st.schemaname = c.table_schema and st.relname = c.table_name)
|
|
5971
6004
|
LEFT JOIN pg_catalog.pg_description d ON (d.objoid = st.relid and d.objsubid = c.ordinal_position);`;
|
|
5972
6005
|
const columnsInDb = await server.queryDatabaseObject(sqlQueryColumnInformations, []);
|
|
5973
6006
|
for (const model of applicationConfig.models) {
|
|
@@ -10196,9 +10229,9 @@ class EntityAccessControlPlugin {
|
|
|
10196
10229
|
if (!userId) {
|
|
10197
10230
|
return;
|
|
10198
10231
|
}
|
|
10199
|
-
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
10200
|
-
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
10201
|
-
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
10232
|
+
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
10233
|
+
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
10234
|
+
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
10202
10235
|
where ru.user_id = $1;`, [userId]);
|
|
10203
10236
|
routeContext.state.allowedActions = actions.map((item) => item.code);
|
|
10204
10237
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -228,6 +228,14 @@ export interface RpdDataModel {
|
|
|
228
228
|
* 是否使用软删除
|
|
229
229
|
*/
|
|
230
230
|
softDelete?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* 是否启用事件日志
|
|
233
|
+
*/
|
|
234
|
+
enableEventLog?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* 事件类型策略
|
|
237
|
+
*/
|
|
238
|
+
eventTypePolicy?: RapidEntityEventTypePolicy;
|
|
231
239
|
/**
|
|
232
240
|
* 多语言配置
|
|
233
241
|
*/
|
|
@@ -255,6 +263,29 @@ export interface PermissionPolicy {
|
|
|
255
263
|
any?: string[];
|
|
256
264
|
all?: string[];
|
|
257
265
|
}
|
|
266
|
+
export interface RapidEntityEventTypePolicy {
|
|
267
|
+
/**
|
|
268
|
+
* 区分事件类型属性code
|
|
269
|
+
*/
|
|
270
|
+
propertyCode?: string;
|
|
271
|
+
/**
|
|
272
|
+
* 属性值事件类型
|
|
273
|
+
*/
|
|
274
|
+
eventTypes?: {
|
|
275
|
+
/**
|
|
276
|
+
* 属性值
|
|
277
|
+
*/
|
|
278
|
+
propertyValue: string;
|
|
279
|
+
/**
|
|
280
|
+
* 事件code前缀 默认取 propertyValue 的值
|
|
281
|
+
*/
|
|
282
|
+
eventTypeCodePrefix?: string;
|
|
283
|
+
/**
|
|
284
|
+
* 属性值名称 区分定义事件类型名称
|
|
285
|
+
*/
|
|
286
|
+
name: string;
|
|
287
|
+
}[];
|
|
288
|
+
}
|
|
258
289
|
export interface RpdDataModelProperty {
|
|
259
290
|
/**
|
|
260
291
|
* 表示此属性由谁来维护
|
|
@@ -604,6 +635,7 @@ export interface FindEntityOrderByOptions {
|
|
|
604
635
|
export interface CountEntityOptions {
|
|
605
636
|
routeContext?: RouteContext;
|
|
606
637
|
filters?: EntityFilterOptions[];
|
|
638
|
+
includingSoftDeleted?: boolean;
|
|
607
639
|
}
|
|
608
640
|
export interface CountEntityResult {
|
|
609
641
|
count: number;
|
package/package.json
CHANGED
package/rollup.config.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import typescript from "rollup-plugin-typescript2";
|
|
2
|
-
import tscAlias from "rollup-plugin-tsc-alias";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
input: ["src/index.ts"],
|
|
6
|
-
output: [
|
|
7
|
-
{
|
|
8
|
-
dir: "dist",
|
|
9
|
-
entryFileNames: "[name].js",
|
|
10
|
-
format: "cjs",
|
|
11
|
-
exports: "named",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
plugins: [typescript(), tscAlias()],
|
|
15
|
-
external: [],
|
|
16
|
-
};
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
import tscAlias from "rollup-plugin-tsc-alias";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
input: ["src/index.ts"],
|
|
6
|
+
output: [
|
|
7
|
+
{
|
|
8
|
+
dir: "dist",
|
|
9
|
+
entryFileNames: "[name].js",
|
|
10
|
+
format: "cjs",
|
|
11
|
+
exports: "named",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
plugins: [typescript(), tscAlias()],
|
|
15
|
+
external: [],
|
|
16
|
+
};
|