All files / src interfaces.ts

100% Statements 541/541
100% Branches 4/4
100% Functions 0/0
100% Lines 541/541

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x 145x  
export interface DirtyTrackable {
  dirtyMessage?: string;
  markClean(): void;
}
 
export interface Workspace {
  uuid: string;
  name: string;
  country: string;
  languages: string[];
  timezone: string;
  date_style: DateStyle;
  anon: boolean;
}
 
export interface Language {
  iso: string;
  name: string;
}
 
export interface Notification {
  created_on: string;
  type: string;
  url: string;
  is_seen: boolean;
  export?: {
    type: string;
    num_records: number;
  };
  import?: {
    type: string;
    num_records: number;
  };
  incident?: {
    type: string;
    started_on: string;
    ended_on?: string;
  };
}
 
export interface Attachment {
  uuid: string;
  content_type: string;
  url: string;
  filename: string;
  size: number;
  error: string;
}
 
/** A quick reply as stored/served by the server (engine shape) —
 * `text` buttons carry text, `location` requests may omit it. */
export interface QuickReply {
  type?: string;
  text?: string;
  extra?: string;
}
 
export enum DateStyle {
  DayFirst = 'day_first',
  MonthFirst = 'month_first',
  YearFirst = 'year_first'
}
 
export enum ScheduledEventType {
  CampaignEvent = 'campaign_event',
  ScheduledBroadcast = 'scheduled_broadcast',
  ScheduledTrigger = 'scheduled_trigger',
  SentBroadcast = 'sent_broadcast'
}
 
export enum TicketStatus {
  Open = 'open',
  Closed = 'closed'
}
 
export interface ScheduledEvent {
  type: ScheduledEventType;
  scheduled: string;
  repeat_period: string;
  campaign?: ObjectReference;
  flow?: ObjectReference;
  message?: string;
}
 
// one event definition in a campaign's schedule, offset from a date field
// on the contact - consumed by the temba-campaign-events component
export interface CampaignScheduleEvent {
  uuid: string;
  type: 'message' | 'flow';
  status: 'ready' | 'scheduling';
  offset: number;
  unit: string;
  offset_display: string;
  delivery_hour_display?: string;
  relative_to: { key: string; name: string; system?: boolean };
  flow?: ObjectReference;
  message?: string;
  count: number;
  edit_url: string;
  delete_url: string;
  fires_url: string;
}
 
export interface NamedUser extends User {
  name: string;
}
 
export interface User {
  id?: number;
  uuid?: string;
  first_name?: string;
  last_name?: string;
  name?: string;
  email?: string;
  role?: string;
  created_on?: string;
  avatar?: string;
}
 
export interface Ticket {
  uuid: string;
  subject: string;
  body?: string;
  closed_on: string;
  opened_on: string;
  status: string;
  contact: ObjectReference;
  topic: ObjectReference;
  assignee?: { email: string; name: string; avatar?: string };
}
 
export interface FlowResult {
  key: string;
  name: string;
  categories: string[];
  node_uuids: string[];
}
 
export interface FlowDetails {
  name: string;
  results: FlowResult[];
  modified_on: string;
  runs: {
    active: number;
    completed: number;
    expired: number;
    interrupted: number;
  };
}
 
/** A single row in the flow CRUDL list (`flows/flow_list.html`).
 * Distinct from {@link FlowDetails}, which is the per-flow editor
 * payload — this is the lighter list-row shape. */
export interface Flow {
  uuid: string;
  name: string;
  /** Flow type — drives the leading row icon. */
  type: 'messaging' | 'voice' | 'ivr' | 'background' | 'survey' | string;
  runs: number;
  ongoing: number;
  /** Completion ratio in the range 0–1. */
  completion: number;
  has_issues: boolean;
  labels: ObjectReference[];
  /** Recent daily engagement counts, oldest to newest — rendered as
   * a sparkline. Empty when there's been no recent engagement. */
  activity: number[];
}
 
