@parseapi/sdk 1.7.0 → 1.8.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.d.ts CHANGED
@@ -305,7 +305,22 @@ interface Vat {
305
305
  from?: string;
306
306
  deep?: Deep<VatDeep>;
307
307
  }
308
- interface Iban {
308
+ /** Ordered IBAN checks. States are open strings for future API values. */
309
+ interface BankChecks {
310
+ input: string;
311
+ country: string;
312
+ length: string;
313
+ structure: string;
314
+ checksum: string;
315
+ national: string;
316
+ }
317
+ /** A validation issue. Fields and codes remain open strings. */
318
+ interface BankIssue {
319
+ field: string;
320
+ code: string;
321
+ message: string;
322
+ }
323
+ interface Bank {
309
324
  iban: string | null;
310
325
  valid: boolean;
311
326
  country: string | null;
@@ -317,16 +332,91 @@ interface Iban {
317
332
  bank_name: string | null;
318
333
  /** BIC from that same directory. Null when unsourced or missing. */
319
334
  bic: string | null;
320
- deep?: Deep<IbanDeep>;
335
+ /** Core check results. Older responses may omit them. */
336
+ checks?: BankChecks;
337
+ /** First blocking validation issue, or an empty list. Older responses may omit it. */
338
+ issues?: BankIssue[];
339
+ deep?: Deep<BankDeep>;
340
+ }
341
+ /** Directory evidence is optional and present only when a lookup ran. */
342
+ interface BankDirectory {
343
+ edition: string;
344
+ country: string;
345
+ /** bank, branch, prefix or none; remains open for future API values. */
346
+ match: string;
321
347
  }
322
- interface Npi {
323
- /** Normalized 10-digit NPI. Invalid input still echoes the fold. */
348
+ interface BankRequirementField {
349
+ key: string;
350
+ label: string;
351
+ required: boolean;
352
+ type: string;
353
+ length?: number;
354
+ min_length?: number;
355
+ max_length?: number;
356
+ max_input_length?: number;
357
+ length_unit?: string;
358
+ pattern?: string;
359
+ normalization?: string;
360
+ }
361
+ interface BankRequirements {
362
+ country: string;
363
+ format: string;
364
+ supported: boolean;
365
+ fields: BankRequirementField[];
366
+ checks: Record<string, string>;
367
+ limitations: string[];
368
+ }
369
+ /** US ACH syntax/checksum analysis; no account or payment verification. */
370
+ interface BankUsAchInput {
371
+ routing: string;
372
+ account: string;
373
+ }
374
+ interface BankUsAchChecks {
375
+ routing_format: string;
376
+ routing_checksum: string;
377
+ account_format: string;
378
+ account_checksum: string;
379
+ }
380
+ interface BankUsAch {
381
+ format: string;
382
+ country: string;
383
+ routing: string | null;
384
+ account: string | null;
385
+ valid: boolean;
386
+ bank_name: string | null;
387
+ checks: BankUsAchChecks;
388
+ issues: BankIssue[];
389
+ }
390
+ interface ProviderTaxonomy {
391
+ taxonomy?: string | null;
392
+ specialty?: string | null;
393
+ primary?: boolean | null;
394
+ license?: string | null;
395
+ state?: string | null;
396
+ }
397
+ interface ProviderSource {
398
+ edition?: string | null;
399
+ published_at?: string | null;
400
+ through?: string | null;
401
+ imported_at?: string | null;
402
+ }
403
+ interface ProviderSources {
404
+ nppes?: ProviderSource | null;
405
+ leie?: ProviderSource | null;
406
+ pecos?: ProviderSource | null;
407
+ optout?: ProviderSource | null;
408
+ }
409
+ interface Provider {
410
+ sources?: ProviderSources | null;
411
+ /** Input with accepted separators removed; null when empty. Invalid values remain visible. */
324
412
  npi: string | null;
413
+ /** Format and NPI checksum only; does not verify a provider or credentials. */
325
414
  valid: boolean;
326
- /** Exists in the CMS NPPES registry. */
415
+ /** Found in the stored NPPES snapshot. Null when input is invalid. */
327
416
  registered: boolean | null;
417
+ /** Recorded NPI activation status. Null when unknown; not licensure or practice status. */
328
418
  active: boolean | null;
329
- /** On the OIG exclusion list. */
419
+ /** NPI-only match in the stored OIG LEIE file. False is not complete exclusion clearance. */
330
420
  excluded: boolean | null;
331
421
  /** individual or organization. */
332
422
  type: string | null;
@@ -344,22 +434,26 @@ interface Npi {
344
434
  postal: string | null;
345
435
  country: string | null;
346
436
  phone: string | null;
347
- deep?: Deep<NpiDeep>;
437
+ deep?: Deep<ProviderDeep>;
348
438
  }
349
- interface NpiEnrollment {
439
+ interface ProviderEnrollment {
350
440
  /** part_a, part_b, practitioner, dme, order_refer, mdpp. Null when the code is unknown. */
351
441
  type: string | null;
352
442
  specialty: string | null;
353
443
  state: string | null;
354
444
  }
355
- interface NpiDeep {
356
- /** In the published Medicare FFS enrollment extract. */
445
+ interface ProviderDeep {
446
+ enumerated_at?: string | null;
447
+ updated_at?: string | null;
448
+ reactivated_at?: string | null;
449
+ taxonomies?: ProviderTaxonomy[] | null;
450
+ /** Present in the stored Medicare FFS enrollment extract; not payment eligibility. */
357
451
  medicare?: boolean | null;
358
- /** On the CMS opt-out affidavit list. Matched by NPI only. */
452
+ /** NPI-only match in the stored CMS opt-out affidavit list. Null when unavailable. */
359
453
  opt_out?: boolean | null;
360
- /** Enrollment rows. [] when medicare is false. */
361
- enrollments?: NpiEnrollment[] | null;
362
- /** Date CMS deactivated the NPI, YYYY-MM-DD. Null when still active. */
454
+ /** Stored enrollment rows. Null when unavailable; [] when no rows are returned. */
455
+ enrollments?: ProviderEnrollment[] | null;
456
+ /** Recorded NPI deactivation date, YYYY-MM-DD. Null when active or unavailable. */
363
457
  deactivated_at: string | null;
364
458
  }
365
459
  interface TariffMeasure {
@@ -436,7 +530,7 @@ interface VinRecall {
436
530
  summary: string | null;
437
531
  }
438
532
  interface VinDeep {
439
- /** Open recall campaigns for the decoded vehicle. [] when none, null when the registry did not answer. */
533
+ /** Recall campaigns for the decoded year, make and model. [] when none, null when the registry did not answer. */
440
534
  recalls?: VinRecall[] | null;
441
535
  series: string | null;
442
536
  doors: number | null;
@@ -572,20 +666,23 @@ interface Mac {
572
666
  local: boolean | null;
573
667
  multicast: boolean | null;
574
668
  }
575
- /** Card-prefix reference data. Null means unknown, not an invalid payment card. */
576
- interface Bin {
669
+ /** Network identity from reviewed prefix rules; null means unknown or ambiguous. */
670
+ interface Card {
577
671
  bin: string;
578
- /** Actual longest matched prefix. May be shorter than the input. */
579
- prefix: string | null;
580
- country: string | null;
581
- issuer: string | null;
582
- /** Network key (visa, amex) or co-branded combination. */
583
672
  brand: string | null;
584
- /** Display name for brand (American Express). */
585
673
  brand_name: string | null;
674
+ /** SVG URL, with a generic-card fallback. */
675
+ logo: string;
676
+ /** Included only when requested; pooled on every plan. */
677
+ deep?: CardDeep;
678
+ }
679
+ interface CardDeep {
680
+ /** Longest recorded matching prefix; may be shorter than bin. */
681
+ prefix: string | null;
682
+ issuer: string | null;
683
+ country: string | null;
586
684
  type: string | null;
587
685
  prepaid: boolean | null;
588
- deep?: Record<string, never>;
589
686
  }
590
687
  /** A published DNS record. Value is DNS presentation text, including TXT quoting. */
591
688
  interface DnsRecord {
@@ -1208,7 +1305,9 @@ interface PostalDeep {
1208
1305
  /** Median annual property tax payable on owner-occupied homes in this statistical area. Null when unsupported, missing or censored. */
1209
1306
  property_tax?: PropertyTax | null;
1210
1307
  }
1211
- interface IbanDeep {
1308
+ interface BankDeep {
1309
+ /** Source edition and exact match grain, not coverage or account verification. */
1310
+ directory?: BankDirectory;
1212
1311
  /** Two check digits as a string, keeping a leading zero. */
1213
1312
  checksum: string | null;
1214
1313
  /** Branch identifier when that country has one. */
@@ -1387,6 +1486,95 @@ interface TimeLocation {
1387
1486
  truncated: boolean;
1388
1487
  source: string;
1389
1488
  }
1489
+ type Industry = Naics;
1490
+ type IndustryChild = NaicsChild;
1491
+ type IndustryCorrection = NaicsCorrection;
1492
+ type IndustryDeep = NaicsDeep;
1493
+ type IndustryExclusion = NaicsExclusion;
1494
+ type IndustryMatch = NaicsMatch;
1495
+ type IndustrySearch = NaicsSearch;
1496
+ type IndustrySearchItem = NaicsSearchItem;
1497
+ type Vehicle = Vin;
1498
+ type VehicleDeep = VinDeep;
1499
+ type VehicleRecall = VinRecall;
1500
+ interface Iban {
1501
+ iban: string | null;
1502
+ valid: boolean;
1503
+ country: string | null;
1504
+ /** Print form in groups of four, for display. Null when invalid. */
1505
+ formatted: string | null;
1506
+ /** Bank identifier parsed from the number, not a name. */
1507
+ bank: string | null;
1508
+ /** Institution name from the national bank-code directory. Null when unsourced. */
1509
+ bank_name: string | null;
1510
+ /** BIC from that same directory. Null when unsourced or missing. */
1511
+ bic: string | null;
1512
+ deep?: Deep<IbanDeep>;
1513
+ }
1514
+ interface Npi {
1515
+ /** Normalized 10-digit NPI. Invalid input still echoes the fold. */
1516
+ npi: string | null;
1517
+ valid: boolean;
1518
+ /** Exists in the CMS NPPES registry. */
1519
+ registered: boolean | null;
1520
+ active: boolean | null;
1521
+ /** On the OIG exclusion list. */
1522
+ excluded: boolean | null;
1523
+ /** individual or organization. */
1524
+ type: string | null;
1525
+ name: string | null;
1526
+ first: string | null;
1527
+ last: string | null;
1528
+ credential: string | null;
1529
+ specialty: string | null;
1530
+ /** NUCC taxonomy code. */
1531
+ taxonomy: string | null;
1532
+ address: string | null;
1533
+ city: string | null;
1534
+ state: string | null;
1535
+ state_name: string | null;
1536
+ postal: string | null;
1537
+ country: string | null;
1538
+ phone: string | null;
1539
+ deep?: Deep<NpiDeep>;
1540
+ }
1541
+ interface NpiEnrollment {
1542
+ /** part_a, part_b, practitioner, dme, order_refer, mdpp. Null when the code is unknown. */
1543
+ type: string | null;
1544
+ specialty: string | null;
1545
+ state: string | null;
1546
+ }
1547
+ interface NpiDeep {
1548
+ /** In the published Medicare FFS enrollment extract. */
1549
+ medicare?: boolean | null;
1550
+ /** On the CMS opt-out affidavit list. Matched by NPI only. */
1551
+ opt_out?: boolean | null;
1552
+ /** Enrollment rows. [] when medicare is false. */
1553
+ enrollments?: NpiEnrollment[] | null;
1554
+ /** Date CMS deactivated the NPI, YYYY-MM-DD. Null when still active. */
1555
+ deactivated_at: string | null;
1556
+ }
1557
+ interface Bin {
1558
+ bin: string;
1559
+ /** Actual longest matched prefix. May be shorter than the input. */
1560
+ prefix: string | null;
1561
+ country: string | null;
1562
+ issuer: string | null;
1563
+ /** Network key (visa, amex) or co-branded combination. */
1564
+ brand: string | null;
1565
+ /** Display name for brand (American Express). */
1566
+ brand_name: string | null;
1567
+ type: string | null;
1568
+ prepaid: boolean | null;
1569
+ deep?: Record<string, never>;
1570
+ }
1571
+ interface IbanDeep {
1572
+ /** Two check digits as a string, keeping a leading zero. */
1573
+ checksum: string | null;
1574
+ /** Branch identifier when that country has one. */
1575
+ branch: string | null;
1576
+ account: string | null;
1577
+ }
1390
1578
 
1391
1579
  /** A proposed task contains operation counts, never lookup inputs. */
1392
1580
  interface PreflightOperation {
@@ -1494,7 +1682,9 @@ declare class ParseAPIError extends Error {
1494
1682
  readonly docs: string | null;
1495
1683
  /** Send this if you contact support */
1496
1684
  readonly requestId: string | null;
1497
- constructor(status: number, code: string, message: string, docs: string | null, requestId: string | null);
1685
+ /** Original Retry-After response header, when supplied. */
1686
+ readonly retryAfter: string | null;
1687
+ constructor(status: number, code: string, message: string, docs: string | null, requestId: string | null, retryAfter?: string | null);
1498
1688
  }
1499
1689
  /** Optional output language for supported display fields. Input parsing stays unchanged. */
1500
1690
  interface LanguageOption {
@@ -1593,10 +1783,13 @@ type VatOptions = {
1593
1783
  country?: string;
1594
1784
  from?: string;
1595
1785
  } & DeepOption & RequestOptions;
1596
- type IbanOptions = {
1786
+ type BankOptions = {
1597
1787
  country?: string;
1598
1788
  } & DeepOption & RequestOptions;
1599
- type NpiOptions = LanguageOption & DeepOption & RequestOptions;
1789
+ type BankRequirementsOptions = {
1790
+ format?: string;
1791
+ } & RequestOptions;
1792
+ type ProviderOptions = LanguageOption & DeepOption & RequestOptions;
1600
1793
  /** Country resolves national-number ambiguity. Deep adds numbering-plan geography on every plan. */
1601
1794
  type PhoneOptions = {
1602
1795
  country?: string;
@@ -1619,8 +1812,8 @@ type StackOptions = {
1619
1812
  type DomainOptions = DeepOption & RequestOptions;
1620
1813
  type AsnOptions = LanguageOption & RequestOptions;
1621
1814
  type MacOptions = RequestOptions;
1622
- /** Card-prefix reference lookup. Deep returns an empty object on every plan. */
1623
- type BinOptions = DeepOption & RequestOptions;
1815
+ /** Request controls for a card-prefix reference lookup. */
1816
+ type CardOptions = DeepOption & RequestOptions;
1624
1817
  /** Parse a measurement, optionally converting it. Locale and system resolve explicit ambiguity. */
1625
1818
  type MeasureOptions = {
1626
1819
  to?: string;
@@ -1639,10 +1832,11 @@ type DnsOptions = {
1639
1832
  type MxOptions = RequestOptions;
1640
1833
  type UseragentOptions = DeepOption & RequestOptions;
1641
1834
  type VinOptions = DeepOption & RequestOptions;
1835
+ type VehicleOptions = VinOptions;
1642
1836
  /** US NAICS 2022 code lookup, using pooled requests. */
1643
- type NaicsOptions = DeepOption & RequestOptions;
1837
+ type IndustryOptions = DeepOption & RequestOptions;
1644
1838
  /** Keyword search. Limit defaults to 10 and accepts 1-50. */
1645
- type NaicsSearchOptions = {
1839
+ type IndustrySearchOptions = {
1646
1840
  limit?: number;
1647
1841
  } & DeepOption & RequestOptions;
1648
1842
  /** 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. */
@@ -1794,7 +1988,14 @@ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
1794
1988
  /** Check VAT format and checksum. `deep: true` requests a metered registry check where supported, with no automatic retries by default. */
1795
1989
  vat: (number: string, opts?: VatOptions) => Promise<Vat>;
1796
1990
  iban: (iban: string, opts?: IbanOptions) => Promise<Iban>;
1991
+ bin: (bin: string, opts?: BinOptions) => Promise<Bin>;
1797
1992
  npi: (npi: string, opts?: NpiOptions) => Promise<Npi>;
1993
+ bank: (iban: string, opts?: BankOptions) => Promise<Bank>;
1994
+ /** Check US routing/account syntax using POST. Does not verify ownership, existence or ACH eligibility. */
1995
+ bankUsAch: (input: BankUsAchInput, opts?: RequestOptions) => Promise<BankUsAch>;
1996
+ /** Describe supported input fields and check scope; this does not establish country directory coverage. */
1997
+ bankRequirements: (country: string, opts?: BankRequirementsOptions) => Promise<BankRequirements>;
1998
+ provider: (npi: string, opts?: ProviderOptions) => Promise<Provider>;
1798
1999
  /** Parse a phone number and its formats. Pass country for national numbers when needed. Deep adds numbering-plan geography. */
1799
2000
  phone: (number: string, opts?: PhoneOptions) => Promise<Phone>;
1800
2001
  /** Request a metered carrier lookup. No automatic retries by default. */
@@ -1809,8 +2010,8 @@ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
1809
2010
  domain: (domain: string, opts?: DomainOptions) => Promise<Domain>;
1810
2011
  asn: (asn: string, opts?: AsnOptions) => Promise<Asn>;
1811
2012
  mac: (mac: string, opts?: MacOptions) => Promise<Mac>;
1812
- /** Look up a 6-11 digit card prefix. Keep leading zeros in the input string. */
1813
- bin: (bin: string, opts?: BinOptions) => Promise<Bin>;
2013
+ /** Look up a 2-11 digit card prefix. Keep leading zeros in the input string. */
2014
+ card: (bin: string, opts?: CardOptions) => Promise<Card>;
1814
2015
  /** Parse a measurement or convert it to `to`. Without `to`, use its type's canonical unit. Invalid input is plain data with `valid: false`. */
1815
2016
  measure: ((measure: string, opts?: MeasureOptions) => Promise<Measure>) & {
1816
2017
  /** Discover reviewed units. Pass `unit` to find compatible conversion targets. */
@@ -1820,10 +2021,17 @@ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
1820
2021
  dns: (domain: string, opts?: DnsOptions) => Promise<Dns>;
1821
2022
  mx: (domain: string, opts?: MxOptions) => Promise<Mx>;
1822
2023
  useragent: (ua: string, opts?: UseragentOptions) => Promise<Useragent>;
2024
+ /** Identify a vehicle by VIN. Paid deep adds specifications and model-level recall campaigns. */
2025
+ vehicle: (vin: string, opts?: VehicleOptions) => Promise<Vehicle>;
2026
+ /** Compatibility entry for VIN callers. */
1823
2027
  vin: (vin: string, opts?: VinOptions) => Promise<Vin>;
1824
2028
  /** US NAICS 2022 definitions and hierarchy. */
1825
- naics: ((code: string, opts?: NaicsOptions) => Promise<Naics>) & {
1826
- search: (query: string, opts?: NaicsSearchOptions) => Promise<NaicsSearch>;
2029
+ industry: ((code: string, opts?: IndustryOptions) => Promise<Industry>) & {
2030
+ search: (query: string, opts?: IndustrySearchOptions) => Promise<IndustrySearch>;
2031
+ };
2032
+ /** Compatibility name for industry. */
2033
+ naics: ((code: string, opts?: IndustryOptions) => Promise<Industry>) & {
2034
+ search: (query: string, opts?: IndustrySearchOptions) => Promise<IndustrySearch>;
1827
2035
  };
1828
2036
  /** 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. */
1829
2037
  tariff: ((code: string, opts?: TariffOptions) => Promise<Tariff>) & {
@@ -1864,5 +2072,13 @@ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
1864
2072
  };
1865
2073
  };
1866
2074
  type ParseAPIClient = ReturnType<typeof parseAPI>;
2075
+ /** Existing NAICS options remain source compatible. */
2076
+ type NaicsOptions = IndustryOptions;
2077
+ type NaicsSearchOptions = IndustrySearchOptions;
2078
+ type IbanOptions = {
2079
+ country?: string;
2080
+ } & DeepOption & RequestOptions;
2081
+ type NpiOptions = LanguageOption & DeepOption & RequestOptions;
2082
+ type BinOptions = DeepOption & RequestOptions;
1867
2083
 
1868
- 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 ElevationLocations, 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 PostalLocality, 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 Stack, type StackOptions, type StackTechnology, 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 TimeLocation, type TimeLocationCandidate, type TimeLocationInput, type TimeOptions, type TimeResolution, type TimeResolutionAlternative, type TimeSeason, type TimeTransition, type TimeTransitionState, type TimeZoneEntry, type TimeZones, type TimeZonesOptions, 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 };
2084
+ export { type Address, type AddressOptions, type AddressSearch, type AddressSearchOptions, type AddressSuggestion, type Asn, type AsnOptions, type Bank, type BankChecks, type BankDeep, type BankDirectory, type BankIssue, type BankOptions, type BankRequirementField, type BankRequirements, type BankRequirementsOptions, type BankUsAch, type BankUsAchChecks, type BankUsAchInput, type Bin, type BinOptions, type Bloc, type BlocCountries, type BlocCountriesOptions, type BlocCountryItem, type BlocOptions, type Caller, type CallerOptions, type Card, type CardDeep, type CardOptions, 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 ElevationLocations, 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 Industry, type IndustryChild, type IndustryCorrection, type IndustryDeep, type IndustryExclusion, type IndustryMatch, type IndustryOptions, type IndustrySearch, type IndustrySearchItem, type IndustrySearchOptions, 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 PostalLocality, 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 Provider, type ProviderDeep, type ProviderEnrollment, type ProviderOptions, type ProviderSource, type ProviderSources, type ProviderTaxonomy, type RequestOptions, type Stack, type StackOptions, type StackTechnology, 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 TimeLocation, type TimeLocationCandidate, type TimeLocationInput, type TimeOptions, type TimeResolution, type TimeResolutionAlternative, type TimeSeason, type TimeTransition, type TimeTransitionState, type TimeZoneEntry, type TimeZones, type TimeZonesOptions, 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 Vehicle, type VehicleDeep, type VehicleOptions, type VehicleRecall, 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,5 @@
1
1
  // src/index.ts
2
- var VERSION = "1.7.0";
2
+ var VERSION = "1.8.0";
3
3
  var API_VERSION = "2.0.0";
4
4
  var DEFAULT_BASE_URL = "https://api.parseapi.com";
5
5
  var DEFAULT_TIMEOUT_MS = 1e4;
@@ -15,13 +15,16 @@ var ParseAPIError = class extends Error {
15
15
  docs;
16
16
  /** Send this if you contact support */
17
17
  requestId;
18
- constructor(status, code, message, docs, requestId) {
18
+ /** Original Retry-After response header, when supplied. */
19
+ retryAfter;
20
+ constructor(status, code, message, docs, requestId, retryAfter = null) {
19
21
  super(message);
20
22
  this.name = "ParseAPIError";
21
23
  this.status = status;
22
24
  this.code = code;
23
25
  this.docs = docs;
24
26
  this.requestId = requestId;
27
+ this.retryAfter = retryAfter;
25
28
  }
26
29
  };
27
30
  function tariffSelection(result, opts) {
@@ -66,16 +69,20 @@ function metered(path, query) {
66
69
  }
67
70
  function retryDelayMs(attempt, retryAfter) {
68
71
  if (retryAfter) {
69
- const seconds = Number(retryAfter);
70
- if (Number.isFinite(seconds) && seconds >= 0) {
71
- return Math.min(seconds * 1e3, RETRY_AFTER_CAP_MS);
72
+ const value = retryAfter.trim();
73
+ if (/^[0-9]+(?:\.[0-9]+)?$/.test(value)) {
74
+ const seconds = Number(value);
75
+ return seconds > RETRY_AFTER_CAP_MS / 1e3 ? null : seconds * 1e3;
72
76
  }
73
- if (Number.isNaN(seconds)) {
74
- const date = Date.parse(retryAfter);
75
- if (Number.isFinite(date)) return Math.min(Math.max(date - Date.now(), 0), RETRY_AFTER_CAP_MS);
77
+ if (/^[A-Za-z]{3,9},? /.test(value)) {
78
+ const date = Date.parse(value);
79
+ if (Number.isFinite(date)) {
80
+ const delay = Math.max(date - Date.now(), 0);
81
+ return delay > RETRY_AFTER_CAP_MS ? null : delay;
82
+ }
76
83
  }
77
84
  }
78
- return Math.random() * 250 * 2 ** attempt;
85
+ return Math.random() * Math.min(250 * 2 ** Math.min(attempt, 16), RETRY_AFTER_CAP_MS);
79
86
  }
80
87
  function parseAPI(apiKey, options = {}) {
81
88
  const key = apiKey || env("PARSEAPI_KEY");
@@ -108,7 +115,7 @@ function parseAPI(apiKey, options = {}) {
108
115
  const onAbort = () => controller.abort(signal.reason);
109
116
  signal?.addEventListener("abort", onAbort, { once: true });
110
117
  const timer = setTimeout(() => controller.abort(new DOMException("Request timed out", "TimeoutError")), attemptTimeout);
111
- let retryAfter = null;
118
+ let retryDelay;
112
119
  try {
113
120
  let res;
114
121
  try {
@@ -134,8 +141,8 @@ function parseAPI(apiKey, options = {}) {
134
141
  res = void 0;
135
142
  }
136
143
  }
137
- if (res && RETRY_STATUS.has(res.status) && attempt < retries) {
138
- retryAfter = res.headers.get("Retry-After");
144
+ if (res) retryDelay = retryDelayMs(attempt, res.headers.get("Retry-After"));
145
+ if (res && RETRY_STATUS.has(res.status) && attempt < retries && retryDelay !== null) {
139
146
  await res.body?.cancel().catch(() => {
140
147
  });
141
148
  } else if (res) {
@@ -152,14 +159,15 @@ function parseAPI(apiKey, options = {}) {
152
159
  typeof body2.code === "string" ? body2.code : "unknown_error",
153
160
  typeof body2.message === "string" ? body2.message : `Request failed with status ${res.status}`,
154
161
  typeof body2.docs === "string" ? body2.docs : null,
155
- typeof body2.request_id === "string" ? body2.request_id : null
162
+ typeof body2.request_id === "string" ? body2.request_id : null,
163
+ res.headers.get("Retry-After")
156
164
  );
157
165
  }
158
166
  } finally {
159
167
  clearTimeout(timer);
160
168
  signal?.removeEventListener("abort", onAbort);
161
169
  }
162
- await sleep(retryDelayMs(attempt, retryAfter), signal);
170
+ await sleep(retryDelay ?? retryDelayMs(attempt, null), signal);
163
171
  }
164
172
  }
165
173
  const enc = encodeURIComponent;
@@ -173,6 +181,12 @@ function parseAPI(apiKey, options = {}) {
173
181
  for (const [name, value2] of Object.entries(query)) url.searchParams.set(name, String(value2));
174
182
  return !numericJson && url.href.length <= 8e3 ? request("/elevation", query, void 0, opts) : request("/elevation", void 0, void 0, opts, { [selector]: coordinates, ...sampling });
175
183
  }
184
+ const industry = Object.assign(
185
+ (code, opts) => request(`/industry/${enc(code)}`, deepQuery(opts), void 0, opts),
186
+ {
187
+ search: (query, opts) => request("/industry", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
188
+ }
189
+ );
176
190
  return {
177
191
  /** Estimate task access, capacity and additional charges. Requires a secret key. Reserves no units or money and does not enforce the supplied budget. */
178
192
  preflight: (task, opts) => request("/preflight", void 0, void 0, opts, task),
@@ -258,8 +272,16 @@ function parseAPI(apiKey, options = {}) {
258
272
  from: opts?.from,
259
273
  ...deepQuery(opts)
260
274
  }, void 0, opts),
275
+ // Keep existing callers on their established HTTP contracts.
261
276
  iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
277
+ bin: (bin, opts) => request(`/bin/${enc(bin)}`, { deep: opts?.deep }, void 0, opts),
262
278
  npi: (npi, opts) => request(`/npi/${enc(npi)}`, deepQuery(opts), void 0, opts),
279
+ bank: (iban, opts) => request("/bank", void 0, void 0, opts, { iban, country: opts?.country, deep: opts?.deep }),
280
+ /** Check US routing/account syntax using POST. Does not verify ownership, existence or ACH eligibility. */
281
+ bankUsAch: (input, opts) => request("/bank", void 0, void 0, opts, { format: "us_ach", country: "US", routing: input.routing, account: input.account }),
282
+ /** Describe supported input fields and check scope; this does not establish country directory coverage. */
283
+ bankRequirements: (country, opts) => request("/bank/requirements", { country, format: opts?.format }, void 0, opts),
284
+ provider: (npi, opts) => request(`/provider/${enc(npi)}`, deepQuery(opts), void 0, opts),
263
285
  /** Parse a phone number and its formats. Pass country for national numbers when needed. Deep adds numbering-plan geography. */
264
286
  phone: (number, opts) => request(`/phone/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
265
287
  /** Request a metered carrier lookup. No automatic retries by default. */
@@ -274,8 +296,13 @@ function parseAPI(apiKey, options = {}) {
274
296
  domain: (domain, opts) => request(`/domain/${enc(domain)}`, deepQuery(opts), void 0, opts),
275
297
  asn: (asn, opts) => request(`/asn/${enc(asn)}`, void 0, void 0, opts),
276
298
  mac: (mac, opts) => request(`/mac/${enc(mac)}`, void 0, void 0, opts),
277
- /** Look up a 6-11 digit card prefix. Keep leading zeros in the input string. */
278
- bin: (bin, opts) => request(`/bin/${enc(bin)}`, { deep: opts?.deep }, void 0, opts),
299
+ /** Look up a 2-11 digit card prefix. Keep leading zeros in the input string. */
300
+ card: async (bin, opts) => {
301
+ if (typeof bin !== "string" || bin.length > 64 || !/^[0-9]{2,11}$/.test(bin.replace(/[ \t\r\n-]/g, ""))) {
302
+ throw new TypeError("parseAPI: Card requires a string containing 2 to 11 digits. Send a prefix only.");
303
+ }
304
+ return request(`/card/${enc(bin)}`, deepQuery(opts), void 0, opts);
305
+ },
279
306
  /** Parse a measurement or convert it to `to`. Without `to`, use its type's canonical unit. Invalid input is plain data with `valid: false`. */
280
307
  measure: Object.assign(
281
308
  (measure, opts) => request(`/measure/${enc(measure)}`, { to: opts?.to, locale: opts?.locale, system: opts?.system }, void 0, opts),
@@ -288,14 +315,14 @@ function parseAPI(apiKey, options = {}) {
288
315
  dns: (domain, opts) => request(`/dns/${enc(domain)}`, { type: opts?.type }, void 0, opts),
289
316
  mx: (domain, opts) => request(`/mx/${enc(domain)}`, void 0, void 0, opts),
290
317
  useragent: (ua, opts) => request("/useragent", deepQuery(opts), { "User-Agent": ua }, opts),
318
+ /** Identify a vehicle by VIN. Paid deep adds specifications and model-level recall campaigns. */
319
+ vehicle: (vin, opts) => request(`/vehicle/${enc(vin)}`, deepQuery(opts), void 0, opts),
320
+ /** Compatibility entry for VIN callers. */
291
321
  vin: (vin, opts) => request(`/vin/${enc(vin)}`, deepQuery(opts), void 0, opts),
292
322
  /** US NAICS 2022 definitions and hierarchy. */
293
- naics: Object.assign(
294
- (code, opts) => request(`/naics/${enc(code)}`, deepQuery(opts), void 0, opts),
295
- {
296
- search: (query, opts) => request("/naics", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
297
- }
298
- ),
323
+ industry,
324
+ /** Compatibility name for industry. */
325
+ naics: industry,
299
326
  /** 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. */
300
327
  tariff: Object.assign(
301
328
  (code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, edition: opts?.edition, date: opts?.date, ...deepQuery(opts) }, void 0, opts).then((result) => tariffSelection(result, opts)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parseapi/sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Official ParseAPI client for Node and TypeScript. One key, minimal JSON, fast.",
5
5
  "keywords": [
6
6
  "parseapi",