universal-parcel-scraper 0.49.0-main.532 → 0.49.0-main.541
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/NOTICE +2 -1
- package/README.md +1 -1
- package/data/catalog.json +4 -0
- package/data/detection-golden.json +40 -20
- package/dist/app.d.ts +6 -3
- package/dist/app.js +6 -3
- package/dist/browser/scraper.js +5 -0
- package/dist/carriers/chronopost/carrier.json +5 -0
- package/dist/carriers/chronopost/numbers.json +77 -17
- package/dist/carriers/chronopost/status.d.ts +3 -0
- package/dist/carriers/chronopost/status.js +14 -1
- package/dist/carriers/dhl-express/adapter.js +3 -19
- package/dist/carriers/dhl-express/status.d.ts +16 -0
- package/dist/carriers/dhl-express/status.js +38 -0
- package/dist/carriers/dhl-express/statuses.json +39 -0
- package/dist/carriers/dpd/status.d.ts +12 -2
- package/dist/carriers/dpd/status.js +30 -0
- package/dist/carriers/dpd/statuses.json +68 -0
- package/dist/carriers/intl-post/numbers.json +3 -6
- package/dist/carriers/la-poste/status.d.ts +11 -1
- package/dist/carriers/la-poste/status.js +22 -6
- package/dist/carriers/la-poste/statuses.json +13 -4
- package/dist/carriers/postlogistics/status.d.ts +3 -0
- package/dist/carriers/postlogistics/status.js +5 -0
- package/dist/carriers/swiss-post/status.d.ts +7 -0
- package/dist/carriers/swiss-post/status.js +10 -0
- package/dist/carriers/tnt/status.d.ts +3 -0
- package/dist/carriers/tnt/status.js +6 -0
- package/dist/carriers/tnt/statuses.json +9 -0
- package/dist/carriers/ups/status.d.ts +3 -0
- package/dist/carriers/ups/status.js +5 -0
- package/dist/carriers/yunexpress/status.d.ts +6 -0
- package/dist/carriers/yunexpress/status.js +19 -3
- package/dist/carriers/yunexpress/statuses.json +29 -0
- package/dist/core/catalog/statusMaps.d.ts +32 -0
- package/dist/core/catalog/statusMaps.js +52 -0
- package/dist/core/status/statusMap.d.ts +29 -0
- package/dist/core/status/statusMap.js +4 -0
- package/dist/data/catalog.json +4 -0
- package/dist/generated/catalog.d.ts +3 -0
- package/dist/generated/catalog.js +5 -1
- package/dist/places/countries.json +238 -16
- package/dist/places/hubs.json +5 -0
- package/dist/places/index.js +216 -39
- package/dist/places/names.d.mts +1 -0
- package/dist/places/names.mjs +5 -2
- package/dist/places/places.tsv.br +0 -0
- package/dist/places/trackingLocation.d.ts +2 -1
- package/dist/places/trackingLocation.js +23 -2
- package/dist/providers/seventeentrack/adapter.js +14 -1
- package/package.json +1 -1
package/NOTICE
CHANGED
|
@@ -12,4 +12,5 @@ The places gazetteer includes GeoNames data (https://www.geonames.org),
|
|
|
12
12
|
licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/).
|
|
13
13
|
Facility coordinates include OpenStreetMap data (https://www.openstreetmap.org/copyright),
|
|
14
14
|
licensed under the Open Database License. Natural Earth country label points
|
|
15
|
-
(https://www.naturalearthdata.com)
|
|
15
|
+
(https://www.naturalearthdata.com) and OurAirports airports
|
|
16
|
+
(https://ourairports.com/data/) are public domain.
|
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ createTracker({ providers: ['ParcelsApp', 'Ship24', '17TRACK', 'Postal Ninja', '
|
|
|
149
149
|
<!-- GENERATED:stages -->
|
|
150
150
|
<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">
|
|
151
151
|
|
|
152
|
-
The carrier folders record 2,
|
|
152
|
+
The carrier folders record 2,744 such statuses, each filed under one stage.
|
|
153
153
|
<!-- /GENERATED:stages -->
|
|
154
154
|
|
|
155
155
|
Wording nobody recorded yet goes through a classifier that reads seven European languages.
|
package/data/catalog.json
CHANGED
|
@@ -1157,6 +1157,10 @@
|
|
|
1157
1157
|
"confidence": "high",
|
|
1158
1158
|
"checksum": "s10"
|
|
1159
1159
|
},
|
|
1160
|
+
{
|
|
1161
|
+
"pattern": "^(?!(?:PZ|XR|XT|XU|XW|XY))[A-Z]{2}\\d{9}(?:JB|JF|TS)$",
|
|
1162
|
+
"confidence": "high"
|
|
1163
|
+
},
|
|
1160
1164
|
{
|
|
1161
1165
|
"pattern": "^\\d{14}[0-9A-Z]$",
|
|
1162
1166
|
"confidence": "low",
|
|
@@ -12318,6 +12318,14 @@
|
|
|
12318
12318
|
"confidence": "none",
|
|
12319
12319
|
"candidates": []
|
|
12320
12320
|
},
|
|
12321
|
+
{
|
|
12322
|
+
"input": "BC989633266JB",
|
|
12323
|
+
"carrier": "chronopost",
|
|
12324
|
+
"confidence": "high",
|
|
12325
|
+
"candidates": [
|
|
12326
|
+
"chronopost"
|
|
12327
|
+
]
|
|
12328
|
+
},
|
|
12321
12329
|
{
|
|
12322
12330
|
"input": "BE0000000001",
|
|
12323
12331
|
"carrier": "amazon-logistics",
|
|
@@ -13800,13 +13808,10 @@
|
|
|
13800
13808
|
},
|
|
13801
13809
|
{
|
|
13802
13810
|
"input": "FZ246006535JB",
|
|
13803
|
-
"carrier": "
|
|
13804
|
-
"confidence": "
|
|
13811
|
+
"carrier": "chronopost",
|
|
13812
|
+
"confidence": "high",
|
|
13805
13813
|
"candidates": [
|
|
13806
13814
|
"chronopost"
|
|
13807
|
-
],
|
|
13808
|
-
"asked": [
|
|
13809
|
-
"chronopost"
|
|
13810
13815
|
]
|
|
13811
13816
|
},
|
|
13812
13817
|
{
|
|
@@ -13919,6 +13924,14 @@
|
|
|
13919
13924
|
"gofo"
|
|
13920
13925
|
]
|
|
13921
13926
|
},
|
|
13927
|
+
{
|
|
13928
|
+
"input": "GH205472665JB",
|
|
13929
|
+
"carrier": "chronopost",
|
|
13930
|
+
"confidence": "high",
|
|
13931
|
+
"candidates": [
|
|
13932
|
+
"chronopost"
|
|
13933
|
+
]
|
|
13934
|
+
},
|
|
13922
13935
|
{
|
|
13923
13936
|
"input": "GI049170518GB",
|
|
13924
13937
|
"carrier": "parcelforce",
|
|
@@ -14184,13 +14197,10 @@
|
|
|
14184
14197
|
},
|
|
14185
14198
|
{
|
|
14186
14199
|
"input": "HV520454959JF",
|
|
14187
|
-
"carrier": "
|
|
14188
|
-
"confidence": "
|
|
14200
|
+
"carrier": "chronopost",
|
|
14201
|
+
"confidence": "high",
|
|
14189
14202
|
"candidates": [
|
|
14190
14203
|
"chronopost"
|
|
14191
|
-
],
|
|
14192
|
-
"asked": [
|
|
14193
|
-
"chronopost"
|
|
14194
14204
|
]
|
|
14195
14205
|
},
|
|
14196
14206
|
{
|
|
@@ -15824,6 +15834,22 @@
|
|
|
15824
15834
|
"correios-br"
|
|
15825
15835
|
]
|
|
15826
15836
|
},
|
|
15837
|
+
{
|
|
15838
|
+
"input": "NP123456789JB",
|
|
15839
|
+
"carrier": "chronopost",
|
|
15840
|
+
"confidence": "high",
|
|
15841
|
+
"candidates": [
|
|
15842
|
+
"chronopost"
|
|
15843
|
+
]
|
|
15844
|
+
},
|
|
15845
|
+
{
|
|
15846
|
+
"input": "NP989065909JB",
|
|
15847
|
+
"carrier": "chronopost",
|
|
15848
|
+
"confidence": "high",
|
|
15849
|
+
"candidates": [
|
|
15850
|
+
"chronopost"
|
|
15851
|
+
]
|
|
15852
|
+
},
|
|
15827
15853
|
{
|
|
15828
15854
|
"input": "NVSGBEDBP03784ADPL",
|
|
15829
15855
|
"carrier": "unknown",
|
|
@@ -16613,13 +16639,10 @@
|
|
|
16613
16639
|
},
|
|
16614
16640
|
{
|
|
16615
16641
|
"input": "RR123456785TS",
|
|
16616
|
-
"carrier": "
|
|
16617
|
-
"confidence": "
|
|
16642
|
+
"carrier": "chronopost",
|
|
16643
|
+
"confidence": "high",
|
|
16618
16644
|
"candidates": [
|
|
16619
16645
|
"chronopost"
|
|
16620
|
-
],
|
|
16621
|
-
"asked": [
|
|
16622
|
-
"chronopost"
|
|
16623
16646
|
]
|
|
16624
16647
|
},
|
|
16625
16648
|
{
|
|
@@ -17854,13 +17877,10 @@
|
|
|
17854
17877
|
},
|
|
17855
17878
|
{
|
|
17856
17879
|
"input": "XN136114912JB",
|
|
17857
|
-
"carrier": "
|
|
17858
|
-
"confidence": "
|
|
17880
|
+
"carrier": "chronopost",
|
|
17881
|
+
"confidence": "high",
|
|
17859
17882
|
"candidates": [
|
|
17860
17883
|
"chronopost"
|
|
17861
|
-
],
|
|
17862
|
-
"asked": [
|
|
17863
|
-
"chronopost"
|
|
17864
17884
|
]
|
|
17865
17885
|
},
|
|
17866
17886
|
{
|
package/dist/app.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Helpers shaped for the parcel app this package was extracted from: its
|
|
3
3
|
* parcel view, carrier-name hints for provider results, the clock helpers
|
|
4
|
-
* its sync uses, carrier scan-identity policies,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* its sync uses, carrier scan-identity policies, what a carrier's status map
|
|
5
|
+
* says about a scan the app reviews, and the country a scan's location
|
|
6
|
+
* names. They change with that app and carry no stability promise; the
|
|
7
|
+
* tracking contract is the other entry points.
|
|
7
8
|
*/
|
|
8
9
|
export * from './core/catalog/parcel.js';
|
|
9
10
|
export * from './core/catalog/hints.js';
|
|
@@ -11,4 +12,6 @@ export * from './core/time/result.js';
|
|
|
11
12
|
export { sameInstantIdentityPolicy, type SameInstantIdentityPolicy, type SameInstantScan } from './core/catalog/eventIdentity.js';
|
|
12
13
|
export { universalCarrierHints } from './providers/shared/hints.js';
|
|
13
14
|
export { recognitionAskedCarriers } from './core/catalog/recognition.js';
|
|
15
|
+
export { statusMapAnswer, type ObservedStatus, type StatusMapAnswer } from './core/catalog/statusMaps.js';
|
|
16
|
+
export { normalizeStatusWording } from './core/status/statusMap.js';
|
|
14
17
|
export { countryFlag, countryName, trackingLocationCountry, trackingPlace, type TrackingPlace } from './places/trackingLocation.js';
|
package/dist/app.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Helpers shaped for the parcel app this package was extracted from: its
|
|
3
3
|
* parcel view, carrier-name hints for provider results, the clock helpers
|
|
4
|
-
* its sync uses, carrier scan-identity policies,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* its sync uses, carrier scan-identity policies, what a carrier's status map
|
|
5
|
+
* says about a scan the app reviews, and the country a scan's location
|
|
6
|
+
* names. They change with that app and carry no stability promise; the
|
|
7
|
+
* tracking contract is the other entry points.
|
|
7
8
|
*/
|
|
8
9
|
export * from './core/catalog/parcel.js';
|
|
9
10
|
export * from './core/catalog/hints.js';
|
|
@@ -11,4 +12,6 @@ export * from './core/time/result.js';
|
|
|
11
12
|
export { sameInstantIdentityPolicy } from './core/catalog/eventIdentity.js';
|
|
12
13
|
export { universalCarrierHints } from './providers/shared/hints.js';
|
|
13
14
|
export { recognitionAskedCarriers } from './core/catalog/recognition.js';
|
|
15
|
+
export { statusMapAnswer } from './core/catalog/statusMaps.js';
|
|
16
|
+
export { normalizeStatusWording } from './core/status/statusMap.js';
|
|
14
17
|
export { countryFlag, countryName, trackingLocationCountry, trackingPlace } from './places/trackingLocation.js';
|
package/dist/browser/scraper.js
CHANGED
|
@@ -1030,6 +1030,10 @@ var ve = {
|
|
|
1030
1030
|
confidence: "high",
|
|
1031
1031
|
checksum: "s10"
|
|
1032
1032
|
},
|
|
1033
|
+
{
|
|
1034
|
+
pattern: "^(?!(?:PZ|XR|XT|XU|XW|XY))[A-Z]{2}\\d{9}(?:JB|JF|TS)$",
|
|
1035
|
+
confidence: "high"
|
|
1036
|
+
},
|
|
1033
1037
|
{
|
|
1034
1038
|
pattern: "^\\d{14}[0-9A-Z]$",
|
|
1035
1039
|
confidence: "low",
|
|
@@ -4083,6 +4087,7 @@ var ve = {
|
|
|
4083
4087
|
],
|
|
4084
4088
|
chronopost: [
|
|
4085
4089
|
"chronopost-1",
|
|
4090
|
+
"chronopost-own-suffix",
|
|
4086
4091
|
"chronopost-2",
|
|
4087
4092
|
"chronopost-3"
|
|
4088
4093
|
],
|
|
@@ -73,6 +73,11 @@
|
|
|
73
73
|
"confidence": "high",
|
|
74
74
|
"checksum": "s10"
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
"id": "chronopost-own-suffix",
|
|
78
|
+
"pattern": "^(?!(?:PZ|XR|XT|XU|XW|XY))[A-Z]{2}\\d{9}(?:JB|JF|TS)$",
|
|
79
|
+
"confidence": "high"
|
|
80
|
+
},
|
|
76
81
|
{
|
|
77
82
|
"id": "chronopost-2",
|
|
78
83
|
"pattern": "^\\d{14}[0-9A-Z]$",
|
|
@@ -133,6 +133,18 @@
|
|
|
133
133
|
},
|
|
134
134
|
"note": "Made-up number in the shape of Chronopost parcels whose S10 check digit passes and whose TS suffix is no country."
|
|
135
135
|
},
|
|
136
|
+
{
|
|
137
|
+
"number": "NP123456789JB",
|
|
138
|
+
"role": "shipment",
|
|
139
|
+
"evidence": "synthetic",
|
|
140
|
+
"derivedFrom": "invented",
|
|
141
|
+
"shapeConfirmed": "2026-10-08",
|
|
142
|
+
"expect": {
|
|
143
|
+
"carrier": "chronopost",
|
|
144
|
+
"confidence": "high"
|
|
145
|
+
},
|
|
146
|
+
"note": "Made-up number with Chronopost's own JB suffix and no S10 check digit, as its numbers outside the dedicated prefixes often have."
|
|
147
|
+
},
|
|
136
148
|
{
|
|
137
149
|
"number": "XT010847192TS",
|
|
138
150
|
"role": "shipment",
|
|
@@ -295,13 +307,10 @@
|
|
|
295
307
|
"assessment": "confirmed"
|
|
296
308
|
},
|
|
297
309
|
"expect": {
|
|
298
|
-
"carrier": "
|
|
299
|
-
"confidence": "
|
|
300
|
-
"candidates": [
|
|
301
|
-
"chronopost"
|
|
302
|
-
]
|
|
310
|
+
"carrier": "chronopost",
|
|
311
|
+
"confidence": "high"
|
|
303
312
|
},
|
|
304
|
-
"note": "Chronopost's tracker returns its history. The JB suffix
|
|
313
|
+
"note": "Chronopost's tracker returns its history. The JB suffix is Chronopost's own code, not a country."
|
|
305
314
|
},
|
|
306
315
|
{
|
|
307
316
|
"number": "XR657749906TS",
|
|
@@ -336,11 +345,8 @@
|
|
|
336
345
|
"assessment": "confirmed"
|
|
337
346
|
},
|
|
338
347
|
"expect": {
|
|
339
|
-
"carrier": "
|
|
340
|
-
"confidence": "
|
|
341
|
-
"candidates": [
|
|
342
|
-
"chronopost"
|
|
343
|
-
]
|
|
348
|
+
"carrier": "chronopost",
|
|
349
|
+
"confidence": "high"
|
|
344
350
|
},
|
|
345
351
|
"note": "Chronopost's tracker returns its history, delivered in Spain through the DPD network."
|
|
346
352
|
},
|
|
@@ -358,13 +364,67 @@
|
|
|
358
364
|
"assessment": "confirmed"
|
|
359
365
|
},
|
|
360
366
|
"expect": {
|
|
361
|
-
"carrier": "
|
|
362
|
-
"confidence": "
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
"carrier": "chronopost",
|
|
368
|
+
"confidence": "high"
|
|
369
|
+
},
|
|
370
|
+
"note": "Chronopost's tracker returns its history, dropped off at a relay by the sender. The JB suffix is Chronopost's own code, not a country."
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"number": "NP989065909JB",
|
|
374
|
+
"role": "shipment",
|
|
375
|
+
"evidence": "public_shipment_report",
|
|
376
|
+
"source": {
|
|
377
|
+
"url": "https://web.archive.org/web/20260704104531/https://www.chronopost.fr/tracking-no-cms/suivi-page?listeNumerosLT=NP989065909JB&langue=de",
|
|
378
|
+
"date": "2026-07-04",
|
|
379
|
+
"dateKind": "capture",
|
|
380
|
+
"access": "indexed_excerpt"
|
|
381
|
+
},
|
|
382
|
+
"context": {
|
|
383
|
+
"assessment": "confirmed"
|
|
384
|
+
},
|
|
385
|
+
"expect": {
|
|
386
|
+
"carrier": "chronopost",
|
|
387
|
+
"confidence": "high"
|
|
388
|
+
},
|
|
389
|
+
"note": "Chronopost's tracker returns its history. It has no S10 check digit, like many JB numbers whose prefix is not one of Chronopost's dedicated ones."
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"number": "BC989633266JB",
|
|
393
|
+
"role": "shipment",
|
|
394
|
+
"evidence": "public_shipment_report",
|
|
395
|
+
"source": {
|
|
396
|
+
"url": "https://web.archive.org/web/20260630120634/https://www.chronopost.fr/tracking-no-cms/suivi-page?langue=es&listeNumerosLT=BC989633266JB",
|
|
397
|
+
"date": "2026-06-30",
|
|
398
|
+
"dateKind": "capture",
|
|
399
|
+
"access": "indexed_excerpt"
|
|
400
|
+
},
|
|
401
|
+
"context": {
|
|
402
|
+
"assessment": "confirmed"
|
|
403
|
+
},
|
|
404
|
+
"expect": {
|
|
405
|
+
"carrier": "chronopost",
|
|
406
|
+
"confidence": "high"
|
|
407
|
+
},
|
|
408
|
+
"note": "Chronopost's tracker returns its history. It has no S10 check digit."
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"number": "GH205472665JB",
|
|
412
|
+
"role": "shipment",
|
|
413
|
+
"evidence": "public_shipment_report",
|
|
414
|
+
"source": {
|
|
415
|
+
"url": "https://web.archive.org/web/20260602155627/https://www.chronopost.fr/tracking-no-cms/suivi-page?listeNumerosLT=GH205472665JB",
|
|
416
|
+
"date": "2026-06-02",
|
|
417
|
+
"dateKind": "capture",
|
|
418
|
+
"access": "indexed_excerpt"
|
|
419
|
+
},
|
|
420
|
+
"context": {
|
|
421
|
+
"assessment": "confirmed"
|
|
422
|
+
},
|
|
423
|
+
"expect": {
|
|
424
|
+
"carrier": "chronopost",
|
|
425
|
+
"confidence": "high"
|
|
366
426
|
},
|
|
367
|
-
"note": "Chronopost's tracker returns its history
|
|
427
|
+
"note": "Chronopost's tracker returns its history. Its S10 check digit passes, but the JB suffix names no country, so it is not international mail."
|
|
368
428
|
},
|
|
369
429
|
{
|
|
370
430
|
"number": "XS431625991FR",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type ClassifiedWording } from '../../core/status/index.js';
|
|
2
|
+
import { type CarrierStatusMap } from '../../core/status/statusMap.js';
|
|
2
3
|
export declare function isChronopostNotification(label: string): boolean;
|
|
3
4
|
/** The courier's drop-off scan, which can follow the pickup point's own arrival scan. */
|
|
4
5
|
export declare function isPickupDropOff(code: string, label: string): boolean;
|
|
5
6
|
/** Partner events can reuse codes; the observed wording must agree with the code. */
|
|
6
7
|
export declare function chronopostStage(code: string, label: string): ClassifiedWording;
|
|
8
|
+
/** What the map says about one scan: a code whose observed wording it carries. */
|
|
9
|
+
export declare const statusMap: CarrierStatusMap;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { classifyWording } from '../../core/status/index.js';
|
|
2
|
+
import { normalizeStatusWording } from '../../core/status/statusMap.js';
|
|
2
3
|
const observed = new Map([
|
|
3
4
|
['DC', { label: "Colis en cours de préparation chez l'expéditeur", stage: 'registered' }],
|
|
4
5
|
['DB', { label: "Colis déposé par l'expéditeur", stage: 'accepted' }],
|
|
@@ -14,8 +15,9 @@ const observed = new Map([
|
|
|
14
15
|
['P', { label: "Echec de livraison suite à l'absence du destinataire.", stage: 'failed_attempt' }],
|
|
15
16
|
['SK', { label: "Colis en attente d'informations complémentaires de votre part", stage: 'exception' }],
|
|
16
17
|
]);
|
|
18
|
+
const NOTIFICATION = 'Destinataire informé par SMS ou mail';
|
|
17
19
|
export function isChronopostNotification(label) {
|
|
18
|
-
return label ===
|
|
20
|
+
return label === NOTIFICATION;
|
|
19
21
|
}
|
|
20
22
|
/** The courier's drop-off scan, which can follow the pickup point's own arrival scan. */
|
|
21
23
|
export function isPickupDropOff(code, label) {
|
|
@@ -28,3 +30,14 @@ export function chronopostStage(code, label) {
|
|
|
28
30
|
return { stage: known.stage, source: 'carrier_map' };
|
|
29
31
|
return classifyWording(label, 'pending');
|
|
30
32
|
}
|
|
33
|
+
/** What the map says about one scan: a code whose observed wording it carries. */
|
|
34
|
+
export const statusMap = {
|
|
35
|
+
stage: (code, wording) => {
|
|
36
|
+
const known = code ? observed.get(code) : undefined;
|
|
37
|
+
return known && normalizeStatusWording(known.label) === wording ? known.stage : undefined;
|
|
38
|
+
},
|
|
39
|
+
gaps: [{
|
|
40
|
+
code: 'SM', wording: normalizeStatusWording(NOTIFICATION),
|
|
41
|
+
note: 'A notice to the recipient, not a scan: it keeps the stage the parcel already had.',
|
|
42
|
+
}],
|
|
43
|
+
};
|
|
@@ -4,12 +4,12 @@ import { accepted, lookupBudget, recognizeFromBrowserLookup, recognizeFromLookup
|
|
|
4
4
|
import { isValidDhlExpressWaybill } from '../../core/detection/numericChecksums.js';
|
|
5
5
|
import { BudgetExceededError, ChallengeError, IndeterminateError, InvalidInputError, NotFoundError, RateLimitedError, SchemaError, TransportError, UpstreamHttpError } from '../../core/errors/index.js';
|
|
6
6
|
import { runSteps } from '../../core/runner/index.js';
|
|
7
|
-
import { classifyWording } from '../../core/status/index.js';
|
|
8
7
|
import { explicitOffsetTime, zonedTime } from '../../core/time/index.js';
|
|
9
8
|
import { clean, parseJsonBytes } from '../../core/transport/index.js';
|
|
10
9
|
import { isRecord } from '../../core/types.js';
|
|
11
10
|
import { facilityZone } from './clock.js';
|
|
12
11
|
import { mobileTracking } from './mobile.js';
|
|
12
|
+
import { dhlExpressStage } from './status.js';
|
|
13
13
|
const PROVIDER = 'DHL Express';
|
|
14
14
|
const BROWSER_API = 'https://www.dhl.com/utapi';
|
|
15
15
|
const MAX_BYTES = 1_000_000;
|
|
@@ -42,22 +42,6 @@ function clock(date, time, location) {
|
|
|
42
42
|
const instant = zone ? zonedTime(wall, CLOCK_FORMAT, zone, { locale: 'en' }) : null;
|
|
43
43
|
return instant ? { time: instant.iso } : { local_time: local.toFormat("yyyy-MM-dd'T'HH:mm:ss") };
|
|
44
44
|
}
|
|
45
|
-
function stage(description) {
|
|
46
|
-
const text = description.toLowerCase();
|
|
47
|
-
if (text === 'delivered')
|
|
48
|
-
return { stage: 'delivered', source: 'carrier_map' };
|
|
49
|
-
if (text === 'shipment is out with courier for delivery')
|
|
50
|
-
return { stage: 'out_for_delivery', source: 'carrier_map' };
|
|
51
|
-
if (text.startsWith('delivery attempted'))
|
|
52
|
-
return { stage: 'failed_attempt', source: 'carrier_map' };
|
|
53
|
-
if (text === 'shipment is on hold')
|
|
54
|
-
return { stage: 'exception', source: 'carrier_map' };
|
|
55
|
-
if (text === 'shipment picked up')
|
|
56
|
-
return { stage: 'accepted', source: 'carrier_map' };
|
|
57
|
-
if (text.startsWith('clearance processing') || text.startsWith('customs clearance'))
|
|
58
|
-
return { stage: 'customs', source: 'carrier_map' };
|
|
59
|
-
return classifyWording(description, 'pending');
|
|
60
|
-
}
|
|
61
45
|
/** Public DHL web tracking: bind both the waybill and the Express division. */
|
|
62
46
|
export function parseUnified(payload, raw) {
|
|
63
47
|
const number = normalizeNumber(raw);
|
|
@@ -80,7 +64,7 @@ export function parseUnified(payload, raw) {
|
|
|
80
64
|
if (!isRecord(row) || typeof row.description !== 'string' || !row.description.trim())
|
|
81
65
|
throw new SchemaError(PROVIDER, 'DHL returned an invalid event');
|
|
82
66
|
const description = row.statusCode === 'delivered' ? 'Delivered' : clean(row.description).slice(0, 1000);
|
|
83
|
-
const mapped =
|
|
67
|
+
const mapped = dhlExpressStage(description);
|
|
84
68
|
const time = typeof row.timestamp === 'string' && /(?:Z|[+-](?:[01]\d|2[0-3]):?[0-5]\d)$/i.test(row.timestamp)
|
|
85
69
|
? explicitOffsetTime(row.timestamp)?.iso : undefined;
|
|
86
70
|
const address = isRecord(row.location) && isRecord(row.location.address) ? row.location.address : {};
|
|
@@ -124,7 +108,7 @@ export function parse(payload, raw) {
|
|
|
124
108
|
if (!isRecord(row) || typeof row.description !== 'string' || !row.description.trim())
|
|
125
109
|
throw new SchemaError(PROVIDER, 'DHL Express returned an invalid checkpoint');
|
|
126
110
|
const description = clean(row.description).slice(0, 1000);
|
|
127
|
-
const mapped =
|
|
111
|
+
const mapped = dhlExpressStage(description);
|
|
128
112
|
const location = typeof row.location === 'string' ? clean(row.location).slice(0, 300) : '';
|
|
129
113
|
return { description, ...clock(row.date, row.time, location), ...(typeof row.location === 'string' ? { location } : {}),
|
|
130
114
|
stage: mapped.stage, stage_source: mapped.source };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DHL Express checkpoint wording. Both the guest mobile API and the public
|
|
3
|
+
* web tracking send DHL's English checkpoint sentences, several of which end
|
|
4
|
+
* with the facility ("Processed at PARIS - FRANCE"), so those are matched on
|
|
5
|
+
* their fixed start. Other wording goes to the shared classifier.
|
|
6
|
+
*/
|
|
7
|
+
import { type Stage } from '../../core/status/index.js';
|
|
8
|
+
import type { CarrierStatusMap } from '../../core/status/statusMap.js';
|
|
9
|
+
/** The checkpoint's stage from DHL's own wording, if the wording is one of DHL's checkpoints. */
|
|
10
|
+
export declare function dhlExpressCheckpointStage(description: string): Stage | undefined;
|
|
11
|
+
export declare function dhlExpressStage(description: string): {
|
|
12
|
+
stage: Stage;
|
|
13
|
+
source: string;
|
|
14
|
+
};
|
|
15
|
+
/** What the map says about one scan: the web feed's codes are not read, only the checkpoint wording. */
|
|
16
|
+
export declare const statusMap: CarrierStatusMap;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DHL Express checkpoint wording. Both the guest mobile API and the public
|
|
3
|
+
* web tracking send DHL's English checkpoint sentences, several of which end
|
|
4
|
+
* with the facility ("Processed at PARIS - FRANCE"), so those are matched on
|
|
5
|
+
* their fixed start. Other wording goes to the shared classifier.
|
|
6
|
+
*/
|
|
7
|
+
import { classifyWording } from '../../core/status/index.js';
|
|
8
|
+
const EXACT = new Map([
|
|
9
|
+
['shipment information received', 'registered'],
|
|
10
|
+
['shipment picked up', 'accepted'],
|
|
11
|
+
['shipment is in transit to destination', 'in_transit'],
|
|
12
|
+
['shipment is out with courier for delivery', 'out_for_delivery'],
|
|
13
|
+
['shipment is on hold', 'exception'],
|
|
14
|
+
['delivered', 'delivered'],
|
|
15
|
+
]);
|
|
16
|
+
const PREFIXES = [
|
|
17
|
+
['delivery attempted', 'failed_attempt'],
|
|
18
|
+
['clearance processing', 'customs'],
|
|
19
|
+
['customs clearance', 'customs'],
|
|
20
|
+
['processed at ', 'in_transit'],
|
|
21
|
+
['arrived at dhl sort facility', 'in_transit'],
|
|
22
|
+
['arrived at dhl delivery facility', 'in_transit'],
|
|
23
|
+
['shipment has departed from a dhl facility', 'in_transit'],
|
|
24
|
+
];
|
|
25
|
+
/** The checkpoint's stage from DHL's own wording, if the wording is one of DHL's checkpoints. */
|
|
26
|
+
export function dhlExpressCheckpointStage(description) {
|
|
27
|
+
const text = description.toLowerCase();
|
|
28
|
+
return EXACT.get(text) ?? PREFIXES.find(([start]) => text.startsWith(start))?.[1];
|
|
29
|
+
}
|
|
30
|
+
export function dhlExpressStage(description) {
|
|
31
|
+
const stage = dhlExpressCheckpointStage(description);
|
|
32
|
+
return stage ? { stage, source: 'carrier_map' } : classifyWording(description, 'pending');
|
|
33
|
+
}
|
|
34
|
+
/** What the map says about one scan: the web feed's codes are not read, only the checkpoint wording. */
|
|
35
|
+
export const statusMap = {
|
|
36
|
+
stage: (_code, wording) => dhlExpressCheckpointStage(wording),
|
|
37
|
+
gaps: [],
|
|
38
|
+
};
|
|
@@ -42,6 +42,45 @@
|
|
|
42
42
|
"stage": "in_transit",
|
|
43
43
|
"confirmedBy": "live",
|
|
44
44
|
"firstSeen": "2026-10-05"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"wording": "Shipment information received",
|
|
48
|
+
"language": "en",
|
|
49
|
+
"stage": "registered",
|
|
50
|
+
"confirmedBy": "live",
|
|
51
|
+
"firstSeen": "2026-10-05"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"wording": "Processed at",
|
|
55
|
+
"language": "en",
|
|
56
|
+
"stage": "in_transit",
|
|
57
|
+
"confirmedBy": "live",
|
|
58
|
+
"firstSeen": "2026-10-05",
|
|
59
|
+
"note": "Followed by the facility, as in \"Processed at <city> - <country>\"; matched on its start."
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"wording": "Arrived at DHL Sort Facility",
|
|
63
|
+
"language": "en",
|
|
64
|
+
"stage": "in_transit",
|
|
65
|
+
"confirmedBy": "live",
|
|
66
|
+
"firstSeen": "2026-10-05",
|
|
67
|
+
"note": "Followed by the facility; matched on its start."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"wording": "Arrived at DHL Delivery Facility",
|
|
71
|
+
"language": "en",
|
|
72
|
+
"stage": "in_transit",
|
|
73
|
+
"confirmedBy": "live",
|
|
74
|
+
"firstSeen": "2026-10-05",
|
|
75
|
+
"note": "Followed by the facility; matched on its start."
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"wording": "Shipment has departed from a DHL facility",
|
|
79
|
+
"language": "en",
|
|
80
|
+
"stage": "in_transit",
|
|
81
|
+
"confirmedBy": "live",
|
|
82
|
+
"firstSeen": "2026-10-05",
|
|
83
|
+
"note": "Followed by the facility; matched on its start."
|
|
45
84
|
}
|
|
46
85
|
]
|
|
47
86
|
}
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
* `PARCEL_HANDED`, `IN_TRANSIT` and `AT_DELIVERY_CENTER` deliberately yield no
|
|
14
14
|
* stage: they move the result status to `in_transit` but leave the event
|
|
15
15
|
* unmapped so the sync's classifier records the wording for review instead of
|
|
16
|
-
* this map inventing a milestone. Scan codes are mapped
|
|
17
|
-
*
|
|
16
|
+
* this map inventing a milestone. Scan codes are mapped where a live lookup
|
|
17
|
+
* paired them with an enumeration value, or where DPD's own label names one
|
|
18
|
+
* movement inside its network (see `scanStage`). `statusMap` lists the codes
|
|
19
|
+
* and labels left unmapped on purpose.
|
|
18
20
|
*
|
|
19
21
|
* Provenance: the enumeration, the scan codes and their English labels are
|
|
20
22
|
* what the myDPD guest API returns for Swiss consignee lookups; the wording
|
|
@@ -22,6 +24,7 @@
|
|
|
22
24
|
*/
|
|
23
25
|
import type { CarrierStatus } from '../../core/result/index.js';
|
|
24
26
|
import type { Stage } from '../../core/status/index.js';
|
|
27
|
+
import type { CarrierStatusMap } from '../../core/status/statusMap.js';
|
|
25
28
|
/** English labels for the guest API enumeration, used when the API sends no translation. */
|
|
26
29
|
export declare const API_LABELS: Record<string, string>;
|
|
27
30
|
/** Wording classifier for the rendered page, which carries no status codes. */
|
|
@@ -37,3 +40,10 @@ export declare function scanStage(code: string): Stage | null;
|
|
|
37
40
|
* with no place. Paperwork, not a movement of the parcel.
|
|
38
41
|
*/
|
|
39
42
|
export declare const PROOF_OF_DELIVERY_SCAN = "DEYY";
|
|
43
|
+
/**
|
|
44
|
+
* What the map says about one scan. A scan code or an enumeration value is all
|
|
45
|
+
* it reads: the rendered page's prose has no code and gets no stage here, and
|
|
46
|
+
* a code staged by its enumeration twin depends on the reply, so it is not
|
|
47
|
+
* answered by the code alone.
|
|
48
|
+
*/
|
|
49
|
+
export declare const statusMap: CarrierStatusMap;
|
|
@@ -73,6 +73,8 @@ export function apiStage(description) {
|
|
|
73
73
|
* `parcelEvents[].eventType` scan codes. On 2026-09-26 a verified lookup
|
|
74
74
|
* listed ORI, DLI, DLO and DEY at the same wall clock as the `parcelHistory`
|
|
75
75
|
* enumeration named beside them. CCO has no twin; it ends customs clearance.
|
|
76
|
+
* HUI, HUS, DLS and DLQ are the hub and delivery-depot scans a verified
|
|
77
|
+
* domestic history lists between ORI and DLO, each labelled with one movement.
|
|
76
78
|
* ORI ("Origin depot - In") stays unmapped like its twin PARCEL_HANDED: the
|
|
77
79
|
* result stage then comes from the same wording as the scan's, and an import
|
|
78
80
|
* that cleared customs does not step back to accepted. Other codes stay
|
|
@@ -80,7 +82,11 @@ export function apiStage(description) {
|
|
|
80
82
|
*/
|
|
81
83
|
const SCAN_STAGES = {
|
|
82
84
|
CCO: 'in_transit', // "Customs - Out"
|
|
85
|
+
HUI: 'in_transit', // "Your parcel arrived at our hub"
|
|
86
|
+
HUS: 'in_transit', // "Your parcel is ready to be transported to our next premises"
|
|
83
87
|
DLI: 'in_transit', // "Destination depot - Inbound", twin AT_DELIVERY_CENTER
|
|
88
|
+
DLS: 'in_transit', // "Your parcel has been sorted and is ready for delivery"
|
|
89
|
+
DLQ: 'in_transit', // "Your parcel is at our delivery depot, it will soon be on its way"
|
|
84
90
|
DLO: 'out_for_delivery', // "Destination depot - Out for delivery", twin PARCEL_OUT_FOR_DELIVERY
|
|
85
91
|
DEY: 'delivered', // "Delivery - Delivered", twin DELIVERED
|
|
86
92
|
};
|
|
@@ -93,3 +99,27 @@ export function scanStage(code) {
|
|
|
93
99
|
* with no place. Paperwork, not a movement of the parcel.
|
|
94
100
|
*/
|
|
95
101
|
export const PROOF_OF_DELIVERY_SCAN = 'DEYY';
|
|
102
|
+
const MOVES_WITHOUT_MILESTONE = "DPD's map leaves it unmapped on purpose: it moves the parcel in transit without a milestone of its own.";
|
|
103
|
+
/**
|
|
104
|
+
* What the map says about one scan. A scan code or an enumeration value is all
|
|
105
|
+
* it reads: the rendered page's prose has no code and gets no stage here, and
|
|
106
|
+
* a code staged by its enumeration twin depends on the reply, so it is not
|
|
107
|
+
* answered by the code alone.
|
|
108
|
+
*/
|
|
109
|
+
export const statusMap = {
|
|
110
|
+
stage: (code) => (code ? scanStage(code) ?? apiStage(code) : null) ?? undefined,
|
|
111
|
+
gaps: [
|
|
112
|
+
{ code: 'PARCEL_HANDED', note: MOVES_WITHOUT_MILESTONE },
|
|
113
|
+
{ code: 'IN_TRANSIT', note: MOVES_WITHOUT_MILESTONE },
|
|
114
|
+
{ code: 'AT_DELIVERY_CENTER', note: MOVES_WITHOUT_MILESTONE },
|
|
115
|
+
{ code: 'ORI', note: "DPD's map leaves it unmapped on purpose, like its twin PARCEL_HANDED, so an import that cleared customs does not step back to accepted." },
|
|
116
|
+
{ wording: 'parcel handed to dpd', note: "The label of PARCEL_HANDED, which DPD's map leaves unmapped on purpose." },
|
|
117
|
+
{ wording: 'your parcel is on its way', note: "The label of IN_TRANSIT, which DPD's map leaves unmapped on purpose." },
|
|
118
|
+
{ wording: 'at delivery center', note: "The label of AT_DELIVERY_CENTER, which DPD's map leaves unmapped on purpose." },
|
|
119
|
+
{ code: 'SPL', note: 'Worded like IN_TRANSIT and seen on both sides of the origin depot, so it names no movement of its own.' },
|
|
120
|
+
{ code: 'OTHER', note: "The guest API's catch-all, which names no movement." },
|
|
121
|
+
{ code: 'SPE', note: 'A delivery estimate or a changed delivery day, not a scan.' },
|
|
122
|
+
{ code: 'MSDLO', note: 'The notice DPD emailed for the delivery round, not a scan.' },
|
|
123
|
+
{ code: 'MIDLI', note: "The recipient's delivery instruction, not a scan." },
|
|
124
|
+
],
|
|
125
|
+
};
|