@kayahr/edsm 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +168 -0
  3. package/lib/body.schema.json +587 -0
  4. package/lib/codex.schema.json +55 -0
  5. package/lib/commander-credits-response.schema.json +52 -0
  6. package/lib/commander-inventory-response.schema.json +91 -0
  7. package/lib/commander-position-response.schema.json +101 -0
  8. package/lib/commander-ranks-response.schema.json +138 -0
  9. package/lib/elite-server-status-response.schema.json +38 -0
  10. package/lib/flight-logs-response.schema.json +68 -0
  11. package/lib/main/api/commander.d.ts +96 -0
  12. package/lib/main/api/commander.js +38 -0
  13. package/lib/main/api/commander.js.map +1 -0
  14. package/lib/main/api/common.d.ts +28 -0
  15. package/lib/main/api/common.js +54 -0
  16. package/lib/main/api/common.js.map +1 -0
  17. package/lib/main/api/journal.d.ts +51 -0
  18. package/lib/main/api/journal.js +35 -0
  19. package/lib/main/api/journal.js.map +1 -0
  20. package/lib/main/api/logs.d.ts +130 -0
  21. package/lib/main/api/logs.js +60 -0
  22. package/lib/main/api/logs.js.map +1 -0
  23. package/lib/main/api/status.d.ts +13 -0
  24. package/lib/main/api/status.js +14 -0
  25. package/lib/main/api/status.js.map +1 -0
  26. package/lib/main/api/system.d.ts +279 -0
  27. package/lib/main/api/system.js +125 -0
  28. package/lib/main/api/system.js.map +1 -0
  29. package/lib/main/api/systems.d.ts +148 -0
  30. package/lib/main/api/systems.js +51 -0
  31. package/lib/main/api/systems.js.map +1 -0
  32. package/lib/main/bodies.d.ts +116 -0
  33. package/lib/main/bodies.js +33 -0
  34. package/lib/main/bodies.js.map +1 -0
  35. package/lib/main/codex.d.ts +20 -0
  36. package/lib/main/codex.js +15 -0
  37. package/lib/main/codex.js.map +1 -0
  38. package/lib/main/common.d.ts +14 -0
  39. package/lib/main/common.js +20 -0
  40. package/lib/main/common.js.map +1 -0
  41. package/lib/main/index.d.ts +14 -0
  42. package/lib/main/index.js +19 -0
  43. package/lib/main/index.js.map +1 -0
  44. package/lib/main/powerplay.d.ts +23 -0
  45. package/lib/main/powerplay.js +15 -0
  46. package/lib/main/powerplay.js.map +1 -0
  47. package/lib/main/stations.d.ts +69 -0
  48. package/lib/main/stations.js +15 -0
  49. package/lib/main/stations.js.map +1 -0
  50. package/lib/main/systems.d.ts +61 -0
  51. package/lib/main/systems.js +15 -0
  52. package/lib/main/systems.js.map +1 -0
  53. package/lib/main/util.d.ts +38 -0
  54. package/lib/main/util.js +104 -0
  55. package/lib/main/util.js.map +1 -0
  56. package/lib/powerplay.schema.json +90 -0
  57. package/lib/station-market-response.schema.json +95 -0
  58. package/lib/station-outfitting-response.schema.json +75 -0
  59. package/lib/station-shipyard-response.schema.json +72 -0
  60. package/lib/station.schema.json +315 -0
  61. package/lib/system-bodies-response.schema.json +609 -0
  62. package/lib/system-deaths-response.schema.json +58 -0
  63. package/lib/system-estimated-value-response.schema.json +76 -0
  64. package/lib/system-factions-response.schema.json +313 -0
  65. package/lib/system-response.schema.json +137 -0
  66. package/lib/system-stations-response.schema.json +222 -0
  67. package/lib/system-traffic-response.schema.json +85 -0
  68. package/lib/system.schema.json +1016 -0
  69. package/package.json +82 -0
  70. package/src/main/api/commander.ts +116 -0
  71. package/src/main/api/common.ts +77 -0
  72. package/src/main/api/journal.ts +76 -0
  73. package/src/main/api/logs.ts +166 -0
  74. package/src/main/api/status.ts +24 -0
  75. package/src/main/api/system.ts +361 -0
  76. package/src/main/api/systems.ts +199 -0
  77. package/src/main/bodies.ts +153 -0
  78. package/src/main/codex.ts +31 -0
  79. package/src/main/common.ts +29 -0
  80. package/src/main/index.ts +42 -0
  81. package/src/main/powerplay.ts +34 -0
  82. package/src/main/stations.ts +87 -0
  83. package/src/main/systems.ts +77 -0
  84. package/src/main/util.ts +103 -0
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/package",
3
+ "name": "@kayahr/edsm",
4
+ "version": "1.1.0",
5
+ "type": "module",
6
+ "description": "Typescript types and utility functions for the Elite Dangerous Star Map (EDSM) API",
7
+ "keywords": [
8
+ "elite dangerous",
9
+ "edsm",
10
+ "frontier"
11
+ ],
12
+ "license": "SEE LICENSE IN LICENSE.md",
13
+ "repository": "github:kayahr/edsm",
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "author": {
18
+ "name": "Klaus Reimer",
19
+ "email": "k@ailis.de"
20
+ },
21
+ "funding": "https://github.com/kayahr/edsm?sponsor=1",
22
+ "files": [
23
+ "lib/main/",
24
+ "lib/*.schema.json",
25
+ "src/main/"
26
+ ],
27
+ "exports": "./lib/main/index.js",
28
+ "scripts": {
29
+ "clean": "rm -rf lib",
30
+ "build": "run build:*",
31
+ "build:compile": "tsc",
32
+ "build:schema": "run -p build:schema:*",
33
+ "build:schema:system-bodies-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemBodiesResponse -o lib/system-bodies-response.schema.json",
34
+ "build:schema:system-estimated-value-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemEstimatedValueResponse -o lib/system-estimated-value-response.schema.json",
35
+ "build:schema:system-stations-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemStationsResponse -o lib/system-stations-response.schema.json",
36
+ "build:schema:system-factions-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemFactionsResponse -o lib/system-factions-response.schema.json",
37
+ "build:schema:system-traffic-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemTrafficResponse -o lib/system-traffic-response.schema.json",
38
+ "build:schema:system-deaths-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemDeathsResponse -o lib/system-deaths-response.schema.json",
39
+ "build:schema:system-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t SystemResponse -o lib/system-response.schema.json",
40
+ "build:schema:station-market-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t StationMarketResponse -o lib/station-market-response.schema.json",
41
+ "build:schema:station-shipyard-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t StationShipyardResponse -o lib/station-shipyard-response.schema.json",
42
+ "build:schema:station-outfitting-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t StationOutfittingResponse -o lib/station-outfitting-response.schema.json",
43
+ "build:schema:elite-server-status-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t EliteServerStatusResponse -o lib/elite-server-status-response.schema.json",
44
+ "build:schema:flight-logs-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t FlightLogsResponse -o lib/flight-logs-response.schema.json",
45
+ "build:schema:commander-position-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t CommanderPositionResponse -o lib/commander-position-response.schema.json",
46
+ "build:schema:commander-ranks-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t CommanderRanksResponse -o lib/commander-ranks-response.schema.json",
47
+ "build:schema:commander-credits-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t CommanderCreditsResponse -o lib/commander-credits-response.schema.json",
48
+ "build:schema:commander-inventory-response": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t CommanderInventoryResponse -o lib/commander-inventory-response.schema.json",
49
+ "build:schema:system": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t System -o lib/system.schema.json",
50
+ "build:schema:station": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t Station -o lib/station.schema.json",
51
+ "build:schema:powerplay": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t PowerPlay -o lib/powerplay.schema.json",
52
+ "build:schema:codex": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t Codex -o lib/codex.schema.json",
53
+ "build:schema:body": "ts-json-schema-generator --no-type-check -e all -f tsconfig.json -t Body -o lib/body.schema.json",
54
+ "test": "run test:*",
55
+ "test:unit": "ntest",
56
+ "test:lint": "oxlint --type-aware --deny-warnings",
57
+ "test:apidoc": "typedoc --emit none",
58
+ "test:spell": "cspell --no-progress --no-summary",
59
+ "apidoc": "typedoc",
60
+ "site": "run apidoc site:*",
61
+ "site:clean": "rm -rf lib/site",
62
+ "site:apidoc": "cp -rf lib/apidoc lib/site ",
63
+ "site:schemas": "cp -f 'lib/*.schema.json' lib/site/schemas/",
64
+ "prepare": "run clean build"
65
+ },
66
+ "devDependencies": {
67
+ "@kayahr/assert": "1.3.2",
68
+ "@kayahr/cspell": "9.2.2-bundle.1",
69
+ "@kayahr/npm-utils": "1.1.1",
70
+ "@kayahr/ntest": "1.3.0",
71
+ "@kayahr/oxlint-config": "1.11.0",
72
+ "@kayahr/ts-json-schema-generator": "2.4.0-bundle.1",
73
+ "@kayahr/typedoc": "0.28.14-bundle.2",
74
+ "@types/node": "24.10.0",
75
+ "ajv": "8.17.1",
76
+ "fetch-mock": "12.6.0",
77
+ "typescript": "5.9.3"
78
+ },
79
+ "dependencies": {
80
+ "json-with-bigint": "^3.4.4"
81
+ }
82
+ }
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+
6
+ import { request } from "./common.ts";
7
+
8
+ /**
9
+ * Commander ranks response returned by {@link getCommanderRanks} request.
10
+ */
11
+ export interface CommanderRanksResponse {
12
+ ranks: {
13
+ Combat: number;
14
+ Trade: number;
15
+ Explore: number;
16
+ Soldier: number;
17
+ Exobiologist: number;
18
+ CQC: number;
19
+ Federation: number;
20
+ Empire: number;
21
+ };
22
+ progress: {
23
+ Combat: number;
24
+ Trade: number;
25
+ Explore: number;
26
+ Soldier: number;
27
+ Exobiologist: number;
28
+ CQC: number;
29
+ Federation: number;
30
+ Empire: number;
31
+ };
32
+ ranksVerbose: {
33
+ Combat: string;
34
+ Trade: string;
35
+ Explore: string;
36
+ Soldier: string;
37
+ Exobiologist: string;
38
+ CQC: string;
39
+ Federation: string;
40
+ Empire: string;
41
+ };
42
+ }
43
+
44
+ /** Credits period type */
45
+ export type CreditsPeriod = "7DAY" | "1MONTH" | "3MONTH" | "6MONTH";
46
+
47
+ /**
48
+ * Commander credits response returned by {@link getCommanderCredits} request.
49
+ */
50
+ export interface CommanderCreditsResponse {
51
+ credits: Array<{
52
+ balance: number;
53
+ loan: number;
54
+ date: string;
55
+ }>;
56
+ period?: CreditsPeriod;
57
+ }
58
+
59
+ /** Inventory type */
60
+ export type InventoryType = "materials" | "data" | "cargo";
61
+
62
+ /**
63
+ * Commander inventory response returned by {@link getCommanderInventory} request.
64
+ */
65
+ export interface CommanderInventoryResponse {
66
+ materials?: Array<{
67
+ type: string | number;
68
+ name: string;
69
+ qty: number;
70
+ }>;
71
+ data?: Array<{
72
+ type: string | number;
73
+ name: string;
74
+ qty: number;
75
+ }>;
76
+ cargo?: Array<{
77
+ type: string | null;
78
+ name: string;
79
+ qty: number;
80
+ }>;
81
+ }
82
+
83
+ /**
84
+ * Returns commander ranks.
85
+ *
86
+ * @param commanderName - The name of the commander as registered on EDSM.
87
+ * @param apiKey - The API key of the commander. If not provided, ranks will only be returned if the commander
88
+ * has enabled his public profile.
89
+ * @returns The commander ranks.
90
+ */
91
+ export async function getCommanderRanks(commanderName: string, apiKey?: string): Promise<CommanderRanksResponse> {
92
+ return (await request<CommanderRanksResponse>("api-commander-v1/get-ranks", { commanderName, apiKey }))!;
93
+ }
94
+
95
+ /**
96
+ * Returns commander credits.
97
+ *
98
+ * @param commanderName - The name of the commander as registered on EDSM.
99
+ * @param apiKey - The API key of the commander.
100
+ * @returns The commander credits.
101
+ */
102
+ export async function getCommanderCredits(commanderName: string, apiKey: string, period?: CreditsPeriod): Promise<CommanderCreditsResponse> {
103
+ return (await request("api-commander-v1/get-credits", { commanderName, apiKey, period }))!;
104
+ }
105
+
106
+ /**
107
+ * Returns commander inventory.
108
+ *
109
+ * @param commanderName - The name of the commander as registered on EDSM.
110
+ * @param apiKey - The API key of the commander.
111
+ * @param type - The inventory type. Defaults to "materials".
112
+ * @returns The commander inventory.
113
+ */
114
+ export async function getCommanderInventory(commanderName: string, apiKey: string, type?: InventoryType): Promise<CommanderInventoryResponse> {
115
+ return (await request("api-commander-v1/get-materials", { commanderName, apiKey, type }))!;
116
+ }
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+
6
+ import { JSONStringify } from "json-with-bigint";
7
+
8
+ import type { Id64 } from "../common.ts";
9
+ import { EDSMException, jsonReviver } from "../util.ts";
10
+
11
+ export const edsmBaseUrl = "https://www.edsm.net";
12
+
13
+ /**
14
+ * Request options for referencing a system via EDSM or Frontier ID instead of name. Needed when system name is not unique.
15
+ */
16
+ export interface SystemIdRequestOptions {
17
+ /** The system ID if you seek for a duplicate system and want to force a specific ID. */
18
+ systemId?: number;
19
+
20
+ /** The system ID64 if you seek for a duplicate system and want to force a specific ID. */
21
+ systemId64?: Id64;
22
+ }
23
+
24
+ export class ServerException extends EDSMException {
25
+ public readonly status: number;
26
+
27
+ public constructor(status: number, message: string) {
28
+ super(message);
29
+ this.status = status;
30
+ }
31
+ }
32
+
33
+ export class APIException extends EDSMException {
34
+ public readonly status: number;
35
+
36
+ public constructor(status: number, message: string) {
37
+ super(message);
38
+ this.status = status;
39
+ }
40
+ }
41
+
42
+ interface MessageResult {
43
+ msgnum?: number;
44
+ msg?: string;
45
+ }
46
+
47
+ /**
48
+ * Sends JSON request to the given URL with the given parameters and returns the response.
49
+ *
50
+ * @param params - Optional parameters.
51
+ * @returns The JSON result. Null when result was an empty object which for EDSM means "not found".
52
+ * @throws APIException - When request failed for some unknown reason.
53
+ */
54
+ export async function request<T>(url: string, params: Record<string, unknown> = {}): Promise<T | null> {
55
+ const result = await fetch(`${edsmBaseUrl}/${url}`, {
56
+ method: "POST",
57
+ headers: { "Content-Type": "application/json" },
58
+ body: JSONStringify(params)
59
+ });
60
+ if (result.status !== 200) {
61
+ throw new ServerException(result.status, result.statusText);
62
+ }
63
+ const text = await result.text();
64
+ const json = JSON.parse(text, jsonReviver) as T & MessageResult;
65
+ if (json.msgnum != null && json.msg != null) {
66
+ if (json.msgnum < 100 || json.msgnum >= 200) {
67
+ throw new APIException(json.msgnum, json.msg);
68
+ } else {
69
+ delete json.msgnum;
70
+ delete json.msg;
71
+ }
72
+ }
73
+ if (Object.keys(json).length === 0) {
74
+ return null;
75
+ }
76
+ return json;
77
+ }
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright (C) 2025 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+
6
+ import type { Coordinates, Id64 } from "../common.ts";
7
+ import { request } from "./common.ts";
8
+
9
+ /**
10
+ * Response of a {@link sendEvents} request.
11
+ */
12
+ export interface EventResponse {
13
+ /** Responses for each sent event. */
14
+ events: Array<{
15
+ /**
16
+ * 100 means the event was accepted. Every other code means the event was rejected for some reason.
17
+ * See https://www.edsm.net/en/api-journal-v1 for details.
18
+ */
19
+ msgnum: number;
20
+
21
+ /** Response code in text form. */
22
+ msg: string;
23
+
24
+ /** True if new system was created, false if not. */
25
+ systemCreated?: boolean;
26
+
27
+ /** EDSM system ID. */
28
+ systemId?: number;
29
+ }>;
30
+ }
31
+
32
+ /**
33
+ * Base data for EDSM event to be sent to EDSM. This must be the unmodified event read from the Journal, optionally enriched with additional
34
+ * context information.
35
+ */
36
+ export interface EDSMEvent {
37
+ _systemAddress?: Id64;
38
+ _systemName?: string;
39
+ _systemCoordinates?: Coordinates;
40
+ _marketId?: number;
41
+ _stationName?: string;
42
+ _shipId?: number;
43
+ event: string;
44
+ }
45
+
46
+ /**
47
+ * Sends journal events to EDSM.
48
+ *
49
+ * @param commanderName - The name of the commander as registered on EDSM.
50
+ * @param apiKey - The API Key associated with the EDSM account.
51
+ * @param fromSoftware - Name of the software (YOUR software using this library, not the name of this library!) used to submit the data.
52
+ * @param fromSoftwareVersion - Version of the software used to submit the data.
53
+ * @param fromGameVersion - Version of the game which generated the journal messages.
54
+ * @param fromGameBuild - Build of the game which generated the journal messages.
55
+ * @param message - The journal event (or multiple events to send).
56
+ */
57
+ export async function sendEvents(commanderName: string, apiKey: string, fromSoftware: string, fromSoftwareVersion: string, fromGameVersion: string,
58
+ fromGameBuild: string, message: EDSMEvent | EDSMEvent[]): Promise<EventResponse> {
59
+ return (await request("api-journal-v1", {
60
+ apiKey,
61
+ fromSoftware,
62
+ fromSoftwareVersion,
63
+ fromGameVersion,
64
+ fromGameBuild,
65
+ message
66
+ }))!;
67
+ }
68
+
69
+ /**
70
+ * Returns the events which must be discarded from the list of journal events sent to EDSM.
71
+ *
72
+ * @returns The list of event names to be discarded.
73
+ */
74
+ export async function getDiscardEvents(): Promise<string[]> {
75
+ return (await request("api-journal-v1/discard"))!;
76
+ }
@@ -0,0 +1,166 @@
1
+ /*
2
+ * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+
6
+ import type { Coordinates, Id64 } from "../common.ts";
7
+ import { type SystemIdRequestOptions, request } from "./common.ts";
8
+
9
+ export interface FlightLog {
10
+ shipId: number | null;
11
+ system: string;
12
+ systemId?: number;
13
+ systemId64?: Id64;
14
+ firstDiscover: boolean;
15
+ date: string;
16
+ }
17
+
18
+ export interface FlightLogsResponse {
19
+ startDateTime: string;
20
+ endDateTime: string;
21
+ logs: FlightLog[];
22
+ }
23
+
24
+ export interface FlightLogFilter {
25
+ /** Filters flight logs by system name. */
26
+ systemName?: string;
27
+
28
+ /**
29
+ * Filters for flight logs after this date & time (inclusive). Must be specified in UTC in the format
30
+ * YYYY-MM-DD HH:MM:SS.
31
+ */
32
+ startDateTime?: string;
33
+
34
+ /**
35
+ * Filters for flight logs before this date & time (inclusive). Must be specified in UTC in the format
36
+ * YYYY-MM-DD HH:MM:SS.
37
+ */
38
+ endDateTime?: string;
39
+
40
+ /** Set to 1 if you want to get the EDSM internal id. Useful to handle duplicated name systems of the game. */
41
+ showId?: number;
42
+ }
43
+
44
+ /**
45
+ * Returns the flight log entries.
46
+ *
47
+ * @param commanderName - The name of the commander as registered on EDSM.
48
+ * @param apiKey - The API key of the commander.
49
+ * @param filter - Optional filter properties.
50
+ * @returns The flight log entries.
51
+ */
52
+ export async function getFlightLogs(commanderName: string, apiKey: string, filter?: FlightLogFilter): Promise<FlightLogsResponse> {
53
+ return (await request("api-logs-v1/get-logs", { commanderName, apiKey, ...filter }))!;
54
+ }
55
+
56
+ /**
57
+ * Commander position response returned by {@link getCommanderPosition} request.
58
+ */
59
+ export interface CommanderPositionResponse {
60
+ system: string | null;
61
+ systemId?: number;
62
+ systemId64?: Id64;
63
+ firstDiscover: boolean | null;
64
+ date: string | null;
65
+ coordinates?: Coordinates;
66
+ isDocked?: boolean;
67
+ station?: string;
68
+ stationId?: number;
69
+ dateDocked?: string;
70
+ shipId?: number;
71
+ shipType?: string;
72
+ shipFuel?: number | null;
73
+ dateLastActivity?: string;
74
+ url?: string;
75
+ }
76
+
77
+ export interface CommanderPositionOptions {
78
+ /**
79
+ * If not provided, information will only be returned if the commander has enabled his public profile, and share
80
+ * logs or map.
81
+ */
82
+ apiKey?: string;
83
+
84
+ /** Set to 1 if you want to get the EDSM internal id. Useful to handle duplicated name systems of the game. */
85
+ showId?: number;
86
+
87
+ /** Set to 1 if you want to get the coordinates of the system. */
88
+ showCoordinates?: number;
89
+ }
90
+
91
+ /**
92
+ * Returns the last position of the given commander.
93
+ *
94
+ * @param commanderName - The name of the commander as registered on EDSM.
95
+ * @param options - Options.
96
+ * @returns The last position.
97
+ */
98
+ export async function getCommanderPosition(commanderName: string, options?: CommanderPositionOptions): Promise<CommanderPositionResponse> {
99
+ return (await request("api-logs-v1/get-position", { commanderName, ...options }))!;
100
+ }
101
+
102
+ /** Response type of {@link setSystemComment} */
103
+ export interface SystemCommentResponse {
104
+ comment: string | null;
105
+ lastUpdate: string | null;
106
+ }
107
+
108
+ /**
109
+ * Sets/Updates a comment.
110
+ *
111
+ * @param commanderName - The name of the commander as registered on EDSM.
112
+ * @param apiKey - The API key associated with the commander.
113
+ * @param systemName - The system name for which to set a comment.
114
+ * @param comment - The comment to set. Empty string to remove.
115
+ * @param options - Additional options.
116
+ */
117
+ export async function setSystemComment(commanderName: string, apiKey: string, systemName: string, comment: string, options?: SystemIdRequestOptions):
118
+ Promise<SystemCommentResponse> {
119
+ return (await request("api-logs-v1/set-comment", { commanderName, apiKey, systemName, comment, ...options }))!;
120
+ }
121
+
122
+ /**
123
+ * Returns a system comment.
124
+ *
125
+ * @param commanderName - The name of the commander as registered on EDSM.
126
+ * @param apiKey - The API key associated with the commander.
127
+ * @param systemName - The system name for which to return the comment.
128
+ * @param options - Additional options.
129
+ */
130
+ export async function getSystemComment(commanderName: string, apiKey: string, systemName: string, options?: SystemIdRequestOptions):
131
+ Promise<SystemCommentResponse> {
132
+ return (await request("api-logs-v1/get-comment", { commanderName, apiKey, systemName, ...options }))!;
133
+ }
134
+
135
+ /** Response of a {@link getSystemComments} request. */
136
+ export interface SystemCommentsResponse {
137
+ comments: Array<{
138
+ system: string;
139
+ systemId?: number;
140
+ comment: string;
141
+ lastUpdate: string;
142
+ }>;
143
+ }
144
+
145
+ /** Options for {@link getSystemComments} request. */
146
+ export interface SystemCommentsOptions {
147
+ /**
148
+ * If you only want to receive comments updated after a specific date & time, use this parameter.
149
+ * That parameter is inclusive. All dates must be UTC.
150
+ */
151
+ startDateTime?: string;
152
+
153
+ /** Set to 1 if you want to get the EDSM internal id. Useful to handle duplicated name systems of the game. */
154
+ showId?: number;
155
+ }
156
+
157
+ /**
158
+ * Returns comments set for various systems.
159
+ *
160
+ * @param commanderName - The name of the commander as registered on EDSM.
161
+ * @param apiKey - The API key associated with the commander.
162
+ * @param options - Additional options.
163
+ */
164
+ export async function getSystemComments(commanderName: string, apiKey: string, options?: SystemCommentsOptions): Promise<SystemCommentsResponse> {
165
+ return (await request("api-logs-v1/get-comments", { commanderName, apiKey, ...options }))!;
166
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+
6
+ import { request } from "./common.ts";
7
+
8
+ export type EliteServerStatusType = "success" | "warning" | "danger";
9
+
10
+ export interface EliteServerStatusResponse {
11
+ lastUpdate: string;
12
+ type: EliteServerStatusType;
13
+ message: string;
14
+ status: number;
15
+ }
16
+
17
+ /**
18
+ * Returns the elite server status.
19
+ *
20
+ * @returns The elite server status.
21
+ */
22
+ export async function getEliteServerStatus(): Promise<EliteServerStatusResponse> {
23
+ return (await request("api-status-v1/elite-server"))!;
24
+ }