feat(interfaces): add structured data models and discriminated check configs; migrate tooling and package metadata
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import * as plugins from '../../ul-interfaces.plugins.js';
|
||||
import { TCheckResultStatus, TExecutionTiming } from './index.js';
|
||||
import type * as plugins from '../../ul-interfaces.plugins.js';
|
||||
import type { TCheckResultStatus } from '../types.js';
|
||||
import type { TExecutionTiming } from './index.js';
|
||||
|
||||
/**
|
||||
* Assumption check execution data.
|
||||
* Used by check runners to store input and results.
|
||||
*/
|
||||
export interface IAssumptionCheck {
|
||||
inputData: {
|
||||
domain: string;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { TCheckResultStatus, TExecutionTiming } from './index.js';
|
||||
import type { TCheckResultStatus } from '../types.js';
|
||||
import type { TExecutionTiming } from './index.js';
|
||||
|
||||
/**
|
||||
* Function check execution data.
|
||||
* Used by check runners to store input and results.
|
||||
*/
|
||||
export interface IFunctionCheck {
|
||||
checkId: string;
|
||||
inputData: {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
export type TCheckResultStatus = 'ok' | 'not ok' | 'timed out';
|
||||
import type { TStatusType, TCheckResultStatus, TCheckLastResult } from '../types.js';
|
||||
|
||||
// ============================================
|
||||
// Execution Timing (used by check runners)
|
||||
// ============================================
|
||||
|
||||
export interface TExecutionTiming {
|
||||
plannedTime: number;
|
||||
@@ -7,6 +11,106 @@ export interface TExecutionTiming {
|
||||
duration: number;
|
||||
}
|
||||
|
||||
// Re-export for backward compatibility
|
||||
export type { TCheckResultStatus };
|
||||
|
||||
// ============================================
|
||||
// Check Configuration Base Interface
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Base interface for all check configurations.
|
||||
* Extended by discriminated variants.
|
||||
*/
|
||||
export interface ICheckBase {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
enabled: boolean;
|
||||
intervalMs?: number;
|
||||
lastRun?: number;
|
||||
lastResult?: TCheckLastResult;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Discriminated Check Variants (Configuration)
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Assumption check - assumes a status without active verification
|
||||
*/
|
||||
export interface IAssumptionCheckConfig extends ICheckBase {
|
||||
checkType: 'assumption';
|
||||
assumedStatus: TStatusType;
|
||||
domain?: string;
|
||||
title?: string;
|
||||
statusCode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function check - calls a URL and validates response
|
||||
*/
|
||||
export interface IFunctionCheckConfig extends ICheckBase {
|
||||
checkType: 'function';
|
||||
functionUrl: string;
|
||||
domain?: string;
|
||||
expectedStatusCode?: number;
|
||||
timeoutMs?: number;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* PWA check - validates Progressive Web App criteria
|
||||
*/
|
||||
export interface IPwaCheckConfig extends ICheckBase {
|
||||
checkType: 'pwa';
|
||||
targetUrl: string;
|
||||
domain?: string;
|
||||
lighthouseThreshold?: number;
|
||||
categories?: ('performance' | 'accessibility' | 'best-practices' | 'seo')[];
|
||||
}
|
||||
|
||||
/**
|
||||
* PageRank check - validates search engine ranking
|
||||
*/
|
||||
export interface IPageRankCheckConfig extends ICheckBase {
|
||||
checkType: 'pagerank';
|
||||
targetUrl: string;
|
||||
domain?: string;
|
||||
searchTerm: string;
|
||||
minimumRank?: number;
|
||||
checkGoogle?: boolean;
|
||||
checkBing?: boolean;
|
||||
googleMinRank?: number;
|
||||
bingMinRank?: number;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Union Type (for UI and generic handling)
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Union of all check configuration types.
|
||||
* Use `checkType` discriminant for type narrowing.
|
||||
*
|
||||
* @example
|
||||
* function handleCheck(check: TCheckConfig) {
|
||||
* if (check.checkType === 'function') {
|
||||
* console.log(check.functionUrl); // TypeScript knows this exists
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
export type TCheckConfig =
|
||||
| IAssumptionCheckConfig
|
||||
| IFunctionCheckConfig
|
||||
| IPwaCheckConfig
|
||||
| IPageRankCheckConfig;
|
||||
|
||||
// ============================================
|
||||
// Execution Interfaces (Runtime Data)
|
||||
// ============================================
|
||||
|
||||
// Keep existing execution interfaces for backward compatibility
|
||||
export * from './assumption.check.js';
|
||||
export * from './function.check.js';
|
||||
export * from './pagerank.check.js';
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import * as search from '../search.js';
|
||||
import { TCheckResultStatus, TExecutionTiming } from './index.js';
|
||||
import type * as search from '../search.js';
|
||||
import type { TCheckResultStatus } from '../types.js';
|
||||
import type { TExecutionTiming } from './index.js';
|
||||
|
||||
/**
|
||||
* PageRank check execution data.
|
||||
* Used by check runners to store input and results.
|
||||
*/
|
||||
export interface IPageRankCheck {
|
||||
inputData: {
|
||||
subId: string;
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { TCheckResultStatus } from './index.js';
|
||||
import type { TCheckResultStatus } from '../types.js';
|
||||
|
||||
/**
|
||||
* PWA check execution data.
|
||||
* Used by check runners to store input and results.
|
||||
*/
|
||||
export interface IPwaCheck {
|
||||
inputData: { domain: string };
|
||||
inputData: {
|
||||
domain: string;
|
||||
};
|
||||
executionResults: Array<{
|
||||
subId: string;
|
||||
timeStarted: number;
|
||||
|
||||
Reference in New Issue
Block a user