mirror of
https://github.com/immich-app/immich.git
synced 2026-06-05 06:15:24 -04:00
8682be4774
* wip: confirm before existing and disable/enable save button condition * fix: get correct workflow detail * wip: add back workflow summary * wip: add back json editor * wip: step property badge * wip: redesign card flow * wip: redesign card flow * redesign workflow summary * wworkflow summary styling * wip * drag and drop * list redesign * refactor * refactor * remove deadcode * refactor * insert steps * push down when dropped * feat: workflow template * simplify * move template to manifest * feat: hash manifest file * fix: template column * fix: migration * fix: workflow lookup * chore: clean up --------- Co-authored-by: Jason Rasmussen <jason@rasm.me>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
import {
|
|
mapMethod,
|
|
mapPlugin,
|
|
mapTemplate,
|
|
PluginMethodResponseDto,
|
|
PluginMethodSearchDto,
|
|
PluginResponseDto,
|
|
PluginSearchDto,
|
|
PluginTemplateResponseDto,
|
|
} from 'src/dtos/plugin.dto';
|
|
import { BaseService } from 'src/services/base.service';
|
|
import { isMethodCompatible } from 'src/utils/workflow';
|
|
|
|
@Injectable()
|
|
export class PluginService extends BaseService {
|
|
async search(dto: PluginSearchDto): Promise<PluginResponseDto[]> {
|
|
const plugins = await this.pluginRepository.search(dto);
|
|
return plugins.map((plugin) => mapPlugin(plugin));
|
|
}
|
|
|
|
async get(id: string): Promise<PluginResponseDto> {
|
|
const plugin = await this.pluginRepository.get(id);
|
|
if (!plugin) {
|
|
throw new BadRequestException('Plugin not found');
|
|
}
|
|
return mapPlugin(plugin);
|
|
}
|
|
|
|
async searchMethods(dto: PluginMethodSearchDto): Promise<PluginMethodResponseDto[]> {
|
|
const methods = await this.pluginRepository.searchMethods(dto);
|
|
return methods
|
|
.filter((method) => !dto.trigger || isMethodCompatible(method, dto.trigger))
|
|
.map((method) => mapMethod(method));
|
|
}
|
|
|
|
async searchTemplates(): Promise<PluginTemplateResponseDto[]> {
|
|
const plugins = await this.pluginRepository.search();
|
|
return plugins.flatMap((plugin) => plugin.templates.map((template) => mapTemplate(plugin, template)));
|
|
}
|
|
}
|