@ruiapp/rapid-core 0.1.63 → 0.1.65

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.
Files changed (161) hide show
  1. package/dist/helpers/entityHelpers.d.ts +3 -1
  2. package/dist/{dataAccess → helpers}/metaHelper.d.ts +3 -0
  3. package/dist/index.js +109 -31
  4. package/dist/plugins/setting/SettingPlugin.d.ts +21 -0
  5. package/dist/plugins/setting/SettingPluginTypes.d.ts +31 -0
  6. package/dist/plugins/setting/SettingService.d.ts +10 -0
  7. package/dist/plugins/setting/actionHandlers/getSystemSettingValues.d.ts +7 -0
  8. package/dist/plugins/setting/actionHandlers/index.d.ts +3 -0
  9. package/dist/plugins/setting/models/SystemSettingGroupSetting.d.ts +3 -0
  10. package/dist/plugins/setting/models/SystemSettingItem.d.ts +3 -0
  11. package/dist/plugins/setting/models/SystemSettingItemSetting.d.ts +3 -0
  12. package/dist/plugins/setting/models/UserSettingGroupSetting.d.ts +3 -0
  13. package/dist/plugins/setting/models/UserSettingItem.d.ts +3 -0
  14. package/dist/plugins/setting/models/UserSettingItemSetting.d.ts +3 -0
  15. package/dist/plugins/setting/models/index.d.ts +2 -0
  16. package/dist/plugins/setting/routes/getSystemSettingValues.d.ts +12 -0
  17. package/dist/plugins/setting/routes/index.d.ts +12 -0
  18. package/dist/types.d.ts +4 -0
  19. package/package.json +1 -1
  20. package/rollup.config.js +16 -16
  21. package/src/bootstrapApplicationConfig.ts +552 -545
  22. package/src/core/actionHandler.ts +22 -22
  23. package/src/core/eventManager.ts +20 -20
  24. package/src/core/facility.ts +7 -7
  25. package/src/core/http/formDataParser.ts +89 -89
  26. package/src/core/http-types.ts +4 -4
  27. package/src/core/pluginManager.ts +175 -175
  28. package/src/core/providers/runtimeProvider.ts +5 -5
  29. package/src/core/request.ts +86 -86
  30. package/src/core/response.ts +76 -76
  31. package/src/core/routeContext.ts +43 -43
  32. package/src/core/routesBuilder.ts +88 -88
  33. package/src/core/server.ts +16 -1
  34. package/src/dataAccess/dataAccessTypes.ts +109 -109
  35. package/src/dataAccess/dataAccessor.ts +137 -137
  36. package/src/dataAccess/entityManager.ts +1298 -1292
  37. package/src/dataAccess/entityMapper.ts +4 -5
  38. package/src/dataAccess/propertyMapper.ts +27 -27
  39. package/src/deno-std/assert/assert.ts +9 -9
  40. package/src/deno-std/assert/assertion_error.ts +7 -7
  41. package/src/deno-std/datetime/to_imf.ts +32 -32
  42. package/src/deno-std/encoding/base64.ts +141 -141
  43. package/src/deno-std/http/cookie.ts +8 -1
  44. package/src/facilities/log/LogFacility.ts +35 -35
  45. package/src/helpers/entityHelpers.ts +76 -21
  46. package/src/{dataAccess → helpers}/filterHelper.ts +3 -1
  47. package/src/helpers/inputHelper.ts +11 -11
  48. package/src/{dataAccess → helpers}/metaHelper.ts +15 -6
  49. package/src/helpers/runCollectionEntityActionHandler.ts +6 -1
  50. package/src/index.ts +41 -41
  51. package/src/plugins/auth/AuthPlugin.ts +7 -1
  52. package/src/plugins/auth/actionHandlers/changePassword.ts +54 -54
  53. package/src/plugins/auth/actionHandlers/createSession.ts +63 -63
  54. package/src/plugins/auth/actionHandlers/deleteSession.ts +18 -18
  55. package/src/plugins/auth/actionHandlers/getMyProfile.ts +35 -35
  56. package/src/plugins/auth/actionHandlers/index.ts +8 -8
  57. package/src/plugins/auth/actionHandlers/resetPassword.ts +38 -38
  58. package/src/plugins/auth/models/AccessToken.ts +56 -56
  59. package/src/plugins/auth/models/index.ts +3 -3
  60. package/src/plugins/auth/routes/changePassword.ts +15 -15
  61. package/src/plugins/auth/routes/getMyProfile.ts +15 -15
  62. package/src/plugins/auth/routes/index.ts +7 -7
  63. package/src/plugins/auth/routes/resetPassword.ts +15 -15
  64. package/src/plugins/auth/routes/signin.ts +15 -15
  65. package/src/plugins/auth/routes/signout.ts +15 -15
  66. package/src/plugins/cronJob/CronJobPlugin.ts +7 -1
  67. package/src/plugins/cronJob/CronJobPluginTypes.ts +49 -49
  68. package/src/plugins/cronJob/actionHandlers/index.ts +4 -4
  69. package/src/plugins/cronJob/actionHandlers/runCronJob.ts +29 -29
  70. package/src/plugins/cronJob/routes/index.ts +3 -3
  71. package/src/plugins/cronJob/routes/runCronJob.ts +15 -15
  72. package/src/plugins/dataManage/DataManagePlugin.ts +7 -1
  73. package/src/plugins/dataManage/actionHandlers/addEntityRelations.ts +20 -20
  74. package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +15 -15
  75. package/src/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.ts +42 -42
  76. package/src/plugins/dataManage/actionHandlers/createCollectionEntity.ts +24 -24
  77. package/src/plugins/dataManage/actionHandlers/deleteCollectionEntityById.ts +7 -4
  78. package/src/plugins/dataManage/actionHandlers/findCollectionEntities.ts +26 -26
  79. package/src/plugins/dataManage/actionHandlers/findCollectionEntityById.ts +21 -21
  80. package/src/plugins/dataManage/actionHandlers/queryDatabase.ts +22 -22
  81. package/src/plugins/dataManage/actionHandlers/removeEntityRelations.ts +20 -20
  82. package/src/plugins/dataManage/actionHandlers/updateCollectionEntityById.ts +35 -35
  83. package/src/plugins/entityAccessControl/EntityAccessControlPlugin.ts +146 -146
  84. package/src/plugins/fileManage/FileManagePlugin.ts +7 -1
  85. package/src/plugins/fileManage/actionHandlers/downloadDocument.ts +36 -36
  86. package/src/plugins/fileManage/actionHandlers/downloadFile.ts +28 -28
  87. package/src/plugins/fileManage/actionHandlers/uploadFile.ts +33 -33
  88. package/src/plugins/fileManage/routes/downloadDocument.ts +15 -15
  89. package/src/plugins/fileManage/routes/downloadFile.ts +15 -15
  90. package/src/plugins/fileManage/routes/index.ts +5 -5
  91. package/src/plugins/fileManage/routes/uploadFile.ts +15 -15
  92. package/src/plugins/metaManage/MetaManagePlugin.ts +37 -9
  93. package/src/plugins/metaManage/actionHandlers/getMetaModelDetail.ts +10 -10
  94. package/src/plugins/metaManage/actionHandlers/listMetaModels.ts +9 -9
  95. package/src/plugins/metaManage/actionHandlers/listMetaRoutes.ts +9 -9
  96. package/src/plugins/routeManage/RouteManagePlugin.ts +7 -1
  97. package/src/plugins/routeManage/actionHandlers/httpProxy.ts +13 -13
  98. package/src/plugins/sequence/SequencePlugin.ts +8 -2
  99. package/src/plugins/sequence/SequencePluginTypes.ts +9 -1
  100. package/src/plugins/sequence/SequenceService.ts +81 -81
  101. package/src/plugins/sequence/actionHandlers/generateSn.ts +32 -32
  102. package/src/plugins/sequence/actionHandlers/index.ts +4 -4
  103. package/src/plugins/sequence/models/SequenceAutoIncrementRecord.ts +49 -49
  104. package/src/plugins/sequence/models/SequenceRule.ts +42 -42
  105. package/src/plugins/sequence/models/index.ts +4 -4
  106. package/src/plugins/sequence/routes/generateSn.ts +15 -15
  107. package/src/plugins/sequence/routes/index.ts +3 -3
  108. package/src/plugins/sequence/segment-utility.ts +11 -11
  109. package/src/plugins/sequence/segments/autoIncrement.ts +6 -1
  110. package/src/plugins/sequence/segments/dayOfMonth.ts +6 -1
  111. package/src/plugins/sequence/segments/index.ts +9 -9
  112. package/src/plugins/sequence/segments/literal.ts +6 -1
  113. package/src/plugins/sequence/segments/month.ts +6 -1
  114. package/src/plugins/sequence/segments/parameter.ts +6 -1
  115. package/src/plugins/sequence/segments/year.ts +6 -1
  116. package/src/plugins/serverOperation/ServerOperationPlugin.ts +91 -91
  117. package/src/plugins/serverOperation/ServerOperationPluginTypes.ts +15 -15
  118. package/src/plugins/serverOperation/actionHandlers/index.ts +4 -4
  119. package/src/plugins/serverOperation/actionHandlers/runServerOperation.ts +15 -15
  120. package/src/plugins/setting/SettingPlugin.ts +71 -0
  121. package/src/plugins/setting/SettingPluginTypes.ts +35 -0
  122. package/src/plugins/setting/SettingService.ts +17 -0
  123. package/src/plugins/setting/actionHandlers/getSystemSettingValues.ts +30 -0
  124. package/src/plugins/setting/actionHandlers/index.ts +4 -0
  125. package/src/plugins/setting/models/SystemSettingGroupSetting.ts +56 -0
  126. package/src/plugins/setting/models/SystemSettingItem.ts +42 -0
  127. package/src/plugins/setting/models/SystemSettingItemSetting.ts +72 -0
  128. package/src/plugins/setting/models/UserSettingGroupSetting.ts +56 -0
  129. package/src/plugins/setting/models/UserSettingItem.ts +49 -0
  130. package/src/plugins/setting/models/UserSettingItemSetting.ts +72 -0
  131. package/src/plugins/setting/models/index.ts +8 -0
  132. package/src/plugins/setting/routes/getSystemSettingValues.ts +15 -0
  133. package/src/plugins/setting/routes/index.ts +3 -0
  134. package/src/plugins/stateMachine/StateMachinePlugin.ts +8 -2
  135. package/src/plugins/stateMachine/StateMachinePluginTypes.ts +9 -1
  136. package/src/plugins/stateMachine/actionHandlers/index.ts +4 -4
  137. package/src/plugins/stateMachine/actionHandlers/sendStateMachineEvent.ts +51 -51
  138. package/src/plugins/stateMachine/models/StateMachine.ts +42 -42
  139. package/src/plugins/stateMachine/models/index.ts +3 -3
  140. package/src/plugins/stateMachine/routes/index.ts +3 -3
  141. package/src/plugins/stateMachine/routes/sendStateMachineEvent.ts +15 -15
  142. package/src/plugins/stateMachine/stateMachineHelper.ts +36 -36
  143. package/src/plugins/webhooks/WebhooksPlugin.ts +13 -2
  144. package/src/plugins/webhooks/pluginConfig.ts +74 -74
  145. package/src/polyfill.ts +5 -5
  146. package/src/proxy/mod.ts +38 -38
  147. package/src/proxy/types.ts +21 -21
  148. package/src/queryBuilder/index.ts +1 -1
  149. package/src/queryBuilder/queryBuilder.ts +473 -473
  150. package/src/server.ts +23 -3
  151. package/src/types.ts +593 -589
  152. package/src/utilities/accessControlUtility.ts +33 -33
  153. package/src/utilities/errorUtility.ts +4 -6
  154. package/src/utilities/fsUtility.ts +61 -61
  155. package/src/utilities/httpUtility.ts +19 -19
  156. package/src/utilities/jwtUtility.ts +26 -26
  157. package/src/utilities/typeUtility.ts +11 -11
  158. package/tsconfig.json +19 -19
  159. package/dist/utilities/rapidUtility.d.ts +0 -2
  160. package/src/utilities/rapidUtility.ts +0 -5
  161. /package/dist/{dataAccess → helpers}/filterHelper.d.ts +0 -0
