From 234770b611df32178382b557df396db220070a7f Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 5 Apr 2024 00:42:30 +0200 Subject: [node] Big Ships lib refactoring --- nodejs/model/agent.ts | 8 ------- nodejs/model/api.ts | 31 ------------------------ nodejs/model/cargo.ts | 17 ------------- nodejs/model/common.ts | 5 ---- nodejs/model/contract.ts | 22 ----------------- nodejs/model/errors.ts | 8 ------- nodejs/model/market.ts | 19 --------------- nodejs/model/ship.ts | 62 ------------------------------------------------ nodejs/model/system.ts | 30 ----------------------- 9 files changed, 202 deletions(-) delete mode 100644 nodejs/model/agent.ts delete mode 100644 nodejs/model/api.ts delete mode 100644 nodejs/model/cargo.ts delete mode 100644 nodejs/model/common.ts delete mode 100644 nodejs/model/contract.ts delete mode 100644 nodejs/model/errors.ts delete mode 100644 nodejs/model/market.ts delete mode 100644 nodejs/model/ship.ts delete mode 100644 nodejs/model/system.ts (limited to 'nodejs/model') diff --git a/nodejs/model/agent.ts b/nodejs/model/agent.ts deleted file mode 100644 index dce6424..0000000 --- a/nodejs/model/agent.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type Agent = { - accountId: string; - credits: number; - headquarters: string; - shipCount: number; - startingFaction: string; - symbol: string; -}; diff --git a/nodejs/model/api.ts b/nodejs/model/api.ts deleted file mode 100644 index 69c7ee1..0000000 --- a/nodejs/model/api.ts +++ /dev/null @@ -1,31 +0,0 @@ -export type APIError = { - error: string; - code: number; - data: unknown; -}; - -export type Meta = { - limit: number; - page: number; - total: number; -} - -export type Request = { - endpoint: string; // the path part of the url to call - method?: string; // HTTP method for `fetch` call, defaults to 'GET' - page?: number; // run a paginated request starting from this page until all the following pages are fetched - payload?: { [key:string]: any}; // optional json object that will be sent along the request - priority?: number; // optional priority value, defaults to 10. lower than 10 means the message will be sent faster -}; - -export type RequestPromise = { - reject: (reason?: any) => void; - request: Request; - resolve: (value: Response | PromiseLike>) => void; -}; - -export type Response = { - data: T; - error?: APIError; - meta?: Meta; -} diff --git a/nodejs/model/cargo.ts b/nodejs/model/cargo.ts deleted file mode 100644 index 869fa49..0000000 --- a/nodejs/model/cargo.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type Inventory = { - description: string; - name: string; - symbol: string; - units: number; -}; - -export type Cargo = { - "capacity": number; - "units": number; - "inventory": Array; -}; - -// Custom type, not from space traders api -export type CargoManifest = { - [key: string]: number; -}; diff --git a/nodejs/model/common.ts b/nodejs/model/common.ts deleted file mode 100644 index 1712ad8..0000000 --- a/nodejs/model/common.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type CommonThing = { - description: string; - name: string; - symbol: string; -}; diff --git a/nodejs/model/contract.ts b/nodejs/model/contract.ts deleted file mode 100644 index eb7add4..0000000 --- a/nodejs/model/contract.ts +++ /dev/null @@ -1,22 +0,0 @@ -export type Contract = { - id: string; - factionSymbol: string; - type: string; - terms: { - deadline: Date; - payment: { - onAccepted: number; - onFulfilled: number; - }, - deliver: Array<{ - tradeSymbol: string; - destinationSymbol: string; - unitsRequired: number; - unitsFulfilled: number; - }>; - }; - accepted: boolean; - fulfilled: boolean; - expiration: Date; - deadlineToAccept: Date; -}; diff --git a/nodejs/model/errors.ts b/nodejs/model/errors.ts deleted file mode 100644 index 6002ae6..0000000 --- a/nodejs/model/errors.ts +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index 1ba70c1..0000000 --- a/nodejs/model/market.ts +++ /dev/null @@ -1,19 +0,0 @@ -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; - exports: Array; - imports: Array; - //transactions: Array; - tradeGoods: Array; -}; diff --git a/nodejs/model/ship.ts b/nodejs/model/ship.ts deleted file mode 100644 index bf40767..0000000 --- a/nodejs/model/ship.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Cargo } from './cargo.ts'; - -export type Cooldown = { - shipSymbol: string; - totalSeconds: number; - remainingSeconds: number; -}; - -export type Consummed = { - amount: number; - timestamp: Date; -}; - -export type Fuel = { - capacity: number; - consummed: Consummed; - current: number; -}; - -export type Nav = { - flightMode: string; - route: Route; - status: string; - systemSymbol: string; - waypointSymbol: string; -}; - -export type Registration = { - factionSymbol: string; - name: string; - role: string; -}; - -export type Route = { - arrival: Date; - departureTime: Date; - destination: RouteEndpoint; - origin: RouteEndpoint; -}; - -export type RouteEndpoint = { - type: string; - symbol: string; - systemSymbol: string; - x: number; - y: number; -}; - -export type Ship = { - cargo: Cargo; - cooldown: Cooldown; - // crew - // engine - // frame - fuel: Fuel; - // modules - // mounts - nav: Nav; - // reactor - registration: Registration; - symbol: string; -}; diff --git a/nodejs/model/system.ts b/nodejs/model/system.ts deleted file mode 100644 index b90560f..0000000 --- a/nodejs/model/system.ts +++ /dev/null @@ -1,30 +0,0 @@ -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; -}; - -export type Waypoint = { - chart: Chart; - factions: Array<{symbol: string;}>; - isUnderConstruction: boolean; - modifiers: Array; - orbitals: Array<{symbol: string;}>; - orbits: string; - symbol: string; - traits: Array; - type: string; - x: number; - y: number; -}; -- cgit v1.2.3