Skip to content

std/kind

std/kind

Import from @norbital-ai/std/kind

std/kind (D7): the one field-kind table. The kind literal a model, an input or a shape declares (structurally, so ui and std need no bolt dependency), its traits, and its Schema: inputSchema(spec) is the one validator of input and stored values (callables, write flatten, IR literals, configuration, feed rows, AI output kinds). A decoded value is JSON with std's Decimal for decimals; its encoding is the wire's (std/wire): { $dec }, ISO dates and instants.

DatePrecision type

type DatePrecision = 'year' | 'month' | 'week' | 'day';

The unit a date is picked in and snapped to, with weeks beginning on Monday.

Source: packages/std/src/kind.ts:12

FieldKind type

type FieldKind = Kind['kind'];

The name of a kind.

Source: packages/std/src/kind.ts:92

Fields type

type Fields = {
    readonly [name: string]: Kind;
};

Named kinds: an object's, an input's or a custom field's fields.

Source: packages/std/src/kind.ts:90

FileRef type

type FileRef = {
    readonly id: string;
    readonly name: string;
    readonly mime: string;
    readonly size?: number;
};

A stored file's handle: id, name, MIME type, and its size when known.

Members

NameTypeDescription
idstring
namestring
mimestring
size?number

Source: packages/std/src/kind.ts:96

FileUrlOptions type

type FileUrlOptions = {
    readonly preview?: 64 | 512 | 1024;
};

A bounded image preview; omit the options to download the original stored file.

Members

NameTypeDescription
preview?64 | 512 | 1024

Source: packages/std/src/kind.ts:103

IdValue const

const IdValue: Schema.String

The canonical ID value, without retaining the field-kind catalogue.

Source: packages/std/src/kind.ts:129

Json type

type Json = null | boolean | number | string | readonly Json[] | {
    readonly [key: string]: Json;
};

A JSON value.

Source: packages/std/src/wire.ts:8

KIND const

const KIND: { readonly number: Entry<"number">; readonly object: Entry<"object">; readonly text: Entry<"text">; readonly int: Entry<"int">; readonly decimal: Entry<"decimal">; readonly money: Entry<"money">; readonly currency: Entry<"currency">; readonly bool: Entry<"bool">; readonly duration: Entry<"duration">; readonly date: Entry<"date">; readonly instant: Entry<"instant">; readonly time: Entry<"time">; readonly period: Entry<"period">; readonly enum: Entry<"enum">; readonly state: Entry<"state">; readonly seq: Entry<"seq">; readonly sum: Entry<"sum">; readonly count: Entry<"count">; readonly json: En…

Every kind: its one-value codec (many, multiple and optional are inputSchema's) and its traits.

Source: packages/std/src/kind.ts:268

Kind type

type Kind = Common & ({
    readonly kind: 'text';
    readonly format?: 'email' | 'phone' | 'url' | 'zone' | 'markdown' | 'cel' | 'team';
    readonly max?: number;
    readonly many?: true;
} | ({
    readonly kind: 'int';
} & Range) | ({
    readonly kind: 'number';
} & Range) | ({
    readonly kind: 'decimal';
    readonly scale: number;
    readonly precision?: number;
} & Range) | {
    readonly kind: 'money';
    readonly currency?: string;
    readonly scale?: number;
} | {
    readonly kind: 'currency';
} | {
    readonly kind: 'bool';
} | {
    readonly kind: 'duration';
} | {
    readonly kind: 'point';
} | {
    readonly kind: 'date';
    readonly precision?: DatePrecision;
} | {
    readonly kind: 'instant';
    readonly precision?: Precision;
} | {
    readonly kind: 'time';
    readonly precision?: TimePrecision;
} | {
    readonly kind: 'period';
    readonly of: 'date';
    readonly precision?: DatePrecision;
} | {
    readonly kind: 'period';
    readonly of: 'instant';
    readonly precision?: Precision;
} | {
    readonly kind: 'enum';
    readonly values: readonly string[];
    readonly many?: true;
} | {
    readonly kind: 'state';
    readonly initial: string;
    readonly states: {
        readonly [state: string]: {
            readonly to?: readonly string[];
            readonly edit?: 'all' | 'none' | readonly string[];
        };
    };
} | {
    readonly kind: 'seq';
    readonly pattern?: string;
    readonly per?: readonly string[];
} | {
    …

A kind literal: every stored and input kind with its options, one arm per kind.

Source: packages/std/src/kind.ts:28

KindCodec type

type KindCodec = Schema.Codec<Value, Json>;

A kind's codec: decodes the wire (or an authored literal) into a Value, encodes back to the wire.

Source: packages/std/src/kind.ts:112

KindOf type

type KindOf<K extends FieldKind> = Extract<Kind, {
    readonly kind: K;
}>;

The literal of one kind.

Source: packages/std/src/kind.ts:94

Point type

type Point = {
    readonly lat: number;
    readonly lng: number;
};

A latitude and longitude in degrees.

Members

NameTypeDescription
latnumber
lngnumber

Source: packages/std/src/kind.ts:105

Precision type

type Precision = DatePrecision | TimePrecision;

Calendar or clock granularity for an instant field, selecting the unit its picker offers and snaps values to.

Source: packages/std/src/kind.ts:16

TimePrecision type

type TimePrecision = 'hour' | 'minute';

The unit a time is picked in and snapped to.

Source: packages/std/src/kind.ts:14

Traits type

type Traits = {
    readonly numeric: boolean;
    readonly ordered: boolean;
    readonly summable: boolean;
    readonly sortable: boolean;
};

What operators and views may do with a kind's values.

Members

NameTypeDescription
numericboolean
orderedboolean
summableboolean
sortableboolean

Source: packages/std/src/kind.ts:114

Value type

type Value = null | boolean | number | string | Decimal | readonly Value[] | {
    readonly [key: string]: Value;
};

A decoded value: JSON, with std's Decimal for a decimal, money or sum value.

Source: packages/std/src/kind.ts:109

Where type

type Where = {
    readonly [key: string]: Json;
};

A where literal as it travels (the IR decoder reads it).

Source: packages/std/src/kind.ts:107

inputSchema function

function inputSchema(spec: Kind): KindCodec

The codec of one kind literal, memoised per spec object: many (text, enum, custom) and multiple (file) are lists of the kind's values, optional admits null. An input's fields decode as inputSchema({ kind: 'object', fields }).

Parameters

NameTypeDescription
specKind

Source: packages/std/src/kind.ts:369