2022-02-27 04:07:39 +02:00
|
|
|
import define from '../define.js';
|
|
|
|
import endpoints from '../endpoints.js';
|
2019-04-25 08:40:42 +03:00
|
|
|
|
|
|
|
export const meta = {
|
2022-01-18 15:27:10 +02:00
|
|
|
requireCredential: false,
|
2019-04-25 08:40:42 +03:00
|
|
|
|
|
|
|
tags: ['meta'],
|
2022-02-19 07:05:32 +02:00
|
|
|
} as const;
|
2019-04-25 08:40:42 +03:00
|
|
|
|
2022-02-20 06:15:40 +02:00
|
|
|
export const paramDef = {
|
2022-02-19 07:05:32 +02:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
endpoint: { type: 'string' },
|
2019-04-25 08:40:42 +03:00
|
|
|
},
|
2022-02-19 07:05:32 +02:00
|
|
|
required: ['endpoint'],
|
2022-01-18 15:27:10 +02:00
|
|
|
} as const;
|
2019-04-25 08:40:42 +03:00
|
|
|
|
2022-01-02 19:12:50 +02:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 07:05:32 +02:00
|
|
|
export default define(meta, paramDef, async (ps) => {
|
2019-04-25 08:40:42 +03:00
|
|
|
const ep = endpoints.find(x => x.name === ps.endpoint);
|
|
|
|
if (ep == null) return null;
|
|
|
|
return {
|
2022-03-19 11:25:06 +02:00
|
|
|
params: Object.entries(ep.params.properties || {}).map(([k, v]) => ({
|
2019-04-25 08:40:42 +03:00
|
|
|
name: k,
|
2022-03-19 11:25:06 +02:00
|
|
|
type: v.type.charAt(0).toUpperCase() + v.type.slice(1),
|
2021-12-09 16:58:30 +02:00
|
|
|
})),
|
2019-04-25 08:40:42 +03:00
|
|
|
};
|
|
|
|
});
|