@ruiapp/rapid-core 0.1.4 → 0.1.6

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 (121) hide show
  1. package/dist/bootstrapApplicationConfig.d.ts +1 -1
  2. package/dist/core/actionHandler.d.ts +17 -0
  3. package/dist/core/pluginManager.d.ts +31 -26
  4. package/dist/core/server.d.ts +24 -24
  5. package/dist/helpers/runCollectionEntityActionHandler.d.ts +5 -0
  6. package/dist/index.d.ts +8 -0
  7. package/dist/index.js +3335 -3279
  8. package/dist/plugins/auth/actionHandlers/createSession.d.ts +8 -0
  9. package/dist/plugins/auth/actionHandlers/deleteSession.d.ts +4 -0
  10. package/dist/plugins/auth/actionHandlers/getMyProfile.d.ts +4 -0
  11. package/dist/plugins/auth/mod.d.ts +25 -0
  12. package/dist/plugins/{authManager → auth}/routes/getMyProfile.d.ts +1 -1
  13. package/dist/plugins/{authManager → auth}/routes/signin.d.ts +1 -1
  14. package/dist/plugins/{authManager → auth}/routes/signout.d.ts +1 -1
  15. package/dist/plugins/dataManage/actionHandlers/addEntityRelations.d.ts +5 -0
  16. package/dist/plugins/dataManage/actionHandlers/countCollectionEntities.d.ts +5 -0
  17. package/dist/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.d.ts +5 -0
  18. package/dist/plugins/dataManage/actionHandlers/createCollectionEntity.d.ts +5 -0
  19. package/dist/plugins/dataManage/actionHandlers/deleteCollectionEntityById.d.ts +5 -0
  20. package/dist/plugins/dataManage/actionHandlers/findCollectionEntities.d.ts +5 -0
  21. package/dist/plugins/dataManage/actionHandlers/findCollectionEntityById.d.ts +5 -0
  22. package/dist/plugins/dataManage/actionHandlers/queryDatabase.d.ts +5 -0
  23. package/dist/plugins/dataManage/actionHandlers/removeEntityRelations.d.ts +5 -0
  24. package/dist/plugins/dataManage/actionHandlers/updateCollectionEntityById.d.ts +5 -0
  25. package/dist/plugins/dataManage/mod.d.ts +27 -0
  26. package/dist/plugins/fileManage/actionHandlers/downloadDocument.d.ts +4 -0
  27. package/dist/plugins/fileManage/actionHandlers/downloadFile.d.ts +4 -0
  28. package/dist/plugins/fileManage/actionHandlers/uploadFile.d.ts +4 -0
  29. package/dist/plugins/fileManage/mod.d.ts +25 -0
  30. package/dist/plugins/metaManage/actionHandlers/getMetaModelDetail.d.ts +4 -0
  31. package/dist/plugins/metaManage/actionHandlers/listMetaModels.d.ts +4 -0
  32. package/dist/plugins/metaManage/actionHandlers/listMetaRoutes.d.ts +4 -0
  33. package/dist/plugins/metaManage/mod.d.ts +25 -0
  34. package/dist/plugins/routeManage/actionHandlers/httpProxy.d.ts +5 -0
  35. package/dist/plugins/routeManage/mod.d.ts +25 -0
  36. package/dist/plugins/webhooks/mod.d.ts +25 -11
  37. package/dist/server.d.ts +7 -6
  38. package/dist/types.d.ts +10 -12
  39. package/package.json +1 -1
  40. package/src/bootstrapApplicationConfig.ts +6 -6
  41. package/src/core/actionHandler.ts +23 -0
  42. package/src/core/pluginManager.ts +107 -108
  43. package/src/core/routesBuilder.ts +4 -4
  44. package/src/core/server.ts +26 -44
  45. package/src/dataAccess/dataAccessor.ts +1 -1
  46. package/src/helpers/{runCollectionEntityHttpHandler.ts → runCollectionEntityActionHandler.ts} +5 -5
  47. package/src/index.ts +9 -0
  48. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/createSession.ts +4 -4
  49. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/deleteSession.ts +4 -4
  50. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/getMyProfile.ts +4 -4
  51. package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.ts +2 -2
  52. package/src/plugins/auth/mod.ts +80 -0
  53. package/src/plugins/{authManager → auth}/routes/getMyProfile.ts +1 -1
  54. package/src/plugins/{authManager → auth}/routes/signin.ts +1 -1
  55. package/src/plugins/{authManager → auth}/routes/signout.ts +1 -1
  56. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/addEntityRelations.ts +6 -5
  57. package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +23 -0
  58. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntitiesBatch.ts +6 -5
  59. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntity.ts +6 -5
  60. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/deleteCollectionEntityById.ts +8 -7
  61. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntities.ts +8 -7
  62. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntityById.ts +6 -5
  63. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/queryDatabase.ts +5 -4
  64. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/removeEntityRelations.ts +6 -5
  65. package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/updateCollectionEntityById.ts +6 -5
  66. package/src/plugins/dataManage/mod.ts +187 -0
  67. package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadDocument.ts +4 -4
  68. package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadFile.ts +4 -4
  69. package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/uploadFile.ts +5 -5
  70. package/src/plugins/fileManage/mod.ts +77 -0
  71. package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/getMetaModelDetail.ts +4 -4
  72. package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/listMetaModels.ts +4 -4
  73. package/src/plugins/{routeManager/httpHandlers → metaManage/actionHandlers}/listMetaRoutes.ts +4 -4
  74. package/src/plugins/{metaManager → metaManage}/mod.ts +88 -55
  75. package/src/plugins/{routeManager/httpHandlers → routeManage/actionHandlers}/httpProxy.ts +5 -4
  76. package/src/plugins/routeManage/mod.ts +92 -0
  77. package/src/plugins/webhooks/mod.ts +134 -94
  78. package/src/server.ts +28 -21
  79. package/src/types.ts +11 -14
  80. package/dist/core/httpHandler.d.ts +0 -18
  81. package/dist/core/plugin.d.ts +0 -6
  82. package/dist/helpers/runCollectionEntityHttpHandler.d.ts +0 -5
  83. package/dist/plugins/authManager/httpHandlers/createSession.d.ts +0 -8
  84. package/dist/plugins/authManager/httpHandlers/deleteSession.d.ts +0 -4
  85. package/dist/plugins/authManager/httpHandlers/getMyProfile.d.ts +0 -4
  86. package/dist/plugins/authManager/mod.d.ts +0 -16
  87. package/dist/plugins/dataManager/httpHandlers/addEntityRelations.d.ts +0 -4
  88. package/dist/plugins/dataManager/httpHandlers/countCollectionEntities.d.ts +0 -4
  89. package/dist/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.d.ts +0 -4
  90. package/dist/plugins/dataManager/httpHandlers/createCollectionEntity.d.ts +0 -4
  91. package/dist/plugins/dataManager/httpHandlers/deleteCollectionEntityById.d.ts +0 -4
  92. package/dist/plugins/dataManager/httpHandlers/findCollectionEntities.d.ts +0 -4
  93. package/dist/plugins/dataManager/httpHandlers/findCollectionEntityById.d.ts +0 -4
  94. package/dist/plugins/dataManager/httpHandlers/queryDatabase.d.ts +0 -4
  95. package/dist/plugins/dataManager/httpHandlers/removeEntityRelations.d.ts +0 -4
  96. package/dist/plugins/dataManager/httpHandlers/updateCollectionEntityById.d.ts +0 -4
  97. package/dist/plugins/dataManager/mod.d.ts +0 -16
  98. package/dist/plugins/fileManager/httpHandlers/downloadDocument.d.ts +0 -4
  99. package/dist/plugins/fileManager/httpHandlers/downloadFile.d.ts +0 -4
  100. package/dist/plugins/fileManager/httpHandlers/uploadFile.d.ts +0 -4
  101. package/dist/plugins/fileManager/mod.d.ts +0 -15
  102. package/dist/plugins/metaManager/httpHandlers/getMetaModelDetail.d.ts +0 -4
  103. package/dist/plugins/metaManager/httpHandlers/listMetaModels.d.ts +0 -4
  104. package/dist/plugins/metaManager/mod.d.ts +0 -15
  105. package/dist/plugins/routeManager/httpHandlers/httpProxy.d.ts +0 -4
  106. package/dist/plugins/routeManager/httpHandlers/listMetaRoutes.d.ts +0 -4
  107. package/dist/plugins/routeManager/mod.d.ts +0 -15
  108. package/src/core/httpHandler.ts +0 -29
  109. package/src/core/plugin.ts +0 -13
  110. package/src/plugins/authManager/mod.ts +0 -56
  111. package/src/plugins/dataManager/httpHandlers/countCollectionEntities.ts +0 -22
  112. package/src/plugins/dataManager/mod.ts +0 -154
  113. package/src/plugins/fileManager/mod.ts +0 -48
  114. package/src/plugins/routeManager/mod.ts +0 -97
  115. /package/dist/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.d.ts +0 -0
  116. /package/dist/plugins/{authManager → auth}/models/AccessToken.d.ts +0 -0
  117. /package/dist/plugins/{authManager → auth}/models/index.d.ts +0 -0
  118. /package/dist/plugins/{authManager → auth}/routes/index.d.ts +0 -0
  119. /package/src/plugins/{authManager → auth}/models/AccessToken.ts +0 -0
  120. /package/src/plugins/{authManager → auth}/models/index.ts +0 -0
  121. /package/src/plugins/{authManager → auth}/routes/index.ts +0 -0
