rocket-launch-live-client 0.3.0 → 1.0.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/README.md +16 -5
- package/lib/cjs/Watcher.js +8 -4
- package/lib/cjs/types/Watcher.d.ts +1 -12
- package/lib/cjs/types/Watcher.d.ts.map +1 -1
- package/lib/cjs/types/application.js +4 -2
- package/lib/cjs/types/types/application.d.ts +5 -1
- package/lib/cjs/types/types/application.d.ts.map +1 -1
- package/lib/cjs/types/utils.d.ts.map +1 -1
- package/lib/cjs/utils.js +21 -0
- package/lib/esm/Client.js +27 -23
- package/lib/esm/Watcher.js +27 -14
- package/lib/esm/fetcher.js +10 -3
- package/lib/esm/index.mjs +13 -5
- package/lib/esm/types/Watcher.d.ts +1 -12
- package/lib/esm/types/Watcher.d.ts.map +1 -1
- package/lib/esm/types/application.js +10 -5
- package/lib/esm/types/standards.js +11 -6
- package/lib/esm/types/types/application.d.ts +5 -1
- package/lib/esm/types/types/application.d.ts.map +1 -1
- package/lib/esm/types/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +51 -21
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -141,18 +141,18 @@ const options = {
|
|
|
141
141
|
// Show launches only before this date
|
|
142
142
|
// JS Date Object - Anything more precise than day is ignored
|
|
143
143
|
// Also accepts any date string which can be used to create a valid Date object in JavaScript
|
|
144
|
-
before_date: new Date("2023-01-31")
|
|
144
|
+
before_date: new Date("2023-01-31"),
|
|
145
145
|
|
|
146
146
|
// Show launches only after this date
|
|
147
147
|
// JS Date Object - Anything more precise than day is ignored
|
|
148
148
|
// Also accepts any date string which can be used to create a valid Date object in JavaScript
|
|
149
|
-
after_date: new Date("2023-01-31")
|
|
149
|
+
after_date: new Date("2023-01-31"),
|
|
150
150
|
|
|
151
151
|
// Show launches that have had data updated since this date
|
|
152
152
|
// Useful for checking for changes since your last API call
|
|
153
153
|
// JS Date Object
|
|
154
154
|
// Also accepts any date string which can be used to create a valid Date object in JavaScript
|
|
155
|
-
modified_since: new Date("2023-01-31T06:00:00Z")
|
|
155
|
+
modified_since: new Date("2023-01-31T06:00:00Z"),
|
|
156
156
|
|
|
157
157
|
// Launch location id
|
|
158
158
|
// Also accepts number parseable strings like "1"
|
|
@@ -187,7 +187,18 @@ const options = {
|
|
|
187
187
|
search: "Starlink",
|
|
188
188
|
|
|
189
189
|
// Unique launch slug as used on RocketLaunch.live
|
|
190
|
-
slug: "ses-20-ses-21"
|
|
190
|
+
slug: "ses-20-ses-21",
|
|
191
|
+
|
|
192
|
+
// Limit amount of launches returned
|
|
193
|
+
// Must be between 1 and 25
|
|
194
|
+
// Also accepts number parseable strings like "10"
|
|
195
|
+
// Note: this param is safely ignored when using in conjuction with a Watcher (see below)
|
|
196
|
+
limit: 10,
|
|
197
|
+
|
|
198
|
+
// Sort order (by date) of results
|
|
199
|
+
// Accepts either "asc" or "desc"
|
|
200
|
+
// If left unfilled, API defaults to "asc"
|
|
201
|
+
direction: "asc",
|
|
191
202
|
};
|
|
192
203
|
```
|
|
193
204
|
|
|
@@ -344,7 +355,7 @@ watcher.stop();
|
|
|
344
355
|
A new watcher takes up to two arguments:
|
|
345
356
|
|
|
346
357
|
1. Interval - (optional) (default: 5) - a duration, in minutes, between calls to the API. Adjust this based on the frequency you wish to stay up to date. To avoid needlessly querying the API, this client will now allow any option less than 1 minute.
|
|
347
|
-
2. Query Options - (optional) - The exact same query options that can be submitted to the [`launches`](#launches) endpoint.
|
|
358
|
+
2. Query Options - (optional) - The exact same query options that can be submitted to the [`launches`](#launches) endpoint. _NOTE:_ the "limit" param is ignored on the `watcher`.
|
|
348
359
|
|
|
349
360
|
Query options cannot be altered on a running watcher. In order to change your search conditions, you'll need to stop the watcher and start a new one.
|
|
350
361
|
|
package/lib/cjs/Watcher.js
CHANGED
|
@@ -60,10 +60,6 @@ class RLLWatcher extends events_1.default {
|
|
|
60
60
|
*/
|
|
61
61
|
constructor(fetcher, interval = DEFAULT_INTERVAL_IN_MINS, options) {
|
|
62
62
|
super();
|
|
63
|
-
this._untypedOn = this.on;
|
|
64
|
-
this._untypedEmit = this.emit;
|
|
65
|
-
this.on = (event, listener) => this._untypedOn(event, listener);
|
|
66
|
-
this.emit = (event, ...args) => this._untypedEmit(event, ...args);
|
|
67
63
|
this.launches = new Map();
|
|
68
64
|
/**
|
|
69
65
|
* Recursive API Caller to iterate through pages
|
|
@@ -92,10 +88,18 @@ class RLLWatcher extends events_1.default {
|
|
|
92
88
|
};
|
|
93
89
|
return recursiveFetcher();
|
|
94
90
|
};
|
|
91
|
+
// Reassign default Event Emitter methods
|
|
92
|
+
this._untypedOn = this.on;
|
|
93
|
+
this._untypedEmit = this.emit;
|
|
94
|
+
// Methord Overide for type safety
|
|
95
|
+
this.on = (event, listener) => this._untypedOn(event, listener);
|
|
96
|
+
this.emit = (event, ...args) => this._untypedEmit(event, ...args);
|
|
95
97
|
this.last_call = new Date();
|
|
96
98
|
this.fetcher = fetcher;
|
|
97
99
|
this.interval = intervalValidator(interval);
|
|
98
100
|
this.params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.LAUNCHES, options);
|
|
101
|
+
// ignore any limit params as these cause unnecessary API calls and do not serve the Watcher role
|
|
102
|
+
this.params.delete("limit");
|
|
99
103
|
}
|
|
100
104
|
/**
|
|
101
105
|
* Query wrapper to trigger events
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from "events";
|
|
3
|
-
import { RLLEntity,
|
|
4
|
-
interface IRLLWatcherEvent {
|
|
5
|
-
new: (launch: RLLEntity.Launch) => void;
|
|
6
|
-
change: (oldLaunch: RLLEntity.Launch, newLaunch: RLLEntity.Launch) => void;
|
|
7
|
-
error: (error: RLLError) => void;
|
|
8
|
-
ready: (launches: Map<number, RLLEntity.Launch>) => void;
|
|
9
|
-
init_error: (error: RLLError) => void;
|
|
10
|
-
call: (params: URLSearchParams) => void;
|
|
11
|
-
}
|
|
3
|
+
import { RLLEntity, RLLQueryConfig, RLLResponse } from "./types/application";
|
|
12
4
|
/**
|
|
13
5
|
* Class representing a RocketLaunch.Live Client Watcher
|
|
14
6
|
* @class
|
|
@@ -16,8 +8,6 @@ interface IRLLWatcherEvent {
|
|
|
16
8
|
export declare class RLLWatcher extends EventEmitter {
|
|
17
9
|
private _untypedOn;
|
|
18
10
|
private _untypedEmit;
|
|
19
|
-
on: <K extends keyof IRLLWatcherEvent>(event: K, listener: IRLLWatcherEvent[K]) => this;
|
|
20
|
-
emit: <K extends keyof IRLLWatcherEvent>(event: K, ...args: Parameters<IRLLWatcherEvent[K]>) => boolean;
|
|
21
11
|
private last_call;
|
|
22
12
|
launches: Map<number, RLLEntity.Launch>;
|
|
23
13
|
private interval;
|
|
@@ -88,5 +78,4 @@ export declare class RLLWatcher extends EventEmitter {
|
|
|
88
78
|
*/
|
|
89
79
|
stop(): void;
|
|
90
80
|
}
|
|
91
|
-
export {};
|
|
92
81
|
//# sourceMappingURL=Watcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/Watcher.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,SAAS,
|
|
1
|
+
{"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/Watcher.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,SAAS,EAET,cAAc,EAEd,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAqD7B;;;GAGG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,UAAU,CAGR;IACV,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,SAAS,CAAO;IACjB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAa;IAC3D,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,OAAO,CAE+B;IAE9C;;;;;;;;;;;;;;;;;;;;;;OAsBG;gBAED,OAAO,EAAE,CACP,MAAM,EAAE,eAAe,KACpB,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC7C,QAAQ,GAAE,MAAM,GAAG,MAAiC,EACpD,OAAO,CAAC,EAAE,cAAc,CAAC,QAAQ;IA4BnC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB,CAsBtB;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK;IAyBb;;;;;;;OAOG;IACI,KAAK,IAAI,IAAI;IAoBpB;;;;;;;OAOG;IACI,IAAI,IAAI,IAAI;CAKpB"}
|
|
@@ -10,7 +10,7 @@ var RLLEndPoint;
|
|
|
10
10
|
RLLEndPoint["PADS"] = "pads";
|
|
11
11
|
RLLEndPoint["TAGS"] = "tags";
|
|
12
12
|
RLLEndPoint["VEHICLES"] = "vehicles";
|
|
13
|
-
})(RLLEndPoint
|
|
13
|
+
})(RLLEndPoint || (exports.RLLEndPoint = RLLEndPoint = {}));
|
|
14
14
|
var RLLEntity;
|
|
15
15
|
(function (RLLEntity) {
|
|
16
16
|
let LaunchResult;
|
|
@@ -21,7 +21,7 @@ var RLLEntity;
|
|
|
21
21
|
LaunchResult[LaunchResult["PARTIAL_FAILURE"] = 2] = "PARTIAL_FAILURE";
|
|
22
22
|
LaunchResult[LaunchResult["IN_FLIGHT_ABORT_CREWED"] = 3] = "IN_FLIGHT_ABORT_CREWED";
|
|
23
23
|
})(LaunchResult = RLLEntity.LaunchResult || (RLLEntity.LaunchResult = {}));
|
|
24
|
-
})(RLLEntity
|
|
24
|
+
})(RLLEntity || (exports.RLLEntity = RLLEntity = {}));
|
|
25
25
|
exports.RLLQueryParams = {
|
|
26
26
|
id: true,
|
|
27
27
|
page: true,
|
|
@@ -41,4 +41,6 @@ exports.RLLQueryParams = {
|
|
|
41
41
|
search: true,
|
|
42
42
|
slug: true,
|
|
43
43
|
text: true,
|
|
44
|
+
limit: true,
|
|
45
|
+
direction: true,
|
|
44
46
|
};
|
|
@@ -23,7 +23,7 @@ export declare namespace RLLEntity {
|
|
|
23
23
|
export interface Company extends RLLRecord {
|
|
24
24
|
name: string;
|
|
25
25
|
country: Country;
|
|
26
|
-
inactive: boolean
|
|
26
|
+
inactive: boolean;
|
|
27
27
|
}
|
|
28
28
|
export enum LaunchResult {
|
|
29
29
|
NOT_SET = -1,
|
|
@@ -135,6 +135,8 @@ export declare const RLLQueryParams: {
|
|
|
135
135
|
search: boolean;
|
|
136
136
|
slug: boolean;
|
|
137
137
|
text: boolean;
|
|
138
|
+
limit: boolean;
|
|
139
|
+
direction: boolean;
|
|
138
140
|
};
|
|
139
141
|
export declare namespace RLLQueryConfig {
|
|
140
142
|
interface Base {
|
|
@@ -160,6 +162,8 @@ export declare namespace RLLQueryConfig {
|
|
|
160
162
|
country_code?: ISO3166Alpha2.CountryCode;
|
|
161
163
|
search?: string | number;
|
|
162
164
|
slug?: string | number;
|
|
165
|
+
limit?: number | string;
|
|
166
|
+
direction?: "asc" | "desc";
|
|
163
167
|
}
|
|
164
168
|
export interface Locations extends Base {
|
|
165
169
|
name?: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../src/types/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,yBAAiB,SAAS,CAAC;IACzB,UAAU,SAAS;QACjB,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,MAAM,WAAW,OAAO;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,aAAa,CAAC,WAAW,GAAG,EAAE,CAAC;KACtC;IAED,MAAM,WAAW,KAAK;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;KAClC;IAED,MAAM,WAAW,OAAQ,SAAQ,SAAS;QACxC,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../src/types/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,yBAAiB,SAAS,CAAC;IACzB,UAAU,SAAS;QACjB,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,MAAM,WAAW,OAAO;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,aAAa,CAAC,WAAW,GAAG,EAAE,CAAC;KACtC;IAED,MAAM,WAAW,KAAK;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;KAClC;IAED,MAAM,WAAW,OAAQ,SAAQ,SAAS;QACxC,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC;KACnB;IAED,MAAM,MAAM,YAAY;QACtB,OAAO,KAAK;QACZ,OAAO,IAAI;QACX,OAAO,IAAI;QACX,eAAe,IAAI;QACnB,sBAAsB,IAAI;KAC3B;IAED,MAAM,WAAW,KAAM,SAAQ,SAAS;QACtC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC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,CAAC,IAAI;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQlE,eAAO,MAAM,kBAAkB,SAAU,IAAI,KAAG,MAE/C,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,GAAG,KAAG,MA2B7C,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;MAEzB,IAeH,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQlE,eAAO,MAAM,kBAAkB,SAAU,IAAI,KAAG,MAE/C,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,GAAG,KAAG,MA2B7C,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;MAEzB,IAeH,CAAC;AAkLF,eAAO,MAAM,qBAAqB,aACtB,WAAW,YAEjB,eAAe,SAAS,GACxB,eAAe,QAAQ,GACvB,eAAe,SAAS,GACxB,eAAe,QAAQ,GACvB,eAAe,IAAI,GACnB,eAAe,IAAI,GACnB,eAAe,QAAQ,KAC1B,eAwDF,CAAC;AAEF,eAAO,MAAM,IAAI,QAAS,MAAM,SAAyC,CAAC;AAE1E,eAAO,MAAM,KAAK,QACX,MAAM,SACL,MAAM,GAAG,OAAO,GAAG,OAAO,KAC/B,IAYF,CAAC"}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -132,6 +132,25 @@ const validators = {
|
|
|
132
132
|
}
|
|
133
133
|
return (0, exports.formatToRLLISODate)(date);
|
|
134
134
|
},
|
|
135
|
+
limit: (option) => {
|
|
136
|
+
const num = validators.number(option);
|
|
137
|
+
if (num < 1) {
|
|
138
|
+
throw "Must be a number greater than 0";
|
|
139
|
+
}
|
|
140
|
+
if (num > 25) {
|
|
141
|
+
throw "Must be a number less than 26";
|
|
142
|
+
}
|
|
143
|
+
return num;
|
|
144
|
+
},
|
|
145
|
+
direction: (option) => {
|
|
146
|
+
if (typeof option !== "string") {
|
|
147
|
+
throw "Must be a string";
|
|
148
|
+
}
|
|
149
|
+
if (option !== "asc" && option !== "desc") {
|
|
150
|
+
throw 'String must be either "asc" or "desc"';
|
|
151
|
+
}
|
|
152
|
+
return option;
|
|
153
|
+
},
|
|
135
154
|
};
|
|
136
155
|
const optionsMap = {
|
|
137
156
|
companies: {
|
|
@@ -157,6 +176,8 @@ const optionsMap = {
|
|
|
157
176
|
country_code: validators.countryCode,
|
|
158
177
|
search: validators.string,
|
|
159
178
|
slug: validators.string,
|
|
179
|
+
limit: validators.limit,
|
|
180
|
+
direction: validators.direction,
|
|
160
181
|
},
|
|
161
182
|
locations: {
|
|
162
183
|
page: validators.number,
|
package/lib/esm/Client.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RLLClient = void 0;
|
|
4
|
+
const application_1 = require("./types/application");
|
|
5
|
+
const fetcher_1 = require("./fetcher");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const Watcher_1 = require("./Watcher");
|
|
5
8
|
/**
|
|
6
9
|
* Class representing a RocketLaunch.Live client
|
|
7
10
|
* @class
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
class RLLClient {
|
|
10
13
|
apiKey;
|
|
11
14
|
config = {
|
|
12
15
|
keyInQueryParams: false,
|
|
@@ -22,12 +25,12 @@ export class RLLClient {
|
|
|
22
25
|
constructor(apiKey, options) {
|
|
23
26
|
// Validate API Key is a valid UUID format
|
|
24
27
|
// Constructor throws if not
|
|
25
|
-
this.apiKey = apiKeyValidator(apiKey);
|
|
28
|
+
this.apiKey = (0, utils_1.apiKeyValidator)(apiKey);
|
|
26
29
|
if (!options) {
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
32
|
// Validate Options with warnings or throws
|
|
30
|
-
optionsValidator(options);
|
|
33
|
+
(0, utils_1.optionsValidator)(options);
|
|
31
34
|
if (options.keyInQueryParams) {
|
|
32
35
|
this.config.keyInQueryParams = options.keyInQueryParams;
|
|
33
36
|
}
|
|
@@ -45,7 +48,7 @@ export class RLLClient {
|
|
|
45
48
|
* @returns {Promise<T>}
|
|
46
49
|
*/
|
|
47
50
|
query(endpoint, params) {
|
|
48
|
-
return fetcher(this.apiKey, endpoint, params, this.config.keyInQueryParams);
|
|
51
|
+
return (0, fetcher_1.fetcher)(this.apiKey, endpoint, params, this.config.keyInQueryParams);
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Instantiate a new RLL Watcher which will continually query the API for changes to the launches endpoint
|
|
@@ -58,7 +61,7 @@ export class RLLClient {
|
|
|
58
61
|
* @returns {RLLWatcher}
|
|
59
62
|
*/
|
|
60
63
|
watch(interval, options) {
|
|
61
|
-
return new RLLWatcher((params) => this.query(RLLEndPoint.LAUNCHES, params), interval, options);
|
|
64
|
+
return new Watcher_1.RLLWatcher((params) => this.query(application_1.RLLEndPoint.LAUNCHES, params), interval, options);
|
|
62
65
|
}
|
|
63
66
|
/**
|
|
64
67
|
* Fetch launch companies
|
|
@@ -80,8 +83,8 @@ export class RLLClient {
|
|
|
80
83
|
* const response = await client.companies({ country_code: "US" })
|
|
81
84
|
*/
|
|
82
85
|
companies(options) {
|
|
83
|
-
const params = queryOptionsValidator(RLLEndPoint.COMPANIES, options);
|
|
84
|
-
return this.query(RLLEndPoint.COMPANIES, params);
|
|
86
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.COMPANIES, options);
|
|
87
|
+
return this.query(application_1.RLLEndPoint.COMPANIES, params);
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
87
90
|
* Fetch launches
|
|
@@ -113,8 +116,8 @@ export class RLLClient {
|
|
|
113
116
|
* const response = await client.launches({ after_date: new Date("2022-10-10") })
|
|
114
117
|
*/
|
|
115
118
|
launches(options) {
|
|
116
|
-
const params = queryOptionsValidator(RLLEndPoint.LAUNCHES, options);
|
|
117
|
-
return this.query(RLLEndPoint.LAUNCHES, params);
|
|
119
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.LAUNCHES, options);
|
|
120
|
+
return this.query(application_1.RLLEndPoint.LAUNCHES, params);
|
|
118
121
|
}
|
|
119
122
|
/**
|
|
120
123
|
* Fetch launch locations
|
|
@@ -136,8 +139,8 @@ export class RLLClient {
|
|
|
136
139
|
* const response = await client.locations({ country_code: "US" })
|
|
137
140
|
*/
|
|
138
141
|
locations(options) {
|
|
139
|
-
const params = queryOptionsValidator(RLLEndPoint.LOCATIONS, options);
|
|
140
|
-
return this.query(RLLEndPoint.LOCATIONS, params);
|
|
142
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.LOCATIONS, options);
|
|
143
|
+
return this.query(application_1.RLLEndPoint.LOCATIONS, params);
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
143
146
|
* Fetch launch Missions
|
|
@@ -157,8 +160,8 @@ export class RLLClient {
|
|
|
157
160
|
* const response = await client.missions({ name: "Mars 2020" })
|
|
158
161
|
*/
|
|
159
162
|
missions(options) {
|
|
160
|
-
const params = queryOptionsValidator(RLLEndPoint.MISSIONS, options);
|
|
161
|
-
return this.query(RLLEndPoint.MISSIONS, params);
|
|
163
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.MISSIONS, options);
|
|
164
|
+
return this.query(application_1.RLLEndPoint.MISSIONS, params);
|
|
162
165
|
}
|
|
163
166
|
/**
|
|
164
167
|
* Fetch launch pads
|
|
@@ -180,8 +183,8 @@ export class RLLClient {
|
|
|
180
183
|
* const response = await client.pads({ country_code: "US" })
|
|
181
184
|
*/
|
|
182
185
|
pads(options) {
|
|
183
|
-
const params = queryOptionsValidator(RLLEndPoint.PADS, options);
|
|
184
|
-
return this.query(RLLEndPoint.PADS, params);
|
|
186
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.PADS, options);
|
|
187
|
+
return this.query(application_1.RLLEndPoint.PADS, params);
|
|
185
188
|
}
|
|
186
189
|
/**
|
|
187
190
|
* Fetch launch tags
|
|
@@ -201,8 +204,8 @@ export class RLLClient {
|
|
|
201
204
|
* const response = await client.tags({ text: "Crewed" })
|
|
202
205
|
*/
|
|
203
206
|
tags(options) {
|
|
204
|
-
const params = queryOptionsValidator(RLLEndPoint.TAGS, options);
|
|
205
|
-
return this.query(RLLEndPoint.TAGS, params);
|
|
207
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.TAGS, options);
|
|
208
|
+
return this.query(application_1.RLLEndPoint.TAGS, params);
|
|
206
209
|
}
|
|
207
210
|
/**
|
|
208
211
|
* Fetch launch Vehicles
|
|
@@ -222,7 +225,8 @@ export class RLLClient {
|
|
|
222
225
|
* const response = await client.vehicles({ name: "Falcon 9" })
|
|
223
226
|
*/
|
|
224
227
|
vehicles(options) {
|
|
225
|
-
const params = queryOptionsValidator(RLLEndPoint.VEHICLES, options);
|
|
226
|
-
return this.query(RLLEndPoint.VEHICLES, params);
|
|
228
|
+
const params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.VEHICLES, options);
|
|
229
|
+
return this.query(application_1.RLLEndPoint.VEHICLES, params);
|
|
227
230
|
}
|
|
228
231
|
}
|
|
232
|
+
exports.RLLClient = RLLClient;
|
package/lib/esm/Watcher.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RLLWatcher = void 0;
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
const application_1 = require("./types/application");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
4
10
|
const DEFAULT_INTERVAL_IN_MINS = 5;
|
|
5
11
|
const MS_IN_MIN = 60000;
|
|
6
12
|
const intervalValidator = (interval) => {
|
|
7
13
|
if (typeof interval !== "number" && typeof interval !== "string") {
|
|
8
|
-
error("RLLWatcher interval must be a number.");
|
|
14
|
+
(0, utils_1.error)("RLLWatcher interval must be a number.");
|
|
9
15
|
return DEFAULT_INTERVAL_IN_MINS;
|
|
10
16
|
}
|
|
11
17
|
if (typeof interval === "string" &&
|
|
12
18
|
(isNaN(Number(interval)) || interval === "")) {
|
|
13
|
-
error("RLLWatcher interval must be a number.", "type");
|
|
19
|
+
(0, utils_1.error)("RLLWatcher interval must be a number.", "type");
|
|
14
20
|
return DEFAULT_INTERVAL_IN_MINS;
|
|
15
21
|
}
|
|
16
22
|
const typedInterval = Number(interval);
|
|
17
23
|
if (typedInterval <= 0) {
|
|
18
|
-
error("RLLWatcher interval cannot be a negative number or zero. Watcher intervals should be greater than or equal to 1 minute.");
|
|
24
|
+
(0, utils_1.error)("RLLWatcher interval cannot be a negative number or zero. Watcher intervals should be greater than or equal to 1 minute.");
|
|
19
25
|
return DEFAULT_INTERVAL_IN_MINS;
|
|
20
26
|
}
|
|
21
27
|
if (typedInterval < 1) {
|
|
22
|
-
warn("RLLWatcher does not accept intervals less than 1. Your watcher will default to 5 minute intervals unless corrected.");
|
|
28
|
+
(0, utils_1.warn)("RLLWatcher does not accept intervals less than 1. Your watcher will default to 5 minute intervals unless corrected.");
|
|
23
29
|
return DEFAULT_INTERVAL_IN_MINS;
|
|
24
30
|
}
|
|
25
31
|
return typedInterval;
|
|
@@ -28,11 +34,9 @@ const intervalValidator = (interval) => {
|
|
|
28
34
|
* Class representing a RocketLaunch.Live Client Watcher
|
|
29
35
|
* @class
|
|
30
36
|
*/
|
|
31
|
-
|
|
32
|
-
_untypedOn
|
|
33
|
-
_untypedEmit
|
|
34
|
-
on = (event, listener) => this._untypedOn(event, listener);
|
|
35
|
-
emit = (event, ...args) => this._untypedEmit(event, ...args);
|
|
37
|
+
class RLLWatcher extends events_1.default {
|
|
38
|
+
_untypedOn;
|
|
39
|
+
_untypedEmit;
|
|
36
40
|
last_call;
|
|
37
41
|
launches = new Map();
|
|
38
42
|
interval;
|
|
@@ -64,10 +68,18 @@ export class RLLWatcher extends EventEmitter {
|
|
|
64
68
|
*/
|
|
65
69
|
constructor(fetcher, interval = DEFAULT_INTERVAL_IN_MINS, options) {
|
|
66
70
|
super();
|
|
71
|
+
// Reassign default Event Emitter methods
|
|
72
|
+
this._untypedOn = this.on;
|
|
73
|
+
this._untypedEmit = this.emit;
|
|
74
|
+
// Methord Overide for type safety
|
|
75
|
+
this.on = (event, listener) => this._untypedOn(event, listener);
|
|
76
|
+
this.emit = (event, ...args) => this._untypedEmit(event, ...args);
|
|
67
77
|
this.last_call = new Date();
|
|
68
78
|
this.fetcher = fetcher;
|
|
69
79
|
this.interval = intervalValidator(interval);
|
|
70
|
-
this.params = queryOptionsValidator(RLLEndPoint.LAUNCHES, options);
|
|
80
|
+
this.params = (0, utils_1.queryOptionsValidator)(application_1.RLLEndPoint.LAUNCHES, options);
|
|
81
|
+
// ignore any limit params as these cause unnecessary API calls and do not serve the Watcher role
|
|
82
|
+
this.params.delete("limit");
|
|
71
83
|
}
|
|
72
84
|
/**
|
|
73
85
|
* Recursive API Caller to iterate through pages
|
|
@@ -118,7 +130,7 @@ export class RLLWatcher extends EventEmitter {
|
|
|
118
130
|
this.launches.set(changedLaunch.id, changedLaunch);
|
|
119
131
|
}
|
|
120
132
|
};
|
|
121
|
-
this.params.set("modified_since", formatToRLLISODate(this.last_call));
|
|
133
|
+
this.params.set("modified_since", (0, utils_1.formatToRLLISODate)(this.last_call));
|
|
122
134
|
this.recursivelyFetch(new URLSearchParams(this.params), notify)
|
|
123
135
|
.then(() => {
|
|
124
136
|
this.last_call = new Date();
|
|
@@ -167,3 +179,4 @@ export class RLLWatcher extends EventEmitter {
|
|
|
167
179
|
}
|
|
168
180
|
}
|
|
169
181
|
}
|
|
182
|
+
exports.RLLWatcher = RLLWatcher;
|
package/lib/esm/fetcher.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetcher = void 0;
|
|
7
|
+
const https_1 = __importDefault(require("https"));
|
|
2
8
|
const BASE_URL = "https://fdo.rocketlaunch.live";
|
|
3
|
-
|
|
9
|
+
const fetcher = (apiKey, endpoint, params, keyInQueryParams) => {
|
|
4
10
|
const url = new URL("json/" + endpoint, BASE_URL);
|
|
5
11
|
let headers;
|
|
6
12
|
if (keyInQueryParams) {
|
|
@@ -12,9 +18,10 @@ export const fetcher = (apiKey, endpoint, params, keyInQueryParams) => {
|
|
|
12
18
|
params.forEach((v, k) => url.searchParams.set(k, v));
|
|
13
19
|
return query(url, headers);
|
|
14
20
|
};
|
|
21
|
+
exports.fetcher = fetcher;
|
|
15
22
|
const query = (url, headers) => {
|
|
16
23
|
return new Promise((resolve, reject) => {
|
|
17
|
-
const req =
|
|
24
|
+
const req = https_1.default.get(url, { headers }, (res) => {
|
|
18
25
|
let data = [];
|
|
19
26
|
res.on("data", (chunk) => data.push(chunk));
|
|
20
27
|
res.on("end", () => {
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rllc = exports.RLLWatcher = exports.RLLClient = exports.RLLEntity = exports.RLLEndPoint = void 0;
|
|
4
|
+
const Client_1 = require("./Client");
|
|
5
|
+
var application_1 = require("./types/application");
|
|
6
|
+
Object.defineProperty(exports, "RLLEndPoint", { enumerable: true, get: function () { return application_1.RLLEndPoint; } });
|
|
7
|
+
Object.defineProperty(exports, "RLLEntity", { enumerable: true, get: function () { return application_1.RLLEntity; } });
|
|
8
|
+
var Client_2 = require("./Client");
|
|
9
|
+
Object.defineProperty(exports, "RLLClient", { enumerable: true, get: function () { return Client_2.RLLClient; } });
|
|
10
|
+
var Watcher_1 = require("./Watcher");
|
|
11
|
+
Object.defineProperty(exports, "RLLWatcher", { enumerable: true, get: function () { return Watcher_1.RLLWatcher; } });
|
|
5
12
|
/**
|
|
6
13
|
* Generate a RocketLaunch.Live client
|
|
7
14
|
*
|
|
@@ -19,4 +26,5 @@ export { RLLWatcher } from "./Watcher";
|
|
|
19
26
|
* const MY_KEY = process.env.ROCKETLAUNCH_LIVE_API_KEY
|
|
20
27
|
* const client = rllc(MY_KEY, { keyInQueryParams: true })
|
|
21
28
|
*/
|
|
22
|
-
|
|
29
|
+
const rllc = (apiKey, options) => new Client_1.RLLClient(apiKey, options);
|
|
30
|
+
exports.rllc = rllc;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from "events";
|
|
3
|
-
import { RLLEntity,
|
|
4
|
-
interface IRLLWatcherEvent {
|
|
5
|
-
new: (launch: RLLEntity.Launch) => void;
|
|
6
|
-
change: (oldLaunch: RLLEntity.Launch, newLaunch: RLLEntity.Launch) => void;
|
|
7
|
-
error: (error: RLLError) => void;
|
|
8
|
-
ready: (launches: Map<number, RLLEntity.Launch>) => void;
|
|
9
|
-
init_error: (error: RLLError) => void;
|
|
10
|
-
call: (params: URLSearchParams) => void;
|
|
11
|
-
}
|
|
3
|
+
import { RLLEntity, RLLQueryConfig, RLLResponse } from "./types/application";
|
|
12
4
|
/**
|
|
13
5
|
* Class representing a RocketLaunch.Live Client Watcher
|
|
14
6
|
* @class
|
|
@@ -16,8 +8,6 @@ interface IRLLWatcherEvent {
|
|
|
16
8
|
export declare class RLLWatcher extends EventEmitter {
|
|
17
9
|
private _untypedOn;
|
|
18
10
|
private _untypedEmit;
|
|
19
|
-
on: <K extends keyof IRLLWatcherEvent>(event: K, listener: IRLLWatcherEvent[K]) => this;
|
|
20
|
-
emit: <K extends keyof IRLLWatcherEvent>(event: K, ...args: Parameters<IRLLWatcherEvent[K]>) => boolean;
|
|
21
11
|
private last_call;
|
|
22
12
|
launches: Map<number, RLLEntity.Launch>;
|
|
23
13
|
private interval;
|
|
@@ -88,5 +78,4 @@ export declare class RLLWatcher extends EventEmitter {
|
|
|
88
78
|
*/
|
|
89
79
|
stop(): void;
|
|
90
80
|
}
|
|
91
|
-
export {};
|
|
92
81
|
//# sourceMappingURL=Watcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/Watcher.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,SAAS,
|
|
1
|
+
{"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/Watcher.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,SAAS,EAET,cAAc,EAEd,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAqD7B;;;GAGG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,UAAU,CAGR;IACV,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,SAAS,CAAO;IACjB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAa;IAC3D,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,OAAO,CAE+B;IAE9C;;;;;;;;;;;;;;;;;;;;;;OAsBG;gBAED,OAAO,EAAE,CACP,MAAM,EAAE,eAAe,KACpB,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC7C,QAAQ,GAAE,MAAM,GAAG,MAAiC,EACpD,OAAO,CAAC,EAAE,cAAc,CAAC,QAAQ;IA4BnC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB,CAsBtB;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK;IAyBb;;;;;;;OAOG;IACI,KAAK,IAAI,IAAI;IAoBpB;;;;;;;OAOG;IACI,IAAI,IAAI,IAAI;CAKpB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RLLQueryParams = exports.RLLEntity = exports.RLLEndPoint = void 0;
|
|
4
|
+
var RLLEndPoint;
|
|
2
5
|
(function (RLLEndPoint) {
|
|
3
6
|
RLLEndPoint["COMPANIES"] = "companies";
|
|
4
7
|
RLLEndPoint["LAUNCHES"] = "launches";
|
|
@@ -7,8 +10,8 @@ export var RLLEndPoint;
|
|
|
7
10
|
RLLEndPoint["PADS"] = "pads";
|
|
8
11
|
RLLEndPoint["TAGS"] = "tags";
|
|
9
12
|
RLLEndPoint["VEHICLES"] = "vehicles";
|
|
10
|
-
})(RLLEndPoint || (RLLEndPoint = {}));
|
|
11
|
-
|
|
13
|
+
})(RLLEndPoint || (exports.RLLEndPoint = RLLEndPoint = {}));
|
|
14
|
+
var RLLEntity;
|
|
12
15
|
(function (RLLEntity) {
|
|
13
16
|
let LaunchResult;
|
|
14
17
|
(function (LaunchResult) {
|
|
@@ -18,8 +21,8 @@ export var RLLEntity;
|
|
|
18
21
|
LaunchResult[LaunchResult["PARTIAL_FAILURE"] = 2] = "PARTIAL_FAILURE";
|
|
19
22
|
LaunchResult[LaunchResult["IN_FLIGHT_ABORT_CREWED"] = 3] = "IN_FLIGHT_ABORT_CREWED";
|
|
20
23
|
})(LaunchResult = RLLEntity.LaunchResult || (RLLEntity.LaunchResult = {}));
|
|
21
|
-
})(RLLEntity || (RLLEntity = {}));
|
|
22
|
-
|
|
24
|
+
})(RLLEntity || (exports.RLLEntity = RLLEntity = {}));
|
|
25
|
+
exports.RLLQueryParams = {
|
|
23
26
|
id: true,
|
|
24
27
|
page: true,
|
|
25
28
|
name: true,
|
|
@@ -38,4 +41,6 @@ export const RLLQueryParams = {
|
|
|
38
41
|
search: true,
|
|
39
42
|
slug: true,
|
|
40
43
|
text: true,
|
|
44
|
+
limit: true,
|
|
45
|
+
direction: true,
|
|
41
46
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidStateCode = exports.isValidCountryCode = exports.usStateCodes = exports.countryCodes = void 0;
|
|
4
|
+
exports.countryCodes = {
|
|
2
5
|
AF: "AF",
|
|
3
6
|
AL: "AL",
|
|
4
7
|
DZ: "DZ",
|
|
@@ -249,7 +252,7 @@ export const countryCodes = {
|
|
|
249
252
|
ZW: "ZW",
|
|
250
253
|
AX: "AX",
|
|
251
254
|
};
|
|
252
|
-
|
|
255
|
+
exports.usStateCodes = {
|
|
253
256
|
AL: "AL",
|
|
254
257
|
AK: "AK",
|
|
255
258
|
AZ: "AZ",
|
|
@@ -308,9 +311,11 @@ export const usStateCodes = {
|
|
|
308
311
|
UM: "UM",
|
|
309
312
|
VI: "VI",
|
|
310
313
|
};
|
|
311
|
-
|
|
312
|
-
return !!countryCodes[code];
|
|
314
|
+
const isValidCountryCode = (code) => {
|
|
315
|
+
return !!exports.countryCodes[code];
|
|
313
316
|
};
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
exports.isValidCountryCode = isValidCountryCode;
|
|
318
|
+
const isValidStateCode = (code) => {
|
|
319
|
+
return !!exports.usStateCodes[code];
|
|
316
320
|
};
|
|
321
|
+
exports.isValidStateCode = isValidStateCode;
|
|
@@ -23,7 +23,7 @@ export declare namespace RLLEntity {
|
|
|
23
23
|
export interface Company extends RLLRecord {
|
|
24
24
|
name: string;
|
|
25
25
|
country: Country;
|
|
26
|
-
inactive: boolean
|
|
26
|
+
inactive: boolean;
|
|
27
27
|
}
|
|
28
28
|
export enum LaunchResult {
|
|
29
29
|
NOT_SET = -1,
|
|
@@ -135,6 +135,8 @@ export declare const RLLQueryParams: {
|
|
|
135
135
|
search: boolean;
|
|
136
136
|
slug: boolean;
|
|
137
137
|
text: boolean;
|
|
138
|
+
limit: boolean;
|
|
139
|
+
direction: boolean;
|
|
138
140
|
};
|
|
139
141
|
export declare namespace RLLQueryConfig {
|
|
140
142
|
interface Base {
|
|
@@ -160,6 +162,8 @@ export declare namespace RLLQueryConfig {
|
|
|
160
162
|
country_code?: ISO3166Alpha2.CountryCode;
|
|
161
163
|
search?: string | number;
|
|
162
164
|
slug?: string | number;
|
|
165
|
+
limit?: number | string;
|
|
166
|
+
direction?: "asc" | "desc";
|
|
163
167
|
}
|
|
164
168
|
export interface Locations extends Base {
|
|
165
169
|
name?: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../src/types/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,yBAAiB,SAAS,CAAC;IACzB,UAAU,SAAS;QACjB,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,MAAM,WAAW,OAAO;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,aAAa,CAAC,WAAW,GAAG,EAAE,CAAC;KACtC;IAED,MAAM,WAAW,KAAK;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;KAClC;IAED,MAAM,WAAW,OAAQ,SAAQ,SAAS;QACxC,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../src/types/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,yBAAiB,SAAS,CAAC;IACzB,UAAU,SAAS;QACjB,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,MAAM,WAAW,OAAO;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,aAAa,CAAC,WAAW,GAAG,EAAE,CAAC;KACtC;IAED,MAAM,WAAW,KAAK;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;KAClC;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aAAa,CAAC,WAAW,CAAC;KAC1C;IAED,MAAM,WAAW,IAAK,SAAQ,IAAI;QAChC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB;IAED,MAAM,WAAW,QAAS,SAAQ,IAAI;QACpC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB;;CACF;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQlE,eAAO,MAAM,kBAAkB,SAAU,IAAI,KAAG,MAE/C,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,GAAG,KAAG,MA2B7C,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;MAEzB,IAeH,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQlE,eAAO,MAAM,kBAAkB,SAAU,IAAI,KAAG,MAE/C,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,GAAG,KAAG,MA2B7C,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;MAEzB,IAeH,CAAC;AAkLF,eAAO,MAAM,qBAAqB,aACtB,WAAW,YAEjB,eAAe,SAAS,GACxB,eAAe,QAAQ,GACvB,eAAe,SAAS,GACxB,eAAe,QAAQ,GACvB,eAAe,IAAI,GACnB,eAAe,IAAI,GACnB,eAAe,QAAQ,KAC1B,eAwDF,CAAC;AAEF,eAAO,MAAM,IAAI,QAAS,MAAM,SAAyC,CAAC;AAE1E,eAAO,MAAM,KAAK,QACX,MAAM,SACL,MAAM,GAAG,OAAO,GAAG,OAAO,KAC/B,IAYF,CAAC"}
|
package/lib/esm/utils.js
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.error = exports.warn = exports.queryOptionsValidator = exports.optionsValidator = exports.apiKeyValidator = exports.formatToRLLISODate = void 0;
|
|
4
|
+
const standards_1 = require("./types/standards");
|
|
2
5
|
const getLeadingZero = (month, offset = 0) => {
|
|
3
6
|
const str = "0".concat((month + offset).toString());
|
|
4
7
|
return str.slice(-2);
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
const formatToRLLISODate = (date) => {
|
|
7
10
|
return date.toISOString().slice(0, 19).concat("Z");
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
exports.formatToRLLISODate = formatToRLLISODate;
|
|
13
|
+
const apiKeyValidator = (apiKey) => {
|
|
10
14
|
if (apiKey === undefined) {
|
|
11
|
-
error("RLL Client requires API Key", "type");
|
|
15
|
+
(0, exports.error)("RLL Client requires API Key", "type");
|
|
12
16
|
}
|
|
13
17
|
if (typeof apiKey !== "string") {
|
|
14
|
-
error("RLL Client API Key must be a string", "type");
|
|
18
|
+
(0, exports.error)("RLL Client API Key must be a string", "type");
|
|
15
19
|
}
|
|
16
20
|
const trimmedKey = apiKey.trim();
|
|
17
21
|
if (trimmedKey === "") {
|
|
18
|
-
error("RLL Client API Key cannot be an empty string", "type");
|
|
22
|
+
(0, exports.error)("RLL Client API Key cannot be an empty string", "type");
|
|
19
23
|
}
|
|
20
24
|
const validator = trimmedKey.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
|
21
25
|
if (validator === null) {
|
|
22
|
-
error("RLL Client API Key appears malformed. RLL Client API Keys are in UUID format.", "type");
|
|
26
|
+
(0, exports.error)("RLL Client API Key appears malformed. RLL Client API Keys are in UUID format.", "type");
|
|
23
27
|
}
|
|
24
28
|
return trimmedKey;
|
|
25
29
|
};
|
|
26
|
-
|
|
30
|
+
exports.apiKeyValidator = apiKeyValidator;
|
|
31
|
+
const optionsValidator = (options) => {
|
|
27
32
|
for (const option in options) {
|
|
28
33
|
if (option !== "keyInQueryParams") {
|
|
29
|
-
warn(`RLL Client options do not accept a "${option}" property. This property will be ignored.`);
|
|
34
|
+
(0, exports.warn)(`RLL Client options do not accept a "${option}" property. This property will be ignored.`);
|
|
30
35
|
}
|
|
31
36
|
else {
|
|
32
37
|
if (typeof options[option] !== "boolean") {
|
|
33
|
-
error("RLL Client configuration option 'keyInQueryParams' must be a boolean.", "type");
|
|
38
|
+
(0, exports.error)("RLL Client configuration option 'keyInQueryParams' must be a boolean.", "type");
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
};
|
|
43
|
+
exports.optionsValidator = optionsValidator;
|
|
38
44
|
const validators = {
|
|
39
45
|
string: (option) => {
|
|
40
46
|
if (typeof option === "number") {
|
|
@@ -69,7 +75,7 @@ const validators = {
|
|
|
69
75
|
if (typeof option !== "string") {
|
|
70
76
|
throw "Must be a string";
|
|
71
77
|
}
|
|
72
|
-
if (!isValidCountryCode(option)) {
|
|
78
|
+
if (!(0, standards_1.isValidCountryCode)(option)) {
|
|
73
79
|
throw "Invalid country code. Country codes should follow ISO 3166-1 A2 convention, like 'US'.";
|
|
74
80
|
}
|
|
75
81
|
return option;
|
|
@@ -78,7 +84,7 @@ const validators = {
|
|
|
78
84
|
if (typeof option !== "string") {
|
|
79
85
|
throw "Must be a string";
|
|
80
86
|
}
|
|
81
|
-
if (!isValidStateCode(option)) {
|
|
87
|
+
if (!(0, standards_1.isValidStateCode)(option)) {
|
|
82
88
|
throw "Invalid United States State Code. State Codes should follow ISO 3166-2 convention, like 'FL'.";
|
|
83
89
|
}
|
|
84
90
|
return option;
|
|
@@ -124,7 +130,26 @@ const validators = {
|
|
|
124
130
|
else {
|
|
125
131
|
date = option;
|
|
126
132
|
}
|
|
127
|
-
return formatToRLLISODate(date);
|
|
133
|
+
return (0, exports.formatToRLLISODate)(date);
|
|
134
|
+
},
|
|
135
|
+
limit: (option) => {
|
|
136
|
+
const num = validators.number(option);
|
|
137
|
+
if (num < 1) {
|
|
138
|
+
throw "Must be a number greater than 0";
|
|
139
|
+
}
|
|
140
|
+
if (num > 25) {
|
|
141
|
+
throw "Must be a number less than 26";
|
|
142
|
+
}
|
|
143
|
+
return num;
|
|
144
|
+
},
|
|
145
|
+
direction: (option) => {
|
|
146
|
+
if (typeof option !== "string") {
|
|
147
|
+
throw "Must be a string";
|
|
148
|
+
}
|
|
149
|
+
if (option !== "asc" && option !== "desc") {
|
|
150
|
+
throw 'String must be either "asc" or "desc"';
|
|
151
|
+
}
|
|
152
|
+
return option;
|
|
128
153
|
},
|
|
129
154
|
};
|
|
130
155
|
const optionsMap = {
|
|
@@ -151,6 +176,8 @@ const optionsMap = {
|
|
|
151
176
|
country_code: validators.countryCode,
|
|
152
177
|
search: validators.string,
|
|
153
178
|
slug: validators.string,
|
|
179
|
+
limit: validators.limit,
|
|
180
|
+
direction: validators.direction,
|
|
154
181
|
},
|
|
155
182
|
locations: {
|
|
156
183
|
page: validators.number,
|
|
@@ -182,7 +209,7 @@ const optionsMap = {
|
|
|
182
209
|
name: validators.string,
|
|
183
210
|
},
|
|
184
211
|
};
|
|
185
|
-
|
|
212
|
+
const queryOptionsValidator = (resource, options) => {
|
|
186
213
|
const params = new URLSearchParams();
|
|
187
214
|
if (options === undefined) {
|
|
188
215
|
return params;
|
|
@@ -195,19 +222,19 @@ export const queryOptionsValidator = (resource, options) => {
|
|
|
195
222
|
typeof options === "function" ||
|
|
196
223
|
options === null ||
|
|
197
224
|
Array.isArray(options)) {
|
|
198
|
-
error("Invalid type for query options. Must be an object.");
|
|
225
|
+
(0, exports.error)("Invalid type for query options. Must be an object.");
|
|
199
226
|
}
|
|
200
227
|
if ((options.id || "slug" in options || "cospar_id" in options) &&
|
|
201
228
|
Object.keys(options).length > 1) {
|
|
202
|
-
warn("Using 'id', 'slug', or 'cospar_id' as query parameters generally returns a single result. Combining it with other parameters may not be achieving the result you expect.");
|
|
229
|
+
(0, exports.warn)("Using 'id', 'slug', or 'cospar_id' as query parameters generally returns a single result. Combining it with other parameters may not be achieving the result you expect.");
|
|
203
230
|
}
|
|
204
231
|
for (const option in options) {
|
|
205
232
|
if (!(option in optionsMap[resource])) {
|
|
206
|
-
warn(`Parameter "${option}" is not a valid option for the ${resource} endpoint. It will be ignored.`);
|
|
233
|
+
(0, exports.warn)(`Parameter "${option}" is not a valid option for the ${resource} endpoint. It will be ignored.`);
|
|
207
234
|
continue;
|
|
208
235
|
}
|
|
209
236
|
if (options[option] === undefined) {
|
|
210
|
-
warn(`Parameter "${option}" is undefined and will be ignored.`);
|
|
237
|
+
(0, exports.warn)(`Parameter "${option}" is undefined and will be ignored.`);
|
|
211
238
|
continue;
|
|
212
239
|
}
|
|
213
240
|
try {
|
|
@@ -215,13 +242,15 @@ export const queryOptionsValidator = (resource, options) => {
|
|
|
215
242
|
params.set(option, o);
|
|
216
243
|
}
|
|
217
244
|
catch (err) {
|
|
218
|
-
error(`Malformed query parameter for resource "${resource}" and parameter: "${option}": ${err}.`, "type");
|
|
245
|
+
(0, exports.error)(`Malformed query parameter for resource "${resource}" and parameter: "${option}": ${err}.`, "type");
|
|
219
246
|
}
|
|
220
247
|
}
|
|
221
248
|
return params;
|
|
222
249
|
};
|
|
223
|
-
|
|
224
|
-
|
|
250
|
+
exports.queryOptionsValidator = queryOptionsValidator;
|
|
251
|
+
const warn = (msg) => console.warn(`[RLL Client]: ${msg}`);
|
|
252
|
+
exports.warn = warn;
|
|
253
|
+
const error = (msg, type = "error") => {
|
|
225
254
|
switch (type) {
|
|
226
255
|
case "error": {
|
|
227
256
|
throw new Error(`[RLL Client]: ${msg}`);
|
|
@@ -234,3 +263,4 @@ export const error = (msg, type = "error") => {
|
|
|
234
263
|
}
|
|
235
264
|
}
|
|
236
265
|
};
|
|
266
|
+
exports.error = error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rocket-launch-live-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A Node.JS client for interacting with the RocketLaunch.Live API",
|
|
5
5
|
"types": "./lib/cjs/types/index.d.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -30,20 +30,19 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/mendahu/rocket-launch-live-client#readme",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/chai": "^4.3.
|
|
33
|
+
"@types/chai": "^4.3.5",
|
|
34
34
|
"@types/chai-as-promised": "^7.1.5",
|
|
35
35
|
"@types/mocha": "^10.0.1",
|
|
36
|
-
"@types/node": "^
|
|
37
|
-
"@types/sinon": "^10.0.
|
|
38
|
-
"chai": "^4.3.
|
|
36
|
+
"@types/node": "^20.5.6",
|
|
37
|
+
"@types/sinon": "^10.0.16",
|
|
38
|
+
"chai": "^4.3.8",
|
|
39
39
|
"chai-as-promised": "^7.1.1",
|
|
40
|
-
"dotenv": "^16.
|
|
40
|
+
"dotenv": "^16.3.1",
|
|
41
41
|
"mocha": "^10.2.0",
|
|
42
|
-
"nock": "^13.3.
|
|
43
|
-
"
|
|
44
|
-
"sinon": "^15.0.1",
|
|
42
|
+
"nock": "^13.3.3",
|
|
43
|
+
"sinon": "^15.2.0",
|
|
45
44
|
"ts-node": "^10.9.1",
|
|
46
|
-
"typescript": "^
|
|
45
|
+
"typescript": "^5.2.2"
|
|
47
46
|
},
|
|
48
47
|
"files": [
|
|
49
48
|
"lib/**/*"
|