universal-parcel-scraper 0.556.0-main.2575 → 0.557.0-main.2585
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/data/detection-golden.json +33 -0
- package/dist/browser/scraper.js +1 -1
- package/dist/carriers/japan-post/numbers.json +19 -0
- package/dist/carriers/mrw/parser.js +15 -8
- package/dist/carriers/seur/numbers.json +34 -0
- package/dist/carriers/sf-express/identity.d.ts +2 -0
- package/dist/carriers/sf-express/identity.js +6 -0
- package/dist/carriers/sf-express/parser.js +1 -1
- package/dist/carriers/sf-express/status.d.ts +2 -2
- package/dist/carriers/sf-express/status.js +11 -4
- package/dist/carriers/sf-express/statuses.json +18 -0
- package/dist/core/catalog/eventIdentity.js +2 -1
- package/dist/core/detection/valid.js +4 -3
- package/dist/server/openapi.json +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ createTracker({ providers: ['ParcelsApp', 'Ship24', '17TRACK', 'Postal Ninja', '
|
|
|
155
155
|
<!-- GENERATED:stages -->
|
|
156
156
|
<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">
|
|
157
157
|
|
|
158
|
-
The carrier folders record 16,
|
|
158
|
+
The carrier folders record 16,081 such statuses, each filed under one stage.
|
|
159
159
|
<!-- /GENERATED:stages -->
|
|
160
160
|
|
|
161
161
|
Wording nobody recorded yet goes through a classifier that reads seven European languages.
|
|
@@ -39780,6 +39780,31 @@
|
|
|
39780
39780
|
"confidence": "none",
|
|
39781
39781
|
"candidates": []
|
|
39782
39782
|
},
|
|
39783
|
+
{
|
|
39784
|
+
"input": "48285234834793",
|
|
39785
|
+
"carrier": "unknown",
|
|
39786
|
+
"confidence": "low",
|
|
39787
|
+
"candidates": [
|
|
39788
|
+
"dpd",
|
|
39789
|
+
"ciblex",
|
|
39790
|
+
"hermes-de",
|
|
39791
|
+
"seur",
|
|
39792
|
+
"brt",
|
|
39793
|
+
"delhivery",
|
|
39794
|
+
"dhl-ecommerce-uk",
|
|
39795
|
+
"dpd-be",
|
|
39796
|
+
"dpd-de",
|
|
39797
|
+
"dpd-nl",
|
|
39798
|
+
"dpd-uk"
|
|
39799
|
+
],
|
|
39800
|
+
"asked": [
|
|
39801
|
+
"hermes-de",
|
|
39802
|
+
"dpd-be",
|
|
39803
|
+
"dpd",
|
|
39804
|
+
"dpd-nl",
|
|
39805
|
+
"dpd-de"
|
|
39806
|
+
]
|
|
39807
|
+
},
|
|
39783
39808
|
{
|
|
39784
39809
|
"input": "483151203868516",
|
|
39785
39810
|
"carrier": "unknown",
|
|
@@ -77396,6 +77421,14 @@
|
|
|
77396
77421
|
"japan-post"
|
|
77397
77422
|
]
|
|
77398
77423
|
},
|
|
77424
|
+
{
|
|
77425
|
+
"input": "LP107777790JP",
|
|
77426
|
+
"carrier": "japan-post",
|
|
77427
|
+
"confidence": "high",
|
|
77428
|
+
"candidates": [
|
|
77429
|
+
"japan-post"
|
|
77430
|
+
]
|
|
77431
|
+
},
|
|
77399
77432
|
{
|
|
77400
77433
|
"input": "LP157079155HK",
|
|
77401
77434
|
"carrier": "hongkong-post",
|
package/dist/browser/scraper.js
CHANGED
|
@@ -25019,7 +25019,7 @@ function on(e) {
|
|
|
25019
25019
|
//#endregion
|
|
25020
25020
|
//#region core/detection/valid.ts
|
|
25021
25021
|
function sn(e) {
|
|
25022
|
-
return e.length >= 4 && e.length <= 40 && (/^[A-Z0-9]
|
|
25022
|
+
return e.length >= 4 && e.length <= 40 && (/^[A-Z0-9]+(?:_[A-Z0-9]+)?$/.test(e) || /^\d{4}\/\d{8}$/.test(e));
|
|
25023
25023
|
}
|
|
25024
25024
|
function cn(e) {
|
|
25025
25025
|
let t = n(e);
|
|
@@ -958,6 +958,25 @@
|
|
|
958
958
|
"confidence": "high"
|
|
959
959
|
},
|
|
960
960
|
"note": "A Japan Post tracking link archived by the Wayback Machine. Japan Post's tracker returns its international history."
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
"number": "LP107777790JP",
|
|
964
|
+
"role": "shipment",
|
|
965
|
+
"evidence": "public_shipment_report",
|
|
966
|
+
"source": {
|
|
967
|
+
"url": "https://web.archive.org/web/20261005062200/https://trackings.post.japanpost.jp/services/srv/search/direct?locale=en&reqCodeNo1=LP107777790JP",
|
|
968
|
+
"date": "2026-10-05",
|
|
969
|
+
"dateKind": "capture",
|
|
970
|
+
"access": "full_page"
|
|
971
|
+
},
|
|
972
|
+
"context": {
|
|
973
|
+
"assessment": "confirmed"
|
|
974
|
+
},
|
|
975
|
+
"expect": {
|
|
976
|
+
"carrier": "japan-post",
|
|
977
|
+
"confidence": "high"
|
|
978
|
+
},
|
|
979
|
+
"note": "A Japan Post tracking link archived by the Wayback Machine. Japan Post's tracker returns its international history."
|
|
961
980
|
}
|
|
962
981
|
]
|
|
963
982
|
}
|
|
@@ -96,15 +96,15 @@ function officeLabel(value) {
|
|
|
96
96
|
* Ceuta's and Melilla's offices among them, 052 for Gibraltar and 060 for
|
|
97
97
|
* Andorra, all on Madrid's clock. The Canary Islands' 049 and 050 and
|
|
98
98
|
* Portugal's 070 to 089 keep clocks of their own, and nothing shows whether
|
|
99
|
-
* their rows are written on the office's clock or on Madrid's;
|
|
99
|
+
* their rows are written on the office's clock or on Madrid's; pickup points'
|
|
100
100
|
* codes name no province. Those, and an office named for a town of the Canary
|
|
101
101
|
* Islands, have none.
|
|
102
102
|
*/
|
|
103
|
-
function officeZone(location) {
|
|
104
|
-
const office = /^(\d{3})\d{2}\s+(.+?)(?: \([\p{L} ]+\))?$/u.exec(location);
|
|
105
|
-
if (!office || regionHasTown('ES-CN', office[
|
|
103
|
+
function officeZone(location, points) {
|
|
104
|
+
const office = /^((\d{3})\d{2})\s+(.+?)(?: \([\p{L} ]+\))?$/u.exec(location);
|
|
105
|
+
if (!office || points.has(office[1]) || regionHasTown('ES-CN', office[3]))
|
|
106
106
|
return null;
|
|
107
|
-
const province = Number(office[
|
|
107
|
+
const province = Number(office[2]);
|
|
108
108
|
if (province >= 1 && province <= 48)
|
|
109
109
|
return 'Europe/Madrid';
|
|
110
110
|
return province === 52 ? 'Europe/Gibraltar' : province === 60 ? 'Europe/Andorra' : null;
|
|
@@ -115,9 +115,9 @@ function instant(wall, zone) {
|
|
|
115
115
|
return placed.isValid && placed.toFormat("yyyy-MM-dd'T'HH:mm:ss") === wall ? placed.toISO({ suppressMilliseconds: true }) : null;
|
|
116
116
|
}
|
|
117
117
|
/** A row's clock: an instant when its office settles the zone, else the wall clock or the text as shown. */
|
|
118
|
-
function rowClock(rawDate, rawHour, location) {
|
|
118
|
+
function rowClock(rawDate, rawHour, location, points) {
|
|
119
119
|
const clock = buildLocalDate(rawDate, rawHour);
|
|
120
|
-
const zone = location ? officeZone(location) : null;
|
|
120
|
+
const zone = location ? officeZone(location, points) : null;
|
|
121
121
|
const time = zone && clock.local_time ? instant(clock.local_time, zone) : null;
|
|
122
122
|
return time ? { time } : clock;
|
|
123
123
|
}
|
|
@@ -155,6 +155,13 @@ export function parseMrwHistory(html, raw, summary) {
|
|
|
155
155
|
throw new IndeterminateError('MRW', 'Shipment history is empty');
|
|
156
156
|
if (rows.length > 500)
|
|
157
157
|
throw new SchemaError('MRW', 'Shipment history is unexpectedly large');
|
|
158
|
+
// A pickup point's place links to its map; a later row there, such as the
|
|
159
|
+
// collection, shows its code without the link.
|
|
160
|
+
const points = new Set(rows.toArray().flatMap((row) => {
|
|
161
|
+
const place = $(row).children('td').eq(3);
|
|
162
|
+
const code = /^\d{5}(?=\s)/.exec(officeLabel(place.text()))?.[0];
|
|
163
|
+
return code && place.find('a[onclick*="openMap"]').length ? [code] : [];
|
|
164
|
+
}));
|
|
158
165
|
const events = [];
|
|
159
166
|
const seen = new Set();
|
|
160
167
|
// MRW renders the current row first. Do not promote an older dated row when
|
|
@@ -171,7 +178,7 @@ export function parseMrwHistory(html, raw, summary) {
|
|
|
171
178
|
// Read visible text only. The PointCorner link embeds a full store address
|
|
172
179
|
// and map arguments in onclick; they must never enter the result.
|
|
173
180
|
const location = officeLabel(cells.eq(3).text());
|
|
174
|
-
const clock = rowClock(date, hour, location);
|
|
181
|
+
const clock = rowClock(date, hour, location, points);
|
|
175
182
|
const key = JSON.stringify([date, hour, rawStatus, location]);
|
|
176
183
|
if (seen.has(key))
|
|
177
184
|
continue;
|
|
@@ -613,6 +613,40 @@
|
|
|
613
613
|
]
|
|
614
614
|
},
|
|
615
615
|
"note": "Made-up number in the layout of a sender's reference, dated day before month, that SEUR's lookup found for its shipments."
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
"number": "48285234834793",
|
|
619
|
+
"role": "shipment",
|
|
620
|
+
"evidence": "public_shipment_report",
|
|
621
|
+
"source": {
|
|
622
|
+
"url": "https://www.ocu.org/reclamar/lista-reclamaciones-publicas/reclamaci-C3-B3n-formal-contra-seur/3d4034ae564773a03b",
|
|
623
|
+
"date": "2026-10-14",
|
|
624
|
+
"dateKind": "publication",
|
|
625
|
+
"access": "full_page"
|
|
626
|
+
},
|
|
627
|
+
"context": {
|
|
628
|
+
"assessment": "confirmed",
|
|
629
|
+
"reportedRole": "shipment_tracking",
|
|
630
|
+
"service": "SEUR"
|
|
631
|
+
},
|
|
632
|
+
"expect": {
|
|
633
|
+
"carrier": "unknown",
|
|
634
|
+
"confidence": "low",
|
|
635
|
+
"candidates": [
|
|
636
|
+
"dpd",
|
|
637
|
+
"ciblex",
|
|
638
|
+
"hermes-de",
|
|
639
|
+
"seur",
|
|
640
|
+
"brt",
|
|
641
|
+
"delhivery",
|
|
642
|
+
"dhl-ecommerce-uk",
|
|
643
|
+
"dpd-be",
|
|
644
|
+
"dpd-de",
|
|
645
|
+
"dpd-nl",
|
|
646
|
+
"dpd-uk"
|
|
647
|
+
]
|
|
648
|
+
},
|
|
649
|
+
"note": "Tracking number in a complaint about a locker drop-off; SEUR's tracker returns its history."
|
|
616
650
|
}
|
|
617
651
|
]
|
|
618
652
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Universal providers copy SF's scans to the second, on the same UTC+08:00
|
|
2
|
+
// clock, in their own wording. The scan SF itself returns at that instant
|
|
3
|
+
// takes over the copy, and over its own row stored under older wording.
|
|
4
|
+
export const sameInstantIdentityPolicy = {
|
|
5
|
+
sourceCarrierId: 'sf-express', storedSources: ['sf-express', 'unknown'], requireProviderCode: false,
|
|
6
|
+
};
|
|
@@ -83,7 +83,7 @@ export function parse(payload, trackingNumber) {
|
|
|
83
83
|
const reason = clean(raw.stayWhyCode, 64);
|
|
84
84
|
if (!/^[A-Z0-9_-]{1,64}$/.test(code))
|
|
85
85
|
throw new SchemaError(PROVIDER, 'SF Express returned an invalid operation code');
|
|
86
|
-
const status = sfExpressEventStatus(code, reason);
|
|
86
|
+
const status = sfExpressEventStatus(code, reason, text);
|
|
87
87
|
const event = { time, provider_code: code,
|
|
88
88
|
description: status?.status === 'delivered' ? 'Delivered' : text,
|
|
89
89
|
...(status ? { stage: status.stage } : {}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ClassifiedStatus } from '../../core/status/index.js';
|
|
2
|
-
/** Codes 8000 and 70 are ambiguous without their reason; do not default them to signed. */
|
|
3
|
-
export declare function sfExpressEventStatus(code: string, reason: string): ClassifiedStatus | undefined;
|
|
2
|
+
/** Codes 8000 and 70 are ambiguous without their reason, and 99 without its remark; do not default them to signed. */
|
|
3
|
+
export declare function sfExpressEventStatus(code: string, reason: string, remark?: string): ClassifiedStatus | undefined;
|
|
4
4
|
export declare function sfExpressSummaryStatus(state: string, signed: boolean): ClassifiedStatus | undefined;
|
|
@@ -15,8 +15,7 @@ const UNDELIVERED = new Map([
|
|
|
15
15
|
const SUMMARY = new Map([['2', EXCEPTION], ['3', TRANSIT], ['4', RETURNED], ['5', EXCEPTION], ['6', EXCEPTION], ['99', TRANSIT], ['100', DELIVERED]]);
|
|
16
16
|
// The official Taiwan frontend's operation-code groups, plus codes observed in
|
|
17
17
|
// its public route response whose remarks settle them. The warehouse
|
|
18
|
-
// "delivered" group means dispatched. Code 99
|
|
19
|
-
// "being forwarded", so it stays unclassified.
|
|
18
|
+
// "delivered" group means dispatched. Code 99 is read by its remark.
|
|
20
19
|
const CODES = new Map([
|
|
21
20
|
...['80', '980'].map((code) => [code, DELIVERED]),
|
|
22
21
|
...['50', '54', '950'].map((code) => [code, { stage: 'accepted', status: 'in_transit' }]),
|
|
@@ -28,13 +27,21 @@ const CODES = new Map([
|
|
|
28
27
|
...['98', '208', '649', '310', '115', '116', '302', '305'].map((code) => [code, TRANSIT]),
|
|
29
28
|
['605', { stage: 'customs', status: 'in_transit' }],
|
|
30
29
|
]);
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// Code 99 carries several notices: one on its way back to the sender, or one
|
|
31
|
+
// sent on to another address. Other remarks stay unclassified.
|
|
32
|
+
const NOTICES = [
|
|
33
|
+
[/^The shipment is being returned\.?$/i, RETURNED],
|
|
34
|
+
[/^The shipment is being forwarded\.?$/i, TRANSIT],
|
|
35
|
+
];
|
|
36
|
+
/** Codes 8000 and 70 are ambiguous without their reason, and 99 without its remark; do not default them to signed. */
|
|
37
|
+
export function sfExpressEventStatus(code, reason, remark = '') {
|
|
33
38
|
if (code === '8000') {
|
|
34
39
|
return REASONS.get(reason);
|
|
35
40
|
}
|
|
36
41
|
if (code === '70')
|
|
37
42
|
return UNDELIVERED.get(reason);
|
|
43
|
+
if (code === '99')
|
|
44
|
+
return NOTICES.find(([wording]) => wording.test(remark.trim()))?.[1];
|
|
38
45
|
return CODES.get(code);
|
|
39
46
|
}
|
|
40
47
|
export function sfExpressSummaryStatus(state, signed) {
|
|
@@ -406,6 +406,24 @@
|
|
|
406
406
|
"confirmedBy": "bundle",
|
|
407
407
|
"firstSeen": "2026-09-26",
|
|
408
408
|
"note": "Shipment summary vocabulary from official abroad/billDetailItem/mixins. State 99 yields to a more specific latest scan."
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"code": "99",
|
|
412
|
+
"wording": "The shipment is being returned",
|
|
413
|
+
"stage": "returned",
|
|
414
|
+
"language": "en",
|
|
415
|
+
"confirmedBy": "live",
|
|
416
|
+
"firstSeen": "2026-10-20",
|
|
417
|
+
"note": "Official Taiwan routes opCode 99, which carries several notices; this remark says the parcel is on its way back to the sender."
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"code": "99",
|
|
421
|
+
"wording": "The shipment is being forwarded",
|
|
422
|
+
"stage": "in_transit",
|
|
423
|
+
"language": "en",
|
|
424
|
+
"confirmedBy": "live",
|
|
425
|
+
"firstSeen": "2026-10-20",
|
|
426
|
+
"note": "Official Taiwan routes opCode 99 with this remark: the parcel is sent on to another address."
|
|
409
427
|
}
|
|
410
428
|
]
|
|
411
429
|
}
|
|
@@ -27,13 +27,14 @@ import { sameInstantIdentityPolicy as postaSlovenije } from '../../carriers/post
|
|
|
27
27
|
import { sameInstantIdentityPolicy as posteItaliane } from '../../carriers/poste-italiane/identity.js';
|
|
28
28
|
import { sameInstantIdentityPolicy as posti } from '../../carriers/posti/identity.js';
|
|
29
29
|
import { sameInstantIdentityPolicy as royalMail } from '../../carriers/royal-mail/identity.js';
|
|
30
|
+
import { sameInstantIdentityPolicy as sfExpress } from '../../carriers/sf-express/identity.js';
|
|
30
31
|
import { sameInstantIdentityPolicy as speedpak } from '../../carriers/speedpak/identity.js';
|
|
31
32
|
import { sameInstantIdentityPolicy as sunYou } from '../../carriers/sunyou/identity.js';
|
|
32
33
|
import { sameInstantIdentityPolicy as ups } from '../../carriers/ups/app.js';
|
|
33
34
|
import { sameInstantIdentityPolicy as swissPost } from '../../carriers/swiss-post/app.js';
|
|
34
35
|
import { sameInstantIdentityPolicy as yanwen } from '../../carriers/yanwen/app.js';
|
|
35
36
|
import { sameInstantIdentityPolicy as universal } from '../../providers/shared/app.js';
|
|
36
|
-
const policies = new Map([aliexpress, amazonShipping, australiaPost, austrianPost, canadaPost, chronopost, ciblex, correosExpress, correosSpain, ctt, dhlEcommerce, dpd, dpdFrance, hermesGermany, indiaPost, inpost, jdLogistics, laPoste, lbcExpress, mondialRelay, mrw, nzPost, packeta, posMalaysia, postlogistics, postaSlovenije, posteItaliane, posti, royalMail, speedpak, sunYou, ups, swissPost, yanwen, universal].map((policy) => [policy.sourceCarrierId, policy]));
|
|
37
|
+
const policies = new Map([aliexpress, amazonShipping, australiaPost, austrianPost, canadaPost, chronopost, ciblex, correosExpress, correosSpain, ctt, dhlEcommerce, dpd, dpdFrance, hermesGermany, indiaPost, inpost, jdLogistics, laPoste, lbcExpress, mondialRelay, mrw, nzPost, packeta, posMalaysia, postlogistics, postaSlovenije, posteItaliane, posti, royalMail, sfExpress, speedpak, sunYou, ups, swissPost, yanwen, universal].map((policy) => [policy.sourceCarrierId, policy]));
|
|
37
38
|
/** Unlisted sources cannot identify a reworded scan by its instant alone. */
|
|
38
39
|
export function sameInstantIdentityPolicy(sourceCarrierId, options = {}) {
|
|
39
40
|
const policy = policies.get(sourceCarrierId);
|
|
@@ -11,9 +11,10 @@ import { normalizeTrackingNumber } from './normalize.js';
|
|
|
11
11
|
function hasTrackingShape(normalized) {
|
|
12
12
|
return normalized.length >= 4
|
|
13
13
|
&& normalized.length <= 40
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
|
|
14
|
+
// Letters and digits, with one underscore inside as Better Trucks writes
|
|
15
|
+
// its BTS_ numbers. The NACEX agency/shipment composite is the only other
|
|
16
|
+
// shape allowed to keep punctuation.
|
|
17
|
+
&& (/^[A-Z0-9]+(?:_[A-Z0-9]+)?$/.test(normalized) || /^\d{4}\/\d{8}$/.test(normalized));
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Shape gate for a number entered whole or carried by a carrier's link. A number
|
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.
|
|
3
|
+
"version": "0.557.0-main.2585",
|
|
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",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"test": "vitest run",
|
|
63
63
|
"test:scripts": "node --test trawl/*.test.mjs scripts/*.test.mjs",
|
|
64
64
|
"generate": "node scripts/generate-catalog.mjs && node scripts/generate-registry.mjs --strict && node scripts/generate-region-towns.mjs && node scripts/benchmark.mjs routing && node scripts/coverage-tables.mjs && node scripts/generate-readme.mjs",
|
|
65
|
+
"generate:golden": "node scripts/detection-golden.mjs",
|
|
65
66
|
"test:generated": "node scripts/generate-catalog.mjs --check && node scripts/generate-registry.mjs --strict --check && node scripts/generate-region-towns.mjs --check && node scripts/benchmark.mjs routing --check && node scripts/coverage-tables.mjs --check && node scripts/generate-readme.mjs --check",
|
|
66
67
|
"test:package": "node scripts/test-package.mjs",
|
|
67
68
|
"test:carriers:live": "vitest run --config vitest.carriers-live.config.ts",
|