/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The Allocation's decoded payload and its model over the app's own records * (#1372, `Builder Interfaces Spec.md` §6, §9): the pure functions and codecs * compiled once per bin row type, as the Roster's domain is — East decides * which types are the same; the day assembled from the bins' rows and the * own row of the period holding it — the day's, or its week's (#1550) — * drafts in place. The renderer reads and writes the bins * through these, and draws every figure and word from e3-ui's own functions — * it reimplements none. * * @packageDocumentation */ import { SortedMap, type EastType, type EastTypeValue, type ValueTypeOf, type option } from "@elaraai/east"; import { AllocationArrivalType, AllocationCandidateType, AllocationContextType, AllocationFitAskType, AllocationFitResultType, AllocationFitType, AllocationIssueType, AllocationLoadType, AllocationPayloadType, AllocationResourceLineType, AllocationResourceType, AllocationSlotType, ScheduleAllocationRolesType, type AllocationBinType, type AllocationDayType } from "@elaraai/e3-ui/internal"; export { DAY, NARROW_WIDTH, dayStart } from "../shared/schedule/window.js"; /** The decoded payload. */ export type AllocationValue = ValueTypeOf; /** A bin as the board reads it: its roles, and the app's row — opaque here, read through the app's columns, check and forms. */ export type Bin = ValueTypeOf>; /** One day as the board reads it: its period's status, and its bins. */ export type Day = ValueTypeOf>; /** A bin's roles, as the bin kind reads them from its row and writes them into one. */ export type Roles = ValueTypeOf; export type Context = ValueTypeOf; /** What the board books from: an arrival, as the tag reads it from the app's rows. */ export type ArrivalRow = ValueTypeOf; export type ResourceRow = ValueTypeOf; export type Load = ValueTypeOf; export type Issue = ValueTypeOf; export type Slot = ValueTypeOf; /** A resource's line on the day, and its marks. */ export type ResourceLine = ValueTypeOf; /** A fit's question, its answer, one verdict and one candidate. */ export type FitAsk = ValueTypeOf; export type FitResult = ValueTypeOf; export type Fit = ValueTypeOf; export type Candidate = ValueTypeOf; /** A fit's request: the day as drafted and the question. */ export interface FitRequest { day: Date; plan: Day; ask: FitAsk; context: Context; } /** A duration, as the payload holds it. */ export type TimeStep = AllocationValue["every"]; export type AllocationStyles = Record>; /** The viewer's persisted view; the date is an epoch for local storage. */ export interface AllocationView { layout: "timeline" | "table"; date: number; } /** What is selected (A8): a bin, a resource, or a lane slot by its lane and its time. */ export type Selection = { type: "bin"; id: string; } | { type: "resource"; key: string; } | { type: "slot"; lane: string; at: number; }; export declare const dayKey: (value: Date, ctx?: { refs: Map; currentPath: string[]; }) => string; export declare const parseDay: (x: string) => { success: true; value: Date; position: number; } | { success: false; error: string; position: number; }; export declare const compareDate: (x: Date, y: Date) => 1 | 0 | -1; export declare const compareString: (x: string, y: string) => 1 | 0 | -1; export declare const compareFloat: (x: number, y: number) => 1 | 0 | -1; /** The board's codecs and pure functions at one bin row type, compiled once. */ export interface AllocationDomain { /** The app's bin row type. */ rowType: EastType; /** A day's type at the row type. */ dayType: EastType; /** A row as bytes, and back. */ encodeRow: (row: unknown) => Uint8Array; decodeRow: (bytes: Uint8Array) => unknown; /** A day, detached: a command changes its own copy, never what the board read. */ copyDay: (day: Day) => Day; /** Whether two bins are the same: a bin unlike the stored day's is a draft. */ sameBin: (a: Bin, b: Bin) => boolean; /** A bin as the board reads it on a day (B12): its roles beside its row; `none` for a bin of another day. */ binOf: (roles: Roles, row: unknown, day: Date) => option; /** The app's check's input, as bytes. */ encodeCheckContext: (context: { day: Date; plan: Day; context: Context; loads: SortedMap; }) => Uint8Array; /** Every resource's load. */ loads: (day: Date, plan: Day, context: Context) => SortedMap; /** The built-in checks. */ check: (day: Date, plan: Day, context: Context) => Issue[]; /** The day's lane slots. */ slots: (day: Date, plan: Day, context: Context) => Slot[]; /** A question's candidates: what a placement would leave on each resource — a fit's preview, never its verdict. */ candidates: (request: FitRequest) => Candidate[]; /** The fit's request type at the row type: what the app's function takes. */ requestType: EastType; } /** * The domain for a bin kind's row type: built and compiled the first time a * type is seen, then shared — East decides which types are the same. * * @param rowType - The bin kind's `rowType` * @returns Its codecs and compiled pure functions */ export declare function allocationDomain(rowType: EastTypeValue): AllocationDomain; /** The app's check's input over a reference record (#1551): the day's, and the record's rows over it by key. */ export interface AllocationReferenceCheckAsk { day: Date; plan: Day; context: Context; loads: SortedMap; reference: SortedMap; } /** * The app's check's input at the bin row type and a reference record's row * type (#1551), `CheckContext(R, P)`, as bytes: its encoder made the first * time the pair is seen, then shared — East decides which types are the same. * * @param rowType - The bin kind's `rowType` * @param referenceType - The reference record's row type * @returns The input's encoder */ export declare function allocationReferenceCheckEncoder(rowType: EastTypeValue, referenceType: EastTypeValue): (ask: AllocationReferenceCheckAsk) => Uint8Array; export declare function allocationWords(): { quantity: (value: number, unit: string) => string; load: (fill: number, resource: ResourceRow, unit: string) => string; line: (day: Date, resource: ResourceRow, load: Load, unit: string, reserved: string) => ResourceLine; ms: (step: TimeStep) => bigint; }; /** Every arrival and resource, by key, and the board's configuration: what the fit, the checks and the loads read, whatever the narrowing hides. */ export declare function allocationContext(value: AllocationValue): Context; /** A bin's parts — or its roles' — the largest first (ties in key order): its first is the resource the bin is shown on. */ export declare function partsOf(bin: Pick): { key: string; quantity: number; }[]; /** Whether two bins' parts are the same: a link a draft changed. */ export declare const sameParts: (x: Map, y: Map) => boolean; /** The focus (A13): the selected resource, or the selected bin's resource. */ export declare function focusOf(selection: Selection | undefined, plan: Day): string | undefined; /** A day with no row and no bins yet: Not started. */ export declare function emptyDay(): Day; /** Checks the bound configuration, before anything draws. */ export declare function configError(value: AllocationValue): string | undefined; /** One stored bin as the bin kind's `rows` gives it: its roles, its row's bytes, and its row, decoded once. */ export interface StoredBin { readonly roles: Roles; readonly bytes: Uint8Array; readonly row: unknown; } /** A bin's row as a draft holds it: its bytes, its roles and its row. */ export interface DraftedBin { readonly bytes: Uint8Array; readonly roles: Roles; readonly row: unknown; } /** A bin's roles, as the board reads them from it: what the kind writes into its row. */ export declare function rolesOf(bin: Bin): Roles; /** Whether two bins' roles are the same: what a command changed of a bin, and what its row is written with. */ export declare const sameRoles: (a: Bin, b: Bin) => boolean; /** Whether two rows' bytes are the same. */ export declare const sameRowBytes: (a: Uint8Array, b: Uint8Array) => boolean; /** * The day's bins as the record holds them: each stored bin the day's window * read, as the board reads it on the day. * * @param domain - The bin row type's domain * @param stored - The bins the day's window read, by key * @param day - The plan day * @returns The day's bins, by key */ export declare function placeStored(domain: AllocationDomain, stored: ReadonlyMap, day: Date): SortedMap; /** * The day's bins as drafted: the stored ones, each a draft holds in its * draft's place — a draft of any day, placed in this one where its `at` is — * and each one a draft removes gone. * * @param domain - The bin row type's domain * @param stored - The day's bins as the record holds them * @param drafts - Every drafted bin of the session, by key: its row, or `undefined` for one removed * @param day - The plan day * @returns The day's bins as drafted, by key */ export declare function placeDrafted(domain: AllocationDomain, stored: SortedMap, drafts: ReadonlyMap, day: Date): SortedMap; /** The own row of the period holding the day — the day's, or its week's (#1550) — and what it says. */ export interface PlacedPeriod { /** Its row's bytes; `undefined` for a period with no row: Not started. */ readonly bytes: Uint8Array | undefined; /** Its status. */ readonly status: Day["status"]; } /** A period with no row of its own: Not started, a draft. */ export declare const NO_PERIOD: PlacedPeriod; /** Whether a period's row is its own: what a period with no row reads as Not started for. */ export declare function started(period: PlacedPeriod): boolean; /** Whether a period is open to edits by its status: a draft — Not started among them — never the published case or another. */ export declare function editableStatus(status: Day["status"]): boolean; /** A period's status chip's words: Not started, Draft, Published, or the app's own case by its name. */ export declare function statusText(period: PlacedPeriod): string; /** Whether the board publishes a week at a time (#1550): its periods every `"week"`; else a day at a time. */ export declare function byWeek(value: AllocationValue): boolean; /** * The period the board publishes that holds a day (#1550): the day itself * where it publishes a day at a time — or has no periods — else the week * holding it, from the day its week starts on (`week.start`). * * @param value - The payload: its periods, and the day its week starts on * @param day - A day, at UTC midnight * @returns The period's first day — its row's key — and the day after its last */ export declare function periodSpan(value: AllocationValue, day: Date): { readonly from: Date; readonly to: Date; }; //# sourceMappingURL=model.d.ts.map