rocket-launch-live-client 0.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.
- package/LICENSE +661 -0
- package/README.md +309 -0
- package/dist/Client.d.ts +164 -0
- package/dist/Client.js +221 -0
- package/dist/Client.js.map +1 -0
- package/dist/fetcher.d.ts +1 -0
- package/dist/fetcher.js +44 -0
- package/dist/fetcher.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +9 -0
- package/dist/test.js.map +1 -0
- package/dist/types/application.d.ts +165 -0
- package/dist/types/application.js +25 -0
- package/dist/types/application.js.map +1 -0
- package/dist/types/standards.d.ts +314 -0
- package/dist/types/standards.js +314 -0
- package/dist/types/standards.js.map +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +253 -0
- package/dist/utils.js.map +1 -0
- package/package.json +44 -0
- package/src/Client.ts +262 -0
- package/src/fetcher.ts +50 -0
- package/src/index.ts +29 -0
- package/src/types/application.ts +193 -0
- package/src/types/standards.ts +317 -0
- package/src/utils.ts +294 -0
- package/tsconfig.json +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# rocket-launch-live-client
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Simple Usage](#simple)
|
|
6
|
+
- [Client Configuration](#config)
|
|
7
|
+
- [Endpoints](#endpoints)
|
|
8
|
+
- [Response Types](#types)
|
|
9
|
+
- [Companies](#companies)
|
|
10
|
+
- [Launches](#launches)
|
|
11
|
+
- [Locations](#locations)
|
|
12
|
+
- [Missions](#missions)
|
|
13
|
+
- [Pads](#pads)
|
|
14
|
+
- [Tags](#tags)
|
|
15
|
+
- [Vehicles](#vehicles)
|
|
16
|
+
|
|
17
|
+
This package is a fully-typed, promise-based, zero-dependency Node.JS JavaScript/TypeScript library for interacting with the [RocketLaunch.Live](https://www.rocketlaunch.live) API.
|
|
18
|
+
|
|
19
|
+
<a name="simple"></a>
|
|
20
|
+
|
|
21
|
+
## Simple usage
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
// Import package
|
|
25
|
+
import rllc from "rocket-launch-live-client";
|
|
26
|
+
|
|
27
|
+
// Get API Key
|
|
28
|
+
const RLL_API_KEY = process.env.RLL_API_KEY;
|
|
29
|
+
|
|
30
|
+
// Create client
|
|
31
|
+
const client = rllc(RLL_API_KEY);
|
|
32
|
+
|
|
33
|
+
// Call endpoints
|
|
34
|
+
const launches = await client.launches();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<a name="config"></a>
|
|
38
|
+
|
|
39
|
+
## Client Configuration
|
|
40
|
+
|
|
41
|
+
RLL Clients require an API key as the first parameter, and will throw if one is not present.
|
|
42
|
+
|
|
43
|
+
The client can be configured with an optional second parameter using the following keys:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const options = {
|
|
47
|
+
// Defaults to false.
|
|
48
|
+
// API Key is normally passed in the Authorization Bearer header
|
|
49
|
+
// Set to true to pass your API key as a query parameter instead (not recommended)
|
|
50
|
+
keyInQueryParams: true,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const client = rllc(RLL_API_KEY, options);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
<a name="endpoints"></a>
|
|
57
|
+
|
|
58
|
+
## Endpoints
|
|
59
|
+
|
|
60
|
+
All endpoints return the following response format, where `T` is an array of results:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
type RLLResponse<T> = {
|
|
64
|
+
errors?: string[];
|
|
65
|
+
valid_auth: boolean;
|
|
66
|
+
count: number;
|
|
67
|
+
limit: number;
|
|
68
|
+
total: number;
|
|
69
|
+
last_page: number;
|
|
70
|
+
result: T;
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
All endpoints return a maximum of 25 results per page. A `page` argument can be passed to retrieve incremental results.
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
const response = await client.launches({ page: 2 });
|
|
78
|
+
// Also accepts page number as a number-parseable string like "2"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For complete API Documentation on parameters, be sure to visit [RocketLaunch.Live](https://www.rocketlaunch.live/api)
|
|
82
|
+
|
|
83
|
+
<a name="types"></a>
|
|
84
|
+
|
|
85
|
+
### Response Types
|
|
86
|
+
|
|
87
|
+
All entity response types are browseable in the [GitHub Repository](https://github.com/mendahu/rocket-launch-live-client/tree/main/src/types).
|
|
88
|
+
|
|
89
|
+
<a name="companies"></a>
|
|
90
|
+
|
|
91
|
+
### Companies
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
const response = await client.companies(options);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Optional search parameters:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
const options = {
|
|
101
|
+
// Company numeric id
|
|
102
|
+
// Also accepts number parseable strings like "1"
|
|
103
|
+
id: 1,
|
|
104
|
+
|
|
105
|
+
// Company name
|
|
106
|
+
name: "SpaceX",
|
|
107
|
+
|
|
108
|
+
// Company country
|
|
109
|
+
// ISO 3166 Alpha 2 Country Code
|
|
110
|
+
country_code: "US",
|
|
111
|
+
|
|
112
|
+
// For defunct companies
|
|
113
|
+
inactive: true,
|
|
114
|
+
};
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
<a name="launches"></a>
|
|
118
|
+
|
|
119
|
+
### Launches
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
const response = await client.launches(options);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Optional search parameters:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
const options = {
|
|
129
|
+
// Launch numeric id
|
|
130
|
+
// Also accepts number parseable strings like "1"
|
|
131
|
+
id: 1,
|
|
132
|
+
|
|
133
|
+
// COSPAR
|
|
134
|
+
// Format YYYY-NNN
|
|
135
|
+
cospar_id: "2022-123",
|
|
136
|
+
|
|
137
|
+
// Show launches only before this date
|
|
138
|
+
// JS Date Object - Anything more precise than day is ignored
|
|
139
|
+
// Also accepts any date string which can be used to create a valid Date object in JavaScript
|
|
140
|
+
before_date: new Date("2023-01-31")
|
|
141
|
+
|
|
142
|
+
// Show launches only after this date
|
|
143
|
+
// JS Date Object - Anything more precise than day is ignored
|
|
144
|
+
// Also accepts any date string which can be used to create a valid Date object in JavaScript
|
|
145
|
+
after_date: new Date("2023-01-31")
|
|
146
|
+
|
|
147
|
+
// Show launches that have had data updated since this date
|
|
148
|
+
// Useful for checking for changes since your last API call
|
|
149
|
+
// JS Date Object
|
|
150
|
+
// Also accepts any date string which can be used to create a valid Date object in JavaScript
|
|
151
|
+
modified_since: new Date("2023-01-31T06:00:00Z")
|
|
152
|
+
|
|
153
|
+
// Launch location id
|
|
154
|
+
// Also accepts number parseable strings like "1"
|
|
155
|
+
location_id: 1,
|
|
156
|
+
|
|
157
|
+
// Launch pad id
|
|
158
|
+
// Also accepts number parseable strings like "1"
|
|
159
|
+
pad_id: 1,
|
|
160
|
+
|
|
161
|
+
// Launch provider id
|
|
162
|
+
// Also accepts number parseable strings like "1"
|
|
163
|
+
provider_id: 1,
|
|
164
|
+
|
|
165
|
+
// Launch tag id
|
|
166
|
+
// Also accepts number parseable strings like "1"
|
|
167
|
+
tag_id: 1,
|
|
168
|
+
|
|
169
|
+
// Launch vehicle id
|
|
170
|
+
// Also accepts number parseable strings like "1"
|
|
171
|
+
vehicle_id: 1,
|
|
172
|
+
|
|
173
|
+
// US State
|
|
174
|
+
// ISO 3166-2 US State Code Abbreviation
|
|
175
|
+
state_abbr: "FL",
|
|
176
|
+
|
|
177
|
+
// Country of launch
|
|
178
|
+
// ISO 3166-1 Alpha 2 Country Code
|
|
179
|
+
country_code: "US",
|
|
180
|
+
|
|
181
|
+
// Search string
|
|
182
|
+
// Also accepts numbers like 2020
|
|
183
|
+
search: "Starlink",
|
|
184
|
+
|
|
185
|
+
// Unique launch slug as used on RocketLaunch.live
|
|
186
|
+
slug: "ses-20-ses-21"
|
|
187
|
+
};
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
<a name="locations"></a>
|
|
191
|
+
|
|
192
|
+
### Locations
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
const response = await client.locations(options);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Optional search parameters:
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
const options = {
|
|
202
|
+
// Location numeric id
|
|
203
|
+
// Also accepts number parseable strings like "1"
|
|
204
|
+
id: 1,
|
|
205
|
+
|
|
206
|
+
// Location name
|
|
207
|
+
name: "Cape Canaveral",
|
|
208
|
+
|
|
209
|
+
// Location State (US)
|
|
210
|
+
// ISO 3166-2 US State Code Abbreviation
|
|
211
|
+
state_abbr: "FL",
|
|
212
|
+
|
|
213
|
+
// Location country
|
|
214
|
+
// ISO 3166 Alpha 2 Country Code
|
|
215
|
+
country_code: "US",
|
|
216
|
+
};
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
<a name="missions"></a>
|
|
220
|
+
|
|
221
|
+
### Missions
|
|
222
|
+
|
|
223
|
+
```js
|
|
224
|
+
const response = await client.missions(options);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Optional search parameters:
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
const options = {
|
|
231
|
+
// Mission numeric id
|
|
232
|
+
// Also accepts number parseable strings like "1"
|
|
233
|
+
id: 1,
|
|
234
|
+
|
|
235
|
+
// Mission name
|
|
236
|
+
name: "Juno",
|
|
237
|
+
};
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
<a name="pads"></a>
|
|
241
|
+
|
|
242
|
+
### Pads
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
const response = await client.pads(options);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Optional search parameters:
|
|
249
|
+
|
|
250
|
+
```js
|
|
251
|
+
const options = {
|
|
252
|
+
// Pad numeric id
|
|
253
|
+
// Also accepts number parseable strings like "1"
|
|
254
|
+
id: 1,
|
|
255
|
+
|
|
256
|
+
// Pad name
|
|
257
|
+
name: "SpaceX",
|
|
258
|
+
|
|
259
|
+
// Pad State (US)
|
|
260
|
+
// ISO 3166-2 US State Code Abbreviation
|
|
261
|
+
state_abbr: "FL",
|
|
262
|
+
|
|
263
|
+
// Pad country
|
|
264
|
+
// ISO 3166 Alpha 2 Country Code
|
|
265
|
+
country_code: "US",
|
|
266
|
+
};
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
<a name="tags"></a>
|
|
270
|
+
|
|
271
|
+
### Tags
|
|
272
|
+
|
|
273
|
+
```js
|
|
274
|
+
const response = await client.tags(options);
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Optional search parameters:
|
|
278
|
+
|
|
279
|
+
```js
|
|
280
|
+
const options = {
|
|
281
|
+
// Tag numeric id
|
|
282
|
+
// Also accepts number parseable strings like "1"
|
|
283
|
+
id: 1,
|
|
284
|
+
|
|
285
|
+
// Tag text
|
|
286
|
+
text: "Crewed",
|
|
287
|
+
};
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
<a name="vehicles"></a>
|
|
291
|
+
|
|
292
|
+
### Vehicles
|
|
293
|
+
|
|
294
|
+
```js
|
|
295
|
+
const response = await client.vehicles(options);
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Optional search parameters:
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
const options = {
|
|
302
|
+
// Vehicle numeric id
|
|
303
|
+
// Also accepts number parseable strings like "1"
|
|
304
|
+
id: 1,
|
|
305
|
+
|
|
306
|
+
// Vehicle name
|
|
307
|
+
name: "Atlas V",
|
|
308
|
+
};
|
|
309
|
+
```
|
package/dist/Client.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { RLLClientOptions, RLLEntity, RLLQueryConfig, RLLResponse } from "./types/application";
|
|
2
|
+
declare class RLLClient {
|
|
3
|
+
private apiKey;
|
|
4
|
+
private config;
|
|
5
|
+
constructor(apiKey: string, options?: RLLClientOptions);
|
|
6
|
+
/**
|
|
7
|
+
* Used internally to make API query
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*
|
|
11
|
+
* @template T
|
|
12
|
+
*
|
|
13
|
+
* @param {string} endpoint - API endpoint (ie. "/launches")
|
|
14
|
+
* @param {URLSearchParams} params - API Search Params
|
|
15
|
+
*
|
|
16
|
+
* @returns {Promise<T>}
|
|
17
|
+
*/
|
|
18
|
+
private query;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch launch companies
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @function
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} [options] - Launch Company Search Options
|
|
26
|
+
* @param {number | string} options.id - Company id
|
|
27
|
+
* @param {number | string} options.page - Page number of results
|
|
28
|
+
* @param {number | string} options.name - Company name
|
|
29
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
30
|
+
* @param {boolean} options.inactive - Company inactive status
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<RLLResponse<RLLEntity.Company[]>>} Array of companies wrapped in a standard RLL Response
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* const response = client.companies({ country_code: "US" })
|
|
37
|
+
*/
|
|
38
|
+
companies(options?: RLLQueryConfig.Companies): Promise<RLLResponse<RLLEntity.Company[]>>;
|
|
39
|
+
/**
|
|
40
|
+
* Fetch launches
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
* @function
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} [options] - Launch Search Options
|
|
46
|
+
* @param {number | string} options.id - Launch id
|
|
47
|
+
* @param {number | string} options.page - Page number of results
|
|
48
|
+
* @param {string} options.cospar_id - Launch COSPAR ID (ie. 2022-123)
|
|
49
|
+
* @param {Date | string} options.before_date - Only return launches before this date
|
|
50
|
+
* @param {Date | string} options.after_date - Only return launches after this date
|
|
51
|
+
* @param {Date | string} options.modified_since - Only return launches with API changes after this date
|
|
52
|
+
* @param {number | string} options.location_id - Launches from this Location
|
|
53
|
+
* @param {number | string} options.pad_id - Launches from this Pad
|
|
54
|
+
* @param {number | string} options.provider_id - Launches from this Company
|
|
55
|
+
* @param {number | string} options.tag_id - Launches with this Tag
|
|
56
|
+
* @param {number | string} options.vehicle_id - Launches on this Vehicle
|
|
57
|
+
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
58
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
59
|
+
* @param {number | string} options.search - Launches matching this search string
|
|
60
|
+
* @param {number | string} options.slug - Launches matching this unique slug
|
|
61
|
+
*
|
|
62
|
+
* @returns {Promise<RLLResponse<RLLEntity.Launch[]>>} Array of companies wrapped in a standard RLL Response
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
*
|
|
66
|
+
* const response = client.launches({ after_date: new Date("2022-10-10") })
|
|
67
|
+
*/
|
|
68
|
+
launches(options?: RLLQueryConfig.Launches): Promise<RLLResponse<RLLEntity.Launch[]>>;
|
|
69
|
+
/**
|
|
70
|
+
* Fetch launch locations
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
* @function
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} [options] - Launch Location Search Options
|
|
76
|
+
* @param {number | string} options.id - Location id
|
|
77
|
+
* @param {number | string} options.page - Page number of results
|
|
78
|
+
* @param {number | string} options.name - Location name
|
|
79
|
+
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
80
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<RLLResponse<RLLEntity.Location[]>>} Array of companies wrapped in a standard RLL Response
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
*
|
|
86
|
+
* const response = client.locations({ country_code: "US" })
|
|
87
|
+
*/
|
|
88
|
+
locations(options?: RLLQueryConfig.Locations): Promise<RLLResponse<RLLEntity.Location[]>>;
|
|
89
|
+
/**
|
|
90
|
+
* Fetch launch Missions
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
* @function
|
|
94
|
+
*
|
|
95
|
+
* @param {Object} [options] - Launch Mission Search Options
|
|
96
|
+
* @param {number | string} options.id - Mission id
|
|
97
|
+
* @param {number | string} options.page - Page number of results
|
|
98
|
+
* @param {number | string} options.name - Mission name
|
|
99
|
+
*
|
|
100
|
+
* @returns {Promise<RLLResponse<RLLEntity.Mission[]>>} Array of companies wrapped in a standard RLL Response
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
*
|
|
104
|
+
* const response = client.missions({ name: "Mars 2020" })
|
|
105
|
+
*/
|
|
106
|
+
missions(options?: RLLQueryConfig.Missions): Promise<RLLResponse<RLLEntity.Mission[]>>;
|
|
107
|
+
/**
|
|
108
|
+
* Fetch launch pads
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
* @function
|
|
112
|
+
*
|
|
113
|
+
* @param {Object} [options] - Launch Pad Search Options
|
|
114
|
+
* @param {number | string} options.id - Pad id
|
|
115
|
+
* @param {number | string} options.page - Page number of results
|
|
116
|
+
* @param {number | string} options.name - Pad name
|
|
117
|
+
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
118
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
119
|
+
*
|
|
120
|
+
* @returns {Promise<RLLResponse<RLLEntity.Pad[]>>} Array of companies wrapped in a standard RLL Response
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
*
|
|
124
|
+
* const response = client.pads({ country_code: "US" })
|
|
125
|
+
*/
|
|
126
|
+
pads(options?: RLLQueryConfig.Pads): Promise<RLLResponse<RLLEntity.Pad[]>>;
|
|
127
|
+
/**
|
|
128
|
+
* Fetch launch tags
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
* @function
|
|
132
|
+
*
|
|
133
|
+
* @param {Object} [options] - Launch Tag Search Options
|
|
134
|
+
* @param {number | string} options.id - Tag id
|
|
135
|
+
* @param {number | string} options.page - Page number of results
|
|
136
|
+
* @param {number | string} options.text - Tag text
|
|
137
|
+
*
|
|
138
|
+
* @returns {Promise<RLLResponse<RLLEntity.Tag[]>>} Array of companies wrapped in a standard RLL Response
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
*
|
|
142
|
+
* const response = client.tags({ text: "Crewed" })
|
|
143
|
+
*/
|
|
144
|
+
tags(options?: RLLQueryConfig.Tags): Promise<RLLResponse<RLLEntity.Tag[]>>;
|
|
145
|
+
/**
|
|
146
|
+
* Fetch launch Vehicles
|
|
147
|
+
*
|
|
148
|
+
* @public
|
|
149
|
+
* @function
|
|
150
|
+
*
|
|
151
|
+
* @param {Object} [options] - Launch Vehicles Search Options
|
|
152
|
+
* @param {number | string} options.id - Vehicle id
|
|
153
|
+
* @param {number | string} options.page - Page number of results
|
|
154
|
+
* @param {number | string} options.name - Vehicle name
|
|
155
|
+
*
|
|
156
|
+
* @returns {Promise<RLLResponse<RLLEntity.Vehicle[]>>} Array of companies wrapped in a standard RLL Response
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
*
|
|
160
|
+
* const response = client.vehicles({ name: "Falcon 9" })
|
|
161
|
+
*/
|
|
162
|
+
vehicles(options?: RLLQueryConfig.Vehicles): Promise<RLLResponse<RLLEntity.Vehicle[]>>;
|
|
163
|
+
}
|
|
164
|
+
export default RLLClient;
|
package/dist/Client.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var application_1 = require("./types/application");
|
|
4
|
+
var fetcher_1 = require("./fetcher");
|
|
5
|
+
var utils_1 = require("./utils");
|
|
6
|
+
var RLLClient = /** @class */ (function () {
|
|
7
|
+
function RLLClient(apiKey, options) {
|
|
8
|
+
this.config = {
|
|
9
|
+
keyInQueryParams: false,
|
|
10
|
+
};
|
|
11
|
+
// Validate API Key is a valid UUID format
|
|
12
|
+
// Constructor throws if not
|
|
13
|
+
(0, utils_1.apiKeyValidator)(apiKey);
|
|
14
|
+
this.apiKey = apiKey;
|
|
15
|
+
if (!options) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Validate Options with warnings or throws
|
|
19
|
+
(0, utils_1.optionsValidator)(options);
|
|
20
|
+
if (options.keyInQueryParams) {
|
|
21
|
+
this.config.keyInQueryParams = options.keyInQueryParams;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Used internally to make API query
|
|
26
|
+
*
|
|
27
|
+
* @private
|
|
28
|
+
*
|
|
29
|
+
* @template T
|
|
30
|
+
*
|
|
31
|
+
* @param {string} endpoint - API endpoint (ie. "/launches")
|
|
32
|
+
* @param {URLSearchParams} params - API Search Params
|
|
33
|
+
*
|
|
34
|
+
* @returns {Promise<T>}
|
|
35
|
+
*/
|
|
36
|
+
RLLClient.prototype.query = function (endpoint, params) {
|
|
37
|
+
return (0, fetcher_1.fetcher)(this.apiKey, endpoint, params, this.config.keyInQueryParams);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Fetch launch companies
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
* @function
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} [options] - Launch Company Search Options
|
|
46
|
+
* @param {number | string} options.id - Company id
|
|
47
|
+
* @param {number | string} options.page - Page number of results
|
|
48
|
+
* @param {number | string} options.name - Company name
|
|
49
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
50
|
+
* @param {boolean} options.inactive - Company inactive status
|
|
51
|
+
*
|
|
52
|
+
* @returns {Promise<RLLResponse<RLLEntity.Company[]>>} Array of companies wrapped in a standard RLL Response
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
*
|
|
56
|
+
* const response = client.companies({ country_code: "US" })
|
|
57
|
+
*/
|
|
58
|
+
RLLClient.prototype.companies = function (options) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.COMPANIES, options).then(function (params) {
|
|
61
|
+
return _this.query(application_1.RLLEndPoint.COMPANIES, params);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Fetch launches
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
* @function
|
|
69
|
+
*
|
|
70
|
+
* @param {Object} [options] - Launch Search Options
|
|
71
|
+
* @param {number | string} options.id - Launch id
|
|
72
|
+
* @param {number | string} options.page - Page number of results
|
|
73
|
+
* @param {string} options.cospar_id - Launch COSPAR ID (ie. 2022-123)
|
|
74
|
+
* @param {Date | string} options.before_date - Only return launches before this date
|
|
75
|
+
* @param {Date | string} options.after_date - Only return launches after this date
|
|
76
|
+
* @param {Date | string} options.modified_since - Only return launches with API changes after this date
|
|
77
|
+
* @param {number | string} options.location_id - Launches from this Location
|
|
78
|
+
* @param {number | string} options.pad_id - Launches from this Pad
|
|
79
|
+
* @param {number | string} options.provider_id - Launches from this Company
|
|
80
|
+
* @param {number | string} options.tag_id - Launches with this Tag
|
|
81
|
+
* @param {number | string} options.vehicle_id - Launches on this Vehicle
|
|
82
|
+
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
83
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
84
|
+
* @param {number | string} options.search - Launches matching this search string
|
|
85
|
+
* @param {number | string} options.slug - Launches matching this unique slug
|
|
86
|
+
*
|
|
87
|
+
* @returns {Promise<RLLResponse<RLLEntity.Launch[]>>} Array of companies wrapped in a standard RLL Response
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
*
|
|
91
|
+
* const response = client.launches({ after_date: new Date("2022-10-10") })
|
|
92
|
+
*/
|
|
93
|
+
RLLClient.prototype.launches = function (options) {
|
|
94
|
+
var _this = this;
|
|
95
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.LAUNCHES, options).then(function (params) {
|
|
96
|
+
return _this.query(application_1.RLLEndPoint.LAUNCHES, params);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Fetch launch locations
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
* @function
|
|
104
|
+
*
|
|
105
|
+
* @param {Object} [options] - Launch Location Search Options
|
|
106
|
+
* @param {number | string} options.id - Location id
|
|
107
|
+
* @param {number | string} options.page - Page number of results
|
|
108
|
+
* @param {number | string} options.name - Location name
|
|
109
|
+
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
110
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
111
|
+
*
|
|
112
|
+
* @returns {Promise<RLLResponse<RLLEntity.Location[]>>} Array of companies wrapped in a standard RLL Response
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
*
|
|
116
|
+
* const response = client.locations({ country_code: "US" })
|
|
117
|
+
*/
|
|
118
|
+
RLLClient.prototype.locations = function (options) {
|
|
119
|
+
var _this = this;
|
|
120
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.LOCATIONS, options).then(function (params) {
|
|
121
|
+
return _this.query(application_1.RLLEndPoint.LOCATIONS, params);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Fetch launch Missions
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @function
|
|
129
|
+
*
|
|
130
|
+
* @param {Object} [options] - Launch Mission Search Options
|
|
131
|
+
* @param {number | string} options.id - Mission id
|
|
132
|
+
* @param {number | string} options.page - Page number of results
|
|
133
|
+
* @param {number | string} options.name - Mission name
|
|
134
|
+
*
|
|
135
|
+
* @returns {Promise<RLLResponse<RLLEntity.Mission[]>>} Array of companies wrapped in a standard RLL Response
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
*
|
|
139
|
+
* const response = client.missions({ name: "Mars 2020" })
|
|
140
|
+
*/
|
|
141
|
+
RLLClient.prototype.missions = function (options) {
|
|
142
|
+
var _this = this;
|
|
143
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.MISSIONS, options).then(function (params) {
|
|
144
|
+
return _this.query(application_1.RLLEndPoint.MISSIONS, params);
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Fetch launch pads
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
* @function
|
|
152
|
+
*
|
|
153
|
+
* @param {Object} [options] - Launch Pad Search Options
|
|
154
|
+
* @param {number | string} options.id - Pad id
|
|
155
|
+
* @param {number | string} options.page - Page number of results
|
|
156
|
+
* @param {number | string} options.name - Pad name
|
|
157
|
+
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
158
|
+
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
159
|
+
*
|
|
160
|
+
* @returns {Promise<RLLResponse<RLLEntity.Pad[]>>} Array of companies wrapped in a standard RLL Response
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
*
|
|
164
|
+
* const response = client.pads({ country_code: "US" })
|
|
165
|
+
*/
|
|
166
|
+
RLLClient.prototype.pads = function (options) {
|
|
167
|
+
var _this = this;
|
|
168
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.PADS, options).then(function (params) {
|
|
169
|
+
return _this.query(application_1.RLLEndPoint.PADS, params);
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Fetch launch tags
|
|
174
|
+
*
|
|
175
|
+
* @public
|
|
176
|
+
* @function
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} [options] - Launch Tag Search Options
|
|
179
|
+
* @param {number | string} options.id - Tag id
|
|
180
|
+
* @param {number | string} options.page - Page number of results
|
|
181
|
+
* @param {number | string} options.text - Tag text
|
|
182
|
+
*
|
|
183
|
+
* @returns {Promise<RLLResponse<RLLEntity.Tag[]>>} Array of companies wrapped in a standard RLL Response
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
*
|
|
187
|
+
* const response = client.tags({ text: "Crewed" })
|
|
188
|
+
*/
|
|
189
|
+
RLLClient.prototype.tags = function (options) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.TAGS, options).then(function (params) {
|
|
192
|
+
return _this.query(application_1.RLLEndPoint.TAGS, params);
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Fetch launch Vehicles
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
* @function
|
|
200
|
+
*
|
|
201
|
+
* @param {Object} [options] - Launch Vehicles Search Options
|
|
202
|
+
* @param {number | string} options.id - Vehicle id
|
|
203
|
+
* @param {number | string} options.page - Page number of results
|
|
204
|
+
* @param {number | string} options.name - Vehicle name
|
|
205
|
+
*
|
|
206
|
+
* @returns {Promise<RLLResponse<RLLEntity.Vehicle[]>>} Array of companies wrapped in a standard RLL Response
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
*
|
|
210
|
+
* const response = client.vehicles({ name: "Falcon 9" })
|
|
211
|
+
*/
|
|
212
|
+
RLLClient.prototype.vehicles = function (options) {
|
|
213
|
+
var _this = this;
|
|
214
|
+
return (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.VEHICLES, options).then(function (params) {
|
|
215
|
+
return _this.query(application_1.RLLEndPoint.VEHICLES, params);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
return RLLClient;
|
|
219
|
+
}());
|
|
220
|
+
exports.default = RLLClient;
|
|
221
|
+
//# sourceMappingURL=Client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetcher: <T>(apiKey: string, endpoint: string, params: URLSearchParams, keyInQueryParams: boolean) => Promise<T>;
|