Skip to content

API

@ogygia/devtools/profiler/storage

The storage interface that decides where the profiler keeps its runs. Adapters live at /storage/sqlite, /storage/redis and /storage/postgres.

On this page

This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.

import { … } from '@ogygia/devtools/profiler/storage';

Exports getProfilerStore · memoryStore · recordColumns · setProfilerStore · ProfilerRecord · ProfilerStore · ProfilerVisitRecord · ProfilerSummary

getProfilerStore

function

The store set by setProfilerStore, if any — read by the profiler host on mount.

function getProfilerStore(): ProfilerStore | undefined;

memoryStore

function

An in-memory store — a Map with an LRU cap. The profiler without a store keeps reports in its own memory already, so this adds nothing there; it is for tests and a model for a custom store. Nothing survives a restart.

function memoryStore(cap?: number): ProfilerStore;

recordColumns

function

Pull the summary columns off a record for storing them alongside the dump.

function recordColumns(rec: ProfilerRecord): ProfilerSummary;

setProfilerStore

function

function setProfilerStore(store: ProfilerStore): void;

ProfilerRecord

interface

One report as a store holds it: summary columns for the list, and the portable dump as JSON.

interface ProfilerRecord {/*…*/}

ProfilerRecord.id

id: string;

ProfilerRecord.created

epoch ms the report was created

created: number;

ProfilerRecord.page

the profiled page (page mode), else null

page: string | null;

ProfilerRecord.trigger

window | page | request | trap

trigger: string;

ProfilerRecord.label

a human label for the list (the page, or the request path)

label: string;

ProfilerRecord.median

the median render in ms (page mode), else null — shown in the list

median: number | null;

ProfilerRecord.dump

the portable dump as a JSON string: { kind, version, meta, analysis, extras }

dump: string;

ProfilerStore

interface

The storage contract. Report methods are required; visit methods are optional (with a store that omits them, a server window sees only its own instance's requests). All async so a network backend fits; a memory or SQLite store just resolves immediately.

interface ProfilerStore {/*…*/}

ProfilerStore.init

Called once before first use — create tables, connect, etc. Optional.

init?(): Promise<void> | void;

ProfilerStore.putReport

Write (or overwrite) a report.

putReport(rec: ProfilerRecord): Promise<void> | void;

ProfilerStore.getReport

Read a report's full dump JSON, or null when absent.

getReport(id: string): Promise<string | null> | string | null;

ProfilerStore.listReports

The most recent reports (summaries), newest first.

listReports(limit?: number): Promise<ProfilerSummary[]> | ProfilerSummary[];

ProfilerStore.deleteReport

Remove a report.

deleteReport(id: string): Promise<void> | void;

ProfilerStore.prune

Keep at most keep reports, dropping the oldest — the store's own LRU, called after a put.

prune?(keep: number): Promise<void> | void;

ProfilerStore.putVisit

putVisit?(rec: ProfilerVisitRecord): Promise<void> | void;

ProfilerStore.listVisits

listVisits?(page: string, limit?: number): Promise<ProfilerVisitRecord[]> | ProfilerVisitRecord[];

ProfilerStore.close

Release connections. Optional.

close?(): Promise<void> | void;

ProfilerStore.kind

A name for the dashboard ("sqlite", "redis", "postgres", "memory").

readonly kind: string;

ProfilerVisitRecord

interface

One visit row, as a store holds it: today, one request of a server window, written by whichever instance served it and listed together under the window's page key. Optional to support.

interface ProfilerVisitRecord {/*…*/}

ProfilerVisitRecord.key

unique per row (it starts with page)

key: string;

ProfilerVisitRecord.page

page: string;

ProfilerVisitRecord.at

epoch ms

at: number;

ProfilerVisitRecord.visit

the visit payload as a JSON string

visit: string;

ProfilerSummary

type

What the list needs — every column of a record except the (large) dump.

type ProfilerSummary = Omit<ProfilerRecord, "dump">;