rocket-launch-live-client 0.1.5 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/{dist → lib/cjs}/Client.js +32 -55
  2. package/{dist → lib/cjs}/fetcher.js +17 -15
  3. package/lib/cjs/index.js +28 -0
  4. package/{dist → lib/cjs/types}/Client.d.ts +2 -2
  5. package/lib/cjs/types/Client.d.ts.map +1 -0
  6. package/{dist → lib/cjs}/types/application.js +23 -4
  7. package/{dist → lib/cjs/types}/fetcher.d.ts +1 -0
  8. package/lib/cjs/types/fetcher.d.ts.map +1 -0
  9. package/lib/cjs/types/index.d.ts +24 -0
  10. package/lib/cjs/types/index.d.ts.map +1 -0
  11. package/lib/cjs/types/standards.js +321 -0
  12. package/{dist → lib/cjs/types}/types/application.d.ts +40 -21
  13. package/lib/cjs/types/types/application.d.ts.map +1 -0
  14. package/{dist → lib/cjs/types}/types/standards.d.ts +3 -0
  15. package/lib/cjs/types/types/standards.d.ts.map +1 -0
  16. package/lib/cjs/types/utils.d.ts +11 -0
  17. package/lib/cjs/types/utils.d.ts.map +1 -0
  18. package/{dist → lib/cjs}/utils.js +56 -60
  19. package/lib/esm/Client.js +207 -0
  20. package/lib/esm/fetcher.js +39 -0
  21. package/{dist/index.d.ts → lib/esm/index.mjs} +5 -6
  22. package/lib/esm/types/Client.d.ts +176 -0
  23. package/lib/esm/types/Client.d.ts.map +1 -0
  24. package/lib/esm/types/application.js +41 -0
  25. package/lib/esm/types/fetcher.d.ts +2 -0
  26. package/lib/esm/types/fetcher.d.ts.map +1 -0
  27. package/lib/esm/types/index.d.ts +24 -0
  28. package/lib/esm/types/index.d.ts.map +1 -0
  29. package/{dist → lib/esm}/types/standards.js +8 -6
  30. package/lib/esm/types/types/application.d.ts +184 -0
  31. package/lib/esm/types/types/application.d.ts.map +1 -0
  32. package/lib/esm/types/types/standards.d.ts +317 -0
  33. package/lib/esm/types/types/standards.d.ts.map +1 -0
  34. package/lib/esm/types/utils.d.ts +11 -0
  35. package/lib/esm/types/utils.d.ts.map +1 -0
  36. package/lib/esm/utils.js +241 -0
  37. package/package.json +32 -10
  38. package/dist/Client.js.map +0 -1
  39. package/dist/fetcher.js.map +0 -1
  40. package/dist/index.js +0 -27
  41. package/dist/index.js.map +0 -1
  42. package/dist/types/application.js.map +0 -1
  43. package/dist/types/standards.js.map +0 -1
  44. package/dist/utils.d.ts +0 -6
  45. package/dist/utils.js.map +0 -1
@@ -8,15 +8,15 @@ export declare enum RLLEndPoint {
8
8
  TAGS = "tags",
9
9
  VEHICLES = "vehicles"
10
10
  }
