mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-25 06:26:27 +02:00
refactor: typescript api
This commit is contained in:
parent
234530ed60
commit
996929f053
16 changed files with 341 additions and 321 deletions
|
@ -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];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue