@ruiapp/rapid-core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrapApplicationConfig.d.ts +3 -0
- package/dist/core/eventManager.d.ts +7 -0
- package/dist/core/http-types.d.ts +3 -0
- package/dist/core/httpHandler.d.ts +18 -0
- package/dist/core/plugin.d.ts +6 -0
- package/dist/core/pluginManager.d.ts +27 -0
- package/dist/core/request.d.ts +15 -0
- package/dist/core/response.d.ts +17 -0
- package/dist/core/routeContext.d.ts +17 -0
- package/dist/core/routesBuilder.d.ts +4 -0
- package/dist/core/server.d.ts +83 -0
- package/dist/dataAccess/dataAccessor.d.ts +20 -0
- package/dist/dataAccess/entityManager.d.ts +6 -0
- package/dist/dataAccess/entityMapper.d.ts +3 -0
- package/dist/dataAccess/filterHelper.d.ts +2 -0
- package/dist/dataAccess/propertyMapper.d.ts +3 -0
- package/dist/deno-std/assert/assert.d.ts +2 -0
- package/dist/deno-std/assert/assertion_error.d.ts +4 -0
- package/dist/deno-std/datetime/to_imf.d.ts +17 -0
- package/dist/deno-std/http/cookie.d.ts +134 -0
- package/dist/helpers/entityHelpers.d.ts +1 -0
- package/dist/helpers/inputHelper.d.ts +1 -0
- package/dist/helpers/runCollectionEntityHttpHandler.d.ts +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3590 -0
- package/dist/plugins/authManager/httpHandlers/createSession.d.ts +8 -0
- package/dist/plugins/authManager/httpHandlers/deleteSession.d.ts +4 -0
- package/dist/plugins/authManager/httpHandlers/getMyProfile.d.ts +4 -0
- package/dist/plugins/authManager/httpHandlers/index.d.ts +5 -0
- package/dist/plugins/authManager/mod.d.ts +16 -0
- package/dist/plugins/authManager/models/AccessToken.d.ts +3 -0
- package/dist/plugins/authManager/models/index.d.ts +2 -0
- package/dist/plugins/authManager/routes/getMyProfile.d.ts +3 -0
- package/dist/plugins/authManager/routes/index.d.ts +2 -0
- package/dist/plugins/authManager/routes/signin.d.ts +3 -0
- package/dist/plugins/authManager/routes/signout.d.ts +3 -0
- package/dist/plugins/dataManager/httpHandlers/addEntityRelations.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/countCollectionEntities.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/createCollectionEntity.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/deleteCollectionEntityById.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntities.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/findCollectionEntityById.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/queryDatabase.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/removeEntityRelations.d.ts +4 -0
- package/dist/plugins/dataManager/httpHandlers/updateCollectionEntityById.d.ts +4 -0
- package/dist/plugins/dataManager/mod.d.ts +16 -0
- package/dist/plugins/metaManager/httpHandlers/getMetaModelDetail.d.ts +4 -0
- package/dist/plugins/metaManager/httpHandlers/listMetaModels.d.ts +4 -0
- package/dist/plugins/metaManager/mod.d.ts +15 -0
- package/dist/plugins/routeManager/httpHandlers/httpProxy.d.ts +4 -0
- package/dist/plugins/routeManager/httpHandlers/listMetaRoutes.d.ts +4 -0
- package/dist/plugins/routeManager/mod.d.ts +15 -0
- package/dist/plugins/webhooks/mod.d.ts +24 -0
- package/dist/plugins/webhooks/pluginConfig.d.ts +48 -0
- package/dist/polyfill.d.ts +1 -0
- package/dist/proxy/mod.d.ts +13 -0
- package/dist/proxy/types.d.ts +17 -0
- package/dist/queryBuilder/index.d.ts +1 -0
- package/dist/queryBuilder/queryBuilder.d.ts +34 -0
- package/dist/server.d.ts +31 -0
- package/dist/types.d.ts +327 -0
- package/dist/utilities/httpUtility.d.ts +1 -0
- package/dist/utilities/jwtUtility.d.ts +8 -0
- package/dist/utilities/rapidUtility.d.ts +2 -0
- package/dist/utilities/typeUtility.d.ts +3 -0
- package/package.json +29 -0
- package/rollup.config.js +20 -0
- package/src/bootstrapApplicationConfig.ts +524 -0
- package/src/core/eventManager.ts +21 -0
- package/src/core/http-types.ts +4 -0
- package/src/core/httpHandler.ts +29 -0
- package/src/core/plugin.ts +13 -0
- package/src/core/pluginManager.ts +143 -0
- package/src/core/request.ts +23 -0
- package/src/core/response.ts +77 -0
- package/src/core/routeContext.ts +38 -0
- package/src/core/routesBuilder.ts +86 -0
- package/src/core/server.ts +144 -0
- package/src/dataAccess/dataAccessor.ts +110 -0
- package/src/dataAccess/entityManager.ts +651 -0
- package/src/dataAccess/entityMapper.ts +74 -0
- package/src/dataAccess/filterHelper.ts +47 -0
- package/src/dataAccess/propertyMapper.ts +27 -0
- package/src/deno-std/assert/assert.ts +9 -0
- package/src/deno-std/assert/assertion_error.ts +7 -0
- package/src/deno-std/datetime/to_imf.ts +47 -0
- package/src/deno-std/http/cookie.ts +398 -0
- package/src/helpers/entityHelpers.ts +24 -0
- package/src/helpers/inputHelper.ts +11 -0
- package/src/helpers/runCollectionEntityHttpHandler.ts +34 -0
- package/src/index.ts +12 -0
- package/src/plugins/authManager/httpHandlers/createSession.ts +57 -0
- package/src/plugins/authManager/httpHandlers/deleteSession.ts +22 -0
- package/src/plugins/authManager/httpHandlers/getMyProfile.ts +43 -0
- package/src/plugins/authManager/httpHandlers/index.ts +10 -0
- package/src/plugins/authManager/mod.ts +56 -0
- package/src/plugins/authManager/models/AccessToken.ts +56 -0
- package/src/plugins/authManager/models/index.ts +5 -0
- package/src/plugins/authManager/routes/getMyProfile.ts +15 -0
- package/src/plugins/authManager/routes/index.ts +9 -0
- package/src/plugins/authManager/routes/signin.ts +15 -0
- package/src/plugins/authManager/routes/signout.ts +15 -0
- package/src/plugins/dataManager/httpHandlers/addEntityRelations.ts +76 -0
- package/src/plugins/dataManager/httpHandlers/countCollectionEntities.ts +22 -0
- package/src/plugins/dataManager/httpHandlers/createCollectionEntitiesBatch.ts +57 -0
- package/src/plugins/dataManager/httpHandlers/createCollectionEntity.ts +43 -0
- package/src/plugins/dataManager/httpHandlers/deleteCollectionEntityById.ts +38 -0
- package/src/plugins/dataManager/httpHandlers/findCollectionEntities.ts +35 -0
- package/src/plugins/dataManager/httpHandlers/findCollectionEntityById.ts +30 -0
- package/src/plugins/dataManager/httpHandlers/queryDatabase.ts +29 -0
- package/src/plugins/dataManager/httpHandlers/removeEntityRelations.ts +72 -0
- package/src/plugins/dataManager/httpHandlers/updateCollectionEntityById.ts +53 -0
- package/src/plugins/dataManager/mod.ts +150 -0
- package/src/plugins/metaManager/httpHandlers/getMetaModelDetail.ts +14 -0
- package/src/plugins/metaManager/httpHandlers/listMetaModels.ts +13 -0
- package/src/plugins/metaManager/mod.ts +419 -0
- package/src/plugins/routeManager/httpHandlers/httpProxy.ts +15 -0
- package/src/plugins/routeManager/httpHandlers/listMetaRoutes.ts +13 -0
- package/src/plugins/routeManager/mod.ts +97 -0
- package/src/plugins/webhooks/mod.ts +144 -0
- package/src/plugins/webhooks/pluginConfig.ts +74 -0
- package/src/polyfill.ts +5 -0
- package/src/proxy/mod.ts +47 -0
- package/src/proxy/types.ts +21 -0
- package/src/queryBuilder/index.ts +1 -0
- package/src/queryBuilder/queryBuilder.ts +424 -0
- package/src/server.ts +192 -0
- package/src/types.ts +438 -0
- package/src/utilities/httpUtility.ts +23 -0
- package/src/utilities/jwtUtility.ts +16 -0
- package/src/utilities/rapidUtility.ts +5 -0
- package/src/utilities/typeUtility.ts +11 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
+
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
|
+
import { isRelationProperty } from "~/utilities/rapidUtility";
|
|
4
|
+
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
5
|
+
|
|
6
|
+
export const code = "removeEntityRelations";
|
|
7
|
+
|
|
8
|
+
interface RemoveEntityRelationsInput {
|
|
9
|
+
id: number;
|
|
10
|
+
property: string;
|
|
11
|
+
relations: {id?: number, [k: string]: any}[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function handler(
|
|
15
|
+
plugin: IPluginInstance,
|
|
16
|
+
ctx: HttpHandlerContext,
|
|
17
|
+
options: RunEntityHttpHandlerOptions,
|
|
18
|
+
) {
|
|
19
|
+
const { server, input } = ctx;
|
|
20
|
+
const { queryBuilder } = server;
|
|
21
|
+
const { defaultInput, fixedInput } = options;
|
|
22
|
+
|
|
23
|
+
console.debug(`Running ${code} handler...`);
|
|
24
|
+
|
|
25
|
+
console.debug(`defaultInput: ${JSON.stringify(defaultInput)}`);
|
|
26
|
+
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
27
|
+
console.debug(`fixedInput: ${JSON.stringify(fixedInput)}`);
|
|
28
|
+
console.debug(`mergedInput: ${JSON.stringify(mergedInput)}`);
|
|
29
|
+
|
|
30
|
+
const dataAccessor = server.getDataAccessor(options);
|
|
31
|
+
const model = dataAccessor.getModel();
|
|
32
|
+
|
|
33
|
+
const {id, property, relations} = mergedInput as RemoveEntityRelationsInput;
|
|
34
|
+
const row = await dataAccessor.findById(id);
|
|
35
|
+
if (!row) {
|
|
36
|
+
throw new Error(`${options.namespace}.${options.singularCode} with id "${id}" was not found.`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(mergedInput);
|
|
40
|
+
|
|
41
|
+
const relationProperty = model.properties.find(e => e.code === property);
|
|
42
|
+
if (!relationProperty) {
|
|
43
|
+
throw new Error(`Property '${property}' was not found in ${options.namespace}.${options.singularCode}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!(isRelationProperty(relationProperty) && relationProperty.relation === "many")) {
|
|
47
|
+
throw new Error(`Operation 'createEntityRelations' is only supported on property of 'many' relation`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (relationProperty.linkTableName) {
|
|
51
|
+
for (const relation of relations) {
|
|
52
|
+
const command = `DELETE FROM ${queryBuilder.quoteTable({schema:relationProperty.linkSchema, tableName: relationProperty.linkTableName})}
|
|
53
|
+
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName!)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName!)}=$2;`;
|
|
54
|
+
const params = [id, relation.id];
|
|
55
|
+
await server.queryDatabaseObject(command, params);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ctx.output = {};
|
|
60
|
+
|
|
61
|
+
server.emitEvent(
|
|
62
|
+
"entity.removeRelations",
|
|
63
|
+
plugin,
|
|
64
|
+
{
|
|
65
|
+
namespace: options.namespace,
|
|
66
|
+
modelSingularCode: options.singularCode,
|
|
67
|
+
entity: row,
|
|
68
|
+
property,
|
|
69
|
+
relations: relations,
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IPluginInstance, RunEntityHttpHandlerOptions } from "~/types";
|
|
2
|
+
import { getEntityPartChanges } from "~/helpers/entityHelpers";
|
|
3
|
+
import { mergeInput } from "~/helpers/inputHelper";
|
|
4
|
+
import { updateEntityById } from "~/dataAccess/entityManager";
|
|
5
|
+
import { mapDbRowToEntity } from "~/dataAccess/entityMapper";
|
|
6
|
+
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
7
|
+
|
|
8
|
+
export const code = "updateCollectionEntityById";
|
|
9
|
+
|
|
10
|
+
export async function handler(
|
|
11
|
+
plugin: IPluginInstance,
|
|
12
|
+
ctx: HttpHandlerContext,
|
|
13
|
+
options: RunEntityHttpHandlerOptions,
|
|
14
|
+
) {
|
|
15
|
+
const { server, input } = ctx;
|
|
16
|
+
const { defaultInput, fixedInput } = options;
|
|
17
|
+
|
|
18
|
+
console.debug(`Running ${code} handler...`);
|
|
19
|
+
|
|
20
|
+
console.debug(`defaultInput: ${JSON.stringify(defaultInput)}`);
|
|
21
|
+
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
22
|
+
console.debug(`fixedInput: ${JSON.stringify(fixedInput)}`);
|
|
23
|
+
console.debug(`mergedInput: ${JSON.stringify(mergedInput)}`);
|
|
24
|
+
|
|
25
|
+
const dataAccessor = server.getDataAccessor(options);
|
|
26
|
+
const id = mergedInput.id;
|
|
27
|
+
const row = await dataAccessor.findById(id);
|
|
28
|
+
if (!row) {
|
|
29
|
+
throw new Error(`${options.namespace}.${options.singularCode} with id "${id}" was not found.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const entity = mapDbRowToEntity(dataAccessor.getModel(), row);
|
|
33
|
+
const changes = getEntityPartChanges(entity, mergedInput);
|
|
34
|
+
if (!changes) {
|
|
35
|
+
ctx.output = entity;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const output = await updateEntityById(server, dataAccessor, { id, entity, changes });
|
|
40
|
+
ctx.output = output;
|
|
41
|
+
|
|
42
|
+
server.emitEvent(
|
|
43
|
+
"entity.update",
|
|
44
|
+
plugin,
|
|
45
|
+
{
|
|
46
|
+
namespace: options.namespace,
|
|
47
|
+
modelSingularCode: options.singularCode,
|
|
48
|
+
before: entity,
|
|
49
|
+
after: output,
|
|
50
|
+
changes: changes,
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
IPluginInstance,
|
|
10
|
+
RpdApplicationConfig,
|
|
11
|
+
RpdHttpMethod,
|
|
12
|
+
RunEntityHttpHandlerOptions,
|
|
13
|
+
} from "~/types";
|
|
14
|
+
|
|
15
|
+
import * as findCollectionEntitiesHttpHandler from "./httpHandlers/findCollectionEntities";
|
|
16
|
+
import * as findCollectionEntityById from "./httpHandlers/findCollectionEntityById";
|
|
17
|
+
import * as countCollectionEntities from "./httpHandlers/countCollectionEntities";
|
|
18
|
+
import * as createCollectionEntity from "./httpHandlers/createCollectionEntity";
|
|
19
|
+
import * as createCollectionEntitiesBatch from "./httpHandlers/createCollectionEntitiesBatch";
|
|
20
|
+
import * as updateCollectionEntityById from "./httpHandlers/updateCollectionEntityById";
|
|
21
|
+
import * as deleteCollectionEntityById from "./httpHandlers/deleteCollectionEntityById";
|
|
22
|
+
import * as addEntityRelations from "./httpHandlers/addEntityRelations";
|
|
23
|
+
import * as removeEntityRelations from "./httpHandlers/removeEntityRelations";
|
|
24
|
+
import * as queryDatabase from "./httpHandlers/queryDatabase";
|
|
25
|
+
import { RpdServerPluginExtendingAbilities, RpdServerPluginConfigurableTargetOptions, RpdConfigurationItemOptions, IRpdServer } from "~/core/server";
|
|
26
|
+
|
|
27
|
+
export const code = "dataManager";
|
|
28
|
+
export const description = "对数据进行管理,提供增删改查等接口。";
|
|
29
|
+
export const extendingAbilities: RpdServerPluginExtendingAbilities[] = [];
|
|
30
|
+
export const configurableTargets: RpdServerPluginConfigurableTargetOptions[] = [];
|
|
31
|
+
export const configurations: RpdConfigurationItemOptions[] = [];
|
|
32
|
+
|
|
33
|
+
const routeConfigs: {
|
|
34
|
+
code: string;
|
|
35
|
+
method: RpdHttpMethod;
|
|
36
|
+
endpoint: string;
|
|
37
|
+
handlerCode: string;
|
|
38
|
+
}[] = [
|
|
39
|
+
{
|
|
40
|
+
code: "createBatch",
|
|
41
|
+
method: "post",
|
|
42
|
+
endpoint: "/operations/create_batch",
|
|
43
|
+
handlerCode: "createCollectionEntitiesBatch",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
code: "find",
|
|
47
|
+
method: "post",
|
|
48
|
+
endpoint: "/operations/find",
|
|
49
|
+
handlerCode: "findCollectionEntities",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
code: "count",
|
|
53
|
+
method: "post",
|
|
54
|
+
endpoint: "/operations/count",
|
|
55
|
+
handlerCode: "countCollectionEntities",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
code: "addRelations",
|
|
59
|
+
method: "post",
|
|
60
|
+
endpoint: "/operations/add_relations",
|
|
61
|
+
handlerCode: "addEntityRelations",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
code: "removeRelations",
|
|
65
|
+
method: "post",
|
|
66
|
+
endpoint: "/operations/remove_relations",
|
|
67
|
+
handlerCode: "removeEntityRelations",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
code: "getById",
|
|
71
|
+
method: "get",
|
|
72
|
+
endpoint: "/:id",
|
|
73
|
+
handlerCode: "findCollectionEntityById",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
code: "create",
|
|
77
|
+
method: "post",
|
|
78
|
+
endpoint: "",
|
|
79
|
+
handlerCode: "createCollectionEntity",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
code: "updateById",
|
|
83
|
+
method: "post",
|
|
84
|
+
endpoint: "/:id",
|
|
85
|
+
handlerCode: "updateCollectionEntityById",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
code: "deleteById",
|
|
89
|
+
method: "delete",
|
|
90
|
+
endpoint: "/:id",
|
|
91
|
+
handlerCode: "deleteCollectionEntityById",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
let _plugin: IPluginInstance;
|
|
96
|
+
|
|
97
|
+
export async function initPlugin(plugin: IPluginInstance, server: IRpdServer) {
|
|
98
|
+
_plugin = plugin;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function registerHttpHandlers(server: IRpdServer) {
|
|
102
|
+
server.registerHttpHandler(_plugin, findCollectionEntitiesHttpHandler);
|
|
103
|
+
server.registerHttpHandler(_plugin, findCollectionEntityById);
|
|
104
|
+
server.registerHttpHandler(_plugin, countCollectionEntities);
|
|
105
|
+
server.registerHttpHandler(_plugin, createCollectionEntity);
|
|
106
|
+
server.registerHttpHandler(_plugin, createCollectionEntitiesBatch);
|
|
107
|
+
server.registerHttpHandler(_plugin, updateCollectionEntityById);
|
|
108
|
+
server.registerHttpHandler(_plugin, addEntityRelations);
|
|
109
|
+
server.registerHttpHandler(_plugin, removeEntityRelations);
|
|
110
|
+
server.registerHttpHandler(_plugin, deleteCollectionEntityById);
|
|
111
|
+
server.registerHttpHandler(_plugin, queryDatabase);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export async function configureRoutes(
|
|
115
|
+
server: IRpdServer,
|
|
116
|
+
applicationConfig: RpdApplicationConfig,
|
|
117
|
+
) {
|
|
118
|
+
const { routes, models } = applicationConfig;
|
|
119
|
+
|
|
120
|
+
models.forEach((model) => {
|
|
121
|
+
const { namespace, singularCode, pluralCode } = model;
|
|
122
|
+
|
|
123
|
+
routeConfigs.forEach((routeConfig) => {
|
|
124
|
+
routes.push({
|
|
125
|
+
namespace,
|
|
126
|
+
name: `${namespace}.${singularCode}.${routeConfig.code}`,
|
|
127
|
+
code: `${namespace}.${singularCode}.${routeConfig.code}`,
|
|
128
|
+
type: "RESTful",
|
|
129
|
+
method: routeConfig.method,
|
|
130
|
+
endpoint: `/api/${namespace}/${pluralCode}${routeConfig.endpoint}`,
|
|
131
|
+
handlers: [
|
|
132
|
+
{
|
|
133
|
+
code: routeConfig.handlerCode,
|
|
134
|
+
config: {
|
|
135
|
+
namespace,
|
|
136
|
+
singularCode,
|
|
137
|
+
} as RunEntityHttpHandlerOptions,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export async function onApplicationLoaded(
|
|
146
|
+
server: IRpdServer,
|
|
147
|
+
application: RpdApplicationConfig,
|
|
148
|
+
) {
|
|
149
|
+
console.log("[dataManager.onApplicationLoaded]");
|
|
150
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
2
|
+
import { IPluginInstance } from "~/types";
|
|
3
|
+
|
|
4
|
+
export const code = "getMetaModelDetail";
|
|
5
|
+
|
|
6
|
+
export async function handler(
|
|
7
|
+
plugin: IPluginInstance,
|
|
8
|
+
ctx: HttpHandlerContext,
|
|
9
|
+
options: any,
|
|
10
|
+
) {
|
|
11
|
+
const { server, input } = ctx;
|
|
12
|
+
const model = server.getModel(input);
|
|
13
|
+
ctx.output = model;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpHandlerContext } from "~/core/httpHandler";
|
|
2
|
+
import { IPluginInstance } from "~/types";
|
|
3
|
+
|
|
4
|
+
export const code = "listMetaModels";
|
|
5
|
+
|
|
6
|
+
export async function handler(
|
|
7
|
+
plugin: IPluginInstance,
|
|
8
|
+
ctx: HttpHandlerContext,
|
|
9
|
+
options: any,
|
|
10
|
+
) {
|
|
11
|
+
const { applicationConfig } = ctx;
|
|
12
|
+
ctx.output = { list: applicationConfig.models };
|
|
13
|
+
}
|