/** A single row in the campaign CRUDL list
 * (`campaigns/campaign_list.html`). */
export interface Campaign {
  uuid: string;
  name: string;
  /** The contact group the campaign schedules against. */
  group: ObjectReference;
  /** Number of events (messages / flow starts) in the campaign. */
  events: number;
  /** Contacts currently in the campaign's group. */
  contacts: number;
  modified_on: string;
}
 
/** A single row in the trigger CRUDL list
 * (`triggers/trigger_list.html`): what starts the flow (type +
 * per-type details), any channel / group filters, and the flow it
 * starts. Triggers have no uuid — rows key off the numeric id. */
export interface Trigger {
  id: number;
  /** Trigger type slug — drives the leading row icon and the
   * details cell (`keyword`, `catch_all`, `schedule`,
   * `inbound_call`, `missed_call`, `new_conversation`, `referral`,
   * `closed_ticket`, `opt_in`, `opt_out`). */
  type: string;
  /** The flow the trigger starts. */
  flow: ObjectReference;
  /** Channel the trigger is limited to, with its type icon. */
  channel?: (ObjectReference & { icon?: string }) | null;
  /** Groups the trigger is limited to. */
  groups?: ObjectReference[];
  /** Groups the trigger excludes. */
  exclude_groups?: ObjectReference[];
  /** Contacts a scheduled trigger starts directly. */
  contacts?: ObjectReference[];
  /** Keyword triggers only. */
  keywords?: string[];
  /** Keyword match type — `F` (starts with) or `O` (matches). */
  match_type?: string | null;
  /** Referral triggers only. */
  referrer_id?: string | null;
  /** Scheduled triggers only — `display` is the server-rendered
   * human schedule ("each week on Monday"); `next_fire` is unset
   * once the schedule is exhausted or paused. */
  schedule?: {
    repeat_period?: string;
    display?: string;
    next_fire?: string | null;
  } | null;
  priority?: number;
  created_on?: string;
}
 
/** A single row in the broadcast CRUDL lists — both the scheduled
 * list (`msgs/broadcast_scheduled.html`) and the sent list
 * (`msgs/broadcast_list.html`). Broadcasts key off the numeric id;
 * content fields carry the base-language translation. */
export interface Broadcast {
  id: number;
  /** Server status slug — `pending`, `queued`, `started`,
   * `completed`, `failed` or `interrupted`. Scheduled broadcasts
   * that haven't fired yet sit at `pending`. */
  status?: string;
  /** Send progress for an in-flight broadcast — total recipients
   * (-1 until the org's contact count resolves) and messages
   * created so far. */
  progress?: { total: number; started: number };
  /** Base-language message text. */
  text?: string;
  /** Base-language attachments (`{content_type, url}` objects or
   * `contentType:url` strings). */
  attachments?: (string | Attachment)[];
  /** Base-language quick replies — engine `{text}` objects, with
   * plain strings tolerated for older data. */
  quick_replies?: (string | QuickReply)[];
  /** The opt-in the broadcast requests, when it is one. */
  optin?: ObjectReference | null;
  /** The WhatsApp template the broadcast sends, when it uses one. */
  template?: ObjectReference | null;
  /** Recipient groups. */
  groups?: ObjectReference[];
  /** Recipient contacts. */
  contacts?: ObjectReference[];
  /** Raw recipient URNs (editors/admins only). */
  urns?: string[];
  /** Recipient contact query, for query-addressed broadcasts. */
  query?: string | null;
  /** Human-readable exclusion descriptions ("Skip inactive
   * contacts", ...) rendered in the detail view. */
  exclusions?: string[];
  /** Scheduled broadcasts only — `display` is the server-rendered
   * human repeat ("each week on Monday, Wednesday"); `next_fire` is
   * null once the schedule is exhausted or paused. */
  schedule?: {
    repeat_period?: string;
    display?: string;
    next_fire?: string | null;
  } | null;
  /** Messages created by a sent broadcast. */
  msg_count?: number;
  created_on?: string;
  /** Email of the user who created the broadcast. */
  created_by?: string | null;
  modified_on?: string;
}
 
