Quick reference for LLMs working with TypeScript in this repository.
- MUST prefix all interfaces with
I(e.g.,IUserState,IStationLoginProps) - MUST use PascalCase for components and interfaces
- MUST use camelCase for hooks with
useprefix (e.g.,useUserState) - MUST use
.tsxextension for components,.tsfor hooks and utilities - MUST co-locate types in
{component}.types.tsfiles - MUST use
PickandPartialto derive types from parent interfaces - MUST document every interface property with JSDoc comments
- MUST use enums for event names and constants
- NEVER use
anywithout ESLint disable comment and explanation - NEVER duplicate type definitions - derive from source with
Pick
// PascalCase, .tsx extension
UserState.tsx
StationLogin.tsx
CallControl.tsx// camelCase with 'use' prefix, .ts extension
useUserState.ts
useStationLogin.ts
useCallControl.ts// PascalCase with 'I' prefix
interface IUserState { ... }
interface IStationLoginProps { ... }
interface IContactCenter { ... }// SCREAMING_SNAKE_CASE
const MAX_RETRY_COUNT = 3;
const DEFAULT_TIMEOUT = 5000;packages/*/src/{widget}/index.tsx # Widget entry
packages/*/src/helper.ts # Hooks/helpers
packages/*/src/{widget}/{widget}.types.ts # Types
import store from '@webex/cc-store';import { Component } from '@webex/cc-components';import { IUserState } from './user-state.types';import { observer } from 'mobx-react-lite';
import { runInAction } from 'mobx';interface IUserState {
idleCodes: IdleCode[];
agentId: string;
cc: IContactCenter;
currentState: string;
onStateChange?: (arg: IdleCode | ICustomState) => void;
}// Widget picks only what it needs from component interface
export type IUserStateProps = Pick<IUserState, 'onStateChange'>;
// Hook picks different subset
export type UseUserStateProps = Pick<
IUserState,
'idleCodes' | 'agentId' | 'cc' | 'currentState' | 'logger'
>;// Required props + optional callback props
export type StationLoginProps =
Pick<IStationLoginProps, 'profileMode'> &
Partial<Pick<IStationLoginProps, 'onLogin' | 'onLogout' | 'onCCSignOut'>>;type ICustomState = ICustomStateSet | ICustomStateReset;export enum TASK_EVENTS {
TASK_INCOMING = 'task:incoming',
TASK_ASSIGNED = 'task:assigned',
TASK_HOLD = 'task:hold',
}
export enum CC_EVENTS {
AGENT_DN_REGISTERED = 'agent:dnRegistered',
AGENT_LOGOUT_SUCCESS = 'agent:logoutSuccess',
}export enum AgentUserState {
Available = 'Available',
RONA = 'RONA',
Engaged = 'ENGAGED',
}/**
* Interface representing the properties for the Station Login component.
*/
export interface IStationLoginProps {
/**
* Webex Contact Center instance.
*/
cc: IContactCenter;
/**
* Array of teams the agent belongs to.
*/
teams: Team[];
/**
* Handler called when login completes.
*/
onLogin?: () => void;
}// Central export from *.types.ts
export type {
IContactCenter,
ITask,
Profile,
Team,
};
export {
CC_EVENTS,
TASK_EVENTS,
};// Optional callback with specific signature
onStateChange?: (arg: IdleCode | ICustomState) => void;
onLogin?: () => void;
onSaveEnd?: (isComplete: boolean) => void;