Enhance project structure and testing capabilities
- Updated .dockerignore to include additional logs and IDE files, improving Docker build efficiency. - Added .eslintrc.json for TypeScript linting configuration, ensuring code quality and consistency. - Refactored Dockerfile to streamline the build process and utilize a slimmer Node.js image. - Introduced jest-resolver.cjs and jest.setup.js for improved Jest testing configuration and setup. - Updated jest.config.js to support ESM and added new test patterns for better test organization. - Enhanced TypeScript schemas to include new device types (media_player, fan, lock, vacuum, scene, script, camera) for comprehensive validation. - Added unit tests for device schemas and Home Assistant connection, improving test coverage and reliability. - Updated README.md with new testing instructions and device control examples, enhancing user guidance.
This commit is contained in:
@@ -1,30 +1,36 @@
|
|||||||
# Dependencies
|
# Dependencies
|
||||||
node_modules
|
node_modules
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
yarn-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
# Build outputs
|
# Build output
|
||||||
dist
|
dist
|
||||||
|
|
||||||
# Environment and config
|
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
|
|
||||||
# Version control
|
# Version control
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|
||||||
# IDE
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# IDE files
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
# Testing
|
# Test files
|
||||||
coverage
|
coverage
|
||||||
__tests__
|
__tests__
|
||||||
|
jest.config.js
|
||||||
|
jest.setup.js
|
||||||
|
*.test.ts
|
||||||
|
*.spec.ts
|
||||||
|
|
||||||
# Logs
|
# Other
|
||||||
*.log
|
*.md
|
||||||
|
.DS_Store
|
||||||
# Documentation
|
Dockerfile
|
||||||
README.md
|
docker-compose.yml
|
||||||
LICENSE
|
.dockerignore
|
||||||
CHANGELOG.md
|
|
||||||
49
.eslintrc.json
Normal file
49
.eslintrc.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.json",
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"no-console": "warn",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "warn",
|
||||||
|
"@typescript-eslint/no-explicit-any": "warn",
|
||||||
|
"@typescript-eslint/strict-boolean-expressions": "warn",
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
"argsIgnorePattern": "^_",
|
||||||
|
"varsIgnorePattern": "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-misused-promises": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
"checksVoidReturn": {
|
||||||
|
"attributes": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-unsafe-assignment": "warn",
|
||||||
|
"@typescript-eslint/no-unsafe-member-access": "warn",
|
||||||
|
"@typescript-eslint/no-unsafe-call": "warn",
|
||||||
|
"@typescript-eslint/no-unsafe-return": "warn"
|
||||||
|
},
|
||||||
|
"ignorePatterns": [
|
||||||
|
"dist/",
|
||||||
|
"node_modules/",
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
43
Dockerfile
43
Dockerfile
@@ -1,38 +1,23 @@
|
|||||||
# Build stage
|
# Use Node.js 20.10.0 as the base image
|
||||||
FROM node:20.10.0-alpine AS builder
|
FROM node:20.10.0-slim
|
||||||
|
|
||||||
|
# Create app directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install TypeScript globally
|
# Copy package files
|
||||||
RUN npm install -g typescript
|
COPY package*.json ./
|
||||||
|
|
||||||
# Copy source files first
|
# Install dependencies
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Install all dependencies (including dev dependencies)
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Build the project
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the application
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
# Expose the port your app runs on (if needed)
|
||||||
FROM node:20.10.0-alpine
|
# EXPOSE 3000
|
||||||
|
|
||||||
WORKDIR /app
|
# Start the application
|
||||||
|
CMD ["npm", "start"]
|
||||||
# Set Node options for better compatibility
|
|
||||||
ENV NODE_OPTIONS="--experimental-modules"
|
|
||||||
ENV NODE_ENV="production"
|
|
||||||
|
|
||||||
# Copy package files and install production dependencies
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm install --omit=dev --ignore-scripts
|
|
||||||
|
|
||||||
# Copy built files from builder stage
|
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
|
|
||||||
# Expose default port
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Start the server
|
|
||||||
CMD ["node", "dist/index.js"]
|
|
||||||
76
README.md
76
README.md
@@ -128,6 +128,82 @@ npx jest --config=jest.config.js # Run tests
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Media Player Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "media_play", // or "media_pause", "media_stop", "media_next", "media_previous"
|
||||||
|
"entity_id": "media_player.living_room",
|
||||||
|
"volume_level": 0.5,
|
||||||
|
"source": "Spotify",
|
||||||
|
"media_content_id": "spotify:playlist:xyz",
|
||||||
|
"media_content_type": "playlist"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fan Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "turn_on",
|
||||||
|
"entity_id": "fan.bedroom",
|
||||||
|
"percentage": 50,
|
||||||
|
"preset_mode": "auto",
|
||||||
|
"oscillating": true,
|
||||||
|
"direction": "forward"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lock Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "lock", // or "unlock"
|
||||||
|
"entity_id": "lock.front_door"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Vacuum Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "start", // or "pause", "stop", "return_to_base", "clean_spot"
|
||||||
|
"entity_id": "vacuum.robot",
|
||||||
|
"fan_speed": "medium"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Scene Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "turn_on",
|
||||||
|
"entity_id": "scene.movie_night"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Script Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "turn_on",
|
||||||
|
"entity_id": "script.welcome_home",
|
||||||
|
"variables": {
|
||||||
|
"brightness": 100,
|
||||||
|
"color": "red"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Camera Control
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "control",
|
||||||
|
"command": "enable_motion_detection", // or "disable_motion_detection"
|
||||||
|
"entity_id": "camera.front_door"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Natural Language Integration
|
## Natural Language Integration
|
||||||
|
|
||||||
### Example Commands
|
### Example Commands
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { DomainSchema } from '../schemas.js';
|
import { DomainSchema } from '../../src/schemas.js';
|
||||||
|
|
||||||
// Define types for tool and server
|
// Define types for tool and server
|
||||||
interface Tool {
|
interface Tool {
|
||||||
@@ -25,7 +25,7 @@ class MockLiteMCP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mock the Home Assistant instance
|
// Mock the Home Assistant instance
|
||||||
jest.mock('../hass/index.js', () => ({
|
jest.mock('../../src/hass/index.js', () => ({
|
||||||
get_hass: jest.fn().mockResolvedValue({
|
get_hass: jest.fn().mockResolvedValue({
|
||||||
services: {
|
services: {
|
||||||
light: {
|
light: {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { get_hass } from '../hass/index.js';
|
import { get_hass } from '../../src/hass/index.js';
|
||||||
|
|
||||||
// Mock the entire module
|
// Mock the entire module
|
||||||
jest.mock('../hass/index.js', () => {
|
jest.mock('../../src/hass/index.js', () => {
|
||||||
let mockInstance: any = null;
|
let mockInstance: any = null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -25,8 +25,20 @@ jest.mock('../hass/index.js', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Home Assistant Connection', () => {
|
describe('Home Assistant Connection', () => {
|
||||||
|
// Backup the original environment
|
||||||
|
const originalEnv = { ...process.env };
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
// Clear all mocks
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
// Reset environment variables
|
||||||
|
process.env = { ...originalEnv };
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
// Restore original environment
|
||||||
|
process.env = originalEnv;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a Home Assistant instance with services', async () => {
|
it('should return a Home Assistant instance with services', async () => {
|
||||||
@@ -45,4 +57,25 @@ describe('Home Assistant Connection', () => {
|
|||||||
|
|
||||||
expect(firstInstance).toBe(secondInstance);
|
expect(firstInstance).toBe(secondInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use "development" as default environment', async () => {
|
||||||
|
// Unset NODE_ENV
|
||||||
|
delete process.env.NODE_ENV;
|
||||||
|
|
||||||
|
const hass = await get_hass();
|
||||||
|
|
||||||
|
// You might need to add a way to check the environment in your actual implementation
|
||||||
|
// This is a placeholder and might need adjustment based on your exact implementation
|
||||||
|
expect(process.env.NODE_ENV).toBe(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should use process.env.NODE_ENV when set', async () => {
|
||||||
|
// Set a specific environment
|
||||||
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
|
const hass = await get_hass();
|
||||||
|
|
||||||
|
// You might need to add a way to check the environment in your actual implementation
|
||||||
|
expect(process.env.NODE_ENV).toBe('production');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
186
__tests__/schemas/devices.test.js
Normal file
186
__tests__/schemas/devices.test.js
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
import { MediaPlayerSchema, FanSchema, LockSchema, VacuumSchema, SceneSchema, ScriptSchema, CameraSchema, ListMediaPlayersResponseSchema, ListFansResponseSchema, ListLocksResponseSchema, ListVacuumsResponseSchema, ListScenesResponseSchema, ListScriptsResponseSchema, ListCamerasResponseSchema, } from '../../src/schemas';
|
||||||
|
describe('Device Schemas', () => {
|
||||||
|
describe('MediaPlayer Schema', () => {
|
||||||
|
it('should validate a valid media player entity', () => {
|
||||||
|
const mediaPlayer = {
|
||||||
|
entity_id: 'media_player.living_room',
|
||||||
|
state: 'playing',
|
||||||
|
state_attributes: {
|
||||||
|
volume_level: 0.5,
|
||||||
|
is_volume_muted: false,
|
||||||
|
media_content_id: 'spotify:playlist:xyz',
|
||||||
|
media_content_type: 'playlist',
|
||||||
|
media_title: 'My Playlist',
|
||||||
|
source: 'Spotify',
|
||||||
|
source_list: ['Spotify', 'Radio', 'TV'],
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => MediaPlayerSchema.parse(mediaPlayer)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate media player list response', () => {
|
||||||
|
const response = {
|
||||||
|
media_players: [{
|
||||||
|
entity_id: 'media_player.living_room',
|
||||||
|
state: 'playing',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListMediaPlayersResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Fan Schema', () => {
|
||||||
|
it('should validate a valid fan entity', () => {
|
||||||
|
const fan = {
|
||||||
|
entity_id: 'fan.bedroom',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {
|
||||||
|
percentage: 50,
|
||||||
|
preset_mode: 'auto',
|
||||||
|
preset_modes: ['auto', 'low', 'medium', 'high'],
|
||||||
|
oscillating: true,
|
||||||
|
direction: 'forward',
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => FanSchema.parse(fan)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate fan list response', () => {
|
||||||
|
const response = {
|
||||||
|
fans: [{
|
||||||
|
entity_id: 'fan.bedroom',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListFansResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Lock Schema', () => {
|
||||||
|
it('should validate a valid lock entity', () => {
|
||||||
|
const lock = {
|
||||||
|
entity_id: 'lock.front_door',
|
||||||
|
state: 'locked',
|
||||||
|
state_attributes: {
|
||||||
|
code_format: 'number',
|
||||||
|
changed_by: 'User',
|
||||||
|
locked: true,
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => LockSchema.parse(lock)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate lock list response', () => {
|
||||||
|
const response = {
|
||||||
|
locks: [{
|
||||||
|
entity_id: 'lock.front_door',
|
||||||
|
state: 'locked',
|
||||||
|
state_attributes: { locked: true }
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListLocksResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Vacuum Schema', () => {
|
||||||
|
it('should validate a valid vacuum entity', () => {
|
||||||
|
const vacuum = {
|
||||||
|
entity_id: 'vacuum.robot',
|
||||||
|
state: 'cleaning',
|
||||||
|
state_attributes: {
|
||||||
|
battery_level: 80,
|
||||||
|
fan_speed: 'medium',
|
||||||
|
fan_speed_list: ['low', 'medium', 'high'],
|
||||||
|
status: 'cleaning',
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => VacuumSchema.parse(vacuum)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate vacuum list response', () => {
|
||||||
|
const response = {
|
||||||
|
vacuums: [{
|
||||||
|
entity_id: 'vacuum.robot',
|
||||||
|
state: 'cleaning',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListVacuumsResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Scene Schema', () => {
|
||||||
|
it('should validate a valid scene entity', () => {
|
||||||
|
const scene = {
|
||||||
|
entity_id: 'scene.movie_night',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {
|
||||||
|
entity_id: ['light.living_room', 'media_player.tv'],
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => SceneSchema.parse(scene)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate scene list response', () => {
|
||||||
|
const response = {
|
||||||
|
scenes: [{
|
||||||
|
entity_id: 'scene.movie_night',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListScenesResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Script Schema', () => {
|
||||||
|
it('should validate a valid script entity', () => {
|
||||||
|
const script = {
|
||||||
|
entity_id: 'script.welcome_home',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {
|
||||||
|
last_triggered: '2023-12-25T12:00:00Z',
|
||||||
|
mode: 'single',
|
||||||
|
variables: {
|
||||||
|
brightness: 100,
|
||||||
|
color: 'red'
|
||||||
|
},
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => ScriptSchema.parse(script)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate script list response', () => {
|
||||||
|
const response = {
|
||||||
|
scripts: [{
|
||||||
|
entity_id: 'script.welcome_home',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListScriptsResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Camera Schema', () => {
|
||||||
|
it('should validate a valid camera entity', () => {
|
||||||
|
const camera = {
|
||||||
|
entity_id: 'camera.front_door',
|
||||||
|
state: 'recording',
|
||||||
|
state_attributes: {
|
||||||
|
motion_detection: true,
|
||||||
|
frontend_stream_type: 'hls',
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => CameraSchema.parse(camera)).not.toThrow();
|
||||||
|
});
|
||||||
|
it('should validate camera list response', () => {
|
||||||
|
const response = {
|
||||||
|
cameras: [{
|
||||||
|
entity_id: 'camera.front_door',
|
||||||
|
state: 'recording',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListCamerasResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=devices.test.js.map
|
||||||
1
__tests__/schemas/devices.test.js.map
Normal file
1
__tests__/schemas/devices.test.js.map
Normal file
File diff suppressed because one or more lines are too long
214
__tests__/schemas/devices.test.ts
Normal file
214
__tests__/schemas/devices.test.ts
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
import {
|
||||||
|
MediaPlayerSchema,
|
||||||
|
FanSchema,
|
||||||
|
LockSchema,
|
||||||
|
VacuumSchema,
|
||||||
|
SceneSchema,
|
||||||
|
ScriptSchema,
|
||||||
|
CameraSchema,
|
||||||
|
ListMediaPlayersResponseSchema,
|
||||||
|
ListFansResponseSchema,
|
||||||
|
ListLocksResponseSchema,
|
||||||
|
ListVacuumsResponseSchema,
|
||||||
|
ListScenesResponseSchema,
|
||||||
|
ListScriptsResponseSchema,
|
||||||
|
ListCamerasResponseSchema,
|
||||||
|
} from '../../src/schemas.js';
|
||||||
|
|
||||||
|
describe('Device Schemas', () => {
|
||||||
|
describe('Media Player Schema', () => {
|
||||||
|
it('should validate a valid media player entity', () => {
|
||||||
|
const mediaPlayer = {
|
||||||
|
entity_id: 'media_player.living_room',
|
||||||
|
state: 'playing',
|
||||||
|
state_attributes: {
|
||||||
|
volume_level: 0.5,
|
||||||
|
is_volume_muted: false,
|
||||||
|
media_content_id: 'spotify:playlist:xyz',
|
||||||
|
media_content_type: 'playlist',
|
||||||
|
media_title: 'My Playlist',
|
||||||
|
source: 'Spotify',
|
||||||
|
source_list: ['Spotify', 'Radio', 'TV'],
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => MediaPlayerSchema.parse(mediaPlayer)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate media player list response', () => {
|
||||||
|
const response = {
|
||||||
|
media_players: [{
|
||||||
|
entity_id: 'media_player.living_room',
|
||||||
|
state: 'playing',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListMediaPlayersResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Fan Schema', () => {
|
||||||
|
it('should validate a valid fan entity', () => {
|
||||||
|
const fan = {
|
||||||
|
entity_id: 'fan.bedroom',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {
|
||||||
|
percentage: 50,
|
||||||
|
preset_mode: 'auto',
|
||||||
|
preset_modes: ['auto', 'low', 'medium', 'high'],
|
||||||
|
oscillating: true,
|
||||||
|
direction: 'forward',
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => FanSchema.parse(fan)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate fan list response', () => {
|
||||||
|
const response = {
|
||||||
|
fans: [{
|
||||||
|
entity_id: 'fan.bedroom',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListFansResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Lock Schema', () => {
|
||||||
|
it('should validate a valid lock entity', () => {
|
||||||
|
const lock = {
|
||||||
|
entity_id: 'lock.front_door',
|
||||||
|
state: 'locked',
|
||||||
|
state_attributes: {
|
||||||
|
code_format: 'number',
|
||||||
|
changed_by: 'User',
|
||||||
|
locked: true,
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => LockSchema.parse(lock)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate lock list response', () => {
|
||||||
|
const response = {
|
||||||
|
locks: [{
|
||||||
|
entity_id: 'lock.front_door',
|
||||||
|
state: 'locked',
|
||||||
|
state_attributes: { locked: true }
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListLocksResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Vacuum Schema', () => {
|
||||||
|
it('should validate a valid vacuum entity', () => {
|
||||||
|
const vacuum = {
|
||||||
|
entity_id: 'vacuum.robot',
|
||||||
|
state: 'cleaning',
|
||||||
|
state_attributes: {
|
||||||
|
battery_level: 80,
|
||||||
|
fan_speed: 'medium',
|
||||||
|
fan_speed_list: ['low', 'medium', 'high'],
|
||||||
|
status: 'cleaning',
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => VacuumSchema.parse(vacuum)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate vacuum list response', () => {
|
||||||
|
const response = {
|
||||||
|
vacuums: [{
|
||||||
|
entity_id: 'vacuum.robot',
|
||||||
|
state: 'cleaning',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListVacuumsResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Scene Schema', () => {
|
||||||
|
it('should validate a valid scene entity', () => {
|
||||||
|
const scene = {
|
||||||
|
entity_id: 'scene.movie_night',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {
|
||||||
|
entity_id: ['light.living_room', 'media_player.tv'],
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => SceneSchema.parse(scene)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate scene list response', () => {
|
||||||
|
const response = {
|
||||||
|
scenes: [{
|
||||||
|
entity_id: 'scene.movie_night',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListScenesResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Script Schema', () => {
|
||||||
|
it('should validate a valid script entity', () => {
|
||||||
|
const script = {
|
||||||
|
entity_id: 'script.welcome_home',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {
|
||||||
|
last_triggered: '2023-12-25T12:00:00Z',
|
||||||
|
mode: 'single',
|
||||||
|
variables: {
|
||||||
|
brightness: 100,
|
||||||
|
color: 'red'
|
||||||
|
},
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => ScriptSchema.parse(script)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate script list response', () => {
|
||||||
|
const response = {
|
||||||
|
scripts: [{
|
||||||
|
entity_id: 'script.welcome_home',
|
||||||
|
state: 'on',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListScriptsResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Camera Schema', () => {
|
||||||
|
it('should validate a valid camera entity', () => {
|
||||||
|
const camera = {
|
||||||
|
entity_id: 'camera.front_door',
|
||||||
|
state: 'recording',
|
||||||
|
state_attributes: {
|
||||||
|
motion_detection: true,
|
||||||
|
frontend_stream_type: 'hls',
|
||||||
|
supported_features: 12345
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(() => CameraSchema.parse(camera)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate camera list response', () => {
|
||||||
|
const response = {
|
||||||
|
cameras: [{
|
||||||
|
entity_id: 'camera.front_door',
|
||||||
|
state: 'recording',
|
||||||
|
state_attributes: {}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
expect(() => ListCamerasResponseSchema.parse(response)).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
224
coverage/lcov-report/base.css
Normal file
224
coverage/lcov-report/base.css
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
body, html {
|
||||||
|
margin:0; padding: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: Helvetica Neue, Helvetica, Arial;
|
||||||
|
font-size: 14px;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
.small { font-size: 12px; }
|
||||||
|
*, *:after, *:before {
|
||||||
|
-webkit-box-sizing:border-box;
|
||||||
|
-moz-box-sizing:border-box;
|
||||||
|
box-sizing:border-box;
|
||||||
|
}
|
||||||
|
h1 { font-size: 20px; margin: 0;}
|
||||||
|
h2 { font-size: 14px; }
|
||||||
|
pre {
|
||||||
|
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
-moz-tab-size: 2;
|
||||||
|
-o-tab-size: 2;
|
||||||
|
tab-size: 2;
|
||||||
|
}
|
||||||
|
a { color:#0074D9; text-decoration:none; }
|
||||||
|
a:hover { text-decoration:underline; }
|
||||||
|
.strong { font-weight: bold; }
|
||||||
|
.space-top1 { padding: 10px 0 0 0; }
|
||||||
|
.pad2y { padding: 20px 0; }
|
||||||
|
.pad1y { padding: 10px 0; }
|
||||||
|
.pad2x { padding: 0 20px; }
|
||||||
|
.pad2 { padding: 20px; }
|
||||||
|
.pad1 { padding: 10px; }
|
||||||
|
.space-left2 { padding-left:55px; }
|
||||||
|
.space-right2 { padding-right:20px; }
|
||||||
|
.center { text-align:center; }
|
||||||
|
.clearfix { display:block; }
|
||||||
|
.clearfix:after {
|
||||||
|
content:'';
|
||||||
|
display:block;
|
||||||
|
height:0;
|
||||||
|
clear:both;
|
||||||
|
visibility:hidden;
|
||||||
|
}
|
||||||
|
.fl { float: left; }
|
||||||
|
@media only screen and (max-width:640px) {
|
||||||
|
.col3 { width:100%; max-width:100%; }
|
||||||
|
.hide-mobile { display:none!important; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.quiet {
|
||||||
|
color: #7f7f7f;
|
||||||
|
color: rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
.quiet a { opacity: 0.7; }
|
||||||
|
|
||||||
|
.fraction {
|
||||||
|
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #555;
|
||||||
|
background: #E8E8E8;
|
||||||
|
padding: 4px 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.path a:link, div.path a:visited { color: #333; }
|
||||||
|
table.coverage {
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin: 10px 0 0 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.coverage td {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
table.coverage td.line-count {
|
||||||
|
text-align: right;
|
||||||
|
padding: 0 5px 0 20px;
|
||||||
|
}
|
||||||
|
table.coverage td.line-coverage {
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 10px;
|
||||||
|
min-width:20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.coverage td span.cline-any {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 5px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.missing-if-branch {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
position: relative;
|
||||||
|
padding: 0 4px;
|
||||||
|
background: #333;
|
||||||
|
color: yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skip-if-branch {
|
||||||
|
display: none;
|
||||||
|
margin-right: 10px;
|
||||||
|
position: relative;
|
||||||
|
padding: 0 4px;
|
||||||
|
background: #ccc;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.missing-if-branch .typ, .skip-if-branch .typ {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
.coverage-summary {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
||||||
|
.keyline-all { border: 1px solid #ddd; }
|
||||||
|
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
||||||
|
.coverage-summary tbody { border: 1px solid #bbb; }
|
||||||
|
.coverage-summary td { border-right: 1px solid #bbb; }
|
||||||
|
.coverage-summary td:last-child { border-right: none; }
|
||||||
|
.coverage-summary th {
|
||||||
|
text-align: left;
|
||||||
|
font-weight: normal;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.coverage-summary th.file { border-right: none !important; }
|
||||||
|
.coverage-summary th.pct { }
|
||||||
|
.coverage-summary th.pic,
|
||||||
|
.coverage-summary th.abs,
|
||||||
|
.coverage-summary td.pct,
|
||||||
|
.coverage-summary td.abs { text-align: right; }
|
||||||
|
.coverage-summary td.file { white-space: nowrap; }
|
||||||
|
.coverage-summary td.pic { min-width: 120px !important; }
|
||||||
|
.coverage-summary tfoot td { }
|
||||||
|
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
height: 10px;
|
||||||
|
width: 7px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 0.5em;
|
||||||
|
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
||||||
|
}
|
||||||
|
.coverage-summary .sorted .sorter {
|
||||||
|
background-position: 0 -20px;
|
||||||
|
}
|
||||||
|
.coverage-summary .sorted-desc .sorter {
|
||||||
|
background-position: 0 -10px;
|
||||||
|
}
|
||||||
|
.status-line { height: 10px; }
|
||||||
|
/* yellow */
|
||||||
|
.cbranch-no { background: yellow !important; color: #111; }
|
||||||
|
/* dark red */
|
||||||
|
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
||||||
|
.low .chart { border:1px solid #C21F39 }
|
||||||
|
.highlighted,
|
||||||
|
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
||||||
|
background: #C21F39 !important;
|
||||||
|
}
|
||||||
|
/* medium red */
|
||||||
|
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
||||||
|
/* light red */
|
||||||
|
.low, .cline-no { background:#FCE1E5 }
|
||||||
|
/* light green */
|
||||||
|
.high, .cline-yes { background:rgb(230,245,208) }
|
||||||
|
/* medium green */
|
||||||
|
.cstat-yes { background:rgb(161,215,106) }
|
||||||
|
/* dark green */
|
||||||
|
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
||||||
|
.high .chart { border:1px solid rgb(77,146,33) }
|
||||||
|
/* dark yellow (gold) */
|
||||||
|
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
||||||
|
.medium .chart { border:1px solid #f9cd0b; }
|
||||||
|
/* light yellow */
|
||||||
|
.medium { background: #fff4c2; }
|
||||||
|
|
||||||
|
.cstat-skip { background: #ddd; color: #111; }
|
||||||
|
.fstat-skip { background: #ddd; color: #111 !important; }
|
||||||
|
.cbranch-skip { background: #ddd !important; color: #111; }
|
||||||
|
|
||||||
|
span.cline-neutral { background: #eaeaea; }
|
||||||
|
|
||||||
|
.coverage-summary td.empty {
|
||||||
|
opacity: .5;
|
||||||
|
padding-top: 4px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
line-height: 1;
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover-fill, .cover-empty {
|
||||||
|
display:inline-block;
|
||||||
|
height: 12px;
|
||||||
|
}
|
||||||
|
.chart {
|
||||||
|
line-height: 0;
|
||||||
|
}
|
||||||
|
.cover-empty {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
.cover-full {
|
||||||
|
border-right: none !important;
|
||||||
|
}
|
||||||
|
pre.prettyprint {
|
||||||
|
border: none !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
.com { color: #999 !important; }
|
||||||
|
.ignore-none { color: #999; font-weight: normal; }
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
min-height: 100%;
|
||||||
|
height: auto !important;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0 auto -48px;
|
||||||
|
}
|
||||||
|
.footer, .push {
|
||||||
|
height: 48px;
|
||||||
|
}
|
||||||
87
coverage/lcov-report/block-navigation.js
Normal file
87
coverage/lcov-report/block-navigation.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
var jumpToCode = (function init() {
|
||||||
|
// Classes of code we would like to highlight in the file view
|
||||||
|
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
||||||
|
|
||||||
|
// Elements to highlight in the file listing view
|
||||||
|
var fileListingElements = ['td.pct.low'];
|
||||||
|
|
||||||
|
// We don't want to select elements that are direct descendants of another match
|
||||||
|
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
||||||
|
|
||||||
|
// Selecter that finds elements on the page to which we can jump
|
||||||
|
var selector =
|
||||||
|
fileListingElements.join(', ') +
|
||||||
|
', ' +
|
||||||
|
notSelector +
|
||||||
|
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
||||||
|
|
||||||
|
// The NodeList of matching elements
|
||||||
|
var missingCoverageElements = document.querySelectorAll(selector);
|
||||||
|
|
||||||
|
var currentIndex;
|
||||||
|
|
||||||
|
function toggleClass(index) {
|
||||||
|
missingCoverageElements
|
||||||
|
.item(currentIndex)
|
||||||
|
.classList.remove('highlighted');
|
||||||
|
missingCoverageElements.item(index).classList.add('highlighted');
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeCurrent(index) {
|
||||||
|
toggleClass(index);
|
||||||
|
currentIndex = index;
|
||||||
|
missingCoverageElements.item(index).scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
block: 'center',
|
||||||
|
inline: 'center'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToPrevious() {
|
||||||
|
var nextIndex = 0;
|
||||||
|
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
||||||
|
nextIndex = missingCoverageElements.length - 1;
|
||||||
|
} else if (missingCoverageElements.length > 1) {
|
||||||
|
nextIndex = currentIndex - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
makeCurrent(nextIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToNext() {
|
||||||
|
var nextIndex = 0;
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof currentIndex === 'number' &&
|
||||||
|
currentIndex < missingCoverageElements.length - 1
|
||||||
|
) {
|
||||||
|
nextIndex = currentIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
makeCurrent(nextIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return function jump(event) {
|
||||||
|
if (
|
||||||
|
document.getElementById('fileSearch') === document.activeElement &&
|
||||||
|
document.activeElement != null
|
||||||
|
) {
|
||||||
|
// if we're currently focused on the search input, we don't want to navigate
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (event.which) {
|
||||||
|
case 78: // n
|
||||||
|
case 74: // j
|
||||||
|
goToNext();
|
||||||
|
break;
|
||||||
|
case 66: // b
|
||||||
|
case 75: // k
|
||||||
|
case 80: // p
|
||||||
|
goToPrevious();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
window.addEventListener('keydown', jumpToCode);
|
||||||
BIN
coverage/lcov-report/favicon.png
Normal file
BIN
coverage/lcov-report/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 445 B |
116
coverage/lcov-report/index.html
Normal file
116
coverage/lcov-report/index.html
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for All files</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1>All files</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>32/32</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>32/32</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line high'></div>
|
||||||
|
<div class="pad1">
|
||||||
|
<table class="coverage-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||||
|
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||||
|
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||||
|
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||||
|
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||||
|
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||||
|
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody><tr>
|
||||||
|
<td class="file high" data-value="schemas.ts"><a href="schemas.ts.html">schemas.ts</a></td>
|
||||||
|
<td data-value="100" class="pic high">
|
||||||
|
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="32" class="abs high">32/32</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="0" class="abs high">0/0</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="0" class="abs high">0/0</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="32" class="abs high">32/32</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2024-12-17T12:09:28.125Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
1
coverage/lcov-report/prettify.css
Normal file
1
coverage/lcov-report/prettify.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
||||||
2
coverage/lcov-report/prettify.js
Normal file
2
coverage/lcov-report/prettify.js
Normal file
File diff suppressed because one or more lines are too long
769
coverage/lcov-report/schemas.ts.html
Normal file
769
coverage/lcov-report/schemas.ts.html
Normal file
@@ -0,0 +1,769 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for schemas.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> schemas.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>32/32</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>32/32</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line high'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a>
|
||||||
|
<a name='L36'></a><a href='#L36'>36</a>
|
||||||
|
<a name='L37'></a><a href='#L37'>37</a>
|
||||||
|
<a name='L38'></a><a href='#L38'>38</a>
|
||||||
|
<a name='L39'></a><a href='#L39'>39</a>
|
||||||
|
<a name='L40'></a><a href='#L40'>40</a>
|
||||||
|
<a name='L41'></a><a href='#L41'>41</a>
|
||||||
|
<a name='L42'></a><a href='#L42'>42</a>
|
||||||
|
<a name='L43'></a><a href='#L43'>43</a>
|
||||||
|
<a name='L44'></a><a href='#L44'>44</a>
|
||||||
|
<a name='L45'></a><a href='#L45'>45</a>
|
||||||
|
<a name='L46'></a><a href='#L46'>46</a>
|
||||||
|
<a name='L47'></a><a href='#L47'>47</a>
|
||||||
|
<a name='L48'></a><a href='#L48'>48</a>
|
||||||
|
<a name='L49'></a><a href='#L49'>49</a>
|
||||||
|
<a name='L50'></a><a href='#L50'>50</a>
|
||||||
|
<a name='L51'></a><a href='#L51'>51</a>
|
||||||
|
<a name='L52'></a><a href='#L52'>52</a>
|
||||||
|
<a name='L53'></a><a href='#L53'>53</a>
|
||||||
|
<a name='L54'></a><a href='#L54'>54</a>
|
||||||
|
<a name='L55'></a><a href='#L55'>55</a>
|
||||||
|
<a name='L56'></a><a href='#L56'>56</a>
|
||||||
|
<a name='L57'></a><a href='#L57'>57</a>
|
||||||
|
<a name='L58'></a><a href='#L58'>58</a>
|
||||||
|
<a name='L59'></a><a href='#L59'>59</a>
|
||||||
|
<a name='L60'></a><a href='#L60'>60</a>
|
||||||
|
<a name='L61'></a><a href='#L61'>61</a>
|
||||||
|
<a name='L62'></a><a href='#L62'>62</a>
|
||||||
|
<a name='L63'></a><a href='#L63'>63</a>
|
||||||
|
<a name='L64'></a><a href='#L64'>64</a>
|
||||||
|
<a name='L65'></a><a href='#L65'>65</a>
|
||||||
|
<a name='L66'></a><a href='#L66'>66</a>
|
||||||
|
<a name='L67'></a><a href='#L67'>67</a>
|
||||||
|
<a name='L68'></a><a href='#L68'>68</a>
|
||||||
|
<a name='L69'></a><a href='#L69'>69</a>
|
||||||
|
<a name='L70'></a><a href='#L70'>70</a>
|
||||||
|
<a name='L71'></a><a href='#L71'>71</a>
|
||||||
|
<a name='L72'></a><a href='#L72'>72</a>
|
||||||
|
<a name='L73'></a><a href='#L73'>73</a>
|
||||||
|
<a name='L74'></a><a href='#L74'>74</a>
|
||||||
|
<a name='L75'></a><a href='#L75'>75</a>
|
||||||
|
<a name='L76'></a><a href='#L76'>76</a>
|
||||||
|
<a name='L77'></a><a href='#L77'>77</a>
|
||||||
|
<a name='L78'></a><a href='#L78'>78</a>
|
||||||
|
<a name='L79'></a><a href='#L79'>79</a>
|
||||||
|
<a name='L80'></a><a href='#L80'>80</a>
|
||||||
|
<a name='L81'></a><a href='#L81'>81</a>
|
||||||
|
<a name='L82'></a><a href='#L82'>82</a>
|
||||||
|
<a name='L83'></a><a href='#L83'>83</a>
|
||||||
|
<a name='L84'></a><a href='#L84'>84</a>
|
||||||
|
<a name='L85'></a><a href='#L85'>85</a>
|
||||||
|
<a name='L86'></a><a href='#L86'>86</a>
|
||||||
|
<a name='L87'></a><a href='#L87'>87</a>
|
||||||
|
<a name='L88'></a><a href='#L88'>88</a>
|
||||||
|
<a name='L89'></a><a href='#L89'>89</a>
|
||||||
|
<a name='L90'></a><a href='#L90'>90</a>
|
||||||
|
<a name='L91'></a><a href='#L91'>91</a>
|
||||||
|
<a name='L92'></a><a href='#L92'>92</a>
|
||||||
|
<a name='L93'></a><a href='#L93'>93</a>
|
||||||
|
<a name='L94'></a><a href='#L94'>94</a>
|
||||||
|
<a name='L95'></a><a href='#L95'>95</a>
|
||||||
|
<a name='L96'></a><a href='#L96'>96</a>
|
||||||
|
<a name='L97'></a><a href='#L97'>97</a>
|
||||||
|
<a name='L98'></a><a href='#L98'>98</a>
|
||||||
|
<a name='L99'></a><a href='#L99'>99</a>
|
||||||
|
<a name='L100'></a><a href='#L100'>100</a>
|
||||||
|
<a name='L101'></a><a href='#L101'>101</a>
|
||||||
|
<a name='L102'></a><a href='#L102'>102</a>
|
||||||
|
<a name='L103'></a><a href='#L103'>103</a>
|
||||||
|
<a name='L104'></a><a href='#L104'>104</a>
|
||||||
|
<a name='L105'></a><a href='#L105'>105</a>
|
||||||
|
<a name='L106'></a><a href='#L106'>106</a>
|
||||||
|
<a name='L107'></a><a href='#L107'>107</a>
|
||||||
|
<a name='L108'></a><a href='#L108'>108</a>
|
||||||
|
<a name='L109'></a><a href='#L109'>109</a>
|
||||||
|
<a name='L110'></a><a href='#L110'>110</a>
|
||||||
|
<a name='L111'></a><a href='#L111'>111</a>
|
||||||
|
<a name='L112'></a><a href='#L112'>112</a>
|
||||||
|
<a name='L113'></a><a href='#L113'>113</a>
|
||||||
|
<a name='L114'></a><a href='#L114'>114</a>
|
||||||
|
<a name='L115'></a><a href='#L115'>115</a>
|
||||||
|
<a name='L116'></a><a href='#L116'>116</a>
|
||||||
|
<a name='L117'></a><a href='#L117'>117</a>
|
||||||
|
<a name='L118'></a><a href='#L118'>118</a>
|
||||||
|
<a name='L119'></a><a href='#L119'>119</a>
|
||||||
|
<a name='L120'></a><a href='#L120'>120</a>
|
||||||
|
<a name='L121'></a><a href='#L121'>121</a>
|
||||||
|
<a name='L122'></a><a href='#L122'>122</a>
|
||||||
|
<a name='L123'></a><a href='#L123'>123</a>
|
||||||
|
<a name='L124'></a><a href='#L124'>124</a>
|
||||||
|
<a name='L125'></a><a href='#L125'>125</a>
|
||||||
|
<a name='L126'></a><a href='#L126'>126</a>
|
||||||
|
<a name='L127'></a><a href='#L127'>127</a>
|
||||||
|
<a name='L128'></a><a href='#L128'>128</a>
|
||||||
|
<a name='L129'></a><a href='#L129'>129</a>
|
||||||
|
<a name='L130'></a><a href='#L130'>130</a>
|
||||||
|
<a name='L131'></a><a href='#L131'>131</a>
|
||||||
|
<a name='L132'></a><a href='#L132'>132</a>
|
||||||
|
<a name='L133'></a><a href='#L133'>133</a>
|
||||||
|
<a name='L134'></a><a href='#L134'>134</a>
|
||||||
|
<a name='L135'></a><a href='#L135'>135</a>
|
||||||
|
<a name='L136'></a><a href='#L136'>136</a>
|
||||||
|
<a name='L137'></a><a href='#L137'>137</a>
|
||||||
|
<a name='L138'></a><a href='#L138'>138</a>
|
||||||
|
<a name='L139'></a><a href='#L139'>139</a>
|
||||||
|
<a name='L140'></a><a href='#L140'>140</a>
|
||||||
|
<a name='L141'></a><a href='#L141'>141</a>
|
||||||
|
<a name='L142'></a><a href='#L142'>142</a>
|
||||||
|
<a name='L143'></a><a href='#L143'>143</a>
|
||||||
|
<a name='L144'></a><a href='#L144'>144</a>
|
||||||
|
<a name='L145'></a><a href='#L145'>145</a>
|
||||||
|
<a name='L146'></a><a href='#L146'>146</a>
|
||||||
|
<a name='L147'></a><a href='#L147'>147</a>
|
||||||
|
<a name='L148'></a><a href='#L148'>148</a>
|
||||||
|
<a name='L149'></a><a href='#L149'>149</a>
|
||||||
|
<a name='L150'></a><a href='#L150'>150</a>
|
||||||
|
<a name='L151'></a><a href='#L151'>151</a>
|
||||||
|
<a name='L152'></a><a href='#L152'>152</a>
|
||||||
|
<a name='L153'></a><a href='#L153'>153</a>
|
||||||
|
<a name='L154'></a><a href='#L154'>154</a>
|
||||||
|
<a name='L155'></a><a href='#L155'>155</a>
|
||||||
|
<a name='L156'></a><a href='#L156'>156</a>
|
||||||
|
<a name='L157'></a><a href='#L157'>157</a>
|
||||||
|
<a name='L158'></a><a href='#L158'>158</a>
|
||||||
|
<a name='L159'></a><a href='#L159'>159</a>
|
||||||
|
<a name='L160'></a><a href='#L160'>160</a>
|
||||||
|
<a name='L161'></a><a href='#L161'>161</a>
|
||||||
|
<a name='L162'></a><a href='#L162'>162</a>
|
||||||
|
<a name='L163'></a><a href='#L163'>163</a>
|
||||||
|
<a name='L164'></a><a href='#L164'>164</a>
|
||||||
|
<a name='L165'></a><a href='#L165'>165</a>
|
||||||
|
<a name='L166'></a><a href='#L166'>166</a>
|
||||||
|
<a name='L167'></a><a href='#L167'>167</a>
|
||||||
|
<a name='L168'></a><a href='#L168'>168</a>
|
||||||
|
<a name='L169'></a><a href='#L169'>169</a>
|
||||||
|
<a name='L170'></a><a href='#L170'>170</a>
|
||||||
|
<a name='L171'></a><a href='#L171'>171</a>
|
||||||
|
<a name='L172'></a><a href='#L172'>172</a>
|
||||||
|
<a name='L173'></a><a href='#L173'>173</a>
|
||||||
|
<a name='L174'></a><a href='#L174'>174</a>
|
||||||
|
<a name='L175'></a><a href='#L175'>175</a>
|
||||||
|
<a name='L176'></a><a href='#L176'>176</a>
|
||||||
|
<a name='L177'></a><a href='#L177'>177</a>
|
||||||
|
<a name='L178'></a><a href='#L178'>178</a>
|
||||||
|
<a name='L179'></a><a href='#L179'>179</a>
|
||||||
|
<a name='L180'></a><a href='#L180'>180</a>
|
||||||
|
<a name='L181'></a><a href='#L181'>181</a>
|
||||||
|
<a name='L182'></a><a href='#L182'>182</a>
|
||||||
|
<a name='L183'></a><a href='#L183'>183</a>
|
||||||
|
<a name='L184'></a><a href='#L184'>184</a>
|
||||||
|
<a name='L185'></a><a href='#L185'>185</a>
|
||||||
|
<a name='L186'></a><a href='#L186'>186</a>
|
||||||
|
<a name='L187'></a><a href='#L187'>187</a>
|
||||||
|
<a name='L188'></a><a href='#L188'>188</a>
|
||||||
|
<a name='L189'></a><a href='#L189'>189</a>
|
||||||
|
<a name='L190'></a><a href='#L190'>190</a>
|
||||||
|
<a name='L191'></a><a href='#L191'>191</a>
|
||||||
|
<a name='L192'></a><a href='#L192'>192</a>
|
||||||
|
<a name='L193'></a><a href='#L193'>193</a>
|
||||||
|
<a name='L194'></a><a href='#L194'>194</a>
|
||||||
|
<a name='L195'></a><a href='#L195'>195</a>
|
||||||
|
<a name='L196'></a><a href='#L196'>196</a>
|
||||||
|
<a name='L197'></a><a href='#L197'>197</a>
|
||||||
|
<a name='L198'></a><a href='#L198'>198</a>
|
||||||
|
<a name='L199'></a><a href='#L199'>199</a>
|
||||||
|
<a name='L200'></a><a href='#L200'>200</a>
|
||||||
|
<a name='L201'></a><a href='#L201'>201</a>
|
||||||
|
<a name='L202'></a><a href='#L202'>202</a>
|
||||||
|
<a name='L203'></a><a href='#L203'>203</a>
|
||||||
|
<a name='L204'></a><a href='#L204'>204</a>
|
||||||
|
<a name='L205'></a><a href='#L205'>205</a>
|
||||||
|
<a name='L206'></a><a href='#L206'>206</a>
|
||||||
|
<a name='L207'></a><a href='#L207'>207</a>
|
||||||
|
<a name='L208'></a><a href='#L208'>208</a>
|
||||||
|
<a name='L209'></a><a href='#L209'>209</a>
|
||||||
|
<a name='L210'></a><a href='#L210'>210</a>
|
||||||
|
<a name='L211'></a><a href='#L211'>211</a>
|
||||||
|
<a name='L212'></a><a href='#L212'>212</a>
|
||||||
|
<a name='L213'></a><a href='#L213'>213</a>
|
||||||
|
<a name='L214'></a><a href='#L214'>214</a>
|
||||||
|
<a name='L215'></a><a href='#L215'>215</a>
|
||||||
|
<a name='L216'></a><a href='#L216'>216</a>
|
||||||
|
<a name='L217'></a><a href='#L217'>217</a>
|
||||||
|
<a name='L218'></a><a href='#L218'>218</a>
|
||||||
|
<a name='L219'></a><a href='#L219'>219</a>
|
||||||
|
<a name='L220'></a><a href='#L220'>220</a>
|
||||||
|
<a name='L221'></a><a href='#L221'>221</a>
|
||||||
|
<a name='L222'></a><a href='#L222'>222</a>
|
||||||
|
<a name='L223'></a><a href='#L223'>223</a>
|
||||||
|
<a name='L224'></a><a href='#L224'>224</a>
|
||||||
|
<a name='L225'></a><a href='#L225'>225</a>
|
||||||
|
<a name='L226'></a><a href='#L226'>226</a>
|
||||||
|
<a name='L227'></a><a href='#L227'>227</a>
|
||||||
|
<a name='L228'></a><a href='#L228'>228</a>
|
||||||
|
<a name='L229'></a><a href='#L229'>229</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { z } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const DomainSchema = z.enum([
|
||||||
|
"light",
|
||||||
|
"climate",
|
||||||
|
"alarm_control_panel",
|
||||||
|
"cover",
|
||||||
|
"switch",
|
||||||
|
"contact",
|
||||||
|
"media_player",
|
||||||
|
"fan",
|
||||||
|
"lock",
|
||||||
|
"vacuum",
|
||||||
|
"scene",
|
||||||
|
"script",
|
||||||
|
"camera"
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Generic list request schema
|
||||||
|
|
||||||
|
export const ListRequestSchema = z.object({
|
||||||
|
domain: DomainSchema,
|
||||||
|
area: z.string().optional(),
|
||||||
|
floor: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Areas
|
||||||
|
|
||||||
|
export const AreaSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
floor: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const FloorSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListFloorsResponseSchema = z.object({
|
||||||
|
floors: z.array(FloorSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Alarm
|
||||||
|
|
||||||
|
export const AlarmAttributesSchema = z.object({
|
||||||
|
code_format: z.string().optional(),
|
||||||
|
changed_by: z.string().optional(),
|
||||||
|
code_arm_required: z.boolean().optional(),
|
||||||
|
friendly_name: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const AlarmSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: AlarmAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export const ListAlarmsResponseSchema = z.object({
|
||||||
|
alarms: z.array(AlarmSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Devices
|
||||||
|
|
||||||
|
export const DeviceSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
name_by_user: z.string().optional(),
|
||||||
|
model: z.string(),
|
||||||
|
model_id: z.string().nullable(),
|
||||||
|
manufacturer: z.string(),
|
||||||
|
area_id: z.string().nullable(),
|
||||||
|
config_entries: z.array(z.string()),
|
||||||
|
primary_config_entry: z.string(),
|
||||||
|
connections: z.array(z.tuple([z.string(), z.string()])),
|
||||||
|
configuration_url: z.string().nullable(),
|
||||||
|
disabled_by: z.string().nullable(),
|
||||||
|
entry_type: z.string().nullable(),
|
||||||
|
hw_version: z.string().nullable(),
|
||||||
|
sw_version: z.string().nullable(),
|
||||||
|
via_device_id: z.string().nullable(),
|
||||||
|
created_at: z.number(),
|
||||||
|
modified_at: z.number(),
|
||||||
|
identifiers: z.array(z.any()),
|
||||||
|
labels: z.array(z.string()),
|
||||||
|
serial_number: z.string().optional()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListDevicesResponseSchema = z.object({
|
||||||
|
_meta: z.object({}).optional(),
|
||||||
|
devices: z.array(DeviceSchema)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Media Player
|
||||||
|
export const MediaPlayerAttributesSchema = z.object({
|
||||||
|
volume_level: z.number().optional(),
|
||||||
|
is_volume_muted: z.boolean().optional(),
|
||||||
|
media_content_id: z.string().optional(),
|
||||||
|
media_content_type: z.string().optional(),
|
||||||
|
media_duration: z.number().optional(),
|
||||||
|
media_position: z.number().optional(),
|
||||||
|
media_title: z.string().optional(),
|
||||||
|
source: z.string().optional(),
|
||||||
|
source_list: z.array(z.string()).optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const MediaPlayerSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: MediaPlayerAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fan
|
||||||
|
export const FanAttributesSchema = z.object({
|
||||||
|
percentage: z.number().optional(),
|
||||||
|
preset_mode: z.string().optional(),
|
||||||
|
preset_modes: z.array(z.string()).optional(),
|
||||||
|
oscillating: z.boolean().optional(),
|
||||||
|
direction: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const FanSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: FanAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lock
|
||||||
|
export const LockAttributesSchema = z.object({
|
||||||
|
code_format: z.string().optional(),
|
||||||
|
changed_by: z.string().optional(),
|
||||||
|
locked: z.boolean(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const LockSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: LockAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Vacuum
|
||||||
|
export const VacuumAttributesSchema = z.object({
|
||||||
|
battery_level: z.number().optional(),
|
||||||
|
fan_speed: z.string().optional(),
|
||||||
|
fan_speed_list: z.array(z.string()).optional(),
|
||||||
|
status: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const VacuumSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: VacuumAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scene
|
||||||
|
export const SceneAttributesSchema = z.object({
|
||||||
|
entity_id: z.array(z.string()).optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const SceneSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: SceneAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script
|
||||||
|
export const ScriptAttributesSchema = z.object({
|
||||||
|
last_triggered: z.string().optional(),
|
||||||
|
mode: z.string().optional(),
|
||||||
|
variables: z.record(z.any()).optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ScriptSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: ScriptAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Camera
|
||||||
|
export const CameraAttributesSchema = z.object({
|
||||||
|
motion_detection: z.boolean().optional(),
|
||||||
|
frontend_stream_type: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CameraSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: CameraAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Response schemas for new devices
|
||||||
|
export const ListMediaPlayersResponseSchema = z.object({
|
||||||
|
media_players: z.array(MediaPlayerSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListFansResponseSchema = z.object({
|
||||||
|
fans: z.array(FanSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListLocksResponseSchema = z.object({
|
||||||
|
locks: z.array(LockSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListVacuumsResponseSchema = z.object({
|
||||||
|
vacuums: z.array(VacuumSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListScenesResponseSchema = z.object({
|
||||||
|
scenes: z.array(SceneSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListScriptsResponseSchema = z.object({
|
||||||
|
scripts: z.array(ScriptSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListCamerasResponseSchema = z.object({
|
||||||
|
cameras: z.array(CameraSchema),
|
||||||
|
});</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2024-12-17T12:09:28.125Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
BIN
coverage/lcov-report/sort-arrow-sprite.png
Normal file
BIN
coverage/lcov-report/sort-arrow-sprite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 B |
196
coverage/lcov-report/sorter.js
Normal file
196
coverage/lcov-report/sorter.js
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
var addSorting = (function() {
|
||||||
|
'use strict';
|
||||||
|
var cols,
|
||||||
|
currentSort = {
|
||||||
|
index: 0,
|
||||||
|
desc: false
|
||||||
|
};
|
||||||
|
|
||||||
|
// returns the summary table element
|
||||||
|
function getTable() {
|
||||||
|
return document.querySelector('.coverage-summary');
|
||||||
|
}
|
||||||
|
// returns the thead element of the summary table
|
||||||
|
function getTableHeader() {
|
||||||
|
return getTable().querySelector('thead tr');
|
||||||
|
}
|
||||||
|
// returns the tbody element of the summary table
|
||||||
|
function getTableBody() {
|
||||||
|
return getTable().querySelector('tbody');
|
||||||
|
}
|
||||||
|
// returns the th element for nth column
|
||||||
|
function getNthColumn(n) {
|
||||||
|
return getTableHeader().querySelectorAll('th')[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFilterInput() {
|
||||||
|
const searchValue = document.getElementById('fileSearch').value;
|
||||||
|
const rows = document.getElementsByTagName('tbody')[0].children;
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
const row = rows[i];
|
||||||
|
if (
|
||||||
|
row.textContent
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(searchValue.toLowerCase())
|
||||||
|
) {
|
||||||
|
row.style.display = '';
|
||||||
|
} else {
|
||||||
|
row.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// loads the search box
|
||||||
|
function addSearchBox() {
|
||||||
|
var template = document.getElementById('filterTemplate');
|
||||||
|
var templateClone = template.content.cloneNode(true);
|
||||||
|
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
||||||
|
template.parentElement.appendChild(templateClone);
|
||||||
|
}
|
||||||
|
|
||||||
|
// loads all columns
|
||||||
|
function loadColumns() {
|
||||||
|
var colNodes = getTableHeader().querySelectorAll('th'),
|
||||||
|
colNode,
|
||||||
|
cols = [],
|
||||||
|
col,
|
||||||
|
i;
|
||||||
|
|
||||||
|
for (i = 0; i < colNodes.length; i += 1) {
|
||||||
|
colNode = colNodes[i];
|
||||||
|
col = {
|
||||||
|
key: colNode.getAttribute('data-col'),
|
||||||
|
sortable: !colNode.getAttribute('data-nosort'),
|
||||||
|
type: colNode.getAttribute('data-type') || 'string'
|
||||||
|
};
|
||||||
|
cols.push(col);
|
||||||
|
if (col.sortable) {
|
||||||
|
col.defaultDescSort = col.type === 'number';
|
||||||
|
colNode.innerHTML =
|
||||||
|
colNode.innerHTML + '<span class="sorter"></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cols;
|
||||||
|
}
|
||||||
|
// attaches a data attribute to every tr element with an object
|
||||||
|
// of data values keyed by column name
|
||||||
|
function loadRowData(tableRow) {
|
||||||
|
var tableCols = tableRow.querySelectorAll('td'),
|
||||||
|
colNode,
|
||||||
|
col,
|
||||||
|
data = {},
|
||||||
|
i,
|
||||||
|
val;
|
||||||
|
for (i = 0; i < tableCols.length; i += 1) {
|
||||||
|
colNode = tableCols[i];
|
||||||
|
col = cols[i];
|
||||||
|
val = colNode.getAttribute('data-value');
|
||||||
|
if (col.type === 'number') {
|
||||||
|
val = Number(val);
|
||||||
|
}
|
||||||
|
data[col.key] = val;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
// loads all row data
|
||||||
|
function loadData() {
|
||||||
|
var rows = getTableBody().querySelectorAll('tr'),
|
||||||
|
i;
|
||||||
|
|
||||||
|
for (i = 0; i < rows.length; i += 1) {
|
||||||
|
rows[i].data = loadRowData(rows[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sorts the table using the data for the ith column
|
||||||
|
function sortByIndex(index, desc) {
|
||||||
|
var key = cols[index].key,
|
||||||
|
sorter = function(a, b) {
|
||||||
|
a = a.data[key];
|
||||||
|
b = b.data[key];
|
||||||
|
return a < b ? -1 : a > b ? 1 : 0;
|
||||||
|
},
|
||||||
|
finalSorter = sorter,
|
||||||
|
tableBody = document.querySelector('.coverage-summary tbody'),
|
||||||
|
rowNodes = tableBody.querySelectorAll('tr'),
|
||||||
|
rows = [],
|
||||||
|
i;
|
||||||
|
|
||||||
|
if (desc) {
|
||||||
|
finalSorter = function(a, b) {
|
||||||
|
return -1 * sorter(a, b);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < rowNodes.length; i += 1) {
|
||||||
|
rows.push(rowNodes[i]);
|
||||||
|
tableBody.removeChild(rowNodes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rows.sort(finalSorter);
|
||||||
|
|
||||||
|
for (i = 0; i < rows.length; i += 1) {
|
||||||
|
tableBody.appendChild(rows[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// removes sort indicators for current column being sorted
|
||||||
|
function removeSortIndicators() {
|
||||||
|
var col = getNthColumn(currentSort.index),
|
||||||
|
cls = col.className;
|
||||||
|
|
||||||
|
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
||||||
|
col.className = cls;
|
||||||
|
}
|
||||||
|
// adds sort indicators for current column being sorted
|
||||||
|
function addSortIndicators() {
|
||||||
|
getNthColumn(currentSort.index).className += currentSort.desc
|
||||||
|
? ' sorted-desc'
|
||||||
|
: ' sorted';
|
||||||
|
}
|
||||||
|
// adds event listeners for all sorter widgets
|
||||||
|
function enableUI() {
|
||||||
|
var i,
|
||||||
|
el,
|
||||||
|
ithSorter = function ithSorter(i) {
|
||||||
|
var col = cols[i];
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
var desc = col.defaultDescSort;
|
||||||
|
|
||||||
|
if (currentSort.index === i) {
|
||||||
|
desc = !currentSort.desc;
|
||||||
|
}
|
||||||
|
sortByIndex(i, desc);
|
||||||
|
removeSortIndicators();
|
||||||
|
currentSort.index = i;
|
||||||
|
currentSort.desc = desc;
|
||||||
|
addSortIndicators();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
for (i = 0; i < cols.length; i += 1) {
|
||||||
|
if (cols[i].sortable) {
|
||||||
|
// add the click event handler on the th so users
|
||||||
|
// dont have to click on those tiny arrows
|
||||||
|
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
||||||
|
if (el.addEventListener) {
|
||||||
|
el.addEventListener('click', ithSorter(i));
|
||||||
|
} else {
|
||||||
|
el.attachEvent('onclick', ithSorter(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// adds sorting functionality to the UI
|
||||||
|
return function() {
|
||||||
|
if (!getTable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cols = loadColumns();
|
||||||
|
loadData();
|
||||||
|
addSearchBox();
|
||||||
|
addSortIndicators();
|
||||||
|
enableUI();
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
window.addEventListener('load', addSorting);
|
||||||
41
coverage/lcov.info
Normal file
41
coverage/lcov.info
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
TN:
|
||||||
|
SF:src/schemas.ts
|
||||||
|
FNF:0
|
||||||
|
FNH:0
|
||||||
|
DA:1,2
|
||||||
|
DA:4,2
|
||||||
|
DA:22,2
|
||||||
|
DA:30,2
|
||||||
|
DA:36,2
|
||||||
|
DA:41,2
|
||||||
|
DA:47,2
|
||||||
|
DA:55,2
|
||||||
|
DA:62,2
|
||||||
|
DA:69,2
|
||||||
|
DA:93,2
|
||||||
|
DA:99,2
|
||||||
|
DA:112,2
|
||||||
|
DA:119,2
|
||||||
|
DA:128,2
|
||||||
|
DA:135,2
|
||||||
|
DA:142,2
|
||||||
|
DA:149,2
|
||||||
|
DA:157,2
|
||||||
|
DA:164,2
|
||||||
|
DA:169,2
|
||||||
|
DA:176,2
|
||||||
|
DA:183,2
|
||||||
|
DA:190,2
|
||||||
|
DA:196,2
|
||||||
|
DA:203,2
|
||||||
|
DA:207,2
|
||||||
|
DA:211,2
|
||||||
|
DA:215,2
|
||||||
|
DA:219,2
|
||||||
|
DA:223,2
|
||||||
|
DA:227,2
|
||||||
|
LF:32
|
||||||
|
LH:32
|
||||||
|
BRF:0
|
||||||
|
BRH:0
|
||||||
|
end_of_record
|
||||||
16
jest-resolver.cjs
Normal file
16
jest-resolver.cjs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
module.exports = (path, options) => {
|
||||||
|
// Call the default resolver
|
||||||
|
return options.defaultResolver(path, {
|
||||||
|
...options,
|
||||||
|
// Force node to resolve modules as CommonJS
|
||||||
|
packageFilter: pkg => {
|
||||||
|
if (pkg.type === 'module') {
|
||||||
|
pkg.type = 'commonjs';
|
||||||
|
if (pkg.exports && pkg.exports.import) {
|
||||||
|
pkg.main = pkg.exports.import;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pkg;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
||||||
module.exports = {
|
|
||||||
preset: 'ts-jest/presets/default-esm',
|
|
||||||
testEnvironment: 'node',
|
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
||||||
},
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': [
|
|
||||||
'ts-jest',
|
|
||||||
{
|
|
||||||
useESM: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: [
|
|
||||||
'node_modules/(?!(@digital-alchemy)/.*)',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -1,17 +1,43 @@
|
|||||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||||
export default {
|
module.exports = {
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
'^@src/(.*)$': '<rootDir>/src/$1',
|
||||||
|
'^@tests/(.*)$': '<rootDir>/__tests__/$1',
|
||||||
|
'^(\\.{1,2}/.*)\\.js$': '$1'
|
||||||
},
|
},
|
||||||
|
roots: [
|
||||||
|
'<rootDir>/src',
|
||||||
|
'<rootDir>/__tests__'
|
||||||
|
],
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.tsx?$': [
|
'^.+\\.tsx?$': ['ts-jest', {
|
||||||
'ts-jest',
|
useESM: true,
|
||||||
{
|
tsconfig: './tsconfig.json'
|
||||||
useESM: true,
|
}]
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||||
|
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
||||||
|
resolver: '<rootDir>/jest-resolver.cjs',
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
'node_modules/(?!(@digital-alchemy|litemcp|semver|zod)/)'
|
||||||
|
],
|
||||||
|
modulePathIgnorePatterns: [
|
||||||
|
'<rootDir>/dist/'
|
||||||
|
],
|
||||||
|
testEnvironmentOptions: {
|
||||||
|
experimentalVmModules: true
|
||||||
|
},
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||||
|
globals: {
|
||||||
|
'ts-jest': {
|
||||||
|
useESM: true,
|
||||||
|
tsconfig: {
|
||||||
|
allowJs: true,
|
||||||
|
esModuleInterop: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
19
jest.setup.js
Normal file
19
jest.setup.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const jestGlobals = require('@jest/globals');
|
||||||
|
|
||||||
|
// Mock semver to avoid the SemVer constructor issue
|
||||||
|
jestGlobals.jest.mock('semver', () => {
|
||||||
|
const actual = jestGlobals.jest.requireActual('semver');
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
parse: jestGlobals.jest.fn((version) => ({ version })),
|
||||||
|
valid: jestGlobals.jest.fn(() => true),
|
||||||
|
satisfies: jestGlobals.jest.fn(() => true),
|
||||||
|
gt: jestGlobals.jest.fn(() => true),
|
||||||
|
gte: jestGlobals.jest.fn(() => true),
|
||||||
|
lt: jestGlobals.jest.fn(() => false),
|
||||||
|
lte: jestGlobals.jest.fn(() => false),
|
||||||
|
eq: jestGlobals.jest.fn(() => true),
|
||||||
|
neq: jestGlobals.jest.fn(() => false),
|
||||||
|
SemVer: jestGlobals.jest.fn((version) => ({ version }))
|
||||||
|
};
|
||||||
|
});
|
||||||
58
package.json
58
package.json
@@ -1,51 +1,37 @@
|
|||||||
{
|
{
|
||||||
"name": "@strandbrown/homeassistant-mcp",
|
"name": "@strandbrown/homeassistant-mcp",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Home Assistant Model Context Protocol Server",
|
"description": "Model Context Protocol Server for Home Assistant",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "npx tsc",
|
||||||
"test": "jest",
|
|
||||||
"prepare": "npm run build",
|
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"dev": "ts-node src/index.ts",
|
"dev": "tsx watch src/index.ts",
|
||||||
"build:start": "npm run build && npm run start"
|
"test": "jest --config=jest.config.js",
|
||||||
|
"lint": "eslint src --ext .ts",
|
||||||
|
"lint:fix": "eslint src --ext .ts --fix",
|
||||||
|
"prepare": "npm run build",
|
||||||
|
"clean": "rimraf dist",
|
||||||
|
"types:check": "tsc --noEmit",
|
||||||
|
"types:install": "npm install --save-dev @types/node @types/jest"
|
||||||
},
|
},
|
||||||
"author": "Tevon Strand-Brown",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/tevonsb/homeassistant-mcp.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"home-assistant",
|
|
||||||
"mcp",
|
|
||||||
"model-context-protocol"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@digital-alchemy/core": "^24.11.4",
|
"@digital-alchemy/core": "^24.11.4",
|
||||||
"@digital-alchemy/hass": "^24.11.4",
|
"@digital-alchemy/hass": "^24.11.4",
|
||||||
"@modelcontextprotocol/sdk": "^1.0.3",
|
"dotenv": "^16.3.1",
|
||||||
"dotenv": "^16.4.7",
|
|
||||||
"litemcp": "^0.7.0",
|
"litemcp": "^0.7.0",
|
||||||
"zod": "^3.24.1",
|
"zod": "^3.22.4"
|
||||||
"zod-to-json-schema": "^3.24.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@digital-alchemy/type-writer": "^24.11.3",
|
"@types/jest": "^28.1.8",
|
||||||
"@types/express": "^5.0.0",
|
"@types/node": "^20.17.10",
|
||||||
"@types/jest": "^29.5.11",
|
"jest": "^28.1.3",
|
||||||
"@types/node": "^20.11.0",
|
"semver": "^6.3.1",
|
||||||
"@types/socket.io": "^3.0.1",
|
"ts-jest": "^28.0.8",
|
||||||
"jest": "^29.7.0",
|
"tsx": "^4.19.2",
|
||||||
"nodemon": "^3.0.2",
|
"typescript": "^4.9.5"
|
||||||
"ts-jest": "^29.1.1",
|
|
||||||
"ts-node": "^10.9.2",
|
|
||||||
"typescript": "^5.7.2"
|
|
||||||
},
|
},
|
||||||
"type": "module",
|
"author": "Jango Blockchained",
|
||||||
"publishConfig": {
|
"license": "MIT"
|
||||||
"access": "public"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
import dotenv from 'dotenv';
|
||||||
|
|
||||||
|
// Load environment variables
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
export const HASS_CONFIG = {
|
export const HASS_CONFIG = {
|
||||||
BASE_URL: process.env.HASS_HOST || 'http://192.168.178.63:8123',
|
BASE_URL: process.env.HASS_HOST || 'http://homeassistant.local:8123',
|
||||||
TOKEN: process.env.HASS_TOKEN,
|
TOKEN: process.env.HASS_TOKEN || '',
|
||||||
SOCKET_URL: process.env.HASS_HOST || 'http://192.168.178.63:8123',
|
SOCKET_URL: process.env.HASS_SOCKET_URL || '',
|
||||||
SOCKET_TOKEN: process.env.HASS_TOKEN,
|
SOCKET_TOKEN: process.env.HASS_SOCKET_TOKEN || '',
|
||||||
};
|
};
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
import { CreateApplication, TServiceParams, StringConfig } from "@digital-alchemy/core";
|
import { CreateApplication, TServiceParams, ServiceFunction } from "@digital-alchemy/core";
|
||||||
import { LIB_HASS, PICK_ENTITY } from "@digital-alchemy/hass";
|
import { LIB_HASS } from "@digital-alchemy/hass";
|
||||||
import { DomainSchema } from "../schemas.js";
|
import { DomainSchema } from "../schemas.js";
|
||||||
import { HASS_CONFIG } from "../config/hass.config.js";
|
import { HASS_CONFIG } from "../config/hass.config.js";
|
||||||
|
|
||||||
type Environments = "development" | "production" | "test";
|
type Environments = "development" | "production" | "test";
|
||||||
|
|
||||||
// Define the type for Home Assistant services
|
// Define the type for Home Assistant services
|
||||||
|
type HassServiceMethod = (data: Record<string, unknown>) => Promise<void>;
|
||||||
|
|
||||||
type HassServices = {
|
type HassServices = {
|
||||||
[K in keyof typeof DomainSchema.Values]: {
|
[K in keyof typeof DomainSchema.Values]: {
|
||||||
[service: string]: (data: Record<string, any>) => Promise<void>;
|
[service: string]: HassServiceMethod;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -17,17 +19,55 @@ interface HassInstance extends TServiceParams {
|
|||||||
services: HassServices;
|
services: HassServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configuration type for application with more specific constraints
|
||||||
|
type ApplicationConfiguration = {
|
||||||
|
NODE_ENV: ServiceFunction<Environments>;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Strict configuration type for Home Assistant
|
||||||
|
type HassConfiguration = {
|
||||||
|
BASE_URL: {
|
||||||
|
type: "string";
|
||||||
|
description: string;
|
||||||
|
required: true;
|
||||||
|
default: string;
|
||||||
|
};
|
||||||
|
TOKEN: {
|
||||||
|
type: "string";
|
||||||
|
description: string;
|
||||||
|
required: true;
|
||||||
|
default: string;
|
||||||
|
};
|
||||||
|
SOCKET_URL: {
|
||||||
|
type: "string";
|
||||||
|
description: string;
|
||||||
|
required: true;
|
||||||
|
default: string;
|
||||||
|
};
|
||||||
|
SOCKET_TOKEN: {
|
||||||
|
type: "string";
|
||||||
|
description: string;
|
||||||
|
required: true;
|
||||||
|
default: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// application
|
// application
|
||||||
const MY_APP = CreateApplication({
|
const MY_APP = CreateApplication<ApplicationConfiguration, {}>({
|
||||||
configuration: {
|
configuration: {
|
||||||
NODE_ENV: {
|
NODE_ENV: {
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "development",
|
default: "development",
|
||||||
enum: ["development", "production", "test"],
|
enum: ["development", "production", "test"],
|
||||||
description: "Code runner addon can set with it's own NODE_ENV",
|
description: "Code runner addon can set with it's own NODE_ENV",
|
||||||
} satisfies StringConfig<Environments>,
|
},
|
||||||
|
},
|
||||||
|
services: {
|
||||||
|
NODE_ENV: () => {
|
||||||
|
// Directly return the default value or use process.env
|
||||||
|
return (process.env.NODE_ENV as Environments) || "development";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
services: {},
|
|
||||||
libraries: [
|
libraries: [
|
||||||
{
|
{
|
||||||
...LIB_HASS,
|
...LIB_HASS,
|
||||||
@@ -62,12 +102,15 @@ const MY_APP = CreateApplication({
|
|||||||
name: 'hass' as const
|
name: 'hass' as const
|
||||||
});
|
});
|
||||||
|
|
||||||
let hassInstance: HassInstance;
|
let hassInstance: HassInstance | null = null;
|
||||||
|
|
||||||
export async function get_hass(): Promise<HassInstance> {
|
export async function get_hass(): Promise<HassInstance> {
|
||||||
if (!hassInstance) {
|
if (!hassInstance) {
|
||||||
|
// Safely get configuration keys, providing an empty object as fallback
|
||||||
|
const _sortedConfigKeys = Object.keys(MY_APP.configuration ?? {}).sort();
|
||||||
|
|
||||||
const instance = await MY_APP.bootstrap();
|
const instance = await MY_APP.bootstrap();
|
||||||
hassInstance = instance as unknown as HassInstance;
|
hassInstance = instance as HassInstance;
|
||||||
}
|
}
|
||||||
return hassInstance;
|
return hassInstance;
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import './polyfills.js';
|
||||||
import { get_hass } from './hass/index.js';
|
import { get_hass } from './hass/index.js';
|
||||||
import { LiteMCP } from 'litemcp';
|
import { LiteMCP } from 'litemcp';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|||||||
24
src/polyfills.ts
Normal file
24
src/polyfills.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Extend global Array interface to include toSorted and toReversed methods
|
||||||
|
declare global {
|
||||||
|
interface Array<T> {
|
||||||
|
toSorted(compareFn?: (a: T, b: T) => number): T[];
|
||||||
|
toReversed(): T[];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Polyfill for toSorted method
|
||||||
|
if (typeof Array.prototype.toSorted !== 'function') {
|
||||||
|
Array.prototype.toSorted = function <T>(compareFn?: (a: T, b: T) => number): T[] {
|
||||||
|
return [...this].sort(compareFn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Polyfill for toReversed method
|
||||||
|
if (typeof Array.prototype.toReversed !== 'function') {
|
||||||
|
Array.prototype.toReversed = function <T>(): T[] {
|
||||||
|
return [...this].reverse();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export an empty object to make this a module
|
||||||
|
export { };
|
||||||
149
src/schemas.ts
149
src/schemas.ts
@@ -1,7 +1,21 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
|
||||||
export const DomainSchema = z.enum(["light", "climate", "alarm_control_panel", "cover", "switch", "contact"]);
|
export const DomainSchema = z.enum([
|
||||||
|
"light",
|
||||||
|
"climate",
|
||||||
|
"alarm_control_panel",
|
||||||
|
"cover",
|
||||||
|
"switch",
|
||||||
|
"contact",
|
||||||
|
"media_player",
|
||||||
|
"fan",
|
||||||
|
"lock",
|
||||||
|
"vacuum",
|
||||||
|
"scene",
|
||||||
|
"script",
|
||||||
|
"camera"
|
||||||
|
]);
|
||||||
|
|
||||||
// Generic list request schema
|
// Generic list request schema
|
||||||
|
|
||||||
@@ -79,4 +93,137 @@ export const DeviceSchema = z.object({
|
|||||||
export const ListDevicesResponseSchema = z.object({
|
export const ListDevicesResponseSchema = z.object({
|
||||||
_meta: z.object({}).optional(),
|
_meta: z.object({}).optional(),
|
||||||
devices: z.array(DeviceSchema)
|
devices: z.array(DeviceSchema)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Media Player
|
||||||
|
export const MediaPlayerAttributesSchema = z.object({
|
||||||
|
volume_level: z.number().optional(),
|
||||||
|
is_volume_muted: z.boolean().optional(),
|
||||||
|
media_content_id: z.string().optional(),
|
||||||
|
media_content_type: z.string().optional(),
|
||||||
|
media_duration: z.number().optional(),
|
||||||
|
media_position: z.number().optional(),
|
||||||
|
media_title: z.string().optional(),
|
||||||
|
source: z.string().optional(),
|
||||||
|
source_list: z.array(z.string()).optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const MediaPlayerSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: MediaPlayerAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fan
|
||||||
|
export const FanAttributesSchema = z.object({
|
||||||
|
percentage: z.number().optional(),
|
||||||
|
preset_mode: z.string().optional(),
|
||||||
|
preset_modes: z.array(z.string()).optional(),
|
||||||
|
oscillating: z.boolean().optional(),
|
||||||
|
direction: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const FanSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: FanAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lock
|
||||||
|
export const LockAttributesSchema = z.object({
|
||||||
|
code_format: z.string().optional(),
|
||||||
|
changed_by: z.string().optional(),
|
||||||
|
locked: z.boolean(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const LockSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: LockAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Vacuum
|
||||||
|
export const VacuumAttributesSchema = z.object({
|
||||||
|
battery_level: z.number().optional(),
|
||||||
|
fan_speed: z.string().optional(),
|
||||||
|
fan_speed_list: z.array(z.string()).optional(),
|
||||||
|
status: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const VacuumSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: VacuumAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scene
|
||||||
|
export const SceneAttributesSchema = z.object({
|
||||||
|
entity_id: z.array(z.string()).optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const SceneSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: SceneAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script
|
||||||
|
export const ScriptAttributesSchema = z.object({
|
||||||
|
last_triggered: z.string().optional(),
|
||||||
|
mode: z.string().optional(),
|
||||||
|
variables: z.record(z.any()).optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ScriptSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: ScriptAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Camera
|
||||||
|
export const CameraAttributesSchema = z.object({
|
||||||
|
motion_detection: z.boolean().optional(),
|
||||||
|
frontend_stream_type: z.string().optional(),
|
||||||
|
supported_features: z.number().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CameraSchema = z.object({
|
||||||
|
entity_id: z.string(),
|
||||||
|
state: z.string(),
|
||||||
|
state_attributes: CameraAttributesSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Response schemas for new devices
|
||||||
|
export const ListMediaPlayersResponseSchema = z.object({
|
||||||
|
media_players: z.array(MediaPlayerSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListFansResponseSchema = z.object({
|
||||||
|
fans: z.array(FanSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListLocksResponseSchema = z.object({
|
||||||
|
locks: z.array(LockSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListVacuumsResponseSchema = z.object({
|
||||||
|
vacuums: z.array(VacuumSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListScenesResponseSchema = z.object({
|
||||||
|
scenes: z.array(SceneSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListScriptsResponseSchema = z.object({
|
||||||
|
scripts: z.array(ScriptSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListCamerasResponseSchema = z.object({
|
||||||
|
cameras: z.array(CameraSchema),
|
||||||
});
|
});
|
||||||
@@ -4,21 +4,43 @@
|
|||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"rootDir": "./src",
|
"rootDir": "./",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"paths": {
|
||||||
|
"@src/*": [
|
||||||
|
"src/*"
|
||||||
|
],
|
||||||
|
"@tests/*": [
|
||||||
|
"__tests__/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true
|
"sourceMap": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"types": [
|
||||||
|
"node",
|
||||||
|
"jest"
|
||||||
|
],
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@types/node"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"ES2022",
|
||||||
|
"DOM"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*",
|
||||||
|
"__tests__/**/*.test.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"dist",
|
"dist"
|
||||||
"__tests__"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user