export interface Msg {
  /** Numeric id — present on persisted messages (the CRUDL list
   * keys rows off it); absent on outbound drafts. */
  id?: number;
  text: string;
  status: string;
  channel: ObjectReference;
  quick_replies: (string | QuickReply)[];
  urn: string;
  /** The message's contact — populated by the messages CRUDL
   * endpoint. Carries whichever of name/urn the endpoint exposes. */
  contact?: { uuid?: string; name?: string; urn?: string };
  direction: string;
  type: string;
  /** Message type as exposed by the messages CRUDL endpoint
   * (`text` / `optin` / …); mirrors `type` for that surface. */
  msg_type?: string;
  /** Attachments as exposed by the messages CRUDL endpoint, which
   * serializes each as a `{content_type, url}` object; some other
   * message surfaces carry them as `contentType:url` strings. */
  attachments: (string | Attachment)[];
  /** Labels applied to the message. */
  labels?: ObjectReference[];
  /** The flow the message was sent from, when there is one. */
  flow?: ObjectReference;
  /** When the message was created. */
  created_on?: string;
  /** Permission- and retention-gated URL to this message's channel
   * log. Present on the CRUDL list when the viewer can read logs and
   * the message is within the retention window; absent otherwise. */
  logs_url?: string;
  unsendable_reason?:
    | 'no_route'
    | 'contact_blocked'
    | 'contact_stopped'
    | 'contact_archived'
    | 'org_suspended'
    | 'looping';
}
 
export interface ObjectReference {
  uuid: string;
  name: string;
  url?: string;
}
 
export interface Shortcut {
  uuid: string;
  name: string;
  text: string;
  modified_on: string;
}
 
export interface ContactField {
  key: string;
  label: string;
  value_type: string;
  featured: boolean;
  priority: number;
  agent_access: string;
  type: string;
  usages: { campaign_events: number; flows: number; groups: number };
}
 
export interface ContactGroup {
  uuid: string;
  count: number;
  name: string;
  query?: string;
  status: string;
}
 
export interface URN {
  scheme: string;
  path: string;
  display?: string | null;
  channel?: ObjectReference | null;
}
 
export interface Group {
  name: string;
  uuid: string;
  is_dynamic?: boolean;
}
 
export interface ContactNote {
  text: string;
  created_on: string;
  created_by: NamedUser;
}
 
export interface ContactTicket {
  name: string;
  uuid: string;
  status: string;
 
  contact: {
    uuid: string;
    name: string;
    created_on: Date;
    last_seen_on: Date;
  };
}
 
export interface Contact {
  name: string;
  uuid: string;
  stopped: boolean;
  blocked: boolean;
  urns: URN[];
  language?: string;
  fields: { [key: string]: string };
  groups: Group[];
  notes: ContactNote[];
  modified_on: string;
  created_on: string;
  last_seen_on: string;
  status: string;
 
  ref?: string; // only returned for anon workspaces
  flow?: ObjectReference;
  last_msg?: Msg;
  direction?: string;
  ticket: {
    uuid: string;
    subject: string;
    closed_on?: string;
    last_activity_on: string;
    assignee?: User;
    topic?: ObjectReference;
  };
}
 
export interface FeatureProperties {
  name: string;
  osm_id: string;
  level: number;
  children?: FeatureProperties[];
  has_children?: boolean;
  aliases?: string;
  parent_osm_id?: string;
  id?: number;
  path?: string;
}
 
export interface Position {
  top: number;
  left: number;
}
 
export interface FunctionExample {
  template: string;
  output: string;
}
 
export interface CompletionOption {
  name?: string;
  summary: string;
 
  // functions
  signature?: string;
  detail?: string;
  examples?: FunctionExample[];
}
 
export interface CompletionResult {
  anchorPosition: Position;
  query: string;
  options: CompletionOption[];
  currentFunction: CompletionOption;
}
 
