@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
37 lines • 1.92 kB
TypeScript
type Primitive = 'string' | 'int' | 'bool' | 'time' | 'raw' | 'author' | 'reactions' | 'owner';
/**
* The Go type gh decodes a field into, which is what decides how it prints.
*
* A string prints `""` for null, a number 0 and a bool false; `time` is a
* non-pointer `time.Time`, whose zero is the year-one timestamp; `raw` is a
* pointer (or a nullable time) and stays null. A struct prints every one of
* its fields in its own order, zero-filled where the query asked for fewer
* (a user's `databaseId` is always there, as 0), and prints null only when it
* is a pointer. A list prints null when the answer carried none. Each struct
* field may read a differently spelled key from the answer: an untagged Go
* field prints under its own name.
*
* Three of gh's types marshal themselves. `author` is its `Author`, which
* prints a user as `{id, is_bot, login, name}` and an actor with no id (a
* bot, whose login the query reads without one) as `app/<login>`.
* `reactions` is its `ReactionGroups`, which drops every group nobody
* reacted with and prints `[]` rather than null. `owner` is its `Owner`,
* whose id and name are `omitempty`. `orNull` is a pointer to any of them.
*/
export type Shape = Primitive | {
readonly fields: readonly (readonly [string, Shape, string?])[];
readonly nullable: boolean;
} | {
readonly list: Shape;
} | {
readonly orNull: Shape;
};
export declare const ZERO_TIME = "0001-01-01T00:00:00Z";
export declare function struct(...fields: (readonly [string, Shape, string?])[]): Shape;
export declare function pointer(...fields: (readonly [string, Shape, string?])[]): Shape;
export declare function listOf(shape: Shape): Shape;
export declare function orNull(shape: Shape): Shape;
/** One value as gh prints it once decoded into `shape`. */
export declare function exported(value: unknown, shape: Shape): unknown;
export {};
//# sourceMappingURL=shape.d.ts.map