Files
certd/packages/ui/certd-server/src/modules/pipeline/service/builtin-plugin-service.ts
T

43 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-07-15 00:30:33 +08:00
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
import { pluginGroups, pluginRegistry } from '@certd/pipeline';
2024-12-03 00:35:34 +08:00
import { cloneDeep } from 'lodash-es';
2024-10-13 01:27:08 +08:00
2023-01-29 13:44:19 +08:00
@Provide()
@Scope(ScopeEnum.Request, { allowDowngrade: true })
2024-10-13 01:27:08 +08:00
export class BuiltInPluginService {
2023-01-29 13:44:19 +08:00
getList() {
const collection = pluginRegistry.storage;
2025-04-03 00:19:54 +08:00
let list = [];
2023-01-29 13:44:19 +08:00
for (const key in collection) {
const Plugin = collection[key];
2024-09-30 12:25:44 +08:00
if (Plugin?.define?.deprecated) {
2024-09-29 14:57:20 +08:00
continue;
}
//@ts-ignore
if(Plugin.define?.type && Plugin.define?.type !== 'builtin'){
continue;
}
2023-01-29 13:44:19 +08:00
list.push({ ...Plugin.define, key });
}
2025-04-03 00:19:54 +08:00
list = list.sort((a, b) => {
return (a.order ?? 10 )- (b.order ?? 10);
});
2023-01-29 13:44:19 +08:00
return list;
}
getGroups() {
2025-04-03 00:19:54 +08:00
const groups:any = cloneDeep(pluginGroups);
for (const key in groups) {
const group = groups[key];
group.plugins = group.plugins.sort((a, b) => {
return (a.order ?? 10 )- (b.order ?? 10);
});
}
return groups;
}
2024-12-03 00:55:37 +08:00
getByType(type: string) {
return pluginRegistry.getDefine(type);
}
2023-01-29 13:44:19 +08:00
}