rocket-launch-live-client 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/{dist → lib/cjs}/Client.js +31 -53
  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 +53 -59
  19. package/lib/esm/Client.js +208 -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 +239 -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) => void;
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,IAuB7C,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,13 +1,12 @@
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
  }
@@ -17,16 +16,16 @@ var apiKeyValidator = function (apiKey) {
17
16
  if (apiKey === "") {
18
17
  (0, exports.error)("RLL Client API Key cannot be an empty string", "type");
19
18
  }
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);
19
+ const 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);
21
20
  if (validator === null) {
22
21
  (0, exports.error)("RLL Client API Key appears malformed. RLL Client API Keys are in UUID format.", "type");
23
22
  }
24
23
  };
25
24
  exports.apiKeyValidator = apiKeyValidator;
26
- var optionsValidator = function (options) {
27
- for (var option in options) {
25
+ const optionsValidator = (options) => {
26
+ for (const option in options) {
28
27
  if (option !== "keyInQueryParams") {
29
- (0, exports.warn)("RLL Client options do not accept a \"".concat(option, "\" property. This property will be ignored."));
28
+ (0, exports.warn)(`RLL Client options do not accept a "${option}" property. This property will be ignored.`);
30
29
  }
31
30
  else {
32
31
  if (typeof options[option] !== "boolean") {
@@ -36,9 +35,9 @@ var optionsValidator = function (options) {
36
35
  }
37
36
  };
38
37
  exports.optionsValidator = optionsValidator;
39
- var validators = {
40
- string: function (option) {
41
- return new Promise(function (resolve, reject) {
38
+ const validators = {
39
+ string: (option) => {
40
+ return new Promise((resolve, reject) => {
42
41
  if (typeof option === "number") {
43
42
  resolve(option.toString());
44
43
  }
@@ -51,16 +50,16 @@ var validators = {
51
50
  resolve(option);
52
51
  });
53
52
  },
54
- boolean: function (option) {
55
- return new Promise(function (resolve, reject) {
53
+ boolean: (option) => {
54
+ return new Promise((resolve, reject) => {
56
55
  if (typeof option !== "boolean") {
57
56
  return reject("Must be a boolean");
58
57
  }
59
58
  resolve(option === true ? 1 : 0);
60
59
  });
61
60
  },
62
- number: function (option) {
63
- return new Promise(function (resolve, reject) {
61
+ number: (option) => {
62
+ return new Promise((resolve, reject) => {
64
63
  if (typeof option === "number") {
65
64
  return resolve(option);
66
65
  }
@@ -74,30 +73,30 @@ var validators = {
74
73
  }
75
74
  });
76
75
  },
77
- countryCode: function (option) {
78
- return new Promise(function (resolve, reject) {
76
+ countryCode: (option) => {
77
+ return new Promise((resolve, reject) => {
79
78
  if (typeof option !== "string") {
80
79
  return reject("Must be a string");
81
80
  }
82
- if (!standards_1.countryCodes[option]) {
81
+ if (!(0, standards_1.isValidCountryCode)(option)) {
83
82
  return reject("Invalid country code. Country codes should follow ISO 3166-1 A2 convention, like 'US'.");
84
83
  }
85
84
  resolve(option);
86
85
  });
87
86
  },
88
- stateCode: function (option) {
89
- return new Promise(function (resolve, reject) {
87
+ stateCode: (option) => {
88
+ return new Promise((resolve, reject) => {
90
89
  if (typeof option !== "string") {
91
90
  return reject("Must be a string");
92
91
  }
93
- if (!standards_1.usStateCodes[option]) {
92
+ if (!(0, standards_1.isValidStateCode)(option)) {
94
93
  return reject("Invalid United States State Code. State Codes should follow ISO 3166-2 convention, like 'FL'.");
95
94
  }
96
95
  resolve(option);
97
96
  });
98
97
  },
99
- cosparId: function (option) {
100
- return new Promise(function (resolve, reject) {
98
+ cosparId: (option) => {
99
+ return new Promise((resolve, reject) => {
101
100
  if (typeof option !== "string") {
102
101
  return reject("Must be a string");
103
102
  }
@@ -107,12 +106,12 @@ var validators = {
107
106
  resolve(option);
108
107
  });
109
108
  },
110
- shortDate: function (option) {
111
- return new Promise(function (resolve, reject) {
109
+ shortDate: (option) => {
110
+ return new Promise((resolve, reject) => {
112
111
  if (typeof option === "string" || option instanceof Date) {
113
- var date = void 0;
112
+ let date;
114
113
  if (typeof option === "string") {
115
- var parsed = Date.parse(option);
114
+ const parsed = Date.parse(option);
116
115
  if (isNaN(parsed)) {
117
116
  return reject("Must be an ISO 8601 Date String");
118
117
  }
@@ -121,17 +120,17 @@ var validators = {
121
120
  else {
122
121
  date = option;
123
122
  }
124
- resolve("".concat(date.getUTCFullYear(), "-").concat(getLeadingZero(date.getUTCMonth(), 1), "-").concat(getLeadingZero(date.getUTCDate())));
123
+ resolve(`${date.getUTCFullYear()}-${getLeadingZero(date.getUTCMonth(), 1)}-${getLeadingZero(date.getUTCDate())}`);
125
124
  }
126
125
  return reject("Must be a JavaScript Date Object or ISO 8601 Date String");
127
126
  });
128
127
  },
129
- isoDate: function (option) {
130
- return new Promise(function (resolve, reject) {
128
+ isoDate: (option) => {
129
+ return new Promise((resolve, reject) => {
131
130
  if (typeof option === "string" || option instanceof Date) {
132
- var date = void 0;
131
+ let date;
133
132
  if (typeof option === "string") {
134
- var parsed = Date.parse(option);
133
+ const parsed = Date.parse(option);
135
134
  if (isNaN(parsed)) {
136
135
  return reject("Must be an ISO 8601 Date String");
137
136
  }
@@ -146,7 +145,7 @@ var validators = {
146
145
  });
147
146
  },
148
147
  };
149
- var optionsMap = {
148
+ const optionsMap = {
150
149
  companies: {
151
150
  page: validators.number,
152
151
  id: validators.number,
@@ -201,53 +200,48 @@ var optionsMap = {
201
200
  name: validators.string,
202
201
  },
203
202
  };
204
- var queryOptionsValidator = function (resource, options) {
205
- var params = new URLSearchParams();
206
- var paramsPromises = [];
203
+ const queryOptionsValidator = (resource, options) => {
204
+ const params = new URLSearchParams();
205
+ const paramsPromises = [];
207
206
  if (!options) {
208
207
  return Promise.resolve(params);
209
208
  }
210
- if ((options.id || options.slug || options.cospar_id) &&
209
+ if ((options.id || "slug" in options || "cospar_id" in options) &&
211
210
  Object.keys(options).length > 1) {
212
211
  (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
212
  }
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";
213
+ for (const option in options) {
214
+ if (!(option in optionsMap[resource])) {
215
+ (0, exports.warn)(`Parameter "${option}" is not a valid option for the ${resource} endpoint. It will be ignored.`);
216
+ continue;
218
217
  }
219
218
  if (options[option] === undefined) {
220
- (0, exports.warn)("Parameter \"".concat(option, "\" is undefined and will be ignored."));
221
- return "continue";
219
+ (0, exports.warn)(`Parameter "${option}" is undefined and will be ignored.`);
220
+ continue;
222
221
  }
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, ".");
222
+ const promise = optionsMap[resource][option](options[option])
223
+ .then((o) => params.set(option, o))
224
+ .catch((err) => {
225
+ throw `Malformed query parameter for resource "${resource}" and parameter: "${option}": ${err}.`;
227
226
  });
228
227
  paramsPromises.push(promise);
229
- };
230
- for (var option in options) {
231
- _loop_1(option);
232
228
  }
233
- return Promise.all(paramsPromises).then(function () { return params; });
229
+ return Promise.all(paramsPromises).then(() => params);
234
230
  };
235
231
  exports.queryOptionsValidator = queryOptionsValidator;
236
- var warn = function (msg) { return console.warn("[RLL Client]: ".concat(msg)); };
232
+ const warn = (msg) => console.warn(`[RLL Client]: ${msg}`);
237
233
  exports.warn = warn;
238
- var error = function (msg, type) {
239
- if (type === void 0) { type = "error"; }
234
+ const error = (msg, type = "error") => {
240
235
  switch (type) {
241
236
  case "error": {
242
- throw new Error("[RLL Client]: ".concat(msg));
237
+ throw new Error(`[RLL Client]: ${msg}`);
243
238
  }
244
239
  case "type": {
245
- throw new TypeError("[RLL Client]: ".concat(msg));
240
+ throw new TypeError(`[RLL Client]: ${msg}`);
246
241
  }
247
242
  case "range": {
248
- throw new RangeError("[RLL Client]: ".concat(msg));
243
+ throw new RangeError(`[RLL Client]: ${msg}`);
249
244
  }
250
245
  }
251
246
  };
252
247
  exports.error = error;
253
- //# sourceMappingURL=utils.js.map
@@ -0,0 +1,208 @@
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
+ apiKeyValidator(apiKey);
25
+ this.apiKey = apiKey;
26
+ if (!options) {
27
+ return;
28
+ }
29
+ // Validate Options with warnings or throws
30
+ optionsValidator(options);
31
+ if (options.keyInQueryParams) {
32
+ this.config.keyInQueryParams = options.keyInQueryParams;
33
+ }
34
+ }
35
+ /**
36
+ * Used internally to make API query
37
+ *
38
+ * @private
39
+ *
40
+ * @template T
41
+ *
42
+ * @param {string} endpoint - API endpoint (ie. "/launches")
43
+ * @param {URLSearchParams} params - API Search Params
44
+ *
45
+ * @returns {Promise<T>}
46
+ */
47
+ query(endpoint, params) {
48
+ return fetcher(this.apiKey, endpoint, params, this.config.keyInQueryParams);
49
+ }
50
+ /**
51
+ * Fetch launch companies
52
+ *
53
+ * @public
54
+ * @function
55
+ *
56
+ * @param {Object} [options] - Launch Company Search Options
57
+ * @param {number | string} options.id - Company id
58
+ * @param {number | string} options.page - Page number of results
59
+ * @param {number | string} options.name - Company name
60
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
61
+ * @param {boolean} options.inactive - Company inactive status
62
+ *
63
+ * @returns {Promise<RLLResponse<RLLEntity.Company[]>>} Array of companies wrapped in a standard RLL Response
64
+ *
65
+ * @example
66
+ *
67
+ * const response = client.companies({ country_code: "US" })
68
+ */
69
+ companies(options) {
70
+ return queryOptionsValidator(RLLEndPoint.COMPANIES, options).then((params) => this.query(RLLEndPoint.COMPANIES, params));
71
+ }
72
+ /**
73
+ * Fetch launches
74
+ *
75
+ * @public
76
+ * @function
77
+ *
78
+ * @param {Object} [options] - Launch Search Options
79
+ * @param {number | string} options.id - Launch id
80
+ * @param {number | string} options.page - Page number of results
81
+ * @param {string} options.cospar_id - Launch COSPAR ID (ie. 2022-123)
82
+ * @param {Date | string} options.before_date - Only return launches before this date
83
+ * @param {Date | string} options.after_date - Only return launches after this date
84
+ * @param {Date | string} options.modified_since - Only return launches with API changes after this date
85
+ * @param {number | string} options.location_id - Launches from this Location
86
+ * @param {number | string} options.pad_id - Launches from this Pad
87
+ * @param {number | string} options.provider_id - Launches from this Company
88
+ * @param {number | string} options.tag_id - Launches with this Tag
89
+ * @param {number | string} options.vehicle_id - Launches on this Vehicle
90
+ * @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
91
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
92
+ * @param {number | string} options.search - Launches matching this search string
93
+ * @param {number | string} options.slug - Launches matching this unique slug
94
+ *
95
+ * @returns {Promise<RLLResponse<RLLEntity.Launch[]>>} Array of companies wrapped in a standard RLL Response
96
+ *
97
+ * @example
98
+ *
99
+ * const response = client.launches({ after_date: new Date("2022-10-10") })
100
+ */
101
+ launches(options) {
102
+ return queryOptionsValidator(RLLEndPoint.LAUNCHES, options).then((params) => this.query(RLLEndPoint.LAUNCHES, params));
103
+ }
104
+ /**
105
+ * Fetch launch locations
106
+ *
107
+ * @public
108
+ * @function
109
+ *
110
+ * @param {Object} [options] - Launch Location Search Options
111
+ * @param {number | string} options.id - Location id
112
+ * @param {number | string} options.page - Page number of results
113
+ * @param {number | string} options.name - Location name
114
+ * @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
115
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
116
+ *
117
+ * @returns {Promise<RLLResponse<RLLEntity.Location[]>>} Array of companies wrapped in a standard RLL Response
118
+ *
119
+ * @example
120
+ *
121
+ * const response = client.locations({ country_code: "US" })
122
+ */
123
+ locations(options) {
124
+ return queryOptionsValidator(RLLEndPoint.LOCATIONS, options).then((params) => this.query(RLLEndPoint.LOCATIONS, params));
125
+ }
126
+ /**
127
+ * Fetch launch Missions
128
+ *
129
+ * @public
130
+ * @function
131
+ *
132
+ * @param {Object} [options] - Launch Mission Search Options
133
+ * @param {number | string} options.id - Mission id
134
+ * @param {number | string} options.page - Page number of results
135
+ * @param {number | string} options.name - Mission name
136
+ *
137
+ * @returns {Promise<RLLResponse<RLLEntity.Mission[]>>} Array of companies wrapped in a standard RLL Response
138
+ *
139
+ * @example
140
+ *
141
+ * const response = client.missions({ name: "Mars 2020" })
142
+ */
143
+ missions(options) {
144
+ return queryOptionsValidator(RLLEndPoint.MISSIONS, options).then((params) => this.query(RLLEndPoint.MISSIONS, params));
145
+ }
146
+ /**
147
+ * Fetch launch pads
148
+ *
149
+ * @public
150
+ * @function
151
+ *
152
+ * @param {Object} [options] - Launch Pad Search Options
153
+ * @param {number | string} options.id - Pad id
154
+ * @param {number | string} options.page - Page number of results
155
+ * @param {number | string} options.name - Pad name
156
+ * @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
157
+ * @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
158
+ *
159
+ * @returns {Promise<RLLResponse<RLLEntity.Pad[]>>} Array of companies wrapped in a standard RLL Response
160
+ *
161
+ * @example
162
+ *
163
+ * const response = client.pads({ country_code: "US" })
164
+ */
165
+ pads(options) {
166
+ return queryOptionsValidator(RLLEndPoint.PADS, options).then((params) => this.query(RLLEndPoint.PADS, params));
167
+ }
168
+ /**
169
+ * Fetch launch tags
170
+ *
171
+ * @public
172
+ * @function
173
+ *
174
+ * @param {Object} [options] - Launch Tag Search Options
175
+ * @param {number | string} options.id - Tag id
176
+ * @param {number | string} options.page - Page number of results
177
+ * @param {number | string} options.text - Tag text
178
+ *
179
+ * @returns {Promise<RLLResponse<RLLEntity.Tag[]>>} Array of companies wrapped in a standard RLL Response
180
+ *
181
+ * @example
182
+ *
183
+ * const response = client.tags({ text: "Crewed" })
184
+ */
185
+ tags(options) {
186
+ return queryOptionsValidator(RLLEndPoint.TAGS, options).then((params) => this.query(RLLEndPoint.TAGS, params));
187
+ }
188
+ /**
189
+ * Fetch launch Vehicles
190
+ *
191
+ * @public
192
+ * @function
193
+ *
194
+ * @param {Object} [options] - Launch Vehicles Search Options
195
+ * @param {number | string} options.id - Vehicle id
196
+ * @param {number | string} options.page - Page number of results
197
+ * @param {number | string} options.name - Vehicle name
198
+ *
199
+ * @returns {Promise<RLLResponse<RLLEntity.Vehicle[]>>} Array of companies wrapped in a standard RLL Response
200
+ *
201
+ * @example
202
+ *
203
+ * const response = client.vehicles({ name: "Falcon 9" })
204
+ */
205
+ vehicles(options) {
206
+ return queryOptionsValidator(RLLEndPoint.VEHICLES, options).then((params) => this.query(RLLEndPoint.VEHICLES, params));
207
+ }
208
+ }
@@ -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
+ };