universal-parcel-scraper 0.1509.7-main.10559 → 0.1509.8
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.
|
@@ -1484,8 +1484,15 @@ function postnlUtcStampDates(payload) {
|
|
|
1484
1484
|
&& (POSTNL_CUSTOMS_STAMP.test(status) || POSTNL_ACCEPTANCE_STAMP.test(status)) ? [raw.date.slice(0, 19)] : [];
|
|
1485
1485
|
}));
|
|
1486
1486
|
}
|
|
1487
|
-
/**
|
|
1488
|
-
|
|
1487
|
+
/**
|
|
1488
|
+
* Whether a state is one of PostNL's UTC stamps, whose date is the instant: its customs stamps under any name or none,
|
|
1489
|
+
* and Cainiao's copy of one of the reply's UTC stamps (`postnlUtcStampDates`). A Chinese line that relays PostNL's
|
|
1490
|
+
* pre-declaration gives its UTC digits to the minute: read on the line's own Chinese clock, it came eight hours before
|
|
1491
|
+
* PostNL's own stamp of it.
|
|
1492
|
+
*/
|
|
1493
|
+
function postnlStampCopy(payload, name, date, status) {
|
|
1494
|
+
if (POSTNL_CUSTOMS_STAMP.test(status.trim()))
|
|
1495
|
+
return true;
|
|
1489
1496
|
return typeof name === 'string' && /^cainiao\b/i.test(name.trim()) && typeof date === 'string'
|
|
1490
1497
|
&& /T\d{2}:\d{2}:(?!00)\d{2}/.test(date) && postnlUtcStampDates(payload).has(date.slice(0, 19));
|
|
1491
1498
|
}
|
|
@@ -1495,7 +1502,9 @@ function carrierClock(payload, state, number, status = '', destination = null) {
|
|
|
1495
1502
|
const carrier = typeof name === 'string' ? carrierIdFromName(name) : undefined;
|
|
1496
1503
|
if (carrier === 'tnt' && /^\d{9}$/.test(number))
|
|
1497
1504
|
return null;
|
|
1498
|
-
|
|
1505
|
+
// PostNL's customs stamps, whose own feed states a real UTC instant to the fraction of a second (carriers/spring-gds):
|
|
1506
|
+
// read on Dutch time, the clearance came an hour before Cainiao's copy of it, stated +01:00.
|
|
1507
|
+
if (postnlStampCopy(payload, name, state.date, status))
|
|
1499
1508
|
return null;
|
|
1500
1509
|
if (typeof name === 'string' && ASENDIA_USA.test(name.trim()))
|
|
1501
1510
|
return null;
|
|
@@ -1516,14 +1525,10 @@ function carrierClock(payload, state, number, status = '', destination = null) {
|
|
|
1516
1525
|
// tracker dates its rows in China and Hong Kong at the same instants to the second.
|
|
1517
1526
|
if (carrier === 'shouwu')
|
|
1518
1527
|
return null;
|
|
1519
|
-
// PostNL's scans in Britain have their UTC instants
|
|
1520
|
-
// in another country are that country's wall clock, as in PostNL's own feed. In
|
|
1521
|
-
// clocks the city or region dates the scan.
|
|
1522
|
-
//
|
|
1523
|
-
// read on Dutch time, the clearance came an hour before Cainiao's copy of it, stated +01:00.
|
|
1524
|
-
if (carrier === 'spring-gds' && POSTNL_CUSTOMS_STAMP.test(status.trim()))
|
|
1525
|
-
return null;
|
|
1526
|
-
// And so do its acceptance and bagging stamps that keep their seconds: read on Dutch time, they came an hour
|
|
1528
|
+
// PostNL's scans in Britain have their UTC instants, as its customs stamps do (`postnlStampCopy`): FIC shows the same
|
|
1529
|
+
// scans on Dutch time. Its scans in another country are that country's wall clock, as in PostNL's own feed. In
|
|
1530
|
+
// countries with several clocks the city or region dates the scan.
|
|
1531
|
+
// Its acceptance and bagging stamps that keep their seconds have their UTC instants too: read on Dutch time, they came an hour
|
|
1527
1532
|
// before PostNL's own UTC stamps of them. Those dated to the minute are on the local clock.
|
|
1528
1533
|
if (carrier === 'spring-gds' && POSTNL_ACCEPTANCE_STAMP.test(status.trim())
|
|
1529
1534
|
&& /T\d{2}:\d{2}:(?!00)\d{2}/.test(typeof state.date === 'string' ? state.date : ''))
|
|
@@ -1866,7 +1871,9 @@ function readState(payload, raw, status, fallback, number, inNorthAmerica = fals
|
|
|
1866
1871
|
const name = stateCarrierName(payload, raw);
|
|
1867
1872
|
const location = scanLocation(name, raw.location);
|
|
1868
1873
|
const offset = ownOffset(name, raw.date, location);
|
|
1869
|
-
|
|
1874
|
+
// PostNL's UTC stamp is its instant whoever relays it, or nobody does (`postnlStampCopy`).
|
|
1875
|
+
const stamp = postnlStampCopy(payload, name, raw.date, status);
|
|
1876
|
+
const wallClock = WALL_CLOCKS.has(nameKey(name)) && !offset && !uspsLabelRow(name, status) && !stamp;
|
|
1870
1877
|
const partner = royalMailPartnerRelay(payload, name, raw.date, raw.location);
|
|
1871
1878
|
const relay = polandPostRelay(name, raw.date, location, number, destination) ?? laPosteLetterRelay(name, raw.date, location, number)
|
|
1872
1879
|
?? correosDeMexicoRelay(name, raw.date, location, origin, destination) ?? partner;
|
|
@@ -1907,8 +1914,8 @@ function readState(payload, raw, status, fallback, number, inNorthAmerica = fals
|
|
|
1907
1914
|
fallback: wallClock || office ? fitsPlace(fallback, location) : null, known: known?.zone ?? null, arrival: known?.country ?? null,
|
|
1908
1915
|
// With no zone, a scan whose label nothing vouches for keeps its wall clock, as does one on a clock its place cannot
|
|
1909
1916
|
// tell (`siteZone`) or at a port of entry no row names (`knownClock`).
|
|
1910
|
-
wallOnly: unplacedWall || sited === null || destinationCode || unknownNetwork(name) || localClockBrand(name) || militaryPostOffice(location)
|
|
1911
|
-
|| known?.port === true };
|
|
1917
|
+
wallOnly: !stamp && (unplacedWall || sited === null || destinationCode || unknownNetwork(name) || localClockBrand(name) || militaryPostOffice(location)
|
|
1918
|
+
|| known?.port === true) };
|
|
1912
1919
|
}
|
|
1913
1920
|
/**
|
|
1914
1921
|
* How a scan's zone was chosen, as a carrier's deduced clock says it
|
|
@@ -424,6 +424,13 @@ function sourceEventStage(description, includeBroadMovement = true) {
|
|
|
424
424
|
if (/out for delivery/i.test(description)
|
|
425
425
|
&& !/(?:once|when|as soon as) (?:the |your )?(?:shipment|parcel|package|item) is out for delivery|\bout for delivery soon\b/i.test(description))
|
|
426
426
|
return 'out_for_delivery';
|
|
427
|
+
// PostNL's customs stamps, as providers relay them, read as the carriers that carry PostNL's feed read them (Spring
|
|
428
|
+
// GDS, SpeedPAK, Correos): the pre-declaration is the item's data filed with customs before PostNL has it, and the
|
|
429
|
+
// duties confirmed come with its clearance.
|
|
430
|
+
if (/^pre-declaration of the item has been received by customs[.!]?$/i.test(description))
|
|
431
|
+
return 'registered';
|
|
432
|
+
if (/^duties and taxes confirmed by customs[.!]?$/i.test(description))
|
|
433
|
+
return 'in_transit';
|
|
427
434
|
// Customs wording outranks a provider's own stage. The shared rules tell a
|
|
428
435
|
// release or a completed clearance, and a refusal, from customs still at work.
|
|
429
436
|
if (/customs|clearance/i.test(description)) {
|
package/dist/server/openapi.json
CHANGED
package/package.json
CHANGED