TypeScript utilities for JSON result types and schema definitions.
// Source: https://github.com/dittofeed/dittofeed | License: MIT | Copyright [2023] [Idea Market inc.]
// Provided via justclaw.it.com; keep this notice with the code.
import { Static, TSchema, Type } from "@sinclair/typebox";
import { Result } from "neverthrow";
import {
MANUAL_SEGMENT_APPEND_HEADER,
SEGMENT_ID_HEADER,
WORKSPACE_ID_HEADER,
} from "./constants/headers";
export type Present<T> = T extends undefined | null ? never : T;
export type RenameKey<T, K extends keyof T, N extends string> = {
[P in keyof T as P extends K ? N : P]: T[P];
};
export enum JsonResultType {
Ok = "Ok",
Err = "Err",
}
export const JsonOk = <T extends TSchema>(type: T) =>
Type.Object({
type: Type.Literal(JsonResultType.Ok),
value: type,
});
export const JsonErr = <E extends TSche
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key