IF Commons GitHub

logical/records/store

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0002-planning-core FR-011

The files of a store and of a published edition (0037-planning FR-038), in JSON5, which the library encodes and decodes at its boundary with the codec of formats. The store has one file for each event, <item>/<event>.json5, so that two stores merge by the union of their files; the edition has one file for each item that holds its events in the order of fold. Each file has an order of keys that does not change, the order of RFC 8785 section 3.2.3 (by property name, recursively), so that a diff of two stores is a diff of events. Decoding is total: a text that is not an event or an item of the schema is an error value, and an event that breaks a rule of the actors (an agent with no principal, a person that names an agent) is refused when it is read.

import { decodeEvent, encodeEvent, eventPath } from "./store.ts";
// decodeEvent(encodeEvent(event)) is the event, and eventPath(event) is "<item>/<event>.json5"

Source: commons/planning/src/logical/records/store.ts

0 of 26 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

records.EVENT_FILE_SCHEMAconstno test imports it
const EVENT_FILE_SCHEMA: "planning/event@1"

The schema of an event file.

records.ITEM_FILE_SCHEMAconstno test imports it
const ITEM_FILE_SCHEMA: "planning/item@1"

The schema of an item file of the published edition.

records.CodecProblemtypeno test imports it
type CodecProblem = { readonly kind: "codec"; readonly message: string };

Why a text is not an event or an item of the schema.

records.jsonOffunctionno test imports it
function jsonOf(value: unknown): Json

A value as JSON with its properties in the order of their names, recursively, and a property that is undefined left out.

records.eventPathfunctionno test imports it
function eventPath(e: Pick<ItemEvent, "id" | "item">): string

The place of an event's file in a store: the item's folder and the event's name.

records.itemPathfunctionno test imports it
function itemPath(item: ItemId): string

The place of an item's file in a published edition.

records.eventToJsonfunctionno test imports it
function eventToJson(e: ItemEvent): Json

An event as a JSON value: its head, its type and the data of the type, keys in order.

records.encodeEventfunctionno test imports it
function encodeEvent(e: ItemEvent): string

The text of an event's file.

records.encodeItemfunctionno test imports it
function encodeItem(events: readonly ItemEvent[]): Result<string, CodecProblem>

The text of an item's file in a published edition: its events in the order of fold, which is the order of their id.

records.eventDataOfJsonfunctionno test imports it
function eventDataOfJson(type: string, d: JsonObject): Result<EventData, CodecProblem>

The data of an event of a type from its JSON object, or why it is not one.

records.eventOfJsonfunctionno test imports it
function eventOfJson(j: Json | undefined): Result<ItemEvent, CodecProblem>

One event from a JSON value, or why it is not one of the schema.

records.decodeEventfunctionno test imports it
function decodeEvent(source: string): Result<ItemEvent, CodecProblem>

An event from the text of its file, or why it is not one of the schema.

records.decodeItemfunctionno test imports it
function decodeItem(source: string): Result<readonly ItemEvent[], CodecProblem>

The events of an item from the text of its file in a published edition, or why it is not an item of the schema.

EVENT_FILE_SCHEMAconstno test imports it
const EVENT_FILE_SCHEMA: "planning/event@1"

The schema of an event file.

ITEM_FILE_SCHEMAconstno test imports it
const ITEM_FILE_SCHEMA: "planning/item@1"

The schema of an item file of the published edition.

CodecProblemtypeno test imports it
type CodecProblem = { readonly kind: "codec"; readonly message: string };

Why a text is not an event or an item of the schema.

jsonOffunctionno test imports it
function jsonOf(value: unknown): Json

A value as JSON with its properties in the order of their names, recursively, and a property that is undefined left out.

eventPathfunctionno test imports it
function eventPath(e: Pick<ItemEvent, "id" | "item">): string

The place of an event's file in a store: the item's folder and the event's name.

itemPathfunctionno test imports it
function itemPath(item: ItemId): string

The place of an item's file in a published edition.

eventToJsonfunctionno test imports it
function eventToJson(e: ItemEvent): Json

An event as a JSON value: its head, its type and the data of the type, keys in order.

encodeEventfunctionno test imports it
function encodeEvent(e: ItemEvent): string

The text of an event's file.

encodeItemfunctionno test imports it
function encodeItem(events: readonly ItemEvent[]): Result<string, CodecProblem>

The text of an item's file in a published edition: its events in the order of fold, which is the order of their id.

eventDataOfJsonfunctionno test imports it
function eventDataOfJson(type: string, d: JsonObject): Result<EventData, CodecProblem>

The data of an event of a type from its JSON object, or why it is not one.

eventOfJsonfunctionno test imports it
function eventOfJson(j: Json | undefined): Result<ItemEvent, CodecProblem>

One event from a JSON value, or why it is not one of the schema.

decodeEventfunctionno test imports it
function decodeEvent(source: string): Result<ItemEvent, CodecProblem>

An event from the text of its file, or why it is not one of the schema.

decodeItemfunctionno test imports it
function decodeItem(source: string): Result<readonly ItemEvent[], CodecProblem>

The events of an item from the text of its file in a published edition, or why it is not an item of the schema.

Titles, headings, exports, tables, columns and requirements. Esc closes.