video-loader/session

Source: session.js:10

Versioned analysis session, technical journal, and reversible editorial commands for the Video Loader. The technical journal is intentionally independent from the report so it can later drive clip extraction or other post-processing without rendering the editorial output again.


Instance Methods

createId(prefix: string): string

Creates a stable random identifier with a deterministic fallback for older browsers and constrained test environments.

Parameters

  • prefix (string) — Identifier prefix.

Returns

  • string — Unique identifier.

Static Methods

createAnalysisSession(source: object, config: object): object

Creates an empty video-analysis session.

Parameters

  • source (object) — Source metadata.
    • source.name (string) — Source filename.
    • source.size (number) — Source byte size.
    • source.type (string) — Source media type.
    • source.lastModified (number, optional) — Source modification time.
    • source.duration (number, optional) — Decoded duration.
    • source.width (number, optional) — Decoded width.
    • source.height (number, optional) — Decoded height.
    • source.fingerprint (string | null, optional) — Bounded source fingerprint.
  • config (object) — Effective analyser configuration.

Returns

  • object — Mutable session owned by one analyser controller.

appendJournal( session: object, type: string, payload?: object, ): object

Appends one structured technical-journal entry.

Parameters

  • session (object) — Analysis session.
  • type (string) — Stable entry type.
  • payload (object, optional, default: "{}") — Serializable entry payload.

Returns

  • object — Appended journal entry.

appendSample(session: object, sample: object): object

Adds one lightweight sample without image pixels or model vectors.

Parameters

  • session (object) — Analysis session.
  • sample (object) — Serializable sample metrics.

Returns

  • object — Stored sample.

recordEvidenceObservation( session: object, observation: object, mergeWindowSeconds?: number, ): object

Adds an evidence event or merges a nearby verification into the latest open event. Images may be attached to the session for report rendering, but they are excluded from the separately downloadable technical log.

Parameters

  • session (object) — Analysis session.
  • observation (object) — Face-api observation and trigger context.
  • mergeWindowSeconds (number, optional, default: 3) — Maximum distance from the previous observation.

Returns

  • object — Created or updated event.

recordManualFrameCheck(session: object, check: object): object

Adds one person-requested source-frame comparison to the evidence story. Unlike automatic events, a manual check needs no repeated divergence vote: its meaning is that a person explicitly asked to inspect this timestamp. Image bytes remain on the session event and are omitted from the log.

Parameters

  • session (object) — Analysis session with an acquired baseline.
  • check (object) — Manual comparison result.
    • check.mediaTime (number) — Exact source timestamp.
    • check.interpretation ('below-threshold' | 'above-threshold' | 'no-2d-face' | 'not-comparable') — Human-facing result category.
    • check.observation (object) — Model result stored with the event.
    • check.frame (Object) — Native source frame.

Returns

  • object — Created manual evidence event.

selectEventFrame(event: object, frame: Object): boolean

Attaches or replaces the selected high-resolution frame for an event.

Parameters

  • event (object) — Evidence event.
  • frame (Object) — Frame payload.

Returns

  • boolean — Whether the frame replaced the prior selection.

applyEditorialCommand(session: object, command: object): boolean

Applies one reversible editorial command.

Parameters

  • session (object) — Analysis session.
  • command (object) — Editorial command.
    • command.type ('promote' | 'reject' | 'caption' | 'move-earlier' | 'move-later') — Command type.
    • command.eventId (string) — Event identifier. The baseline is pinned and cannot receive editorial commands.
    • command.value (string, optional) — Caption value.

Returns

  • boolean — Whether the command changed an event.

undoEditorialCommand(session: object): boolean

Restores the state before the latest editorial command.

Parameters

  • session (object) — Analysis session.

Returns

  • boolean — Whether a command was undone.

redoEditorialCommand(session: object): boolean

Reapplies the latest undone editorial command.

Parameters

  • session (object) — Analysis session.

Returns

  • boolean — Whether a command was redone.

buildReport(session: object): object

Produces the user-facing report without technical journal internals or image byte duplication. Selected frame data URLs remain available to the caller as separate frame artifacts.

Parameters

  • session (object) — Analysis session.

Returns

  • object — Serializable report model.

serializeTechnicalLog(session: object): string

Serialises the technical log as newline-delimited JSON. The first record is a self-contained header; later records can be streamed or processed without loading report images into memory.

Parameters

  • session (object) — Analysis session.

Returns

  • string — NDJSON document ending with a newline.

Other

VIDEO_ANALYSIS_SCHEMA_VERSION

Current machine-readable session and log schema version.