universal-parcel-scraper 0.1315.4 → 0.1315.8-main.8876
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 +1 -1
- package/dist/carriers/fan-courier/adapter.js +29 -2
- package/dist/carriers/lingdong/statuses.json +1 -0
- package/dist/carriers/shouwu/status.js +2 -2
- package/dist/carriers/shouwu/statuses.json +2 -1
- package/dist/providers/shared/result.js +4 -0
- package/dist/providers/status.js +4 -0
- package/dist/server/openapi.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ the command line's `track --source ParcelsApp` does the same.
|
|
|
164
164
|
<!-- GENERATED:stages -->
|
|
165
165
|
<img src="docs/assets/stages.svg" alt="DHL: Die Sendung wurde in das Zustellfahrzeug geladen.; Mondial Relay: En cours de livraison; Correios Brazil: Objeto saiu para entrega ao destinatário; Correos Express: EN REPARTO; Yamato Transport: 配達中; La Poste / Colissimo: DISTOU. All are filed under out_for_delivery." width="760">
|
|
166
166
|
|
|
167
|
-
The carrier folders record 24,
|
|
167
|
+
The carrier folders record 24,425 such statuses, each filed under one stage.
|
|
168
168
|
<!-- /GENERATED:stages -->
|
|
169
169
|
|
|
170
170
|
Wording nobody recorded yet goes through a classifier that reads seven European languages.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { accepted, recognizeFromLookup } from '../../core/adapter/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { returnedTrackingNumber } from '../../core/detection/returned.js';
|
|
3
|
+
import { ChallengeError, IndeterminateError, NoHistoryError, SchemaError } from '../../core/errors/index.js';
|
|
3
4
|
import { runSteps } from '../../core/runner/index.js';
|
|
4
5
|
import { NOOP_RECORDER } from '../../core/telemetry/index.js';
|
|
5
6
|
import { clean, decodeText, fetchBounded, parseJsonBytes, userAgentOf } from '../../core/transport/index.js';
|
|
@@ -21,6 +22,24 @@ function rejection(bytes) {
|
|
|
21
22
|
const message = isRecord(payload) ? clean(payload.message, 120).replace(/\d{6,}/g, '#') : '';
|
|
22
23
|
return message ? `: ${message}` : '';
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether a 404 is FAN's "The AWB has been registered by sender": the sender's label, before FAN has the
|
|
27
|
+
* parcel. A reply naming another AWB in `content` is not that answer for this one.
|
|
28
|
+
*/
|
|
29
|
+
function registeredBySender(bytes, number) {
|
|
30
|
+
let payload;
|
|
31
|
+
try {
|
|
32
|
+
payload = parseJsonBytes(bytes.subarray(0, 4_096), PROVIDER);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!isRecord(payload) || typeof payload.message !== 'string')
|
|
38
|
+
return false;
|
|
39
|
+
if (payload.content !== undefined && payload.content !== null && returnedTrackingNumber(payload.content, true) !== number)
|
|
40
|
+
return false;
|
|
41
|
+
return payload.message.trim().replace(/\.$/, '').toLowerCase() === 'the awb has been registered by sender';
|
|
42
|
+
}
|
|
24
43
|
export class FanCourierTracker {
|
|
25
44
|
options;
|
|
26
45
|
constructor(options = {}) {
|
|
@@ -39,6 +58,9 @@ export class FanCourierTracker {
|
|
|
39
58
|
allowHttpStatuses: [404, 422], fetcher: this.options.fetcher });
|
|
40
59
|
// The number was checked before the request: a rejection or a missing page says nothing about the parcel.
|
|
41
60
|
// The tracking page shows the message FAN sends with it, which the diagnostics keep, without long digit runs.
|
|
61
|
+
if (response.status === 404 && registeredBySender(bytes, number)) {
|
|
62
|
+
throw new NoHistoryError(PROVIDER, 'FAN Courier lists the AWB as registered by its sender, before it has the parcel', { reason: 'listed' });
|
|
63
|
+
}
|
|
42
64
|
if (response.status !== 200) {
|
|
43
65
|
throw new IndeterminateError(PROVIDER, `FAN Courier tracking is unavailable (HTTP ${response.status}${rejection(bytes)})`);
|
|
44
66
|
}
|
|
@@ -62,5 +84,10 @@ export class FanCourierTracker {
|
|
|
62
84
|
export const adapter = environment => {
|
|
63
85
|
const tracker = new FanCourierTracker({ fetcher: environment.fetcher, recorder: environment.recorder, userAgent: environment.userAgent });
|
|
64
86
|
return { id: 'fan-courier', recordsSteps: true, steps: ['direct'], track: (input, context) => tracker.fetch(input.number, context),
|
|
65
|
-
|
|
87
|
+
// An AWB its sender registered is FAN's own number, known before the parcel's first scan.
|
|
88
|
+
recognize: (number, context) => recognizeFromLookup(() => tracker.fetch(number, context), () => accepted(() => normalizeFanCourierNumber(number))).catch((error) => {
|
|
89
|
+
if (error instanceof NoHistoryError && error.reason === 'listed')
|
|
90
|
+
return { known: true, lastActivityAt: null };
|
|
91
|
+
throw error;
|
|
92
|
+
}) };
|
|
66
93
|
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
{"wording": "Shipment information received", "language": "en", "stage": "registered", "confirmedBy": "live", "firstSeen": "2026-11-14", "note": "The order's data arriving, its first row, seconds before the delivery partner's pre-advice."},
|
|
5
5
|
{"wording": "Shipping Label Created", "language": "en", "stage": "registered", "confirmedBy": "live", "firstSeen": "2026-11-14", "note": "The label made for the order, hours before the warehouse's first scan."},
|
|
6
6
|
{"wording": "Order information has been transmitted to DPD.", "language": "en", "stage": "registered", "confirmedBy": "live", "firstSeen": "2026-11-22", "note": "The order's data handed to DPD, the delivery partner, as the first row, days before the warehouse's first scan."},
|
|
7
|
+
{"wording": "Your package is being prepared by the sender and will be handed over to us soon", "language": "en", "stage": "registered", "confirmedBy": "live", "firstSeen": "2026-11-23", "note": "The order's data, its first row, hours before the warehouse's first scan: the sender still has the parcel."},
|
|
7
8
|
{"code": "ARRIVAL", "wording": "Shipment arrived at facility", "language": "en", "stage": "accepted", "confirmedBy": "live", "note": "The first scan in Lingdong's hands, at its Shenzhen warehouse."},
|
|
8
9
|
{"code": "SHIPMENT", "wording": "Shipment departed from facility", "language": "en", "stage": "in_transit", "confirmedBy": "live"},
|
|
9
10
|
{"wording": "预计…航班/Flight scheduled for …", "language": "zh", "stage": "in_transit", "confirmedBy": "live", "note": "Waiting for the flight it is booked on, after leaving the warehouse; the flight's day, month.day and in English, is read as an ellipsis."},
|
|
@@ -107,8 +107,8 @@ export function shouwuStage(wording) {
|
|
|
107
107
|
/** What the map says about a parcel's status, by its code, or about a scan, by its wording. */
|
|
108
108
|
export const statusMap = {
|
|
109
109
|
stage: (code, wording) => (code ? CODES.get(code) : FLIGHT_BOOKED.test(wording) ? undefined : mappedStage(wording)),
|
|
110
|
-
// The last mile's rows after its failed delivery, minutes apart, while its station keeps the parcel.
|
|
111
|
-
gaps: ['stationed shipment', 'stationed located'].map((wording) => ({ wording,
|
|
110
|
+
// The last mile's rows after its failed delivery, minutes apart, while its station keeps the parcel, in English or Spanish.
|
|
111
|
+
gaps: ['stationed shipment', 'stationed located', 'envío estacionado', 'estacionado ubicado'].map((wording) => ({ wording,
|
|
112
112
|
note: "The last mile's station keeping the parcel after a failed delivery: it says neither that the parcel waits for the recipient to collect nor that another round follows, so it names no stage." })),
|
|
113
113
|
gapNote: (_code, wording) => (FLIGHT_BOOKED.test(wording)
|
|
114
114
|
? 'The flight booked for the parcel, before it flies: a forecast, so the parcel keeps the stage of the scan before it.'
|
|
@@ -1368,6 +1368,7 @@
|
|
|
1368
1368
|
{"wording": "Votre envoi est en cours de traitement sur le site de tri local.", "language": "fr", "stage": "in_transit", "confirmedBy": "live", "note": "La Poste's sort at the local sorting site, which Shouwu gives after the country's code and before its Chinese label."},
|
|
1369
1369
|
{"wording": "Votre envoi est sur son site de distribution. Nous le préparons pour le mettre en livraison.", "language": "fr", "stage": "out_for_delivery", "confirmedBy": "live", "note": "La Poste's sort into the delivery round, as Colissimo's map reads it; relayed like the sort above."},
|
|
1370
1370
|
{"wording": "Votre envoi a été distribué dans la boîte à lettres.", "language": "fr", "stage": "delivered", "confirmedBy": "live", "note": "Delivered to the letterbox; relayed like the sort above."},
|
|
1371
|
-
{"wording": "Arrived at pick-up point. Package available for collection.", "language": "en", "stage": "ready_for_pickup", "confirmedBy": "live", "note": "The last mile can append its own note after a comma (\"Carrier note: …\"), which does not change the stage."}
|
|
1371
|
+
{"wording": "Arrived at pick-up point. Package available for collection.", "language": "en", "stage": "ready_for_pickup", "confirmedBy": "live", "note": "The last mile can append its own note after a comma (\"Carrier note: …\"), which does not change the stage."},
|
|
1372
|
+
{"wording": "Reparto fallido", "language": "es", "stage": "failed_attempt", "confirmedBy": "live", "firstSeen": "2026-11-23", "note": "The Spanish last mile's failed round, between two rounds; its station keeping the parcel follows minutes later (Envío estacionado, Estacionado ubicado)."}
|
|
1372
1373
|
]
|
|
1373
1374
|
}
|
|
@@ -248,6 +248,10 @@ function sourceEventStage(description, includeBroadMovement = true) {
|
|
|
248
248
|
// A sender's parcel left at a pick-up point for a courier to collect: an acceptance, not a parcel awaiting its recipient.
|
|
249
249
|
if (/^the (?:parcel|package) has been delivered to the pick-?up point\. a courier will pick it up\b/i.test(description))
|
|
250
250
|
return 'accepted';
|
|
251
|
+
// An airline's unit load device broken down at the destination airport, the parcels awaiting the forwarder there, not
|
|
252
|
+
// their recipient, as ParcelsApp relays it with a non-breaking hyphen: "ULD breakdown completed, awaiting pick‑up in" a place.
|
|
253
|
+
if (/^uld breakdown completed, awaiting pick[-\u2010\u2011]?up in [^,]{1,40}$/iu.test(description))
|
|
254
|
+
return 'in_transit';
|
|
251
255
|
// myBRT's progress bar, as ParcelsApp relays it: the shipment handed to BRT, which BRT's own page calls its collection
|
|
252
256
|
// (RITIRATA). "Consegnata" names the hand-over to BRT, not the delivery.
|
|
253
257
|
if (/^spedizione consegnata a brt[.!]?$/i.test(description))
|
package/dist/providers/status.js
CHANGED
|
@@ -156,6 +156,10 @@ export const statusMap = {
|
|
|
156
156
|
if (/^package research case closed(?:, [^,]{1,60}){0,2}$/.test(wording)) {
|
|
157
157
|
return "USPS's closing of a customer's missing-mail search, as ParcelsApp relays it with a place: not a scan, so it keeps the stage the parcel already had.";
|
|
158
158
|
}
|
|
159
|
+
// A delivery booked for a date, as ParcelsApp relays it with the date after "Info:".
|
|
160
|
+
if (/^information - booking \(scheduled delivery date\)\. info: ?\S.{0,80}$/.test(wording)) {
|
|
161
|
+
return 'A delivery booked for a date, as ParcelsApp relays it: a booking, not a scan, so it keeps the stage the parcel already had.';
|
|
162
|
+
}
|
|
159
163
|
// Rows recorded before the providers left them out.
|
|
160
164
|
return relayedRowLeftOut(wording)
|
|
161
165
|
? 'A notice, a flight or schedule still to come, a bare time or a label without words, which the providers leave out of a history: not a scan, so it keeps the stage the parcel already had.'
|
package/dist/server/openapi.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "universal-parcel-scraper",
|
|
3
|
-
"version": "0.1315.
|
|
3
|
+
"version": "0.1315.8-main.8876",
|
|
4
4
|
"description": "Self-hosted parcel tracking: carrier detection, dedicated scrapers and optional universal providers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "PolyForm-Noncommercial-1.0.0",
|