@parseapi/sdk 0.3.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -3
- package/dist/index.cjs +75 -26
- package/dist/index.d.cts +597 -241
- package/dist/index.d.ts +597 -241
- package/dist/index.js +75 -26
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var VERSION = "0.
|
|
2
|
+
var VERSION = "1.0.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;
|
|
@@ -89,6 +90,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
89
90
|
validateTimeout(attemptTimeout);
|
|
90
91
|
validateRetries(retries);
|
|
91
92
|
const url = new URL(baseUrl + path);
|
|
93
|
+
if (controls.lang !== void 0) url.searchParams.set("lang", controls.lang);
|
|
92
94
|
for (const [name, value] of Object.entries(query ?? {})) {
|
|
93
95
|
if (value !== void 0) url.searchParams.set(name, String(value));
|
|
94
96
|
}
|
|
@@ -104,7 +106,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
104
106
|
try {
|
|
105
107
|
res = await doFetch(url, {
|
|
106
108
|
redirect: "manual",
|
|
107
|
-
headers: { "X-API-Key": key, "User-Agent": `parseapi-node/${VERSION}`, ...headers },
|
|
109
|
+
headers: { "X-API-Key": key, "User-Agent": `parseapi-node/${VERSION}`, ...headers, "Parse-Version": API_VERSION },
|
|
108
110
|
signal: controller.signal
|
|
109
111
|
});
|
|
110
112
|
} catch (error) {
|
|
@@ -154,9 +156,11 @@ function parseAPI(apiKey, options = {}) {
|
|
|
154
156
|
const enc = encodeURIComponent;
|
|
155
157
|
const deepQuery = (opts) => opts?.deep ? { deep: true } : {};
|
|
156
158
|
return {
|
|
159
|
+
/** Look up an IP. `deep: true` adds enrichment included with a paid plan, without a separate check meter. */
|
|
157
160
|
ip: Object.assign(
|
|
158
161
|
(ip, opts) => request(`/ip/${enc(ip)}`, deepQuery(opts), void 0, opts),
|
|
159
162
|
{
|
|
163
|
+
/** Look up the public IP making this request. On a server, this is the server's IP. */
|
|
160
164
|
self: (opts) => request("/ip", deepQuery(opts), void 0, opts)
|
|
161
165
|
}
|
|
162
166
|
),
|
|
@@ -173,69 +177,104 @@ function parseAPI(apiKey, options = {}) {
|
|
|
173
177
|
}
|
|
174
178
|
),
|
|
175
179
|
country: Object.assign(
|
|
176
|
-
(code, opts) => request(`/country/${enc(code)}`,
|
|
180
|
+
(code, opts) => request(`/country/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
177
181
|
{
|
|
178
182
|
states: (code, opts) => request(`/country/${enc(code)}/states`, void 0, void 0, opts)
|
|
179
183
|
}
|
|
180
184
|
),
|
|
181
185
|
state: Object.assign(
|
|
182
|
-
(code, opts) => request(`/state/${enc(code)}`, { country: opts?.country }, void 0, opts),
|
|
186
|
+
(code, opts) => request(`/state/${enc(code)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
183
187
|
{
|
|
184
|
-
districts: (code, opts) => request(`/state/${enc(code)}/districts`, { country: opts?.country }, void 0, opts)
|
|
188
|
+
districts: (code, opts) => request(`/state/${enc(code)}/districts`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts)
|
|
185
189
|
}
|
|
186
190
|
),
|
|
187
|
-
district: (code, opts) => request(`/district/${enc(code)}`, { country: opts?.country, state: opts?.state }, void 0, opts),
|
|
191
|
+
district: (code, opts) => request(`/district/${enc(code)}`, { country: opts?.country, state: opts?.state, ...deepQuery(opts) }, void 0, opts),
|
|
188
192
|
city: Object.assign(
|
|
189
|
-
(name, opts) => request(`/city/${enc(name)}`, { country: opts?.country, state: opts?.state }, void 0, opts),
|
|
193
|
+
(name, opts) => request(`/city/${enc(name)}`, { country: opts?.country, state: opts?.state, ...deepQuery(opts) }, void 0, opts),
|
|
190
194
|
{
|
|
191
|
-
id: (id, opts) => request(`/city/id/${enc(id)}`,
|
|
192
|
-
search: (query, opts) => request("/city", { q: query, country: opts?.country, state: opts?.state, limit: opts?.limit }, void 0, opts),
|
|
193
|
-
nearest: (lat, lon, opts) => request("/city", { lat, lon }, void 0, opts),
|
|
195
|
+
id: (id, opts) => request(`/city/id/${enc(id)}`, deepQuery(opts), void 0, opts),
|
|
196
|
+
search: (query, opts) => request("/city", { q: query, country: opts?.country, state: opts?.state, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts),
|
|
197
|
+
nearest: (lat, lon, opts) => request("/city", { lat, lon, ...deepQuery(opts) }, void 0, opts),
|
|
194
198
|
nearby: (name, opts) => request(`/city/${enc(name)}/nearby`, {
|
|
195
199
|
radius: opts?.radius,
|
|
196
200
|
unit: opts?.unit,
|
|
197
201
|
country: opts?.country,
|
|
198
202
|
state: opts?.state,
|
|
199
|
-
limit: opts?.limit
|
|
203
|
+
limit: opts?.limit,
|
|
204
|
+
...deepQuery(opts)
|
|
200
205
|
}, void 0, opts)
|
|
201
206
|
}
|
|
202
207
|
),
|
|
208
|
+
/** Look up a postal area. Pass country when known. Check nullable latitude/longitude before another location lookup. */
|
|
203
209
|
postal: Object.assign(
|
|
204
|
-
(code, opts) => request(`/postal/${enc(code)}`, { country: opts?.country }, void 0, opts),
|
|
210
|
+
(code, opts) => request(`/postal/${enc(code)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
205
211
|
{
|
|
206
212
|
nearby: (code, opts) => request(`/postal/${enc(code)}/nearby`, {
|
|
207
213
|
country: opts?.country,
|
|
208
214
|
radius: opts?.radius,
|
|
209
|
-
unit: opts?.unit
|
|
215
|
+
unit: opts?.unit,
|
|
216
|
+
...deepQuery(opts)
|
|
210
217
|
}, void 0, opts),
|
|
211
|
-
distance: (from, to, opts) => request(`/postal/${enc(from)}/distance/${enc(to)}`, { country: opts?.country }, void 0, opts)
|
|
218
|
+
distance: (from, to, opts) => request(`/postal/${enc(from)}/distance/${enc(to)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts)
|
|
212
219
|
}
|
|
213
220
|
),
|
|
214
221
|
address: Object.assign(
|
|
215
222
|
(address, opts) => request(`/address/${enc(address)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
216
223
|
{
|
|
224
|
+
/** Find address suggestions using the context supplied. Prefer postal, or city and state, from the form. ip is an optional end-user locality hint for server-side calls. An empty result has reason more_input, missing_context or no_matches. Suggestions have reason null. Operational failures are errors. */
|
|
217
225
|
search: (query, opts) => request("/address", { q: query, country: opts?.country, postal: opts?.postal, city: opts?.city, state: opts?.state, ip: opts?.ip }, void 0, opts)
|
|
218
226
|
}
|
|
219
227
|
),
|
|
220
228
|
company: (number, opts) => request(`/company/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
229
|
+
/**
|
|
230
|
+
* Parse an email and check its format and domain.
|
|
231
|
+
* `deep: true` explicitly requests a metered deliverability check using included checks or enabled on-demand usage.
|
|
232
|
+
* Deep checks default to one attempt. An explicit retry count can repeat paid usage.
|
|
233
|
+
*/
|
|
221
234
|
email: (email, opts) => request(`/email/${enc(email)}`, deepQuery(opts), void 0, opts),
|
|
235
|
+
/** Check VAT format and checksum. `deep: true` requests a metered registry check where supported, with no automatic retries by default. */
|
|
222
236
|
vat: (number, opts) => request(`/vat/${enc(number)}`, {
|
|
223
237
|
country: opts?.country,
|
|
224
238
|
from: opts?.from,
|
|
225
239
|
...deepQuery(opts)
|
|
226
240
|
}, void 0, opts),
|
|
227
|
-
iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country }, void 0, opts),
|
|
241
|
+
iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
228
242
|
npi: (npi, opts) => request(`/npi/${enc(npi)}`, deepQuery(opts), void 0, opts),
|
|
243
|
+
/** Parse a phone number and its formats. Pass country for national numbers when needed. Deep adds numbering-plan geography. */
|
|
229
244
|
phone: (number, opts) => request(`/phone/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
230
|
-
|
|
245
|
+
/** Request a metered carrier lookup. No automatic retries by default. */
|
|
246
|
+
carrier: (number, opts) => request(`/carrier/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
247
|
+
/** Request a metered caller-name lookup for a NANP number. No automatic retries by default. */
|
|
231
248
|
caller: (number, opts) => request(`/caller/${enc(number)}`, { country: opts?.country }, void 0, opts),
|
|
232
|
-
|
|
249
|
+
/** Look up phone status at the last check. Live means assigned and connected means reachable at that check. Cached results may be returned. Null means unconfirmed. Deep adds network diagnostics within the same metered lookup. No automatic retries by default. */
|
|
250
|
+
hlr: (number, opts) => request(`/hlr/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
251
|
+
/** Check whether a domain is registered. Deep adds registration dates, registrar, status and DNSSEC on paid plans. */
|
|
233
252
|
domain: (domain, opts) => request(`/domain/${enc(domain)}`, deepQuery(opts), void 0, opts),
|
|
234
253
|
asn: (asn, opts) => request(`/asn/${enc(asn)}`, void 0, void 0, opts),
|
|
235
254
|
mac: (mac, opts) => request(`/mac/${enc(mac)}`, void 0, void 0, opts),
|
|
255
|
+
/** Look up a 6-11 digit card prefix. Keep leading zeros in the input string. */
|
|
256
|
+
bin: (bin, opts) => request(`/bin/${enc(bin)}`, { deep: opts?.deep }, void 0, opts),
|
|
257
|
+
/** Parse a measurement or convert it to `to`. Without `to`, use its type's canonical unit. Invalid input is plain data with `valid: false`. */
|
|
258
|
+
measure: Object.assign(
|
|
259
|
+
(measure, opts) => request(`/measure/${enc(measure)}`, { to: opts?.to, locale: opts?.locale, system: opts?.system }, void 0, opts),
|
|
260
|
+
{
|
|
261
|
+
/** Discover reviewed units. Pass `unit` to find compatible conversion targets. */
|
|
262
|
+
units: (opts) => request("/measure/units", { q: opts?.query, type: opts?.type, unit: opts?.unit }, void 0, opts)
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/** Look up DNS records with TTLs. Type selects the question and may include its CNAME chain. Pooled on every plan. */
|
|
266
|
+
dns: (domain, opts) => request(`/dns/${enc(domain)}`, { type: opts?.type }, void 0, opts),
|
|
236
267
|
mx: (domain, opts) => request(`/mx/${enc(domain)}`, void 0, void 0, opts),
|
|
237
268
|
useragent: (ua, opts) => request("/useragent", deepQuery(opts), { "User-Agent": ua }, opts),
|
|
238
269
|
vin: (vin, opts) => request(`/vin/${enc(vin)}`, deepQuery(opts), void 0, opts),
|
|
270
|
+
/** US NAICS 2022 definitions and hierarchy. */
|
|
271
|
+
naics: Object.assign(
|
|
272
|
+
(code, opts) => request(`/naics/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
273
|
+
{
|
|
274
|
+
search: (query, opts) => request("/naics", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
/** Look up the general US duty schedule line. Paid deep adds units and the special and other schedule columns. Add origin with deep to resolve country-specific measures. Without origin, schedule detail remains available and origin-dependent fields are null. A null effective rate is not a zero rate. */
|
|
239
278
|
tariff: Object.assign(
|
|
240
279
|
(code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, ...deepQuery(opts) }, void 0, opts),
|
|
241
280
|
{
|
|
@@ -243,7 +282,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
243
282
|
}
|
|
244
283
|
),
|
|
245
284
|
currency: Object.assign(
|
|
246
|
-
(code, opts) => request(`/currency/${enc(code)}`,
|
|
285
|
+
(code, opts) => request(`/currency/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
247
286
|
{
|
|
248
287
|
rate: (base, quote, opts) => request(`/currency/${enc(base)}/${enc(quote)}`, {
|
|
249
288
|
date: opts?.date,
|
|
@@ -251,18 +290,25 @@ function parseAPI(apiKey, options = {}) {
|
|
|
251
290
|
}, void 0, opts)
|
|
252
291
|
}
|
|
253
292
|
),
|
|
254
|
-
language: (code, opts) => request(`/language/${enc(code)}`,
|
|
255
|
-
name: (name, opts) => request(`/name/${enc(name)}`,
|
|
293
|
+
language: (code, opts) => request(`/language/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
294
|
+
name: (name, opts) => request(`/name/${enc(name)}`, { country: opts?.country, ...deepQuery(opts), name_locale: opts?.name_locale }, void 0, opts),
|
|
295
|
+
/** Current local time, UTC by default. With to, offsetless at is source wall time. */
|
|
296
|
+
time: Object.assign(
|
|
297
|
+
(timezone, opts) => request(timezone === void 0 ? "/time" : `/time/${enc(timezone)}`, { at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
|
|
298
|
+
{
|
|
299
|
+
at: (lat, lon, opts) => request("/time", { lat, lon, at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts)
|
|
300
|
+
}
|
|
301
|
+
),
|
|
256
302
|
timezone: Object.assign(
|
|
257
|
-
(id, opts) => request(`/timezone/${enc(id)}`, { at: opts?.at, to: opts?.to }, void 0, opts),
|
|
303
|
+
(id, opts) => request(`/timezone/${enc(id)}`, { at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
|
|
258
304
|
{
|
|
259
|
-
at: (lat, lon, opts) => request("/timezone", { lat, lon, at: opts?.at }, void 0, opts)
|
|
305
|
+
at: (lat, lon, opts) => request("/timezone", { lat, lon, at: opts?.at, ...deepQuery(opts) }, void 0, opts)
|
|
260
306
|
}
|
|
261
307
|
),
|
|
262
308
|
date: Object.assign(
|
|
263
|
-
(date, opts) => request(`/date/${enc(date)}`, { format: opts?.format, to: opts?.to }, void 0, opts),
|
|
309
|
+
(date, opts) => request(`/date/${enc(date)}`, { format: opts?.format, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
|
|
264
310
|
{
|
|
265
|
-
today: (opts) => request("/date", { to: opts?.to }, void 0, opts)
|
|
311
|
+
today: (opts) => request("/date", { to: opts?.to, ...deepQuery(opts) }, void 0, opts)
|
|
266
312
|
}
|
|
267
313
|
),
|
|
268
314
|
holiday: Object.assign(
|
|
@@ -272,12 +318,14 @@ function parseAPI(apiKey, options = {}) {
|
|
|
272
318
|
}
|
|
273
319
|
),
|
|
274
320
|
elevation: (lat, lon, opts) => request("/elevation", { lat, lon }, void 0, opts),
|
|
321
|
+
/** 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. */
|
|
275
322
|
point: (lat, lon, opts) => request("/point", { lat, lon, ...deepQuery(opts) }, void 0, opts),
|
|
323
|
+
/** 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. */
|
|
276
324
|
weather: (lat, lon, opts) => request("/weather", { lat, lon, date: opts?.date, ...deepQuery(opts) }, void 0, opts),
|
|
277
325
|
emoji: Object.assign(
|
|
278
|
-
(emoji, opts) => request(`/emoji/${enc(emoji)}`,
|
|
326
|
+
(emoji, opts) => request(`/emoji/${enc(emoji)}`, deepQuery(opts), void 0, opts),
|
|
279
327
|
{
|
|
280
|
-
search: (query, opts) => request("/emoji", { q: query, limit: opts?.limit }, void 0, opts)
|
|
328
|
+
search: (query, opts) => request("/emoji", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
|
|
281
329
|
}
|
|
282
330
|
)
|
|
283
331
|
};
|
|
@@ -286,3 +334,4 @@ export {
|
|
|
286
334
|
ParseAPIError,
|
|
287
335
|
parseAPI
|
|
288
336
|
};
|
|
337
|
+
/*! You found Dev. https://parseapi.com/dev */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parseapi/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Official ParseAPI client for Node and TypeScript. One key, minimal JSON, fast.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"parseapi",
|
|
@@ -59,6 +59,9 @@
|
|
|
59
59
|
"@types/node": "^22.10.0",
|
|
60
60
|
"tsup": "^8.3.5",
|
|
61
61
|
"typescript": "^5.7.0",
|
|
62
|
-
"vitest": "^
|
|
62
|
+
"vitest": "^4.1.11"
|
|
63
|
+
},
|
|
64
|
+
"overrides": {
|
|
65
|
+
"esbuild": "0.27.2"
|
|
63
66
|
}
|
|
64
67
|
}
|