Period shapes

@teakit/sheet builds in four fixed-shape period sheets, each with a fixed row length and a fixed key format.

import { Sheet } from "@teakit/sheet";

// Built by Sheet.range(...).fill(value); see the range reference.
Sheet.range("2024", "2024", { by: "quarter" }).fill(0);
// { "2024": [0, 0, 0, 0] }  (QuarterSheet: YYYY -> 4)

Sheet.range("2024-02", "2024-02", { by: "day" }).fill(0)["2024-02"].length;
// 31  (DaySheet: YYYY-MM -> 31; Feb 30/31 are "-")

API Reference

ShapeKeyRow lengthExample key -> row
YearSheet<T>YYYY1"2024" -> [v]
QuarterSheet<T>YYYY4"2024" -> [Q1, Q2, Q3, Q4]
MonthSheet<T>YYYY12"2024" -> [Jan .. Dec]
DaySheet<T>YYYY-MM31"2024-01" -> [D1 .. D31]

DaySheet uses YYYY-MM -> 31 (one month per row), not YYYY -> 366. Non-existent days (e.g. Feb 30) are "-".

Shape detection

rollup and rolldown take no from argument — they detect the input period from key format + row length:

  • YYYY -> 1 → year
  • YYYY -> 4 → quarter
  • YYYY -> 12 → month
  • YYYY-MM -> 31 → day

All rows must match one shape. Mixed or unrecognized shapes raise SHEET_UNRECOGNIZED_PERIOD_SHEET. An ordinary sheet that happens to match a shape is treated as that period — this is intentional.

Agent Contract

FieldValue
Kindconcept
ShapesYearSheet, QuarterSheet, MonthSheet, DaySheet
DaySheet layoutYYYY-MM -> 31
Detectionby key format + row length (no from)

Agent Notes

  • Create period sheets with range; convert between granularities with rollup (finer → coarser) and rolldown (coarser → finer).
  • Do not assume a from option on rollup/rolldown — pass only to.
  • Non-existent days in a DaySheet are always "-", never undefined.