84 lines
2.0 KiB
TypeScript
84 lines
2.0 KiB
TypeScript
|
|
import type { IRouteConfig } from '@push.rocks/smartproxy';
|
||
|
|
|
||
|
|
// ============================================================================
|
||
|
|
// Route Management Data Types
|
||
|
|
// ============================================================================
|
||
|
|
|
||
|
|
export type TApiTokenScope = 'routes:read' | 'routes:write' | 'config:read' | 'tokens:read' | 'tokens:manage';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A merged route combining hardcoded and programmatic sources.
|
||
|
|
*/
|
||
|
|
export interface IMergedRoute {
|
||
|
|
route: IRouteConfig;
|
||
|
|
source: 'hardcoded' | 'programmatic';
|
||
|
|
enabled: boolean;
|
||
|
|
overridden: boolean;
|
||
|
|
storedRouteId?: string;
|
||
|
|
createdAt?: number;
|
||
|
|
updatedAt?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A warning generated during route merge/startup.
|
||
|
|
*/
|
||
|
|
export interface IRouteWarning {
|
||
|
|
type: 'disabled-hardcoded' | 'disabled-programmatic' | 'orphaned-override';
|
||
|
|
routeName: string;
|
||
|
|
message: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Public info about an API token (never includes the hash).
|
||
|
|
*/
|
||
|
|
export interface IApiTokenInfo {
|
||
|
|
id: string;
|
||
|
|
name: string;
|
||
|
|
scopes: TApiTokenScope[];
|
||
|
|
createdAt: number;
|
||
|
|
expiresAt: number | null;
|
||
|
|
lastUsedAt: number | null;
|
||
|
|
enabled: boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
// ============================================================================
|
||
|
|
// Storage Schemas (persisted via StorageManager)
|
||
|
|
// ============================================================================
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A programmatic route stored in /config-api/routes/{id}.json
|
||
|
|
*/
|
||
|
|
export interface IStoredRoute {
|
||
|
|
id: string;
|
||
|
|
route: IRouteConfig;
|
||
|
|
enabled: boolean;
|
||
|
|
createdAt: number;
|
||
|
|
updatedAt: number;
|
||
|
|
createdBy: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* An override for a hardcoded route, stored in /config-api/overrides/{routeName}.json
|
||
|
|
*/
|
||
|
|
export interface IRouteOverride {
|
||
|
|
routeName: string;
|
||
|
|
enabled: boolean;
|
||
|
|
updatedAt: number;
|
||
|
|
updatedBy: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A stored API token, stored in /config-api/tokens/{id}.json
|
||
|
|
*/
|
||
|
|
export interface IStoredApiToken {
|
||
|
|
id: string;
|
||
|
|
name: string;
|
||
|
|
tokenHash: string;
|
||
|
|
scopes: TApiTokenScope[];
|
||
|
|
createdAt: number;
|
||
|
|
expiresAt: number | null;
|
||
|
|
lastUsedAt: number | null;
|
||
|
|
createdBy: string;
|
||
|
|
enabled: boolean;
|
||
|
|
}
|