export interface CompletionProperty {
  key: string;
  help: string;
  type: string;
}
 
export interface CompletionType {
  name: string;
 
  key_source?: string;
  property_template?: CompletionProperty;
  properties?: CompletionProperty[];
}
 
export interface CompletionSchema {
  types: CompletionType[];
  root: CompletionProperty[];
  root_no_session: CompletionProperty[];
}
 
export type KeyedAssets = { [assetType: string]: string[] };
 
export enum CustomEventType {
  Loaded = 'temba-loaded',
  Loading = 'temba-loading',
  Canceled = 'temba-canceled',
  CursorChanged = 'temba-cursor-changed',
  Refreshed = 'temba-refreshed',
  Selection = 'temba-selection',
  ButtonClicked = 'temba-button-clicked',
  DialogHidden = 'temba-dialog-hidden',
  ScrollThreshold = 'temba-scroll-threshold',
  ScrollThresholdBottom = 'temba-scroll-threshold-bottom',
  ContentChanged = 'temba-content-changed',
  ContextChanged = 'temba-context-changed',
  FetchComplete = 'temba-fetch-complete',
  MessageSent = 'temba-message-sent',
  Submitted = 'temba-submitted',
  Redirected = 'temba-redirected',
  NoPath = 'temba-no-path',
  StoreUpdated = 'temba-store-updated',
  Ready = 'temba-ready',
  OrderChanged = 'temba-order-changed',
  ColumnOrderChanged = 'temba-column-order-changed',
  DragStart = 'temba-drag-start',
  DragStop = 'temba-drag-stop',
  DragExternal = 'temba-drag-external',
  DragInternal = 'temba-drag-internal',
  Resized = 'temba-resized',
  DetailsChanged = 'temba-details-changed',
  Error = 'temba-error',
  Interrupt = 'temba-interrupt',
  Opened = 'temba-opened',
  NotificationReceived = 'temba-notification',
  TicketUpdated = 'temba-ticket-updated',
  Moved = 'temba-moved',
  DateRangeChanged = 'temba-date-range-changed',
  NodeDeleted = 'temba-node-deleted',
  StickyNoteDeleted = 'temba-sticky-note-deleted',
  ActionEditRequested = 'temba-action-edit-requested',
  AddActionRequested = 'temba-add-action-requested',
  ActionSaved = 'temba-action-saved',
  ActionEditCanceled = 'temba-action-edit-canceled',
  NodeEditRequested = 'temba-node-edit-requested',
  NodeSaved = 'temba-node-saved',
  NodeEditCancelled = 'temba-node-edit-cancelled',
  FollowSimulation = 'temba-follow-simulation',
  ContactClicked = 'temba-contact-clicked',
  FlowClicked = 'temba-flow-clicked',
  GroupClicked = 'temba-group-clicked',
  ShowIssue = 'temba-show-issue',
  SizeChanged = 'temba-size-changed',
  IssueSelected = 'temba-issue-selected',
  IssuesClosed = 'temba-issues-closed',
  IssuesTabClicked = 'temba-issues-tab-clicked',
  RevisionViewed = 'temba-revision-viewed',
  RevisionCancelled = 'temba-revision-cancelled',
  RevisionReverted = 'temba-revision-reverted',
  RevisionsClosed = 'temba-revisions-closed',
  RowClick = 'temba-row-click',
  ShortcutEdit = 'temba-shortcut-edit',
  ShortcutDelete = 'temba-shortcut-delete',
  SelectionChange = 'temba-selection-change',
  BulkAction = 'temba-bulk-action',
  /** The label dropdown's "New Label…" row was clicked — detail
   * carries the action key and the selected row ids so the host can
   * open its create modal seeded with the selection. */
  LabelCreate = 'temba-label-create',
  /** A restorable piece of component state changed (page, sort, …).
   * Fired by lists so the host SPA can persist the state into the
   * browser's history entry (typically via `history.replaceState`).
   * Detail: `{ key: string, state: object }`. */
  HistoryChange = 'temba-history-change'
}