The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: Handle RealtimeLimitsEstimator component for md output (#47134)
Jeremias Menichelli3a25a86874a0
diff --git a/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.constants.ts b/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.constants.tsnew file mode 100644index 00000000000..abf52483ef9--- /dev/null+++ b/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.constants.ts@@ -0,0 +1,30 @@+// Shared copy for the Realtime throughput tables. Consumed both by the+// interactive component and by the markdown alternative in+// `internals/markdown-schema/RealtimeLimitsEstimator.ts`, so the headings and+// compute labels stay in sync. Keep this file free of React/browser imports.++export const COMPUTE_OPTIONS = [+ { value: 'micro', label: 'Micro' },+ { value: 'small', label: 'Small to medium' },+ { value: 'large', label: 'Large to 16XL' },+] as const++export const COMPUTE_LABELS: Record<string, string> = Object.fromEntries(+ COMPUTE_OPTIONS.map((o) => [o.value, o.label])+)++// Input-parameter columns (only shown in the full/raw table).+export const THROUGHPUT_PARAM_HEADINGS = ['Filters', 'RLS', 'Connected clients'] as const++// Result columns (shown in both the current-selection table and the raw table).+export const THROUGHPUT_METRIC_HEADINGS = [+ 'Total DB changes /sec',+ 'Max messages per client /sec',+ 'Max total messages /sec',+ 'Latency p95',+] as const++export const THROUGHPUT_TABLE_HEADINGS = [+ ...THROUGHPUT_PARAM_HEADINGS,+ ...THROUGHPUT_METRIC_HEADINGS,+] as constdiff --git a/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.tsx b/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.tsxindex e1a3659de8e..de5402b9d3b 100644--- a/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.tsx+++ b/apps/docs/components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.tsx@@ -14,6 +14,13 @@ import {SelectValue,} from 'ui'+import {+ COMPUTE_LABELS,+ COMPUTE_OPTIONS,+ THROUGHPUT_METRIC_HEADINGS,+ THROUGHPUT_TABLE_HEADINGS,+} from './RealtimeLimitsEstimator.constants'+export default function RealtimeLimitsEstimater({}) {const findTableValue = ({ computeAddOn, filters, rls, concurrency }) => {return throughputTable.find(@@ -71,9 +78,11 @@ export default function RealtimeLimitsEstimater({}) {<SelectValue className="font-mono" /></SelectTrigger><SelectContent>- <SelectItem value="micro">Micro</SelectItem>- <SelectItem value="small">Small to medium</SelectItem>- <SelectItem value="large">Large to 16XL</SelectItem>+ {COMPUTE_OPTIONS.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}</SelectContent></Select></div>@@ -129,10 +138,11 @@ export default function RealtimeLimitsEstimater({}) {<table className="table-auto"><thead><tr>- <th className="px-4 py-2">Total DB changes /sec</th>- <th className="px-4 py-2">Max messages per client /sec</th>- <th className="px-4 py-2">Max total messages /sec</th>- <th className="px-4 py-2">Latency p95</th>+ {THROUGHPUT_METRIC_HEADINGS.map((heading) => (+ <th key={heading} className="px-4 py-2">+ {heading}+ </th>+ ))}</tr></thead><tbody>@@ -174,23 +184,15 @@ export default function RealtimeLimitsEstimater({}) {.filter((v, i, a) => a.indexOf(v) === i).map((computeAddOn) => (<div>- <h4>- {computeAddOn === 'micro'- ? 'Micro'- : computeAddOn === 'small'- ? 'Small to medium'- : 'Large to 16XL'}- </h4>+ <h4>{COMPUTE_LABELS[computeAddOn]}</h4><table className="table-auto"><thead><tr>- <th className="px-4 py-2">Filters</th>- <th className="px-4 py-2">RLS</th>- <th className="px-4 py-2">Connected clients</th>- <th className="px-4 py-2">Total DB changes /sec</th>- <th className="px-4 py-2">Max messages per client /sec</th>- <th className="px-4 py-2">Max total messages /sec</th>- <th className="px-4 py-2">Latency p95</th>+ {THROUGHPUT_TABLE_HEADINGS.map((heading) => (+ <th key={heading} className="px-4 py-2">+ {heading}+ </th>+ ))}</tr></thead><tbody>diff --git a/apps/docs/internals/generate-guides-markdown.ts b/apps/docs/internals/generate-guides-markdown.tsindex 4e54f643f90..191b93f426d 100644--- a/apps/docs/internals/generate-guides-markdown.ts+++ b/apps/docs/internals/generate-guides-markdown.ts@@ -18,6 +18,7 @@ import { Link } from './markdown-schema/Link'import { MetricsStackCards } from './markdown-schema/MetricsStackCards'import { Panel } from './markdown-schema/Panel'import { Price } from './markdown-schema/Price'+import { RealtimeLimitsEstimator } from './markdown-schema/RealtimeLimitsEstimator'import { RegionsList, SmartRegionsList } from './markdown-schema/RegionsList'import { SharedData } from './markdown-schema/SharedData'import { StepHike } from './markdown-schema/StepHike'@@ -140,6 +141,7 @@ const SCHEMA: ComponentSchema = {Price,GlassPanel: Panel,IconPanel: Panel,+ RealtimeLimitsEstimator,RegionsList,SmartRegionsList,...StepHike,diff --git a/apps/docs/internals/markdown-schema/RealtimeLimitsEstimator.ts b/apps/docs/internals/markdown-schema/RealtimeLimitsEstimator.tsnew file mode 100644index 00000000000..7d07d8dc8a4--- /dev/null+++ b/apps/docs/internals/markdown-schema/RealtimeLimitsEstimator.ts@@ -0,0 +1,36 @@+import {+ COMPUTE_LABELS,+ THROUGHPUT_TABLE_HEADINGS,+} from '../../components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.constants'+import throughputTable from '../../data/realtime/throughput.json'++type Row = {+ computeAddOn: string+ filters: boolean+ rls: boolean+ concurrency: number+ maxDBChanges: number+ maxMessagesPerClient: number+ totalMessagesPerSecond: number+ p95Latency: number+}++const headerRow = `| ${THROUGHPUT_TABLE_HEADINGS.join(' | ')} |`+const dividerRow = `| ${THROUGHPUT_TABLE_HEADINGS.map(() => '---').join(' | ')} |`++const renderGroup = (computeAddOn: string): string => {+ const rows = (throughputTable as Row[]).filter((l) => l.computeAddOn === computeAddOn)+ return `#### ${COMPUTE_LABELS[computeAddOn] ?? computeAddOn}++${headerRow}+${dividerRow}+${rows+ .map(+ (l) =>+ `| ${l.filters ? 'Yes' : 'No'} | ${l.rls ? 'Yes' : 'No'} | ${l.concurrency.toLocaleString()} | ${l.maxDBChanges} | ${l.maxMessagesPerClient} | ${l.totalMessagesPerSecond.toLocaleString()} | ${l.p95Latency}ms |`+ )+ .join('\n')}`+}++export const RealtimeLimitsEstimator = (): string =>+ [...new Set((throughputTable as Row[]).map((l) => l.computeAddOn))].map(renderGroup).join('\n\n')