@sudobility/testomniac_client
v0.0.110
Published
Testomniac API client library with TanStack Query hooks
Maintainers
Readme
@sudobility/testomniac_client
API client SDK for the Testomniac testing platform with TanStack Query hooks.
Installation
bun add @sudobility/testomniac_clientPeer dependencies:
bun add react @tanstack/react-query @sudobility/typesUsage
import { TestomniacClient } from '@sudobility/testomniac_client';
import {
useRun,
useRunSummary,
useRunFindings,
useSubmitScan,
} from '@sudobility/testomniac_client/hooks';
// Create the HTTP client (dependency-injected NetworkClient)
const client = new TestomniacClient({
baseUrl: 'https://api.example.com',
networkClient,
});
// Fetch a test run directly
const run = await client.getTestRun(runId, token);
// In a React component -- query hook:
const { run, isLoading, error } = useRun({
networkClient,
baseUrl,
runId,
token,
});
// Mutation hook (public endpoint, no auth required):
const { submitScan, isSubmitting } = useSubmitScan({
networkClient,
baseUrl,
});
await submitScan({ url: 'https://example.com', email: '[email protected]' });API
TestomniacClient
HTTP client class constructed with { baseUrl, networkClient }. Uses dependency injection via the NetworkClient interface from @sudobility/types -- no direct fetch calls. Provides 60+ async methods covering all API endpoints: users, entities, products, runners, test environments, test runs, findings, personas, test scenarios, test surfaces, test interactions, credentials, schedules, and more.
Hooks (74)
All hooks follow consistent patterns:
Query hooks accept a config object with { baseUrl, networkClient, token, ...params, enabled? } and return { data, isLoading, error, refetch } with safe defaults (?? [], ?? null).
Mutation hooks return { mutateAsync, isPending, error, reset } with automatic cache invalidation.
Runs & Summaries
useRun(config)-- Single run detailsuseRunSummary(config)-- Run summary with finding counts and expertise breakdownuseRunLiveDashboard(config)-- Live dashboard data for in-progress runsuseRunStructure(config)-- Run structure (pages, interactions hierarchy)useRunNavigationMap(config)-- Site navigation map for graph visualization
Pages & Page States
useRunPages(config)-- Pages discovered in a runuseRunPagesSummary(config)-- Summary of all pages in a runuseRunPageSummary(config)-- Detailed summary for a single pageusePageStates(config)-- Page states for a given pageusePageStateItems(config)-- Actionable items within a page stateusePageStateScaffolds(config)-- Scaffolds detected in a page stateuseHtmlElement(config)-- HTML element details
Test Surfaces & Bundles
useRunnerTestSurfaces(config)-- Test surfaces for a runneruseEnvironmentTestSurfaces(config)-- Test surfaces for an environmentuseTestSurfaceChildSurfaces(config)-- Child surfaces of a test surfaceuseTestSurfaceTestInteractions(config)-- Interactions for a test surfaceuseRunnerTestSurfaceBundles(config)-- Test surface bundlesuseBundleSurfaces(config)-- Surfaces in a bundleuseBundleInteractions(config)-- Interactions in a bundleuseBundleScenarios(config)-- Scenarios in a bundleuseCreateTestSurfaceBundle(config)-- Mutation: create bundleuseUpdateTestSurfaceBundle(config)-- Mutation: update bundleuseDeleteTestSurfaceBundle(config)-- Mutation: delete bundle
Test Interactions & Test Runs
useRunTestInteractions(config)-- Test interactions for a runuseRunnerTestInteractions(config)-- Test interactions for a runneruseEnvironmentTestInteractions(config)-- Test interactions for an environmentuseTestInteractionActions(config)-- Actions within a test interactionuseTestInteractionRun(config)-- Single test interaction runuseCreateTestInteractionRun(config)-- Mutation: create interaction runuseRunTestRuns(config)-- Test runs for a runuseRunnerTestRuns(config)-- Test runs for a runneruseTestRunFindings(config)-- Findings for a specific test run
Findings & Patterns
useRunFindings(config)-- Findings for a runuseRunnerFindings(config)-- Findings across a runneruseRunPatterns(config)-- UI patterns detected in a runuseRunScaffolds(config)-- Scaffolds detected in a runuseRunnerScaffolds(config)-- Scaffolds across a runner
Personas
useRunPersonas(config)-- Personas for a runuseRunnerPersonas(config)-- Personas for a runneruseProductPersonas(config)-- Personas for a productusePersonaUseCases(config)-- Use cases for a personauseUseCaseInputValues(config)-- Input values for a use caseuseCreatePersona(config)-- Mutation: create personauseUpdatePersona(config)-- Mutation: update personauseDeletePersona(config)-- Mutation: delete personauseDetectPersonas(config)-- Mutation: AI-detect personas
Test Scenarios & Sequences
useRunnerTestScenarios(config)-- Test scenarios for a runneruseTestScenarioSequences(config)-- Sequences in a test scenariouseTestScenarioSequenceTestInteractions(config)-- Interactions in a sequenceuseTestScenarioSequenceRuns(config)-- Runs of a sequenceuseCreateTestScenario(config)-- Mutation: create scenariouseUpdateTestScenario(config)-- Mutation: update scenariouseDeleteTestScenario(config)-- Mutation: delete scenariouseDetectTestScenarios(config)-- Mutation: AI-detect scenariosuseGenerateSequence(config)-- Mutation: AI-generate sequence steps
Schedules & Credentials
useRunnerSchedules(config)-- Schedules for a runneruseCreateTestSchedule(config)-- Mutation: create scheduleuseEntityCredentials(config)-- Credentials for an entityuseCreateEntityCredential(config)-- Mutation: create credentialuseUpdateEntityCredential(config)-- Mutation: update credentialuseDeleteEntityCredential(config)-- Mutation: delete credential
Entities, Products & Runners
useEntities(config)-- User's entitiesuseEntityProducts(config)-- Products for an entityuseProduct(config)-- Single product detailsuseProductRuns(config)-- Runs for a productuseProductRunners(config)-- Runners for a productuseProductEnvironments(config)-- Environments for a productuseRunner(config)-- Single runner detailsuseRunnerScans(config)-- Scans for a runneruseRunnerPages(config)-- Pages across a runneruseRunnerPageStates(config)-- Page states across a runneruseEnvironmentPages(config)-- Pages for an environment
Scanning
useSubmitScan(config)-- Mutation: submit a scan (public endpoint, no auth required)
QUERY_KEYS
Type-safe cache key factory for TanStack Query with 50+ key methods. Keys are namespaced under 'testomniac' and structured hierarchically (e.g., QUERY_KEYS.run(runId) produces ['testomniac', 'run', runId]).
Cache Settings
DEFAULT_STALE_TIME-- 5 minutesDEFAULT_GC_TIME-- 30 minutes
Utilities
createAuthHeaders(token)-- BuildsAuthorization: Bearerheader objectbuildUrl(base, path)-- URL construction helperhandleApiError(error)-- Standardized API error handling
Development
bun run build # Build ESM (tsc -> dist/)
bun run build:watch # Watch mode build
bun run clean # Remove dist/
bun test # Run Vitest tests
bun run typecheck # TypeScript check
bun run lint # ESLint
bun run verify # typecheck + test + build (use before commit)Related Packages
- testomniac_types -- Shared type definitions (imported for all API request/response types)
- testomniac_api -- Backend server this client communicates with
- testomniac_lib -- Business logic library that wraps this client's hooks
- testomniac_app -- Web frontend (consumes transitively via testomniac_lib)
- testomniac_app_rn -- React Native app (consumes transitively via testomniac_lib)
License
BUSL-1.1
