Skip to content

@webcontextinterface/spec API

Types and DOM helpers for the WCI 1.0 specification.

Types

WciRole

'action' | 'form' | 'display' | 'nav' | 'status' | 'landmark'

RoleUse
actionClickable CTA (button, link with side-effect)
formInput, textarea, select, checkbox, radio
displayRead-only data (price, status, label)
navNavigation link (route change)
statusAsync indicator (loading, error, success)
landmarkScope root — bounded task zone

WciAction

'click' | 'fill' | 'select' | 'check' | 'upload' | 'submit' | 'navigate' | 'focus' | 'clear'

WciNodeSpec

Maps 1:1 to data-wci-* on an element.

FieldTypeAttribute
idstringdata-wci-id
roleWciRoledata-wci-role
descstringdata-wci-desc
action?WciActiondata-wci-action
stateRecord<string, unknown>data-wci-state (JSON)
precondition?stringdata-wci-precondition
required?booleandata-wci-required
options?string[]data-wci-options (JSON)
emits?stringdata-wci-emit
scope?stringdata-wci-scope
hidden?booleandata-wci-hidden
priority?numberdata-wci-priority (1–5)

WciView

Distilled page or scope:

FieldType
wci_versionstring
page_titlestring
scope?string
scope_desc?string
distilled_atISO timestamp
node_countnumber
site_context?SiteContextSummary
nodesWciNodeSpec[]

Site policy types

TypeSource
WciPolicyParsed wci.txt
SiteManifestParsed wci.json
TaskFlowMulti-step journey in manifest
ScopeDescriptorScope metadata with sensitivity
SiteContextSummaryAbbreviated site info for distilled views

See packages/spec/src/index.ts for full field lists.

Functions

readWciNodeSpec(el: HTMLElement): WciNodeSpec | null

Reads all data-wci-* attributes from an element.

Returns null if the element has neither data-wci-id nor data-wci-role.

Example:

typescript
import { readWciNodeSpec } from '@webcontextinterface/spec';

const spec = readWciNodeSpec(
  document.querySelector('[data-wci-id="email-input"]') as HTMLElement
);

Install

bash
npm install @webcontextinterface/spec
typescript
import {
  readWciNodeSpec,
  type WciNodeSpec,
  type WciView,
  type WciPolicy,
  type SiteManifest,
} from '@webcontextinterface/spec';

No runtime dependencies.

See also