11
- interface RLLRecord {
12
- id: number;
13
- }
14
11
  export declare namespace RLLEntity {
15
- interface Country {
12
+ interface RLLRecord {
13
+ id: number;
14
+ }
15
+ export interface Country {
16
16
  name: string;
17
17
  code: ISO3166Alpha2.CountryCode;
18
18
  }
19
- interface State {
19
+ export interface State {
20
20
  name: string;
21
21
  abbr: ISO3166Alpha2.StateCodeUS;
22
22
  }
@@ -24,14 +24,14 @@ export declare namespace RLLEntity {
24
24
  country: Country;
25
25
  inactive: boolean | null;
26
26
  }
27
- enum LaunchResult {
27
+ export enum LaunchResult {
28
28
  NOT_SET = -1,
29
29
  FAILURE = 0,
30
30
  SUCCESS = 1,
31
31
  PARTIAL_FAILURE = 2,
32
32
  IN_FLIGHT_ABORT_CREWED = 3
33
33
  }
34
- interface Media extends RLLRecord {
34
+ export interface Media extends RLLRecord {
35
35
  media_url: string | null;
36
36
  youtube_vidid: string | null;
37
37
  featured: boolean;
@@ -103,17 +103,37 @@ export declare namespace RLLEntity {
103
103
  }
104
104
  export {};
105
105
  }
106
- interface RLLBaseQueryConfig {
107
- id?: number | string;
108
- page?: number | string;
109
- }
106
+ export declare const RLLQueryParams: {
107
+ id: boolean;
108
+ page: boolean;
109
+ name: boolean;
110
+ country_code: boolean;
111
+ inactive: boolean;
112
+ cospar_id: boolean;
113
+ after_date: boolean;
114
+ before_date: boolean;
115
+ modified_since: boolean;
116
+ location_id: boolean;
117
+ pad_id: boolean;
118
+ provider_id: boolean;
119
+ tag_id: boolean;
120
+ vehicle_id: boolean;
121
+ state_abbr: boolean;
122
+ search: boolean;
123
+ slug: boolean;
124
+ text: boolean;
125
+ };
110
126
  export declare namespace RLLQueryConfig {
111
- interface Companies extends RLLBaseQueryConfig {
127
+ interface Base {
128
+ id?: number | string;
129
+ page?: number | string;
130
+ }
131
+ export interface Companies extends Base {
112
132
  name?: string | number;
113
133
  country_code?: ISO3166Alpha2.CountryCode;
114
134
  inactive?: boolean;
115
135
  }
116
- interface Launches extends RLLBaseQueryConfig {
136
+ export interface Launches extends Base {
117
137
  cospar_id?: string;
118
138
  after_date?: Date | string;
119
139
  before_date?: Date | string;
@@ -128,27 +148,26 @@ export declare namespace RLLQueryConfig {
128
148
  search?: string | number;
129
149
  slug?: string | number;
130
150
  }
131
- interface Locations extends RLLBaseQueryConfig {
151
+ export interface Locations extends Base {
132
152
  name?: string | number;
133
153
  state_abbr?: ISO3166Alpha2.StateCodeUS;
134
154
  country_code?: ISO3166Alpha2.CountryCode;
135
155
  }
136
- interface Missions extends RLLBaseQueryConfig {
156
+ export interface Missions extends Base {
137
157
  name?: string | number;
138
158
  }
139
- interface Pads extends RLLBaseQueryConfig {
159
+ export interface Pads extends Base {
140
160
  name?: string | number;
141
161
  state_abbr?: ISO3166Alpha2.StateCodeUS;
142
162
  country_code?: ISO3166Alpha2.CountryCode;
143
163
  }
144
- interface Tags extends RLLBaseQueryConfig {
164
+ export interface Tags extends Base {
145
165
  text?: string | number;
146
166
  }
147
- interface Vehicles extends RLLBaseQueryConfig {
167
+ export interface Vehicles extends Base {
148
168
  name?: string | number;
149
169
  }
150
- interface All extends Companies, Launches, Locations, Missions, Pads, Tags, Vehicles {
151
- }
170
+ export {};
152
171
  }
153
172
  export type RLLClientOptions = {
154
173
  keyInQueryParams?: boolean;
@@ -162,4 +181,4 @@ export type RLLResponse<T> = {
162
181
  last_page: number;
163
182
  result: T;
164
183
  };
165
- export {};
184
+ //# sourceMappingURL=application.d.ts.map
@@ -0,0 +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;KACjC;IAED,MAAM,WAAW,KAAK;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC;KACjC;IAED,MAAM,WAAW,OAAQ,SAAQ,SAAS;QACxC,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;KAC1B;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;QACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,QAAQ,EAAE,OAAO,CAAC;QAClB,UAAU,EAAE,OAAO,CAAC;QACpB,QAAQ,EAAE,OAAO,CAAC;KACnB;IAED,MAAM,WAAW,MAAO,SAAQ,SAAS;QACvC,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,IAA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,CAAC;QACvC,YAAY,CAAC,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"}
@@ -308,7 +308,10 @@ export declare const usStateCodes: {
308
308
  UM: string;
309
309
  VI: string;
310
310
  };
311
+ export declare const isValidCountryCode: (code: string) => code is "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BV" | "BR" | "IO" | "BN" | "BG" | "BF" | "BI" | "CV" | "KH" | "CM" | "CA" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CD" | "CG" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "CI" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "SZ" | "ET" | "FK" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "HM" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KP" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "MK" | "RO" | "RU" | "RW" | "RE" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "VG" | "VI" | "WF" | "EH" | "YE" | "ZM" | "ZW" | "AX";
312
+ export declare const isValidStateCode: (code: string) => code is "AL" | "AS" | "AR" | "AZ" | "CA" | "KY" | "CO" | "GA" | "DE" | "GU" | "VA" | "IN" | "ID" | "IL" | "LA" | "MO" | "MT" | "MD" | "MN" | "ME" | "MS" | "MA" | "NC" | "NE" | "MP" | "PA" | "PR" | "SC" | "SD" | "TN" | "UM" | "VI" | "AK" | "CT" | "FL" | "HI" | "IA" | "KS" | "MI" | "NV" | "NH" | "NJ" | "NM" | "NY" | "ND" | "OH" | "OK" | "OR" | "RI" | "TX" | "UT" | "VT" | "WA" | "WV" | "WI" | "WY" | "DC";
311
313
  export declare namespace ISO3166Alpha2 {
312
314
  type CountryCode = keyof typeof countryCodes;
313
315
  type StateCodeUS = keyof typeof usStateCodes;
314
316
  }
317
+ //# sourceMappingURL=standards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standards.d.ts","sourceRoot":"","sources":["../../../../src/types/standards.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0PxB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,SACvB,MAAM,ytDAGb,CAAC;AAEF,eAAO,MAAM,gBAAgB,SACrB,MAAM,yZAGb,CAAC;AAEF,yBAAiB,aAAa,CAAC;IAC7B,KAAY,WAAW,GAAG,MAAM,OAAO,YAAY,CAAC;IAEpD,KAAY,WAAW,GAAG,MAAM,OAAO,YAAY,CAAC;CACrD"}
@@ -0,0 +1,11 @@
1
+ import { RLLEndPoint, RLLQueryConfig } from "./types/application";
2
+ export declare const apiKeyValidator: (apiKey: any) => string;
3
+ export declare const optionsValidator: (options: {
4
+ [key: string]: any;
5
+ [key: number]: any;
6
+ [key: symbol]: any;
7
+ }) => void;
8
+ export declare const queryOptionsValidator: (resource: RLLEndPoint, options?: RLLQueryConfig.Companies | RLLQueryConfig.Launches | RLLQueryConfig.Locations | RLLQueryConfig.Missions | RLLQueryConfig.Pads | RLLQueryConfig.Tags | RLLQueryConfig.Vehicles) => Promise<URLSearchParams>;
9
+ export declare const warn: (msg: string) => void;
10
+ export declare const error: (msg: string, type?: "type" | "range" | "error") => void;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +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;AAuLF,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,QAAQ,eAAe,CA0CzB,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"}
@@ -1,32 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.error = exports.warn = exports.queryOptionsValidator = exports.optionsValidator = exports.apiKeyValidator = void 0;
4
- var standards_1 = require("./types/standards");
5
- var getLeadingZero = function (month, offset) {
6
- if (offset === void 0) { offset = 0; }
7
- var str = "0".concat((month + offset).toString());
4
+ const standards_1 = require("./types/standards");
5
+ const getLeadingZero = (month, offset = 0) => {
6
+ const str = "0".concat((month + offset).toString());
8
7
  return str.slice(-2);
9
8
  };
10
- var apiKeyValidator = function (apiKey) {
9
+ const apiKeyValidator = (apiKey) => {
11
10
  if (apiKey === undefined) {
12
11
  (0, exports.error)("RLL Client requires API Key", "type");
13
12
  }
14
13
  if (typeof apiKey !== "string") {
15
14
  (0, exports.error)("RLL Client API Key must be a string", "type");
16
15
  }
17
- if (apiKey === "") {
16
+ const trimmedKey = apiKey.trim();
17
+ if (trimmedKey === "") {
18
18
  (0, exports.error)("RLL Client API Key cannot be an empty string", "type");
19
19
  }
20
- var validator = apiKey.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);
20
+ 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
21
  if (validator === null) {
22
22
  (0, exports.error)("RLL Client API Key appears malformed. RLL Client API Keys are in UUID format.", "type");
23
23
  }
24
+ return trimmedKey;
24
25
  };
25
26
  exports.apiKeyValidator = apiKeyValidator;
26
- var optionsValidator = function (options) {
27
- for (var option in options) {
27
+ const optionsValidator = (options) => {
28
+ for (const option in options) {
28
29
  if (option !== "keyInQueryParams") {
29
- (0, exports.warn)("RLL Client options do not accept a \"".concat(option, "\" property. This property will be ignored."));
30
+ (0, exports.warn)(`RLL Client options do not accept a "${option}" property. This property will be ignored.`);
30
31
  }
31
32
  else {
32
33
  if (typeof options[option] !== "boolean") {
@@ -36,9 +37,9 @@ var optionsValidator = function (options) {
36
37
  }
37
38
  };
38
39
  exports.optionsValidator = optionsValidator;
39
- var validators = {
40
- string: function (option) {
41
- return new Promise(function (resolve, reject) {
40
+ const validators = {
41
+ string: (option) => {
42
+ return new Promise((resolve, reject) => {
42
43
  if (typeof option === "number") {
43
44
  resolve(option.toString());
44
45
  }
@@ -51,16 +52,16 @@ var validators = {
51
52
  resolve(option);
52
53
  });
53
54
  },
54
- boolean: function (option) {
55
- return new Promise(function (resolve, reject) {
55
+ boolean: (option) => {
56
+ return new Promise((resolve, reject) => {
56
57
  if (typeof option !== "boolean") {
57
58
  return reject("Must be a boolean");
58
59
  }
59
60
  resolve(option === true ? 1 : 0);
60
61
  });
61
62
  },
62
- number: function (option) {
63
- return new Promise(function (resolve, reject) {
63
+ number: (option) => {
64
+ return new Promise((resolve, reject) => {
64
65
  if (typeof option === "number") {
65
66
  return resolve(option);
66
67
  }
@@ -74,30 +75,30 @@ var validators = {
74
75
  }
75
76
  });
76
77
  },
77
- countryCode: function (option) {
78
- return new Promise(function (resolve, reject) {
78
+ countryCode: (option) => {
79
+ return new Promise((resolve, reject) => {
79
80
  if (typeof option !== "string") {
80
81
  return reject("Must be a string");
81
82
  }
82
- if (!standards_1.countryCodes[option]) {
83
+ if (!(0, standards_1.isValidCountryCode)(option)) {
83
84
  return reject("Invalid country code. Country codes should follow ISO 3166-1 A2 convention, like 'US'.");
84
85
  }
85
86
  resolve(option);
86
87
  });
87
88
  },
88
- stateCode: function (option) {
89
- return new Promise(function (resolve, reject) {
89
+ stateCode: (option) => {
90
+ return new Promise((resolve, reject) => {
90
91
  if (typeof option !== "string") {
91
92
  return reject("Must be a string");
92
93
  }
93
- if (!standards_1.usStateCodes[option]) {
94
+ if (!(0, standards_1.isValidStateCode)(option)) {
94
95
  return reject("Invalid United States State Code. State Codes should follow ISO 3166-2 convention, like 'FL'.");
95
96
  }
96
97
  resolve(option);
97
98
  });
98
99
  },
99
- cosparId: function (option) {
100
- return new Promise(function (resolve, reject) {
100
+ cosparId: (option) => {
101
+ return new Promise((resolve, reject) => {
101
102
  if (typeof option !== "string") {
102
103
  return reject("Must be a string");
103
104
  }
@@ -107,12 +108,12 @@ var validators = {
107
108
  resolve(option);
108
109
  });
109
110
  },
110
- shortDate: function (option) {
111
- return new Promise(function (resolve, reject) {
111
+ shortDate: (option) => {
112
+ return new Promise((resolve, reject) => {
112
113
  if (typeof option === "string" || option instanceof Date) {
113
- var date = void 0;
114
+ let date;
114
115
  if (typeof option === "string") {
115
- var parsed = Date.parse(option);
116
+ const parsed = Date.parse(option);
116
117
  if (isNaN(parsed)) {
117
118
  return reject("Must be an ISO 8601 Date String");
118
119
  }
@@ -121,17 +122,17 @@ var validators = {
121
122
  else {
122
123
  date = option;
123
124
  }
124
- resolve("".concat(date.getUTCFullYear(), "-").concat(getLeadingZero(date.getUTCMonth(), 1), "-").concat(getLeadingZero(date.getUTCDate())));
125
+ resolve(`${date.getUTCFullYear()}-${getLeadingZero(date.getUTCMonth(), 1)}-${getLeadingZero(date.getUTCDate())}`);
125
126
  }
126
127
  return reject("Must be a JavaScript Date Object or ISO 8601 Date String");
127
128
  });
128
129
  },
129
- isoDate: function (option) {
130
- return new Promise(function (resolve, reject) {
130
+ isoDate: (option) => {
131
+ return new Promise((resolve, reject) => {
131
132
  if (typeof option === "string" || option instanceof Date) {
132
- var date = void 0;
133
+ let date;
133
134
  if (typeof option === "string") {
134
- var parsed = Date.parse(option);
135
+ const parsed = Date.parse(option);
135
136
  if (isNaN(parsed)) {
136
137
  return reject("Must be an ISO 8601 Date String");
137
138
  }
@@ -146,7 +147,7 @@ var validators = {
146
147
  });
147
148
  },
148
149
  };
149
- var optionsMap = {
150
+ const optionsMap = {
150
151
  companies: {
151
152
  page: validators.number,
152
153
  id: validators.number,
@@ -201,53 +202,48 @@ var optionsMap = {
201
202
  name: validators.string,
202
203
  },
203
204
  };
204
- var queryOptionsValidator = function (resource, options) {
205
- var params = new URLSearchParams();
206
- var paramsPromises = [];
205
+ const queryOptionsValidator = (resource, options) => {
206
+ const params = new URLSearchParams();
207
+ const paramsPromises = [];
207
208
  if (!options) {
208
209
  return Promise.resolve(params);
209
210
  }
210
- if ((options.id || options.slug || options.cospar_id) &&
211
+ if ((options.id || "slug" in options || "cospar_id" in options) &&
211
212
  Object.keys(options).length > 1) {
212
213
  (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.");
213
214
  }
214
- var _loop_1 = function (option) {
215
- if (!optionsMap[resource][option]) {
216
- (0, exports.warn)("Parameter \"".concat(option, "\" is not a valid option for the ").concat(resource, " endpoint. It will be ignored."));
217
- return "continue";
215
+ for (const option in options) {
216
+ if (!(option in optionsMap[resource])) {
217
+ (0, exports.warn)(`Parameter "${option}" is not a valid option for the ${resource} endpoint. It will be ignored.`);
218
+ continue;
218
219
  }
219
220
  if (options[option] === undefined) {
220
- (0, exports.warn)("Parameter \"".concat(option, "\" is undefined and will be ignored."));
221
- return "continue";
221
+ (0, exports.warn)(`Parameter "${option}" is undefined and will be ignored.`);
222
+ continue;
222
223
  }
223
- var promise = optionsMap[resource][option](options[option])
224
- .then(function (o) { return params.set(option, o); })
225
- .catch(function (err) {
226
- throw "Malformed query parameter for resource \"".concat(resource, "\" and parameter: \"").concat(option, "\": ").concat(err, ".");
224
+ const promise = optionsMap[resource][option](options[option])
225
+ .then((o) => params.set(option, o))
226
+ .catch((err) => {
227
+ throw `Malformed query parameter for resource "${resource}" and parameter: "${option}": ${err}.`;
227
228
  });
228
229
  paramsPromises.push(promise);
229
- };
230
- for (var option in options) {
231
- _loop_1(option);
232
230
  }
233
- return Promise.all(paramsPromises).then(function () { return params; });
231
+ return Promise.all(paramsPromises).then(() => params);
234
232
  };
235
233
  exports.queryOptionsValidator = queryOptionsValidator;
236
- var warn = function (msg) { return console.warn("[RLL Client]: ".concat(msg)); };
234
+ const warn = (msg) => console.warn(`[RLL Client]: ${msg}`);
237
235
  exports.warn = warn;
238
- var error = function (msg, type) {
239
- if (type === void 0) { type = "error"; }
236
+ const error = (msg, type = "error") => {
240
237
  switch (type) {
241
238
  case "error": {
242
- throw new Error("[RLL Client]: ".concat(msg));
239
+ throw new Error(`[RLL Client]: ${msg}`);
243
240
  }
244
241
  case "type": {
245
- throw new TypeError("[RLL Client]: ".concat(msg));
242
+ throw new TypeError(`[RLL Client]: ${msg}`);
246
243
  }
247
244
  case "range": {
248
- throw new RangeError("[RLL Client]: ".concat(msg));
245
+ throw new RangeError(`[RLL Client]: ${msg}`);
249
246
  }
250
247
  }
251
248
  };
252
249
  exports.error = error;
253
- //# sourceMappingURL=utils.js.map
@@ -0,0 +1,207 @@
1
+ import { RLLEndPoint, } from "./types/application";
2
+ import { fetcher } from "./fetcher";
3
+ import { apiKeyValidator, optionsValidator, queryOptionsValidator, } from "./utils";
4
+ /**
5
+ * Class representing a RocketLaunch.Live client
6
+ * @class
7
+ */
8
+ export class RLLClient {
9
+ apiKey;
10
+ config = {
11
+ keyInQueryParams: false,
12
+ };
13
+ /**
14
+ * Create a new RocketLaunch.live Client
15
+ *
16
+ * @param {string} apiKey - Your RocketLaunch.Live API Key
17
+ * @param {Object} [options] - Optional Client Configuration options
18
+ * @param {boolean} options.keyInQueryParams - Set to true to send your API Key via Query parameters instead of Authorization Header (not recommended)
19
+ *
20
+ */
21
+ constructor(apiKey, options) {
22
+ // Validate API Key is a valid UUID format
23
+ // Constructor throws if not
24
+ this.apiKey = apiKeyValidator(apiKey);
25
+ if (!options) {
26
+ return;
27
+ }
28
+ // Validate Options with warnings or throws
29
+ optionsValidator(options);
30
+ if (options.keyInQueryParams) {
31
+ this.config.keyInQueryParams = options.keyInQueryParams;
32
+ }
33
+ }
34
+ /**
35
+ * Used internally to make API query
36
+ *
37
+ * @private
38
+ *
39
+ * @template T
40
+ *
41
+ * @param {string} endpoint - API endpoint (ie. "/launches")
42
+ * @param {URLSearchParams} params - API Search Params
43
+ *
44
+ * @returns {Promise<T>}
45
+ */
46
+ query(endpoint, params) {
47
+ return fetcher(this.apiKey, endpoint, params, this.config.keyInQueryParams);
48
+ }
49
+ /**
50
+ * Fetch launch companies
51
+ *
52
+ * @public
53
+ * @function
54
+ *
55
+ * @param {Object} [options] - Launch Company Search Options
56
+ * @param {number | string} options.id - Company id
57
+ * @param {number | string} options.page - Page number of results
58
+ * @param {number | string} options.name - Company name
59
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
60
+ * @param {boolean} options.inactive - Company inactive status
61
+ *
62
+ * @returns {Promise<RLLResponse<RLLEntity.Company[]>>} Array of companies wrapped in a standard RLL Response
63
+ *
64
+ * @example
65
+ *
66
+ * const response = client.companies({ country_code: "US" })
67
+ */
68
+ companies(options) {
69
+ return queryOptionsValidator(RLLEndPoint.COMPANIES, options).then((params) => this.query(RLLEndPoint.COMPANIES, params));
70
+ }
71
+ /**
72
+ * Fetch launches
73
+ *
74
+ * @public
75
+ * @function
76
+ *
77
+ * @param {Object} [options] - Launch Search Options
78
+ * @param {number | string} options.id - Launch id
79
+ * @param {number | string} options.page - Page number of results
80
+ * @param {string} options.cospar_id - Launch COSPAR ID (ie. 2022-123)
81
+ * @param {Date | string} options.before_date - Only return launches before this date
82
+ * @param {Date | string} options.after_date - Only return launches after this date
83
+ * @param {Date | string} options.modified_since - Only return launches with API changes after this date
84
+ * @param {number | string} options.location_id - Launches from this Location
85
+ * @param {number | string} options.pad_id - Launches from this Pad
86
+ * @param {number | string} options.provider_id - Launches from this Company
87
+ * @param {number | string} options.tag_id - Launches with this Tag
88
+ * @param {number | string} options.vehicle_id - Launches on this Vehicle
89
+ * @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
90
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
91
+ * @param {number | string} options.search - Launches matching this search string
92
+ * @param {number | string} options.slug - Launches matching this unique slug
93
+ *
94
+ * @returns {Promise<RLLResponse<RLLEntity.Launch[]>>} Array of companies wrapped in a standard RLL Response
95
+ *
96
+ * @example
97
+ *
98
+ * const response = client.launches({ after_date: new Date("2022-10-10") })
99
+ */
100
+ launches(options) {
101
+ return queryOptionsValidator(RLLEndPoint.LAUNCHES, options).then((params) => this.query(RLLEndPoint.LAUNCHES, params));
102
+ }
103
+ /**
104
+ * Fetch launch locations
105
+ *
106
+ * @public
107
+ * @function
108
+ *
109
+ * @param {Object} [options] - Launch Location Search Options
110
+ * @param {number | string} options.id - Location id
111
+ * @param {number | string} options.page - Page number of results
112
+ * @param {number | string} options.name - Location name
113
+ * @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
114
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
115
+ *
116
+ * @returns {Promise<RLLResponse<RLLEntity.Location[]>>} Array of companies wrapped in a standard RLL Response
117
+ *
118
+ * @example
119
+ *
120
+ * const response = client.locations({ country_code: "US" })
121
+ */
122
+ locations(options) {
123
+ return queryOptionsValidator(RLLEndPoint.LOCATIONS, options).then((params) => this.query(RLLEndPoint.LOCATIONS, params));
124
+ }
125
+ /**
126
+ * Fetch launch Missions
127
+ *
128
+ * @public
129
+ * @function
130
+ *
131
+ * @param {Object} [options] - Launch Mission Search Options
132
+ * @param {number | string} options.id - Mission id
133
+ * @param {number | string} options.page - Page number of results
134
+ * @param {number | string} options.name - Mission name
135
+ *
136
+ * @returns {Promise<RLLResponse<RLLEntity.Mission[]>>} Array of companies wrapped in a standard RLL Response
137
+ *
138
+ * @example
139
+ *
140
+ * const response = client.missions({ name: "Mars 2020" })
141
+ */
142
+ missions(options) {
143
+ return queryOptionsValidator(RLLEndPoint.MISSIONS, options).then((params) => this.query(RLLEndPoint.MISSIONS, params));
144
+ }
145
+ /**
146
+ * Fetch launch pads
147
+ *
148
+ * @public
149
+ * @function
150
+ *
151
+ * @param {Object} [options] - Launch Pad Search Options
152
+ * @param {number | string} options.id - Pad id
153
+ * @param {number | string} options.page - Page number of results
154
+ * @param {number | string} options.name - Pad name
155
+ * @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
156
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
157
+ *
158
+ * @returns {Promise<RLLResponse<RLLEntity.Pad[]>>} Array of companies wrapped in a standard RLL Response
159
+ *
160
+ * @example
161
+ *
162
+ * const response = client.pads({ country_code: "US" })
163
+ */
164
+ pads(options) {
165
+ return queryOptionsValidator(RLLEndPoint.PADS, options).then((params) => this.query(RLLEndPoint.PADS, params));
166
+ }
167
+ /**
168
+ * Fetch launch tags
169
+ *
170
+ * @public
171
+ * @function
172
+ *
173
+ * @param {Object} [options] - Launch Tag Search Options
174
+ * @param {number | string} options.id - Tag id
175
+ * @param {number | string} options.page - Page number of results
176
+ * @param {number | string} options.text - Tag text
177
+ *
178
+ * @returns {Promise<RLLResponse<RLLEntity.Tag[]>>} Array of companies wrapped in a standard RLL Response
179
+ *
180
+ * @example
181
+ *
182
+ * const response = client.tags({ text: "Crewed" })
183
+ */
184
+ tags(options) {
185
+ return queryOptionsValidator(RLLEndPoint.TAGS, options).then((params) => this.query(RLLEndPoint.TAGS, params));
186
+ }
187
+ /**
188
+ * Fetch launch Vehicles
189
+ *
190
+ * @public
191
+ * @function
192
+ *
193
+ * @param {Object} [options] - Launch Vehicles Search Options
194
+ * @param {number | string} options.id - Vehicle id
195
+ * @param {number | string} options.page - Page number of results
196
+ * @param {number | string} options.name - Vehicle name
197
+ *
198
+ * @returns {Promise<RLLResponse<RLLEntity.Vehicle[]>>} Array of companies wrapped in a standard RLL Response
199
+ *
200
+ * @example
201
+ *
202
+ * const response = client.vehicles({ name: "Falcon 9" })
203
+ */
204
+ vehicles(options) {
205
+ return queryOptionsValidator(RLLEndPoint.VEHICLES, options).then((params) => this.query(RLLEndPoint.VEHICLES, params));
206
+ }
207
+ }
@@ -0,0 +1,39 @@
1
+ import https from "https";
2
+ const BASE_URL = "https://fdo.rocketlaunch.live";
3
+ export const fetcher = (apiKey, endpoint, params, keyInQueryParams) => {
4
+ const url = new URL("json/" + endpoint, BASE_URL);
5
+ let headers;
6
+ if (keyInQueryParams) {
7
+ params.set("key", apiKey);
8
+ }
9
+ else {
10
+ headers = { authorization: `Bearer ${apiKey}` };
11
+ }
12
+ params.forEach((v, k) => url.searchParams.set(k, v));
13
+ return query(url, headers);
14
+ };
15
+ const query = (url, headers) => {
16
+ return new Promise((resolve, reject) => {
17
+ const req = https.get(url, { headers }, (res) => {
18
+ let data = [];
19
+ res.on("data", (chunk) => data.push(chunk));
20
+ res.on("end", () => {
21
+ if (res.statusCode === 200) {
22
+ const response = Buffer.concat(data).toString();
23
+ resolve(JSON.parse(response));
24
+ }
25
+ else if (res.statusCode === 404) {
26
+ reject({
27
+ error: "Resource not found",
28
+ statusCode: 404,
29
+ message: "The server returned a 404 Not Found response. Check that your API key is valid, and that you are not requesting a page number beyond the available results.",
30
+ });
31
+ }
32
+ else {
33
+ reject(res);
34
+ }
35
+ });
36
+ });
37
+ req.on("error", reject);
38
+ });
39
+ };