@parseapi/sdk 0.3.2 → 0.4.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- var VERSION = "0.3.2";
2
+ var VERSION = "0.4.0";
3
3
  var DEFAULT_BASE_URL = "https://api.parseapi.com";
4
4
  var DEFAULT_TIMEOUT_MS = 1e4;
5
5
  var DEFAULT_RETRIES = 2;
@@ -154,9 +154,11 @@ function parseAPI(apiKey, options = {}) {
154
154
  const enc = encodeURIComponent;
155
155
  const deepQuery = (opts) => opts?.deep ? { deep: true } : {};
156
156
  return {
157
+ /** Look up an IP. `deep: true` adds enrichment included with a paid plan, without a separate check meter. */
157
158
  ip: Object.assign(
158
159
  (ip, opts) => request(`/ip/${enc(ip)}`, deepQuery(opts), void 0, opts),
159
160
  {
161
+ /** Look up the public IP making this request. On a server, this is the server's IP. */
160
162
  self: (opts) => request("/ip", deepQuery(opts), void 0, opts)
161
163
  }
162
164
  ),
@@ -173,69 +175,104 @@ function parseAPI(apiKey, options = {}) {
173
175
  }
174
176
  ),
175
177
  country: Object.assign(
176
- (code, opts) => request(`/country/${enc(code)}`, void 0, void 0, opts),
178
+ (code, opts) => request(`/country/${enc(code)}`, deepQuery(opts), void 0, opts),
177
179
  {
178
180
  states: (code, opts) => request(`/country/${enc(code)}/states`, void 0, void 0, opts)
179
181
  }
180
182
  ),
181
183
  state: Object.assign(
182
- (code, opts) => request(`/state/${enc(code)}`, { country: opts?.country }, void 0, opts),
184
+ (code, opts) => request(`/state/${enc(code)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
183
185
  {
184
- districts: (code, opts) => request(`/state/${enc(code)}/districts`, { country: opts?.country }, void 0, opts)
186
+ districts: (code, opts) => request(`/state/${enc(code)}/districts`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts)
185
187
  }
186
188
  ),
187
- district: (code, opts) => request(`/district/${enc(code)}`, { country: opts?.country, state: opts?.state }, void 0, opts),
189
+ district: (code, opts) => request(`/district/${enc(code)}`, { country: opts?.country, state: opts?.state, ...deepQuery(opts) }, void 0, opts),
188
190
  city: Object.assign(
189
- (name, opts) => request(`/city/${enc(name)}`, { country: opts?.country, state: opts?.state }, void 0, opts),
191
+ (name, opts) => request(`/city/${enc(name)}`, { country: opts?.country, state: opts?.state, ...deepQuery(opts) }, void 0, opts),
190
192
  {
191
- id: (id, opts) => request(`/city/id/${enc(id)}`, void 0, void 0, opts),
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),
193
+ id: (id, opts) => request(`/city/id/${enc(id)}`, deepQuery(opts), void 0, opts),
194
+ search: (query, opts) => request("/city", { q: query, country: opts?.country, state: opts?.state, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts),
195
+ nearest: (lat, lon, opts) => request("/city", { lat, lon, ...deepQuery(opts) }, void 0, opts),
194
196
  nearby: (name, opts) => request(`/city/${enc(name)}/nearby`, {
195
197
  radius: opts?.radius,
196
198
  unit: opts?.unit,
197
199
  country: opts?.country,
198
200
  state: opts?.state,
199
- limit: opts?.limit
201
+ limit: opts?.limit,
202
+ ...deepQuery(opts)
200
203
  }, void 0, opts)
201
204
  }
202
205
  ),
206
+ /** Look up a postal area. Pass country when known. Check nullable latitude/longitude before another location lookup. */
203
207
  postal: Object.assign(
204
- (code, opts) => request(`/postal/${enc(code)}`, { country: opts?.country }, void 0, opts),
208
+ (code, opts) => request(`/postal/${enc(code)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
205
209
  {
206
210
  nearby: (code, opts) => request(`/postal/${enc(code)}/nearby`, {
207
211
  country: opts?.country,
208
212
  radius: opts?.radius,
209
- unit: opts?.unit
213
+ unit: opts?.unit,
214
+ ...deepQuery(opts)
210
215
  }, void 0, opts),
211
- distance: (from, to, opts) => request(`/postal/${enc(from)}/distance/${enc(to)}`, { country: opts?.country }, void 0, opts)
216
+ distance: (from, to, opts) => request(`/postal/${enc(from)}/distance/${enc(to)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts)
212
217
  }
213
218
  ),
214
219
  address: Object.assign(
215
220
  (address, opts) => request(`/address/${enc(address)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
216
221
  {
222
+ /** 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
223
  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
224
  }
219
225
  ),
220
226
  company: (number, opts) => request(`/company/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
227
+ /**
228
+ * Parse an email and check its format and domain.
229
+ * `deep: true` explicitly requests a metered deliverability check using included checks or enabled on-demand usage.
230
+ * Deep checks default to one attempt. An explicit retry count can repeat paid usage.
231
+ */
221
232
  email: (email, opts) => request(`/email/${enc(email)}`, deepQuery(opts), void 0, opts),
233
+ /** Check VAT format and checksum. `deep: true` requests a metered registry check where supported, with no automatic retries by default. */
222
234
  vat: (number, opts) => request(`/vat/${enc(number)}`, {
223
235
  country: opts?.country,
224
236
  from: opts?.from,
225
237
  ...deepQuery(opts)
226
238
  }, void 0, opts),
227
- iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country }, void 0, opts),
239
+ iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
228
240
  npi: (npi, opts) => request(`/npi/${enc(npi)}`, deepQuery(opts), void 0, opts),
241
+ /** Parse a phone number and its formats. Pass country for national numbers when needed. Deep adds numbering-plan geography. */
229
242
  phone: (number, opts) => request(`/phone/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
230
- carrier: (number, opts) => request(`/carrier/${enc(number)}`, { country: opts?.country }, void 0, opts),
243
+ /** Request a metered carrier lookup. No automatic retries by default. */
244
+ carrier: (number, opts) => request(`/carrier/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
245
+ /** Request a metered caller-name lookup for a NANP number. No automatic retries by default. */
231
246
  caller: (number, opts) => request(`/caller/${enc(number)}`, { country: opts?.country }, void 0, opts),
232
- hlr: (number, opts) => request(`/hlr/${enc(number)}`, { country: opts?.country }, void 0, opts),
247
+ /** 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. */
248
+ hlr: (number, opts) => request(`/hlr/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
249
+ /** Check whether a domain is registered. Deep adds registration dates, registrar, status and DNSSEC on paid plans. */
233
250
  domain: (domain, opts) => request(`/domain/${enc(domain)}`, deepQuery(opts), void 0, opts),
234
251
  asn: (asn, opts) => request(`/asn/${enc(asn)}`, void 0, void 0, opts),
235
252
  mac: (mac, opts) => request(`/mac/${enc(mac)}`, void 0, void 0, opts),
253
+ /** Look up a 6-11 digit card prefix. Keep leading zeros in the input string. */
254
+ bin: (bin, opts) => request(`/bin/${enc(bin)}`, { deep: opts?.deep }, void 0, opts),
255
+ /** Parse a measurement or convert it to `to`. Without `to`, use its type's canonical unit. Invalid input is plain data with `valid: false`. */
256
+ measure: Object.assign(
257
+ (measure, opts) => request(`/measure/${enc(measure)}`, { to: opts?.to, locale: opts?.locale, system: opts?.system }, void 0, opts),
258
+ {
259
+ /** Discover reviewed units. Pass `unit` to find compatible conversion targets. */
260
+ units: (opts) => request("/measure/units", { q: opts?.query, type: opts?.type, unit: opts?.unit }, void 0, opts)
261
+ }
262
+ ),
263
+ /** Look up DNS records with TTLs. Type selects the question and may include its CNAME chain. Pooled on every plan. */
264
+ dns: (domain, opts) => request(`/dns/${enc(domain)}`, { type: opts?.type }, void 0, opts),
236
265
  mx: (domain, opts) => request(`/mx/${enc(domain)}`, void 0, void 0, opts),
237
266
  useragent: (ua, opts) => request("/useragent", deepQuery(opts), { "User-Agent": ua }, opts),
238
267
  vin: (vin, opts) => request(`/vin/${enc(vin)}`, deepQuery(opts), void 0, opts),
268
+ /** US NAICS 2022 definitions and hierarchy. */
269
+ naics: Object.assign(
270
+ (code, opts) => request(`/naics/${enc(code)}`, deepQuery(opts), void 0, opts),
271
+ {
272
+ search: (query, opts) => request("/naics", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
273
+ }
274
+ ),
275
+ /** 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
276
  tariff: Object.assign(
240
277
  (code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, ...deepQuery(opts) }, void 0, opts),
241
278
  {
@@ -243,7 +280,7 @@ function parseAPI(apiKey, options = {}) {
243
280
  }
244
281
  ),
245
282
  currency: Object.assign(
246
- (code, opts) => request(`/currency/${enc(code)}`, void 0, void 0, opts),
283
+ (code, opts) => request(`/currency/${enc(code)}`, deepQuery(opts), void 0, opts),
247
284
  {
248
285
  rate: (base, quote, opts) => request(`/currency/${enc(base)}/${enc(quote)}`, {
249
286
  date: opts?.date,
@@ -251,18 +288,25 @@ function parseAPI(apiKey, options = {}) {
251
288
  }, void 0, opts)
252
289
  }
253
290
  ),
254
- language: (code, opts) => request(`/language/${enc(code)}`, void 0, void 0, opts),
255
- name: (name, opts) => request(`/name/${enc(name)}`, void 0, void 0, opts),
291
+ 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),
293
+ /** Current local time, UTC by default. With to, offsetless at is source wall time. */
294
+ time: Object.assign(
295
+ (timezone, opts) => request(timezone === void 0 ? "/time" : `/time/${enc(timezone)}`, { at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
296
+ {
297
+ at: (lat, lon, opts) => request("/time", { lat, lon, at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts)
298
+ }
299
+ ),
256
300
  timezone: Object.assign(
257
- (id, opts) => request(`/timezone/${enc(id)}`, { at: opts?.at, to: opts?.to }, void 0, opts),
301
+ (id, opts) => request(`/timezone/${enc(id)}`, { at: opts?.at, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
258
302
  {
259
- at: (lat, lon, opts) => request("/timezone", { lat, lon, at: opts?.at }, void 0, opts)
303
+ at: (lat, lon, opts) => request("/timezone", { lat, lon, at: opts?.at, ...deepQuery(opts) }, void 0, opts)
260
304
  }
261
305
  ),
262
306
  date: Object.assign(
263
- (date, opts) => request(`/date/${enc(date)}`, { format: opts?.format, to: opts?.to }, void 0, opts),
307
+ (date, opts) => request(`/date/${enc(date)}`, { format: opts?.format, to: opts?.to, ...deepQuery(opts) }, void 0, opts),
264
308
  {
265
- today: (opts) => request("/date", { to: opts?.to }, void 0, opts)
309
+ today: (opts) => request("/date", { to: opts?.to, ...deepQuery(opts) }, void 0, opts)
266
310
  }
267
311
  ),
268
312
  holiday: Object.assign(
@@ -272,12 +316,14 @@ function parseAPI(apiKey, options = {}) {
272
316
  }
273
317
  ),
274
318
  elevation: (lat, lon, opts) => request("/elevation", { lat, lon }, void 0, opts),
319
+ /** 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
320
  point: (lat, lon, opts) => request("/point", { lat, lon, ...deepQuery(opts) }, void 0, opts),
321
+ /** 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
322
  weather: (lat, lon, opts) => request("/weather", { lat, lon, date: opts?.date, ...deepQuery(opts) }, void 0, opts),
277
323
  emoji: Object.assign(
278
- (emoji, opts) => request(`/emoji/${enc(emoji)}`, void 0, void 0, opts),
324
+ (emoji, opts) => request(`/emoji/${enc(emoji)}`, deepQuery(opts), void 0, opts),
279
325
  {
280
- search: (query, opts) => request("/emoji", { q: query, limit: opts?.limit }, void 0, opts)
326
+ search: (query, opts) => request("/emoji", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
281
327
  }
282
328
  )
283
329
  };
@@ -286,3 +332,4 @@ export {
286
332
  ParseAPIError,
287
333
  parseAPI
288
334
  };
335
+ /*! 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.2",
3
+ "version": "0.4.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": "^2.1.8"
62
+ "vitest": "^4.1.11"
63
+ },
64
+ "overrides": {
65
+ "esbuild": "0.27.2"
63
66
  }
64
67
  }