@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
@@ -0,0 +1,91 @@
1
+ {
2
+ "$ref": "#/definitions/CommanderInventoryResponse",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "CommanderInventoryResponse": {
6
+ "additionalProperties": false,
7
+ "description": "Commander inventory response returned by {@link getCommanderInventory } request.",
8
+ "properties": {
9
+ "cargo": {
10
+ "items": {
11
+ "additionalProperties": false,
12
+ "properties": {
13
+ "name": {
14
+ "type": "string"
15
+ },
16
+ "qty": {
17
+ "type": "number"
18
+ },
19
+ "type": {
20
+ "type": [
21
+ "string",
22
+ "null"
23
+ ]
24
+ }
25
+ },
26
+ "required": [
27
+ "type",
28
+ "name",
29
+ "qty"
30
+ ],
31
+ "type": "object"
32
+ },
33
+ "type": "array"
34
+ },
35
+ "data": {
36
+ "items": {
37
+ "additionalProperties": false,
38
+ "properties": {
39
+ "name": {
40
+ "type": "string"
41
+ },
42
+ "qty": {
43
+ "type": "number"
44
+ },
45
+ "type": {
46
+ "type": [
47
+ "string",
48
+ "number"
49
+ ]
50
+ }
51
+ },
52
+ "required": [
53
+ "type",
54
+ "name",
55
+ "qty"
56
+ ],
57
+ "type": "object"
58
+ },
59
+ "type": "array"
60
+ },
61
+ "materials": {
62
+ "items": {
63
+ "additionalProperties": false,
64
+ "properties": {
65
+ "name": {
66
+ "type": "string"
67
+ },
68
+ "qty": {
69
+ "type": "number"
70
+ },
71
+ "type": {
72
+ "type": [
73
+ "string",
74
+ "number"
75
+ ]
76
+ }
77
+ },
78
+ "required": [
79
+ "type",
80
+ "name",
81
+ "qty"
82
+ ],
83
+ "type": "object"
84
+ },
85
+ "type": "array"
86
+ }
87
+ },
88
+ "type": "object"
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "$ref": "#/definitions/CommanderPositionResponse",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "CommanderPositionResponse": {
6
+ "additionalProperties": false,
7
+ "description": "Commander position response returned by {@link getCommanderPosition } request.",
8
+ "properties": {
9
+ "coordinates": {
10
+ "$ref": "#/definitions/Coordinates"
11
+ },
12
+ "date": {
13
+ "type": [
14
+ "string",
15
+ "null"
16
+ ]
17
+ },
18
+ "dateDocked": {
19
+ "type": "string"
20
+ },
21
+ "dateLastActivity": {
22
+ "type": "string"
23
+ },
24
+ "firstDiscover": {
25
+ "type": [
26
+ "boolean",
27
+ "null"
28
+ ]
29
+ },
30
+ "isDocked": {
31
+ "type": "boolean"
32
+ },
33
+ "shipFuel": {
34
+ "type": [
35
+ "number",
36
+ "null"
37
+ ]
38
+ },
39
+ "shipId": {
40
+ "type": "number"
41
+ },
42
+ "shipType": {
43
+ "type": "string"
44
+ },
45
+ "station": {
46
+ "type": "string"
47
+ },
48
+ "stationId": {
49
+ "type": "number"
50
+ },
51
+ "system": {
52
+ "type": [
53
+ "string",
54
+ "null"
55
+ ]
56
+ },
57
+ "systemId": {
58
+ "type": "number"
59
+ },
60
+ "systemId64": {
61
+ "$ref": "#/definitions/Id64"
62
+ },
63
+ "url": {
64
+ "type": "string"
65
+ }
66
+ },
67
+ "required": [
68
+ "system",
69
+ "firstDiscover",
70
+ "date"
71
+ ],
72
+ "type": "object"
73
+ },
74
+ "Coordinates": {
75
+ "additionalProperties": false,
76
+ "properties": {
77
+ "x": {
78
+ "type": "number"
79
+ },
80
+ "y": {
81
+ "type": "number"
82
+ },
83
+ "z": {
84
+ "type": "number"
85
+ }
86
+ },
87
+ "required": [
88
+ "x",
89
+ "y",
90
+ "z"
91
+ ],
92
+ "type": "object"
93
+ },
94
+ "Id64": {
95
+ "description": "A 64 bit ID. Can be a `number` if ID does not need more then 53 bit. Must be `bigint` if ID needs more than 53 bit.",
96
+ "type": [
97
+ "number"
98
+ ]
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,138 @@
1
+ {
2
+ "$ref": "#/definitions/CommanderRanksResponse",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "CommanderRanksResponse": {
6
+ "additionalProperties": false,
7
+ "description": "Commander ranks response returned by {@link getCommanderRanks } request.",
8
+ "properties": {
9
+ "progress": {
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "CQC": {
13
+ "type": "number"
14
+ },
15
+ "Combat": {
16
+ "type": "number"
17
+ },
18
+ "Empire": {
19
+ "type": "number"
20
+ },
21
+ "Exobiologist": {
22
+ "type": "number"
23
+ },
24
+ "Explore": {
25
+ "type": "number"
26
+ },
27
+ "Federation": {
28
+ "type": "number"
29
+ },
30
+ "Soldier": {
31
+ "type": "number"
32
+ },
33
+ "Trade": {
34
+ "type": "number"
35
+ }
36
+ },
37
+ "required": [
38
+ "Combat",
39
+ "Trade",
40
+ "Explore",
41
+ "Soldier",
42
+ "Exobiologist",
43
+ "CQC",
44
+ "Federation",
45
+ "Empire"
46
+ ],
47
+ "type": "object"
48
+ },
49
+ "ranks": {
50
+ "additionalProperties": false,
51
+ "properties": {
52
+ "CQC": {
53
+ "type": "number"
54
+ },
55
+ "Combat": {
56
+ "type": "number"
57
+ },
58
+ "Empire": {
59
+ "type": "number"
60
+ },
61
+ "Exobiologist": {
62
+ "type": "number"
63
+ },
64
+ "Explore": {
65
+ "type": "number"
66
+ },
67
+ "Federation": {
68
+ "type": "number"
69
+ },
70
+ "Soldier": {
71
+ "type": "number"
72
+ },
73
+ "Trade": {
74
+ "type": "number"
75
+ }
76
+ },
77
+ "required": [
78
+ "Combat",
79
+ "Trade",
80
+ "Explore",
81
+ "Soldier",
82
+ "Exobiologist",
83
+ "CQC",
84
+ "Federation",
85
+ "Empire"
86
+ ],
87
+ "type": "object"
88
+ },
89
+ "ranksVerbose": {
90
+ "additionalProperties": false,
91
+ "properties": {
92
+ "CQC": {
93
+ "type": "string"
94
+ },
95
+ "Combat": {
96
+ "type": "string"
97
+ },
98
+ "Empire": {
99
+ "type": "string"
100
+ },
101
+ "Exobiologist": {
102
+ "type": "string"
103
+ },
104
+ "Explore": {
105
+ "type": "string"
106
+ },
107
+ "Federation": {
108
+ "type": "string"
109
+ },
110
+ "Soldier": {
111
+ "type": "string"
112
+ },
113
+ "Trade": {
114
+ "type": "string"
115
+ }
116
+ },
117
+ "required": [
118
+ "Combat",
119
+ "Trade",
120
+ "Explore",
121
+ "Soldier",
122
+ "Exobiologist",
123
+ "CQC",
124
+ "Federation",
125
+ "Empire"
126
+ ],
127
+ "type": "object"
128
+ }
129
+ },
130
+ "required": [
131
+ "ranks",
132
+ "progress",
133
+ "ranksVerbose"
134
+ ],
135
+ "type": "object"
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "$ref": "#/definitions/EliteServerStatusResponse",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "EliteServerStatusResponse": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "lastUpdate": {
9
+ "type": "string"
10
+ },
11
+ "message": {
12
+ "type": "string"
13
+ },
14
+ "status": {
15
+ "type": "number"
16
+ },
17
+ "type": {
18
+ "$ref": "#/definitions/EliteServerStatusType"
19
+ }
20
+ },
21
+ "required": [
22
+ "lastUpdate",
23
+ "type",
24
+ "message",
25
+ "status"
26
+ ],
27
+ "type": "object"
28
+ },
29
+ "EliteServerStatusType": {
30
+ "enum": [
31
+ "success",
32
+ "warning",
33
+ "danger"
34
+ ],
35
+ "type": "string"
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "$ref": "#/definitions/FlightLogsResponse",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "FlightLog": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "date": {
9
+ "type": "string"
10
+ },
11
+ "firstDiscover": {
12
+ "type": "boolean"
13
+ },
14
+ "shipId": {
15
+ "type": [
16
+ "number",
17
+ "null"
18
+ ]
19
+ },
20
+ "system": {
21
+ "type": "string"
22
+ },
23
+ "systemId": {
24
+ "type": "number"
25
+ },
26
+ "systemId64": {
27
+ "$ref": "#/definitions/Id64"
28
+ }
29
+ },
30
+ "required": [
31
+ "shipId",
32
+ "system",
33
+ "firstDiscover",
34
+ "date"
35
+ ],
36
+ "type": "object"
37
+ },
38
+ "FlightLogsResponse": {
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "endDateTime": {
42
+ "type": "string"
43
+ },
44
+ "logs": {
45
+ "items": {
46
+ "$ref": "#/definitions/FlightLog"
47
+ },
48
+ "type": "array"
49
+ },
50
+ "startDateTime": {
51
+ "type": "string"
52
+ }
53
+ },
54
+ "required": [
55
+ "startDateTime",
56
+ "endDateTime",
57
+ "logs"
58
+ ],
59
+ "type": "object"
60
+ },
61
+ "Id64": {
62
+ "description": "A 64 bit ID. Can be a `number` if ID does not need more then 53 bit. Must be `bigint` if ID needs more than 53 bit.",
63
+ "type": [
64
+ "number"
65
+ ]
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Commander ranks response returned by {@link getCommanderRanks} request.
3
+ */
4
+ export interface CommanderRanksResponse {
5
+ ranks: {
6
+ Combat: number;
7
+ Trade: number;
8
+ Explore: number;
9
+ Soldier: number;
10
+ Exobiologist: number;
11
+ CQC: number;
12
+ Federation: number;
13
+ Empire: number;
14
+ };
15
+ progress: {
16
+ Combat: number;
17
+ Trade: number;
18
+ Explore: number;
19
+ Soldier: number;
20
+ Exobiologist: number;
21
+ CQC: number;
22
+ Federation: number;
23
+ Empire: number;
24
+ };
25
+ ranksVerbose: {
26
+ Combat: string;
27
+ Trade: string;
28
+ Explore: string;
29
+ Soldier: string;
30
+ Exobiologist: string;
31
+ CQC: string;
32
+ Federation: string;
33
+ Empire: string;
34
+ };
35
+ }
36
+ /** Credits period type */
37
+ export type CreditsPeriod = "7DAY" | "1MONTH" | "3MONTH" | "6MONTH";
38
+ /**
39
+ * Commander credits response returned by {@link getCommanderCredits} request.
40
+ */
41
+ export interface CommanderCreditsResponse {
42
+ credits: Array<{
43
+ balance: number;
44
+ loan: number;
45
+ date: string;
46
+ }>;
47
+ period?: CreditsPeriod;
48
+ }
49
+ /** Inventory type */
50
+ export type InventoryType = "materials" | "data" | "cargo";
51
+ /**
52
+ * Commander inventory response returned by {@link getCommanderInventory} request.
53
+ */
54
+ export interface CommanderInventoryResponse {
55
+ materials?: Array<{
56
+ type: string | number;
57
+ name: string;
58
+ qty: number;
59
+ }>;
60
+ data?: Array<{
61
+ type: string | number;
62
+ name: string;
63
+ qty: number;
64
+ }>;
65
+ cargo?: Array<{
66
+ type: string | null;
67
+ name: string;
68
+ qty: number;
69
+ }>;
70
+ }
71
+ /**
72
+ * Returns commander ranks.
73
+ *
74
+ * @param commanderName - The name of the commander as registered on EDSM.
75
+ * @param apiKey - The API key of the commander. If not provided, ranks will only be returned if the commander
76
+ * has enabled his public profile.
77
+ * @returns The commander ranks.
78
+ */
79
+ export declare function getCommanderRanks(commanderName: string, apiKey?: string): Promise<CommanderRanksResponse>;
80
+ /**
81
+ * Returns commander credits.
82
+ *
83
+ * @param commanderName - The name of the commander as registered on EDSM.
84
+ * @param apiKey - The API key of the commander.
85
+ * @returns The commander credits.
86
+ */
87
+ export declare function getCommanderCredits(commanderName: string, apiKey: string, period?: CreditsPeriod): Promise<CommanderCreditsResponse>;
88
+ /**
89
+ * Returns commander inventory.
90
+ *
91
+ * @param commanderName - The name of the commander as registered on EDSM.
92
+ * @param apiKey - The API key of the commander.
93
+ * @param type - The inventory type. Defaults to "materials".
94
+ * @returns The commander inventory.
95
+ */
96
+ export declare function getCommanderInventory(commanderName: string, apiKey: string, type?: InventoryType): Promise<CommanderInventoryResponse>;
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+ import { request } from "./common.js";
6
+ /**
7
+ * Returns commander ranks.
8
+ *
9
+ * @param commanderName - The name of the commander as registered on EDSM.
10
+ * @param apiKey - The API key of the commander. If not provided, ranks will only be returned if the commander
11
+ * has enabled his public profile.
12
+ * @returns The commander ranks.
13
+ */
14
+ export async function getCommanderRanks(commanderName, apiKey) {
15
+ return (await request("api-commander-v1/get-ranks", { commanderName, apiKey }));
16
+ }
17
+ /**
18
+ * Returns commander credits.
19
+ *
20
+ * @param commanderName - The name of the commander as registered on EDSM.
21
+ * @param apiKey - The API key of the commander.
22
+ * @returns The commander credits.
23
+ */
24
+ export async function getCommanderCredits(commanderName, apiKey, period) {
25
+ return (await request("api-commander-v1/get-credits", { commanderName, apiKey, period }));
26
+ }
27
+ /**
28
+ * Returns commander inventory.
29
+ *
30
+ * @param commanderName - The name of the commander as registered on EDSM.
31
+ * @param apiKey - The API key of the commander.
32
+ * @param type - The inventory type. Defaults to "materials".
33
+ * @returns The commander inventory.
34
+ */
35
+ export async function getCommanderInventory(commanderName, apiKey, type) {
36
+ return (await request("api-commander-v1/get-materials", { commanderName, apiKey, type }));
37
+ }
38
+ //# sourceMappingURL=commander.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commander.js","sourceRoot":"","sources":["../../../src/main/api/commander.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA6EtC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,aAAqB,EAAE,MAAe;IAC1E,OAAO,CAAC,MAAM,OAAO,CAAyB,4BAA4B,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAE,CAAC;AAC7G,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,aAAqB,EAAE,MAAc,EAAE,MAAsB;IACnG,OAAO,CAAC,MAAM,OAAO,CAAC,8BAA8B,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAE,CAAC;AAC/F,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,aAAqB,EAAE,MAAc,EAAE,IAAoB;IACnG,OAAO,CAAC,MAAM,OAAO,CAAC,gCAAgC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAE,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Id64 } from "../common.ts";
2
+ import { EDSMException } from "../util.ts";
3
+ export declare const edsmBaseUrl = "https://www.edsm.net";
4
+ /**
5
+ * Request options for referencing a system via EDSM or Frontier ID instead of name. Needed when system name is not unique.
6
+ */
7
+ export interface SystemIdRequestOptions {
8
+ /** The system ID if you seek for a duplicate system and want to force a specific ID. */
9
+ systemId?: number;
10
+ /** The system ID64 if you seek for a duplicate system and want to force a specific ID. */
11
+ systemId64?: Id64;
12
+ }
13
+ export declare class ServerException extends EDSMException {
14
+ readonly status: number;
15
+ constructor(status: number, message: string);
16
+ }
17
+ export declare class APIException extends EDSMException {
18
+ readonly status: number;
19
+ constructor(status: number, message: string);
20
+ }
21
+ /**
22
+ * Sends JSON request to the given URL with the given parameters and returns the response.
23
+ *
24
+ * @param params - Optional parameters.
25
+ * @returns The JSON result. Null when result was an empty object which for EDSM means "not found".
26
+ * @throws APIException - When request failed for some unknown reason.
27
+ */
28
+ export declare function request<T>(url: string, params?: Record<string, unknown>): Promise<T | null>;
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
+ * See LICENSE.md for licensing information.
4
+ */
5
+ import { JSONStringify } from "json-with-bigint";
6
+ import { EDSMException, jsonReviver } from "../util.js";
7
+ export const edsmBaseUrl = "https://www.edsm.net";
8
+ export class ServerException extends EDSMException {
9
+ status;
10
+ constructor(status, message) {
11
+ super(message);
12
+ this.status = status;
13
+ }
14
+ }
15
+ export class APIException extends EDSMException {
16
+ status;
17
+ constructor(status, message) {
18
+ super(message);
19
+ this.status = status;
20
+ }
21
+ }
22
+ /**
23
+ * Sends JSON request to the given URL with the given parameters and returns the response.
24
+ *
25
+ * @param params - Optional parameters.
26
+ * @returns The JSON result. Null when result was an empty object which for EDSM means "not found".
27
+ * @throws APIException - When request failed for some unknown reason.
28
+ */
29
+ export async function request(url, params = {}) {
30
+ const result = await fetch(`${edsmBaseUrl}/${url}`, {
31
+ method: "POST",
32
+ headers: { "Content-Type": "application/json" },
33
+ body: JSONStringify(params)
34
+ });
35
+ if (result.status !== 200) {
36
+ throw new ServerException(result.status, result.statusText);
37
+ }
38
+ const text = await result.text();
39
+ const json = JSON.parse(text, jsonReviver);
40
+ if (json.msgnum != null && json.msg != null) {
41
+ if (json.msgnum < 100 || json.msgnum >= 200) {
42
+ throw new APIException(json.msgnum, json.msg);
43
+ }
44
+ else {
45
+ delete json.msgnum;
46
+ delete json.msg;
47
+ }
48
+ }
49
+ if (Object.keys(json).length === 0) {
50
+ return null;
51
+ }
52
+ return json;
53
+ }
54
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/main/api/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAalD,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAC9B,MAAM,CAAS;IAE/B,YAAmB,MAAc,EAAE,OAAe;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAED,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC3B,MAAM,CAAS;IAE/B,YAAmB,MAAc,EAAE,OAAe;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAOD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,GAAW,EAAE,SAAkC,EAAE;IAC9E,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,WAAW,IAAI,GAAG,EAAE,EAAE;QAChD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;KAC9B,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACxB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAsB,CAAC;IAChE,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YAC1C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,MAAM,CAAC;YACnB,OAAO,IAAI,CAAC,GAAG,CAAC;QACpB,CAAC;IACL,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}