rocket-launch-live-client 0.2.1 → 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 +197 -5
- package/lib/cjs/Client.js +35 -14
- package/lib/cjs/Watcher.js +175 -0
- package/lib/cjs/fetcher.js +18 -10
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/types/Client.d.ts +19 -7
- package/lib/cjs/types/Client.d.ts.map +1 -1
- package/lib/cjs/types/Watcher.d.ts +81 -0
- package/lib/cjs/types/Watcher.d.ts.map +1 -0
- package/lib/cjs/types/application.js +4 -2
- package/lib/cjs/types/fetcher.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +2 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/types/application.d.ts +38 -15
- package/lib/cjs/types/types/application.d.ts.map +1 -1
- package/lib/cjs/types/utils.d.ts +2 -1
- package/lib/cjs/types/utils.d.ts.map +1 -1
- package/lib/cjs/utils.js +118 -101
- package/lib/esm/Client.js +46 -21
- package/lib/esm/Watcher.js +182 -0
- package/lib/esm/fetcher.js +27 -13
- package/lib/esm/index.mjs +13 -4
- package/lib/esm/types/Client.d.ts +19 -7
- package/lib/esm/types/Client.d.ts.map +1 -1
- package/lib/esm/types/Watcher.d.ts +81 -0
- package/lib/esm/types/Watcher.d.ts.map +1 -0
- package/lib/esm/types/application.js +10 -5
- package/lib/esm/types/fetcher.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +2 -1
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/standards.js +11 -6
- package/lib/esm/types/types/application.d.ts +38 -15
- package/lib/esm/types/types/application.d.ts.map +1 -1
- package/lib/esm/types/utils.d.ts +2 -1
- package/lib/esm/types/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +140 -115
- package/package.json +9 -13
|
@@ -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;
|
|
@@ -14,15 +14,16 @@ export declare namespace RLLEntity {
|
|
|
14
14
|
}
|
|
15
15
|
export interface Country {
|
|
16
16
|
name: string;
|
|
17
|
-
code: ISO3166Alpha2.CountryCode;
|
|
17
|
+
code: ISO3166Alpha2.CountryCode | "";
|
|
18
18
|
}
|
|
19
19
|
export interface State {
|
|
20
20
|
name: string;
|
|
21
|
-
abbr
|
|
21
|
+
abbr?: ISO3166Alpha2.StateCodeUS;
|
|
22
22
|
}
|
|
23
23
|
export interface Company extends RLLRecord {
|
|
24
|
+
name: string;
|
|
24
25
|
country: Country;
|
|
25
|
-
inactive: boolean
|
|
26
|
+
inactive: boolean;
|
|
26
27
|
}
|
|
27
28
|
export enum LaunchResult {
|
|
28
29
|
NOT_SET = -1,
|
|
@@ -40,12 +41,23 @@ export declare namespace RLLEntity {
|
|
|
40
41
|
}
|
|
41
42
|
export interface Launch extends RLLRecord {
|
|
42
43
|
name: string;
|
|
43
|
-
cospar_id: string;
|
|
44
|
+
cospar_id: string | null;
|
|
44
45
|
sort_date: string;
|
|
45
|
-
provider:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
provider: {
|
|
47
|
+
slug: string;
|
|
48
|
+
} & Omit<Company, "inactive" | "country">;
|
|
49
|
+
vehicle: {
|
|
50
|
+
company_id: number;
|
|
51
|
+
slug: string;
|
|
52
|
+
} & Omit<Vehicle, "company">;
|
|
53
|
+
pad: Omit<Pad, "full_name" | "location"> & {
|
|
54
|
+
location: Omit<Location, "pads" | "utc_offset" | "latitute" | "latitude" | "longitude" | "country" | "state"> & {
|
|
55
|
+
slug: string;
|
|
56
|
+
country: string;
|
|
57
|
+
state: ISO3166Alpha2.StateCodeUS | null;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
missions: Omit<Mission, "launch_id" | "company">[];
|
|
49
61
|
mission_description: string | null;
|
|
50
62
|
launch_description: string;
|
|
51
63
|
win_open: string | null;
|
|
@@ -61,6 +73,8 @@ export declare namespace RLLEntity {
|
|
|
61
73
|
tags: Omit<Tag, "slug">[];
|
|
62
74
|
slug: string;
|
|
63
75
|
weather_summary: string | null;
|
|
76
|
+
weather_condition: string | null;
|
|
77
|
+
weather_wind_mph: number | null;
|
|
64
78
|
weather_temp: number | null;
|
|
65
79
|
weather_icon: string | null;
|
|
66
80
|
weather_updated: string | null;
|
|
@@ -77,20 +91,20 @@ export declare namespace RLLEntity {
|
|
|
77
91
|
longitude: string;
|
|
78
92
|
state: State | null;
|
|
79
93
|
statename?: string | null;
|
|
80
|
-
country: Country;
|
|
81
|
-
pads: Omit<Pad, "location" | "country" | "state">[];
|
|
82
|
-
utc_offset: number;
|
|
94
|
+
country: Country | null;
|
|
95
|
+
pads: Omit<Pad, "full_name" | "location" | "country" | "state">[];
|
|
96
|
+
utc_offset: number | null;
|
|
83
97
|
}
|
|
84
98
|
export interface Mission extends RLLRecord {
|
|
85
99
|
name: string;
|
|
86
100
|
description: string | null;
|
|
87
101
|
launch_id: number;
|
|
88
|
-
company: Omit<Company, "
|
|
102
|
+
company: Omit<Company, "inactive" | "country">;
|
|
89
103
|
}
|
|
90
104
|
export interface Pad extends RLLRecord {
|
|
91
105
|
name: string;
|
|
92
106
|
full_name: string;
|
|
93
|
-
location: Omit<Location, "pads" | "utc_offset" | "latitute">;
|
|
107
|
+
location: Omit<Location, "pads" | "utc_offset" | "latitute" | "statename">;
|
|
94
108
|
}
|
|
95
109
|
export interface Tag extends RLLRecord {
|
|
96
110
|
text: string;
|
|
@@ -98,8 +112,7 @@ export declare namespace RLLEntity {
|
|
|
98
112
|
}
|
|
99
113
|
export interface Vehicle extends RLLRecord {
|
|
100
114
|
name: string;
|
|
101
|
-
|
|
102
|
-
company: Omit<Company, "slug" | "inactive" | "country">;
|
|
115
|
+
company: Omit<Company, "inactive" | "country">;
|
|
103
116
|
}
|
|
104
117
|
export {};
|
|
105
118
|
}
|
|
@@ -122,6 +135,8 @@ export declare const RLLQueryParams: {
|
|
|
122
135
|
search: boolean;
|
|
123
136
|
slug: boolean;
|
|
124
137
|
text: boolean;
|
|
138
|
+
limit: boolean;
|
|
139
|
+
direction: boolean;
|
|
125
140
|
};
|
|
126
141
|
export declare namespace RLLQueryConfig {
|
|
127
142
|
interface Base {
|
|
@@ -147,6 +162,8 @@ export declare namespace RLLQueryConfig {
|
|
|
147
162
|
country_code?: ISO3166Alpha2.CountryCode;
|
|
148
163
|
search?: string | number;
|
|
149
164
|
slug?: string | number;
|
|
165
|
+
limit?: number | string;
|
|
166
|
+
direction?: "asc" | "desc";
|
|
150
167
|
}
|
|
151
168
|
export interface Locations extends Base {
|
|
152
169
|
name?: string | number;
|
|
@@ -181,4 +198,10 @@ export type RLLResponse<T> = {
|
|
|
181
198
|
last_page: number;
|
|
182
199
|
result: T;
|
|
183
200
|
};
|
|
201
|
+
export type RLLError = {
|
|
202
|
+
error: string;
|
|
203
|
+
statusCode: number | null;
|
|
204
|
+
message: string;
|
|
205
|
+
server_response: string | null;
|
|
206
|
+
};
|
|
184
207
|
//# sourceMappingURL=application.d.ts.map
|
|
@@ -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,CAAC;
|
|
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,CAA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C,EAAE,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"}
|
package/lib/esm/types/utils.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RLLEndPoint, RLLQueryConfig } from "./types/application";
|
|
2
|
+
export declare const formatToRLLISODate: (date: Date) => string;
|
|
2
3
|
export declare const apiKeyValidator: (apiKey: any) => string;
|
|
3
4
|
export declare const optionsValidator: (options: {
|
|
4
5
|
[key: string]: any;
|
|
5
6
|
[key: number]: any;
|
|
6
7
|
[key: symbol]: any;
|
|
7
8
|
}) => void;
|
|
8
|
-
export declare const queryOptionsValidator: (resource: RLLEndPoint, options?: RLLQueryConfig.Companies | RLLQueryConfig.Launches | RLLQueryConfig.Locations | RLLQueryConfig.Missions | RLLQueryConfig.Pads | RLLQueryConfig.Tags | RLLQueryConfig.Vehicles) =>
|
|
9
|
+
export declare const queryOptionsValidator: (resource: RLLEndPoint, options?: RLLQueryConfig.Companies | RLLQueryConfig.Launches | RLLQueryConfig.Locations | RLLQueryConfig.Missions | RLLQueryConfig.Pads | RLLQueryConfig.Tags | RLLQueryConfig.Vehicles) => URLSearchParams;
|
|
9
10
|
export declare const warn: (msg: string) => void;
|
|
10
11
|
export declare const error: (msg: string, type?: "type" | "range" | "error") => void;
|
|
11
12
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -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,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,145 +1,155 @@
|
|
|
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) => {
|
|
10
|
+
return date.toISOString().slice(0, 19).concat("Z");
|
|
11
|
+
};
|
|
12
|
+
exports.formatToRLLISODate = formatToRLLISODate;
|
|
13
|
+
const apiKeyValidator = (apiKey) => {
|
|
7
14
|
if (apiKey === undefined) {
|
|
8
|
-
error("RLL Client requires API Key", "type");
|
|
15
|
+
(0, exports.error)("RLL Client requires API Key", "type");
|
|
9
16
|
}
|
|
10
17
|
if (typeof apiKey !== "string") {
|
|
11
|
-
error("RLL Client API Key must be a string", "type");
|
|
18
|
+
(0, exports.error)("RLL Client API Key must be a string", "type");
|
|
12
19
|
}
|
|
13
20
|
const trimmedKey = apiKey.trim();
|
|
14
21
|
if (trimmedKey === "") {
|
|
15
|
-
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");
|
|
16
23
|
}
|
|
17
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);
|
|
18
25
|
if (validator === null) {
|
|
19
|
-
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");
|
|
20
27
|
}
|
|
21
28
|
return trimmedKey;
|
|
22
29
|
};
|
|
23
|
-
|
|
30
|
+
exports.apiKeyValidator = apiKeyValidator;
|
|
31
|
+
const optionsValidator = (options) => {
|
|
24
32
|
for (const option in options) {
|
|
25
33
|
if (option !== "keyInQueryParams") {
|
|
26
|
-
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.`);
|
|
27
35
|
}
|
|
28
36
|
else {
|
|
29
37
|
if (typeof options[option] !== "boolean") {
|
|
30
|
-
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");
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
};
|
|
43
|
+
exports.optionsValidator = optionsValidator;
|
|
35
44
|
const validators = {
|
|
36
45
|
string: (option) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
resolve(option);
|
|
48
|
-
});
|
|
46
|
+
if (typeof option === "number") {
|
|
47
|
+
return option.toString();
|
|
48
|
+
}
|
|
49
|
+
if (typeof option !== "string") {
|
|
50
|
+
throw "Must be a string";
|
|
51
|
+
}
|
|
52
|
+
if (option.length <= 0) {
|
|
53
|
+
throw "String must have length greater than 0";
|
|
54
|
+
}
|
|
55
|
+
return option;
|
|
49
56
|
},
|
|
50
57
|
boolean: (option) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
resolve(option === true ? 1 : 0);
|
|
56
|
-
});
|
|
58
|
+
if (typeof option !== "boolean") {
|
|
59
|
+
throw "Must be a boolean";
|
|
60
|
+
}
|
|
61
|
+
return option === true ? 1 : 0;
|
|
57
62
|
},
|
|
58
63
|
number: (option) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
else {
|
|
69
|
-
resolve(Number(option));
|
|
70
|
-
}
|
|
71
|
-
});
|
|
64
|
+
if (typeof option === "number") {
|
|
65
|
+
return option;
|
|
66
|
+
}
|
|
67
|
+
if (typeof option !== "string" || option === "" || isNaN(Number(option))) {
|
|
68
|
+
throw "Must be a number";
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return Number(option);
|
|
72
|
+
}
|
|
72
73
|
},
|
|
73
74
|
countryCode: (option) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
resolve(option);
|
|
82
|
-
});
|
|
75
|
+
if (typeof option !== "string") {
|
|
76
|
+
throw "Must be a string";
|
|
77
|
+
}
|
|
78
|
+
if (!(0, standards_1.isValidCountryCode)(option)) {
|
|
79
|
+
throw "Invalid country code. Country codes should follow ISO 3166-1 A2 convention, like 'US'.";
|
|
80
|
+
}
|
|
81
|
+
return option;
|
|
83
82
|
},
|
|
84
83
|
stateCode: (option) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
resolve(option);
|
|
93
|
-
});
|
|
84
|
+
if (typeof option !== "string") {
|
|
85
|
+
throw "Must be a string";
|
|
86
|
+
}
|
|
87
|
+
if (!(0, standards_1.isValidStateCode)(option)) {
|
|
88
|
+
throw "Invalid United States State Code. State Codes should follow ISO 3166-2 convention, like 'FL'.";
|
|
89
|
+
}
|
|
90
|
+
return option;
|
|
94
91
|
},
|
|
95
92
|
cosparId: (option) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
resolve(option);
|
|
104
|
-
});
|
|
93
|
+
if (typeof option !== "string") {
|
|
94
|
+
throw "Must be a string";
|
|
95
|
+
}
|
|
96
|
+
if (!option.match(/^\d{4}\-\d{3}$/g)) {
|
|
97
|
+
throw "Cospar IDs must be in the format of YYYY-NNN (eg. 2023-123)";
|
|
98
|
+
}
|
|
99
|
+
return option;
|
|
105
100
|
},
|
|
106
101
|
shortDate: (option) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
date = new Date(parsed);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
date = option;
|
|
119
|
-
}
|
|
120
|
-
resolve(`${date.getUTCFullYear()}-${getLeadingZero(date.getUTCMonth(), 1)}-${getLeadingZero(date.getUTCDate())}`);
|
|
102
|
+
if (typeof option !== "string" && !(option instanceof Date)) {
|
|
103
|
+
throw "Must be a JavaScript Date Object or ISO 8601 Date String";
|
|
104
|
+
}
|
|
105
|
+
let date;
|
|
106
|
+
if (typeof option === "string") {
|
|
107
|
+
const parsed = Date.parse(option);
|
|
108
|
+
if (isNaN(parsed)) {
|
|
109
|
+
throw "Must be an ISO 8601 Date String";
|
|
121
110
|
}
|
|
122
|
-
|
|
123
|
-
}
|
|
111
|
+
date = new Date(parsed);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
date = option;
|
|
115
|
+
}
|
|
116
|
+
return `${date.getUTCFullYear()}-${getLeadingZero(date.getUTCMonth(), 1)}-${getLeadingZero(date.getUTCDate())}`;
|
|
124
117
|
},
|
|
125
118
|
isoDate: (option) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
date = new Date(parsed);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
date = option;
|
|
138
|
-
}
|
|
139
|
-
resolve(date.toISOString().slice(0, 19).concat("Z"));
|
|
119
|
+
if (typeof option !== "string" && !(option instanceof Date)) {
|
|
120
|
+
throw "Must be a JavaScript Date Object or ISO 8601 Date String";
|
|
121
|
+
}
|
|
122
|
+
let date;
|
|
123
|
+
if (typeof option === "string") {
|
|
124
|
+
const parsed = Date.parse(option);
|
|
125
|
+
if (isNaN(parsed)) {
|
|
126
|
+
throw "Must be an ISO 8601 Date String";
|
|
140
127
|
}
|
|
141
|
-
|
|
142
|
-
}
|
|
128
|
+
date = new Date(parsed);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
date = option;
|
|
132
|
+
}
|
|
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;
|
|
143
153
|
},
|
|
144
154
|
};
|
|
145
155
|
const optionsMap = {
|
|
@@ -166,6 +176,8 @@ const optionsMap = {
|
|
|
166
176
|
country_code: validators.countryCode,
|
|
167
177
|
search: validators.string,
|
|
168
178
|
slug: validators.string,
|
|
179
|
+
limit: validators.limit,
|
|
180
|
+
direction: validators.direction,
|
|
169
181
|
},
|
|
170
182
|
locations: {
|
|
171
183
|
page: validators.number,
|
|
@@ -197,36 +209,48 @@ const optionsMap = {
|
|
|
197
209
|
name: validators.string,
|
|
198
210
|
},
|
|
199
211
|
};
|
|
200
|
-
|
|
212
|
+
const queryOptionsValidator = (resource, options) => {
|
|
201
213
|
const params = new URLSearchParams();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
214
|
+
if (options === undefined) {
|
|
215
|
+
return params;
|
|
216
|
+
}
|
|
217
|
+
if (typeof options === "string" ||
|
|
218
|
+
typeof options === "number" ||
|
|
219
|
+
typeof options === "boolean" ||
|
|
220
|
+
typeof options === "bigint" ||
|
|
221
|
+
typeof options === "symbol" ||
|
|
222
|
+
typeof options === "function" ||
|
|
223
|
+
options === null ||
|
|
224
|
+
Array.isArray(options)) {
|
|
225
|
+
(0, exports.error)("Invalid type for query options. Must be an object.");
|
|
205
226
|
}
|
|
206
227
|
if ((options.id || "slug" in options || "cospar_id" in options) &&
|
|
207
228
|
Object.keys(options).length > 1) {
|
|
208
|
-
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.");
|
|
209
230
|
}
|
|
210
231
|
for (const option in options) {
|
|
211
232
|
if (!(option in optionsMap[resource])) {
|
|
212
|
-
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.`);
|
|
213
234
|
continue;
|
|
214
235
|
}
|
|
215
236
|
if (options[option] === undefined) {
|
|
216
|
-
warn(`Parameter "${option}" is undefined and will be ignored.`);
|
|
237
|
+
(0, exports.warn)(`Parameter "${option}" is undefined and will be ignored.`);
|
|
217
238
|
continue;
|
|
218
239
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
240
|
+
try {
|
|
241
|
+
const o = optionsMap[resource][option](options[option]);
|
|
242
|
+
params.set(option, o);
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
(0, exports.error)(`Malformed query parameter for resource "${resource}" and parameter: "${option}": ${err}.`, "type");
|
|
246
|
+
}
|
|
225
247
|
}
|
|
226
|
-
return
|
|
248
|
+
return params;
|
|
227
249
|
};
|
|
228
|
-
|
|
229
|
-
|
|
250
|
+
exports.queryOptionsValidator = queryOptionsValidator;
|
|
251
|
+
const warn = (msg) => console.warn(`[RLL Client]: ${msg}`);
|
|
252
|
+
exports.warn = warn;
|
|
253
|
+
const error = (msg, type = "error") => {
|
|
230
254
|
switch (type) {
|
|
231
255
|
case "error": {
|
|
232
256
|
throw new Error(`[RLL Client]: ${msg}`);
|
|
@@ -239,3 +263,4 @@ export const error = (msg, type = "error") => {
|
|
|
239
263
|
}
|
|
240
264
|
}
|
|
241
265
|
};
|
|
266
|
+
exports.error = error;
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clear": "rm -rf ./lib",
|
|
9
|
-
"dev": "nodemon ./lib/test.js --ignore 'lib/**' -e ts --exec \"npm run compile\"",
|
|
10
|
-
"compile": "npm run clear && tsc && node ./lib/test.js",
|
|
11
9
|
"build": "npm run clear && npm run build:esm && npm run build:cjs",
|
|
12
10
|
"build:esm": "tsc -p ./configs/tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs",
|
|
13
11
|
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json",
|
|
14
|
-
"start": "node ./lib/test.js",
|
|
15
12
|
"prepublish": "npm run build",
|
|
16
13
|
"test": "mocha",
|
|
17
14
|
"test:watch": "mocha --watch"
|
|
@@ -33,20 +30,19 @@
|
|
|
33
30
|
},
|
|
34
31
|
"homepage": "https://github.com/mendahu/rocket-launch-live-client#readme",
|
|
35
32
|
"devDependencies": {
|
|
36
|
-
"@types/chai": "^4.3.
|
|
33
|
+
"@types/chai": "^4.3.5",
|
|
37
34
|
"@types/chai-as-promised": "^7.1.5",
|
|
38
35
|
"@types/mocha": "^10.0.1",
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"@types/sinon": "^10.0.
|
|
41
|
-
"chai": "^4.3.
|
|
36
|
+
"@types/node": "^20.5.6",
|
|
37
|
+
"@types/sinon": "^10.0.16",
|
|
38
|
+
"chai": "^4.3.8",
|
|
42
39
|
"chai-as-promised": "^7.1.1",
|
|
43
|
-
"dotenv": "^16.
|
|
40
|
+
"dotenv": "^16.3.1",
|
|
44
41
|
"mocha": "^10.2.0",
|
|
45
|
-
"nock": "^13.3.
|
|
46
|
-
"
|
|
47
|
-
"sinon": "^15.0.1",
|
|
42
|
+
"nock": "^13.3.3",
|
|
43
|
+
"sinon": "^15.2.0",
|
|
48
44
|
"ts-node": "^10.9.1",
|
|
49
|
-
"typescript": "^
|
|
45
|
+
"typescript": "^5.2.2"
|
|
50
46
|
},
|
|
51
47
|
"files": [
|
|
52
48
|
"lib/**/*"
|