-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspacetrader.types.ts
77 lines (64 loc) · 2.34 KB
/
spacetrader.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { paths, external } from "./generated/schema.d.ts";
/*
Codegen:
npx openapi-typescript https://raw.githubusercontent.com/SpaceTradersAPI/api-docs/main/reference/SpaceTraders.json --alphabetize --immutable-types -o ./generated/schema.d.ts
Almost works (maybe with https://github.com/drwpow/openapi-typescript/tree/main/packages/openapi-typescript#-node):
deno run https://esm.sh/openapi-typescript/bin/cli.js https://raw.githubusercontent.com/SpaceTradersAPI/api-docs/main/reference/SpaceTraders.json --alphabetize --immutable-types -o ./generated/schema.d.ts
*/
// export interface Agent {
// accountId: string;
// symbol: string;
// headquarters: string; // e.g. "X1-YU85-99640B";
// credits: number;
// startingFaction: string; // should be union of "COSMIC"...;
// }
export type Agent = external["../models/Agent.json"];
// export interface MyAgentResponse {
// data: Agent;
// }
export type MyAgentResponse =
paths["/my/agent"]["get"]["responses"][200]["content"]["application/json"];
// export interface Waypoint {
// chart: any;
// faction: any;
// orbitals: any;
// symbol: string;
// systemSymbol: string;
// traits: any[];
// x: number;
// y: number;
// type: string; // e.g. PLANET should be union
// }
export type Waypoint = external["../models/Waypoint.json"];
// export interface WaypointsResponse {
// data: Waypoint[];
// }
export type WaypointsResponse =
paths["/systems/{systemSymbol}/waypoints"]["get"]["responses"][200]["content"]["application/json"];
export interface ChartItem {
name: string;
x: number;
y: number;
type: Waypoint["type"] & System["type"];
}
export type System = external["../models/System.json"];
export type SystemsResponse =
paths["/systems"]["get"]["responses"][200]["content"]["application/json"];
// Writeable version of WaypointsResponse
export interface UnsafeWaypointsResponse {
data: external["../models/Waypoint.json"][];
meta: external["../models/Meta.json"];
}
// Writeable version of WaypointOrbital
// type Writeable<T> = { -readonly [P in keyof T]: T[P] };
export type UnsafeWaypointOrbital = external["../models/WaypointOrbital.json"];
export interface Planet extends Omit<Waypoint, "type"> {
type: "PLANET";
}
export interface Moon extends Omit<Waypoint, "type"> {
type: "MOON";
}
export interface PlanetWithMoons extends Planet {
type: "PLANET";
moons: Moon[];
}