universal-parcel-scraper 0.784.2-main.4207 → 0.784.4-main.4212
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/ctt/clock.d.ts +3 -2
- package/dist/carriers/ctt/clock.js +6 -5
- package/dist/carriers/seur/parser.js +7 -4
- package/dist/carriers/seur/status.js +2 -1
- package/dist/carriers/seur/statuses.json +9 -0
- package/dist/providers/shared/result.js +4 -1
- package/dist/server/openapi.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ the command line's `track --source ParcelsApp` does the same.
|
|
|
161
161
|
<!-- GENERATED:stages -->
|
|
162
162
|
<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">
|
|
163
163
|
|
|
164
|
-
The carrier folders record 17,
|
|
164
|
+
The carrier folders record 17,485 such statuses, each filed under one stage.
|
|
165
165
|
<!-- /GENERATED:stages -->
|
|
166
166
|
|
|
167
167
|
Wording nobody recorded yet goes through a classifier that reads seven European languages.
|
|
@@ -9,7 +9,8 @@ export declare function isCttExpressAgency(location: string): boolean;
|
|
|
9
9
|
/**
|
|
10
10
|
* The clock a CTT scan's location itself names: the country of the office of
|
|
11
11
|
* exchange leading it, when that is Portugal or one of `countries` (the
|
|
12
|
-
* parcel's), Madrid's for Madrid
|
|
13
|
-
* Null when the location does not say.
|
|
12
|
+
* parcel's), Madrid's for Madrid or one of CTT Express's agencies, else
|
|
13
|
+
* Portugal's for one of CTT's own sites. Null when the location does not say.
|
|
14
|
+
* Providers' copies of CTT's scans keep CTT's digits, so they take the same clocks.
|
|
14
15
|
*/
|
|
15
16
|
export declare function cttSiteZone(location: string, countries: readonly (string | null)[]): string | null;
|
|
@@ -11,8 +11,8 @@ import { countryTimeZone, regionHasTown } from '../../core/time/index.js';
|
|
|
11
11
|
*/
|
|
12
12
|
/** A UPU office of exchange leading a location: "PTLISA - (OUTRO) LISBOA". */
|
|
13
13
|
const OFFICE = /^([A-Z]{2})[A-Z0-9]{4}(?=\s+-\s)/;
|
|
14
|
-
/** CTT's own sites: a sorting
|
|
15
|
-
const CTT_SITE = /\b(?:CTT|CDP|centro operacional|centro de distribui[cç][aã]o)\b/i;
|
|
14
|
+
/** CTT's own sites: a sorting centre, also written C.O., a delivery centre (CDP), a shop or a postal point. */
|
|
15
|
+
const CTT_SITE = /\b(?:CTT|CDP|centro operacional|centro de distribui[cç][aã]o)\b|\bC\.O\.(?!\S)/i;
|
|
16
16
|
/** A Portuguese postcode; 9500 to 9999 are the Azores. */
|
|
17
17
|
const POSTCODE = /(?<!\d)(\d{4})(?:-\d{3})?(?!\d)/;
|
|
18
18
|
/**
|
|
@@ -49,15 +49,16 @@ export function isCttExpressAgency(location) {
|
|
|
49
49
|
/**
|
|
50
50
|
* The clock a CTT scan's location itself names: the country of the office of
|
|
51
51
|
* exchange leading it, when that is Portugal or one of `countries` (the
|
|
52
|
-
* parcel's), Madrid's for Madrid
|
|
53
|
-
* Null when the location does not say.
|
|
52
|
+
* parcel's), Madrid's for Madrid or one of CTT Express's agencies, else
|
|
53
|
+
* Portugal's for one of CTT's own sites. Null when the location does not say.
|
|
54
|
+
* Providers' copies of CTT's scans keep CTT's digits, so they take the same clocks.
|
|
54
55
|
*/
|
|
55
56
|
export function cttSiteZone(location, countries) {
|
|
56
57
|
const office = OFFICE.exec(location)?.[1];
|
|
57
58
|
if (office === 'PT' || (office && countries.includes(office))) {
|
|
58
59
|
return office === 'PT' ? portugalZone(location) : countryTimeZone(office);
|
|
59
60
|
}
|
|
60
|
-
if (MADRID.test(location.trim()))
|
|
61
|
+
if (MADRID.test(location.trim()) || isCttExpressAgency(location))
|
|
61
62
|
return 'Europe/Madrid';
|
|
62
63
|
return CTT_SITE.test(location) ? portugalZone(location) : null;
|
|
63
64
|
}
|
|
@@ -85,19 +85,22 @@ export function parseSeur(value, raw) {
|
|
|
85
85
|
provider_group: group, provider_code: code, ...(mapped ? { stage: mapped.stage } : {}), ...scanTime(row.fecha) };
|
|
86
86
|
});
|
|
87
87
|
const delay = (event) => isSeurDelay(event.provider_code, String(event.provider_group), String(event.provider_status));
|
|
88
|
-
// Oldest first: a delay notice keeps the stage of the scan before it.
|
|
88
|
+
// Oldest first: a delay notice keeps the stage of the scan before it. SEUR delays a shipment on
|
|
89
|
+
// its way, so a notice with no stage before it, which may be all SEUR lists, is in transit.
|
|
89
90
|
let previous;
|
|
90
91
|
for (const event of [...events].reverse()) {
|
|
91
92
|
if (!delay(event))
|
|
92
93
|
previous = event.stage ?? previous;
|
|
93
|
-
else
|
|
94
|
-
Object.assign(event, { stage: previous, stage_source: 'none' });
|
|
94
|
+
else
|
|
95
|
+
Object.assign(event, { stage: previous ?? 'in_transit', stage_source: 'none' });
|
|
95
96
|
}
|
|
96
97
|
// The official widget consumes situaciones[0]; unresolved clocks retain that position.
|
|
97
98
|
// Its status is the newest scan's other than a delay notice.
|
|
98
99
|
const latest = events[0];
|
|
99
100
|
const current = events.find((event) => !delay(event));
|
|
100
|
-
const mapped = current
|
|
101
|
+
const mapped = current
|
|
102
|
+
? classifySeurStatus(current.provider_code, String(current.provider_group), String(current.provider_status))
|
|
103
|
+
: { status: 'in_transit', stage: 'in_transit' };
|
|
101
104
|
const weight = value.peso;
|
|
102
105
|
return { status: mapped?.status ?? 'unknown', ...(mapped ? { current_stage: mapped.stage } : {}),
|
|
103
106
|
last_status_text: latest.description, last_update: latest.time ?? null,
|
|
@@ -12,6 +12,7 @@ const observed = {
|
|
|
12
12
|
LI300: { group: 'EN DEMORA', wording: 'EL ENVÍO HA SUFRIDO UN RETRASO Y ES POSIBLE QUE SE DEMORE LA ENTREGA. DISCULPA LAS MOLESTIAS.', mapped: null },
|
|
13
13
|
LI582: { group: 'EN DEMORA', wording: 'EL ENVÍO HA SUFRIDO UN RETRASO PROVOCANDO UNA POSIBLE DEMORA EN LA ENTREGA. DISCULPA LAS MOLESTIAS.', mapped: null },
|
|
14
14
|
LI557: { group: 'EN DEMORA', wording: 'EL ENVÍO HA SUFRIDO UN RETRASO PROVOCANDO UNA POSIBLE DEMORA EN LA ENTREGA. DISCULPA LAS MOLESTIAS.', mapped: null },
|
|
15
|
+
LI587: { group: 'EN DEMORA', wording: 'EL ENVÍO HA SUFRIDO UN RETRASO PROVOCANDO UNA POSIBLE DEMORA EN LA ENTREGA. DISCULPA LAS MOLESTIAS', mapped: null },
|
|
15
16
|
// Recorded after the day's delivery round, which starts again the next day.
|
|
16
17
|
LI521: { group: 'EN INCIDENCIA', wording: 'EL ENVÍO NO SE HA ENTREGADO PORQUE LA DIRECCIÓN DE ENTREGA ESTÁ INCOMPLETA O ERRÓNEA.', mapped: { status: 'exception', stage: 'failed_attempt' } },
|
|
17
18
|
LI523: { group: 'EN INCIDENCIA', wording: 'EL ENVÍO NO SE HA ENTREGADO POR AUSENCIA O CIERRE. SE PUEDE REPROGRAMAR UNA NUEVA ENTREGA.', mapped: { status: 'exception', stage: 'failed_attempt' } },
|
|
@@ -57,5 +58,5 @@ export function seurStatusGroup(code) {
|
|
|
57
58
|
/** What the map says about one scan, read with the group SEUR sends with its code. */
|
|
58
59
|
export const statusMap = {
|
|
59
60
|
stage: (code, wording) => (code ? classifySeurStatus(code, seurStatusGroup(code) ?? '', wording)?.stage : undefined),
|
|
60
|
-
gaps: ['LI300', 'LI582', 'LI557'].map((code) => ({ code, note: 'A delay notice, not a movement: the parcel keeps the stage it had.' })),
|
|
61
|
+
gaps: ['LI300', 'LI582', 'LI557', 'LI587'].map((code) => ({ code, note: 'A delay notice, not a movement: the parcel keeps the stage it had.' })),
|
|
61
62
|
};
|
|
@@ -119,6 +119,15 @@
|
|
|
119
119
|
"firstSeen": "2026-10-22",
|
|
120
120
|
"note": "LI582's wording under another code, read like it. The parcel seen with it moved on from the origin's receipt to an agreed delivery day."
|
|
121
121
|
},
|
|
122
|
+
{
|
|
123
|
+
"code": "LI587",
|
|
124
|
+
"wording": "EL ENVÍO HA SUFRIDO UN RETRASO PROVOCANDO UNA POSIBLE DEMORA EN LA ENTREGA. DISCULPA LAS MOLESTIAS",
|
|
125
|
+
"language": "es",
|
|
126
|
+
"confirmedBy": "live",
|
|
127
|
+
"unmapped": true,
|
|
128
|
+
"firstSeen": "2026-10-28",
|
|
129
|
+
"note": "LI582's wording without its last full stop, under another code, read like it. The parcel seen with it listed it alone."
|
|
130
|
+
},
|
|
122
131
|
{
|
|
123
132
|
"code": "LI511",
|
|
124
133
|
"wording": "EL ENVÍO ESTÁ PENDIENTE DE LLEGAR A DESTINO. EN CUANTO SE RECIBA, ACTUALIZAREMOS LA SITUACIÓN.",
|
|
@@ -540,10 +540,13 @@ const LOCAL_WALL_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;
|
|
|
540
540
|
// A flight written before it leaves is still to come: no scan, as the lines' own trackers drop it.
|
|
541
541
|
// 17FEIA's estimated departure, and the flight DHLink, Intel-Valley and Mayi Yinfu book.
|
|
542
542
|
const flightToCome = (label) => FLIGHT_ESTIMATE.test(label) || DHLINK_FLIGHT.test(label) || intelValleyFlight(label) || MAYIYINFU_FLIGHT.test(label);
|
|
543
|
+
// A time or date in brackets with no words, as 17TRACK relays a Juxi Express row between the flight
|
|
544
|
+
// being arranged at the airport and the departure: it says nothing happened, so it is no scan.
|
|
545
|
+
const BARE_TIME = /^[((]\s*\d{1,2}\s*[::]\s*\d{1,2}\s*[))]$/;
|
|
543
546
|
function describe(description, stage) {
|
|
544
547
|
// A copy of SunYou's departure drops the last-mile number, as SunYou's own result does.
|
|
545
548
|
const label = sunYouWording(relayedNotice(text(description)).replace(CLEARANCE_STATUS, ''));
|
|
546
|
-
if (!label || isNotice(label) || flightToCome(label))
|
|
549
|
+
if (!label || isNotice(label) || flightToCome(label) || BARE_TIME.test(label))
|
|
547
550
|
return null;
|
|
548
551
|
const declared = typeof stage === 'string' && Object.hasOwn(STAGES, stage) ? STAGES[stage] : undefined;
|
|
549
552
|
// Established source semantics (e.g. handoff/negation) remain first. A real
|
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.784.
|
|
3
|
+
"version": "0.784.4-main.4212",
|
|
4
4
|
"description": "Self-hosted parcel tracking: carrier detection, dedicated scrapers and optional universal providers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|