UNPKG

homebridge-config-ui-x

Version:

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

387 lines • 16.4 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 { Body, Controller, Delete, Get, Inject, Param, ParseIntPipe, Post, Put, UseGuards, } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { ApiBearerAuth, ApiBody, ApiOkResponse, ApiOperation, ApiParam, ApiTags, } from '@nestjs/swagger'; import { AdminGuard } from '../../core/auth/guards/admin.guard.js'; import { SetBridgeAlertDto, SetScheduledRestartCronDto } from './config-editor.dto.js'; import { ConfigEditorService } from './config-editor.service.js'; let ConfigEditorController = class ConfigEditorController { configEditorService; constructor(configEditorService) { this.configEditorService = configEditorService; } getConfig() { return this.configEditorService.getConfigFile(); } updateConfig(body) { return this.configEditorService.updateConfigFile(body); } getConfigForPlugin(pluginName) { return this.configEditorService.getConfigForPlugin(pluginName); } updateConfigForPlugin(pluginName, body) { return this.configEditorService.updateConfigForPlugin(pluginName, body); } disablePlugin(pluginName) { return this.configEditorService.disablePlugin(pluginName); } enablePlugin(pluginName) { return this.configEditorService.enablePlugin(pluginName); } getPropertyForUi(key) { return this.configEditorService.getPropertyForUi(key); } setPropertyForUi({ key, value }) { return this.configEditorService.setPropertyForUi(key, value); } setAccessoryControlInstanceBlacklist({ body }) { return this.configEditorService.setAccessoryControlInstanceBlacklist(body); } getPluginsHideUpdatesFor() { return this.configEditorService.getPluginsHideUpdatesFor(); } setPluginsHideUpdatesFor({ body }) { return this.configEditorService.setPluginsHideUpdatesFor(body); } getBridge(username) { return this.configEditorService.getBridge(username); } setBridgeHideHapAlert(username, body) { return this.configEditorService.setBridgeHideHapAlert(username, body.value); } setBridgeHideMatterAlert(username, body) { return this.configEditorService.setBridgeHideMatterAlert(username, body.value); } setBridgeScheduledRestartCron(username, body) { return this.configEditorService.setBridgeScheduledRestartCron(username, body.value); } listConfigBackups() { return this.configEditorService.listConfigBackups(); } getBackup(backupId) { return this.configEditorService.getConfigBackup(backupId); } deleteBackup(backupId) { return this.configEditorService.deleteConfigBackup(backupId); } deleteAllConfigBackups() { return this.configEditorService.deleteAllConfigBackups(); } getMatterPortRange() { return this.configEditorService.getMatterPortRange(); } setMatterPortRange(body) { return this.configEditorService.setMatterPortRange(body); } getMatterConfig() { return this.configEditorService.getMatterConfig(); } updateMatterConfig(matterConfig) { return this.configEditorService.updateMatterConfig(matterConfig); } deleteMatterConfig() { return this.configEditorService.deleteMatterConfig(); } }; __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Return the current Homebridge `config.json` file.' }), Get(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "getConfig", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Update the Homebridge `config.json` file.' }), ApiBody({ description: 'Homebridge config.json', type: 'json', isArray: false }), Post(), __param(0, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "updateConfig", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Return the config blocks for a specific plugin.', description: 'An array of config blocks will be returned. An empty array will be returned if the plugin is not configured.', }), Get('/plugin/:pluginName'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "getConfigForPlugin", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Replace the config for a specific plugin.', description: 'An array of all config blocks for the plugin must be provided, missing blocks will be removed. Sending an empty array will remove all plugin config.', }), Post('/plugin/:pluginName'), ApiBody({ description: 'Array of plugin config blocks', type: 'json', isArray: true }), __param(0, Param('pluginName')), __param(1, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "updateConfigForPlugin", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Mark a plugin as disabled.', }), ApiParam({ name: 'pluginName', type: 'string' }), Put('plugin/:pluginName/disable'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "disablePlugin", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Mark a plugin as enabled.', }), ApiParam({ name: 'pluginName', type: 'string' }), Put('plugin/:pluginName/enable'), __param(0, Param('pluginName')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "enablePlugin", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get a config property for the Homebridge UI.' }), ApiParam({ name: 'key', type: 'string', description: 'The property key to retrieve (e.g., "nodeUpdatePolicy")' }), Get('/ui/:key'), __param(0, Param('key')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "getPropertyForUi", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Update a config property for the Homebridge UI.' }), Put('/ui'), __param(0, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setPropertyForUi", null); __decorate([ UseGuards(AdminGuard), Put('/ui/accessory-control/instance-blacklist'), ApiOperation({ summary: 'Update the accessory control instance blacklist.' }), ApiBody({ description: 'Array of bridge instances for which control by the UI should be blocked.', type: 'json', isArray: true }), __param(0, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setAccessoryControlInstanceBlacklist", null); __decorate([ UseGuards(AdminGuard), Get('/ui/plugins/hide-updates-for'), ApiOperation({ summary: 'Get the plugins hide updates for list.' }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], ConfigEditorController.prototype, "getPluginsHideUpdatesFor", null); __decorate([ UseGuards(AdminGuard), Put('/ui/plugins/hide-updates-for'), ApiOperation({ summary: 'Update the plugins hide updates for.' }), ApiBody({ description: 'Array of plugin names to hide updates for in the UI.', type: 'json', isArray: true }), __param(0, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setPluginsHideUpdatesFor", null); __decorate([ UseGuards(AdminGuard), Get('/ui/bridges/:username'), ApiOperation({ summary: 'Get a specific bridge configuration by username.' }), ApiParam({ name: 'username', type: String, description: 'The MAC address of the bridge (e.g., "0E:02:9A:9D:44:45")', example: '0E:02:9A:9D:44:45', }), ApiOkResponse({ description: 'Bridge configuration', type: 'object', schema: { example: { username: '0E:02:9A:9D:44:45', hideHapAlert: true, hideMatterAlert: false, }, }, }), __param(0, Param('username')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], ConfigEditorController.prototype, "getBridge", null); __decorate([ UseGuards(AdminGuard), Put('/ui/bridges/:username/hide-hap-alert'), ApiOperation({ summary: 'Set the hideHapAlert flag for a specific bridge.' }), ApiParam({ name: 'username', type: String, description: 'The MAC address of the bridge (e.g., "0E:02:9A:9D:44:45")', example: '0E:02:9A:9D:44:45', }), ApiBody({ type: SetBridgeAlertDto }), __param(0, Param('username')), __param(1, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [String, SetBridgeAlertDto]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setBridgeHideHapAlert", null); __decorate([ UseGuards(AdminGuard), Put('/ui/bridges/:username/hide-matter-alert'), ApiOperation({ summary: 'Set the hideMatterAlert flag for a specific bridge.' }), ApiParam({ name: 'username', type: String, description: 'The MAC address of the bridge (e.g., "0E:02:9A:9D:44:45")', example: '0E:02:9A:9D:44:45', }), ApiBody({ type: SetBridgeAlertDto }), __param(0, Param('username')), __param(1, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [String, SetBridgeAlertDto]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setBridgeHideMatterAlert", null); __decorate([ UseGuards(AdminGuard), Put('/ui/bridges/:username/scheduled-restart-cron'), ApiOperation({ summary: 'Set the scheduledRestartCron for a specific child bridge.' }), ApiParam({ name: 'username', type: String, description: 'The MAC address of the bridge (e.g., `0E:02:9A:9D:44:45`)', example: '0E:02:9A:9D:44:45', }), ApiBody({ type: SetScheduledRestartCronDto }), __param(0, Param('username')), __param(1, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [String, SetScheduledRestartCronDto]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setBridgeScheduledRestartCron", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'List the available Homebridge `config.json` backups.' }), Get('/backups'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "listConfigBackups", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Return the Homebridge `config.json` file for the given backup ID.' }), ApiParam({ name: 'backupId', type: 'number' }), Get('/backups/:backupId'), __param(0, Param('backupId', ParseIntPipe)), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "getBackup", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Delete the backup file for the given backup ID.' }), ApiParam({ name: 'backupId', type: 'number' }), Delete('/backups/:backupId'), __param(0, Param('backupId', ParseIntPipe)), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "deleteBackup", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Delete all the Homebridge `config.json` backups.' }), Delete('/backups'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "deleteAllConfigBackups", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get the Matter port range configuration.' }), Get('/matter/ports'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "getMatterPortRange", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Set the Matter port range configuration.' }), ApiBody({ description: 'Object with start and end properties.', type: 'json', isArray: false }), Put('/matter/ports'), __param(0, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "setMatterPortRange", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Get Matter Configuration', description: 'Returns the Matter configuration object for the main Homebridge bridge.', }), Get('/matter'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "getMatterConfig", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Update Matter Configuration', description: 'Update the Matter configuration object for the main Homebridge bridge.', }), ApiBody({ description: 'Matter configuration', type: 'json' }), Put('/matter'), __param(0, Body()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "updateMatterConfig", null); __decorate([ UseGuards(AdminGuard), ApiOperation({ summary: 'Delete Matter Configuration', description: 'Removes the Matter configuration object for the main Homebridge bridge, and deletes the Matter data for it.', }), Delete('/matter'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], ConfigEditorController.prototype, "deleteMatterConfig", null); ConfigEditorController = __decorate([ ApiTags('Homebridge Config Editor'), ApiBearerAuth(), UseGuards(AuthGuard()), Controller('config-editor'), __param(0, Inject(ConfigEditorService)), __metadata("design:paramtypes", [ConfigEditorService]) ], ConfigEditorController); export { ConfigEditorController }; //# sourceMappingURL=config-editor.controller.js.map