@@ -1 +1,3 @@
1
- export declare function getEntityPartChanges(before: any, after: any): Record<string, any> | null;
1
+ import { IRpdServer } from "../core/server";
2
+ import { RpdDataModel } from "../types";
3
+ export declare function getEntityPartChanges(server: IRpdServer, model: RpdDataModel, before: any, after: any): Record<string, any> | null;
@@ -1,5 +1,8 @@
1
1
  import { IRpdServer } from "../core/server";
2
2
  import { RpdDataModel, RpdDataModelProperty } from "../types";
3
+ export declare function isRelationProperty(property: RpdDataModelProperty): boolean;
4
+ export declare function isOneRelationProperty(property: RpdDataModelProperty): boolean;
5
+ export declare function isManyRelationProperty(property: RpdDataModelProperty): boolean;
3
6
  export declare function getEntityProperties(server: IRpdServer, model: RpdDataModel): RpdDataModelProperty[];
4
7
  export declare function getEntityPropertiesIncludingBase(server: IRpdServer, model: RpdDataModel): RpdDataModelProperty[];
5
8
  export declare function getEntityPropertyByCode(server: IRpdServer, model: RpdDataModel, propertyCode: string): RpdDataModelProperty;
package/dist/index.js CHANGED
@@ -1093,7 +1093,12 @@ function validateValue(name, value) {
1093
1093
  return;
1094
1094
  for (let i = 0; i < value.length; i++) {
1095
1095
  const c = value.charAt(i);
1096
- if (c < String.fromCharCode(0x21) || c == String.fromCharCode(0x22) || c == String.fromCharCode(0x2c) || c == String.fromCharCode(0x3b) || c == String.fromCharCode(0x5c) || c == String.fromCharCode(0x7f)) {
1096
+ if (c < String.fromCharCode(0x21) ||
1097
+ c == String.fromCharCode(0x22) ||
1098
+ c == String.fromCharCode(0x2c) ||
1099
+ c == String.fromCharCode(0x3b) ||
1100
+ c == String.fromCharCode(0x5c) ||
1101
+ c == String.fromCharCode(0x7f)) {
1097
1102
  throw new Error("RFC2616 cookie '" + name + "' cannot contain character '" + c + "'");
1098
1103
  }
1099
1104
  if (c > String.fromCharCode(0x80)) {
@@ -1340,6 +1345,13 @@ var bootstrapApplicationConfig = {
1340
1345
  type: "text",
1341
1346
  required: false,
1342
1347
  },
1348
+ {
1349
+ name: "displayPropertyCode",
1350
+ code: "displayPropertyCode",
1351
+ columnName: "display_property_code",
1352
+ type: "text",
1353
+ required: false,
1354
+ },
1343
1355
  {
1344
1356
  name: "properties",
1345
1357
  code: "properties",
@@ -1800,8 +1812,10 @@ var bootstrapApplicationConfig$1 = /*#__PURE__*/Object.freeze({
1800
1812
 
1801
1813
  function isRelationProperty(property) {
1802
1814
  return property.type === "relation" || property.type === "relation[]";
1803
- }
1804
-
1815
+ }
1816
+ function isOneRelationProperty(property) {
1817
+ return isRelationProperty(property) && property.relation === "one";
1818
+ }
1805
1819
  function getEntityPropertiesIncludingBase(server, model) {
1806
1820
  if (!model.base) {
1807
1821
  return model.properties;
@@ -1817,10 +1831,7 @@ function getEntityPropertiesIncludingBase(server, model) {
1817
1831
  return property;
1818
1832
  });
1819
1833
  }
1820
- return [
1821
- ...baseProperties,
1822
- ...model.properties,
1823
- ];
1834
+ return [...baseProperties, ...model.properties];
1824
1835
  }
1825
1836
  function getEntityPropertyByCode(server, model, propertyCode) {
1826
1837
  return getEntityProperty(server, model, (e) => e.code === propertyCode);
@@ -1897,8 +1908,8 @@ function mapEntityToDbRow(server, model, entity) {
1897
1908
  if (!entity) {
1898
1909
  return result;
1899
1910
  }
1900
- const row = result.row = {};
1901
- const baseRow = result.baseRow = {};
1911
+ const row = (result.row = {});
1912
+ const baseRow = (result.baseRow = {});
1902
1913
  if (!model.properties || !model.properties.length) {
1903
1914
  return result;
1904
1915
  }
@@ -1946,25 +1957,80 @@ function mapPropertyNameToColumnName(model, propertyName) {
1946
1957
  return property.columnName || property.code;
1947
1958
  }
1948
1959
 
1949
- function getEntityPartChanges(before, after) {
1960
+ function getEntityPartChanges(server, model, before, after) {
1950
1961
  if (!before) {
1951
1962
  throw new Error("Argument 'before' can not be null.");
1952
1963
  }
1953
1964
  if (!after) {
1954
1965
  throw new Error("Argument 'after' can not be null.");
1955
1966
  }
1956
- let changed = null;
1967
+ let changed = false;
1968
+ let changes = {};
1957
1969
  for (const key in after) {
1958
- if (after[key] != before[key]) {
1959
- if (changed) {
1960
- changed[key] = after[key];
1970
+ const property = getEntityPropertyByCode(server, model, key);
1971
+ if (isOneRelationProperty(property)) {
1972
+ const afterValue = after[key];
1973
+ const beforeValue = before[key] || before[property.targetIdColumnName];
1974
+ if (afterValue) {
1975
+ if (lodash.isNumber(afterValue)) {
1976
+ if (beforeValue) {
1977
+ if (lodash.isNumber(beforeValue)) {
1978
+ if (afterValue != beforeValue) {
1979
+ changed = true;
1980
+ changes[key] = afterValue;
1981
+ }
1982
+ }
1983
+ else {
1984
+ if (afterValue != beforeValue.id) {
1985
+ changed = true;
1986
+ changes[key] = afterValue;
1987
+ }
1988
+ }
1989
+ }
1990
+ else {
1991
+ changed = true;
1992
+ changes[key] = afterValue;
1993
+ }
1994
+ }
1995
+ else {
1996
+ if (beforeValue) {
1997
+ if (lodash.isNumber(beforeValue)) {
1998
+ if (afterValue.id != beforeValue) {
1999
+ changed = true;
2000
+ changes[key] = afterValue;
2001
+ }
2002
+ }
2003
+ else {
2004
+ if (afterValue.id != beforeValue.id) {
2005
+ changed = true;
2006
+ changes[key] = afterValue;
2007
+ }
2008
+ }
2009
+ }
2010
+ else {
2011
+ changed = true;
2012
+ changes[key] = afterValue;
2013
+ }
2014
+ }
1961
2015
  }
1962
2016
  else {
1963
- changed = { [key]: after[key] };
2017
+ if (beforeValue) {
2018
+ changed = true;
2019
+ changes[key] = null;
2020
+ }
1964
2021
  }
1965
2022
  }
2023
+ else {
2024
+ if (after[key] != before[key]) {
2025
+ changed = true;
2026
+ changes[key] = after[key];
2027
+ }
2028
+ }
2029
+ }
2030
+ if (changed) {
2031
+ return changes;
1966
2032
  }
1967
- return changed;
2033
+ return null;
1968
2034
  }
1969
2035
 
1970
2036
  function getNowStringWithTimezone() {
@@ -2572,7 +2638,7 @@ async function createEntity(server, dataAccessor, options, plugin) {
2572
2638
  targetRow[property.targetIdColumnName] = targetEntityId;
2573
2639
  }
2574
2640
  }
2575
- else {
2641
+ else if (lodash.isNumber(fieldValue)) {
2576
2642
  // fieldValue is id;
2577
2643
  const targetEntityId = fieldValue;
2578
2644
  const targetEntity = await findById(server, targetDataAccessor, {
@@ -2585,6 +2651,10 @@ async function createEntity(server, dataAccessor, options, plugin) {
2585
2651
  newEntityOneRelationProps[property.code] = targetEntity;
2586
2652
  targetRow[property.targetIdColumnName] = targetEntityId;
2587
2653
  }
2654
+ else {
2655
+ newEntityOneRelationProps[property.code] = null;
2656
+ targetRow[property.targetIdColumnName] = null;
2657
+ }
2588
2658
  }
2589
2659
  let newBaseRow;
2590
2660
  if (model.base) {
@@ -2693,14 +2763,15 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
2693
2763
  throw new Error("Id is required when updating an entity.");
2694
2764
  }
2695
2765
  const entity = await findById(server, dataAccessor, {
2696
- id,
2697
2766
  routeContext,
2767
+ id,
2768
+ keepNonPropertyFields: true,
2698
2769
  });
2699
2770
  if (!entity) {
2700
2771
  throw new Error(`${model.namespace}.${model.singularCode} with id "${id}" was not found.`);
2701
2772
  }
2702
2773
  let { entityToSave } = options;
2703
- let changes = getEntityPartChanges(entity, entityToSave);
2774
+ let changes = getEntityPartChanges(server, model, entity, entityToSave);
2704
2775
  if (!changes && !options.operation) {
2705
2776
  return entity;
2706
2777
  }
@@ -2730,7 +2801,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
2730
2801
  sender: plugin,
2731
2802
  routeContext: options.routeContext,
2732
2803
  });
2733
- changes = getEntityPartChanges(entity, entityToSave);
2804
+ changes = getEntityPartChanges(server, model, entity, entityToSave);
2734
2805
  const oneRelationPropertiesToUpdate = [];
2735
2806
  const manyRelationPropertiesToUpdate = [];
2736
2807
  lodash.keys(changes).forEach((propertyCode) => {
@@ -2778,7 +2849,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
2778
2849
  targetRow[property.targetIdColumnName] = targetEntityId;
2779
2850
  }
2780
2851
  }
2781
- else {
2852
+ else if (lodash.isNumber(fieldValue)) {
2782
2853
  // fieldValue is id;
2783
2854
  const targetEntityId = fieldValue;
2784
2855
  const targetEntity = await findById(server, targetDataAccessor, {
@@ -2791,6 +2862,10 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
2791
2862
  updatedEntityOneRelationProps[property.code] = targetEntity;
2792
2863
  targetRow[property.targetIdColumnName] = targetEntityId;
2793
2864
  }
2865
+ else {
2866
+ updatedEntityOneRelationProps[property.code] = null;
2867
+ targetRow[property.targetIdColumnName] = null;
2868
+ }
2794
2869
  }
2795
2870
  let updatedRow = row;
2796
2871
  if (Object.keys(row).length) {
@@ -3024,11 +3099,11 @@ class EntityManager {
3024
3099
  const command = `INSERT INTO ${queryBuilder.quoteTable({
3025
3100
  schema: relationProperty.linkSchema,
3026
3101
  tableName: relationProperty.linkTableName,
3027
- })} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
3028
- SELECT $1, $2 WHERE NOT EXISTS (
3029
- SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
3030
- FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
3031
- WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
3102
+ })} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
3103
+ SELECT $1, $2 WHERE NOT EXISTS (
3104
+ SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
3105
+ FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
3106
+ WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
3032
3107
  )`;
3033
3108
  const params = [id, relation.id];
3034
3109
  await server.queryDatabaseObject(command, params);
@@ -3068,7 +3143,7 @@ class EntityManager {
3068
3143
  const { queryBuilder } = server;
3069
3144
  if (relationProperty.linkTableName) {
3070
3145
  for (const relation of relations) {
3071
- const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
3146
+ const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
3072
3147
  WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2;`;
3073
3148
  const params = [id, relation.id];
3074
3149
  await server.queryDatabaseObject(command, params);
@@ -3779,7 +3854,10 @@ async function syncDatabaseSchema(server, applicationConfig) {
3779
3854
  }
3780
3855
  else if (property.relation === "many") {
3781
3856
  if (property.linkTableName) {
3782
- const tableInDb = lodash.find(tablesInDb, { table_schema: property.linkSchema || server.databaseConfig.dbDefaultSchema, table_name: property.linkTableName });
3857
+ const tableInDb = lodash.find(tablesInDb, {
3858
+ table_schema: property.linkSchema || server.databaseConfig.dbDefaultSchema,
3859
+ table_name: property.linkTableName,
3860
+ });
3783
3861
  if (!tableInDb) {
3784
3862
  columnDDL = generateLinkTableDDL(queryBuilder, {
3785
3863
  linkSchema: property.linkSchema,
@@ -6179,9 +6257,9 @@ class EntityAccessControlPlugin {
6179
6257
  if (!userId) {
6180
6258
  return;
6181
6259
  }
6182
- const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
6183
- inner join oc_role_sys_action_links ra on a.id = ra.action_id
6184
- inner join oc_role_user_links ru on ru.role_id = ra.role_id
6260
+ const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
6261
+ inner join oc_role_sys_action_links ra on a.id = ra.action_id
6262
+ inner join oc_role_user_links ru on ru.role_id = ra.role_id
6185
6263
  where ru.user_id = $1;`, [userId]);
6186
6264
  routeContext.state.allowedActions = actions.map((item) => item.code);
6187
6265
  }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Setting plugin
3
+ */
4
+ import { RpdApplicationConfig } from "../../types";
5
+ import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "../../core/server";
6
+ import SettingService from "./SettingService";
7
+ declare class SettingPlugin implements RapidPlugin {
8
+ #private;
9
+ get settingService(): SettingService;
10
+ get code(): string;
11
+ get description(): string;
12
+ get extendingAbilities(): RpdServerPluginExtendingAbilities[];
13
+ get configurableTargets(): RpdServerPluginConfigurableTargetOptions[];
14
+ get configurations(): RpdConfigurationItemOptions[];
15
+ registerActionHandlers(server: IRpdServer): Promise<any>;
16
+ configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
17
+ configureServices(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
18
+ configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
19
+ onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<void>;
20
+ }
21
+ export default SettingPlugin;
@@ -0,0 +1,31 @@
1
+ export type SettingGroupSetting = {
2
+ code: string;
3
+ name: string;
4
+ description?: string;
5
+ permissionAssignments?: PermissionAssignment[];
6
+ };
7
+ export type SettingItemSetting = {
8
+ group: SettingGroupSetting;
9
+ orderNum: number;
10
+ type: string;
11
+ code: string;
12
+ name: string;
13
+ description?: string;
14
+ config?: any;
15
+ };
16
+ export type SystemSettingItem = {
17
+ groupCode: string;
18
+ itemCode: string;
19
+ value: any;
20
+ };
21
+ export type UserSettingItem = {
22
+ userId: number;
23
+ groupCode: string;
24
+ itemCode: string;
25
+ value: any;
26
+ };
27
+ export type PermissionAssignment = {
28
+ assigneeType: string;
29
+ assigneeId: number;
30
+ actions: string[];
31
+ };
@@ -0,0 +1,10 @@
1
+ import { IRpdServer } from "../../core/server";
2
+ export interface GetSystemSettingValuesInput {
3
+ groupCode: string;
4
+ }
5
+ export default class SequenceService {
6
+ #private;
7
+ constructor(server: IRpdServer);
8
+ getSystemSettingValues(input: GetSystemSettingValuesInput): Promise<void>;
9
+ setSystemSettingValue(groupCode: string, itemCode: string, value: any): Promise<void>;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { ActionHandlerContext } from "../../../core/actionHandler";
2
+ import { RapidPlugin } from "../../../core/server";
3
+ export interface GetSystemSettingValuesOptions {
4
+ groupCode: string;
5
+ }
6
+ export declare const code = "getSystemSettingValues";
7
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: GetSystemSettingValuesOptions): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import * as getSystemSettingValues from "./getSystemSettingValues";
2
+ declare const _default: (typeof getSystemSettingValues)[];
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { RpdDataModel } from "../../../types";
2
+ declare const _default: RpdDataModel;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { RpdDataModel } from "../../../types";
2
+ declare const _default: RpdDataModel;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { RpdDataModel } from "../../../types";
2
+ declare const _default: RpdDataModel;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { RpdDataModel } from "../../../types";
2
+ declare const _default: RpdDataModel;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { RpdDataModel } from "../../../types";
2
+ declare const _default: RpdDataModel;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { RpdDataModel } from "../../../types";
2
+ declare const _default: RpdDataModel;
3
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../../..").RpdDataModel[];
2
+ export default _default;
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "POST";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ };
12
+ export default _default;
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "POST";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ }[];
12
+ export default _default;
package/dist/types.d.ts CHANGED
@@ -175,6 +175,10 @@ export interface RpdDataModel {
175
175
  * Configure the property code to save derived type for base entity.
176
176
  */
177
177
  derivedTypePropertyCode?: string;
178
+ /**
179
+ * Configure the property code used to display the entity.
180
+ */
181
+ displayPropertyCode?: string;
178
182
  properties: RpdDataModelProperty[];
179
183
  extensions?: RpdDataModelExtension[];
180
184
  permissionPolicies?: RpdDataModelPermissionPolicies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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
+ };