UNPKG

homebridge-config-ui-x

Version:

A web based management, configuration and control platform for Homebridge.

203 lines • 8.54 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; import { Controller, Get, Inject, Param, Post, Query, UseGuards } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { ApiBearerAuth, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; import { AdminGuard } from '../../core/auth/guards/admin.guard.js'; import { PluginsService } from './plugins.service.js'; let PluginsController = class PluginsController { pluginsService; constructor(pluginsService) { this.pluginsService = pluginsService; } pluginsGet() { return this.pluginsService.getInstalledPlugins(); } clearPluginsCache() { this.pluginsService.clearInstalledPluginsCache(); return { success: true }; } pluginsSearch(query) { return this.pluginsService.searchNpmRegistry(query.trim()); } pluginLookup(pluginName) { return this.pluginsService.lookupPlugin(pluginName); } getAvailablePluginVersions(pluginName) { return this.pluginsService.getAvailablePluginVersions(pluginName); } getPluginConfigSchema(pluginName) { try { return this.pluginsService.getPluginConfigSchema(pluginName); } catch (e) { console.error(e); } } getPluginChangeLog(pluginName) { return this.pluginsService.getPluginChangeLog(pluginName); } getPluginRelease(pluginName) { return this.pluginsService.getPluginRelease(pluginName); } getPluginAlias(pluginName) { return this.pluginsService.getPluginAlias(pluginName); } triggerUpdate(pluginName, version) { return this.pluginsService.triggerUpdate(pluginName, version); } }; __decorate([ ApiOperation({ summary: 'Get the list of currently installed Homebridge plugins.' }), Get(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], PluginsController.prototype, "pluginsGet", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Clear the installed plugins cache.' }), Post('clear-cache'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], PluginsController.prototype, "clearPluginsCache", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Search the NPM registry for Homebridge plugins.' }), ApiParam({ name: 'query', type: 'string' }), Get('search/:query'), __param(0, Param('query')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "pluginsSearch", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Lookup a single plugin from the NPM registry.' }), ApiParam({ name: 'pluginName', type: 'string' }), Get('lookup/:pluginName'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "pluginLookup", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get the available versions and tags for a single plugin from the NPM registry.' }), ApiParam({ name: 'pluginName', type: 'string' }), Get('lookup/:pluginName/versions'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "getAvailablePluginVersions", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get the `config.schema.json` for a plugin.' }), ApiParam({ name: 'pluginName', type: 'string' }), Get('config-schema/:pluginName'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "getPluginConfigSchema", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get the `CHANGELOG.md` (post install) for a plugin.' }), ApiParam({ name: 'pluginName', type: 'string' }), Get('changelog/:pluginName'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "getPluginChangeLog", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get the latest GitHub release notes and latest changelog for a plugin.' }), ApiParam({ name: 'pluginName', type: 'string' }), Get('release/:pluginName'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "getPluginRelease", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Attempt to resolve the type (platform or accessory) and alias for a plugin.', description: 'NOTE: `pluginAlias` and `pluginType` will be `null` if the type or alias could not be resolved.', }), ApiParam({ name: 'pluginName', type: 'string' }), Get('alias/:pluginName'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "getPluginAlias", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Trigger an update for Homebridge, homebridge-config-ui-x, or any plugin.', description: 'This endpoint queues an update to be performed in the background. The update will be executed asynchronously and the appropriate restart will be performed based on what was updated.', }), ApiParam({ name: 'pluginName', type: String, description: 'The name of the package to update (homebridge, homebridge-config-ui-x, or a plugin name)', example: 'homebridge-example-plugin', }), ApiQuery({ name: 'version', type: String, required: false, description: 'Specific version to install. If not provided, the latest version will be installed.', example: '1.2.3', }), ApiResponse({ status: 201, description: 'Update has been queued successfully.', schema: { type: 'object', properties: { ok: { type: 'boolean', example: true }, name: { type: 'string', example: 'homebridge-example-plugin' }, version: { type: 'string', example: '1.2.3' }, }, }, }), ApiResponse({ status: 400, description: 'Invalid package name or validation error.', }), ApiResponse({ status: 404, description: 'Package not installed.', }), Post('update/:pluginName'), __param(0, Param('pluginName')), __param(1, Query('version')), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", void 0) ], PluginsController.prototype, "triggerUpdate", null); PluginsController = __decorate([ ApiTags('Plugins'), ApiBearerAuth(), UseGuards(AuthGuard()), Controller('plugins'), __param(0, Inject(PluginsService)), __metadata("design:paramtypes", [PluginsService]) ], PluginsController); export { PluginsController }; //# sourceMappingURL=plugins.controller.js.map