refactor: typescript api

This commit is contained in:
Endercheif 2023-03-08 17:59:43 -08:00
parent 234530ed60
commit 996929f053
No known key found for this signature in database
GPG key ID: 7767459A0C8BEE00
16 changed files with 341 additions and 321 deletions

View file

@ -1,21 +1,63 @@
export interface Metadata {
language: string;
version: string;
aliases?: string[];
dependencies?: Record<string, string>;
provides: {
language: string;
aliases: string[];
limit_overrides: Limits;
}[];
limit_overrides?: Limits;
}
export type Limit =
| 'compile_timeout'
| 'compile_memory_limit'
| 'max_process_count'
| 'max_open_files'
| 'max_file_size'
| 'output_max_size'
| 'run_memory_limit'
| 'run_timeout';
export type Limits = Record<Limit, number>;
export type LanguageMetadata = {
language: string;
version: string;
};
export type PackageInfo = Metadata & { build_platform: string };
export type File = {
content: string;
name?: string;
encoding?: 'base64' | 'hex' | 'utf8';
};
export interface Body {
export type RequestBody = {
language: string;
version: string;
files: Array<File>;
stdin?: string;
args?: Array<string>;
run_timeout?: number;
compile_timeout?: number;
compile_memory_limit?: number;
run_memory_limit?: number;
} & Partial<Limits>;
export interface ResponseBody {
language: string;
version: string;
run: {
stdout: string;
stderr: string;
output: string;
code: number;
signal?: NodeJS.Signals;
};
}
export type ObjectType<TObject extends Record<any, Record<Key, any>>, Key extends string> = {
export type ObjectType<
TObject extends Record<any, Record<Key, any>>,
Key extends string
> = {
[K in keyof TObject]: TObject[K][Key];
};