@animastor/web-settings
v0.1.0
Published
Pure AI provider and Local AI Connector helpers for Animastor web frontend — provider validation, connector lifecycle, status mapping, sharing badges, and timestamp formatting. Zero host dependencies; pure functions and types only.
Maintainers
Readme
@animastor/web-settings
Pure AI provider and Local AI Connector helpers for Animastor web frontend.
Scope
This package provides pure functions and types for AI settings UI:
AI Provider helpers
normalizeMeta— defensive normalizer for provider meta from APIvalidateProviderInput— form validation before PUTdescribeTestResult— test connection result to safe UI stringstatusLabel— status badge for saved-state pillformatLastTested— epoch-seconds timestamp to relative stringcanSave— save button disable logic
Local AI Connector helpers
validateCreateInput— create-connector form validationlooksLikeRegToken— registration token shape checklooksLikeConnectorCredential— credential shape checkstatusKey/statusClass— connector status badge mappingruntimeReachable— runtime reachability checkconnectorErrorKey— sanitized error code → i18n keybuildRunCommand— npx launch command buildershareStatus/shareStatusKey/shareStatusClass— sharing badge mapping
Zero host dependencies. The package imports nothing but its own internal modules. No host stores, no api/client, no i18n, no DOM APIs.
Install
npm install @animastor/web-settingsNo peer dependencies required — pure functions and types only.
Usage
import { normalizeMeta, validateProviderInput, statusKey, shareStatus } from '@animastor/web-settings';
// Normalize provider meta from API response
const meta = normalizeMeta(rawJson);
// Validate provider form input
const result = validateProviderInput({ providerType: 'openrouter', endpoint: '...', apiKey: '...', model: '...', isExisting: false });
// Get connector status badge key
const badgeKey = statusKey({ status: 'online', live: true }); // 'local_ai_status_online'
// Get sharing badge state
const share = shareStatus({ sharing_enabled: true, connector_live: true, runtime_reachable: true }); // 'shared'Public API
See src/index.ts for the complete public API surface.
Package boundary
- The package imports only its own internal modules — zero host imports.
@animastor/web-settings → host= forbidden;host → @animastor/web-settings= allowed through the public entry point only.
Development
npm install
npm run typecheck # tsc --noEmit
npm run test # vitest (pure function tests)
npm run build # tsup → dist/ (ESM + d.ts + sourcemaps)License
MIT
