summaryrefslogtreecommitdiff
path: root/nodejs/model
diff options
context:
space:
mode:
authorJulien Dessaux2024-03-27 15:20:14 +0100
committerJulien Dessaux2024-03-27 15:21:37 +0100
commita1d6b03ec98abbc073b5b73b631da6ea3eae4eb9 (patch)
tree1566c60bf1155e62821d9561ba1cc998b04b8ea5 /nodejs/model
parent[all] fixed erroneous contracts index (diff)
downloadspacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.tar.gz
spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.tar.bz2
spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.zip
[node] finished the great typescript rewrite
Diffstat (limited to '')
-rw-r--r--nodejs/model/api.ts3
-rw-r--r--nodejs/model/common.ts5
-rw-r--r--nodejs/model/errors.ts8
-rw-r--r--nodejs/model/market.ts19
-rw-r--r--nodejs/model/ship.ts8
-rw-r--r--nodejs/model/system.ts30
6 files changed, 70 insertions, 3 deletions
diff --git a/nodejs/model/api.ts b/nodejs/model/api.ts
index 5092157..69c7ee1 100644
--- a/nodejs/model/api.ts
+++ b/nodejs/model/api.ts
@@ -1,8 +1,7 @@
export type APIError = {
- apiError: 'APIError';
error: string;
code: number;
- data: any; // TODO
+ data: unknown;
};
export type Meta = {
diff --git a/nodejs/model/common.ts b/nodejs/model/common.ts
new file mode 100644
index 0000000..1712ad8
--- /dev/null
+++ b/nodejs/model/common.ts
@@ -0,0 +1,5 @@
+export type CommonThing = {
+ description: string;
+ name: string;
+ symbol: string;
+};
diff --git a/nodejs/model/errors.ts b/nodejs/model/errors.ts
new file mode 100644
index 0000000..6002ae6
--- /dev/null
+++ b/nodejs/model/errors.ts
@@ -0,0 +1,8 @@
+export type RateLimitError = {
+ type: string;
+ retryAfter: number;
+ limitBurst: number;
+ limitPerSecond: number;
+ remaining: number;
+ reset: Date;
+};
diff --git a/nodejs/model/market.ts b/nodejs/model/market.ts
new file mode 100644
index 0000000..1ba70c1
--- /dev/null
+++ b/nodejs/model/market.ts
@@ -0,0 +1,19 @@
+import { CommonThing } from 'common.ts';
+
+export type TradeGood = CommonThing & {
+ activity: string;
+ purchasePrice: number;
+ sellPrice: number;
+ supply: string;
+ tradeVolume: number;
+ type: string;
+};
+
+export type Market = {
+ symbol: string;
+ exchange: Array<CommonThing>;
+ exports: Array<CommonThing>;
+ imports: Array<CommonThing>;
+ //transactions: Array<Transaction>;
+ tradeGoods: Array<TradeGood>;
+};
diff --git a/nodejs/model/ship.ts b/nodejs/model/ship.ts
index 9aaf601..bf40767 100644
--- a/nodejs/model/ship.ts
+++ b/nodejs/model/ship.ts
@@ -25,6 +25,12 @@ export type Nav = {
waypointSymbol: string;
};
+export type Registration = {
+ factionSymbol: string;
+ name: string;
+ role: string;
+};
+
export type Route = {
arrival: Date;
departureTime: Date;
@@ -51,6 +57,6 @@ export type Ship = {
// mounts
nav: Nav;
// reactor
- // registration
+ registration: Registration;
symbol: string;
};
diff --git a/nodejs/model/system.ts b/nodejs/model/system.ts
new file mode 100644
index 0000000..b90560f
--- /dev/null
+++ b/nodejs/model/system.ts
@@ -0,0 +1,30 @@
+import { CommonThing } from 'common.ts';
+
+export type Chart = {
+ waypointSymbol: string;
+ submittedBy: string;
+ submittedOn: Date;
+};
+
+export type System = {
+ symbol: string;
+ sectorSymbol: string;
+ type: string;
+ x: number;
+ y: number;
+ waypoints: Array<Waypoint>;
+};
+
+export type Waypoint = {
+ chart: Chart;
+ factions: Array<{symbol: string;}>;
+ isUnderConstruction: boolean;
+ modifiers: Array<CommonThing>;
+ orbitals: Array<{symbol: string;}>;
+ orbits: string;
+ symbol: string;
+ traits: Array<CommonThing>;
+ type: string;
+ x: number;
+ y: number;
+};