@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.
- package/dist/bootstrapApplicationConfig.d.ts +1 -1
- package/dist/core/actionHandler.d.ts +17 -0
- package/dist/core/pluginManager.d.ts +31 -26
- package/dist/core/server.d.ts +24 -24
- package/dist/helpers/runCollectionEntityActionHandler.d.ts +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3335 -3279
- package/dist/plugins/auth/actionHandlers/createSession.d.ts +8 -0
- package/dist/plugins/auth/actionHandlers/deleteSession.d.ts +4 -0
- package/dist/plugins/auth/actionHandlers/getMyProfile.d.ts +4 -0
- package/dist/plugins/auth/mod.d.ts +25 -0
- package/dist/plugins/{authManager → auth}/routes/getMyProfile.d.ts +1 -1
- package/dist/plugins/{authManager → auth}/routes/signin.d.ts +1 -1
- package/dist/plugins/{authManager → auth}/routes/signout.d.ts +1 -1
- package/dist/plugins/dataManage/actionHandlers/addEntityRelations.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/countCollectionEntities.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/createCollectionEntity.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/deleteCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/findCollectionEntities.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/findCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/queryDatabase.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/removeEntityRelations.d.ts +5 -0
- package/dist/plugins/dataManage/actionHandlers/updateCollectionEntityById.d.ts +5 -0
- package/dist/plugins/dataManage/mod.d.ts +27 -0
- package/dist/plugins/fileManage/actionHandlers/downloadDocument.d.ts +4 -0
- package/dist/plugins/fileManage/actionHandlers/downloadFile.d.ts +4 -0
- package/dist/plugins/fileManage/actionHandlers/uploadFile.d.ts +4 -0
- package/dist/plugins/fileManage/mod.d.ts +25 -0
- package/dist/plugins/metaManage/actionHandlers/getMetaModelDetail.d.ts +4 -0
- package/dist/plugins/metaManage/actionHandlers/listMetaModels.d.ts +4 -0
- package/dist/plugins/metaManage/actionHandlers/listMetaRoutes.d.ts +4 -0
- package/dist/plugins/metaManage/mod.d.ts +25 -0
- package/dist/plugins/routeManage/actionHandlers/httpProxy.d.ts +5 -0
- package/dist/plugins/routeManage/mod.d.ts +25 -0
- package/dist/plugins/webhooks/mod.d.ts +25 -11
- package/dist/server.d.ts +7 -6
- package/dist/types.d.ts +10 -12
- package/package.json +1 -1
- package/src/bootstrapApplicationConfig.ts +6 -6
- package/src/core/actionHandler.ts +23 -0
- package/src/core/pluginManager.ts +107 -108
- package/src/core/routesBuilder.ts +4 -4
- package/src/core/server.ts +26 -44
- package/src/dataAccess/dataAccessor.ts +1 -1
- package/src/helpers/{runCollectionEntityHttpHandler.ts → runCollectionEntityActionHandler.ts} +5 -5
- package/src/index.ts +9 -0
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/createSession.ts +4 -4
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/deleteSession.ts +4 -4
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/getMyProfile.ts +4 -4
- package/src/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.ts +2 -2
- package/src/plugins/auth/mod.ts +80 -0
- package/src/plugins/{authManager → auth}/routes/getMyProfile.ts +1 -1
- package/src/plugins/{authManager → auth}/routes/signin.ts +1 -1
- package/src/plugins/{authManager → auth}/routes/signout.ts +1 -1
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/addEntityRelations.ts +6 -5
- package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +23 -0
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntitiesBatch.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntity.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/deleteCollectionEntityById.ts +8 -7
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntities.ts +8 -7
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntityById.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/queryDatabase.ts +5 -4
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/removeEntityRelations.ts +6 -5
- package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/updateCollectionEntityById.ts +6 -5
- package/src/plugins/dataManage/mod.ts +187 -0
- package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadDocument.ts +4 -4
- package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadFile.ts +4 -4
- package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/uploadFile.ts +5 -5
- package/src/plugins/fileManage/mod.ts +77 -0
- package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/getMetaModelDetail.ts +4 -4
- package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/listMetaModels.ts +4 -4
- package/src/plugins/{routeManager/httpHandlers → metaManage/actionHandlers}/listMetaRoutes.ts +4 -4
- package/src/plugins/{metaManager → metaManage}/mod.ts +88 -55
- package/src/plugins/{routeManager/httpHandlers → routeManage/actionHandlers}/httpProxy.ts +5 -4
- package/src/plugins/routeManage/mod.ts +92 -0
- package/src/plugins/webhooks/mod.ts +134 -94
- package/src/server.ts +28 -21
- package/src/types.ts +11 -14
- package/dist/core/httpHandler.d.ts +0 -18
- package/dist/core/plugin.d.ts +0 -6
- package/dist/helpers/runCollectionEntityHttpHandler.d.ts +0 -5
- package/dist/plugins/authManager/httpHandlers/createSession.d.ts +0 -8
- package/dist/plugins/authManager/httpHandlers/deleteSession.d.ts +0 -4
- package/dist/plugins/authManager/httpHandlers/getMyProfile.d.ts +0 -4
- package/dist/plugins/authManager/mod.d.ts +0 -16
- package/dist/plugins/dataManager/httpHandlers/addEntityRelations.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/countCollectionEntities.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntity.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/deleteCollectionEntityById.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntities.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntityById.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/queryDatabase.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/removeEntityRelations.d.ts +0 -4
- package/dist/plugins/dataManager/httpHandlers/updateCollectionEntityById.d.ts +0 -4
- package/dist/plugins/dataManager/mod.d.ts +0 -16
- package/dist/plugins/fileManager/httpHandlers/downloadDocument.d.ts +0 -4
- package/dist/plugins/fileManager/httpHandlers/downloadFile.d.ts +0 -4
- package/dist/plugins/fileManager/httpHandlers/uploadFile.d.ts +0 -4
- package/dist/plugins/fileManager/mod.d.ts +0 -15
- package/dist/plugins/metaManager/httpHandlers/getMetaModelDetail.d.ts +0 -4
- package/dist/plugins/metaManager/httpHandlers/listMetaModels.d.ts +0 -4
- package/dist/plugins/metaManager/mod.d.ts +0 -15
- package/dist/plugins/routeManager/httpHandlers/httpProxy.d.ts +0 -4
- package/dist/plugins/routeManager/httpHandlers/listMetaRoutes.d.ts +0 -4
- package/dist/plugins/routeManager/mod.d.ts +0 -15
- package/src/core/httpHandler.ts +0 -29
- package/src/core/plugin.ts +0 -13
- package/src/plugins/authManager/mod.ts +0 -56
- package/src/plugins/dataManager/httpHandlers/countCollectionEntities.ts +0 -22
- package/src/plugins/dataManager/mod.ts +0 -154
- package/src/plugins/fileManager/mod.ts +0 -48
- package/src/plugins/routeManager/mod.ts +0 -97
- /package/dist/plugins/{authManager/httpHandlers → auth/actionHandlers}/index.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/models/AccessToken.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/models/index.d.ts +0 -0
- /package/dist/plugins/{authManager → auth}/routes/index.d.ts +0 -0
- /package/src/plugins/{authManager → auth}/models/AccessToken.ts +0 -0
- /package/src/plugins/{authManager → auth}/models/index.ts +0 -0
- /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 {
|
|
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 {
|
|
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:
|
|
11
|
-
ctx:
|
|
12
|
-
options:
|
|
11
|
+
plugin: RapidPlugin,
|
|
12
|
+
ctx: ActionHandlerContext,
|
|
13
|
+
options: RunEntityActionHandlerOptions,
|
|
13
14
|
) {
|
|
14
15
|
const { server, input } = ctx;
|
|
15
16
|
const { defaultInput, fixedInput } = options;
|
package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/createCollectionEntity.ts
RENAMED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
2
|
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
3
|
import { createEntity } from "~/dataAccess/entityManager";
|
|
4
|
-
import {
|
|
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:
|
|
10
|
-
ctx:
|
|
11
|
-
options:
|
|
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 {
|
|
1
|
+
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
2
|
import { mapDbRowToEntity } from "~/dataAccess/entityMapper";
|
|
3
|
-
import {
|
|
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:
|
|
9
|
-
ctx:
|
|
10
|
-
options:
|
|
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.
|
|
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.
|
|
38
|
+
ctx.status = 200;
|
|
38
39
|
}
|
package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/findCollectionEntities.ts
RENAMED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import * as _ from "lodash";
|
|
2
|
-
import { FindEntityOptions,
|
|
3
|
-
import
|
|
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 {
|
|
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:
|
|
12
|
-
ctx:
|
|
13
|
-
options:
|
|
12
|
+
plugin: RapidPlugin,
|
|
13
|
+
ctx: ActionHandlerContext,
|
|
14
|
+
options: RunEntityActionHandlerOptions,
|
|
14
15
|
) {
|
|
15
|
-
await
|
|
16
|
+
await runCollectionEntityActionHandler(
|
|
16
17
|
ctx,
|
|
17
18
|
options,
|
|
18
19
|
code,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
2
|
import { findEntity } from "~/dataAccess/entityManager";
|
|
3
|
-
import {
|
|
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:
|
|
9
|
-
ctx:
|
|
10
|
-
options:
|
|
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 {
|
|
2
|
+
import { RunQueryDatabaseHandlerOptions } from "~/types";
|
|
3
3
|
import { mergeInput } from "~/helpers/inputHelper";
|
|
4
|
-
import {
|
|
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:
|
|
10
|
-
ctx:
|
|
10
|
+
plugin: RapidPlugin,
|
|
11
|
+
ctx: ActionHandlerContext,
|
|
11
12
|
options: RunQueryDatabaseHandlerOptions,
|
|
12
13
|
) {
|
|
13
14
|
const { server, input } = ctx;
|
package/src/plugins/{dataManager/httpHandlers → dataManage/actionHandlers}/removeEntityRelations.ts
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
2
|
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
3
|
import { isRelationProperty } from "~/utilities/rapidUtility";
|
|
4
|
-
import {
|
|
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:
|
|
16
|
-
ctx:
|
|
17
|
-
options:
|
|
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 {
|
|
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 {
|
|
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:
|
|
12
|
-
ctx:
|
|
13
|
-
options:
|
|
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;
|
package/src/plugins/{fileManager/httpHandlers → fileManage/actionHandlers}/downloadDocument.ts
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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:
|
|
10
|
-
ctx:
|
|
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 {
|
|
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:
|
|
10
|
-
ctx:
|
|
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 {
|
|
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:
|
|
12
|
-
ctx:
|
|
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;
|
package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/getMetaModelDetail.ts
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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:
|
|
8
|
-
ctx:
|
|
7
|
+
plugin: RapidPlugin,
|
|
8
|
+
ctx: ActionHandlerContext,
|
|
9
9
|
options: any,
|
|
10
10
|
) {
|
|
11
11
|
const { server, input } = ctx;
|
package/src/plugins/{metaManager/httpHandlers → metaManage/actionHandlers}/listMetaModels.ts
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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:
|
|
8
|
-
ctx:
|
|
7
|
+
plugin: RapidPlugin,
|
|
8
|
+
ctx: ActionHandlerContext,
|
|
9
9
|
options: any,
|
|
10
10
|
) {
|
|
11
11
|
const { applicationConfig } = ctx;
|
package/src/plugins/{routeManager/httpHandlers → metaManage/actionHandlers}/listMetaRoutes.ts
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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:
|
|
8
|
-
ctx:
|
|
7
|
+
plugin: RapidPlugin,
|
|
8
|
+
ctx: ActionHandlerContext,
|
|
9
9
|
options: any,
|
|
10
10
|
) {
|
|
11
11
|
const { applicationConfig } = ctx;
|