universal-parcel-scraper 0.1184.0-main.6913 → 0.1186.2-main.6922
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 +2 -2
- package/data/catalog.json +1 -1
- package/data/coverage-summary.json +1 -1
- package/data/detection-golden.json +30 -0
- package/dist/browser/scraper.js +5 -2
- package/dist/carriers/apg-ecommerce/adapter.d.ts +13 -0
- package/dist/carriers/apg-ecommerce/adapter.js +40 -0
- package/dist/carriers/apg-ecommerce/carrier.json +12 -6
- package/dist/carriers/apg-ecommerce/numbers.json +37 -0
- package/dist/carriers/apg-ecommerce/parser.d.ts +6 -0
- package/dist/carriers/apg-ecommerce/parser.js +93 -0
- package/dist/carriers/apg-ecommerce/status.d.ts +2 -0
- package/dist/carriers/apg-ecommerce/status.js +15 -0
- package/dist/carriers/apg-ecommerce/statuses.json +11 -1
- package/dist/carriers/huahan/status.js +4 -1
- package/dist/carriers/huahan/statuses.json +3 -1
- package/dist/carriers/jd-logistics/status.js +3 -0
- package/dist/carriers/jd-logistics/statuses.json +14 -0
- package/dist/carriers/shouwu/status.js +7 -1
- package/dist/carriers/shouwu/statuses.json +40 -0
- package/dist/carriers/sxw-express/statuses.json +2 -0
- package/dist/carriers/wanbexpress/adapter.js +4 -4
- package/dist/carriers/wanbexpress/parser.d.ts +3 -0
- package/dist/carriers/wanbexpress/parser.js +24 -5
- package/dist/carriers/yanwen/status.js +5 -0
- package/dist/carriers/yanwen/statuses.json +32 -0
- package/dist/core/status/language.js +13 -2
- package/dist/data/catalog.json +1 -1
- package/dist/generated/catalog.js +1 -1
- package/dist/generated/registry.js +3 -1
- package/dist/server/openapi.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ The engine behind [Peek](https://peektracker.com) ([GitHub](https://github.com/p
|
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
|
|
15
15
|
<!-- GENERATED:summary -->
|
|
16
|
-
**3,500+ carriers** through **
|
|
16
|
+
**3,500+ carriers** through **811 dedicated adapters** and **5 universal fallbacks**
|
|
17
17
|
|
|
18
18
|
<sub>1857 catalog entries · 165 countries represented</sub>
|
|
19
19
|
<!-- /GENERATED:summary -->
|
|
@@ -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 21,
|
|
167
|
+
The carrier folders record 21,038 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.
|
package/data/catalog.json
CHANGED
|
@@ -9213,7 +9213,7 @@
|
|
|
9213
9213
|
"timezone": "Europe/London",
|
|
9214
9214
|
"tracking": {
|
|
9215
9215
|
"mode": "automatic",
|
|
9216
|
-
"adapter": "
|
|
9216
|
+
"adapter": "apg-ecommerce"
|
|
9217
9217
|
},
|
|
9218
9218
|
"canaryUrl": "https://apgecommerce.com/track/",
|
|
9219
9219
|
"trackingUrlTemplate": "https://apgecommerce.com/track-result/?track_sequenceNo={trackingNumber}",
|
|
@@ -9221,6 +9221,36 @@
|
|
|
9221
9221
|
"j-and-t"
|
|
9222
9222
|
]
|
|
9223
9223
|
},
|
|
9224
|
+
{
|
|
9225
|
+
"input": "05113004871574",
|
|
9226
|
+
"carrier": "unknown",
|
|
9227
|
+
"confidence": "low",
|
|
9228
|
+
"candidates": [
|
|
9229
|
+
"dpd",
|
|
9230
|
+
"dpd-fr",
|
|
9231
|
+
"mondial-relay",
|
|
9232
|
+
"chronopost",
|
|
9233
|
+
"ciblex",
|
|
9234
|
+
"seur",
|
|
9235
|
+
"brt",
|
|
9236
|
+
"dhl-ecommerce-uk",
|
|
9237
|
+
"dpd-be",
|
|
9238
|
+
"dpd-de",
|
|
9239
|
+
"dpd-hu",
|
|
9240
|
+
"dpd-nl",
|
|
9241
|
+
"dpd-pt",
|
|
9242
|
+
"dpd-uk",
|
|
9243
|
+
"gls-nl",
|
|
9244
|
+
"jadlog"
|
|
9245
|
+
],
|
|
9246
|
+
"asked": [
|
|
9247
|
+
"dpd-be",
|
|
9248
|
+
"dpd",
|
|
9249
|
+
"dpd-nl",
|
|
9250
|
+
"dpd-de",
|
|
9251
|
+
"chronopost"
|
|
9252
|
+
]
|
|
9253
|
+
},
|
|
9224
9254
|
{
|
|
9225
9255
|
"input": "05117981889732",
|
|
9226
9256
|
"carrier": "unknown",
|
package/dist/browser/scraper.js
CHANGED
|
@@ -7208,7 +7208,7 @@ var t = {
|
|
|
7208
7208
|
timezone: "Europe/London",
|
|
7209
7209
|
tracking: {
|
|
7210
7210
|
mode: "automatic",
|
|
7211
|
-
adapter: "
|
|
7211
|
+
adapter: "apg-ecommerce"
|
|
7212
7212
|
},
|
|
7213
7213
|
canaryUrl: "https://apgecommerce.com/track/",
|
|
7214
7214
|
trackingUrlTemplate: "https://apgecommerce.com/track-result/?track_sequenceNo={trackingNumber}",
|
|
@@ -57693,8 +57693,11 @@ function Wd(e) {
|
|
|
57693
57693
|
if (/accepted|(?<!\b(?:be|being) )picked up|pick up was successful|^drop off$|pick ?up scan|prepared the package for return to ups or pickup by ups|handed (?:over )?to (?:dpd|gls)|package received at dhl|item booked|consignment was mailed|posted at (?:a |the )?(?:postal point|post office)|pris en charge|prise en charge|collecte.*(?:reussi|effectue)|recupere.*boite aux lettres|depose.*point postal|remis a (?:dpd|gls)|envoi.*depose|abholung.*erfolgreich|^(?:die sendung wurde )?erfolgreich abgeholt$|eingeliefert|an (?:dpd|gls) ubergeben|paket.*(?:angenommen|ubernommen)|ritiro.*(?:riuscito|effettuato)|pres[oa] in carico|affidat[oa] a (?:dpd|gls)|depositat.*punto postale|spedizione.*impostata/.test(t) || /^到达收货点|^item received by royal mail$|\btaken over by one of our operators\b|\bwe've received your (?:parcel|package|item) at the parcel ?shop\b|^(?:(?:the |your )?(?:item|parcel|package|shipment) )?(?:was|has been) dropped off at (?:the |a )?parcel ?shop$|^(?![^,]*\b(?:recipient|consignee|receiver|customer|addressee|buyer|pick ?up point|parcel ?shop|locker|destination)\b)[a-z][\w&' -]{0,40} has received the goods(?:, [^,]{1,40}){0,2}\.?$|^the shipment has been deposited at a seur pickup point$|^(?:the |your )?collection (?:has been |was )?(?:carried out|completed)$|^已入库|^(?:(?:the |your )?(?:item|parcel|package|shipment) )?(?:has been |was )?put into storage$/.test(t) || /^(?:the )?(?:shipment|parcel|package|item) (?:has been|was) handed in (?:to|at) (?!.*\breturn)[^.;]{1,80}$/.test(t) || /^sender advised item dropped off at parcel locker$|^dropped off at postbox$/.test(t) || /^(?:the )?shipment has been taken over at the post (?:office|locker) point$/.test(t) || /^spedizione affidata a una fedex location\b/.test(t) || /^die sendung wurde vom absender (?:im|in der|in einem|in einer) (?:[\w-]+ )?(?:paketshop|parcelshop|filiale)\b(?!.*\bnicht\b).*\babgegeben$/.test(t) || /^(?:the |your )?(?:package|parcel|shipment) (?:was|has been) dropped off by the sender at (?:the |a )?(?:hermes )?(?:paketshop|parcel ?shop)\b/.test(t) || /^sending the (?:package|parcel) at the pick ?up point$|^handing over the (?:package|parcel) to the courier$/.test(t)) return "accepted";
|
|
57694
57694
|
if (/^warehouse reading$/.test(t) || /^acceptance of the (?:package|parcel) at the delivery branch abroad$/.test(t)) return "in_transit";
|
|
57695
57695
|
if (/^acceptance of the (?:package|parcel) at the pick ?up point$/.test(t) || /^(?:(?:the )?item )?(?:arrival|arrived|receive item) at (?:the )?collection point (?:for pick ?up|waiting for (?:your |the )?collect(?:ion)?)\b/.test(t)) return "ready_for_pickup";
|
|
57696
|
+
if (/^(?:inward|outward) mc (?:[a-z]+ )?acceptance$/.test(t)) return "in_transit";
|
|
57697
|
+
if (/^orden de (?:pedido|compra) recibida\b/.test(t)) return "registered";
|
|
57698
|
+
if (/^carga consolidada para importacion recibida$|^ingreso a (?:la )?bodega$/.test(t)) return "in_transit";
|
|
57696
57699
|
if (/^(?:package|parcel) received (?:&|and) scanned at (?:the )?carrier's domestic warehouse$/.test(t) || /^(?:the )?goods (?:arrive|arrived|have arrived) at (?:the )?receiving point$/.test(t) || /(?<!\b(?:no|nao) )\badmitid[oa]s?\b|\badmision (?:en origen|pais de origen)\b/.test(t) || /^aceite(?:\.|$)|\b(?:envio|objeto|objecto|encomenda|remessa) foi aceite\b/.test(t)) return "accepted";
|
|
57697
|
-
if (/\bcross ?dock(?:ed|ing)?\b|\bready for outbound\b|^(?:(?:item|parcel|package|shipment) )?inbound scan(?:ned|ning)?\b|\b(?:un)?bagg(?:ed|ing)\b|\bmaster (?:air ?way ?bill|awb)(?: (?:number|no))? (?:received|assigned|allocated)\b|\bhand ?over to (?:the |an )?(?:airline|air carrier)\b|^(?:(?:the |your )?(?:item|parcel|package|shipment) )?(?:has )?left (?:the|our) warehouse$|\b(?:flight|leg)\b[^.;]*\b(?:is taking off|took off|has taken off|has left|landed)\b|\bflight (?:take ?off|landing)\b|^(?:initial|final) landing$|\bcargo tally in the supervised warehouse\b|\bprepared for (?:the )?last[- ]mile hand ?over\b/.test(t) || /^(?:the )?noa (?:has been |was )?received$|^noa-notification of arrival\b/.test(t) || /^(?:the |your )?(?:parcel|package|shipment|item) is (?:now )?at (?:the |a )?distribution cent(?:er|re)$/.test(t) || /^l'envoi est dans le reseau de livraison local$/.test(t) || /^there (?:has|have) been (?:a |an )?(?:slight |short |small |unexpected )?delay (?:with|to|in) (?:your |the )?(?:delivery|parcel|package|shipment|order)\.?$/.test(t) || /\b(?:parcel|package|shipment|item) has been sent to (?!(?:the |your |a )?(?:recipient|customer|consignee|addressee|buyer|customs|sender|shipper|seller|merchant|origin|return\w*)\b)/.test(t) || /^scanned (?:in)?to (?:a |the )?container$|^mis ?rout(?:e|ed)$/.test(t) || /transit|\bline ?haul\b|en route|on (?:its|the) way|\bfacility\b|airport|\bleaving\b|\bdispatched\b|^delay(?:ed)?$|received by (?:the )?(?:local )?(?:delivery|logistics) company|\btransfer to (?:the |a |an )?(?:local |destination )?(?:acting |delivery |logistics |courier )?(?:company|agent|carrier|partner)\b|received by (?:postnl|uniuni)\b|notification.*sent to the recipient|delivery option requested|instruction de livraison recue|cambio (?:delle )?disposizioni di consegna|expedie (?:depuis|du|de)\b|acheminement|unterwegs|\bin viaggio\b|\bw drodze\b|\bonderweg\b|transport|trasport|arriv|depart|processed|processing completed|processing at (?:the )?(?:origin |destination )?branch\b|\breceipt of (?:the )?(?:package|parcel|shipment) at (?:the )?dpd branch\b|sorted|sorting|\btri\b|\btriee?s?\b|traitement|traite|sortier|bearbeitet|bearbeitung|elaborat|elaborazion|smistat|parcel cent(?:er|re)|delivery cent(?:er|re)|centre.*(?:colis|distribution)|paketzentrum|verteilzentrum|centro.*(?:pacchi|distribuzione)|depot|import scan|scan.*import|importscan|scansione.*import|delivery.*delayed|livraison.*(?:retard|report)|zustellung.*verzogert|consegna.*ritard|transferred|transfere|weitergeleitet|inoltrato|left.*(?:point|center)|quitte|verlassen|raggiunto|close bag|fermeture du sac|sack.*geschlossen|chiusura.*sacco|scanned into|scanned at (?:a |the )?checkpoint|dismantling the board|scanne dans|eingescannt|scansionat|\b(?:un)?loaded\b|^(?:item|parcel|shipment) distributed$|charg.*vehicule de transport|transportfahrzeug.*geladen|caric.*veicolo.*trasporto/.test(t) || /^enviad[oa]$|\bclasificad[oa]s?\b|\bclasificacion\b|\ben ruta\b|\ben camino\b|\bcargad[oa]s? (?:en (?:el )?|al )vehiculo\b|\bllegad[oa]s? (?:a|al|en)\b|\bllegada (?:a|al|en|de)\b|\bha llegado\b|\bllego (?:a|al)\b|\bsalida (?:de|del|desde)\b|\b(?:ha )?salido (?:de|del)\b|\bsalio (?:de|del)\b|\ben destino\b|\b(?:agencia|delegacion|plataforma|oficina|franquicia) (?:de )?destino\b|\b(?:unidad|centro|oficina|delegacion|base|agencia|plataforma) de reparto\b|\bcentro (?:de )?(?:clasificacion|distribucion|tratamiento|logistico|operaciones|operativo)\b|\blectura\b|\bleid[oa]s?\b|\brecepcionad[oa]s?\b|\bprocesad[oa]s?\b|\bexpedid[oa]s?\b|\btriagem\b|\btriad[oa]s?\b|\bem tratamento\b|\btratad[oa]s?\b|\bcentro (?:de )?(?:distribuicao|tratamento|triagem|operacional)\b|\bchegad[ao] (?:a|ao|no|na|em)\b|\bchegou (?:a|ao|no|na|em)\b|\bsaida (?:do|da|de|dos|das)\b|\bsaiu (?:do|da|de|dos|das)\b|\bem rota\b|\ba caminho\b|\bencaminhad[oa]s?\b|\b(?:em )?transferencia\b|\btransferid[oa]s?\b|\bprocessad[oa]s?\b|\brecebid[oa] (?:no|na|em) (?:centro|armazem|unidade|plataforma)\b|\brecibid[oa] en (?:el |la |nuestr[oa] )?(?:almacen|centro|delegacion|plataforma|hub|agencia)\b/.test(t)) return "in_transit";
|
|
57700
|
+
if (/\bcross ?dock(?:ed|ing)?\b|\bready for outbound\b|^(?:(?:item|parcel|package|shipment) )?inbound scan(?:ned|ning)?\b|\b(?:un)?bagg(?:ed|ing)\b|\bmaster (?:air ?way ?bill|awb)(?: (?:number|no))? (?:received|assigned|allocated)\b|\bhand ?over to (?:the |an )?(?:airline|air carrier)\b|^(?:(?:the |your )?(?:item|parcel|package|shipment) )?(?:(?:has )?left|(?:has been |was )?shipped out of) (?:the|our) warehouse$|\b(?:flight|leg)\b[^.;]*\b(?:is taking off|took off|has taken off|has left|landed)\b|\bflight (?:take ?off|landing)\b|^(?:initial|final) landing$|\bcargo tally in the supervised warehouse\b|\bprepared for (?:the )?last[- ]mile hand ?over\b/.test(t) || /^(?:the )?noa (?:has been |was )?received$|^noa-notification of arrival\b/.test(t) || /^(?:the |your )?(?:parcel|package|shipment|item) is (?:now )?at (?:the |a )?distribution cent(?:er|re)$/.test(t) || /^l'envoi est dans le reseau de livraison local$/.test(t) || /^there (?:has|have) been (?:a |an )?(?:slight |short |small |unexpected )?delay (?:with|to|in) (?:your |the )?(?:delivery|parcel|package|shipment|order)\.?$/.test(t) || /\b(?:parcel|package|shipment|item) has been sent to (?!(?:the |your |a )?(?:recipient|customer|consignee|addressee|buyer|customs|sender|shipper|seller|merchant|origin|return\w*)\b)/.test(t) || /^scanned (?:in)?to (?:a |the )?container$|^mis ?rout(?:e|ed)$/.test(t) || /transit|\bline ?haul\b|en route|on (?:its|the) way|\bfacility\b|airport|\bleaving\b|\bdispatched\b|^delay(?:ed)?$|received by (?:the )?(?:local )?(?:delivery|logistics) company|\btransfer to (?:the |a |an )?(?:local |destination )?(?:acting |delivery |logistics |courier )?(?:company|agent|carrier|partner)\b|received by (?:postnl|uniuni)\b|notification.*sent to the recipient|delivery option requested|instruction de livraison recue|cambio (?:delle )?disposizioni di consegna|expedie (?:depuis|du|de)\b|acheminement|unterwegs|\bin viaggio\b|\bw drodze\b|\bonderweg\b|transport|trasport|arriv|depart|processed|processing completed|processing at (?:the )?(?:origin |destination )?branch\b|\breceipt of (?:the )?(?:package|parcel|shipment) at (?:the )?dpd branch\b|sorted|sorting|\btri\b|\btriee?s?\b|traitement|traite|sortier|bearbeitet|bearbeitung|elaborat|elaborazion|smistat|parcel cent(?:er|re)|delivery cent(?:er|re)|centre.*(?:colis|distribution)|paketzentrum|verteilzentrum|centro.*(?:pacchi|distribuzione)|depot|import scan|scan.*import|importscan|scansione.*import|delivery.*delayed|livraison.*(?:retard|report)|zustellung.*verzogert|consegna.*ritard|transferred|transfere|weitergeleitet|inoltrato|left.*(?:point|center)|quitte|verlassen|raggiunto|close bag|fermeture du sac|sack.*geschlossen|chiusura.*sacco|scanned into|scanned at (?:a |the )?checkpoint|dismantling the board|scanne dans|eingescannt|scansionat|\b(?:un)?loaded\b|^(?:item|parcel|shipment) distributed$|charg.*vehicule de transport|transportfahrzeug.*geladen|caric.*veicolo.*trasporto/.test(t) || /^enviad[oa]$|\bclasificad[oa]s?\b|\bclasificacion\b|\ben ruta\b|\ben camino\b|\bcargad[oa]s? (?:en (?:el )?|al )vehiculo\b|\bllegad[oa]s? (?:a|al|en)\b|\bllegada (?:a|al|en|de)\b|\bha llegado\b|\bllego (?:a|al)\b|\bsalida (?:de|del|desde)\b|\b(?:ha )?salido (?:de|del)\b|\bsalio (?:de|del)\b|\ben destino\b|\b(?:agencia|delegacion|plataforma|oficina|franquicia) (?:de )?destino\b|\b(?:unidad|centro|oficina|delegacion|base|agencia|plataforma) de reparto\b|\bcentro (?:de )?(?:clasificacion|distribucion|tratamiento|logistico|operaciones|operativo)\b|\blectura\b|\bleid[oa]s?\b|\brecepcionad[oa]s?\b|\bprocesad[oa]s?\b|\bexpedid[oa]s?\b|\btriagem\b|\btriad[oa]s?\b|\bem tratamento\b|\btratad[oa]s?\b|\bcentro (?:de )?(?:distribuicao|tratamento|triagem|operacional)\b|\bchegad[ao] (?:a|ao|no|na|em)\b|\bchegou (?:a|ao|no|na|em)\b|\bsaida (?:do|da|de|dos|das)\b|\bsaiu (?:do|da|de|dos|das)\b|\bem rota\b|\ba caminho\b|\bencaminhad[oa]s?\b|\b(?:em )?transferencia\b|\btransferid[oa]s?\b|\bprocessad[oa]s?\b|\brecebid[oa] (?:no|na|em) (?:centro|armazem|unidade|plataforma)\b|\brecibid[oa] en (?:el |la |nuestr[oa] )?(?:almacen|centro|delegacion|plataforma|hub|agencia)\b/.test(t)) return "in_transit";
|
|
57698
57701
|
if (/^(?:приинято|принято)$/.test(t)) return "accepted";
|
|
57699
57702
|
if (nd.test(t)) return "in_transit";
|
|
57700
57703
|
let a = ad(t);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AdapterFactory, TrackingContext } from '../../core/adapter/index.js';
|
|
2
|
+
import type { CarrierResult } from '../../core/result/index.js';
|
|
3
|
+
import { type StepRecorder } from '../../core/telemetry/index.js';
|
|
4
|
+
export declare class ApgEcommerceTracker {
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(options?: {
|
|
7
|
+
fetcher?: typeof fetch;
|
|
8
|
+
userAgent?: string;
|
|
9
|
+
recorder?: StepRecorder;
|
|
10
|
+
});
|
|
11
|
+
fetch(raw: string, context?: TrackingContext): Promise<CarrierResult>;
|
|
12
|
+
}
|
|
13
|
+
export declare const adapter: AdapterFactory;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ChallengeError, TransportError } from '../../core/errors/index.js';
|
|
2
|
+
import { runSteps } from '../../core/runner/index.js';
|
|
3
|
+
import { firstAttemptMs, networkRetryStep } from '../../core/runner/networkRetry.js';
|
|
4
|
+
import { NOOP_RECORDER } from '../../core/telemetry/index.js';
|
|
5
|
+
import { decodeText, fetchBounded } from '../../core/transport/boundedFetch.js';
|
|
6
|
+
import { userAgentOf } from '../../core/transport/userAgent.js';
|
|
7
|
+
import { APG_MAX_BYTES, apgTrackingUrl, normalizeApgReference, parseApgHistory, PROVIDER } from './parser.js';
|
|
8
|
+
export class ApgEcommerceTracker {
|
|
9
|
+
options;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
async fetch(raw, context = {}) {
|
|
14
|
+
context.signal?.throwIfAborted();
|
|
15
|
+
const number = normalizeApgReference(raw);
|
|
16
|
+
const url = apgTrackingUrl(number);
|
|
17
|
+
const read = async (signal, timeoutMs) => {
|
|
18
|
+
const { response, bytes } = await fetchBounded(url, { signal,
|
|
19
|
+
headers: { Accept: 'text/html', 'User-Agent': userAgentOf(this.options.userAgent) } }, { provider: PROVIDER, fetcher: this.options.fetcher, timeoutMs, maxBytes: APG_MAX_BYTES, redirect: 'manual',
|
|
20
|
+
allowHttpStatuses: [301, 302, 303, 307, 308, 401, 403, 404, 410] });
|
|
21
|
+
signal.throwIfAborted();
|
|
22
|
+
if ([401, 403].includes(response.status) || response.headers.get('cf-mitigated') === 'challenge') {
|
|
23
|
+
throw new ChallengeError(PROVIDER, 'APG refused guest tracking', { status: response.status });
|
|
24
|
+
}
|
|
25
|
+
if (response.status !== 200 || response.url && response.url !== url) {
|
|
26
|
+
throw new TransportError(PROVIDER, 'APG tracking route is unavailable', { status: response.status });
|
|
27
|
+
}
|
|
28
|
+
return parseApgHistory(decodeText(bytes), number);
|
|
29
|
+
};
|
|
30
|
+
return runSteps({ carrier: 'apg-ecommerce', budgetMs: context.budgetMs ?? 15_000, signal: context.signal,
|
|
31
|
+
recorder: this.options.recorder ?? NOOP_RECORDER }, [
|
|
32
|
+
{ id: 'direct', run: ({ signal, remainingMs }) => read(signal, firstAttemptMs(remainingMs)) },
|
|
33
|
+
networkRetryStep(({ signal, remainingMs }) => read(signal, remainingMs)),
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export const adapter = environment => {
|
|
38
|
+
const tracker = new ApgEcommerceTracker({ fetcher: environment.fetcher, userAgent: environment.userAgent, recorder: environment.recorder });
|
|
39
|
+
return { id: 'apg-ecommerce', recordsSteps: true, steps: ['direct', 'retry'], track: (input, context) => tracker.fetch(input.number, context) };
|
|
40
|
+
};
|
|
@@ -22,17 +22,23 @@
|
|
|
22
22
|
"timezone": "Europe/London",
|
|
23
23
|
"tracking": {
|
|
24
24
|
"mode": "automatic",
|
|
25
|
-
"adapter": "
|
|
26
|
-
"steps": [
|
|
25
|
+
"adapter": "apg-ecommerce",
|
|
26
|
+
"steps": [
|
|
27
|
+
"direct",
|
|
28
|
+
"retry"
|
|
29
|
+
]
|
|
27
30
|
},
|
|
28
|
-
"capabilities": [
|
|
31
|
+
"capabilities": [
|
|
32
|
+
"history",
|
|
33
|
+
"location"
|
|
34
|
+
],
|
|
29
35
|
"portal": {
|
|
30
36
|
"url": "https://apgecommerce.com/track-result/?track_sequenceNo={trackingNumber}",
|
|
31
37
|
"searchUrl": "https://apgecommerce.com/track/",
|
|
32
38
|
"canaryUrl": "https://apgecommerce.com/track/",
|
|
33
|
-
"shows": [],
|
|
34
|
-
"scraped": [],
|
|
35
|
-
"discarded": [],
|
|
39
|
+
"shows": ["status", "history", "location"],
|
|
40
|
+
"scraped": ["status", "history", "location"],
|
|
41
|
+
"discarded": ["merchant reference", "detailed event text"],
|
|
36
42
|
"unavailable": []
|
|
37
43
|
},
|
|
38
44
|
"links": [
|
|
@@ -72,6 +72,43 @@
|
|
|
72
72
|
]
|
|
73
73
|
},
|
|
74
74
|
"note": "A reference the tracker of Aramex Global Solutions, APG's former name, answered with its history, as an archived page shows."
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"number": "05113004871574",
|
|
78
|
+
"role": "shipment",
|
|
79
|
+
"evidence": "public_shipment_report",
|
|
80
|
+
"source": {
|
|
81
|
+
"url": "https://web.archive.org/web/20260824140605id_/https://apgecommerce.com/track-result/?track_sequenceNo=05113004871574",
|
|
82
|
+
"date": "2026-08-24",
|
|
83
|
+
"dateKind": "capture",
|
|
84
|
+
"access": "full_page"
|
|
85
|
+
},
|
|
86
|
+
"context": {
|
|
87
|
+
"assessment": "confirmed"
|
|
88
|
+
},
|
|
89
|
+
"expect": {
|
|
90
|
+
"carrier": "unknown",
|
|
91
|
+
"confidence": "low",
|
|
92
|
+
"candidates": [
|
|
93
|
+
"dpd",
|
|
94
|
+
"dpd-fr",
|
|
95
|
+
"mondial-relay",
|
|
96
|
+
"chronopost",
|
|
97
|
+
"ciblex",
|
|
98
|
+
"seur",
|
|
99
|
+
"brt",
|
|
100
|
+
"dhl-ecommerce-uk",
|
|
101
|
+
"dpd-be",
|
|
102
|
+
"dpd-de",
|
|
103
|
+
"dpd-hu",
|
|
104
|
+
"dpd-nl",
|
|
105
|
+
"dpd-pt",
|
|
106
|
+
"dpd-uk",
|
|
107
|
+
"gls-nl",
|
|
108
|
+
"jadlog"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"note": "Public capture of the APG result page. The same tracking reference returns dated carrier scans in the current guest tracker."
|
|
75
112
|
}
|
|
76
113
|
]
|
|
77
114
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CarrierResult } from '../../core/result/index.js';
|
|
2
|
+
export declare const PROVIDER = "APG eCommerce Solutions";
|
|
3
|
+
export declare const APG_MAX_BYTES: number;
|
|
4
|
+
export declare function normalizeApgReference(raw: string): string;
|
|
5
|
+
export declare function apgTrackingUrl(number: string): string;
|
|
6
|
+
export declare function parseApgHistory(html: string, number: string): CarrierResult;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { load } from 'cheerio';
|
|
2
|
+
import { normalizeTrackingNumber } from '../../core/detection/normalize.js';
|
|
3
|
+
import { ChallengeError, InvalidInputError, NoHistoryError, NotFoundError, SchemaError } from '../../core/errors/index.js';
|
|
4
|
+
import { hasPrivateDeliveryDetails, languageStageStatus } from '../../core/status/index.js';
|
|
5
|
+
import { calendarDay } from '../../core/time/index.js';
|
|
6
|
+
import { clean } from '../../core/transport/text.js';
|
|
7
|
+
import { apgEcommerceStage } from './status.js';
|
|
8
|
+
export const PROVIDER = 'APG eCommerce Solutions';
|
|
9
|
+
export const APG_MAX_BYTES = 1024 * 1024;
|
|
10
|
+
const TRACKER = 'https://apgecommerce.com/track-result/';
|
|
11
|
+
const BLOCKED = /_cf_chl_opt|<title>\s*(?:Just a moment|Attention Required|Access Denied)|verify (?:that )?you are human/i;
|
|
12
|
+
const COLUMNS = ['Date', 'Local Time', 'Location', 'Event', 'Event Description'];
|
|
13
|
+
export function normalizeApgReference(raw) {
|
|
14
|
+
const number = typeof raw === 'string' && raw.length <= 64 ? normalizeTrackingNumber(raw) : '';
|
|
15
|
+
if (!/^[A-Z0-9]{5,40}$/.test(number))
|
|
16
|
+
throw new InvalidInputError(PROVIDER, 'APG needs a shipment reference');
|
|
17
|
+
if (!/^\d{14}$/.test(number)) {
|
|
18
|
+
throw new NoHistoryError(PROVIDER, 'APG guest history supports its fourteen-digit tracking reference', { reason: 'unsupported_reference' });
|
|
19
|
+
}
|
|
20
|
+
return number;
|
|
21
|
+
}
|
|
22
|
+
export function apgTrackingUrl(number) {
|
|
23
|
+
return TRACKER + '?' + new URLSearchParams({ track_sequenceNo: number }).toString();
|
|
24
|
+
}
|
|
25
|
+
function timestamp(date, time) {
|
|
26
|
+
const parts = /^(\d{2})\/(\d{2})\/(\d{2})$/.exec(date);
|
|
27
|
+
const day = parts && calendarDay(2000 + Number(parts[3]), Number(parts[2]), Number(parts[1]));
|
|
28
|
+
const clock = /^((?:[01]\d|2[0-3]):[0-5]\d) GMT$/.exec(time);
|
|
29
|
+
if (!day || !clock)
|
|
30
|
+
throw new SchemaError(PROVIDER, 'APG returned an unsupported scan clock');
|
|
31
|
+
return `${day}T${clock[1]}:00Z`;
|
|
32
|
+
}
|
|
33
|
+
export function parseApgHistory(html, number) {
|
|
34
|
+
if (new TextEncoder().encode(html).byteLength > APG_MAX_BYTES)
|
|
35
|
+
throw new SchemaError(PROVIDER, 'APG returned an oversized tracking page');
|
|
36
|
+
if (BLOCKED.test(html))
|
|
37
|
+
throw new ChallengeError(PROVIDER, 'APG returned browser verification');
|
|
38
|
+
const $ = load(html);
|
|
39
|
+
const root = $('.tracking-elements > .tracking');
|
|
40
|
+
const title = root.find('.tracking-head > #tracking-title');
|
|
41
|
+
if (root.length !== 1 || title.length !== 1 || !/APG\s+eCommerce/i.test($('title').text())) {
|
|
42
|
+
throw new SchemaError(PROVIDER, 'APG returned no unique tracking result');
|
|
43
|
+
}
|
|
44
|
+
const heading = clean(title.text());
|
|
45
|
+
const missing = /^Reference No\. (\d{14})$/i.exec(heading);
|
|
46
|
+
const body = root.children('.traking-body');
|
|
47
|
+
if (missing?.[1] === number && !body.length && !root.find('table').length) {
|
|
48
|
+
const status = root.find('.tracking-status-text');
|
|
49
|
+
if (status.length === 1 && /^Sorry, order not found$/i.test(clean(status.text())))
|
|
50
|
+
throw new NotFoundError(PROVIDER);
|
|
51
|
+
throw new NoHistoryError(PROVIDER, 'APG returned a reference without a tracking history');
|
|
52
|
+
}
|
|
53
|
+
const tracked = /^Order No\. [A-Z0-9-]{1,80} \/ Tracking No\. (\d{14})$/i.exec(heading);
|
|
54
|
+
if (tracked?.[1] !== number)
|
|
55
|
+
throw new SchemaError(PROVIDER, 'APG returned a result for another reference');
|
|
56
|
+
const table = body.find('div.tracking-table > table');
|
|
57
|
+
const headers = table.find('thead > tr > th').toArray().map(cell => clean($(cell).text()));
|
|
58
|
+
const rows = table.find('tbody > tr').toArray();
|
|
59
|
+
if (body.length !== 1 || table.length !== 1 || table.children('tbody').length !== 1
|
|
60
|
+
|| headers.length !== COLUMNS.length || !COLUMNS.every((column, index) => headers[index] === column) || rows.length > 500) {
|
|
61
|
+
throw new SchemaError(PROVIDER, 'APG changed its scan table');
|
|
62
|
+
}
|
|
63
|
+
const events = [];
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
for (const row of rows) {
|
|
66
|
+
const columns = $(row).children('td');
|
|
67
|
+
if (columns.length !== COLUMNS.length)
|
|
68
|
+
throw new SchemaError(PROVIDER, 'APG returned an invalid scan row');
|
|
69
|
+
const date = clean(columns.eq(0).text()), time = clean(columns.eq(1).text());
|
|
70
|
+
const location = clean(columns.eq(2).text()), description = clean(columns.eq(4).text());
|
|
71
|
+
if (!description || description.length > 140 || /[\d@<>]|https?:/i.test(description) || hasPrivateDeliveryDetails(description)
|
|
72
|
+
|| (location && !/^[A-Z]{2}$/.test(location))) {
|
|
73
|
+
throw new SchemaError(PROVIDER, 'APG returned an invalid scan description or location');
|
|
74
|
+
}
|
|
75
|
+
const stage = apgEcommerceStage(description);
|
|
76
|
+
const scan = { time: timestamp(date, time), description, ...(location ? { location } : {}),
|
|
77
|
+
...(stage ? { stage, stage_source: 'carrier_map' } : {}) };
|
|
78
|
+
const key = JSON.stringify(scan);
|
|
79
|
+
if (!seen.has(key)) {
|
|
80
|
+
seen.add(key);
|
|
81
|
+
events.push(scan);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!events.length)
|
|
85
|
+
throw new NoHistoryError(PROVIDER, 'APG returned a bound result without scans');
|
|
86
|
+
events.sort((a, b) => b.time.localeCompare(a.time));
|
|
87
|
+
const latest = events[0];
|
|
88
|
+
const stage = apgEcommerceStage(latest.description);
|
|
89
|
+
return { status: stage ? languageStageStatus(stage) : 'unknown',
|
|
90
|
+
...(stage ? { current_stage: stage, current_stage_source: 'carrier_map' } : {}),
|
|
91
|
+
last_update: latest.time, last_status_text: latest.description, expected_delivery: null,
|
|
92
|
+
events: events.slice(0, 100), ...(events.length > 100 ? { history_truncated: true } : {}) };
|
|
93
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { normalizeStatusWording } from '../../core/status/statusMap.js';
|
|
2
|
+
const stages = new Map([
|
|
3
|
+
['delivered', 'delivered'],
|
|
4
|
+
['out for delivery', 'out_for_delivery'],
|
|
5
|
+
['attempted delivery', 'failed_attempt'],
|
|
6
|
+
['parcel in transit back to sender', 'exception'],
|
|
7
|
+
['parcel processing at final carrier hub', 'in_transit'],
|
|
8
|
+
['in transit to local carrier', 'in_transit'],
|
|
9
|
+
['parcel to be delivered by local carrier', 'in_transit'],
|
|
10
|
+
['parcel cleared by customs', 'in_transit'],
|
|
11
|
+
['parcel processed', 'in_transit'],
|
|
12
|
+
]);
|
|
13
|
+
export function apgEcommerceStage(wording) {
|
|
14
|
+
return stages.get(normalizeStatusWording(wording));
|
|
15
|
+
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"carrier": "apg-ecommerce",
|
|
3
|
-
"entries": [
|
|
3
|
+
"entries": [
|
|
4
|
+
{"wording": "Delivered", "stage": "delivered", "language": "en", "confirmedBy": "portal"},
|
|
5
|
+
{"wording": "Out for Delivery", "stage": "out_for_delivery", "language": "en", "confirmedBy": "portal"},
|
|
6
|
+
{"wording": "Attempted Delivery", "stage": "failed_attempt", "language": "en", "confirmedBy": "portal"},
|
|
7
|
+
{"wording": "Parcel In Transit back to Sender", "stage": "exception", "language": "en", "confirmedBy": "portal"},
|
|
8
|
+
{"wording": "Parcel processing at final carrier Hub", "stage": "in_transit", "language": "en", "confirmedBy": "portal"},
|
|
9
|
+
{"wording": "In Transit to Local Carrier", "stage": "in_transit", "language": "en", "confirmedBy": "portal"},
|
|
10
|
+
{"wording": "Parcel to Be Delivered by Local Carrier", "stage": "in_transit", "language": "en", "confirmedBy": "portal"},
|
|
11
|
+
{"wording": "Parcel cleared by customs", "stage": "in_transit", "language": "en", "confirmedBy": "portal"},
|
|
12
|
+
{"wording": "Parcel Processed", "stage": "in_transit", "language": "en", "confirmedBy": "portal"}
|
|
13
|
+
]
|
|
4
14
|
}
|
|
@@ -69,9 +69,12 @@ const WORDINGS = new Map([
|
|
|
69
69
|
// China Post's receipt on the postal line, after HuaHan's own acceptance: the hand-over to the post.
|
|
70
70
|
['中国邮政已收取邮件', 'in_transit'],
|
|
71
71
|
// HuaHan's transfer warehouse taking the parcel in after its departure from the origin facility,
|
|
72
|
-
// and sending the shipments on before the export declaration
|
|
72
|
+
// and sending the shipments on before the export declaration; on another line, its collection
|
|
73
|
+
// there and its shipping out a day or two later, before the departure to the next facility.
|
|
73
74
|
['shipment received', 'in_transit'],
|
|
74
75
|
['shipments were sent', 'in_transit'],
|
|
76
|
+
['parcel has been collected.', 'in_transit'],
|
|
77
|
+
['parcel has been shipped out of the warehouse.', 'in_transit'],
|
|
75
78
|
]);
|
|
76
79
|
// Milestones in Chinese with the English after them, and lines with a day, a flight, a time or a place.
|
|
77
80
|
const PATTERNS = [
|
|
@@ -78,6 +78,8 @@
|
|
|
78
78
|
{"code": "CA", "wording": "Incoming scan at facility", "stage": "in_transit", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-09", "note": "Landmark Global's depot receipt after the hand-off to bpost's network."},
|
|
79
79
|
{"code": "CB", "wording": "Outgoing scan at facility", "stage": "in_transit", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-09", "note": "Landmark Global's depot departure under HuaHan's out-for-delivery code, days before a delivery round: the words decide."},
|
|
80
80
|
{"code": "ND", "wording": "Out for delivery (On the way)", "stage": "out_for_delivery", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-12", "note": "Landmark Global's relay of the destination round."},
|
|
81
|
-
{"wording": "Delivery attempt (Delivery not possible)", "stage": "failed_attempt", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-12", "note": "Landmark Global's relay of a round that did not deliver, without a code."}
|
|
81
|
+
{"wording": "Delivery attempt (Delivery not possible)", "stage": "failed_attempt", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-12", "note": "Landmark Global's relay of a round that did not deliver, without a code."},
|
|
82
|
+
{"wording": "Parcel has been collected.", "stage": "in_transit", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-14", "note": "HuaHan's transfer warehouse collecting the parcel the day after its departure from the origin facility, without a code."},
|
|
83
|
+
{"wording": "Parcel has been shipped out of the warehouse.", "stage": "in_transit", "language": "en", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "The same warehouse shipping the parcel out two days later, before its departure to the next facility."}
|
|
82
84
|
]
|
|
83
85
|
}
|
|
@@ -47,7 +47,10 @@ const CODES = new Map([
|
|
|
47
47
|
['200077', MOVING],
|
|
48
48
|
['200019', MOVING],
|
|
49
49
|
['200000', MOVING],
|
|
50
|
+
['10032', MOVING],
|
|
50
51
|
['10054', MOVING],
|
|
52
|
+
// On board a flight about to take off, after leaving a sorting center.
|
|
53
|
+
['200073', MOVING],
|
|
51
54
|
// Arrived at the delivery station, before the courier's round.
|
|
52
55
|
['200075', MOVING],
|
|
53
56
|
// A new round agreed with the recipient (已与收件人约定新的派送时间, 待再次派送). It came after the arrival at the delivery
|
|
@@ -328,6 +328,20 @@
|
|
|
328
328
|
"confirmedBy": "live",
|
|
329
329
|
"firstSeen": "2026-11-03",
|
|
330
330
|
"note": "Arrived at a sorting center abroad (Your package has arrived at 【…】)."
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"code": "10032",
|
|
334
|
+
"stage": "in_transit",
|
|
335
|
+
"confirmedBy": "live",
|
|
336
|
+
"firstSeen": "2026-11-18",
|
|
337
|
+
"note": "Arrived at a sorting center (已到达【…】)."
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"code": "200073",
|
|
341
|
+
"stage": "in_transit",
|
|
342
|
+
"confirmedBy": "live",
|
|
343
|
+
"firstSeen": "2026-11-19",
|
|
344
|
+
"note": "On board a flight about to take off (…航班…起飞), after leaving a sorting center."
|
|
331
345
|
}
|
|
332
346
|
]
|
|
333
347
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { classifyWording } from '../../core/status/index.js';
|
|
2
2
|
import { normalizeStatusWording } from '../../core/status/statusMap.js';
|
|
3
|
+
import { SUB_STAGES } from '../../providers/seventeentrack/status.js';
|
|
3
4
|
import { imileRelayedStage } from '../imile/status.js';
|
|
4
5
|
import statuses from './statuses.json' with { type: 'json' };
|
|
5
6
|
const ENTRIES = statuses.entries;
|
|
@@ -34,13 +35,18 @@ const PATTERNS = [
|
|
|
34
35
|
// Its attempt that found no one or could not deliver, whatever the reason it names: tried again.
|
|
35
36
|
[/^failed delivery for reason: \S/, 'failed_attempt'],
|
|
36
37
|
];
|
|
38
|
+
// 17TRACK's sub-status names, which Shouwu gives as a scan's wording on a line it reads from 17TRACK
|
|
39
|
+
// ("InTransit_CustomsReleased"): they mean what 17TRACK's sub-statuses mean.
|
|
40
|
+
const SUB_STATUS_NAMES = new Map(Object.entries(SUB_STAGES)
|
|
41
|
+
.map(([name, stage]) => [name.toLowerCase(), stage]));
|
|
37
42
|
/**
|
|
38
43
|
* A wording's stage in Shouwu's map, the wording in `normalizeStatusWording` form. On the line into
|
|
39
44
|
* Italy the delivering partner is iMile, whose rows open with its centre in 【】 ("【Milan center】Received."):
|
|
40
45
|
* iMile's sentences read them.
|
|
41
46
|
*/
|
|
42
47
|
function mappedStage(wording) {
|
|
43
|
-
return WORDINGS.get(wording) ?? PATTERNS.find(([pattern]) => pattern.test(wording))?.[1] ??
|
|
48
|
+
return WORDINGS.get(wording) ?? PATTERNS.find(([pattern]) => pattern.test(wording))?.[1] ?? SUB_STATUS_NAMES.get(wording)
|
|
49
|
+
?? imileRelayedStage(wording);
|
|
44
50
|
}
|
|
45
51
|
// Rows that send the parcel back to its sender: DHL's "Shipment will be returned to origin-Bad address" and the
|
|
46
52
|
// Italian last mile's "Back to Sender for reason: …".
|
|
@@ -1101,6 +1101,46 @@
|
|
|
1101
1101
|
"confirmedBy": "live",
|
|
1102
1102
|
"firstSeen": "2026-11-11",
|
|
1103
1103
|
"note": "DPD's failed round with its reason joined, a wrong address. DPD's own map reads the sentence as a failed attempt whatever the reason, and the parcel went back to the depot, not to the sender."
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
"wording": "InTransit_PickedUp",
|
|
1107
|
+
"stage": "accepted",
|
|
1108
|
+
"language": "en",
|
|
1109
|
+
"confirmedBy": "live",
|
|
1110
|
+
"firstSeen": "2026-10-24",
|
|
1111
|
+
"note": "17TRACK's sub-status name, which Shouwu gives as the scan's wording on a line it reads from 17TRACK: it means what 17TRACK's sub-status means. The pickup, after the order's registration."
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
"wording": "InTransit_Arrival",
|
|
1115
|
+
"stage": "in_transit",
|
|
1116
|
+
"language": "en",
|
|
1117
|
+
"confirmedBy": "live",
|
|
1118
|
+
"firstSeen": "2026-10-27",
|
|
1119
|
+
"note": "17TRACK's sub-status name, which Shouwu gives as the scan's wording on a line it reads from 17TRACK: it means what 17TRACK's sub-status means."
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
"wording": "InTransit_Departure",
|
|
1123
|
+
"stage": "in_transit",
|
|
1124
|
+
"language": "en",
|
|
1125
|
+
"confirmedBy": "live",
|
|
1126
|
+
"firstSeen": "2026-10-28",
|
|
1127
|
+
"note": "17TRACK's sub-status name, which Shouwu gives as the scan's wording on a line it reads from 17TRACK: it means what 17TRACK's sub-status means."
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"wording": "InTransit_CustomsProcessing",
|
|
1131
|
+
"stage": "customs",
|
|
1132
|
+
"language": "en",
|
|
1133
|
+
"confirmedBy": "live",
|
|
1134
|
+
"firstSeen": "2026-10-29",
|
|
1135
|
+
"note": "17TRACK's sub-status name, which Shouwu gives as the scan's wording on a line it reads from 17TRACK: it means what 17TRACK's sub-status means."
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
"wording": "InTransit_CustomsReleased",
|
|
1139
|
+
"stage": "in_transit",
|
|
1140
|
+
"language": "en",
|
|
1141
|
+
"confirmedBy": "live",
|
|
1142
|
+
"firstSeen": "2026-10-31",
|
|
1143
|
+
"note": "17TRACK's sub-status name, which Shouwu gives as the scan's wording on a line it reads from 17TRACK: it means what 17TRACK's sub-status means. Released from customs, the parcel moves on."
|
|
1104
1144
|
}
|
|
1105
1145
|
]
|
|
1106
1146
|
}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
{"wording": "Arrived at origin facility", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "The line's facility in China, before its sort facility."},
|
|
18
18
|
{"wording": "Departed from sort facility", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "Leaving the line's sort facility in China."},
|
|
19
19
|
{"wording": "Arrived at the origin international airport", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "At the airport of departure, before the flight."},
|
|
20
|
+
{"wording": "Arrive at international airport to abroad", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-18", "note": "At the airport for the flight abroad, after the departure from origin and before the export release."},
|
|
21
|
+
{"wording": "Released From Export Customs", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-18", "note": "China's export release at the airport, before the flight: the parcel is not held."},
|
|
20
22
|
{"wording": "International flight has arrived", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "The flight landing in the destination country."},
|
|
21
23
|
{"wording": "NOA received", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "The airline's notice of arrival at the destination."},
|
|
22
24
|
{"wording": "Collected at Cargo Terminal", "language": "en", "stage": "in_transit", "confirmedBy": "live", "firstSeen": "2026-11-16", "note": "Collected from the destination airport's cargo terminal."},
|
|
@@ -3,7 +3,7 @@ import { BudgetExceededError, ChallengeError, RateLimitedError, SchemaError, Tra
|
|
|
3
3
|
import { runSteps } from '../../core/runner/index.js';
|
|
4
4
|
import { browserContextProxy } from '../../core/transport/browserRouteTrial.js';
|
|
5
5
|
import { decodeText, fetchBounded, userAgentOf } from '../../core/transport/index.js';
|
|
6
|
-
import { API, COURIER_API, MAX_BYTES, normalizeWanbNumber, ORIGIN, parseWanb, PROVIDER, wanbShippingService, withWanbCourier } from './parser.js';
|
|
6
|
+
import { API, COURIER_API, MAX_BYTES, normalizeWanbLookup, normalizeWanbNumber, ORIGIN, parseWanb, PROVIDER, wanbShippingService, withWanbCourier } from './parser.js';
|
|
7
7
|
import { fetchWanbInBrowser } from './browser.js';
|
|
8
8
|
export class WanbTracker {
|
|
9
9
|
environment;
|
|
@@ -46,7 +46,7 @@ export class WanbTracker {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
async direct(raw, context = {}) {
|
|
49
|
-
const number =
|
|
49
|
+
const number = normalizeWanbLookup(raw);
|
|
50
50
|
const deadline = performance.now() + (context.budgetMs ?? 5000);
|
|
51
51
|
// Node's fetch sends `Accept-Language: *` unless told otherwise, and the
|
|
52
52
|
// tracker fails on it with HTTP 500, often after several seconds.
|
|
@@ -86,7 +86,7 @@ export class WanbTracker {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
async browser(raw, signal, remainingMs, proxy = null, read = { route: null, reads: 0, history: false }) {
|
|
89
|
-
const number =
|
|
89
|
+
const number = normalizeWanbLookup(raw);
|
|
90
90
|
const deadline = performance.now() + remainingMs;
|
|
91
91
|
if (!this.environment.trawl)
|
|
92
92
|
throw new ChallengeError(PROVIDER, 'WanbExpress requires the browser tracking service');
|
|
@@ -129,7 +129,7 @@ export class WanbTracker {
|
|
|
129
129
|
return result;
|
|
130
130
|
}
|
|
131
131
|
fetch(raw, context = {}) {
|
|
132
|
-
const number =
|
|
132
|
+
const number = normalizeWanbLookup(raw);
|
|
133
133
|
// The tracker refuses plain lookups with its verification code, so with a browser to
|
|
134
134
|
// ask the lookup starts there; HTTP recognition still makes the plain request.
|
|
135
135
|
const read = { route: null, reads: 0, history: false };
|
|
@@ -5,7 +5,10 @@ export declare const API = "https://tracking.wanbexpress.com/TrackPoints/Track";
|
|
|
5
5
|
/** The tracker's last-mile panel, which names the courier of a shipping service without verification. */
|
|
6
6
|
export declare const COURIER_API = "https://tracking.wanbexpress.com/Common/TrackLastMileCarrier";
|
|
7
7
|
export declare const MAX_BYTES = 1000000;
|
|
8
|
+
/** WanbExpress's own parcel identifier, the only number recognition asks it about. */
|
|
8
9
|
export declare function normalizeWanbNumber(raw: string): string;
|
|
10
|
+
/** A number a lookup takes: the parcel identifier, or the courier number of a parcel filed under WanbExpress. */
|
|
11
|
+
export declare function normalizeWanbLookup(raw: string): string;
|
|
9
12
|
export declare function parseWanb(payload: unknown, raw: string): CarrierResult;
|
|
10
13
|
/** The shipping service a found parcel travels under, which selects its courier; only with a courier's number. */
|
|
11
14
|
export declare function wanbShippingService(payload: unknown): string | undefined;
|
|
@@ -14,12 +14,27 @@ export const API = `${ORIGIN}/TrackPoints/Track`;
|
|
|
14
14
|
/** The tracker's last-mile panel, which names the courier of a shipping service without verification. */
|
|
15
15
|
export const COURIER_API = `${ORIGIN}/Common/TrackLastMileCarrier`;
|
|
16
16
|
export const MAX_BYTES = 1_000_000;
|
|
17
|
+
const PARCEL_ID = /^WNB[A-Z]{2}\d{10}YQ$/;
|
|
18
|
+
/**
|
|
19
|
+
* Cainiao Express's home-delivery numbers in France, the courier number WanbExpress relabels
|
|
20
|
+
* a parcel with on its service there; its tracker finds the parcel under the whole number.
|
|
21
|
+
*/
|
|
22
|
+
const COURIER_NUMBER = /^(?:DO|CN)FR\d{13}HD$/;
|
|
23
|
+
/** WanbExpress's own parcel identifier, the only number recognition asks it about. */
|
|
17
24
|
export function normalizeWanbNumber(raw) {
|
|
18
25
|
const number = raw.length <= 64 ? normalizeTrackingNumber(raw) : '';
|
|
19
|
-
if (
|
|
26
|
+
if (!PARCEL_ID.test(number))
|
|
20
27
|
throw new InvalidInputError(PROVIDER, 'WanbExpress requires its WNB parcel identifier');
|
|
21
28
|
return number;
|
|
22
29
|
}
|
|
30
|
+
/** A number a lookup takes: the parcel identifier, or the courier number of a parcel filed under WanbExpress. */
|
|
31
|
+
export function normalizeWanbLookup(raw) {
|
|
32
|
+
const number = raw.length <= 64 ? normalizeTrackingNumber(raw) : '';
|
|
33
|
+
if (!PARCEL_ID.test(number) && !COURIER_NUMBER.test(number)) {
|
|
34
|
+
throw new InvalidInputError(PROVIDER, 'WanbExpress takes its WNB parcel identifier or the courier number it relabelled the parcel with');
|
|
35
|
+
}
|
|
36
|
+
return number;
|
|
37
|
+
}
|
|
23
38
|
const CURRENT = { Delivered: 'delivered', InTransit: 'in_transit', OutForDelivery: 'out_for_delivery' };
|
|
24
39
|
/**
|
|
25
40
|
* A scan's place. The linehaul agent's departure names its role, the courier's label its system
|
|
@@ -33,7 +48,7 @@ function wanbPlace(location, stage) {
|
|
|
33
48
|
return place;
|
|
34
49
|
}
|
|
35
50
|
export function parseWanb(payload, raw) {
|
|
36
|
-
const number =
|
|
51
|
+
const number = normalizeWanbLookup(raw);
|
|
37
52
|
if (!isRecord(payload) || typeof payload.Succeeded !== 'boolean')
|
|
38
53
|
throw new SchemaError(PROVIDER, 'WanbExpress returned an invalid envelope');
|
|
39
54
|
if (!payload.Succeeded) {
|
|
@@ -50,8 +65,13 @@ export function parseWanb(payload, raw) {
|
|
|
50
65
|
throw new SchemaError(PROVIDER, 'WanbExpress returned invalid scans');
|
|
51
66
|
if (data.Match === 'Unknown' && !data.TrackPoints.length && data.Metadata === null && data.Status === null)
|
|
52
67
|
throw new NotFoundError(PROVIDER);
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
const metadata = isRecord(data.Metadata) ? data.Metadata : {};
|
|
69
|
+
// A courier number binds only as the parcel's own courier number, whole; a reference stays inconclusive.
|
|
70
|
+
const bound = PARCEL_ID.test(number) ? data.Match === 'ParcelId'
|
|
71
|
+
: data.Match === 'ParcelTrackingNumber' && typeof metadata.TrackingNumber === 'string' && metadata.TrackingNumber.length <= 64
|
|
72
|
+
&& normalizeTrackingNumber(metadata.TrackingNumber) === number;
|
|
73
|
+
if (!bound)
|
|
74
|
+
throw new IndeterminateError(PROVIDER, 'WanbExpress matched a reference instead of the number asked');
|
|
55
75
|
const events = data.TrackPoints.map((row) => {
|
|
56
76
|
if (!isRecord(row) || typeof row.Content !== 'string' || !row.Content.trim() || typeof row.Time !== 'string'
|
|
57
77
|
|| !/(?:Z|[+-]\d{2}:\d{2})$/.test(row.Time)
|
|
@@ -83,7 +103,6 @@ export function parseWanb(payload, raw) {
|
|
|
83
103
|
const current = events.find(event => event.stage);
|
|
84
104
|
const mapped = typeof data.Status === 'string' && Object.hasOwn(CURRENT, data.Status) ? CURRENT[data.Status] : undefined;
|
|
85
105
|
const stage = mapped ?? current?.stage;
|
|
86
|
-
const metadata = isRecord(data.Metadata) ? data.Metadata : {};
|
|
87
106
|
const country = (key) => typeof metadata[key] === 'string' && /^[A-Z]{2}$/.test(metadata[key]) ? metadata[key] : undefined;
|
|
88
107
|
const delivery = deliveryNumber(metadata, number);
|
|
89
108
|
return { status: stage ? languageStageStatus(stage) : 'unknown', current_stage: stage,
|
|
@@ -45,6 +45,11 @@ const WORDING = new Map([
|
|
|
45
45
|
['Votre Colissimo va bientôt nous être confié ! Il est en cours de préparation chez votre expéditeur.', { status: 'pending', stage: 'registered' }],
|
|
46
46
|
['Accepted at USPS Origin Facility', { status: 'in_transit', stage: 'in_transit' }],
|
|
47
47
|
['Arrived at USPS Regional Origin Facility', { status: 'in_transit', stage: 'in_transit' }],
|
|
48
|
+
// USPS's later facility scans on the way to the delivering office, relayed the same way.
|
|
49
|
+
['Arrived at USPS Facility', { status: 'in_transit', stage: 'in_transit' }],
|
|
50
|
+
['Departed USPS Facility', { status: 'in_transit', stage: 'in_transit' }],
|
|
51
|
+
['Arrived at USPS Regional Facility', { status: 'in_transit', stage: 'in_transit' }],
|
|
52
|
+
['Departed USPS Regional Facility', { status: 'in_transit', stage: 'in_transit' }],
|
|
48
53
|
['In Transit to Next Facility, Arriving On Time', { status: 'in_transit', stage: 'in_transit' }],
|
|
49
54
|
['Your shipment has been accepted by delivery carrier', { status: 'in_transit', stage: 'in_transit' }],
|
|
50
55
|
['Parcel Picked Up', { status: 'in_transit', stage: 'in_transit' }],
|
|
@@ -286,6 +286,38 @@
|
|
|
286
286
|
"firstSeen": "2026-11-04",
|
|
287
287
|
"note": "USPS's first sorting centre after the hand-over."
|
|
288
288
|
},
|
|
289
|
+
{
|
|
290
|
+
"wording": "Arrived at USPS Facility",
|
|
291
|
+
"language": "en",
|
|
292
|
+
"stage": "in_transit",
|
|
293
|
+
"confirmedBy": "live",
|
|
294
|
+
"firstSeen": "2026-11-18",
|
|
295
|
+
"note": "USPS's arrival at one of its facilities between the first sorting centre and the delivering office."
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"wording": "Departed USPS Facility",
|
|
299
|
+
"language": "en",
|
|
300
|
+
"stage": "in_transit",
|
|
301
|
+
"confirmedBy": "live",
|
|
302
|
+
"firstSeen": "2026-11-16",
|
|
303
|
+
"note": "USPS's departure from one of its facilities on the way to the delivering office."
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"wording": "Arrived at USPS Regional Facility",
|
|
307
|
+
"language": "en",
|
|
308
|
+
"stage": "in_transit",
|
|
309
|
+
"confirmedBy": "live",
|
|
310
|
+
"firstSeen": "2026-11-17",
|
|
311
|
+
"note": "USPS's arrival at a regional sorting centre on the way to the delivering office."
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"wording": "Departed USPS Regional Facility",
|
|
315
|
+
"language": "en",
|
|
316
|
+
"stage": "in_transit",
|
|
317
|
+
"confirmedBy": "live",
|
|
318
|
+
"firstSeen": "2026-11-16",
|
|
319
|
+
"note": "USPS's departure from a regional sorting centre on the way to the delivering office."
|
|
320
|
+
},
|
|
289
321
|
{
|
|
290
322
|
"wording": "In Transit to Next Facility, Arriving On Time",
|
|
291
323
|
"language": "en",
|
|
@@ -1024,6 +1024,17 @@ export function trackingLanguageStage(description) {
|
|
|
1024
1024
|
// and La Poste's "Item arrived at the collection point waiting for your collect".
|
|
1025
1025
|
if (/^(?:(?:the )?item )?(?:arrival|arrived|receive item) at (?:the )?collection point (?:for pick ?up|waiting for (?:your |the )?collect(?:ion)?)\b/.test(text))
|
|
1026
1026
|
return 'ready_for_pickup';
|
|
1027
|
+
// Royal Mail's mail centre scans as providers relay them, "Inward MC - Handheld Acceptance": the mail centre (MC)
|
|
1028
|
+
// taking the item in on its way, as Royal Mail reads its mail centre receipts.
|
|
1029
|
+
if (/^(?:inward|outward) mc (?:[a-z]+ )?acceptance$/.test(text))
|
|
1030
|
+
return 'in_transit';
|
|
1031
|
+
// PasarEX's import steps in Spanish, as ParcelsApp relays them: the order on record with the parcel still to come
|
|
1032
|
+
// ("Orden de pedido recibida - paquete no …"), then the consolidated cargo received for import and the parcel
|
|
1033
|
+
// taken into a warehouse after customs ("Ingresó a bodega"; its customs warehouse, "bodega aduanera", is customs).
|
|
1034
|
+
if (/^orden de (?:pedido|compra) recibida\b/.test(text))
|
|
1035
|
+
return 'registered';
|
|
1036
|
+
if (/^carga consolidada para importacion recibida$|^ingreso a (?:la )?bodega$/.test(text))
|
|
1037
|
+
return 'in_transit';
|
|
1027
1038
|
// A forwarder's receipt at its warehouse in the sending country, as 17TRACK relays it before the
|
|
1028
1039
|
// parcel departs that warehouse.
|
|
1029
1040
|
if (/^(?:package|parcel) received (?:&|and) scanned at (?:the )?carrier's domestic warehouse$/.test(text))
|
|
@@ -1041,10 +1052,10 @@ export function trackingLanguageStage(description) {
|
|
|
1041
1052
|
// A cross-dock transfer, a flight taking off, gone or landing, a tally in a bonded
|
|
1042
1053
|
// warehouse, a hand-over to the last mile being prepared or to an airline, a
|
|
1043
1054
|
// parcel bagged, unbagged or consolidated onto a master air waybill, a parcel
|
|
1044
|
-
// ready for a facility's outbound dispatch
|
|
1055
|
+
// ready for a facility's outbound dispatch, leaving a warehouse or shipped out of it, and a
|
|
1045
1056
|
// forwarder's inbound scan at a facility, which may follow in brackets, move
|
|
1046
1057
|
// the parcel on.
|
|
1047
|
-
if (/\bcross ?dock(?:ed|ing)?\b|\bready for outbound\b|^(?:(?:item|parcel|package|shipment) )?inbound scan(?:ned|ning)?\b|\b(?:un)?bagg(?:ed|ing)\b|\bmaster (?:air ?way ?bill|awb)(?: (?:number|no))? (?:received|assigned|allocated)\b|\bhand ?over to (?:the |an )?(?:airline|air carrier)\b|^(?:(?:the |your )?(?:item|parcel|package|shipment) )?(?:has )?left (?:the|our) warehouse$|\b(?:flight|leg)\b[^.;]*\b(?:is taking off|took off|has taken off|has left|landed)\b|\bflight (?:take ?off|landing)\b|^(?:initial|final) landing$|\bcargo tally in the supervised warehouse\b|\bprepared for (?:the )?last[- ]mile hand ?over\b/.test(text))
|
|
1058
|
+
if (/\bcross ?dock(?:ed|ing)?\b|\bready for outbound\b|^(?:(?:item|parcel|package|shipment) )?inbound scan(?:ned|ning)?\b|\b(?:un)?bagg(?:ed|ing)\b|\bmaster (?:air ?way ?bill|awb)(?: (?:number|no))? (?:received|assigned|allocated)\b|\bhand ?over to (?:the |an )?(?:airline|air carrier)\b|^(?:(?:the |your )?(?:item|parcel|package|shipment) )?(?:(?:has )?left|(?:has been |was )?shipped out of) (?:the|our) warehouse$|\b(?:flight|leg)\b[^.;]*\b(?:is taking off|took off|has taken off|has left|landed)\b|\bflight (?:take ?off|landing)\b|^(?:initial|final) landing$|\bcargo tally in the supervised warehouse\b|\bprepared for (?:the )?last[- ]mile hand ?over\b/.test(text))
|
|
1048
1059
|
return 'in_transit';
|
|
1049
1060
|
// The airline's notice of arrival (NOA) reaching the destination agent, after the landing and
|
|
1050
1061
|
// before clearance, as Shouwu, JRT and the ground handlers word it.
|
package/dist/data/catalog.json
CHANGED
|
@@ -9213,7 +9213,7 @@
|
|
|
9213
9213
|
"timezone": "Europe/London",
|
|
9214
9214
|
"tracking": {
|
|
9215
9215
|
"mode": "automatic",
|
|
9216
|
-
"adapter": "
|
|
9216
|
+
"adapter": "apg-ecommerce"
|
|
9217
9217
|
},
|
|
9218
9218
|
"canaryUrl": "https://apgecommerce.com/track/",
|
|
9219
9219
|
"trackingUrlTemplate": "https://apgecommerce.com/track-result/?track_sequenceNo={trackingNumber}",
|
|
@@ -9214,7 +9214,7 @@ export const CARRIER_CATALOG = {
|
|
|
9214
9214
|
"timezone": "Europe/London",
|
|
9215
9215
|
"tracking": {
|
|
9216
9216
|
"mode": "automatic",
|
|
9217
|
-
"adapter": "
|
|
9217
|
+
"adapter": "apg-ecommerce"
|
|
9218
9218
|
},
|
|
9219
9219
|
"canaryUrl": "https://apgecommerce.com/track/",
|
|
9220
9220
|
"trackingUrlTemplate": "https://apgecommerce.com/track-result/?track_sequenceNo={trackingNumber}",
|
|
@@ -41,6 +41,7 @@ import { adapter as anteraja } from '../carriers/anteraja/adapter.js';
|
|
|
41
41
|
import { adapter as apcOvernight } from '../carriers/apc-overnight/adapter.js';
|
|
42
42
|
import { adapter as apcPostalLogistics } from '../carriers/apc-postal-logistics/adapter.js';
|
|
43
43
|
import { adapter as apdParcel } from '../carriers/apd-parcel/adapter.js';
|
|
44
|
+
import { adapter as apgEcommerce } from '../carriers/apg-ecommerce/adapter.js';
|
|
44
45
|
import { adapter as appleExpress } from '../carriers/apple-express/adapter.js';
|
|
45
46
|
import { adapter as aquiline } from '../carriers/aquiline/adapter.js';
|
|
46
47
|
import { adapter as aramex } from '../carriers/aramex/adapter.js';
|
|
@@ -853,6 +854,7 @@ export const REGISTRY = {
|
|
|
853
854
|
"apc-overnight": apcOvernight,
|
|
854
855
|
"apc-postal-logistics": apcPostalLogistics,
|
|
855
856
|
"apd-parcel": apdParcel,
|
|
857
|
+
"apg-ecommerce": apgEcommerce,
|
|
856
858
|
"apple-express": appleExpress,
|
|
857
859
|
"aquiline": aquiline,
|
|
858
860
|
"aramex": aramex,
|
|
@@ -1734,7 +1736,7 @@ export const REGISTRY = {
|
|
|
1734
1736
|
"apc-overnight": "apc-overnight",
|
|
1735
1737
|
"apc-postal-logistics": "apc-postal-logistics",
|
|
1736
1738
|
"apd-parcel": "apd-parcel",
|
|
1737
|
-
"apg-ecommerce": "
|
|
1739
|
+
"apg-ecommerce": "apg-ecommerce",
|
|
1738
1740
|
"apg-global": "universal",
|
|
1739
1741
|
"apollo-budbiler": "universal",
|
|
1740
1742
|
"apple-express": "apple-express",
|
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.1186.2-main.6922",
|
|
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",
|