std/kind
std/kind
导入自 @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.
源码: packages/std/src/kind.ts:12
FieldKind type
type FieldKind = Kind['kind']; The name of a kind.
源码: 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.
源码: 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.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
id | string | |
name | string | |
mime | string | |
size? | number |
源码: 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.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
preview? | 64 | 512 | 1024 |
源码: packages/std/src/kind.ts:103
IdValue const
const IdValue: Schema.String The canonical ID value, without retaining the field-kind catalogue.
源码: packages/std/src/kind.ts:129
Json type
type Json = null | boolean | number | string | readonly Json[] | {
readonly [key: string]: Json;
}; A JSON value.
源码: 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.
源码: 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.
源码: 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.
源码: packages/std/src/kind.ts:112
KindOf type
type KindOf<K extends FieldKind> = Extract<Kind, {
readonly kind: K;
}>; The literal of one kind.
源码: packages/std/src/kind.ts:94
Point type
type Point = {
readonly lat: number;
readonly lng: number;
}; A latitude and longitude in degrees.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
lat | number | |
lng | number |
源码: 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.
源码: packages/std/src/kind.ts:16
TimePrecision type
type TimePrecision = 'hour' | 'minute'; The unit a time is picked in and snapped to.
源码: 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.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
numeric | boolean | |
ordered | boolean | |
summable | boolean | |
sortable | boolean |
源码: 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.
源码: 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).
源码: 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 }).
参数
| 名称 | 类型 | 说明 |
|---|---|---|
spec | Kind |