@ruiapp/rapid-core 0.1.83 → 0.2.1
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 +64 -25
- 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 +1507 -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) {
|
|
@@ -2684,10 +2691,14 @@ async function convertEntityFiltersToRowFilters(server, model, baseModel, filter
|
|
|
2684
2691
|
else {
|
|
2685
2692
|
const filterField = filter.field;
|
|
2686
2693
|
let property = getEntityPropertyByCode(server, model, filterField);
|
|
2694
|
+
let filterValue = filter.value;
|
|
2687
2695
|
let columnName = "";
|
|
2688
2696
|
if (property) {
|
|
2689
2697
|
if (isOneRelationProperty(property)) {
|
|
2690
2698
|
columnName = property.targetIdColumnName;
|
|
2699
|
+
if (lodash.isPlainObject(filterValue)) {
|
|
2700
|
+
filterValue = filterValue.id;
|
|
2701
|
+
}
|
|
2691
2702
|
}
|
|
2692
2703
|
else if (isManyRelationProperty(property)) {
|
|
2693
2704
|
throw new Error(`Operator "${operator}" is not supported on many-relation property "${property.code}"`);
|
|
@@ -2709,6 +2720,9 @@ async function convertEntityFiltersToRowFilters(server, model, baseModel, filter
|
|
|
2709
2720
|
});
|
|
2710
2721
|
if (property) {
|
|
2711
2722
|
columnName = property.targetIdColumnName;
|
|
2723
|
+
if (lodash.isPlainObject(filterValue)) {
|
|
2724
|
+
filterValue = filterValue.id;
|
|
2725
|
+
}
|
|
2712
2726
|
}
|
|
2713
2727
|
else {
|
|
2714
2728
|
columnName = filterField;
|
|
@@ -2722,7 +2736,7 @@ async function convertEntityFiltersToRowFilters(server, model, baseModel, filter
|
|
|
2722
2736
|
name: columnName,
|
|
2723
2737
|
tableName: property && property.isBaseProperty ? baseModel.tableName : model.tableName,
|
|
2724
2738
|
},
|
|
2725
|
-
value:
|
|
2739
|
+
value: filterValue,
|
|
2726
2740
|
itemType: filter.itemType,
|
|
2727
2741
|
});
|
|
2728
2742
|
}
|
|
@@ -2875,7 +2889,8 @@ async function createEntity(server, dataAccessor, options, plugin) {
|
|
|
2875
2889
|
lodash.keys(entity).forEach((propertyCode) => {
|
|
2876
2890
|
const property = getEntityPropertyByCode(server, model, propertyCode);
|
|
2877
2891
|
if (!property) {
|
|
2878
|
-
|
|
2892
|
+
// Unknown property
|
|
2893
|
+
return;
|
|
2879
2894
|
}
|
|
2880
2895
|
if (isRelationProperty(property)) {
|
|
2881
2896
|
if (property.relation === "many") {
|
|
@@ -3107,7 +3122,8 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3107
3122
|
lodash.keys(changes).forEach((propertyCode) => {
|
|
3108
3123
|
const property = getEntityPropertyByCode(server, model, propertyCode);
|
|
3109
3124
|
if (!property) {
|
|
3110
|
-
|
|
3125
|
+
// Unknown property
|
|
3126
|
+
return;
|
|
3111
3127
|
}
|
|
3112
3128
|
if (isRelationProperty(property)) {
|
|
3113
3129
|
if (property.relation === "many") {
|
|
@@ -3213,7 +3229,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3213
3229
|
await server.queryDatabaseObject(`DELETE FROM ${server.queryBuilder.quoteTable({
|
|
3214
3230
|
schema: property.linkSchema,
|
|
3215
3231
|
tableName: property.linkTableName,
|
|
3216
|
-
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
3232
|
+
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
3217
3233
|
AND ${server.queryBuilder.quoteObject(property.targetIdColumnName)} <> ALL($2::int[])`, [id, targetIdsToKeep]);
|
|
3218
3234
|
}
|
|
3219
3235
|
else {
|
|
@@ -3482,11 +3498,11 @@ class EntityManager {
|
|
|
3482
3498
|
const command = `INSERT INTO ${queryBuilder.quoteTable({
|
|
3483
3499
|
schema: relationProperty.linkSchema,
|
|
3484
3500
|
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
|
|
3501
|
+
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
3502
|
+
SELECT $1, $2 WHERE NOT EXISTS (
|
|
3503
|
+
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
3504
|
+
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3505
|
+
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
3490
3506
|
)`;
|
|
3491
3507
|
const params = [id, relation.id];
|
|
3492
3508
|
await server.queryDatabaseObject(command, params);
|
|
@@ -3526,7 +3542,7 @@ class EntityManager {
|
|
|
3526
3542
|
const { queryBuilder } = server;
|
|
3527
3543
|
if (relationProperty.linkTableName) {
|
|
3528
3544
|
for (const relation of relations) {
|
|
3529
|
-
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3545
|
+
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3530
3546
|
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2;`;
|
|
3531
3547
|
const params = [id, relation.id];
|
|
3532
3548
|
await server.queryDatabaseObject(command, params);
|
|
@@ -3628,7 +3644,7 @@ class RapidServer {
|
|
|
3628
3644
|
return this.#applicationConfig;
|
|
3629
3645
|
}
|
|
3630
3646
|
appendApplicationConfig(config) {
|
|
3631
|
-
const { models, routes } = config;
|
|
3647
|
+
const { models, dataDictionaries, routes } = config;
|
|
3632
3648
|
if (models) {
|
|
3633
3649
|
for (const model of models) {
|
|
3634
3650
|
const originalModel = lodash.find(this.#applicationConfig.models, (item) => item.singularCode == model.singularCode);
|
|
@@ -3651,6 +3667,19 @@ class RapidServer {
|
|
|
3651
3667
|
}
|
|
3652
3668
|
}
|
|
3653
3669
|
}
|
|
3670
|
+
if (dataDictionaries) {
|
|
3671
|
+
for (const dataDictionary of dataDictionaries) {
|
|
3672
|
+
const originalDataDictionary = lodash.find(this.#applicationConfig.dataDictionaries, (item) => item.code == dataDictionary.code);
|
|
3673
|
+
if (originalDataDictionary) {
|
|
3674
|
+
originalDataDictionary.name = dataDictionary.name;
|
|
3675
|
+
originalDataDictionary.description = dataDictionary.description;
|
|
3676
|
+
originalDataDictionary.entries = dataDictionary.entries;
|
|
3677
|
+
}
|
|
3678
|
+
else {
|
|
3679
|
+
this.#applicationConfig.dataDictionaries.push(dataDictionary);
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3654
3683
|
if (routes) {
|
|
3655
3684
|
for (const route of routes) {
|
|
3656
3685
|
const originalRoute = lodash.find(this.#applicationConfig.routes, (item) => item.code == route.code);
|
|
@@ -4123,8 +4152,9 @@ class MetaManager {
|
|
|
4123
4152
|
const logger = server.getLogger();
|
|
4124
4153
|
try {
|
|
4125
4154
|
logger.info("Loading meta of models...");
|
|
4126
|
-
const models = await
|
|
4127
|
-
|
|
4155
|
+
const models = await listDataModels(server);
|
|
4156
|
+
const dataDictionaries = await listDataDictionaries(server);
|
|
4157
|
+
server.appendApplicationConfig({ models, dataDictionaries });
|
|
4128
4158
|
}
|
|
4129
4159
|
catch (error) {
|
|
4130
4160
|
logger.crit("Failed to load meta of models.", { error });
|
|
@@ -4184,7 +4214,7 @@ async function handleEntityDeleteEvent(server, sender, payload) {
|
|
|
4184
4214
|
}
|
|
4185
4215
|
}
|
|
4186
4216
|
}
|
|
4187
|
-
function
|
|
4217
|
+
function listDataModels(server) {
|
|
4188
4218
|
const entityManager = server.getEntityManager("model");
|
|
4189
4219
|
const model = entityManager.getModel();
|
|
4190
4220
|
const properties = getEntityPropertiesIncludingBase(server, model);
|
|
@@ -4192,6 +4222,14 @@ function listCollections(server, applicationConfig) {
|
|
|
4192
4222
|
properties: properties.map((item) => item.code),
|
|
4193
4223
|
});
|
|
4194
4224
|
}
|
|
4225
|
+
function listDataDictionaries(server) {
|
|
4226
|
+
const dataDictionaryManager = server.getEntityManager("data_dictionary");
|
|
4227
|
+
const model = dataDictionaryManager.getModel();
|
|
4228
|
+
const properties = getEntityPropertiesIncludingBase(server, model);
|
|
4229
|
+
return dataDictionaryManager.findEntities({
|
|
4230
|
+
properties: properties.map((item) => item.code),
|
|
4231
|
+
});
|
|
4232
|
+
}
|
|
4195
4233
|
async function syncDatabaseSchema(server, applicationConfig) {
|
|
4196
4234
|
const logger = server.getLogger();
|
|
4197
4235
|
logger.info("Synchronizing database schema...");
|
|
@@ -4207,7 +4245,7 @@ async function syncDatabaseSchema(server, applicationConfig) {
|
|
|
4207
4245
|
await server.queryDatabaseObject(`CREATE TABLE IF NOT EXISTS ${queryBuilder.quoteTable(model)} ()`, []);
|
|
4208
4246
|
}
|
|
4209
4247
|
}
|
|
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
|
|
4248
|
+
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
4249
|
FROM information_schema.columns;`;
|
|
4212
4250
|
const columnsInDb = await server.queryDatabaseObject(sqlQueryColumnInformations, []);
|
|
4213
4251
|
for (const model of applicationConfig.models) {
|
|
@@ -5482,6 +5520,7 @@ var pluginConfig = {
|
|
|
5482
5520
|
],
|
|
5483
5521
|
},
|
|
5484
5522
|
],
|
|
5523
|
+
dataDictionaries: [],
|
|
5485
5524
|
routes: [],
|
|
5486
5525
|
};
|
|
5487
5526
|
|
|
@@ -7410,9 +7449,9 @@ class EntityAccessControlPlugin {
|
|
|
7410
7449
|
if (!userId) {
|
|
7411
7450
|
return;
|
|
7412
7451
|
}
|
|
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
|
|
7452
|
+
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
7453
|
+
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
7454
|
+
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
7416
7455
|
where ru.user_id = $1;`, [userId]);
|
|
7417
7456
|
routeContext.state.allowedActions = actions.map((item) => item.code);
|
|
7418
7457
|
}
|
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
|
+
};
|