@@ -0,0 +1,23 @@
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
+ import runCollectionEntityActionHandler from "~/helpers/runCollectionEntityActionHandler";
3
+ import { removeFiltersWithNullValue } from "~/dataAccess/filterHelper";
4
+ import { ActionHandlerContext } from "~/core/actionHandler";
5
+ import { RapidPlugin } from "~/core/server";
6
+
7
+ export const code = "countCollectionEntities";
8
+
9
+ export async function handler(
10
+ plugin: RapidPlugin,
11
+ ctx: ActionHandlerContext,
12
+ options: RunEntityActionHandlerOptions,
13
+ ) {
14
+ await runCollectionEntityActionHandler(
15
+ ctx,
16
+ options,
17
+ code,
18
+ (dataAccessor, input) => {
19
+ input.filters = removeFiltersWithNullValue(input.filters);
20
+ return dataAccessor.count(input);
21
+ },
22
+ );
23
+ }
@@ -1,15 +1,16 @@
1
- import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
2
  import { mergeInput } from "~/helpers/inputHelper";
3
3
  import { createEntity } from "~/dataAccess/entityManager";
4
4
  import { isArray } from "lodash";
5
- import { HttpHandlerContext } from "~/core/httpHandler";
5
+ import { ActionHandlerContext } from "~/core/actionHandler";
6
+ import { RapidPlugin } from "~/core/server";
6
7
 
