@parseapi/sdk 0.4.0 → 1.1.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 +40 -4
- package/dist/index.cjs +16 -10
- package/dist/index.d.cts +167 -41
- package/dist/index.d.ts +167 -41
- package/dist/index.js +16 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,11 +17,29 @@ Get a key at [parseapi.com](https://parseapi.com). The client also reads `PARSEA
|
|
|
17
17
|
|
|
18
18
|
## API versions
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Version 1.1.0 explicitly selects the API contract supported by this SDK. It sends `Parse-Version: 2.0.0` on every lookup so responses match the API contract supported by the package. Your key and the team's saved default stay the same.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Upgrade the dependency in staging, review the [release notes](https://parseapi.com/docs/releases), and test the application before deploying the same code and dependency version to production. Commit your dependency lockfile so the tested package travels with your deployment. Future major SDK upgrades can select a newer API contract.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
SDK packages older than 1.0.0 keep their existing behavior and use the team's default. Requests without `Parse-Version` also use that default, managed in [Dashboard API version](https://parseapi.com/dashboard/versions). Keep it unchanged while older applications depend on it. Rolling back to an SDK without a version header restores the team default, so rollback only restores the old contract when that default has stayed unchanged.
|
|
25
|
+
|
|
26
|
+
The package owns its supported API version. For direct HTTP integrations, an explicit `Parse-Version` header selects a supported contract. See [API versions and migration](https://parseapi.com/docs/versioning).
|
|
27
|
+
|
|
28
|
+
## Task preflight
|
|
29
|
+
|
|
30
|
+
Use a secret key to estimate access, advisory capacity and additional charges before a task. Preflight is available with API contract `2.0.0`.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const estimate = await parse.preflight({
|
|
34
|
+
operations: [{ operation: 'email', count: 100, deep: true }],
|
|
35
|
+
budget_usd: '2.50',
|
|
36
|
+
});
|
|
37
|
+
console.log(estimate.permitted, estimate.cost, estimate.capacity, estimate.budget);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Preflight accepts Email, Domain, DNS, MX and Country, with at most 20 rows and 100,000 total lookups. Supply operation counts without personal data or lookup inputs. Monetary values use decimal strings. The maximum assumes included Email checks are exhausted. The projection uses currently unallocated included checks. Rates come from the credential's accepted terms.
|
|
41
|
+
|
|
42
|
+
Check `permitted`, `cost.status`, `capacity` and the optional `budget.within_maximum` together. Unknown values remain null. Capacity can change with concurrent work. Preflight reserves no units or money, performs no paid checks and does not enforce the supplied budget. It uses the normal request rate limit. Estimates allow up to three attempts per ordinary lookup and one per Email Deep lookup. Extra retries or calls require a new estimate. Subscription fees, tax and model costs are excluded.
|
|
25
43
|
|
|
26
44
|
## Weather from a postal code
|
|
27
45
|
|
|
@@ -43,6 +61,23 @@ Pass `country` when a postal code or national phone number needs disambiguation.
|
|
|
43
61
|
|
|
44
62
|
Results are plain data. Pass a returned code or coordinate to another operation when the task needs it. Check nullable values before composing the next call.
|
|
45
63
|
|
|
64
|
+
Name paid deep includes flat `short`, `directory`, and `initials` fields beside `gender` and `salutation`. `name_locale` selects CLDR formatting rules and defaults to `en`. It changes formatting only. Country remains gender context, and unavailable formatting is null. Older responses may omit these fields.
|
|
65
|
+
|
|
66
|
+
## Display language
|
|
67
|
+
|
|
68
|
+
This source candidate accepts an optional per-request `lang` on supported
|
|
69
|
+
operations. It requires the matching API localization release and data.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const country = await parse.country('DE', { lang: 'fr' });
|
|
73
|
+
// country: 'DE', name: 'Allemagne', name_local: 'Deutschland'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Only supported display fields change. Missing translations keep their source
|
|
77
|
+
names. IDs, native-name fields, numeric facts, Date input `format`, and Measure
|
|
78
|
+
input `locale` retain their meaning. Omitting `lang` preserves the existing
|
|
79
|
+
behavior and does not inherit a previous request's choice.
|
|
80
|
+
|
|
46
81
|
## Calls
|
|
47
82
|
|
|
48
83
|
One method per endpoint, named after the route.
|
|
@@ -87,6 +122,7 @@ await parse.currency.rate('USD', 'EUR');
|
|
|
87
122
|
await parse.language('en');
|
|
88
123
|
await parse.name('BILLY OSHALL');
|
|
89
124
|
await parse.name('Andrea', { country: 'IT', deep: true });
|
|
125
|
+
await parse.name('Robert James Smith', { deep: true, name_locale: 'en' });
|
|
90
126
|
await parse.time(); // UTC now
|
|
91
127
|
await parse.time('America/New_York');
|
|
92
128
|
await parse.time('America/New_York', { at: '2026-09-05T15:00:00', to: 'Asia/Tokyo' });
|
|
@@ -144,7 +180,7 @@ const place = await parse.postal('28202', { country: 'US', deep: true });
|
|
|
144
180
|
const propertyTax = place.deep?.property_tax;
|
|
145
181
|
```
|
|
146
182
|
|
|
147
|
-
Read `population_period` alongside `population`: a reporting year (`YYYY`) or period (`YYYY-YYYY`), null when unknown or unverifiable. Keep missing or null values unknown and preserve a known zero. These fields belong to full place profiles. State district lists include each district's population and period. Postal nearby and distance detail remains metropolitan associations only. Continent population
|
|
183
|
+
Read `population_period` alongside `population`: a reporting year (`YYYY`) or period (`YYYY-YYYY`), null when unknown or unverifiable. Keep missing or null values unknown and preserve a known zero. These fields belong to full place profiles. State district lists include each district's population and period. Postal nearby and distance detail remains metropolitan associations only. Continent population stays in core; Continent has no `population_period` field.
|
|
148
184
|
|
|
149
185
|
Point returns the timezone ID with the core location. Its optional deep detail adds terrain and compact nearest-city context on every plan. A nearest city is null when none is within 200 km.
|
|
150
186
|
|
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,8 @@ __export(index_exports, {
|
|
|
24
24
|
parseAPI: () => parseAPI
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var VERSION = "
|
|
27
|
+
var VERSION = "1.1.0";
|
|
28
|
+
var API_VERSION = "2.0.0";
|
|
28
29
|
var DEFAULT_BASE_URL = "https://api.parseapi.com";
|
|
29
30
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
30
31
|
var DEFAULT_RETRIES = 2;
|
|
@@ -106,14 +107,16 @@ function parseAPI(apiKey, options = {}) {
|
|
|
106
107
|
validateTimeout(timeoutMs);
|
|
107
108
|
validateRetries(configuredRetries);
|
|
108
109
|
const doFetch = options.fetch ?? fetch;
|
|
109
|
-
async function request(path, query, headers, controls = {}) {
|
|
110
|
+
async function request(path, query, headers, controls = {}, json) {
|
|
110
111
|
const signal = controls.signal;
|
|
111
112
|
signal?.throwIfAborted();
|
|
112
113
|
const attemptTimeout = controls.timeoutMs ?? timeoutMs;
|
|
113
114
|
const retries = controls.retries ?? configuredRetries ?? (metered(path, query) ? 0 : DEFAULT_RETRIES);
|
|
114
115
|
validateTimeout(attemptTimeout);
|
|
115
116
|
validateRetries(retries);
|
|
117
|
+
const body = json === void 0 ? void 0 : JSON.stringify(json);
|
|
116
118
|
const url = new URL(baseUrl + path);
|
|
119
|
+
if (controls.lang !== void 0) url.searchParams.set("lang", controls.lang);
|
|
117
120
|
for (const [name, value] of Object.entries(query ?? {})) {
|
|
118
121
|
if (value !== void 0) url.searchParams.set(name, String(value));
|
|
119
122
|
}
|
|
@@ -129,7 +132,8 @@ function parseAPI(apiKey, options = {}) {
|
|
|
129
132
|
try {
|
|
130
133
|
res = await doFetch(url, {
|
|
131
134
|
redirect: "manual",
|
|
132
|
-
|
|
135
|
+
...body === void 0 ? {} : { method: "POST", body },
|
|
136
|
+
headers: { "X-API-Key": key, "User-Agent": `parseapi-node/${VERSION}`, ...body === void 0 ? {} : { "Content-Type": "application/json" }, ...headers, "Parse-Version": API_VERSION },
|
|
133
137
|
signal: controller.signal
|
|
134
138
|
});
|
|
135
139
|
} catch (error) {
|
|
@@ -153,20 +157,20 @@ function parseAPI(apiKey, options = {}) {
|
|
|
153
157
|
await res.body?.cancel().catch(() => {
|
|
154
158
|
});
|
|
155
159
|
} else if (res) {
|
|
156
|
-
let
|
|
160
|
+
let body2 = {};
|
|
157
161
|
try {
|
|
158
162
|
const parsed = await res.json();
|
|
159
|
-
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed))
|
|
163
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) body2 = parsed;
|
|
160
164
|
} catch {
|
|
161
165
|
controller.signal.throwIfAborted();
|
|
162
166
|
}
|
|
163
167
|
signal?.throwIfAborted();
|
|
164
168
|
throw new ParseAPIError(
|
|
165
169
|
res.status,
|
|
166
|
-
typeof
|
|
167
|
-
typeof
|
|
168
|
-
typeof
|
|
169
|
-
typeof
|
|
170
|
+
typeof body2.code === "string" ? body2.code : "unknown_error",
|
|
171
|
+
typeof body2.message === "string" ? body2.message : `Request failed with status ${res.status}`,
|
|
172
|
+
typeof body2.docs === "string" ? body2.docs : null,
|
|
173
|
+
typeof body2.request_id === "string" ? body2.request_id : null
|
|
170
174
|
);
|
|
171
175
|
}
|
|
172
176
|
} finally {
|
|
@@ -179,6 +183,8 @@ function parseAPI(apiKey, options = {}) {
|
|
|
179
183
|
const enc = encodeURIComponent;
|
|
180
184
|
const deepQuery = (opts) => opts?.deep ? { deep: true } : {};
|
|
181
185
|
return {
|
|
186
|
+
/** Estimate task access, capacity and additional charges. Requires a secret key. Reserves no units or money and does not enforce the supplied budget. */
|
|
187
|
+
preflight: (task, opts) => request("/preflight", void 0, void 0, opts, task),
|
|
182
188
|
/** Look up an IP. `deep: true` adds enrichment included with a paid plan, without a separate check meter. */
|
|
183
189
|
ip: Object.assign(
|
|
184
190
|
(ip, opts) => request(`/ip/${enc(ip)}`, deepQuery(opts), void 0, opts),
|
|
@@ -314,7 +320,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
314
320
|
}
|
|
315
321
|
),
|
|
316
322
|
language: (code, opts) => request(`/language/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
317
|
-
name: (name, opts) => request(`/name/${enc(name)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
323
|
+
name: (name, opts) => request(`/name/${enc(name)}`, { country: opts?.country, ...deepQuery(opts), name_locale: opts?.name_locale }, void 0, opts),
|
|
318
324
|
/** Current local time, UTC by default. With to, offsetless at is source wall time. */
|
|
319
325
|
time: Object.assign(
|
|
320
326
|
(timezone, opts) => request(timezone === void 0 ? "/time" : `/time/${enc(timezone)}`, { at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
|
package/dist/index.d.cts
CHANGED
|
@@ -250,14 +250,16 @@ interface PostalDistance {
|
|
|
250
250
|
distance_mi: number;
|
|
251
251
|
}
|
|
252
252
|
interface EmailDeep {
|
|
253
|
-
deliverable: boolean;
|
|
254
|
-
catchall: boolean;
|
|
253
|
+
deliverable: boolean | null;
|
|
254
|
+
catchall: boolean | null;
|
|
255
255
|
}
|
|
256
256
|
interface Email {
|
|
257
257
|
email: string;
|
|
258
258
|
didyoumean: string | null;
|
|
259
259
|
valid: boolean;
|
|
260
|
+
free: boolean;
|
|
260
261
|
domain: string | null;
|
|
262
|
+
domain_type: 'academic' | 'government' | 'military' | null;
|
|
261
263
|
domain_valid: boolean | null;
|
|
262
264
|
role: boolean;
|
|
263
265
|
disposable: boolean;
|
|
@@ -519,7 +521,10 @@ interface Bin {
|
|
|
519
521
|
prefix: string | null;
|
|
520
522
|
country: string | null;
|
|
521
523
|
issuer: string | null;
|
|
524
|
+
/** Network key (visa, amex) or co-branded combination. */
|
|
522
525
|
brand: string | null;
|
|
526
|
+
/** Display name for brand (American Express). */
|
|
527
|
+
brand_name: string | null;
|
|
523
528
|
type: string | null;
|
|
524
529
|
prepaid: boolean | null;
|
|
525
530
|
deep?: Record<string, never>;
|
|
@@ -988,6 +993,16 @@ interface CountryDeep {
|
|
|
988
993
|
/** Reporting year or period for population (YYYY or YYYY-YYYY). Null when unknown or unverifiable. */
|
|
989
994
|
population_period?: string | null;
|
|
990
995
|
area: number | null;
|
|
996
|
+
/** Land area in km2. */
|
|
997
|
+
land_area?: number | null;
|
|
998
|
+
/** Water area in km2. */
|
|
999
|
+
water_area?: number | null;
|
|
1000
|
+
/** Coastline length in km. Zero is a known landlocked coastline. */
|
|
1001
|
+
coastline?: number | null;
|
|
1002
|
+
/** Mean elevation in metres above sea level. */
|
|
1003
|
+
elevation?: number | null;
|
|
1004
|
+
lowest_point?: CountryElevationPoint | null;
|
|
1005
|
+
highest_point?: CountryElevationPoint | null;
|
|
991
1006
|
tld: string | null;
|
|
992
1007
|
/** Levy name, such as VAT, GST or sales tax. Null when unknown or not applicable. */
|
|
993
1008
|
tax?: string | null;
|
|
@@ -1013,6 +1028,11 @@ interface CountryDeep {
|
|
|
1013
1028
|
fifa: string | null;
|
|
1014
1029
|
plate: string | null;
|
|
1015
1030
|
}
|
|
1031
|
+
interface CountryElevationPoint {
|
|
1032
|
+
name: string | null;
|
|
1033
|
+
/** Elevation in metres above sea level. Values below sea level are negative. */
|
|
1034
|
+
elevation: number;
|
|
1035
|
+
}
|
|
1016
1036
|
interface StateDeep {
|
|
1017
1037
|
population: number | null;
|
|
1018
1038
|
/** Reporting year or period for population (YYYY or YYYY-YYYY). Null when unknown or unverifiable. */
|
|
@@ -1129,12 +1149,14 @@ interface LanguageDeep {
|
|
|
1129
1149
|
countries: string[];
|
|
1130
1150
|
}
|
|
1131
1151
|
interface NameDeep {
|
|
1132
|
-
/** Name membership is independent of gender. */
|
|
1133
|
-
known: boolean;
|
|
1134
|
-
/** Associated countries, not the person's nationality. */
|
|
1135
|
-
countries: string[];
|
|
1136
1152
|
gender: 'male' | 'female' | null;
|
|
1137
1153
|
salutation: 'Mr' | 'Ms' | null;
|
|
1154
|
+
/** Compact name using CLDR formatting rules. */
|
|
1155
|
+
short?: string | null;
|
|
1156
|
+
/** Name formatted for a directory listing. */
|
|
1157
|
+
directory?: string | null;
|
|
1158
|
+
/** Name initials using CLDR formatting rules. */
|
|
1159
|
+
initials?: string | null;
|
|
1138
1160
|
}
|
|
1139
1161
|
interface TimezoneDeep {
|
|
1140
1162
|
name: string | null;
|
|
@@ -1221,6 +1243,102 @@ interface PropertyTax {
|
|
|
1221
1243
|
period: string;
|
|
1222
1244
|
}
|
|
1223
1245
|
|
|
1246
|
+
/** A proposed task contains operation counts, never lookup inputs. */
|
|
1247
|
+
interface PreflightOperation {
|
|
1248
|
+
operation: 'email' | 'domain' | 'dns' | 'mx' | 'country';
|
|
1249
|
+
/** Positive integer, at most 100000. */
|
|
1250
|
+
count: number;
|
|
1251
|
+
deep?: boolean;
|
|
1252
|
+
}
|
|
1253
|
+
interface PreflightTask {
|
|
1254
|
+
/** One to twenty rows, totaling at most 100000 lookups. */
|
|
1255
|
+
operations: PreflightOperation[];
|
|
1256
|
+
/** Nonnegative USD decimal string with at most two fractional digits. Advisory, never an enforced cap. */
|
|
1257
|
+
budget_usd?: string;
|
|
1258
|
+
}
|
|
1259
|
+
interface PreflightOperationEstimate {
|
|
1260
|
+
operation: string;
|
|
1261
|
+
count: number;
|
|
1262
|
+
deep: boolean;
|
|
1263
|
+
permitted: boolean;
|
|
1264
|
+
reason: string | null;
|
|
1265
|
+
/** Attempts per lookup under the default SDK retry policy. */
|
|
1266
|
+
max_http_attempts: number;
|
|
1267
|
+
pooled_requests_max: number;
|
|
1268
|
+
metered_units_max: number;
|
|
1269
|
+
}
|
|
1270
|
+
interface PreflightCost {
|
|
1271
|
+
currency: string;
|
|
1272
|
+
status: string;
|
|
1273
|
+
minimum_usd: string;
|
|
1274
|
+
/** Additional charges assuming included units are exhausted. Null when the effective rate is unknown. */
|
|
1275
|
+
maximum_usd: string | null;
|
|
1276
|
+
/** Additional charges using currently unallocated included units. */
|
|
1277
|
+
projected_maximum_usd: string | null;
|
|
1278
|
+
on_demand_unit_price_usd: string | null;
|
|
1279
|
+
}
|
|
1280
|
+
interface PreflightPooledCapacity {
|
|
1281
|
+
advisory: true;
|
|
1282
|
+
required_max: number;
|
|
1283
|
+
policy: string | null;
|
|
1284
|
+
limit: number | null;
|
|
1285
|
+
used_at_snapshot: number | null;
|
|
1286
|
+
remaining_at_snapshot: number | null;
|
|
1287
|
+
/** Unix seconds, or null when no active grace deadline is known. */
|
|
1288
|
+
grace_until: number | null;
|
|
1289
|
+
/** Unix seconds. */
|
|
1290
|
+
reset_at: number;
|
|
1291
|
+
allowed_at_snapshot: boolean | null;
|
|
1292
|
+
status: string;
|
|
1293
|
+
}
|
|
1294
|
+
interface PreflightEmailCapacity {
|
|
1295
|
+
advisory: true;
|
|
1296
|
+
required_max: number;
|
|
1297
|
+
included_limit: number;
|
|
1298
|
+
reserved_at_snapshot: number | null;
|
|
1299
|
+
unallocated_included_at_snapshot: number | null;
|
|
1300
|
+
projected_overage_units_max: number | null;
|
|
1301
|
+
on_demand_enabled: boolean | null;
|
|
1302
|
+
fits_unallocated_capacity: boolean | null;
|
|
1303
|
+
/** Unix seconds. */
|
|
1304
|
+
reset_at: number;
|
|
1305
|
+
}
|
|
1306
|
+
interface PreflightSpendCapacity {
|
|
1307
|
+
advisory: true;
|
|
1308
|
+
currency: string;
|
|
1309
|
+
cap_usd: string | null;
|
|
1310
|
+
cap_status: string;
|
|
1311
|
+
reserved_usd_at_snapshot: string | null;
|
|
1312
|
+
unallocated_usd_at_snapshot: string | null;
|
|
1313
|
+
/** Unix seconds. */
|
|
1314
|
+
reset_at: number;
|
|
1315
|
+
}
|
|
1316
|
+
/** A credential-specific estimate. Counters are advisory and can change during execution. */
|
|
1317
|
+
interface Preflight {
|
|
1318
|
+
schema_version: string;
|
|
1319
|
+
api_version: string;
|
|
1320
|
+
/** ISO 8601 evaluation time. */
|
|
1321
|
+
evaluated_at: string;
|
|
1322
|
+
estimate_only: true;
|
|
1323
|
+
supported: boolean;
|
|
1324
|
+
/** Permission for the requested features, separate from available capacity. */
|
|
1325
|
+
permitted: boolean;
|
|
1326
|
+
operations: PreflightOperationEstimate[];
|
|
1327
|
+
cost: PreflightCost;
|
|
1328
|
+
capacity: {
|
|
1329
|
+
pooled_requests: PreflightPooledCapacity;
|
|
1330
|
+
email_verifications: PreflightEmailCapacity;
|
|
1331
|
+
shared_on_demand_spend: PreflightSpendCapacity;
|
|
1332
|
+
};
|
|
1333
|
+
budget?: {
|
|
1334
|
+
amount_usd: string;
|
|
1335
|
+
within_maximum: boolean | null;
|
|
1336
|
+
enforced: false;
|
|
1337
|
+
};
|
|
1338
|
+
assumptions: string[];
|
|
1339
|
+
warnings: string[];
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1224
1342
|
/** Every non-2xx response from the API. Branch on `code`, never on `message`. */
|
|
1225
1343
|
declare class ParseAPIError extends Error {
|
|
1226
1344
|
/** HTTP status */
|
|
@@ -1233,6 +1351,10 @@ declare class ParseAPIError extends Error {
|
|
|
1233
1351
|
readonly requestId: string | null;
|
|
1234
1352
|
constructor(status: number, code: string, message: string, docs: string | null, requestId: string | null);
|
|
1235
1353
|
}
|
|
1354
|
+
/** Optional output language for supported display fields. Input parsing stays unchanged. */
|
|
1355
|
+
interface LanguageOption {
|
|
1356
|
+
lang?: string;
|
|
1357
|
+
}
|
|
1236
1358
|
interface RequestOptions {
|
|
1237
1359
|
/** Cancel this call, including any retry wait. */
|
|
1238
1360
|
signal?: AbortSignal;
|
|
@@ -1252,36 +1374,36 @@ interface ParseAPIOptions {
|
|
|
1252
1374
|
fetch?: typeof fetch;
|
|
1253
1375
|
}
|
|
1254
1376
|
/** IP enrichment is included with a paid plan. `deep` does not use a separate check meter. */
|
|
1255
|
-
type IpOptions = DeepOption & RequestOptions;
|
|
1256
|
-
type IpSelfOptions = DeepOption & RequestOptions;
|
|
1257
|
-
type ContinentOptions = RequestOptions;
|
|
1258
|
-
type ContinentCountriesOptions = RequestOptions;
|
|
1377
|
+
type IpOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1378
|
+
type IpSelfOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1379
|
+
type ContinentOptions = LanguageOption & RequestOptions;
|
|
1380
|
+
type ContinentCountriesOptions = LanguageOption & RequestOptions;
|
|
1259
1381
|
type BlocOptions = RequestOptions;
|
|
1260
|
-
type BlocCountriesOptions = RequestOptions;
|
|
1261
|
-
type CountryOptions = DeepOption & RequestOptions;
|
|
1262
|
-
type CountryStatesOptions = RequestOptions;
|
|
1263
|
-
type StateOptions = {
|
|
1382
|
+
type BlocCountriesOptions = LanguageOption & RequestOptions;
|
|
1383
|
+
type CountryOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1384
|
+
type CountryStatesOptions = LanguageOption & RequestOptions;
|
|
1385
|
+
type StateOptions = LanguageOption & {
|
|
1264
1386
|
country?: string;
|
|
1265
1387
|
} & DeepOption & RequestOptions;
|
|
1266
|
-
type StateDistrictsOptions = {
|
|
1388
|
+
type StateDistrictsOptions = LanguageOption & {
|
|
1267
1389
|
country?: string;
|
|
1268
1390
|
} & DeepOption & RequestOptions;
|
|
1269
|
-
type DistrictOptions = {
|
|
1391
|
+
type DistrictOptions = LanguageOption & {
|
|
1270
1392
|
country?: string;
|
|
1271
1393
|
state?: string;
|
|
1272
1394
|
} & DeepOption & RequestOptions;
|
|
1273
|
-
type CityOptions = {
|
|
1395
|
+
type CityOptions = LanguageOption & {
|
|
1274
1396
|
country?: string;
|
|
1275
1397
|
state?: string;
|
|
1276
1398
|
} & DeepOption & RequestOptions;
|
|
1277
|
-
type CityIdOptions = DeepOption & RequestOptions;
|
|
1278
|
-
type CitySearchOptions = {
|
|
1399
|
+
type CityIdOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1400
|
+
type CitySearchOptions = LanguageOption & {
|
|
1279
1401
|
country?: string;
|
|
1280
1402
|
state?: string;
|
|
1281
1403
|
limit?: number;
|
|
1282
1404
|
} & DeepOption & RequestOptions;
|
|
1283
|
-
type CityNearestOptions = DeepOption & RequestOptions;
|
|
1284
|
-
type CityNearbyOptions = {
|
|
1405
|
+
type CityNearestOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1406
|
+
type CityNearbyOptions = LanguageOption & {
|
|
1285
1407
|
radius?: number;
|
|
1286
1408
|
unit?: 'km' | 'mi';
|
|
1287
1409
|
country?: string;
|
|
@@ -1289,15 +1411,15 @@ type CityNearbyOptions = {
|
|
|
1289
1411
|
limit?: number;
|
|
1290
1412
|
} & DeepOption & RequestOptions;
|
|
1291
1413
|
/** Pass country when known. Codes shared by multiple countries need it. */
|
|
1292
|
-
type PostalOptions = {
|
|
1414
|
+
type PostalOptions = LanguageOption & {
|
|
1293
1415
|
country?: string;
|
|
1294
1416
|
} & DeepOption & RequestOptions;
|
|
1295
|
-
type PostalNearbyOptions = {
|
|
1417
|
+
type PostalNearbyOptions = LanguageOption & {
|
|
1296
1418
|
country?: string;
|
|
1297
1419
|
radius?: number;
|
|
1298
1420
|
unit?: 'km' | 'mi';
|
|
1299
1421
|
} & DeepOption & RequestOptions;
|
|
1300
|
-
type PostalDistanceOptions = {
|
|
1422
|
+
type PostalDistanceOptions = LanguageOption & {
|
|
1301
1423
|
country?: string;
|
|
1302
1424
|
} & DeepOption & RequestOptions;
|
|
1303
1425
|
type AddressOptions = {
|
|
@@ -1316,7 +1438,7 @@ type AddressSearchOptions = {
|
|
|
1316
1438
|
/** Actual end-user IP as an optional locality hint for server-side calls. */
|
|
1317
1439
|
ip?: string;
|
|
1318
1440
|
} & RequestOptions;
|
|
1319
|
-
type CompanyOptions = {
|
|
1441
|
+
type CompanyOptions = LanguageOption & {
|
|
1320
1442
|
country?: string;
|
|
1321
1443
|
} & DeepOption & RequestOptions;
|
|
1322
1444
|
/** `deep: true` requests a metered deliverability check. No automatic retries by default. */
|
|
@@ -1329,7 +1451,7 @@ type VatOptions = {
|
|
|
1329
1451
|
type IbanOptions = {
|
|
1330
1452
|
country?: string;
|
|
1331
1453
|
} & DeepOption & RequestOptions;
|
|
1332
|
-
type NpiOptions = DeepOption & RequestOptions;
|
|
1454
|
+
type NpiOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1333
1455
|
/** Country resolves national-number ambiguity. Deep adds numbering-plan geography on every plan. */
|
|
1334
1456
|
type PhoneOptions = {
|
|
1335
1457
|
country?: string;
|
|
@@ -1346,7 +1468,7 @@ type HlrOptions = {
|
|
|
1346
1468
|
country?: string;
|
|
1347
1469
|
} & DeepOption & RequestOptions;
|
|
1348
1470
|
type DomainOptions = DeepOption & RequestOptions;
|
|
1349
|
-
type AsnOptions = RequestOptions;
|
|
1471
|
+
type AsnOptions = LanguageOption & RequestOptions;
|
|
1350
1472
|
type MacOptions = RequestOptions;
|
|
1351
1473
|
/** Card-prefix reference lookup. Deep returns an empty object on every plan. */
|
|
1352
1474
|
type BinOptions = DeepOption & RequestOptions;
|
|
@@ -1356,7 +1478,7 @@ type MeasureOptions = {
|
|
|
1356
1478
|
locale?: string;
|
|
1357
1479
|
system?: 'us' | 'imperial';
|
|
1358
1480
|
} & RequestOptions;
|
|
1359
|
-
type MeasureUnitsOptions = {
|
|
1481
|
+
type MeasureUnitsOptions = LanguageOption & {
|
|
1360
1482
|
query?: string;
|
|
1361
1483
|
type?: string;
|
|
1362
1484
|
unit?: string;
|
|
@@ -1380,36 +1502,38 @@ type TariffOptions = {
|
|
|
1380
1502
|
origin?: string;
|
|
1381
1503
|
} & DeepOption & RequestOptions;
|
|
1382
1504
|
type TariffSearchOptions = RequestOptions;
|
|
1383
|
-
type CurrencyOptions = DeepOption & RequestOptions;
|
|
1505
|
+
type CurrencyOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1384
1506
|
type CurrencyRateOptions = {
|
|
1385
1507
|
date?: string;
|
|
1386
1508
|
amount?: number;
|
|
1387
1509
|
} & RequestOptions;
|
|
1388
|
-
type LanguageOptions = DeepOption & RequestOptions;
|
|
1389
|
-
/** Country
|
|
1510
|
+
type LanguageOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1511
|
+
/** Country scopes paid deep gender evidence. Name locale selects formatting rules without changing parsing. */
|
|
1390
1512
|
type NameOptions = {
|
|
1391
1513
|
country?: string;
|
|
1514
|
+
/** CLDR name-formatting locale, such as en or ja. Defaults to en. */
|
|
1515
|
+
name_locale?: string;
|
|
1392
1516
|
} & DeepOption & RequestOptions;
|
|
1393
|
-
type TimeOptions = {
|
|
1517
|
+
type TimeOptions = LanguageOption & {
|
|
1394
1518
|
at?: string;
|
|
1395
1519
|
to?: string;
|
|
1396
1520
|
} & DeepOption & RequestOptions;
|
|
1397
|
-
type TimeAtOptions = {
|
|
1521
|
+
type TimeAtOptions = LanguageOption & {
|
|
1398
1522
|
at?: string;
|
|
1399
1523
|
to?: string;
|
|
1400
1524
|
} & DeepOption & RequestOptions;
|
|
1401
|
-
type TimezoneOptions = {
|
|
1525
|
+
type TimezoneOptions = LanguageOption & {
|
|
1402
1526
|
at?: string;
|
|
1403
1527
|
to?: string;
|
|
1404
1528
|
} & DeepOption & RequestOptions;
|
|
1405
|
-
type TimezoneAtOptions = {
|
|
1529
|
+
type TimezoneAtOptions = LanguageOption & {
|
|
1406
1530
|
at?: string;
|
|
1407
1531
|
} & DeepOption & RequestOptions;
|
|
1408
|
-
type DateOptions = {
|
|
1532
|
+
type DateOptions = LanguageOption & {
|
|
1409
1533
|
format?: 'mdy' | 'dmy';
|
|
1410
1534
|
to?: string;
|
|
1411
1535
|
} & DeepOption & RequestOptions;
|
|
1412
|
-
type DateTodayOptions = {
|
|
1536
|
+
type DateTodayOptions = LanguageOption & {
|
|
1413
1537
|
to?: string;
|
|
1414
1538
|
} & DeepOption & RequestOptions;
|
|
1415
1539
|
type HolidayOptions = {
|
|
@@ -1418,14 +1542,14 @@ type HolidayOptions = {
|
|
|
1418
1542
|
type HolidayDateOptions = RequestOptions;
|
|
1419
1543
|
type ElevationOptions = RequestOptions;
|
|
1420
1544
|
/** Resolve the country, state, district and timezone at coordinates. Deep adds terrain and compact nearest-city context on every plan. The timezone ID stays in core. The nearest city is null when none is within 200 km. */
|
|
1421
|
-
type PointOptions = DeepOption & RequestOptions;
|
|
1545
|
+
type PointOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1422
1546
|
/** Get current conditions in metric and imperial units. Paid deep adds specialist current measurements, forecasts and related detail. With deep, date selects a past UTC day (YYYY-MM-DD) in deep.history alongside current conditions. Date alone does not request history. */
|
|
1423
1547
|
type WeatherOptions = DeepOption & {
|
|
1424
1548
|
/** Past UTC day, YYYY-MM-DD. Requires paid deep and populates deep.history alongside current. */
|
|
1425
1549
|
date?: string;
|
|
1426
1550
|
} & RequestOptions;
|
|
1427
|
-
type EmojiOptions = DeepOption & RequestOptions;
|
|
1428
|
-
type EmojiSearchOptions = {
|
|
1551
|
+
type EmojiOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1552
|
+
type EmojiSearchOptions = LanguageOption & {
|
|
1429
1553
|
limit?: number;
|
|
1430
1554
|
} & DeepOption & RequestOptions;
|
|
1431
1555
|
interface DeepOption {
|
|
@@ -1433,6 +1557,8 @@ interface DeepOption {
|
|
|
1433
1557
|
deep?: boolean;
|
|
1434
1558
|
}
|
|
1435
1559
|
declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
|
|
1560
|
+
/** Estimate task access, capacity and additional charges. Requires a secret key. Reserves no units or money and does not enforce the supplied budget. */
|
|
1561
|
+
preflight: (task: PreflightTask, opts?: RequestOptions) => Promise<Preflight>;
|
|
1436
1562
|
/** Look up an IP. `deep: true` adds enrichment included with a paid plan, without a separate check meter. */
|
|
1437
1563
|
ip: ((ip: string, opts?: IpOptions) => Promise<Ip>) & {
|
|
1438
1564
|
/** Look up the public IP making this request. On a server, this is the server's IP. */
|
|
@@ -1538,4 +1664,4 @@ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
|
|
|
1538
1664
|
};
|
|
1539
1665
|
type ParseAPIClient = ReturnType<typeof parseAPI>;
|
|
1540
1666
|
|
|
1541
|
-
export { type Address, type AddressOptions, type AddressSearch, type AddressSearchOptions, type AddressSuggestion, type Asn, type AsnOptions, type Bin, type BinOptions, type Bloc, type BlocCountries, type BlocCountriesOptions, type BlocCountryItem, type BlocOptions, type Caller, type CallerOptions, type Carrier, type CarrierDeep, type CarrierOptions, type City, type CityDeep, type CityIdOptions, type CityNearby, type CityNearbyOptions, type CityNearest, type CityNearestOptions, type CityOptions, type CitySearch, type CitySearchOptions, type Company, type CompanyCountry, type CompanyDeep, type CompanyOptions, type Continent, type ContinentCountries, type ContinentCountriesOptions, type ContinentCountryItem, type ContinentOptions, type Country, type CountryDeep, type CountryEmergency, type CountryOptions, type CountryStateItem, type CountryStates, type CountryStatesOptions, type Currency, type CurrencyDeep, type CurrencyOptions, type CurrencyRate, type CurrencyRateOptions, type DateInfo, type DateInfoDeep, type DateOptions, type DateTodayOptions, type Deep, type District, type DistrictDeep, type DistrictOptions, type Dns, type DnsOptions, type DnsRecord, type Domain, type DomainDeep, type DomainOptions, type DomainRegistration, type Elevation, type ElevationOptions, type Email, type EmailDeep, type EmailOptions, type Emoji, type EmojiDeep, type EmojiOptions, type EmojiSearch, type EmojiSearchOptions, type EmojiSkin, type Hlr, type HlrDeep, type HlrOptions, type Holiday, type HolidayDate, type HolidayDateOptions, type HolidayOptions, type HolidayYear, type Iban, type IbanDeep, type IbanOptions, type Ip, type IpDeep, type IpOptions, type IpSelfOptions, type Language, type LanguageDeep, type LanguageOptions, type Mac, type MacOptions, type Measure, type MeasureChoice, type MeasureOptions, type MeasureUnit, type MeasureUnits, type MeasureUnitsOptions, type Mx, type MxOptions, type MxRecord, type Naics, type NaicsChild, type NaicsCorrection, type NaicsDeep, type NaicsExclusion, type NaicsMatch, type NaicsOptions, type NaicsSearch, type NaicsSearchItem, type NaicsSearchOptions, type Name, type NameDeep, type NameOptions, type Npi, type NpiDeep, type NpiEnrollment, type NpiOptions, type ParseAPIClient, ParseAPIError, type ParseAPIOptions, type Phone, type PhoneDeep, type PhoneOptions, type Point, type PointCity, type PointDeep, type PointOptions, type Postal, type PostalDeep, type PostalDistance, type PostalDistanceEnd, type PostalDistanceOptions, type PostalMetro, type PostalMetrosDeep, type PostalNearby, type PostalNearbyItem, type PostalNearbyOptions, type PostalOptions, type PropertyTax, type RequestOptions, type State, type StateDeep, type StateDistrictDeep, type StateDistrictItem, type StateDistricts, type StateDistrictsOptions, type StateOptions, type Tariff, type TariffDeep, type TariffMeasure, type TariffOptions, type TariffSearch, type TariffSearchHit, type TariffSearchOptions, type Time, type TimeAtOptions, type TimeOptions, type Timezone, type TimezoneAtOptions, type TimezoneConversionTarget, type TimezoneConversionTargetDeep, type TimezoneDeep, type TimezoneNextDst, type TimezoneOptions, type Useragent, type UseragentBrowserBrand, type UseragentBrowserDeep, type UseragentDeep, type UseragentDeviceDeep, type UseragentEngineDeep, type UseragentOptions, type UseragentOsDeep, type Vat, type VatAddress, type VatDeep, type VatOptions, type Vin, type VinDeep, type VinOptions, type VinRecall, type Weather, type WeatherAir, type WeatherAlert, type WeatherCurrent, type WeatherCurrentDeep, type WeatherDay, type WeatherDeep, type WeatherForecastPeriod, type WeatherHistory, type WeatherHour, type WeatherMinute, type WeatherOptions, type WeatherStation, parseAPI };
|
|
1667
|
+
export { type Address, type AddressOptions, type AddressSearch, type AddressSearchOptions, type AddressSuggestion, type Asn, type AsnOptions, type Bin, type BinOptions, type Bloc, type BlocCountries, type BlocCountriesOptions, type BlocCountryItem, type BlocOptions, type Caller, type CallerOptions, type Carrier, type CarrierDeep, type CarrierOptions, type City, type CityDeep, type CityIdOptions, type CityNearby, type CityNearbyOptions, type CityNearest, type CityNearestOptions, type CityOptions, type CitySearch, type CitySearchOptions, type Company, type CompanyCountry, type CompanyDeep, type CompanyOptions, type Continent, type ContinentCountries, type ContinentCountriesOptions, type ContinentCountryItem, type ContinentOptions, type Country, type CountryDeep, type CountryElevationPoint, type CountryEmergency, type CountryOptions, type CountryStateItem, type CountryStates, type CountryStatesOptions, type Currency, type CurrencyDeep, type CurrencyOptions, type CurrencyRate, type CurrencyRateOptions, type DateInfo, type DateInfoDeep, type DateOptions, type DateTodayOptions, type Deep, type District, type DistrictDeep, type DistrictOptions, type Dns, type DnsOptions, type DnsRecord, type Domain, type DomainDeep, type DomainOptions, type DomainRegistration, type Elevation, type ElevationOptions, type Email, type EmailDeep, type EmailOptions, type Emoji, type EmojiDeep, type EmojiOptions, type EmojiSearch, type EmojiSearchOptions, type EmojiSkin, type Hlr, type HlrDeep, type HlrOptions, type Holiday, type HolidayDate, type HolidayDateOptions, type HolidayOptions, type HolidayYear, type Iban, type IbanDeep, type IbanOptions, type Ip, type IpDeep, type IpOptions, type IpSelfOptions, type Language, type LanguageDeep, type LanguageOption, type LanguageOptions, type Mac, type MacOptions, type Measure, type MeasureChoice, type MeasureOptions, type MeasureUnit, type MeasureUnits, type MeasureUnitsOptions, type Mx, type MxOptions, type MxRecord, type Naics, type NaicsChild, type NaicsCorrection, type NaicsDeep, type NaicsExclusion, type NaicsMatch, type NaicsOptions, type NaicsSearch, type NaicsSearchItem, type NaicsSearchOptions, type Name, type NameDeep, type NameOptions, type Npi, type NpiDeep, type NpiEnrollment, type NpiOptions, type ParseAPIClient, ParseAPIError, type ParseAPIOptions, type Phone, type PhoneDeep, type PhoneOptions, type Point, type PointCity, type PointDeep, type PointOptions, type Postal, type PostalDeep, type PostalDistance, type PostalDistanceEnd, type PostalDistanceOptions, type PostalMetro, type PostalMetrosDeep, type PostalNearby, type PostalNearbyItem, type PostalNearbyOptions, type PostalOptions, type Preflight, type PreflightCost, type PreflightEmailCapacity, type PreflightOperation, type PreflightOperationEstimate, type PreflightPooledCapacity, type PreflightSpendCapacity, type PreflightTask, type PropertyTax, type RequestOptions, type State, type StateDeep, type StateDistrictDeep, type StateDistrictItem, type StateDistricts, type StateDistrictsOptions, type StateOptions, type Tariff, type TariffDeep, type TariffMeasure, type TariffOptions, type TariffSearch, type TariffSearchHit, type TariffSearchOptions, type Time, type TimeAtOptions, type TimeOptions, type Timezone, type TimezoneAtOptions, type TimezoneConversionTarget, type TimezoneConversionTargetDeep, type TimezoneDeep, type TimezoneNextDst, type TimezoneOptions, type Useragent, type UseragentBrowserBrand, type UseragentBrowserDeep, type UseragentDeep, type UseragentDeviceDeep, type UseragentEngineDeep, type UseragentOptions, type UseragentOsDeep, type Vat, type VatAddress, type VatDeep, type VatOptions, type Vin, type VinDeep, type VinOptions, type VinRecall, type Weather, type WeatherAir, type WeatherAlert, type WeatherCurrent, type WeatherCurrentDeep, type WeatherDay, type WeatherDeep, type WeatherForecastPeriod, type WeatherHistory, type WeatherHour, type WeatherMinute, type WeatherOptions, type WeatherStation, parseAPI };
|
package/dist/index.d.ts
CHANGED
|
@@ -250,14 +250,16 @@ interface PostalDistance {
|
|
|
250
250
|
distance_mi: number;
|
|
251
251
|
}
|
|
252
252
|
interface EmailDeep {
|
|
253
|
-
deliverable: boolean;
|
|
254
|
-
catchall: boolean;
|
|
253
|
+
deliverable: boolean | null;
|
|
254
|
+
catchall: boolean | null;
|
|
255
255
|
}
|
|
256
256
|
interface Email {
|
|
257
257
|
email: string;
|
|
258
258
|
didyoumean: string | null;
|
|
259
259
|
valid: boolean;
|
|
260
|
+
free: boolean;
|
|
260
261
|
domain: string | null;
|
|
262
|
+
domain_type: 'academic' | 'government' | 'military' | null;
|
|
261
263
|
domain_valid: boolean | null;
|
|
262
264
|
role: boolean;
|
|
263
265
|
disposable: boolean;
|
|
@@ -519,7 +521,10 @@ interface Bin {
|
|
|
519
521
|
prefix: string | null;
|
|
520
522
|
country: string | null;
|
|
521
523
|
issuer: string | null;
|
|
524
|
+
/** Network key (visa, amex) or co-branded combination. */
|
|
522
525
|
brand: string | null;
|
|
526
|
+
/** Display name for brand (American Express). */
|
|
527
|
+
brand_name: string | null;
|
|
523
528
|
type: string | null;
|
|
524
529
|
prepaid: boolean | null;
|
|
525
530
|
deep?: Record<string, never>;
|
|
@@ -988,6 +993,16 @@ interface CountryDeep {
|
|
|
988
993
|
/** Reporting year or period for population (YYYY or YYYY-YYYY). Null when unknown or unverifiable. */
|
|
989
994
|
population_period?: string | null;
|
|
990
995
|
area: number | null;
|
|
996
|
+
/** Land area in km2. */
|
|
997
|
+
land_area?: number | null;
|
|
998
|
+
/** Water area in km2. */
|
|
999
|
+
water_area?: number | null;
|
|
1000
|
+
/** Coastline length in km. Zero is a known landlocked coastline. */
|
|
1001
|
+
coastline?: number | null;
|
|
1002
|
+
/** Mean elevation in metres above sea level. */
|
|
1003
|
+
elevation?: number | null;
|
|
1004
|
+
lowest_point?: CountryElevationPoint | null;
|
|
1005
|
+
highest_point?: CountryElevationPoint | null;
|
|
991
1006
|
tld: string | null;
|
|
992
1007
|
/** Levy name, such as VAT, GST or sales tax. Null when unknown or not applicable. */
|
|
993
1008
|
tax?: string | null;
|
|
@@ -1013,6 +1028,11 @@ interface CountryDeep {
|
|
|
1013
1028
|
fifa: string | null;
|
|
1014
1029
|
plate: string | null;
|
|
1015
1030
|
}
|
|
1031
|
+
interface CountryElevationPoint {
|
|
1032
|
+
name: string | null;
|
|
1033
|
+
/** Elevation in metres above sea level. Values below sea level are negative. */
|
|
1034
|
+
elevation: number;
|
|
1035
|
+
}
|
|
1016
1036
|
interface StateDeep {
|
|
1017
1037
|
population: number | null;
|
|
1018
1038
|
/** Reporting year or period for population (YYYY or YYYY-YYYY). Null when unknown or unverifiable. */
|
|
@@ -1129,12 +1149,14 @@ interface LanguageDeep {
|
|
|
1129
1149
|
countries: string[];
|
|
1130
1150
|
}
|
|
1131
1151
|
interface NameDeep {
|
|
1132
|
-
/** Name membership is independent of gender. */
|
|
1133
|
-
known: boolean;
|
|
1134
|
-
/** Associated countries, not the person's nationality. */
|
|
1135
|
-
countries: string[];
|
|
1136
1152
|
gender: 'male' | 'female' | null;
|
|
1137
1153
|
salutation: 'Mr' | 'Ms' | null;
|
|
1154
|
+
/** Compact name using CLDR formatting rules. */
|
|
1155
|
+
short?: string | null;
|
|
1156
|
+
/** Name formatted for a directory listing. */
|
|
1157
|
+
directory?: string | null;
|
|
1158
|
+
/** Name initials using CLDR formatting rules. */
|
|
1159
|
+
initials?: string | null;
|
|
1138
1160
|
}
|
|
1139
1161
|
interface TimezoneDeep {
|
|
1140
1162
|
name: string | null;
|
|
@@ -1221,6 +1243,102 @@ interface PropertyTax {
|
|
|
1221
1243
|
period: string;
|
|
1222
1244
|
}
|
|
1223
1245
|
|
|
1246
|
+
/** A proposed task contains operation counts, never lookup inputs. */
|
|
1247
|
+
interface PreflightOperation {
|
|
1248
|
+
operation: 'email' | 'domain' | 'dns' | 'mx' | 'country';
|
|
1249
|
+
/** Positive integer, at most 100000. */
|
|
1250
|
+
count: number;
|
|
1251
|
+
deep?: boolean;
|
|
1252
|
+
}
|
|
1253
|
+
interface PreflightTask {
|
|
1254
|
+
/** One to twenty rows, totaling at most 100000 lookups. */
|
|
1255
|
+
operations: PreflightOperation[];
|
|
1256
|
+
/** Nonnegative USD decimal string with at most two fractional digits. Advisory, never an enforced cap. */
|
|
1257
|
+
budget_usd?: string;
|
|
1258
|
+
}
|
|
1259
|
+
interface PreflightOperationEstimate {
|
|
1260
|
+
operation: string;
|
|
1261
|
+
count: number;
|
|
1262
|
+
deep: boolean;
|
|
1263
|
+
permitted: boolean;
|
|
1264
|
+
reason: string | null;
|
|
1265
|
+
/** Attempts per lookup under the default SDK retry policy. */
|
|
1266
|
+
max_http_attempts: number;
|
|
1267
|
+
pooled_requests_max: number;
|
|
1268
|
+
metered_units_max: number;
|
|
1269
|
+
}
|
|
1270
|
+
interface PreflightCost {
|
|
1271
|
+
currency: string;
|
|
1272
|
+
status: string;
|
|
1273
|
+
minimum_usd: string;
|
|
1274
|
+
/** Additional charges assuming included units are exhausted. Null when the effective rate is unknown. */
|
|
1275
|
+
maximum_usd: string | null;
|
|
1276
|
+
/** Additional charges using currently unallocated included units. */
|
|
1277
|
+
projected_maximum_usd: string | null;
|
|
1278
|
+
on_demand_unit_price_usd: string | null;
|
|
1279
|
+
}
|
|
1280
|
+
interface PreflightPooledCapacity {
|
|
1281
|
+
advisory: true;
|
|
1282
|
+
required_max: number;
|
|
1283
|
+
policy: string | null;
|
|
1284
|
+
limit: number | null;
|
|
1285
|
+
used_at_snapshot: number | null;
|
|
1286
|
+
remaining_at_snapshot: number | null;
|
|
1287
|
+
/** Unix seconds, or null when no active grace deadline is known. */
|
|
1288
|
+
grace_until: number | null;
|
|
1289
|
+
/** Unix seconds. */
|
|
1290
|
+
reset_at: number;
|
|
1291
|
+
allowed_at_snapshot: boolean | null;
|
|
1292
|
+
status: string;
|
|
1293
|
+
}
|
|
1294
|
+
interface PreflightEmailCapacity {
|
|
1295
|
+
advisory: true;
|
|
1296
|
+
required_max: number;
|
|
1297
|
+
included_limit: number;
|
|
1298
|
+
reserved_at_snapshot: number | null;
|
|
1299
|
+
unallocated_included_at_snapshot: number | null;
|
|
1300
|
+
projected_overage_units_max: number | null;
|
|
1301
|
+
on_demand_enabled: boolean | null;
|
|
1302
|
+
fits_unallocated_capacity: boolean | null;
|
|
1303
|
+
/** Unix seconds. */
|
|
1304
|
+
reset_at: number;
|
|
1305
|
+
}
|
|
1306
|
+
interface PreflightSpendCapacity {
|
|
1307
|
+
advisory: true;
|
|
1308
|
+
currency: string;
|
|
1309
|
+
cap_usd: string | null;
|
|
1310
|
+
cap_status: string;
|
|
1311
|
+
reserved_usd_at_snapshot: string | null;
|
|
1312
|
+
unallocated_usd_at_snapshot: string | null;
|
|
1313
|
+
/** Unix seconds. */
|
|
1314
|
+
reset_at: number;
|
|
1315
|
+
}
|
|
1316
|
+
/** A credential-specific estimate. Counters are advisory and can change during execution. */
|
|
1317
|
+
interface Preflight {
|
|
1318
|
+
schema_version: string;
|
|
1319
|
+
api_version: string;
|
|
1320
|
+
/** ISO 8601 evaluation time. */
|
|
1321
|
+
evaluated_at: string;
|
|
1322
|
+
estimate_only: true;
|
|
1323
|
+
supported: boolean;
|
|
1324
|
+
/** Permission for the requested features, separate from available capacity. */
|
|
1325
|
+
permitted: boolean;
|
|
1326
|
+
operations: PreflightOperationEstimate[];
|
|
1327
|
+
cost: PreflightCost;
|
|
1328
|
+
capacity: {
|
|
1329
|
+
pooled_requests: PreflightPooledCapacity;
|
|
1330
|
+
email_verifications: PreflightEmailCapacity;
|
|
1331
|
+
shared_on_demand_spend: PreflightSpendCapacity;
|
|
1332
|
+
};
|
|
1333
|
+
budget?: {
|
|
1334
|
+
amount_usd: string;
|
|
1335
|
+
within_maximum: boolean | null;
|
|
1336
|
+
enforced: false;
|
|
1337
|
+
};
|
|
1338
|
+
assumptions: string[];
|
|
1339
|
+
warnings: string[];
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1224
1342
|
/** Every non-2xx response from the API. Branch on `code`, never on `message`. */
|
|
1225
1343
|
declare class ParseAPIError extends Error {
|
|
1226
1344
|
/** HTTP status */
|
|
@@ -1233,6 +1351,10 @@ declare class ParseAPIError extends Error {
|
|
|
1233
1351
|
readonly requestId: string | null;
|
|
1234
1352
|
constructor(status: number, code: string, message: string, docs: string | null, requestId: string | null);
|
|
1235
1353
|
}
|
|
1354
|
+
/** Optional output language for supported display fields. Input parsing stays unchanged. */
|
|
1355
|
+
interface LanguageOption {
|
|
1356
|
+
lang?: string;
|
|
1357
|
+
}
|
|
1236
1358
|
interface RequestOptions {
|
|
1237
1359
|
/** Cancel this call, including any retry wait. */
|
|
1238
1360
|
signal?: AbortSignal;
|
|
@@ -1252,36 +1374,36 @@ interface ParseAPIOptions {
|
|
|
1252
1374
|
fetch?: typeof fetch;
|
|
1253
1375
|
}
|
|
1254
1376
|
/** IP enrichment is included with a paid plan. `deep` does not use a separate check meter. */
|
|
1255
|
-
type IpOptions = DeepOption & RequestOptions;
|
|
1256
|
-
type IpSelfOptions = DeepOption & RequestOptions;
|
|
1257
|
-
type ContinentOptions = RequestOptions;
|
|
1258
|
-
type ContinentCountriesOptions = RequestOptions;
|
|
1377
|
+
type IpOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1378
|
+
type IpSelfOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1379
|
+
type ContinentOptions = LanguageOption & RequestOptions;
|
|
1380
|
+
type ContinentCountriesOptions = LanguageOption & RequestOptions;
|
|
1259
1381
|
type BlocOptions = RequestOptions;
|
|
1260
|
-
type BlocCountriesOptions = RequestOptions;
|
|
1261
|
-
type CountryOptions = DeepOption & RequestOptions;
|
|
1262
|
-
type CountryStatesOptions = RequestOptions;
|
|
1263
|
-
type StateOptions = {
|
|
1382
|
+
type BlocCountriesOptions = LanguageOption & RequestOptions;
|
|
1383
|
+
type CountryOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1384
|
+
type CountryStatesOptions = LanguageOption & RequestOptions;
|
|
1385
|
+
type StateOptions = LanguageOption & {
|
|
1264
1386
|
country?: string;
|
|
1265
1387
|
} & DeepOption & RequestOptions;
|
|
1266
|
-
type StateDistrictsOptions = {
|
|
1388
|
+
type StateDistrictsOptions = LanguageOption & {
|
|
1267
1389
|
country?: string;
|
|
1268
1390
|
} & DeepOption & RequestOptions;
|
|
1269
|
-
type DistrictOptions = {
|
|
1391
|
+
type DistrictOptions = LanguageOption & {
|
|
1270
1392
|
country?: string;
|
|
1271
1393
|
state?: string;
|
|
1272
1394
|
} & DeepOption & RequestOptions;
|
|
1273
|
-
type CityOptions = {
|
|
1395
|
+
type CityOptions = LanguageOption & {
|
|
1274
1396
|
country?: string;
|
|
1275
1397
|
state?: string;
|
|
1276
1398
|
} & DeepOption & RequestOptions;
|
|
1277
|
-
type CityIdOptions = DeepOption & RequestOptions;
|
|
1278
|
-
type CitySearchOptions = {
|
|
1399
|
+
type CityIdOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1400
|
+
type CitySearchOptions = LanguageOption & {
|
|
1279
1401
|
country?: string;
|
|
1280
1402
|
state?: string;
|
|
1281
1403
|
limit?: number;
|
|
1282
1404
|
} & DeepOption & RequestOptions;
|
|
1283
|
-
type CityNearestOptions = DeepOption & RequestOptions;
|
|
1284
|
-
type CityNearbyOptions = {
|
|
1405
|
+
type CityNearestOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1406
|
+
type CityNearbyOptions = LanguageOption & {
|
|
1285
1407
|
radius?: number;
|
|
1286
1408
|
unit?: 'km' | 'mi';
|
|
1287
1409
|
country?: string;
|
|
@@ -1289,15 +1411,15 @@ type CityNearbyOptions = {
|
|
|
1289
1411
|
limit?: number;
|
|
1290
1412
|
} & DeepOption & RequestOptions;
|
|
1291
1413
|
/** Pass country when known. Codes shared by multiple countries need it. */
|
|
1292
|
-
type PostalOptions = {
|
|
1414
|
+
type PostalOptions = LanguageOption & {
|
|
1293
1415
|
country?: string;
|
|
1294
1416
|
} & DeepOption & RequestOptions;
|
|
1295
|
-
type PostalNearbyOptions = {
|
|
1417
|
+
type PostalNearbyOptions = LanguageOption & {
|
|
1296
1418
|
country?: string;
|
|
1297
1419
|
radius?: number;
|
|
1298
1420
|
unit?: 'km' | 'mi';
|
|
1299
1421
|
} & DeepOption & RequestOptions;
|
|
1300
|
-
type PostalDistanceOptions = {
|
|
1422
|
+
type PostalDistanceOptions = LanguageOption & {
|
|
1301
1423
|
country?: string;
|
|
1302
1424
|
} & DeepOption & RequestOptions;
|
|
1303
1425
|
type AddressOptions = {
|
|
@@ -1316,7 +1438,7 @@ type AddressSearchOptions = {
|
|
|
1316
1438
|
/** Actual end-user IP as an optional locality hint for server-side calls. */
|
|
1317
1439
|
ip?: string;
|
|
1318
1440
|
} & RequestOptions;
|
|
1319
|
-
type CompanyOptions = {
|
|
1441
|
+
type CompanyOptions = LanguageOption & {
|
|
1320
1442
|
country?: string;
|
|
1321
1443
|
} & DeepOption & RequestOptions;
|
|
1322
1444
|
/** `deep: true` requests a metered deliverability check. No automatic retries by default. */
|
|
@@ -1329,7 +1451,7 @@ type VatOptions = {
|
|
|
1329
1451
|
type IbanOptions = {
|
|
1330
1452
|
country?: string;
|
|
1331
1453
|
} & DeepOption & RequestOptions;
|
|
1332
|
-
type NpiOptions = DeepOption & RequestOptions;
|
|
1454
|
+
type NpiOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1333
1455
|
/** Country resolves national-number ambiguity. Deep adds numbering-plan geography on every plan. */
|
|
1334
1456
|
type PhoneOptions = {
|
|
1335
1457
|
country?: string;
|
|
@@ -1346,7 +1468,7 @@ type HlrOptions = {
|
|
|
1346
1468
|
country?: string;
|
|
1347
1469
|
} & DeepOption & RequestOptions;
|
|
1348
1470
|
type DomainOptions = DeepOption & RequestOptions;
|
|
1349
|
-
type AsnOptions = RequestOptions;
|
|
1471
|
+
type AsnOptions = LanguageOption & RequestOptions;
|
|
1350
1472
|
type MacOptions = RequestOptions;
|
|
1351
1473
|
/** Card-prefix reference lookup. Deep returns an empty object on every plan. */
|
|
1352
1474
|
type BinOptions = DeepOption & RequestOptions;
|
|
@@ -1356,7 +1478,7 @@ type MeasureOptions = {
|
|
|
1356
1478
|
locale?: string;
|
|
1357
1479
|
system?: 'us' | 'imperial';
|
|
1358
1480
|
} & RequestOptions;
|
|
1359
|
-
type MeasureUnitsOptions = {
|
|
1481
|
+
type MeasureUnitsOptions = LanguageOption & {
|
|
1360
1482
|
query?: string;
|
|
1361
1483
|
type?: string;
|
|
1362
1484
|
unit?: string;
|
|
@@ -1380,36 +1502,38 @@ type TariffOptions = {
|
|
|
1380
1502
|
origin?: string;
|
|
1381
1503
|
} & DeepOption & RequestOptions;
|
|
1382
1504
|
type TariffSearchOptions = RequestOptions;
|
|
1383
|
-
type CurrencyOptions = DeepOption & RequestOptions;
|
|
1505
|
+
type CurrencyOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1384
1506
|
type CurrencyRateOptions = {
|
|
1385
1507
|
date?: string;
|
|
1386
1508
|
amount?: number;
|
|
1387
1509
|
} & RequestOptions;
|
|
1388
|
-
type LanguageOptions = DeepOption & RequestOptions;
|
|
1389
|
-
/** Country
|
|
1510
|
+
type LanguageOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1511
|
+
/** Country scopes paid deep gender evidence. Name locale selects formatting rules without changing parsing. */
|
|
1390
1512
|
type NameOptions = {
|
|
1391
1513
|
country?: string;
|
|
1514
|
+
/** CLDR name-formatting locale, such as en or ja. Defaults to en. */
|
|
1515
|
+
name_locale?: string;
|
|
1392
1516
|
} & DeepOption & RequestOptions;
|
|
1393
|
-
type TimeOptions = {
|
|
1517
|
+
type TimeOptions = LanguageOption & {
|
|
1394
1518
|
at?: string;
|
|
1395
1519
|
to?: string;
|
|
1396
1520
|
} & DeepOption & RequestOptions;
|
|
1397
|
-
type TimeAtOptions = {
|
|
1521
|
+
type TimeAtOptions = LanguageOption & {
|
|
1398
1522
|
at?: string;
|
|
1399
1523
|
to?: string;
|
|
1400
1524
|
} & DeepOption & RequestOptions;
|
|
1401
|
-
type TimezoneOptions = {
|
|
1525
|
+
type TimezoneOptions = LanguageOption & {
|
|
1402
1526
|
at?: string;
|
|
1403
1527
|
to?: string;
|
|
1404
1528
|
} & DeepOption & RequestOptions;
|
|
1405
|
-
type TimezoneAtOptions = {
|
|
1529
|
+
type TimezoneAtOptions = LanguageOption & {
|
|
1406
1530
|
at?: string;
|
|
1407
1531
|
} & DeepOption & RequestOptions;
|
|
1408
|
-
type DateOptions = {
|
|
1532
|
+
type DateOptions = LanguageOption & {
|
|
1409
1533
|
format?: 'mdy' | 'dmy';
|
|
1410
1534
|
to?: string;
|
|
1411
1535
|
} & DeepOption & RequestOptions;
|
|
1412
|
-
type DateTodayOptions = {
|
|
1536
|
+
type DateTodayOptions = LanguageOption & {
|
|
1413
1537
|
to?: string;
|
|
1414
1538
|
} & DeepOption & RequestOptions;
|
|
1415
1539
|
type HolidayOptions = {
|
|
@@ -1418,14 +1542,14 @@ type HolidayOptions = {
|
|
|
1418
1542
|
type HolidayDateOptions = RequestOptions;
|
|
1419
1543
|
type ElevationOptions = RequestOptions;
|
|
1420
1544
|
/** Resolve the country, state, district and timezone at coordinates. Deep adds terrain and compact nearest-city context on every plan. The timezone ID stays in core. The nearest city is null when none is within 200 km. */
|
|
1421
|
-
type PointOptions = DeepOption & RequestOptions;
|
|
1545
|
+
type PointOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1422
1546
|
/** Get current conditions in metric and imperial units. Paid deep adds specialist current measurements, forecasts and related detail. With deep, date selects a past UTC day (YYYY-MM-DD) in deep.history alongside current conditions. Date alone does not request history. */
|
|
1423
1547
|
type WeatherOptions = DeepOption & {
|
|
1424
1548
|
/** Past UTC day, YYYY-MM-DD. Requires paid deep and populates deep.history alongside current. */
|
|
1425
1549
|
date?: string;
|
|
1426
1550
|
} & RequestOptions;
|
|
1427
|
-
type EmojiOptions = DeepOption & RequestOptions;
|
|
1428
|
-
type EmojiSearchOptions = {
|
|
1551
|
+
type EmojiOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1552
|
+
type EmojiSearchOptions = LanguageOption & {
|
|
1429
1553
|
limit?: number;
|
|
1430
1554
|
} & DeepOption & RequestOptions;
|
|
1431
1555
|
interface DeepOption {
|
|
@@ -1433,6 +1557,8 @@ interface DeepOption {
|
|
|
1433
1557
|
deep?: boolean;
|
|
1434
1558
|
}
|
|
1435
1559
|
declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
|
|
1560
|
+
/** Estimate task access, capacity and additional charges. Requires a secret key. Reserves no units or money and does not enforce the supplied budget. */
|
|
1561
|
+
preflight: (task: PreflightTask, opts?: RequestOptions) => Promise<Preflight>;
|
|
1436
1562
|
/** Look up an IP. `deep: true` adds enrichment included with a paid plan, without a separate check meter. */
|
|
1437
1563
|
ip: ((ip: string, opts?: IpOptions) => Promise<Ip>) & {
|
|
1438
1564
|
/** Look up the public IP making this request. On a server, this is the server's IP. */
|
|
@@ -1538,4 +1664,4 @@ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
|
|
|
1538
1664
|
};
|
|
1539
1665
|
type ParseAPIClient = ReturnType<typeof parseAPI>;
|
|
1540
1666
|
|
|
1541
|
-
export { type Address, type AddressOptions, type AddressSearch, type AddressSearchOptions, type AddressSuggestion, type Asn, type AsnOptions, type Bin, type BinOptions, type Bloc, type BlocCountries, type BlocCountriesOptions, type BlocCountryItem, type BlocOptions, type Caller, type CallerOptions, type Carrier, type CarrierDeep, type CarrierOptions, type City, type CityDeep, type CityIdOptions, type CityNearby, type CityNearbyOptions, type CityNearest, type CityNearestOptions, type CityOptions, type CitySearch, type CitySearchOptions, type Company, type CompanyCountry, type CompanyDeep, type CompanyOptions, type Continent, type ContinentCountries, type ContinentCountriesOptions, type ContinentCountryItem, type ContinentOptions, type Country, type CountryDeep, type CountryEmergency, type CountryOptions, type CountryStateItem, type CountryStates, type CountryStatesOptions, type Currency, type CurrencyDeep, type CurrencyOptions, type CurrencyRate, type CurrencyRateOptions, type DateInfo, type DateInfoDeep, type DateOptions, type DateTodayOptions, type Deep, type District, type DistrictDeep, type DistrictOptions, type Dns, type DnsOptions, type DnsRecord, type Domain, type DomainDeep, type DomainOptions, type DomainRegistration, type Elevation, type ElevationOptions, type Email, type EmailDeep, type EmailOptions, type Emoji, type EmojiDeep, type EmojiOptions, type EmojiSearch, type EmojiSearchOptions, type EmojiSkin, type Hlr, type HlrDeep, type HlrOptions, type Holiday, type HolidayDate, type HolidayDateOptions, type HolidayOptions, type HolidayYear, type Iban, type IbanDeep, type IbanOptions, type Ip, type IpDeep, type IpOptions, type IpSelfOptions, type Language, type LanguageDeep, type LanguageOptions, type Mac, type MacOptions, type Measure, type MeasureChoice, type MeasureOptions, type MeasureUnit, type MeasureUnits, type MeasureUnitsOptions, type Mx, type MxOptions, type MxRecord, type Naics, type NaicsChild, type NaicsCorrection, type NaicsDeep, type NaicsExclusion, type NaicsMatch, type NaicsOptions, type NaicsSearch, type NaicsSearchItem, type NaicsSearchOptions, type Name, type NameDeep, type NameOptions, type Npi, type NpiDeep, type NpiEnrollment, type NpiOptions, type ParseAPIClient, ParseAPIError, type ParseAPIOptions, type Phone, type PhoneDeep, type PhoneOptions, type Point, type PointCity, type PointDeep, type PointOptions, type Postal, type PostalDeep, type PostalDistance, type PostalDistanceEnd, type PostalDistanceOptions, type PostalMetro, type PostalMetrosDeep, type PostalNearby, type PostalNearbyItem, type PostalNearbyOptions, type PostalOptions, type PropertyTax, type RequestOptions, type State, type StateDeep, type StateDistrictDeep, type StateDistrictItem, type StateDistricts, type StateDistrictsOptions, type StateOptions, type Tariff, type TariffDeep, type TariffMeasure, type TariffOptions, type TariffSearch, type TariffSearchHit, type TariffSearchOptions, type Time, type TimeAtOptions, type TimeOptions, type Timezone, type TimezoneAtOptions, type TimezoneConversionTarget, type TimezoneConversionTargetDeep, type TimezoneDeep, type TimezoneNextDst, type TimezoneOptions, type Useragent, type UseragentBrowserBrand, type UseragentBrowserDeep, type UseragentDeep, type UseragentDeviceDeep, type UseragentEngineDeep, type UseragentOptions, type UseragentOsDeep, type Vat, type VatAddress, type VatDeep, type VatOptions, type Vin, type VinDeep, type VinOptions, type VinRecall, type Weather, type WeatherAir, type WeatherAlert, type WeatherCurrent, type WeatherCurrentDeep, type WeatherDay, type WeatherDeep, type WeatherForecastPeriod, type WeatherHistory, type WeatherHour, type WeatherMinute, type WeatherOptions, type WeatherStation, parseAPI };
|
|
1667
|
+
export { type Address, type AddressOptions, type AddressSearch, type AddressSearchOptions, type AddressSuggestion, type Asn, type AsnOptions, type Bin, type BinOptions, type Bloc, type BlocCountries, type BlocCountriesOptions, type BlocCountryItem, type BlocOptions, type Caller, type CallerOptions, type Carrier, type CarrierDeep, type CarrierOptions, type City, type CityDeep, type CityIdOptions, type CityNearby, type CityNearbyOptions, type CityNearest, type CityNearestOptions, type CityOptions, type CitySearch, type CitySearchOptions, type Company, type CompanyCountry, type CompanyDeep, type CompanyOptions, type Continent, type ContinentCountries, type ContinentCountriesOptions, type ContinentCountryItem, type ContinentOptions, type Country, type CountryDeep, type CountryElevationPoint, type CountryEmergency, type CountryOptions, type CountryStateItem, type CountryStates, type CountryStatesOptions, type Currency, type CurrencyDeep, type CurrencyOptions, type CurrencyRate, type CurrencyRateOptions, type DateInfo, type DateInfoDeep, type DateOptions, type DateTodayOptions, type Deep, type District, type DistrictDeep, type DistrictOptions, type Dns, type DnsOptions, type DnsRecord, type Domain, type DomainDeep, type DomainOptions, type DomainRegistration, type Elevation, type ElevationOptions, type Email, type EmailDeep, type EmailOptions, type Emoji, type EmojiDeep, type EmojiOptions, type EmojiSearch, type EmojiSearchOptions, type EmojiSkin, type Hlr, type HlrDeep, type HlrOptions, type Holiday, type HolidayDate, type HolidayDateOptions, type HolidayOptions, type HolidayYear, type Iban, type IbanDeep, type IbanOptions, type Ip, type IpDeep, type IpOptions, type IpSelfOptions, type Language, type LanguageDeep, type LanguageOption, type LanguageOptions, type Mac, type MacOptions, type Measure, type MeasureChoice, type MeasureOptions, type MeasureUnit, type MeasureUnits, type MeasureUnitsOptions, type Mx, type MxOptions, type MxRecord, type Naics, type NaicsChild, type NaicsCorrection, type NaicsDeep, type NaicsExclusion, type NaicsMatch, type NaicsOptions, type NaicsSearch, type NaicsSearchItem, type NaicsSearchOptions, type Name, type NameDeep, type NameOptions, type Npi, type NpiDeep, type NpiEnrollment, type NpiOptions, type ParseAPIClient, ParseAPIError, type ParseAPIOptions, type Phone, type PhoneDeep, type PhoneOptions, type Point, type PointCity, type PointDeep, type PointOptions, type Postal, type PostalDeep, type PostalDistance, type PostalDistanceEnd, type PostalDistanceOptions, type PostalMetro, type PostalMetrosDeep, type PostalNearby, type PostalNearbyItem, type PostalNearbyOptions, type PostalOptions, type Preflight, type PreflightCost, type PreflightEmailCapacity, type PreflightOperation, type PreflightOperationEstimate, type PreflightPooledCapacity, type PreflightSpendCapacity, type PreflightTask, type PropertyTax, type RequestOptions, type State, type StateDeep, type StateDistrictDeep, type StateDistrictItem, type StateDistricts, type StateDistrictsOptions, type StateOptions, type Tariff, type TariffDeep, type TariffMeasure, type TariffOptions, type TariffSearch, type TariffSearchHit, type TariffSearchOptions, type Time, type TimeAtOptions, type TimeOptions, type Timezone, type TimezoneAtOptions, type TimezoneConversionTarget, type TimezoneConversionTargetDeep, type TimezoneDeep, type TimezoneNextDst, type TimezoneOptions, type Useragent, type UseragentBrowserBrand, type UseragentBrowserDeep, type UseragentDeep, type UseragentDeviceDeep, type UseragentEngineDeep, type UseragentOptions, type UseragentOsDeep, type Vat, type VatAddress, type VatDeep, type VatOptions, type Vin, type VinDeep, type VinOptions, type VinRecall, type Weather, type WeatherAir, type WeatherAlert, type WeatherCurrent, type WeatherCurrentDeep, type WeatherDay, type WeatherDeep, type WeatherForecastPeriod, type WeatherHistory, type WeatherHour, type WeatherMinute, type WeatherOptions, type WeatherStation, parseAPI };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var VERSION = "
|
|
2
|
+
var VERSION = "1.1.0";
|
|
3
|
+
var API_VERSION = "2.0.0";
|
|
3
4
|
var DEFAULT_BASE_URL = "https://api.parseapi.com";
|
|
4
5
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
5
6
|
var DEFAULT_RETRIES = 2;
|
|
@@ -81,14 +82,16 @@ function parseAPI(apiKey, options = {}) {
|
|
|
81
82
|
validateTimeout(timeoutMs);
|
|
82
83
|
validateRetries(configuredRetries);
|
|
83
84
|
const doFetch = options.fetch ?? fetch;
|
|
84
|
-
async function request(path, query, headers, controls = {}) {
|
|
85
|
+
async function request(path, query, headers, controls = {}, json) {
|
|
85
86
|
const signal = controls.signal;
|
|
86
87
|
signal?.throwIfAborted();
|
|
87
88
|
const attemptTimeout = controls.timeoutMs ?? timeoutMs;
|
|
88
89
|
const retries = controls.retries ?? configuredRetries ?? (metered(path, query) ? 0 : DEFAULT_RETRIES);
|
|
89
90
|
validateTimeout(attemptTimeout);
|
|
90
91
|
validateRetries(retries);
|
|
92
|
+
const body = json === void 0 ? void 0 : JSON.stringify(json);
|
|
91
93
|
const url = new URL(baseUrl + path);
|
|
94
|
+
if (controls.lang !== void 0) url.searchParams.set("lang", controls.lang);
|
|
92
95
|
for (const [name, value] of Object.entries(query ?? {})) {
|
|
93
96
|
if (value !== void 0) url.searchParams.set(name, String(value));
|
|
94
97
|
}
|
|
@@ -104,7 +107,8 @@ function parseAPI(apiKey, options = {}) {
|
|
|
104
107
|
try {
|
|
105
108
|
res = await doFetch(url, {
|
|
106
109
|
redirect: "manual",
|
|
107
|
-
|
|
110
|
+
...body === void 0 ? {} : { method: "POST", body },
|
|
111
|
+
headers: { "X-API-Key": key, "User-Agent": `parseapi-node/${VERSION}`, ...body === void 0 ? {} : { "Content-Type": "application/json" }, ...headers, "Parse-Version": API_VERSION },
|
|
108
112
|
signal: controller.signal
|
|
109
113
|
});
|
|
110
114
|
} catch (error) {
|
|
@@ -128,20 +132,20 @@ function parseAPI(apiKey, options = {}) {
|
|
|
128
132
|
await res.body?.cancel().catch(() => {
|
|
129
133
|
});
|
|
130
134
|
} else if (res) {
|
|
131
|
-
let
|
|
135
|
+
let body2 = {};
|
|
132
136
|
try {
|
|
133
137
|
const parsed = await res.json();
|
|
134
|
-
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed))
|
|
138
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) body2 = parsed;
|
|
135
139
|
} catch {
|
|
136
140
|
controller.signal.throwIfAborted();
|
|
137
141
|
}
|
|
138
142
|
signal?.throwIfAborted();
|
|
139
143
|
throw new ParseAPIError(
|
|
140
144
|
res.status,
|
|
141
|
-
typeof
|
|
142
|
-
typeof
|
|
143
|
-
typeof
|
|
144
|
-
typeof
|
|
145
|
+
typeof body2.code === "string" ? body2.code : "unknown_error",
|
|
146
|
+
typeof body2.message === "string" ? body2.message : `Request failed with status ${res.status}`,
|
|
147
|
+
typeof body2.docs === "string" ? body2.docs : null,
|
|
148
|
+
typeof body2.request_id === "string" ? body2.request_id : null
|
|
145
149
|
);
|
|
146
150
|
}
|
|
147
151
|
} finally {
|
|
@@ -154,6 +158,8 @@ function parseAPI(apiKey, options = {}) {
|
|
|
154
158
|
const enc = encodeURIComponent;
|
|
155
159
|
const deepQuery = (opts) => opts?.deep ? { deep: true } : {};
|
|
156
160
|
return {
|
|
161
|
+
/** Estimate task access, capacity and additional charges. Requires a secret key. Reserves no units or money and does not enforce the supplied budget. */
|
|
162
|
+
preflight: (task, opts) => request("/preflight", void 0, void 0, opts, task),
|
|
157
163
|
/** Look up an IP. `deep: true` adds enrichment included with a paid plan, without a separate check meter. */
|
|
158
164
|
ip: Object.assign(
|
|
159
165
|
(ip, opts) => request(`/ip/${enc(ip)}`, deepQuery(opts), void 0, opts),
|
|
@@ -289,7 +295,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
289
295
|
}
|
|
290
296
|
),
|
|
291
297
|
language: (code, opts) => request(`/language/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
292
|
-
name: (name, opts) => request(`/name/${enc(name)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
298
|
+
name: (name, opts) => request(`/name/${enc(name)}`, { country: opts?.country, ...deepQuery(opts), name_locale: opts?.name_locale }, void 0, opts),
|
|
293
299
|
/** Current local time, UTC by default. With to, offsetless at is source wall time. */
|
|
294
300
|
time: Object.assign(
|
|
295
301
|
(timezone, opts) => request(timezone === void 0 ? "/time" : `/time/${enc(timezone)}`, { at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
|