untyped
Version:
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] [![bundle][bundle-src]][bundle-href]
42 lines (37 loc) • 1.46 kB
TypeScript
declare type JSValue = string | number | bigint | boolean | symbol | Function | Array<any> | undefined | object | null;
declare type JSType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'function' | 'object' | 'any' | 'array';
declare type ResolveFn = ((value: any, get: (key: string) => any) => JSValue);
interface TypeDescriptor {
type?: JSType | JSType[];
items?: TypeDescriptor | TypeDescriptor[];
}
interface FunctionArg extends TypeDescriptor {
name?: string;
default?: JSValue;
optional?: boolean;
}
interface Schema extends TypeDescriptor {
id?: string;
default?: JSValue;
resolve?: ResolveFn;
properties?: {
[key: string]: Schema;
};
title?: string;
description?: string;
$schema?: string;
tags?: string[];
args?: FunctionArg[];
returns?: TypeDescriptor;
}
interface InputObject {
[key: string]: any;
$schema?: Schema;
$resolve?: ResolveFn;
}
declare type InputValue = InputObject | JSValue;
declare function resolveSchema(obj: InputObject, defaults?: InputObject): Schema;
declare function applyDefaults(ref: InputObject, input: InputObject): InputObject;
declare function generateTypes(schema: Schema, name?: string): string;
declare function generateMarkdown(schema: Schema): string;
export { FunctionArg, InputObject, InputValue, JSType, JSValue, ResolveFn, Schema, TypeDescriptor, applyDefaults, generateMarkdown, generateTypes, resolveSchema };