@toclocoinc/lattice-grid 1.39.0 → 1.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/API.html +85 -0
- package/docs/api-detail.html +1 -1
- package/lattice-grid.d.ts +116 -1
- package/lattice-grid.esm.min.js +849 -136
- package/lattice-grid.min.cjs +847 -136
- package/lattice-grid.min.js +847 -136
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-calendar.esm.min.js +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexmap.esm.min.js +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/charts.esm.min.js +4 -4
- package/modules/charts.min.cjs +4 -4
- package/modules/charts.min.js +4 -4
- package/modules/data-router.esm.min.js +212 -6
- package/modules/data-router.min.cjs +212 -6
- package/modules/data-router.min.js +212 -6
- package/modules/devtools.esm.min.js +2 -2
- package/modules/devtools.min.cjs +2 -2
- package/modules/devtools.min.js +2 -2
- package/modules/dhtmlx-compat.esm.min.js +4 -4
- package/modules/dhtmlx-compat.min.cjs +4 -4
- package/modules/dhtmlx-compat.min.js +4 -4
- package/modules/gantt.esm.min.js +4 -4
- package/modules/gantt.min.cjs +4 -4
- package/modules/gantt.min.js +4 -4
- package/modules/htmx.esm.min.js +845 -136
- package/modules/htmx.min.cjs +845 -136
- package/modules/htmx.min.js +845 -136
- package/modules/kanban.esm.min.js +350 -7
- package/modules/kanban.min.cjs +350 -7
- package/modules/kanban.min.js +350 -7
- package/modules/kpi.esm.min.js +4 -4
- package/modules/kpi.min.cjs +4 -4
- package/modules/kpi.min.js +4 -4
- package/modules/mock-socket.esm.min.js +2 -2
- package/modules/mock-socket.min.cjs +2 -2
- package/modules/mock-socket.min.js +2 -2
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.esm.min.js +847 -136
- package/modules/webcomponent.min.cjs +847 -136
- package/modules/webcomponent.min.js +847 -136
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
dependencies, no build step required. Optional adapters for React, Vue, Svelte
|
|
5
5
|
and Web Components ship alongside it.
|
|
6
6
|
|
|
7
|
-
Version 1.
|
|
7
|
+
Version 1.40.0 · [latticegrid.dev](https://www.latticegrid.dev) · TOCLOCO Inc
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
package/docs/API.html
CHANGED
|
@@ -6287,6 +6287,38 @@ const rows = stream.map((temp, t) => ({ t, temp }));
|
|
|
6287
6287
|
const signal = condition(rows);
|
|
6288
6288
|
return `methods ${ROLLING_ANOMALY_METHODS.length}; spike ${roll.flags[10]}; alert ${signal ? signal.flagged.length : 0}`;</code></pre>
|
|
6289
6289
|
|
|
6290
|
+
<h3 id="forecasting">Forecasting</h3>
|
|
6291
|
+
<p class="section-note">Project an ordered series forward, and carry a prediction band where a defensible closed form exists (BACKLOG-0000963). Five methods behind one entry point: <code>movingAverage</code> and <code>ses</code> are flat forecasts (the trailing-window mean, the final smoothed level); <code>holt</code> adds a projected trend, <code>holtWinters</code> a projected trend and an additive seasonal; <code>linear</code> extrapolates an ordinary least-squares fit of the time axis. The exponential-smoothing bands are the innovations state-space forecast variances (Hyndman & Athanasopoulos) at the normal quantile; the linear and moving-average bands are the exact Student-t intervals, and <code>linear</code> also reports the narrower mean-response (confidence) band a trendline draws. These are the pure kernels the chart trendline overlay and the time-series grid forecast from; a host can forecast a plain array the same way.</p>
|
|
6292
|
+
<div class="table-wrap">
|
|
6293
|
+
<table>
|
|
6294
|
+
<thead><tr><th>Name</th><th>Signature</th><th>Description</th></tr></thead>
|
|
6295
|
+
<tbody>
|
|
6296
|
+
<tr><td class="name">FORECAST_METHODS</td><td class="type">readonly ('movingAverage' | 'ses' | 'holt' | 'holtWinters' | 'linear')[]</td><td class="desc">The five methods a caller may ask for, named so a result can say which produced it.</td></tr>
|
|
6297
|
+
<tr><td class="name">forecast</td><td class="type">(seq, opts?) => ForecastResult | null</td><td class="desc">Forecast an ordered series <code>opts.horizon</code> steps ahead by <code>opts.method</code> (default <code>linear</code>), at <code>opts.confidence</code> (default 0.95). Accepts a plain array of numbers (index is the time axis) or <code>{at, value}</code> rows. A smoothing factor absent from <code>opts</code> (<code>alpha</code>/<code>beta</code>/<code>gamma</code>) is fit by minimising the in-sample one-step SSE; <code>holtWinters</code> needs <code>opts.period</code> (≥ 2) and two whole periods of data. Each point carries <code>mean</code> and, where a band applies, <code>lower</code>/<code>upper</code>; <code>linear</code> adds <code>lowerMean</code>/<code>upperMean</code>. Null when the series is too short for the method.</td></tr>
|
|
6298
|
+
</tbody>
|
|
6299
|
+
</table>
|
|
6300
|
+
</div>
|
|
6301
|
+
<pre data-run="js" data-expect="methods 5; next 5.8; r2 0.6; band 1.68..9.92; season 63.125" data-covers="export:FORECAST_METHODS export:forecast"><code>const { forecast, FORECAST_METHODS } = await import('../packages/core/src/index.js');
|
|
6302
|
+
// Linear: fit the time axis, project one step, and carry the prediction band.
|
|
6303
|
+
const lin = forecast([{ at: 1, value: 2 }, { at: 2, value: 4 }, { at: 3, value: 5 }, { at: 4, value: 4 }, { at: 5, value: 5 }], { method: 'linear', horizon: 1 });
|
|
6304
|
+
const p = lin.points[0];
|
|
6305
|
+
// Holt-Winters additive: a level, a trend and a two-step season, projected two
|
|
6306
|
+
// steps ahead — the seasonal swing is carried into the forecast, not smoothed away.
|
|
6307
|
+
const hw = forecast([10, 20, 30, 40], { method: 'holtWinters', period: 2, alpha: 0.5, beta: 0.5, gamma: 0.5, horizon: 2 });
|
|
6308
|
+
return `methods ${FORECAST_METHODS.length}; next ${p.mean.toFixed(1)}; r2 ${lin.r2.toFixed(1)}; band ${p.lower.toFixed(2)}..${p.upper.toFixed(2)}; season ${hw.points[1].mean}`;</code></pre>
|
|
6309
|
+
|
|
6310
|
+
<p class="section-note">The same forecast off the standard stats surface: <code>grid.statistics.forecast(colId, opts)</code> reads the column over the filtered rows — ordered by <code>opts.by</code> when the time axis matters, exactly as <code>grid.statistics.series(...)</code> orders — and returns the same <code>ForecastResult</code>, so a host reaches a forecast the way it reaches <code>grid.statistics.anomalies(...)</code> rather than assembling the series itself.</p>
|
|
6311
|
+
<pre data-run="js" data-expect="next 5.8; r2 0.6; band true" data-covers="method:statistics"><code>const { createHeadlessGrid } = await import('../packages/core/src/index.js');
|
|
6312
|
+
const grid = createHeadlessGrid({
|
|
6313
|
+
columns: [{ field: 't', type: 'number' }, { field: 'v', type: 'number' }],
|
|
6314
|
+
rows: [[1, 2], [2, 4], [3, 5], [4, 4], [5, 5]].map(([t, v], i) => ({ id: String(i), t, v })),
|
|
6315
|
+
rowKey: 'id',
|
|
6316
|
+
});
|
|
6317
|
+
// Forecast the 'v' column one step ahead, ordered by 't', with the prediction band.
|
|
6318
|
+
const f = grid.statistics.forecast('v', { by: 't', method: 'linear', horizon: 1 });
|
|
6319
|
+
const p = f.points[0];
|
|
6320
|
+
return `next ${p.mean.toFixed(1)}; r2 ${f.r2.toFixed(1)}; band ${p.upper - p.lower > 0}`;</code></pre>
|
|
6321
|
+
|
|
6290
6322
|
|
|
6291
6323
|
<!-- BEGIN GENERATED TYPE REFERENCE -->
|
|
6292
6324
|
<h2 id="type-reference">Type reference</h2>
|
|
@@ -7828,6 +7860,40 @@ return `methods ${ROLLING_ANOMALY_METHODS.length}; spike ${roll.flags[10]}; aler
|
|
|
7828
7860
|
</tbody>
|
|
7829
7861
|
</table>
|
|
7830
7862
|
</div>
|
|
7863
|
+
<h3 id="type-ForecastPoint">ForecastPoint</h3>
|
|
7864
|
+
<p class="section-note">One forecast step: the point estimate and, where a band applies, its interval.</p>
|
|
7865
|
+
<div class="table-wrap">
|
|
7866
|
+
<table>
|
|
7867
|
+
<thead><tr><th>Member</th><th>Type</th><th>Description</th></tr></thead>
|
|
7868
|
+
<tbody>
|
|
7869
|
+
<tr><td class="name">step</td><td class="type">number</td><td class="desc">The step ahead, `1 … horizon`.</td></tr>
|
|
7870
|
+
<tr><td class="name">at</td><td class="type">number</td><td class="desc">The time-axis position the step is stamped at, extrapolated at the mean spacing.</td></tr>
|
|
7871
|
+
<tr><td class="name">mean</td><td class="type">number</td><td class="desc">The point forecast.</td></tr>
|
|
7872
|
+
<tr><td class="name">lower</td><td class="type">number | null</td><td class="desc">The prediction-interval lower bound (a future observation), or null when none applies.</td></tr>
|
|
7873
|
+
<tr><td class="name">upper</td><td class="type">number | null</td><td class="desc">The prediction-interval upper bound, or null when none applies.</td></tr>
|
|
7874
|
+
<tr><td class="name">lowerMean</td><td class="type">number | null</td><td class="desc">The mean-response (confidence) lower bound — `linear` only, the band a trendline draws. <small>(optional)</small></td></tr>
|
|
7875
|
+
<tr><td class="name">upperMean</td><td class="type">number | null</td><td class="desc">The mean-response (confidence) upper bound — `linear` only. <small>(optional)</small></td></tr>
|
|
7876
|
+
<tr><td class="name">se</td><td class="type">number | null</td><td class="desc">The prediction standard error the band was built from, or null when none applies.</td></tr>
|
|
7877
|
+
</tbody>
|
|
7878
|
+
</table>
|
|
7879
|
+
</div>
|
|
7880
|
+
<h3 id="type-ForecastResult">ForecastResult</h3>
|
|
7881
|
+
<p class="section-note">A forecast: the chosen model, its parameters, and the projected points.</p>
|
|
7882
|
+
<div class="table-wrap">
|
|
7883
|
+
<table>
|
|
7884
|
+
<thead><tr><th>Member</th><th>Type</th><th>Description</th></tr></thead>
|
|
7885
|
+
<tbody>
|
|
7886
|
+
<tr><td class="name">method</td><td class="type">'movingAverage' | 'ses' | 'holt' | 'holtWinters' | 'linear'</td><td class="desc">Which method produced it.</td></tr>
|
|
7887
|
+
<tr><td class="name">horizon</td><td class="type">number</td><td class="desc">How many steps ahead were projected.</td></tr>
|
|
7888
|
+
<tr><td class="name">confidence</td><td class="type">number</td><td class="desc">The band level, e.g. 0.95.</td></tr>
|
|
7889
|
+
<tr><td class="name">n</td><td class="type">number</td><td class="desc">How many finite readings the fit used.</td></tr>
|
|
7890
|
+
<tr><td class="name">sigma</td><td class="type">number | null</td><td class="desc">The residual standard deviation the bands were built from, or null when there was none.</td></tr>
|
|
7891
|
+
<tr><td class="name">r2</td><td class="type">number</td><td class="desc">The fit's coefficient of determination — `linear` only. <small>(optional)</small></td></tr>
|
|
7892
|
+
<tr><td class="name">params</td><td class="type">{</td><td class="desc">The model parameters: `slope`/`intercept` (linear), `alpha`/`beta`/`gamma`/`period`, or `windowLen`.</td></tr>
|
|
7893
|
+
<tr><td class="name">points</td><td class="type">ForecastPoint[]</td><td class="desc">The forecast, one entry per step.</td></tr>
|
|
7894
|
+
</tbody>
|
|
7895
|
+
</table>
|
|
7896
|
+
</div>
|
|
7831
7897
|
<h3 id="type-FormattingApi">FormattingApi</h3>
|
|
7832
7898
|
<div class="table-wrap">
|
|
7833
7899
|
<table>
|
|
@@ -8268,6 +8334,8 @@ return `methods ${ROLLING_ANOMALY_METHODS.length}; spike ${roll.flags[10]}; aler
|
|
|
8268
8334
|
<tbody>
|
|
8269
8335
|
<tr><td class="name">preview</td><td class="type">(text: string, opts?: object): ImportPreview</td><td class="desc">Parse delimited text into a preview, changing nothing.</td></tr>
|
|
8270
8336
|
<tr><td class="name">csv</td><td class="type">(text: string, opts?: object): Record<string, unknown>[]</td><td class="desc">Parse delimited text into coerced records — the inverse of `export.csv`.</td></tr>
|
|
8337
|
+
<tr><td class="name">previewXlsx</td><td class="type">(bytes: Uint8Array | ArrayBuffer, opts?: object): Promise<ImportXlsxPreview></td><td class="desc">Parse an `.xlsx` file's bytes into a preview, changing nothing (§14, BACKLOG-0000970). Async: the archive is inflated with `DecompressionStream`.</td></tr>
|
|
8338
|
+
<tr><td class="name">xlsx</td><td class="type">(bytes: Uint8Array | ArrayBuffer, opts?: object): Promise<Record<string, unknown>[]></td><td class="desc">Parse an `.xlsx` file's bytes into coerced records — the inverse of `export.excel`.</td></tr>
|
|
8271
8339
|
<tr><td class="name">apply</td><td class="type">(</td><td class="desc">Add or replace the grid's rows from text, a preview or records.</td></tr>
|
|
8272
8340
|
</tbody>
|
|
8273
8341
|
</table>
|
|
@@ -8316,6 +8384,22 @@ return `methods ${ROLLING_ANOMALY_METHODS.length}; spike ${roll.flags[10]}; aler
|
|
|
8316
8384
|
</tbody>
|
|
8317
8385
|
</table>
|
|
8318
8386
|
</div>
|
|
8387
|
+
<h3 id="type-ImportXlsxPreview">ImportXlsxPreview</h3>
|
|
8388
|
+
<p class="section-note">What an `.xlsx` preview carries — an {@link ImportPreview} plus the sheet read (§14).</p>
|
|
8389
|
+
<div class="table-wrap">
|
|
8390
|
+
<table>
|
|
8391
|
+
<thead><tr><th>Member</th><th>Type</th><th>Description</th></tr></thead>
|
|
8392
|
+
<tbody>
|
|
8393
|
+
<tr><td class="name">sheet</td><td class="type">string | null</td><td class="desc">The archive path of the worksheet that was read, e.g. `xl/worksheets/sheet1.xml`.</td></tr>
|
|
8394
|
+
<tr><td class="name">header</td><td class="type">string[]</td><td class="desc">The source column headings.</td></tr>
|
|
8395
|
+
<tr><td class="name">columns</td><td class="type">ImportColumn[]</td><td class="desc">The per-column mapping and inference the user may edit before confirming.</td></tr>
|
|
8396
|
+
<tr><td class="name">records</td><td class="type">Record<string, unknown>[]</td><td class="desc">Every mapped, coerced record the import would add.</td></tr>
|
|
8397
|
+
<tr><td class="name">sample</td><td class="type">Record<string, unknown>[]</td><td class="desc">The leading records, for a preview table.</td></tr>
|
|
8398
|
+
<tr><td class="name">rowCount</td><td class="type">number</td><td class="desc">How many data rows the sheet holds.</td></tr>
|
|
8399
|
+
<tr><td class="name">warnings</td><td class="type">string[]</td><td class="desc">Anything worth flagging before confirming.</td></tr>
|
|
8400
|
+
</tbody>
|
|
8401
|
+
</table>
|
|
8402
|
+
</div>
|
|
8319
8403
|
<h3 id="type-IngestConfig">IngestConfig</h3>
|
|
8320
8404
|
<p class="section-note">How rows are ingested into the column store.</p>
|
|
8321
8405
|
<div class="table-wrap">
|
|
@@ -9431,6 +9515,7 @@ return `methods ${ROLLING_ANOMALY_METHODS.length}; spike ${roll.flags[10]}; aler
|
|
|
9431
9515
|
<tr><td class="name">capability</td><td class="type">(colId: string, opts?: {</td><td class="desc">Process capability against the column's `spec`, with control limits and the Western Electric rule breaks. `baseline` fixes the limits over the first N readings, which is how a shift is found rather than hidden by the limits it widened.</td></tr>
|
|
9432
9516
|
<tr><td class="name">interval</td><td class="type">(colId: string, opts?: {</td><td class="desc">A confidence interval for what a column measures, the range the estimate pins the figure down to, not a verdict about it. Reads the rows the filters left, so an interval narrows as the grid does: it describes the filtered population, not the whole table.</td></tr>
|
|
9433
9517
|
<tr><td class="name">series</td><td class="type">(colId: string, opts: { by: string; periodsPerYear?: number }): SeriesStats | null</td><td class="desc">How a column varies along an ordering. `by` is required and never guessed: kernels see rows in the order they arrived, which is not the grid's sort.</td></tr>
|
|
9518
|
+
<tr><td class="name">forecast</td><td class="type">(colId: string, opts?: {</td><td class="desc">Forecast one column forward (BACKLOG-0000963): the stats-surface face of the {@link forecast} kernel. The column is read over the filtered rows in arrival order, or ordered by `opts.by` (a date or numeric column, as {@link series} orders) when the time axis matters, then projected `opts.horizon` steps ahead by `opts.method` (default `linear`) with a prediction band where one applies. Every kernel option passes through; returns the same {@link ForecastResult}, or null when the column is unknown or too short.</td></tr>
|
|
9434
9519
|
<tr><td class="name">weightedAverage</td><td class="type">(colId: string, weightId: string): number | null</td><td class="desc">A weighted average of one column by another.</td></tr>
|
|
9435
9520
|
<tr><td class="name">keyOf</td><td class="type">(data: unknown): string | null</td><td class="desc">The key a row's data resolves to.</td></tr>
|
|
9436
9521
|
<tr><td class="name">maintenance</td><td class="type">Readonly<Record<string, 'maintained' | 'rescan'>></td><td class="desc">Which reductions can be maintained against a change, and which rescan. <small>(read-only)</small></td></tr>
|
package/docs/api-detail.html
CHANGED
|
@@ -437,7 +437,7 @@
|
|
|
437
437
|
<div class="shell">
|
|
438
438
|
<aside class="rail">
|
|
439
439
|
<p class="rail__brand">Lattice Grid</p>
|
|
440
|
-
<p class="rail__sub">Developer guide · v1.
|
|
440
|
+
<p class="rail__sub">Developer guide · v1.40.0</p>
|
|
441
441
|
<nav>
|
|
442
442
|
<div class="rail__group">
|
|
443
443
|
<span class="rail__label">Start here</span>
|
package/lattice-grid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.40.0, type declarations
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
@@ -2774,6 +2774,22 @@ export interface StatisticsApi {
|
|
|
2774
2774
|
* kernels see rows in the order they arrived, which is not the grid's sort.
|
|
2775
2775
|
*/
|
|
2776
2776
|
series(colId: string, opts: { by: string; periodsPerYear?: number }): SeriesStats | null;
|
|
2777
|
+
/**
|
|
2778
|
+
* Forecast one column forward (BACKLOG-0000963): the stats-surface face of the
|
|
2779
|
+
* {@link forecast} kernel. The column is read over the filtered rows in arrival
|
|
2780
|
+
* order, or ordered by `opts.by` (a date or numeric column, as {@link series}
|
|
2781
|
+
* orders) when the time axis matters, then projected `opts.horizon` steps ahead
|
|
2782
|
+
* by `opts.method` (default `linear`) with a prediction band where one applies.
|
|
2783
|
+
* Every kernel option passes through; returns the same {@link ForecastResult},
|
|
2784
|
+
* or null when the column is unknown or too short.
|
|
2785
|
+
*/
|
|
2786
|
+
forecast(colId: string, opts?: {
|
|
2787
|
+
method?: 'movingAverage' | 'ses' | 'holt' | 'holtWinters' | 'linear';
|
|
2788
|
+
horizon?: number; confidence?: number; windowLen?: number;
|
|
2789
|
+
alpha?: number; beta?: number; gamma?: number; period?: number;
|
|
2790
|
+
/** The column to order by before forecasting — a date or numeric axis. */
|
|
2791
|
+
by?: string;
|
|
2792
|
+
}): ForecastResult | null;
|
|
2777
2793
|
/** A weighted average of one column by another. */
|
|
2778
2794
|
weightedAverage(colId: string, weightId: string): number | null;
|
|
2779
2795
|
/** The key a row's data resolves to. */
|
|
@@ -2989,6 +3005,80 @@ export function anomalyCondition(
|
|
|
2989
3005
|
): (rows: Iterable<Record<string, unknown>>) =>
|
|
2990
3006
|
false | { method: string; field: string; flagged: { row: Record<string, unknown>; score: number | null }[] };
|
|
2991
3007
|
|
|
3008
|
+
/**
|
|
3009
|
+
* The forecasting methods a caller may ask for (BACKLOG-0000963), named so a
|
|
3010
|
+
* result says which produced it: a trailing moving average, single / double
|
|
3011
|
+
* (Holt) / triple (Holt-Winters) exponential smoothing, and a linear least-squares
|
|
3012
|
+
* fit of the time axis.
|
|
3013
|
+
*/
|
|
3014
|
+
export const FORECAST_METHODS: readonly ('movingAverage' | 'ses' | 'holt' | 'holtWinters' | 'linear')[];
|
|
3015
|
+
|
|
3016
|
+
/** One forecast step: the point estimate and, where a band applies, its interval. */
|
|
3017
|
+
export interface ForecastPoint {
|
|
3018
|
+
/** The step ahead, `1 … horizon`. */
|
|
3019
|
+
step: number;
|
|
3020
|
+
/** The time-axis position the step is stamped at, extrapolated at the mean spacing. */
|
|
3021
|
+
at: number;
|
|
3022
|
+
/** The point forecast. */
|
|
3023
|
+
mean: number;
|
|
3024
|
+
/** The prediction-interval lower bound (a future observation), or null when none applies. */
|
|
3025
|
+
lower: number | null;
|
|
3026
|
+
/** The prediction-interval upper bound, or null when none applies. */
|
|
3027
|
+
upper: number | null;
|
|
3028
|
+
/** The mean-response (confidence) lower bound — `linear` only, the band a trendline draws. */
|
|
3029
|
+
lowerMean?: number | null;
|
|
3030
|
+
/** The mean-response (confidence) upper bound — `linear` only. */
|
|
3031
|
+
upperMean?: number | null;
|
|
3032
|
+
/** The prediction standard error the band was built from, or null when none applies. */
|
|
3033
|
+
se: number | null;
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
/** A forecast: the chosen model, its parameters, and the projected points. */
|
|
3037
|
+
export interface ForecastResult {
|
|
3038
|
+
/** Which method produced it. */
|
|
3039
|
+
method: 'movingAverage' | 'ses' | 'holt' | 'holtWinters' | 'linear';
|
|
3040
|
+
/** How many steps ahead were projected. */
|
|
3041
|
+
horizon: number;
|
|
3042
|
+
/** The band level, e.g. 0.95. */
|
|
3043
|
+
confidence: number;
|
|
3044
|
+
/** How many finite readings the fit used. */
|
|
3045
|
+
n: number;
|
|
3046
|
+
/** The residual standard deviation the bands were built from, or null when there was none. */
|
|
3047
|
+
sigma: number | null;
|
|
3048
|
+
/** The fit's coefficient of determination — `linear` only. */
|
|
3049
|
+
r2?: number;
|
|
3050
|
+
/** The model parameters: `slope`/`intercept` (linear), `alpha`/`beta`/`gamma`/`period`, or `windowLen`. */
|
|
3051
|
+
params: {
|
|
3052
|
+
slope?: number; intercept?: number;
|
|
3053
|
+
alpha?: number; beta?: number; gamma?: number; period?: number; windowLen?: number;
|
|
3054
|
+
};
|
|
3055
|
+
/** The forecast, one entry per step. */
|
|
3056
|
+
points: ForecastPoint[];
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/**
|
|
3060
|
+
* Forecast an ordered series `horizon` steps into the future (BACKLOG-0000963).
|
|
3061
|
+
*
|
|
3062
|
+
* `movingAverage` and `ses` are flat forecasts (the trailing-window mean, the
|
|
3063
|
+
* final smoothed level); `holt` adds a projected trend, `holtWinters` a projected
|
|
3064
|
+
* trend and an additive seasonal of period `opts.period`; `linear` extrapolates
|
|
3065
|
+
* an ordinary least-squares fit of the time axis. A prediction band is carried
|
|
3066
|
+
* where a defensible closed form exists — the exponential-smoothing bands are the
|
|
3067
|
+
* innovations state-space forecast variances at the normal quantile; the linear
|
|
3068
|
+
* and moving-average bands are the exact Student-t intervals, and `linear` also
|
|
3069
|
+
* reports the narrower mean-response (confidence) band. A smoothing factor absent
|
|
3070
|
+
* from `opts` is fit by minimising the in-sample one-step SSE. Returns null when
|
|
3071
|
+
* the series is too short for the chosen method.
|
|
3072
|
+
*/
|
|
3073
|
+
export function forecast(
|
|
3074
|
+
seq: ArrayLike<number | null> | { at?: number; value: number | null }[],
|
|
3075
|
+
opts?: {
|
|
3076
|
+
method?: 'movingAverage' | 'ses' | 'holt' | 'holtWinters' | 'linear';
|
|
3077
|
+
horizon?: number; confidence?: number; windowLen?: number;
|
|
3078
|
+
alpha?: number; beta?: number; gamma?: number; period?: number;
|
|
3079
|
+
},
|
|
3080
|
+
): ForecastResult | null;
|
|
3081
|
+
|
|
2992
3082
|
export type ShadowKind =
|
|
2993
3083
|
| 'updates' | 'updatedAt' | 'sinceUpdate' | 'delta' | 'deltaPercent'
|
|
2994
3084
|
| 'rate' | 'history' | 'firstValue' | 'streak'
|
|
@@ -4186,12 +4276,37 @@ export interface ImportPreview {
|
|
|
4186
4276
|
warnings: string[];
|
|
4187
4277
|
}
|
|
4188
4278
|
|
|
4279
|
+
/** What an `.xlsx` preview carries — an {@link ImportPreview} plus the sheet read (§14). */
|
|
4280
|
+
export interface ImportXlsxPreview {
|
|
4281
|
+
/** The archive path of the worksheet that was read, e.g. `xl/worksheets/sheet1.xml`. */
|
|
4282
|
+
sheet: string | null;
|
|
4283
|
+
/** The source column headings. */
|
|
4284
|
+
header: string[];
|
|
4285
|
+
/** The per-column mapping and inference the user may edit before confirming. */
|
|
4286
|
+
columns: ImportColumn[];
|
|
4287
|
+
/** Every mapped, coerced record the import would add. */
|
|
4288
|
+
records: Record<string, unknown>[];
|
|
4289
|
+
/** The leading records, for a preview table. */
|
|
4290
|
+
sample: Record<string, unknown>[];
|
|
4291
|
+
/** How many data rows the sheet holds. */
|
|
4292
|
+
rowCount: number;
|
|
4293
|
+
/** Anything worth flagging before confirming. */
|
|
4294
|
+
warnings: string[];
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4189
4297
|
/** Bringing rows in — the mirror of {@link ExportApi} (§14, BACKLOG-0000949). */
|
|
4190
4298
|
export interface ImportApi {
|
|
4191
4299
|
/** Parse delimited text into a preview, changing nothing. */
|
|
4192
4300
|
preview(text: string, opts?: object): ImportPreview;
|
|
4193
4301
|
/** Parse delimited text into coerced records — the inverse of `export.csv`. */
|
|
4194
4302
|
csv(text: string, opts?: object): Record<string, unknown>[];
|
|
4303
|
+
/**
|
|
4304
|
+
* Parse an `.xlsx` file's bytes into a preview, changing nothing (§14,
|
|
4305
|
+
* BACKLOG-0000970). Async: the archive is inflated with `DecompressionStream`.
|
|
4306
|
+
*/
|
|
4307
|
+
previewXlsx(bytes: Uint8Array | ArrayBuffer, opts?: object): Promise<ImportXlsxPreview>;
|
|
4308
|
+
/** Parse an `.xlsx` file's bytes into coerced records — the inverse of `export.excel`. */
|
|
4309
|
+
xlsx(bytes: Uint8Array | ArrayBuffer, opts?: object): Promise<Record<string, unknown>[]>;
|
|
4195
4310
|
/** Add or replace the grid's rows from text, a preview or records. */
|
|
4196
4311
|
apply(
|
|
4197
4312
|
input: string | ImportPreview | Record<string, unknown>[],
|