@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
|
@@ -5,6 +5,7 @@ declare const _default: {
|
|
|
5
5
|
maintainedBy: string;
|
|
6
6
|
namespace: string;
|
|
7
7
|
name: string;
|
|
8
|
+
code: string;
|
|
8
9
|
singularCode: string;
|
|
9
10
|
pluralCode: string;
|
|
10
11
|
schema: string;
|
|
@@ -77,6 +78,7 @@ declare const _default: {
|
|
|
77
78
|
maintainedBy: string;
|
|
78
79
|
namespace: string;
|
|
79
80
|
name: string;
|
|
81
|
+
code: string;
|
|
80
82
|
singularCode: string;
|
|
81
83
|
pluralCode: string;
|
|
82
84
|
schema: string;
|
|
@@ -170,6 +172,7 @@ declare const _default: {
|
|
|
170
172
|
maintainedBy: string;
|
|
171
173
|
namespace: string;
|
|
172
174
|
name: string;
|
|
175
|
+
code: string;
|
|
173
176
|
singularCode: string;
|
|
174
177
|
pluralCode: string;
|
|
175
178
|
schema: string;
|
|
@@ -246,6 +249,7 @@ declare const _default: {
|
|
|
246
249
|
maintainedBy: string;
|
|
247
250
|
namespace: string;
|
|
248
251
|
name: string;
|
|
252
|
+
code: string;
|
|
249
253
|
singularCode: string;
|
|
250
254
|
pluralCode: string;
|
|
251
255
|
schema: string;
|
|
@@ -322,6 +326,7 @@ declare const _default: {
|
|
|
322
326
|
maintainedBy: string;
|
|
323
327
|
namespace: string;
|
|
324
328
|
name: string;
|
|
329
|
+
code: string;
|
|
325
330
|
singularCode: string;
|
|
326
331
|
pluralCode: string;
|
|
327
332
|
schema: string;
|
|
@@ -357,6 +362,7 @@ declare const _default: {
|
|
|
357
362
|
})[];
|
|
358
363
|
indexes?: undefined;
|
|
359
364
|
})[];
|
|
365
|
+
dataDictionaries: any[];
|
|
360
366
|
routes: {
|
|
361
367
|
namespace: string;
|
|
362
368
|
name: string;
|
|
@@ -5,6 +5,6 @@ export declare function isOneRelationProperty(property: RpdDataModelProperty): b
|
|
|
5
5
|
export declare function isManyRelationProperty(property: RpdDataModelProperty): boolean;
|
|
6
6
|
export declare function getEntityProperties(server: IRpdServer, model: RpdDataModel): RpdDataModelProperty[];
|
|
7
7
|
export declare function getEntityPropertiesIncludingBase(server: IRpdServer, model: RpdDataModel): RpdDataModelProperty[];
|
|
8
|
-
export declare function getEntityPropertyByCode(server: IRpdServer, model: RpdDataModel, propertyCode: string): RpdDataModelProperty;
|
|
9
|
-
export declare function getEntityProperty(server: IRpdServer, model: RpdDataModel, predicate: (item: RpdDataModelProperty) => boolean): RpdDataModelProperty;
|
|
10
|
-
export declare function getEntityPropertyByFieldName(server: IRpdServer, model: RpdDataModel, fieldName: string): RpdDataModelProperty;
|
|
8
|
+
export declare function getEntityPropertyByCode(server: IRpdServer, model: RpdDataModel, propertyCode: string): RpdDataModelProperty | undefined;
|
|
9
|
+
export declare function getEntityProperty(server: IRpdServer, model: RpdDataModel, predicate: (item: RpdDataModelProperty) => boolean): RpdDataModelProperty | undefined;
|
|
10
|
+
export declare function getEntityPropertyByFieldName(server: IRpdServer, model: RpdDataModel, fieldName: string): RpdDataModelProperty | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1407,6 +1407,7 @@ var bootstrapApplicationConfig = {
|
|
|
1407
1407
|
maintainedBy: "metaManager",
|
|
1408
1408
|
namespace: "meta",
|
|
1409
1409
|
name: "model",
|
|
1410
|
+
code: "Model",
|
|
1410
1411
|
singularCode: "model",
|
|
1411
1412
|
pluralCode: "models",
|
|
1412
1413
|
schema: "public",
|
|
@@ -1434,6 +1435,13 @@ var bootstrapApplicationConfig = {
|
|
|
1434
1435
|
type: "text",
|
|
1435
1436
|
required: false,
|
|
1436
1437
|
},
|
|
1438
|
+
{
|
|
1439
|
+
name: "code",
|
|
1440
|
+
code: "code",
|
|
1441
|
+
columnName: "code",
|
|
1442
|
+
type: "text",
|
|
1443
|
+
required: false,
|
|
1444
|
+
},
|
|
1437
1445
|
{
|
|
1438
1446
|
name: "singular code",
|
|
1439
1447
|
code: "singularCode",
|
|
@@ -1547,6 +1555,7 @@ var bootstrapApplicationConfig = {
|
|
|
1547
1555
|
maintainedBy: "metaManager",
|
|
1548
1556
|
namespace: "meta",
|
|
1549
1557
|
name: "property",
|
|
1558
|
+
code: "Property",
|
|
1550
1559
|
singularCode: "property",
|
|
1551
1560
|
pluralCode: "properties",
|
|
1552
1561
|
schema: "public",
|
|
@@ -1717,6 +1726,7 @@ var bootstrapApplicationConfig = {
|
|
|
1717
1726
|
maintainedBy: "metaManager",
|
|
1718
1727
|
namespace: "meta",
|
|
1719
1728
|
name: "data dictionary",
|
|
1729
|
+
code: "DataDictionary",
|
|
1720
1730
|
singularCode: "data_dictionary",
|
|
1721
1731
|
pluralCode: "data_dictionaries",
|
|
1722
1732
|
schema: "public",
|
|
@@ -1808,6 +1818,7 @@ var bootstrapApplicationConfig = {
|
|
|
1808
1818
|
maintainedBy: "metaManager",
|
|
1809
1819
|
namespace: "meta",
|
|
1810
1820
|
name: "data dictionary entry",
|
|
1821
|
+
code: "DataDictionaryEntry",
|
|
1811
1822
|
singularCode: "data_dictionary_entry",
|
|
1812
1823
|
pluralCode: "data_dictionary_entries",
|
|
1813
1824
|
schema: "public",
|
|
@@ -1885,6 +1896,7 @@ var bootstrapApplicationConfig = {
|
|
|
1885
1896
|
maintainedBy: "dataManager",
|
|
1886
1897
|
namespace: "meta",
|
|
1887
1898
|
name: "routes",
|
|
1899
|
+
code: "Route",
|
|
1888
1900
|
singularCode: "route",
|
|
1889
1901
|
pluralCode: "routes",
|
|
1890
1902
|
schema: "public",
|
|
@@ -1957,6 +1969,7 @@ var bootstrapApplicationConfig = {
|
|
|
1957
1969
|
],
|
|
1958
1970
|
},
|
|
1959
1971
|
],
|
|
1972
|
+
dataDictionaries: [],
|
|
1960
1973
|
routes: [
|
|
1961
1974
|
{
|
|
1962
1975
|
namespace: "meta",
|
|
@@ -2322,10 +2335,7 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2322
2335
|
let relationPropertyCodes = Object.keys(relationOptions) || [];
|
|
2323
2336
|
if (!options.properties || !options.properties.length) {
|
|
2324
2337
|
propertiesToSelect = getEntityPropertiesIncludingBase(server, model).filter((property) => {
|
|
2325
|
-
|
|
2326
|
-
throw new Error(`Property '${property}' was not found in ${model.namespace}.${model.singularCode}`);
|
|
2327
|
-
}
|
|
2328
|
-
return !options.keepNonPropertyFields || isRelationProperty(property) || relationPropertyCodes.includes(property.code);
|
|
2338
|
+
return !isRelationProperty(property) || relationPropertyCodes.includes(property.code);
|
|
2329
2339
|
});
|
|
2330
2340
|
}
|
|
2331
2341
|
else {
|
|
@@ -2334,9 +2344,6 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2334
2344
|
const columnsToSelect = [];
|
|
2335
2345
|
const relationPropertiesToSelect = [];
|
|
2336
2346
|
lodash.forEach(propertiesToSelect, (property) => {
|
|
2337
|
-
if (!property) {
|
|
2338
|
-
throw new Error(`Property '${property}' was not found in ${model.namespace}.${model.singularCode}`);
|
|
2339
|
-
}
|
|
2340
2347
|
if (isRelationProperty(property)) {
|
|
2341
2348
|
relationPropertiesToSelect.push(property);
|
|
2342
2349
|
if (property.relation === "one" && !property.linkTableName) {
|
|
@@ -2875,7 +2882,8 @@ async function createEntity(server, dataAccessor, options, plugin) {
|
|
|
2875
2882
|
lodash.keys(entity).forEach((propertyCode) => {
|
|
2876
2883
|
const property = getEntityPropertyByCode(server, model, propertyCode);
|
|
2877
2884
|
if (!property) {
|
|
2878
|
-
|
|
2885
|
+
// Unknown property
|
|
2886
|
+
return;
|
|
2879
2887
|
}
|
|
2880
2888
|
if (isRelationProperty(property)) {
|
|
2881
2889
|
if (property.relation === "many") {
|
|
@@ -3107,7 +3115,8 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3107
3115
|
lodash.keys(changes).forEach((propertyCode) => {
|
|
3108
3116
|
const property = getEntityPropertyByCode(server, model, propertyCode);
|
|
3109
3117
|
if (!property) {
|
|
3110
|
-
|
|
3118
|
+
// Unknown property
|
|
3119
|
+
return;
|
|
3111
3120
|
}
|
|
3112
3121
|
if (isRelationProperty(property)) {
|
|
3113
3122
|
if (property.relation === "many") {
|
|
@@ -3213,7 +3222,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3213
3222
|
await server.queryDatabaseObject(`DELETE FROM ${server.queryBuilder.quoteTable({
|
|
3214
3223
|
schema: property.linkSchema,
|
|
3215
3224
|
tableName: property.linkTableName,
|
|
3216
|
-
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
3225
|
+
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
3217
3226
|
AND ${server.queryBuilder.quoteObject(property.targetIdColumnName)} <> ALL($2::int[])`, [id, targetIdsToKeep]);
|
|
3218
3227
|
}
|
|
3219
3228
|
else {
|
|
@@ -3482,11 +3491,11 @@ class EntityManager {
|
|
|
3482
3491
|
const command = `INSERT INTO ${queryBuilder.quoteTable({
|
|
3483
3492
|
schema: relationProperty.linkSchema,
|
|
3484
3493
|
tableName: relationProperty.linkTableName,
|
|
3485
|
-
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
3486
|
-
SELECT $1, $2 WHERE NOT EXISTS (
|
|
3487
|
-
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
3488
|
-
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3489
|
-
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
3494
|
+
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
3495
|
+
SELECT $1, $2 WHERE NOT EXISTS (
|
|
3496
|
+
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
3497
|
+
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3498
|
+
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
3490
3499
|
)`;
|
|
3491
3500
|
const params = [id, relation.id];
|
|
3492
3501
|
await server.queryDatabaseObject(command, params);
|
|
@@ -3526,7 +3535,7 @@ class EntityManager {
|
|
|
3526
3535
|
const { queryBuilder } = server;
|
|
3527
3536
|
if (relationProperty.linkTableName) {
|
|
3528
3537
|
for (const relation of relations) {
|
|
3529
|
-
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3538
|
+
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3530
3539
|
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2;`;
|
|
3531
3540
|
const params = [id, relation.id];
|
|
3532
3541
|
await server.queryDatabaseObject(command, params);
|
|
@@ -3628,7 +3637,7 @@ class RapidServer {
|
|
|
3628
3637
|
return this.#applicationConfig;
|
|
3629
3638
|
}
|
|
3630
3639
|
appendApplicationConfig(config) {
|
|
3631
|
-
const { models, routes } = config;
|
|
3640
|
+
const { models, dataDictionaries, routes } = config;
|
|
3632
3641
|
if (models) {
|
|
3633
3642
|
for (const model of models) {
|
|
3634
3643
|
const originalModel = lodash.find(this.#applicationConfig.models, (item) => item.singularCode == model.singularCode);
|
|
@@ -3651,6 +3660,19 @@ class RapidServer {
|
|
|
3651
3660
|
}
|
|
3652
3661
|
}
|
|
3653
3662
|
}
|
|
3663
|
+
if (dataDictionaries) {
|
|
3664
|
+
for (const dataDictionary of dataDictionaries) {
|
|
3665
|
+
const originalDataDictionary = lodash.find(this.#applicationConfig.dataDictionaries, (item) => item.code == dataDictionary.code);
|
|
3666
|
+
if (originalDataDictionary) {
|
|
3667
|
+
originalDataDictionary.name = dataDictionary.name;
|
|
3668
|
+
originalDataDictionary.description = dataDictionary.description;
|
|
3669
|
+
originalDataDictionary.entries = dataDictionary.entries;
|
|
3670
|
+
}
|
|
3671
|
+
else {
|
|
3672
|
+
this.#applicationConfig.dataDictionaries.push(dataDictionary);
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3654
3676
|
if (routes) {
|
|
3655
3677
|
for (const route of routes) {
|
|
3656
3678
|
const originalRoute = lodash.find(this.#applicationConfig.routes, (item) => item.code == route.code);
|
|
@@ -4123,8 +4145,9 @@ class MetaManager {
|
|
|
4123
4145
|
const logger = server.getLogger();
|
|
4124
4146
|
try {
|
|
4125
4147
|
logger.info("Loading meta of models...");
|
|
4126
|
-
const models = await
|
|
4127
|
-
|
|
4148
|
+
const models = await listDataModels(server);
|
|
4149
|
+
const dataDictionaries = await listDataDictionaries(server);
|
|
4150
|
+
server.appendApplicationConfig({ models, dataDictionaries });
|
|
4128
4151
|
}
|
|
4129
4152
|
catch (error) {
|
|
4130
4153
|
logger.crit("Failed to load meta of models.", { error });
|
|
@@ -4184,7 +4207,7 @@ async function handleEntityDeleteEvent(server, sender, payload) {
|
|
|
4184
4207
|
}
|
|
4185
4208
|
}
|
|
4186
4209
|
}
|
|
4187
|
-
function
|
|
4210
|
+
function listDataModels(server) {
|
|
4188
4211
|
const entityManager = server.getEntityManager("model");
|
|
4189
4212
|
const model = entityManager.getModel();
|
|
4190
4213
|
const properties = getEntityPropertiesIncludingBase(server, model);
|
|
@@ -4192,6 +4215,14 @@ function listCollections(server, applicationConfig) {
|
|
|
4192
4215
|
properties: properties.map((item) => item.code),
|
|
4193
4216
|
});
|
|
4194
4217
|
}
|
|
4218
|
+
function listDataDictionaries(server) {
|
|
4219
|
+
const dataDictionaryManager = server.getEntityManager("data_dictionary");
|
|
4220
|
+
const model = dataDictionaryManager.getModel();
|
|
4221
|
+
const properties = getEntityPropertiesIncludingBase(server, model);
|
|
4222
|
+
return dataDictionaryManager.findEntities({
|
|
4223
|
+
properties: properties.map((item) => item.code),
|
|
4224
|
+
});
|
|
4225
|
+
}
|
|
4195
4226
|
async function syncDatabaseSchema(server, applicationConfig) {
|
|
4196
4227
|
const logger = server.getLogger();
|
|
4197
4228
|
logger.info("Synchronizing database schema...");
|
|
@@ -4207,7 +4238,7 @@ async function syncDatabaseSchema(server, applicationConfig) {
|
|
|
4207
4238
|
await server.queryDatabaseObject(`CREATE TABLE IF NOT EXISTS ${queryBuilder.quoteTable(model)} ()`, []);
|
|
4208
4239
|
}
|
|
4209
4240
|
}
|
|
4210
|
-
const sqlQueryColumnInformations = `SELECT table_schema, table_name, column_name, data_type, udt_name, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_scale
|
|
4241
|
+
const sqlQueryColumnInformations = `SELECT table_schema, table_name, column_name, data_type, udt_name, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_scale
|
|
4211
4242
|
FROM information_schema.columns;`;
|
|
4212
4243
|
const columnsInDb = await server.queryDatabaseObject(sqlQueryColumnInformations, []);
|
|
4213
4244
|
for (const model of applicationConfig.models) {
|
|
@@ -5482,6 +5513,7 @@ var pluginConfig = {
|
|
|
5482
5513
|
],
|
|
5483
5514
|
},
|
|
5484
5515
|
],
|
|
5516
|
+
dataDictionaries: [],
|
|
5485
5517
|
routes: [],
|
|
5486
5518
|
};
|
|
5487
5519
|
|
|
@@ -7410,9 +7442,9 @@ class EntityAccessControlPlugin {
|
|
|
7410
7442
|
if (!userId) {
|
|
7411
7443
|
return;
|
|
7412
7444
|
}
|
|
7413
|
-
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
7414
|
-
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
7415
|
-
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
7445
|
+
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
7446
|
+
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
7447
|
+
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
7416
7448
|
where ru.user_id = $1;`, [userId]);
|
|
7417
7449
|
routeContext.state.allowedActions = actions.map((item) => item.code);
|
|
7418
7450
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -154,12 +154,14 @@ export interface RpdApplicationConfig {
|
|
|
154
154
|
code?: string;
|
|
155
155
|
name?: string;
|
|
156
156
|
models: RpdDataModel[];
|
|
157
|
+
dataDictionaries: RpdDataDictionary[];
|
|
157
158
|
routes: RpdRoute[];
|
|
158
159
|
}
|
|
159
160
|
export interface RpdDataModel {
|
|
160
161
|
maintainedBy?: string;
|
|
161
162
|
name: string;
|
|
162
163
|
namespace: string;
|
|
164
|
+
code?: string;
|
|
163
165
|
singularCode: string;
|
|
164
166
|
pluralCode: string;
|
|
165
167
|
schema?: string;
|
|
@@ -283,11 +285,19 @@ export type RpdDataDictionary = {
|
|
|
283
285
|
/**
|
|
284
286
|
* 字典名称
|
|
285
287
|
*/
|
|
288
|
+
name?: string;
|
|
289
|
+
/**
|
|
290
|
+
* 描述
|
|
291
|
+
*/
|
|
286
292
|
description?: string;
|
|
287
293
|
/**
|
|
288
294
|
* 字典项值类型
|
|
289
295
|
*/
|
|
290
|
-
|
|
296
|
+
valueType: "string" | "integer";
|
|
297
|
+
/**
|
|
298
|
+
* 字典级别
|
|
299
|
+
*/
|
|
300
|
+
level: "sys" | "app" | "user";
|
|
291
301
|
/**
|
|
292
302
|
* 字典项
|
|
293
303
|
*/
|
|
@@ -305,6 +315,14 @@ export type RpdDataDictionaryEntry = {
|
|
|
305
315
|
* 值
|
|
306
316
|
*/
|
|
307
317
|
value: string;
|
|
318
|
+
/**
|
|
319
|
+
* 颜色
|
|
320
|
+
*/
|
|
321
|
+
color?: string;
|
|
322
|
+
/**
|
|
323
|
+
* 图标
|
|
324
|
+
*/
|
|
325
|
+
icon?: string;
|
|
308
326
|
/**
|
|
309
327
|
* 描述
|
|
310
328
|
*/
|
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
|
+
};
|