7
8
  export const code = "createCollectionEntitiesBatch";
8
9
 
9
10
  export async function handler(
10
- plugin: IPluginInstance,
11
- ctx: HttpHandlerContext,
12
- options: RunEntityHttpHandlerOptions,
11
+ plugin: RapidPlugin,
12
+ ctx: ActionHandlerContext,
13
+ options: RunEntityActionHandlerOptions,
13
14
  ) {
14
15
  const { server, input } = ctx;
15
16
  const { defaultInput, fixedInput } = options;
@@ -1,14 +1,15 @@
1
- import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
2
  import { mergeInput } from "~/helpers/inputHelper";
3
3
  import { createEntity } from "~/dataAccess/entityManager";
4
- import { HttpHandlerContext } from "~/core/httpHandler";
4
+ import { ActionHandlerContext } from "~/core/actionHandler";
5
+ import { RapidPlugin } from "~/core/server";
5
6
 
6
7
  export const code = "createCollectionEntity";
7
8
 
8
9
  export async function handler(
9
- plugin: IPluginInstance,
10
- ctx: HttpHandlerContext,
11
- options: RunEntityHttpHandlerOptions,
10
+ plugin: RapidPlugin,
11
+ ctx: ActionHandlerContext,
12
+ options: RunEntityActionHandlerOptions,
12
13
  ) {
13
14
  const { server, input } = ctx;
14
15
  const { defaultInput, fixedInput } = options;
@@ -1,13 +1,14 @@
1
- import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
2
  import { mapDbRowToEntity } from "~/dataAccess/entityMapper";
3
- import { HttpHandlerContext } from "~/core/httpHandler";
3
+ import { ActionHandlerContext } from "~/core/actionHandler";
4
+ import { RapidPlugin } from "~/core/server";
4
5
 
5
6
  export const code = "deleteCollectionEntityById";
6
7
 
7
8
  export async function handler(
8
- plugin: IPluginInstance,
9
- ctx: HttpHandlerContext,
10
- options: RunEntityHttpHandlerOptions,
9
+ plugin: RapidPlugin,
10
+ ctx: ActionHandlerContext,
11
+ options: RunEntityActionHandlerOptions,
11
12
  ) {
12
13
  console.debug(`Running ${code} handler...`);
13
14
  const { server, input } = ctx;
@@ -16,7 +17,7 @@ export async function handler(
16
17
  const id = input.id;
17
18
  const row = await dataAccessor.findById(id);
18
19
  if (!row) {
19
- ctx.routerContext.status = 200;
20
+ ctx.status = 200;
20
21
  return;
21
22
  }
22
23
 
@@ -34,5 +35,5 @@ export async function handler(
34
35
  },
35
36
  );
36
37
 
37
- ctx.routerContext.status = 200;
38
+ ctx.status = 200;
38
39
  }
@@ -1,18 +1,19 @@
1
1
  import * as _ from "lodash";
2
- import { FindEntityOptions, IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
3
- import runCollectionEntityHttpHandler from "~/helpers/runCollectionEntityHttpHandler";
2
+ import { FindEntityOptions, RunEntityActionHandlerOptions } from "~/types";
3
+ import runCollectionEntityActionHandler from "~/helpers/runCollectionEntityActionHandler";
4
4
  import { findEntities } from "~/dataAccess/entityManager";
5
5
  import { removeFiltersWithNullValue } from "~/dataAccess/filterHelper";
6
- import { HttpHandlerContext } from "~/core/httpHandler";
6
+ import { ActionHandlerContext } from "~/core/actionHandler";
7
+ import { RapidPlugin } from "~/core/server";
7
8
 
8
9
  export const code = "findCollectionEntities";
9
10
 
10
11
  export async function handler(
11
- plugin: IPluginInstance,
12
- ctx: HttpHandlerContext,
13
- options: RunEntityHttpHandlerOptions,
12
+ plugin: RapidPlugin,
13
+ ctx: ActionHandlerContext,
14
+ options: RunEntityActionHandlerOptions,
14
15
  ) {
15
- await runCollectionEntityHttpHandler(
16
+ await runCollectionEntityActionHandler(
16
17
  ctx,
17
18
  options,
18
19
  code,
@@ -1,13 +1,14 @@
1
- import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
2
  import { findEntity } from "~/dataAccess/entityManager";
3
- import { HttpHandlerContext } from "~/core/httpHandler";
3
+ import { ActionHandlerContext } from "~/core/actionHandler";
4
+ import { RapidPlugin } from "~/core/server";
4
5
 
5
6
  export const code = "findCollectionEntityById";
6
7
 
7
8
  export async function handler(
8
- plugin: IPluginInstance,
9
- ctx: HttpHandlerContext,
10
- options: RunEntityHttpHandlerOptions,
9
+ plugin: RapidPlugin,
10
+ ctx: ActionHandlerContext,
11
+ options: RunEntityActionHandlerOptions,
11
12
  ) {
12
13
  console.debug(`Running ${code} handler...`);
13
14
  const { server, input } = ctx;
@@ -1,13 +1,14 @@
1
1
  import * as _ from "lodash";
2
- import { IPluginInstance, RunQueryDatabaseHandlerOptions } from "~/types";
2
+ import { RunQueryDatabaseHandlerOptions } from "~/types";
3
3
  import { mergeInput } from "~/helpers/inputHelper";
4
- import { HttpHandlerContext } from "~/core/httpHandler";
4
+ import { ActionHandlerContext } from "~/core/actionHandler";
5
+ import { RapidPlugin } from "~/core/server";
5
6
 
6
7
  export const code = "queryDatabase";
7
8
 
8
9
  export async function handler(
9
- plugin: IPluginInstance,
10
- ctx: HttpHandlerContext,
10
+ plugin: RapidPlugin,
11
+ ctx: ActionHandlerContext,
11
12
  options: RunQueryDatabaseHandlerOptions,
12
13
  ) {
13
14
  const { server, input } = ctx;
@@ -1,7 +1,8 @@
1
- import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
2
  import { mergeInput } from "~/helpers/inputHelper";
3
3
  import { isRelationProperty } from "~/utilities/rapidUtility";
4
- import { HttpHandlerContext } from "~/core/httpHandler";
4
+ import { ActionHandlerContext } from "~/core/actionHandler";
5
+ import { RapidPlugin } from "~/core/server";
5
6
 
6
7
  export const code = "removeEntityRelations";
7
8
 
@@ -12,9 +13,9 @@ interface RemoveEntityRelationsInput {
12
13
  }
13
14
 
14
15
  export async function handler(
15
- plugin: IPluginInstance,
16
- ctx: HttpHandlerContext,
17
- options: RunEntityHttpHandlerOptions,
16
+ plugin: RapidPlugin,
17
+ ctx: ActionHandlerContext,
18
+ options: RunEntityActionHandlerOptions,
18
19
  ) {
19
20
  const { server, input } = ctx;
20
21
  const { queryBuilder } = server;
@@ -1,16 +1,17 @@
1
- import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
1
+ import { RunEntityActionHandlerOptions } from "~/types";
2
2
  import { getEntityPartChanges } from "~/helpers/entityHelpers";
3
3
  import { mergeInput } from "~/helpers/inputHelper";
4
4
  import { updateEntityById } from "~/dataAccess/entityManager";
5
5
  import { mapDbRowToEntity } from "~/dataAccess/entityMapper";
6
- import { HttpHandlerContext } from "~/core/httpHandler";
6
+ import { ActionHandlerContext } from "~/core/actionHandler";
7
+ import { RapidPlugin } from "~/core/server";
7
8
 
8
9
  export const code = "updateCollectionEntityById";
9
10
 
10
11
  export async function handler(
11
- plugin: IPluginInstance,
12
- ctx: HttpHandlerContext,
13
- options: RunEntityHttpHandlerOptions,
12
+ plugin: RapidPlugin,
13
+ ctx: ActionHandlerContext,
14
+ options: RunEntityActionHandlerOptions,
14
15
  ) {
15
16
  const { server, input } = ctx;
16
17
  const { defaultInput, fixedInput } = options;
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Support manage data in database.
3
+ * This plugin provide:
4
+ * - routes for manage data in database.
5
+ */
6
+
7
+ import * as _ from "lodash";
8
+ import {
9
+ RpdApplicationConfig,
10
+ RpdHttpMethod,
11
+ RpdRoute,
12
+ RunEntityActionHandlerOptions,
13
+ } from "~/types";
14
+
15
+ import * as findCollectionEntities from "./actionHandlers/findCollectionEntities";
16
+ import * as findCollectionEntityById from "./actionHandlers/findCollectionEntityById";
17
+ import * as countCollectionEntities from "./actionHandlers/countCollectionEntities";
18
+ import * as createCollectionEntity from "./actionHandlers/createCollectionEntity";
19
+ import * as createCollectionEntitiesBatch from "./actionHandlers/createCollectionEntitiesBatch";
20
+ import * as updateCollectionEntityById from "./actionHandlers/updateCollectionEntityById";
21
+ import * as deleteCollectionEntityById from "./actionHandlers/deleteCollectionEntityById";
22
+ import * as addEntityRelations from "./actionHandlers/addEntityRelations";
23
+ import * as removeEntityRelations from "./actionHandlers/removeEntityRelations";
24
+ import * as queryDatabase from "./actionHandlers/queryDatabase";
25
+ import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer, RapidPlugin } from "~/core/server";
26
+
27
+
28
+ const routeConfigs: {
29
+ code: string;
30
+ method: RpdHttpMethod;
31
+ endpoint: string;
32
+ handlerCode: string;
33
+ }[] = [
34
+ {
35
+ code: "createBatch",
36
+ method: "POST",
37
+ endpoint: "/operations/create_batch",
38
+ handlerCode: "createCollectionEntitiesBatch",
39
+ },
40
+ {
41
+ code: "find",
42
+ method: "POST",
43
+ endpoint: "/operations/find",
44
+ handlerCode: "findCollectionEntities",
45
+ },
46
+ {
47
+ code: "count",
48
+ method: "POST",
49
+ endpoint: "/operations/count",
50
+ handlerCode: "countCollectionEntities",
51
+ },
52
+ {
53
+ code: "addRelations",
54
+ method: "POST",
55
+ endpoint: "/operations/add_relations",
56
+ handlerCode: "addEntityRelations",
57
+ },
58
+ {
59
+ code: "removeRelations",
60
+ method: "POST",
61
+ endpoint: "/operations/remove_relations",
62
+ handlerCode: "removeEntityRelations",
63
+ },
64
+ {
65
+ code: "getById",
66
+ method: "GET",
67
+ endpoint: "/:id",
68
+ handlerCode: "findCollectionEntityById",
69
+ },
70
+ {
71
+ code: "create",
72
+ method: "POST",
73
+ endpoint: "",
74
+ handlerCode: "createCollectionEntity",
75
+ },
76
+ {
77
+ code: "updateById",
78
+ method: "PATCH",
79
+ endpoint: "/:id",
80
+ handlerCode: "updateCollectionEntityById",
81
+ },
82
+ {
83
+ code: "deleteById",
84
+ method: "DELETE",
85
+ endpoint: "/:id",
86
+ handlerCode: "deleteCollectionEntityById",
87
+ },
88
+ ];
89
+
90
+ class DataManager implements RapidPlugin {
91
+ get code(): string {
92
+ return "dataManager";
93
+ }
94
+
95
+ get description(): string {
96
+ return "对数据进行管理,提供增删改查等接口。";
97
+ }
98
+
99
+ get extendingAbilities(): RpdServerPluginExtendingAbilities[] {
100
+ return [];
101
+ }
102
+
103
+ get configurableTargets(): RpdServerPluginConfigurableTargetOptions[] {
104
+ return [];
105
+ }
106
+
107
+ get configurations(): RpdConfigurationItemOptions[] {
108
+ return [];
109
+ }
110
+
111
+ async initPlugin(server: IRpdServer): Promise<any> {
112
+ }
113
+
114
+ async registerMiddlewares(server: IRpdServer): Promise<any> {
115
+ }
116
+
117
+ async registerActionHandlers(server: IRpdServer): Promise<any> {
118
+ server.registerActionHandler(this, findCollectionEntities);
119
+ server.registerActionHandler(this, findCollectionEntityById);
120
+ server.registerActionHandler(this, countCollectionEntities);
121
+ server.registerActionHandler(this, createCollectionEntity);
122
+ server.registerActionHandler(this, createCollectionEntitiesBatch);
123
+ server.registerActionHandler(this, updateCollectionEntityById);
124
+ server.registerActionHandler(this, addEntityRelations);
125
+ server.registerActionHandler(this, removeEntityRelations);
126
+ server.registerActionHandler(this, deleteCollectionEntityById);
127
+ server.registerActionHandler(this, queryDatabase);
128
+ }
129
+
130
+ async registerEventHandlers(server: IRpdServer): Promise<any> {
131
+ }
132
+
133
+ async registerMessageHandlers(server: IRpdServer): Promise<any> {
134
+ }
135
+
136
+ async registerTaskProcessors(server: IRpdServer): Promise<any> {
137
+ }
138
+
139
+ async onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
140
+ }
141
+
142
+ async configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
143
+ }
144
+
145
+ async configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
146
+ }
147
+
148
+ async configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
149
+ const { models } = applicationConfig;
150
+ const routes: RpdRoute[] = [];
151
+
152
+ models.forEach((model) => {
153
+ const { namespace, singularCode, pluralCode } = model;
154
+
155
+ routeConfigs.forEach((routeConfig) => {
156
+ routes.push({
157
+ namespace,
158
+ name: `${namespace}.${singularCode}.${routeConfig.code}`,
159
+ code: `${namespace}.${singularCode}.${routeConfig.code}`,
160
+ type: "RESTful",
161
+ method: routeConfig.method,
162
+ endpoint: `/${namespace}/${pluralCode}${routeConfig.endpoint}`,
163
+ actions: [
164
+ {
165
+ code: routeConfig.handlerCode,
166
+ config: {
167
+ namespace,
168
+ singularCode,
169
+ } as RunEntityActionHandlerOptions,
170
+ },
171
+ ],
172
+ });
173
+ });
174
+ });
175
+
176
+ server.appendApplicationConfig({ routes });
177
+ }
178
+
179
+ async onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
180
+ console.log("[dataManager.onApplicationLoaded]");
181
+ }
182
+
183
+ async onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
184
+ }
185
+ }
186
+
187
+ export default DataManager;
@@ -1,13 +1,13 @@
1
1
  import path from "path";
2
- import { IPluginInstance } from "~/types";
3
- import { HttpHandlerContext } from "~/core/httpHandler";
2
+ import { ActionHandlerContext } from "~/core/actionHandler";
3
+ import { RapidPlugin } from "~/core/server";
4
4
  import { readFile } from "~/utilities/fsUtility";
5
5
 
6
6
  export const code = "downloadDocument";
7
7
 
8
8
  export async function handler(
9
- plugin: IPluginInstance,
10
- ctx: HttpHandlerContext,
9
+ plugin: RapidPlugin,
10
+ ctx: ActionHandlerContext,
11
11
  options: any,
12
12
  ) {
13
13
  const { server, applicationConfig, routerContext, input } = ctx;
@@ -1,13 +1,13 @@
1
1
  import path from "path";
2
- import { IPluginInstance } from "~/types";
3
2
  import { readFile } from "~/utilities/fsUtility";
4
- import { HttpHandlerContext } from "~/core/httpHandler";
3
+ import { ActionHandlerContext } from "~/core/actionHandler";
4
+ import { RapidPlugin } from "~/core/server";
5
5
 
6
6
  export const code = "downloadFile";
7
7
 
8
8
  export async function handler(
9
- plugin: IPluginInstance,
10
- ctx: HttpHandlerContext,
9
+ plugin: RapidPlugin,
10
+ ctx: ActionHandlerContext,
11
11
  options: any,
12
12
  ) {
13
13
  const { server, applicationConfig, routerContext, input } = ctx;
@@ -1,21 +1,21 @@
1
1
  import { v1 as uuidv1 } from "uuid";
2
- import { IPluginInstance } from "~/types";
3
2
  import { appendFile } from "~/utilities/fsUtility";
4
- import { HttpHandlerContext } from "~/core/httpHandler";
3
+ import { ActionHandlerContext } from "~/core/actionHandler";
5
4
  import path from "path";
6
5
  import { isArray } from "lodash";
6
+ import { RapidPlugin } from "~/core/server";
7
7
 
8
8
  export const code = "uploadFile";
9
9
 
10
10
  export async function handler(
11
- plugin: IPluginInstance,
12
- ctx: HttpHandlerContext,
11
+ plugin: RapidPlugin,
12
+ ctx: ActionHandlerContext,
13
13
  options: any,
14
14
  ) {
15
15
  const { server, applicationConfig, routerContext, input } = ctx;
16
16
  const { request, response } = routerContext;
17
17
 
18
- let file: File | File[] | null = input.files;
18
+ let file: File | File[] | null = input.file || input.files;
19
19
  if (isArray(file)) {
20
20
  file = file[0];
21
21
  }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * File manager plugin
3
+ */
4
+
5
+ import {
6
+ RpdApplicationConfig,
7
+ } from "~/types";
8
+
9
+ import * as downloadDocumentActionHandler from "./actionHandlers/downloadDocument";
10
+ import * as downloadFileActionHandler from "./actionHandlers/downloadFile";
11
+ import * as uploadFileActionHandler from "./actionHandlers/uploadFile";
12
+ import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
13
+
14
+
15
+ class FileManager implements RapidPlugin {
16
+ get code(): string {
17
+ return "fileManager";
18
+ }
19
+
20
+ get description(): string {
21
+ return null;
22
+ }
23
+
24
+ get extendingAbilities(): RpdServerPluginExtendingAbilities[] {
25
+ return [];
26
+ }
27
+
28
+ get configurableTargets(): RpdServerPluginConfigurableTargetOptions[] {
29
+ return [];
30
+ }
31
+
32
+ get configurations(): RpdConfigurationItemOptions[] {
33
+ return [];
34
+ }
35
+
36
+ async initPlugin(server: IRpdServer): Promise<any> {
37
+ }
38
+
39
+ async registerMiddlewares(server: IRpdServer): Promise<any> {
40
+ }
41
+
42
+ async registerActionHandlers(server: IRpdServer): Promise<any> {
43
+ server.registerActionHandler(this, downloadDocumentActionHandler);
44
+ server.registerActionHandler(this, downloadFileActionHandler);
45
+ server.registerActionHandler(this, uploadFileActionHandler);
46
+ }
47
+
48
+ async registerEventHandlers(server: IRpdServer): Promise<any> {
49
+ }
50
+
51
+ async registerMessageHandlers(server: IRpdServer): Promise<any> {
52
+ }
53
+
54
+ async registerTaskProcessors(server: IRpdServer): Promise<any> {
55
+ }
56
+
57
+ async onLoadingApplication(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
58
+ }
59
+
60
+ async configureModels(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
61
+ }
62
+
63
+ async configureModelProperties(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
64
+ }
65
+
66
+ async configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
67
+ }
68
+
69
+ async onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
70
+ console.log("fileManager.onApplicationLoaded");
71
+ }
72
+
73
+ async onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
74
+ }
75
+ }
76
+
77
+ export default FileManager;
@@ -1,11 +1,11 @@
1
- import { HttpHandlerContext } from "~/core/httpHandler";
2
- import { IPluginInstance } from "~/types";
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
3
 
4
4
  export const code = "getMetaModelDetail";
5
5
 
6
6
  export async function handler(
7
- plugin: IPluginInstance,
8
- ctx: HttpHandlerContext,
7
+ plugin: RapidPlugin,
8
+ ctx: ActionHandlerContext,
9
9
  options: any,
10
10
  ) {
11
11
  const { server, input } = ctx;
@@ -1,11 +1,11 @@
1
- import { HttpHandlerContext } from "~/core/httpHandler";
2
- import { IPluginInstance } from "~/types";
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
3
 
4
4
  export const code = "listMetaModels";
5
5
 
6
6
  export async function handler(
7
- plugin: IPluginInstance,
8
- ctx: HttpHandlerContext,
7
+ plugin: RapidPlugin,
8
+ ctx: ActionHandlerContext,
9
9
  options: any,
10
10
  ) {
11
11
  const { applicationConfig } = ctx;
@@ -1,11 +1,11 @@
1
- import { HttpHandlerContext } from "~/core/httpHandler";
2
- import { IPluginInstance } from "~/types";
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
3
 
4
4
  export const code = "listMetaRoutes";
5
5
 
6
6
  export async function handler(
7
- plugin: IPluginInstance,
8
- ctx: HttpHandlerContext,
7
+ plugin: RapidPlugin,
8
+ ctx: ActionHandlerContext,
9
9
  options: any,
10
10
  ) {
11
11
  const { applicationConfig } = ctx;