rocket-launch-live-client 1.0.4 → 2.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 +105 -61
- package/lib/{esm/types/Client.d.ts → Client.d.ts} +6 -8
- package/lib/Client.js +61 -0
- package/lib/fetcher.d.ts +5 -0
- package/lib/fetcher.js +146 -0
- package/lib/{cjs/types/index.d.ts → index.d.ts} +0 -1
- package/lib/index.js +4 -0
- package/lib/{cjs/types/types → types}/application.d.ts +41 -27
- package/lib/types/application.js +41 -0
- package/lib/types/standards.d.ts +8 -0
- package/lib/types/standards.js +314 -0
- package/lib/{cjs/types/utils.d.ts → utils.d.ts} +1 -4
- package/lib/{esm/utils.js → utils.js} +18 -4
- package/lib/{cjs/types → watcher}/Watcher.d.ts +16 -12
- package/lib/watcher/Watcher.js +145 -0
- package/lib/watcher/index.d.ts +25 -0
- package/lib/watcher/index.js +3 -0
- package/package.json +30 -27
- package/lib/cjs/Client.js +0 -233
- package/lib/cjs/Watcher.js +0 -172
- package/lib/cjs/fetcher.js +0 -61
- package/lib/cjs/index.js +0 -30
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/types/Client.d.ts +0 -189
- package/lib/cjs/types/application.js +0 -46
- package/lib/cjs/types/fetcher.d.ts +0 -2
- package/lib/cjs/types/standards.js +0 -321
- package/lib/cjs/types/types/standards.d.ts +0 -316
- package/lib/cjs/utils.js +0 -266
- package/lib/esm/Client.js +0 -229
- package/lib/esm/Watcher.js +0 -168
- package/lib/esm/fetcher.js +0 -54
- package/lib/esm/index.mjs +0 -22
- package/lib/esm/package.json +0 -3
- package/lib/esm/types/Watcher.d.ts +0 -81
- package/lib/esm/types/application.js +0 -43
- package/lib/esm/types/fetcher.d.ts +0 -2
- package/lib/esm/types/index.d.ts +0 -24
- package/lib/esm/types/standards.js +0 -316
- package/lib/esm/types/types/application.d.ts +0 -206
- package/lib/esm/types/types/standards.d.ts +0 -316
- package/lib/esm/types/utils.d.ts +0 -12
package/lib/cjs/fetcher.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
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"));
|
|
8
|
-
const BASE_URL = "https://fdo.rocketlaunch.live";
|
|
9
|
-
const fetcher = (apiKey, endpoint, params, keyInQueryParams) => {
|
|
10
|
-
const url = new URL("json/" + endpoint, BASE_URL);
|
|
11
|
-
let headers;
|
|
12
|
-
if (keyInQueryParams) {
|
|
13
|
-
params.set("key", apiKey);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
headers = { authorization: `Bearer ${apiKey}` };
|
|
17
|
-
}
|
|
18
|
-
params.forEach((v, k) => url.searchParams.set(k, v));
|
|
19
|
-
return query(url, headers);
|
|
20
|
-
};
|
|
21
|
-
exports.fetcher = fetcher;
|
|
22
|
-
const query = (url, headers) => {
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
const req = https_1.default.get(url, { headers }, (res) => {
|
|
25
|
-
let data = [];
|
|
26
|
-
res.on("data", (chunk) => data.push(chunk));
|
|
27
|
-
res.on("end", () => {
|
|
28
|
-
var _a;
|
|
29
|
-
const response = Buffer.concat(data).toString();
|
|
30
|
-
let server_response;
|
|
31
|
-
try {
|
|
32
|
-
server_response = JSON.parse(response);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
server_response = response;
|
|
36
|
-
}
|
|
37
|
-
if (res.statusCode === 200) {
|
|
38
|
-
resolve(server_response);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
const error = {
|
|
42
|
-
error: "API Call Failed",
|
|
43
|
-
statusCode: (_a = res.statusCode) !== null && _a !== void 0 ? _a : null,
|
|
44
|
-
message: "RLLC recieved a response from the server but it did not complete as expected.",
|
|
45
|
-
server_response,
|
|
46
|
-
};
|
|
47
|
-
reject(error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
req.on("error", () => {
|
|
52
|
-
const error = {
|
|
53
|
-
error: "Unknown error",
|
|
54
|
-
statusCode: null,
|
|
55
|
-
message: "RLLC recieved an unknown error. This usually means that the HTTP request did not complete",
|
|
56
|
-
server_response: null,
|
|
57
|
-
};
|
|
58
|
-
reject(error);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
};
|
package/lib/cjs/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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_js_1 = require("./Client.js");
|
|
5
|
-
var application_js_1 = require("./types/application.js");
|
|
6
|
-
Object.defineProperty(exports, "RLLEndPoint", { enumerable: true, get: function () { return application_js_1.RLLEndPoint; } });
|
|
7
|
-
Object.defineProperty(exports, "RLLEntity", { enumerable: true, get: function () { return application_js_1.RLLEntity; } });
|
|
8
|
-
var Client_js_2 = require("./Client.js");
|
|
9
|
-
Object.defineProperty(exports, "RLLClient", { enumerable: true, get: function () { return Client_js_2.RLLClient; } });
|
|
10
|
-
var Watcher_js_1 = require("./Watcher.js");
|
|
11
|
-
Object.defineProperty(exports, "RLLWatcher", { enumerable: true, get: function () { return Watcher_js_1.RLLWatcher; } });
|
|
12
|
-
/**
|
|
13
|
-
* Generate a RocketLaunch.Live client
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
* @function
|
|
17
|
-
*
|
|
18
|
-
* @param {string} apiKey - Your RocketLaunch.Live API Key
|
|
19
|
-
* @param {Object} [options] - Optional Client Configuration options
|
|
20
|
-
* @param {boolean} options.keyInQueryParams - Set to true to send your API Key via Query parameters instead of Authorization Header (not recommended)
|
|
21
|
-
*
|
|
22
|
-
* @returns {RLLCLient}
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
*
|
|
26
|
-
* const MY_KEY = process.env.ROCKETLAUNCH_LIVE_API_KEY
|
|
27
|
-
* const client = rllc(MY_KEY, { keyInQueryParams: true })
|
|
28
|
-
*/
|
|
29
|
-
const rllc = (apiKey, options) => new Client_js_1.RLLClient(apiKey, options);
|
|
30
|
-
exports.rllc = rllc;
|
package/lib/cjs/package.json
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { RLLClientOptions, RLLEntity, RLLQueryConfig, RLLResponse } from "./types/application.js";
|
|
2
|
-
import { RLLWatcher } from "./Watcher.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class representing a RocketLaunch.Live client
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
export declare class RLLClient {
|
|
8
|
-
private apiKey;
|
|
9
|
-
private config;
|
|
10
|
-
/**
|
|
11
|
-
* Create a new RocketLaunch.live Client
|
|
12
|
-
*
|
|
13
|
-
* @param {string} apiKey - Your RocketLaunch.Live API Key
|
|
14
|
-
* @param {Object} [options] - Optional Client Configuration options
|
|
15
|
-
* @param {boolean} options.keyInQueryParams - Set to true to send your API Key via Query parameters instead of Authorization Header (not recommended)
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
constructor(apiKey: string, options?: RLLClientOptions);
|
|
19
|
-
/**
|
|
20
|
-
* Used internally to make API query
|
|
21
|
-
*
|
|
22
|
-
* @private
|
|
23
|
-
*
|
|
24
|
-
* @template T
|
|
25
|
-
*
|
|
26
|
-
* @param {string} endpoint - API endpoint (ie. "/launches")
|
|
27
|
-
* @param {URLSearchParams} params - API Search Params
|
|
28
|
-
*
|
|
29
|
-
* @returns {Promise<T>}
|
|
30
|
-
*/
|
|
31
|
-
private query;
|
|
32
|
-
/**
|
|
33
|
-
* Instantiate a new RLL Watcher which will continually query the API for changes to the launches endpoint
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*
|
|
37
|
-
* @param {number} interval - Interval in minutes to query the API for changes. Defaults to 5 minutes, cannot be less than 1 minute
|
|
38
|
-
* @param {RLLQueryConfig.Launches} options - Query options, same as calling the launches method
|
|
39
|
-
*
|
|
40
|
-
* @returns {RLLWatcher}
|
|
41
|
-
*/
|
|
42
|
-
watch(interval?: number | string, options?: RLLQueryConfig.Launches): RLLWatcher;
|
|
43
|
-
/**
|
|
44
|
-
* Fetch launch companies
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
* @function
|
|
48
|
-
*
|
|
49
|
-
* @param {Object} [options] - Launch Company Search Options
|
|
50
|
-
* @param {number | string} options.id - Company id
|
|
51
|
-
* @param {number | string} options.page - Page number of results
|
|
52
|
-
* @param {number | string} options.name - Company name
|
|
53
|
-
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
54
|
-
* @param {boolean} options.inactive - Company inactive status
|
|
55
|
-
*
|
|
56
|
-
* @returns {Promise<RLLResponse<RLLEntity.Company[]>>} Array of companies wrapped in a standard RLL Response
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
*
|
|
60
|
-
* const response = await client.companies({ country_code: "US" })
|
|
61
|
-
*/
|
|
62
|
-
companies(options?: RLLQueryConfig.Companies): Promise<RLLResponse<RLLEntity.Company[]>>;
|
|
63
|
-
/**
|
|
64
|
-
* Fetch launches
|
|
65
|
-
*
|
|
66
|
-
* @public
|
|
67
|
-
* @function
|
|
68
|
-
*
|
|
69
|
-
* @param {Object} [options] - Launch Search Options
|
|
70
|
-
* @param {number | string} options.id - Launch id
|
|
71
|
-
* @param {number | string} options.page - Page number of results
|
|
72
|
-
* @param {string} options.cospar_id - Launch COSPAR ID (ie. 2022-123)
|
|
73
|
-
* @param {Date | string} options.before_date - Only return launches before this date
|
|
74
|
-
* @param {Date | string} options.after_date - Only return launches after this date
|
|
75
|
-
* @param {Date | string} options.modified_since - Only return launches with API changes after this date
|
|
76
|
-
* @param {number | string} options.location_id - Launches from this Location
|
|
77
|
-
* @param {number | string} options.pad_id - Launches from this Pad
|
|
78
|
-
* @param {number | string} options.provider_id - Launches from this Company
|
|
79
|
-
* @param {number | string} options.tag_id - Launches with this Tag
|
|
80
|
-
* @param {number | string} options.vehicle_id - Launches on this Vehicle
|
|
81
|
-
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
82
|
-
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
83
|
-
* @param {number | string} options.search - Launches matching this search string
|
|
84
|
-
* @param {number | string} options.slug - Launches matching this unique slug
|
|
85
|
-
* @param {number | string} options.limit - Limit results (default 25, max 25)
|
|
86
|
-
* @param {'asc' | 'desc'} options.direction - Launches matching this unique slug
|
|
87
|
-
*
|
|
88
|
-
* @returns {Promise<RLLResponse<RLLEntity.Launch[]>>} Array of companies wrapped in a standard RLL Response
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
*
|
|
92
|
-
* const response = await client.launches({ after_date: new Date("2022-10-10") })
|
|
93
|
-
*/
|
|
94
|
-
launches(options?: RLLQueryConfig.Launches): Promise<RLLResponse<RLLEntity.Launch[]>>;
|
|
95
|
-
/**
|
|
96
|
-
* Fetch launch locations
|
|
97
|
-
*
|
|
98
|
-
* @public
|
|
99
|
-
* @function
|
|
100
|
-
*
|
|
101
|
-
* @param {Object} [options] - Launch Location Search Options
|
|
102
|
-
* @param {number | string} options.id - Location id
|
|
103
|
-
* @param {number | string} options.page - Page number of results
|
|
104
|
-
* @param {number | string} options.name - Location name
|
|
105
|
-
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
106
|
-
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
107
|
-
*
|
|
108
|
-
* @returns {Promise<RLLResponse<RLLEntity.Location[]>>} Array of companies wrapped in a standard RLL Response
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
*
|
|
112
|
-
* const response = await client.locations({ country_code: "US" })
|
|
113
|
-
*/
|
|
114
|
-
locations(options?: RLLQueryConfig.Locations): Promise<RLLResponse<RLLEntity.Location[]>>;
|
|
115
|
-
/**
|
|
116
|
-
* Fetch launch Missions
|
|
117
|
-
*
|
|
118
|
-
* @public
|
|
119
|
-
* @function
|
|
120
|
-
*
|
|
121
|
-
* @param {Object} [options] - Launch Mission Search Options
|
|
122
|
-
* @param {number | string} options.id - Mission id
|
|
123
|
-
* @param {number | string} options.page - Page number of results
|
|
124
|
-
* @param {number | string} options.name - Mission name
|
|
125
|
-
*
|
|
126
|
-
* @returns {Promise<RLLResponse<RLLEntity.Mission[]>>} Array of companies wrapped in a standard RLL Response
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
*
|
|
130
|
-
* const response = await client.missions({ name: "Mars 2020" })
|
|
131
|
-
*/
|
|
132
|
-
missions(options?: RLLQueryConfig.Missions): Promise<RLLResponse<RLLEntity.Mission[]>>;
|
|
133
|
-
/**
|
|
134
|
-
* Fetch launch pads
|
|
135
|
-
*
|
|
136
|
-
* @public
|
|
137
|
-
* @function
|
|
138
|
-
*
|
|
139
|
-
* @param {Object} [options] - Launch Pad Search Options
|
|
140
|
-
* @param {number | string} options.id - Pad id
|
|
141
|
-
* @param {number | string} options.page - Page number of results
|
|
142
|
-
* @param {number | string} options.name - Pad name
|
|
143
|
-
* @param {ISO3166Alpha2.StateCodeUS} options.state_abbr - ISO 3166 Alpha 2 US State Code
|
|
144
|
-
* @param {ISO3166Alpha2.CountryCode} options.country_code - ISO 3166 Alpha 2 Country Code
|
|
145
|
-
*
|
|
146
|
-
* @returns {Promise<RLLResponse<RLLEntity.Pad[]>>} Array of companies wrapped in a standard RLL Response
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
*
|
|
150
|
-
* const response = await client.pads({ country_code: "US" })
|
|
151
|
-
*/
|
|
152
|
-
pads(options?: RLLQueryConfig.Pads): Promise<RLLResponse<RLLEntity.Pad[]>>;
|
|
153
|
-
/**
|
|
154
|
-
* Fetch launch tags
|
|
155
|
-
*
|
|
156
|
-
* @public
|
|
157
|
-
* @function
|
|
158
|
-
*
|
|
159
|
-
* @param {Object} [options] - Launch Tag Search Options
|
|
160
|
-
* @param {number | string} options.id - Tag id
|
|
161
|
-
* @param {number | string} options.page - Page number of results
|
|
162
|
-
* @param {number | string} options.text - Tag text
|
|
163
|
-
*
|
|
164
|
-
* @returns {Promise<RLLResponse<RLLEntity.Tag[]>>} Array of companies wrapped in a standard RLL Response
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
*
|
|
168
|
-
* const response = await client.tags({ text: "Crewed" })
|
|
169
|
-
*/
|
|
170
|
-
tags(options?: RLLQueryConfig.Tags): Promise<RLLResponse<RLLEntity.Tag[]>>;
|
|
171
|
-
/**
|
|
172
|
-
* Fetch launch Vehicles
|
|
173
|
-
*
|
|
174
|
-
* @public
|
|
175
|
-
* @function
|
|
176
|
-
*
|
|
177
|
-
* @param {Object} [options] - Launch Vehicles Search Options
|
|
178
|
-
* @param {number | string} options.id - Vehicle id
|
|
179
|
-
* @param {number | string} options.page - Page number of results
|
|
180
|
-
* @param {number | string} options.name - Vehicle name
|
|
181
|
-
*
|
|
182
|
-
* @returns {Promise<RLLResponse<RLLEntity.Vehicle[]>>} Array of companies wrapped in a standard RLL Response
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
*
|
|
186
|
-
* const response = await client.vehicles({ name: "Falcon 9" })
|
|
187
|
-
*/
|
|
188
|
-
vehicles(options?: RLLQueryConfig.Vehicles): Promise<RLLResponse<RLLEntity.Vehicle[]>>;
|
|
189
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RLLQueryParams = exports.RLLEntity = exports.RLLEndPoint = void 0;
|
|
4
|
-
var RLLEndPoint;
|
|
5
|
-
(function (RLLEndPoint) {
|
|
6
|
-
RLLEndPoint["COMPANIES"] = "companies";
|
|
7
|
-
RLLEndPoint["LAUNCHES"] = "launches";
|
|
8
|
-
RLLEndPoint["LOCATIONS"] = "locations";
|
|
9
|
-
RLLEndPoint["MISSIONS"] = "missions";
|
|
10
|
-
RLLEndPoint["PADS"] = "pads";
|
|
11
|
-
RLLEndPoint["TAGS"] = "tags";
|
|
12
|
-
RLLEndPoint["VEHICLES"] = "vehicles";
|
|
13
|
-
})(RLLEndPoint || (exports.RLLEndPoint = RLLEndPoint = {}));
|
|
14
|
-
var RLLEntity;
|
|
15
|
-
(function (RLLEntity) {
|
|
16
|
-
let LaunchResult;
|
|
17
|
-
(function (LaunchResult) {
|
|
18
|
-
LaunchResult[LaunchResult["NOT_SET"] = -1] = "NOT_SET";
|
|
19
|
-
LaunchResult[LaunchResult["FAILURE"] = 0] = "FAILURE";
|
|
20
|
-
LaunchResult[LaunchResult["SUCCESS"] = 1] = "SUCCESS";
|
|
21
|
-
LaunchResult[LaunchResult["PARTIAL_FAILURE"] = 2] = "PARTIAL_FAILURE";
|
|
22
|
-
LaunchResult[LaunchResult["IN_FLIGHT_ABORT_CREWED"] = 3] = "IN_FLIGHT_ABORT_CREWED";
|
|
23
|
-
})(LaunchResult = RLLEntity.LaunchResult || (RLLEntity.LaunchResult = {}));
|
|
24
|
-
})(RLLEntity || (exports.RLLEntity = RLLEntity = {}));
|
|
25
|
-
exports.RLLQueryParams = {
|
|
26
|
-
id: true,
|
|
27
|
-
page: true,
|
|
28
|
-
name: true,
|
|
29
|
-
country_code: true,
|
|
30
|
-
inactive: true,
|
|
31
|
-
cospar_id: true,
|
|
32
|
-
after_date: true,
|
|
33
|
-
before_date: true,
|
|
34
|
-
modified_since: true,
|
|
35
|
-
location_id: true,
|
|
36
|
-
pad_id: true,
|
|
37
|
-
provider_id: true,
|
|
38
|
-
tag_id: true,
|
|
39
|
-
vehicle_id: true,
|
|
40
|
-
state_abbr: true,
|
|
41
|
-
search: true,
|
|
42
|
-
slug: true,
|
|
43
|
-
text: true,
|
|
44
|
-
limit: true,
|
|
45
|
-
direction: true,
|
|
46
|
-
};
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidStateCode = exports.isValidCountryCode = exports.usStateCodes = exports.countryCodes = void 0;
|
|
4
|
-
exports.countryCodes = {
|
|
5
|
-
AF: "AF",
|
|
6
|
-
AL: "AL",
|
|
7
|
-
DZ: "DZ",
|
|
8
|
-
AS: "AS",
|
|
9
|
-
AD: "AD",
|
|
10
|
-
AO: "AO",
|
|
11
|
-
AI: "AI",
|
|
12
|
-
AQ: "AQ",
|
|
13
|
-
AG: "AG",
|
|
14
|
-
AR: "AR",
|
|
15
|
-
AM: "AM",
|
|
16
|
-
AW: "AW",
|
|
17
|
-
AU: "AU",
|
|
18
|
-
AT: "AT",
|
|
19
|
-
AZ: "AZ",
|
|
20
|
-
BS: "BS",
|
|
21
|
-
BH: "BH",
|
|
22
|
-
BD: "BD",
|
|
23
|
-
BB: "BB",
|
|
24
|
-
BY: "BY",
|
|
25
|
-
BE: "BE",
|
|
26
|
-
BZ: "BZ",
|
|
27
|
-
BJ: "BJ",
|
|
28
|
-
BM: "BM",
|
|
29
|
-
BT: "BT",
|
|
30
|
-
BO: "BO",
|
|
31
|
-
BQ: "BQ",
|
|
32
|
-
BA: "BA",
|
|
33
|
-
BW: "BW",
|
|
34
|
-
BV: "BV",
|
|
35
|
-
BR: "BR",
|
|
36
|
-
IO: "IO",
|
|
37
|
-
BN: "BN",
|
|
38
|
-
BG: "BG",
|
|
39
|
-
BF: "BF",
|
|
40
|
-
BI: "BI",
|
|
41
|
-
CV: "CV",
|
|
42
|
-
KH: "KH",
|
|
43
|
-
CM: "CM",
|
|
44
|
-
CA: "CA",
|
|
45
|
-
KY: "KY",
|
|
46
|
-
CF: "CF",
|
|
47
|
-
TD: "TD",
|
|
48
|
-
CL: "CL",
|
|
49
|
-
CN: "CN",
|
|
50
|
-
CX: "CX",
|
|
51
|
-
CC: "CC",
|
|
52
|
-
CO: "CO",
|
|
53
|
-
KM: "KM",
|
|
54
|
-
CD: "CD",
|
|
55
|
-
CG: "CG",
|
|
56
|
-
CK: "CK",
|
|
57
|
-
CR: "CR",
|
|
58
|
-
HR: "HR",
|
|
59
|
-
CU: "CU",
|
|
60
|
-
CW: "CW",
|
|
61
|
-
CY: "CY",
|
|
62
|
-
CZ: "CZ",
|
|
63
|
-
CI: "CI",
|
|
64
|
-
DK: "DK",
|
|
65
|
-
DJ: "DJ",
|
|
66
|
-
DM: "DM",
|
|
67
|
-
DO: "DO",
|
|
68
|
-
EC: "EC",
|
|
69
|
-
EG: "EG",
|
|
70
|
-
SV: "SV",
|
|
71
|
-
GQ: "GQ",
|
|
72
|
-
ER: "ER",
|
|
73
|
-
EE: "EE",
|
|
74
|
-
SZ: "SZ",
|
|
75
|
-
ET: "ET",
|
|
76
|
-
FK: "FK",
|
|
77
|
-
FO: "FO",
|
|
78
|
-
FJ: "FJ",
|
|
79
|
-
FI: "FI",
|
|
80
|
-
FR: "FR",
|
|
81
|
-
GF: "GF",
|
|
82
|
-
PF: "PF",
|
|
83
|
-
TF: "TF",
|
|
84
|
-
GA: "GA",
|
|
85
|
-
GM: "GM",
|
|
86
|
-
GE: "GE",
|
|
87
|
-
DE: "DE",
|
|
88
|
-
GH: "GH",
|
|
89
|
-
GI: "GI",
|
|
90
|
-
GR: "GR",
|
|
91
|
-
GL: "GL",
|
|
92
|
-
GD: "GD",
|
|
93
|
-
GP: "GP",
|
|
94
|
-
GU: "GU",
|
|
95
|
-
GT: "GT",
|
|
96
|
-
GG: "GG",
|
|
97
|
-
GN: "GN",
|
|
98
|
-
GW: "GW",
|
|
99
|
-
GY: "GY",
|
|
100
|
-
HT: "HT",
|
|
101
|
-
HM: "HM",
|
|
102
|
-
VA: "VA",
|
|
103
|
-
HN: "HN",
|
|
104
|
-
HK: "HK",
|
|
105
|
-
HU: "HU",
|
|
106
|
-
IS: "IS",
|
|
107
|
-
IN: "IN",
|
|
108
|
-
ID: "ID",
|
|
109
|
-
IR: "IR",
|
|
110
|
-
IQ: "IQ",
|
|
111
|
-
IE: "IE",
|
|
112
|
-
IM: "IM",
|
|
113
|
-
IL: "IL",
|
|
114
|
-
IT: "IT",
|
|
115
|
-
JM: "JM",
|
|
116
|
-
JP: "JP",
|
|
117
|
-
JE: "JE",
|
|
118
|
-
JO: "JO",
|
|
119
|
-
KZ: "KZ",
|
|
120
|
-
KE: "KE",
|
|
121
|
-
KI: "KI",
|
|
122
|
-
KP: "KP",
|
|
123
|
-
KR: "KR",
|
|
124
|
-
KW: "KW",
|
|
125
|
-
KG: "KG",
|
|
126
|
-
LA: "LA",
|
|
127
|
-
LV: "LV",
|
|
128
|
-
LB: "LB",
|
|
129
|
-
LS: "LS",
|
|
130
|
-
LR: "LR",
|
|
131
|
-
LY: "LY",
|
|
132
|
-
LI: "LI",
|
|
133
|
-
LT: "LT",
|
|
134
|
-
LU: "LU",
|
|
135
|
-
MO: "MO",
|
|
136
|
-
MG: "MG",
|
|
137
|
-
MW: "MW",
|
|
138
|
-
MY: "MY",
|
|
139
|
-
MV: "MV",
|
|
140
|
-
ML: "ML",
|
|
141
|
-
MT: "MT",
|
|
142
|
-
MH: "MH",
|
|
143
|
-
MQ: "MQ",
|
|
144
|
-
MR: "MR",
|
|
145
|
-
MU: "MU",
|
|
146
|
-
YT: "YT",
|
|
147
|
-
MX: "MX",
|
|
148
|
-
FM: "FM",
|
|
149
|
-
MD: "MD",
|
|
150
|
-
MC: "MC",
|
|
151
|
-
MN: "MN",
|
|
152
|
-
ME: "ME",
|
|
153
|
-
MS: "MS",
|
|
154
|
-
MA: "MA",
|
|
155
|
-
MZ: "MZ",
|
|
156
|
-
MM: "MM",
|
|
157
|
-
NA: "NA",
|
|
158
|
-
NR: "NR",
|
|
159
|
-
NP: "NP",
|
|
160
|
-
NL: "NL",
|
|
161
|
-
NC: "NC",
|
|
162
|
-
NZ: "NZ",
|
|
163
|
-
NI: "NI",
|
|
164
|
-
NE: "NE",
|
|
165
|
-
NG: "NG",
|
|
166
|
-
NU: "NU",
|
|
167
|
-
NF: "NF",
|
|
168
|
-
MP: "MP",
|
|
169
|
-
NO: "NO",
|
|
170
|
-
OM: "OM",
|
|
171
|
-
PK: "PK",
|
|
172
|
-
PW: "PW",
|
|
173
|
-
PS: "PS",
|
|
174
|
-
PA: "PA",
|
|
175
|
-
PG: "PG",
|
|
176
|
-
PY: "PY",
|
|
177
|
-
PE: "PE",
|
|
178
|
-
PH: "PH",
|
|
179
|
-
PN: "PN",
|
|
180
|
-
PL: "PL",
|
|
181
|
-
PT: "PT",
|
|
182
|
-
PR: "PR",
|
|
183
|
-
QA: "QA",
|
|
184
|
-
MK: "MK",
|
|
185
|
-
RO: "RO",
|
|
186
|
-
RU: "RU",
|
|
187
|
-
RW: "RW",
|
|
188
|
-
RE: "RE",
|
|
189
|
-
BL: "BL",
|
|
190
|
-
SH: "SH",
|
|
191
|
-
KN: "KN",
|
|
192
|
-
LC: "LC",
|
|
193
|
-
MF: "MF",
|
|
194
|
-
PM: "PM",
|
|
195
|
-
VC: "VC",
|
|
196
|
-
WS: "WS",
|
|
197
|
-
SM: "SM",
|
|
198
|
-
ST: "ST",
|
|
199
|
-
SA: "SA",
|
|
200
|
-
SN: "SN",
|
|
201
|
-
RS: "RS",
|
|
202
|
-
SC: "SC",
|
|
203
|
-
SL: "SL",
|
|
204
|
-
SG: "SG",
|
|
205
|
-
SX: "SX",
|
|
206
|
-
SK: "SK",
|
|
207
|
-
SI: "SI",
|
|
208
|
-
SB: "SB",
|
|
209
|
-
SO: "SO",
|
|
210
|
-
ZA: "ZA",
|
|
211
|
-
GS: "GS",
|
|
212
|
-
SS: "SS",
|
|
213
|
-
ES: "ES",
|
|
214
|
-
LK: "LK",
|
|
215
|
-
SD: "SD",
|
|
216
|
-
SR: "SR",
|
|
217
|
-
SJ: "SJ",
|
|
218
|
-
SE: "SE",
|
|
219
|
-
CH: "CH",
|
|
220
|
-
SY: "SY",
|
|
221
|
-
TW: "TW",
|
|
222
|
-
TJ: "TJ",
|
|
223
|
-
TZ: "TZ",
|
|
224
|
-
TH: "TH",
|
|
225
|
-
TL: "TL",
|
|
226
|
-
TG: "TG",
|
|
227
|
-
TK: "TK",
|
|
228
|
-
TO: "TO",
|
|
229
|
-
TT: "TT",
|
|
230
|
-
TN: "TN",
|
|
231
|
-
TR: "TR",
|
|
232
|
-
TM: "TM",
|
|
233
|
-
TC: "TC",
|
|
234
|
-
TV: "TV",
|
|
235
|
-
UG: "UG",
|
|
236
|
-
UA: "UA",
|
|
237
|
-
AE: "AE",
|
|
238
|
-
GB: "GB",
|
|
239
|
-
UM: "UM",
|
|
240
|
-
US: "US",
|
|
241
|
-
UY: "UY",
|
|
242
|
-
UZ: "UZ",
|
|
243
|
-
VU: "VU",
|
|
244
|
-
VE: "VE",
|
|
245
|
-
VN: "VN",
|
|
246
|
-
VG: "VG",
|
|
247
|
-
VI: "VI",
|
|
248
|
-
WF: "WF",
|
|
249
|
-
EH: "EH",
|
|
250
|
-
YE: "YE",
|
|
251
|
-
ZM: "ZM",
|
|
252
|
-
ZW: "ZW",
|
|
253
|
-
AX: "AX",
|
|
254
|
-
};
|
|
255
|
-
exports.usStateCodes = {
|
|
256
|
-
AL: "AL",
|
|
257
|
-
AK: "AK",
|
|
258
|
-
AZ: "AZ",
|
|
259
|
-
AR: "AR",
|
|
260
|
-
CA: "CA",
|
|
261
|
-
CO: "CO",
|
|
262
|
-
CT: "CT",
|
|
263
|
-
DE: "DE",
|
|
264
|
-
FL: "FL",
|
|
265
|
-
GA: "GA",
|
|
266
|
-
HI: "HI",
|
|
267
|
-
ID: "ID",
|
|
268
|
-
IL: "IL",
|
|
269
|
-
IN: "IN",
|
|
270
|
-
IA: "IA",
|
|
271
|
-
KS: "KS",
|
|
272
|
-
KY: "KY",
|
|
273
|
-
LA: "LA",
|
|
274
|
-
ME: "ME",
|
|
275
|
-
MD: "MD",
|
|
276
|
-
MA: "MA",
|
|
277
|
-
MI: "MI",
|
|
278
|
-
MN: "MN",
|
|
279
|
-
MS: "MS",
|
|
280
|
-
MO: "MO",
|
|
281
|
-
MT: "MT",
|
|
282
|
-
NE: "NE",
|
|
283
|
-
NV: "NV",
|
|
284
|
-
NH: "NH",
|
|
285
|
-
NJ: "NJ",
|
|
286
|
-
NM: "NM",
|
|
287
|
-
NY: "NY",
|
|
288
|
-
NC: "NC",
|
|
289
|
-
ND: "ND",
|
|
290
|
-
OH: "OH",
|
|
291
|
-
OK: "OK",
|
|
292
|
-
OR: "OR",
|
|
293
|
-
PA: "PA",
|
|
294
|
-
RI: "RI",
|
|
295
|
-
SC: "SC",
|
|
296
|
-
SD: "SD",
|
|
297
|
-
TN: "TN",
|
|
298
|
-
TX: "TX",
|
|
299
|
-
UT: "UT",
|
|
300
|
-
VT: "VT",
|
|
301
|
-
VA: "VA",
|
|
302
|
-
WA: "WA",
|
|
303
|
-
WV: "WV",
|
|
304
|
-
WI: "WI",
|
|
305
|
-
WY: "WY",
|
|
306
|
-
DC: "DC",
|
|
307
|
-
AS: "AS",
|
|
308
|
-
GU: "GU",
|
|
309
|
-
MP: "MP",
|
|
310
|
-
PR: "PR",
|
|
311
|
-
UM: "UM",
|
|
312
|
-
VI: "VI",
|
|
313
|
-
};
|
|
314
|
-
const isValidCountryCode = (code) => {
|
|
315
|
-
return !!exports.countryCodes[code];
|
|
316
|
-
};
|
|
317
|
-
exports.isValidCountryCode = isValidCountryCode;
|
|
318
|
-
const isValidStateCode = (code) => {
|
|
319
|
-
return !!exports.usStateCodes[code];
|
|
320
|
-
};
|
|
321
|
-
exports.isValidStateCode = isValidStateCode;
|