@ruiapp/rapid-core 0.1.82 → 0.1.83
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/index.js +14 -5
- package/package.json +1 -1
- package/rollup.config.js +16 -16
- 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/dataAccess/dataAccessor.ts +137 -137
- package/src/dataAccess/entityManager.ts +14 -5
- package/src/deno-std/datetime/to_imf.ts +32 -32
- package/src/deno-std/encoding/base64.ts +141 -141
- package/src/facilities/log/LogFacility.ts +35 -35
- package/src/helpers/entityHelpers.ts +76 -76
- 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/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/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/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/fileManage/actionHandlers/downloadDocument.ts +36 -36
- 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/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/actionHandlers/httpProxy.ts +13 -13
- 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/index.ts +9 -9
- 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/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/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/polyfill.ts +5 -5
- package/src/proxy/mod.ts +38 -38
- package/src/utilities/accessControlUtility.ts +33 -33
- 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
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
-
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
-
import { RapidPlugin } from "~/core/server";
|
|
5
|
-
|
|
6
|
-
export const code = "createCollectionEntity";
|
|
7
|
-
|
|
8
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
9
|
-
const { logger, server, input } = ctx;
|
|
10
|
-
|
|
11
|
-
const { defaultInput, fixedInput } = options;
|
|
12
|
-
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
13
|
-
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
|
-
|
|
15
|
-
const entityManager = server.getEntityManager(options.singularCode);
|
|
16
|
-
const output = await entityManager.createEntity(
|
|
17
|
-
{
|
|
18
|
-
entity: input,
|
|
19
|
-
routeContext: ctx.routerContext,
|
|
20
|
-
},
|
|
21
|
-
plugin,
|
|
22
|
-
);
|
|
23
|
-
ctx.output = output;
|
|
24
|
-
}
|
|
1
|
+
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
+
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
+
import { RapidPlugin } from "~/core/server";
|
|
5
|
+
|
|
6
|
+
export const code = "createCollectionEntity";
|
|
7
|
+
|
|
8
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
9
|
+
const { logger, server, input } = ctx;
|
|
10
|
+
|
|
11
|
+
const { defaultInput, fixedInput } = options;
|
|
12
|
+
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
13
|
+
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
|
+
|
|
15
|
+
const entityManager = server.getEntityManager(options.singularCode);
|
|
16
|
+
const output = await entityManager.createEntity(
|
|
17
|
+
{
|
|
18
|
+
entity: input,
|
|
19
|
+
routeContext: ctx.routerContext,
|
|
20
|
+
},
|
|
21
|
+
plugin,
|
|
22
|
+
);
|
|
23
|
+
ctx.output = output;
|
|
24
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { FindEntityOptions, RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
-
import runCollectionEntityActionHandler from "~/helpers/runCollectionEntityActionHandler";
|
|
3
|
-
import { removeFiltersWithNullValue } from "~/helpers/filterHelper";
|
|
4
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
5
|
-
import { RapidPlugin } from "~/core/server";
|
|
6
|
-
|
|
7
|
-
export const code = "findCollectionEntities";
|
|
8
|
-
|
|
9
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
10
|
-
await runCollectionEntityActionHandler(ctx, options, code, async (entityManager, input: FindEntityOptions) => {
|
|
11
|
-
input.filters = removeFiltersWithNullValue(input.filters);
|
|
12
|
-
input.routeContext = ctx.routerContext;
|
|
13
|
-
const entities = await entityManager.findEntities(input);
|
|
14
|
-
const result: {
|
|
15
|
-
list: any;
|
|
16
|
-
total?: any;
|
|
17
|
-
} = { list: entities };
|
|
18
|
-
|
|
19
|
-
if (input.pagination && !input.pagination.withoutTotal) {
|
|
20
|
-
// TOOD: count entities when calling findEntities for performance.
|
|
21
|
-
const countResult = await entityManager.count(input);
|
|
22
|
-
result.total = countResult.count;
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
1
|
+
import { FindEntityOptions, RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
+
import runCollectionEntityActionHandler from "~/helpers/runCollectionEntityActionHandler";
|
|
3
|
+
import { removeFiltersWithNullValue } from "~/helpers/filterHelper";
|
|
4
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
5
|
+
import { RapidPlugin } from "~/core/server";
|
|
6
|
+
|
|
7
|
+
export const code = "findCollectionEntities";
|
|
8
|
+
|
|
9
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
10
|
+
await runCollectionEntityActionHandler(ctx, options, code, async (entityManager, input: FindEntityOptions) => {
|
|
11
|
+
input.filters = removeFiltersWithNullValue(input.filters);
|
|
12
|
+
input.routeContext = ctx.routerContext;
|
|
13
|
+
const entities = await entityManager.findEntities(input);
|
|
14
|
+
const result: {
|
|
15
|
+
list: any;
|
|
16
|
+
total?: any;
|
|
17
|
+
} = { list: entities };
|
|
18
|
+
|
|
19
|
+
if (input.pagination && !input.pagination.withoutTotal) {
|
|
20
|
+
// TOOD: count entities when calling findEntities for performance.
|
|
21
|
+
const countResult = await entityManager.count(input);
|
|
22
|
+
result.total = countResult.count;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
|
|
5
|
-
export const code = "findCollectionEntityById";
|
|
6
|
-
|
|
7
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
8
|
-
const { logger, server, input } = ctx;
|
|
9
|
-
logger.debug(`Running ${code} handler...`, { input });
|
|
10
|
-
const { id } = input;
|
|
11
|
-
|
|
12
|
-
const entityManager = server.getEntityManager(options.singularCode);
|
|
13
|
-
const entity = await entityManager.findById({
|
|
14
|
-
id,
|
|
15
|
-
routeContext: ctx.routerContext,
|
|
16
|
-
});
|
|
17
|
-
if (!entity) {
|
|
18
|
-
throw new Error(`${options.namespace}.${options.singularCode} with id "${id}" was not found.`);
|
|
19
|
-
}
|
|
20
|
-
ctx.output = entity;
|
|
21
|
-
}
|
|
1
|
+
import { RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
3
|
+
import { RapidPlugin } from "~/core/server";
|
|
4
|
+
|
|
5
|
+
export const code = "findCollectionEntityById";
|
|
6
|
+
|
|
7
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
8
|
+
const { logger, server, input } = ctx;
|
|
9
|
+
logger.debug(`Running ${code} handler...`, { input });
|
|
10
|
+
const { id } = input;
|
|
11
|
+
|
|
12
|
+
const entityManager = server.getEntityManager(options.singularCode);
|
|
13
|
+
const entity = await entityManager.findById({
|
|
14
|
+
id,
|
|
15
|
+
routeContext: ctx.routerContext,
|
|
16
|
+
});
|
|
17
|
+
if (!entity) {
|
|
18
|
+
throw new Error(`${options.namespace}.${options.singularCode} with id "${id}" was not found.`);
|
|
19
|
+
}
|
|
20
|
+
ctx.output = entity;
|
|
21
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { RunQueryDatabaseHandlerOptions } from "~/types";
|
|
2
|
-
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
-
import { RapidPlugin } from "~/core/server";
|
|
5
|
-
import { first } from "lodash";
|
|
6
|
-
|
|
7
|
-
export const code = "queryDatabase";
|
|
8
|
-
|
|
9
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunQueryDatabaseHandlerOptions) {
|
|
10
|
-
const { logger, server, input } = ctx;
|
|
11
|
-
|
|
12
|
-
const { sql, querySingle, defaultInput, fixedInput } = options;
|
|
13
|
-
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
14
|
-
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
15
|
-
|
|
16
|
-
const result = await server.queryDatabaseObject(sql, mergedInput);
|
|
17
|
-
if (querySingle) {
|
|
18
|
-
ctx.output = first(result);
|
|
19
|
-
} else {
|
|
20
|
-
ctx.output = result;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
import { RunQueryDatabaseHandlerOptions } from "~/types";
|
|
2
|
+
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
+
import { RapidPlugin } from "~/core/server";
|
|
5
|
+
import { first } from "lodash";
|
|
6
|
+
|
|
7
|
+
export const code = "queryDatabase";
|
|
8
|
+
|
|
9
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunQueryDatabaseHandlerOptions) {
|
|
10
|
+
const { logger, server, input } = ctx;
|
|
11
|
+
|
|
12
|
+
const { sql, querySingle, defaultInput, fixedInput } = options;
|
|
13
|
+
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
14
|
+
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
15
|
+
|
|
16
|
+
const result = await server.queryDatabaseObject(sql, mergedInput);
|
|
17
|
+
if (querySingle) {
|
|
18
|
+
ctx.output = first(result);
|
|
19
|
+
} else {
|
|
20
|
+
ctx.output = result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { RemoveEntityRelationsOptions, RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
-
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
-
import { RapidPlugin } from "~/core/server";
|
|
5
|
-
|
|
6
|
-
export const code = "removeEntityRelations";
|
|
7
|
-
|
|
8
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
9
|
-
const { logger, server, input } = ctx;
|
|
10
|
-
const { defaultInput, fixedInput } = options;
|
|
11
|
-
|
|
12
|
-
const mergedInput: RemoveEntityRelationsOptions = mergeInput(defaultInput, input, fixedInput);
|
|
13
|
-
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
|
-
mergedInput.routeContext = ctx.routerContext;
|
|
15
|
-
|
|
16
|
-
const entityManager = server.getEntityManager(options.singularCode);
|
|
17
|
-
await entityManager.removeRelations(mergedInput, plugin);
|
|
18
|
-
|
|
19
|
-
ctx.output = {};
|
|
20
|
-
}
|
|
1
|
+
import { RemoveEntityRelationsOptions, RunEntityActionHandlerOptions } from "~/types";
|
|
2
|
+
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
+
import { RapidPlugin } from "~/core/server";
|
|
5
|
+
|
|
6
|
+
export const code = "removeEntityRelations";
|
|
7
|
+
|
|
8
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
9
|
+
const { logger, server, input } = ctx;
|
|
10
|
+
const { defaultInput, fixedInput } = options;
|
|
11
|
+
|
|
12
|
+
const mergedInput: RemoveEntityRelationsOptions = mergeInput(defaultInput, input, fixedInput);
|
|
13
|
+
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
|
+
mergedInput.routeContext = ctx.routerContext;
|
|
15
|
+
|
|
16
|
+
const entityManager = server.getEntityManager(options.singularCode);
|
|
17
|
+
await entityManager.removeRelations(mergedInput, plugin);
|
|
18
|
+
|
|
19
|
+
ctx.output = {};
|
|
20
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { RunEntityActionHandlerOptions, UpdateEntityByIdOptions } from "~/types";
|
|
2
|
-
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
-
import { RapidPlugin } from "~/core/server";
|
|
5
|
-
|
|
6
|
-
export const code = "updateCollectionEntityById";
|
|
7
|
-
|
|
8
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
9
|
-
const { logger, server, input } = ctx;
|
|
10
|
-
|
|
11
|
-
const { defaultInput, fixedInput } = options;
|
|
12
|
-
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
13
|
-
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
|
-
|
|
15
|
-
const operation = mergedInput.$operation;
|
|
16
|
-
if (operation) {
|
|
17
|
-
delete mergedInput.$operation;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const stateProperties = mergedInput.$stateProperties;
|
|
21
|
-
if (stateProperties) {
|
|
22
|
-
delete mergedInput.$stateProperties;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const updateEntityByIdOptions: UpdateEntityByIdOptions = {
|
|
26
|
-
id: mergedInput.id,
|
|
27
|
-
entityToSave: mergedInput,
|
|
28
|
-
operation,
|
|
29
|
-
stateProperties,
|
|
30
|
-
routeContext: ctx.routerContext,
|
|
31
|
-
};
|
|
32
|
-
const entityManager = server.getEntityManager(options.singularCode);
|
|
33
|
-
const output = await entityManager.updateEntityById(updateEntityByIdOptions, plugin);
|
|
34
|
-
ctx.output = output;
|
|
35
|
-
}
|
|
1
|
+
import { RunEntityActionHandlerOptions, UpdateEntityByIdOptions } from "~/types";
|
|
2
|
+
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
+
import { RapidPlugin } from "~/core/server";
|
|
5
|
+
|
|
6
|
+
export const code = "updateCollectionEntityById";
|
|
7
|
+
|
|
8
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
9
|
+
const { logger, server, input } = ctx;
|
|
10
|
+
|
|
11
|
+
const { defaultInput, fixedInput } = options;
|
|
12
|
+
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
13
|
+
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
|
+
|
|
15
|
+
const operation = mergedInput.$operation;
|
|
16
|
+
if (operation) {
|
|
17
|
+
delete mergedInput.$operation;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const stateProperties = mergedInput.$stateProperties;
|
|
21
|
+
if (stateProperties) {
|
|
22
|
+
delete mergedInput.$stateProperties;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const updateEntityByIdOptions: UpdateEntityByIdOptions = {
|
|
26
|
+
id: mergedInput.id,
|
|
27
|
+
entityToSave: mergedInput,
|
|
28
|
+
operation,
|
|
29
|
+
stateProperties,
|
|
30
|
+
routeContext: ctx.routerContext,
|
|
31
|
+
};
|
|
32
|
+
const entityManager = server.getEntityManager(options.singularCode);
|
|
33
|
+
const output = await entityManager.updateEntityById(updateEntityByIdOptions, plugin);
|
|
34
|
+
ctx.output = output;
|
|
35
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
3
|
-
import { RapidPlugin } from "~/core/server";
|
|
4
|
-
import { readFile } from "~/utilities/fsUtility";
|
|
5
|
-
|
|
6
|
-
export const code = "downloadDocument";
|
|
7
|
-
|
|
8
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
9
|
-
const { server, applicationConfig, routerContext, input } = ctx;
|
|
10
|
-
const { request, response } = routerContext;
|
|
11
|
-
|
|
12
|
-
const documentDataAccessor = ctx.server.getDataAccessor({
|
|
13
|
-
singularCode: "ecm_document",
|
|
14
|
-
});
|
|
15
|
-
const storageDataAccessor = ctx.server.getDataAccessor({
|
|
16
|
-
singularCode: "ecm_storage_object",
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const document = await documentDataAccessor.findById(input.documentId);
|
|
20
|
-
if (!document) {
|
|
21
|
-
ctx.output = { error: new Error("Document not found.") };
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const storageObject = await storageDataAccessor.findById(document.storage_object_id);
|
|
25
|
-
if (!storageObject) {
|
|
26
|
-
ctx.output = { error: new Error("Storage object not found.") };
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const fileKey = storageObject.key;
|
|
31
|
-
const filePathName = path.join(server.config.localFileStoragePath, fileKey);
|
|
32
|
-
const attachmentFileName = document.name;
|
|
33
|
-
|
|
34
|
-
response.body = await readFile(filePathName);
|
|
35
|
-
response.headers.set("Content-Disposition", `attachment; filename="${encodeURIComponent(attachmentFileName)}"`);
|
|
36
|
-
}
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
3
|
+
import { RapidPlugin } from "~/core/server";
|
|
4
|
+
import { readFile } from "~/utilities/fsUtility";
|
|
5
|
+
|
|
6
|
+
export const code = "downloadDocument";
|
|
7
|
+
|
|
8
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
9
|
+
const { server, applicationConfig, routerContext, input } = ctx;
|
|
10
|
+
const { request, response } = routerContext;
|
|
11
|
+
|
|
12
|
+
const documentDataAccessor = ctx.server.getDataAccessor({
|
|
13
|
+
singularCode: "ecm_document",
|
|
14
|
+
});
|
|
15
|
+
const storageDataAccessor = ctx.server.getDataAccessor({
|
|
16
|
+
singularCode: "ecm_storage_object",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const document = await documentDataAccessor.findById(input.documentId);
|
|
20
|
+
if (!document) {
|
|
21
|
+
ctx.output = { error: new Error("Document not found.") };
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const storageObject = await storageDataAccessor.findById(document.storage_object_id);
|
|
25
|
+
if (!storageObject) {
|
|
26
|
+
ctx.output = { error: new Error("Storage object not found.") };
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const fileKey = storageObject.key;
|
|
31
|
+
const filePathName = path.join(server.config.localFileStoragePath, fileKey);
|
|
32
|
+
const attachmentFileName = document.name;
|
|
33
|
+
|
|
34
|
+
response.body = await readFile(filePathName);
|
|
35
|
+
response.headers.set("Content-Disposition", `attachment; filename="${encodeURIComponent(attachmentFileName)}"`);
|
|
36
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { v1 as uuidv1 } from "uuid";
|
|
2
|
-
import { appendFile } from "~/utilities/fsUtility";
|
|
3
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { isArray } from "lodash";
|
|
6
|
-
import { RapidPlugin } from "~/core/server";
|
|
7
|
-
|
|
8
|
-
export const code = "uploadFile";
|
|
9
|
-
|
|
10
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
11
|
-
const { server, applicationConfig, routerContext, input } = ctx;
|
|
12
|
-
const { request, response } = routerContext;
|
|
13
|
-
|
|
14
|
-
let file: File | File[] | null = input.file || input.files;
|
|
15
|
-
if (isArray(file)) {
|
|
16
|
-
file = file[0];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!file) {
|
|
20
|
-
ctx.status = 400;
|
|
21
|
-
ctx.output = { error: "File not found in request body." };
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const extName = path.extname(file.name);
|
|
26
|
-
const fileKey = `${uuidv1()}${extName}`;
|
|
27
|
-
const filePathName = path.join(server.config.localFileStoragePath, fileKey);
|
|
28
|
-
|
|
29
|
-
const fileBuffer = await file.arrayBuffer();
|
|
30
|
-
await appendFile(filePathName, fileBuffer);
|
|
31
|
-
|
|
32
|
-
ctx.output = { ok: true, fileKey };
|
|
33
|
-
}
|
|
1
|
+
import { v1 as uuidv1 } from "uuid";
|
|
2
|
+
import { appendFile } from "~/utilities/fsUtility";
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { isArray } from "lodash";
|
|
6
|
+
import { RapidPlugin } from "~/core/server";
|
|
7
|
+
|
|
8
|
+
export const code = "uploadFile";
|
|
9
|
+
|
|
10
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
11
|
+
const { server, applicationConfig, routerContext, input } = ctx;
|
|
12
|
+
const { request, response } = routerContext;
|
|
13
|
+
|
|
14
|
+
let file: File | File[] | null = input.file || input.files;
|
|
15
|
+
if (isArray(file)) {
|
|
16
|
+
file = file[0];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!file) {
|
|
20
|
+
ctx.status = 400;
|
|
21
|
+
ctx.output = { error: "File not found in request body." };
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const extName = path.extname(file.name);
|
|
26
|
+
const fileKey = `${uuidv1()}${extName}`;
|
|
27
|
+
const filePathName = path.join(server.config.localFileStoragePath, fileKey);
|
|
28
|
+
|
|
29
|
+
const fileBuffer = await file.arrayBuffer();
|
|
30
|
+
await appendFile(filePathName, fileBuffer);
|
|
31
|
+
|
|
32
|
+
ctx.output = { ok: true, fileKey };
|
|
33
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { RpdRoute } from "~/types";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
namespace: "ecm",
|
|
5
|
-
name: "ecm.downloadDocument",
|
|
6
|
-
code: "ecm.downloadDocument",
|
|
7
|
-
type: "RESTful",
|
|
8
|
-
method: "GET",
|
|
9
|
-
endpoint: "/download/document",
|
|
10
|
-
actions: [
|
|
11
|
-
{
|
|
12
|
-
code: "downloadDocument",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
} satisfies RpdRoute;
|
|
1
|
+
import { RpdRoute } from "~/types";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespace: "ecm",
|
|
5
|
+
name: "ecm.downloadDocument",
|
|
6
|
+
code: "ecm.downloadDocument",
|
|
7
|
+
type: "RESTful",
|
|
8
|
+
method: "GET",
|
|
9
|
+
endpoint: "/download/document",
|
|
10
|
+
actions: [
|
|
11
|
+
{
|
|
12
|
+
code: "downloadDocument",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
} satisfies RpdRoute;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { RpdRoute } from "~/types";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
namespace: "ecm",
|
|
5
|
-
name: "ecm.downloadFile",
|
|
6
|
-
code: "ecm.downloadFile",
|
|
7
|
-
type: "RESTful",
|
|
8
|
-
method: "GET",
|
|
9
|
-
endpoint: "/download/file",
|
|
10
|
-
actions: [
|
|
11
|
-
{
|
|
12
|
-
code: "downloadFile",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
} satisfies RpdRoute;
|
|
1
|
+
import { RpdRoute } from "~/types";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespace: "ecm",
|
|
5
|
+
name: "ecm.downloadFile",
|
|
6
|
+
code: "ecm.downloadFile",
|
|
7
|
+
type: "RESTful",
|
|
8
|
+
method: "GET",
|
|
9
|
+
endpoint: "/download/file",
|
|
10
|
+
actions: [
|
|
11
|
+
{
|
|
12
|
+
code: "downloadFile",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
} satisfies RpdRoute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import getMyProfile from "./uploadFile";
|
|
2
|
-
import signin from "./downloadFile";
|
|
3
|
-
import signout from "./downloadDocument";
|
|
4
|
-
|
|
5
|
-
export default [getMyProfile, signin, signout];
|
|
1
|
+
import getMyProfile from "./uploadFile";
|
|
2
|
+
import signin from "./downloadFile";
|
|
3
|
+
import signout from "./downloadDocument";
|
|
4
|
+
|
|
5
|
+
export default [getMyProfile, signin, signout];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { RpdRoute } from "~/types";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
namespace: "ecm",
|
|
5
|
-
name: "ecm.uploadFile",
|
|
6
|
-
code: "ecm.uploadFile",
|
|
7
|
-
type: "RESTful",
|
|
8
|
-
method: "POST",
|
|
9
|
-
endpoint: "/upload",
|
|
10
|
-
actions: [
|
|
11
|
-
{
|
|
12
|
-
code: "uploadFile",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
} satisfies RpdRoute;
|
|
1
|
+
import { RpdRoute } from "~/types";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespace: "ecm",
|
|
5
|
+
name: "ecm.uploadFile",
|
|
6
|
+
code: "ecm.uploadFile",
|
|
7
|
+
type: "RESTful",
|
|
8
|
+
method: "POST",
|
|
9
|
+
endpoint: "/upload",
|
|
10
|
+
actions: [
|
|
11
|
+
{
|
|
12
|
+
code: "uploadFile",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
} satisfies RpdRoute;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
-
import { RapidPlugin } from "~/core/server";
|
|
3
|
-
|
|
4
|
-
export const code = "getMetaModelDetail";
|
|
5
|
-
|
|
6
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
7
|
-
const { server, input } = ctx;
|
|
8
|
-
const model = server.getModel(input);
|
|
9
|
-
ctx.output = model;
|
|
10
|
-
}
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "~/core/server";
|
|
3
|
+
|
|
4
|
+
export const code = "getMetaModelDetail";
|
|
5
|
+
|
|
6
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
7
|
+
const { server, input } = ctx;
|
|
8
|
+
const model = server.getModel(input);
|
|
9
|
+
ctx.output = model;
|
|
10
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
-
import { RapidPlugin } from "~/core/server";
|
|
3
|
-
|
|
4
|
-
export const code = "listMetaModels";
|
|
5
|
-
|
|
6
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
7
|
-
const { applicationConfig } = ctx;
|
|
8
|
-
ctx.output = { list: applicationConfig.models };
|
|
9
|
-
}
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "~/core/server";
|
|
3
|
+
|
|
4
|
+
export const code = "listMetaModels";
|
|
5
|
+
|
|
6
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
7
|
+
const { applicationConfig } = ctx;
|
|
8
|
+
ctx.output = { list: applicationConfig.models };
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
-
import { RapidPlugin } from "~/core/server";
|
|
3
|
-
|
|
4
|
-
export const code = "listMetaRoutes";
|
|
5
|
-
|
|
6
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
7
|
-
const { applicationConfig } = ctx;
|
|
8
|
-
ctx.output = { list: applicationConfig.routes };
|
|
9
|
-
}
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "~/core/server";
|
|
3
|
+
|
|
4
|
+
export const code = "listMetaRoutes";
|
|
5
|
+
|
|
6
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: any) {
|
|
7
|
+
const { applicationConfig } = ctx;
|
|
8
|
+
ctx.output = { list: applicationConfig.routes };
|
|
9
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { RunProxyHandlerOptions } from "~/types";
|
|
2
|
-
import { doProxy } from "~/proxy/mod";
|
|
3
|
-
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
-
import { RapidPlugin } from "~/core/server";
|
|
5
|
-
|
|
6
|
-
export const code = "httpProxy";
|
|
7
|
-
|
|
8
|
-
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunProxyHandlerOptions) {
|
|
9
|
-
const { logger } = ctx;
|
|
10
|
-
logger.debug(`Running ${code} handler...`);
|
|
11
|
-
|
|
12
|
-
await doProxy(ctx.routerContext, options);
|
|
13
|
-
}
|
|
1
|
+
import { RunProxyHandlerOptions } from "~/types";
|
|
2
|
+
import { doProxy } from "~/proxy/mod";
|
|
3
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
|
+
import { RapidPlugin } from "~/core/server";
|
|
5
|
+
|
|
6
|
+
export const code = "httpProxy";
|
|
7
|
+
|
|
8
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunProxyHandlerOptions) {
|
|
9
|
+
const { logger } = ctx;
|
|
10
|
+
logger.debug(`Running ${code} handler...`);
|
|
11
|
+
|
|
12
|
+
await doProxy(ctx.routerContext, options);
|
|
13
|
+
}
|