universal-parcel-scraper 0.1283.0-main.8564 → 0.1285.2-main.8580

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.
Files changed (88) hide show
  1. package/README.md +3 -3
  2. package/data/carrier.schema.json +4 -0
  3. package/data/catalog.json +169 -3
  4. package/data/coverage-summary.json +2 -2
  5. package/data/detection-golden.json +547 -0
  6. package/dist/browser/scraper.js +1599 -1438
  7. package/dist/carriers/benniao-express/adapter.d.ts +21 -0
  8. package/dist/carriers/benniao-express/adapter.js +52 -0
  9. package/dist/carriers/benniao-express/carrier.json +79 -0
  10. package/dist/carriers/benniao-express/numbers.json +119 -0
  11. package/dist/carriers/benniao-express/parser.d.ts +15 -0
  12. package/dist/carriers/benniao-express/parser.js +109 -0
  13. package/dist/carriers/benniao-express/status.d.ts +4 -0
  14. package/dist/carriers/benniao-express/status.js +9 -0
  15. package/dist/carriers/benniao-express/statuses.json +61 -0
  16. package/dist/carriers/correos-spain/status.js +4 -2
  17. package/dist/carriers/correos-spain/statuses.json +1 -0
  18. package/dist/carriers/disu-logistics/adapter.d.ts +14 -0
  19. package/dist/carriers/disu-logistics/adapter.js +43 -0
  20. package/dist/carriers/disu-logistics/carrier.json +76 -0
  21. package/dist/carriers/disu-logistics/numbers.json +208 -0
  22. package/dist/carriers/disu-logistics/parser.d.ts +14 -0
  23. package/dist/carriers/disu-logistics/parser.js +109 -0
  24. package/dist/carriers/disu-logistics/status.d.ts +4 -0
  25. package/dist/carriers/disu-logistics/status.js +9 -0
  26. package/dist/carriers/disu-logistics/statuses.json +77 -0
  27. package/dist/carriers/dpd-fr/status.js +2 -0
  28. package/dist/carriers/dpd-fr/statuses.json +8 -0
  29. package/dist/carriers/ecoscooting/carrier.json +2 -1
  30. package/dist/carriers/feibao-logistics/adapter.d.ts +14 -0
  31. package/dist/carriers/feibao-logistics/adapter.js +43 -0
  32. package/dist/carriers/feibao-logistics/carrier.json +74 -0
  33. package/dist/carriers/feibao-logistics/numbers.json +173 -0
  34. package/dist/carriers/feibao-logistics/parser.d.ts +15 -0
  35. package/dist/carriers/feibao-logistics/parser.js +118 -0
  36. package/dist/carriers/feibao-logistics/status.d.ts +4 -0
  37. package/dist/carriers/feibao-logistics/status.js +9 -0
  38. package/dist/carriers/feibao-logistics/statuses.json +45 -0
  39. package/dist/carriers/huaqi-express/adapter.d.ts +14 -0
  40. package/dist/carriers/huaqi-express/adapter.js +41 -0
  41. package/dist/carriers/huaqi-express/carrier.json +72 -0
  42. package/dist/carriers/huaqi-express/numbers.json +39 -0
  43. package/dist/carriers/huaqi-express/parser.d.ts +14 -0
  44. package/dist/carriers/huaqi-express/parser.js +106 -0
  45. package/dist/carriers/huaqi-express/status.d.ts +4 -0
  46. package/dist/carriers/huaqi-express/status.js +9 -0
  47. package/dist/carriers/huaqi-express/statuses.json +77 -0
  48. package/dist/carriers/lindao-express/adapter.d.ts +14 -0
  49. package/dist/carriers/lindao-express/adapter.js +42 -0
  50. package/dist/carriers/lindao-express/carrier.json +68 -0
  51. package/dist/carriers/lindao-express/numbers.json +120 -0
  52. package/dist/carriers/lindao-express/parser.d.ts +13 -0
  53. package/dist/carriers/lindao-express/parser.js +80 -0
  54. package/dist/carriers/lindao-express/status.d.ts +4 -0
  55. package/dist/carriers/lindao-express/status.js +9 -0
  56. package/dist/carriers/lindao-express/statuses.json +101 -0
  57. package/dist/carriers/ontrac/carrier.json +1 -1
  58. package/dist/carriers/ontrac/numbers.json +15 -0
  59. package/dist/carriers/paack/carrier.json +2 -1
  60. package/dist/carriers/riyu-logistics/adapter.d.ts +14 -0
  61. package/dist/carriers/riyu-logistics/adapter.js +42 -0
  62. package/dist/carriers/riyu-logistics/carrier.json +70 -0
  63. package/dist/carriers/riyu-logistics/numbers.json +71 -0
  64. package/dist/carriers/riyu-logistics/parser.d.ts +19 -0
  65. package/dist/carriers/riyu-logistics/parser.js +90 -0
  66. package/dist/carriers/riyu-logistics/status.d.ts +4 -0
  67. package/dist/carriers/riyu-logistics/status.js +9 -0
  68. package/dist/carriers/riyu-logistics/statuses.json +69 -0
  69. package/dist/carriers/wanjia-logistics/adapter.d.ts +14 -0
  70. package/dist/carriers/wanjia-logistics/adapter.js +41 -0
  71. package/dist/carriers/wanjia-logistics/carrier.json +77 -0
  72. package/dist/carriers/wanjia-logistics/numbers.json +114 -0
  73. package/dist/carriers/wanjia-logistics/parser.d.ts +15 -0
  74. package/dist/carriers/wanjia-logistics/parser.js +145 -0
  75. package/dist/carriers/wanjia-logistics/status.d.ts +4 -0
  76. package/dist/carriers/wanjia-logistics/status.js +9 -0
  77. package/dist/carriers/wanjia-logistics/statuses.json +77 -0
  78. package/dist/core/catalog/recognition.js +9 -0
  79. package/dist/core/catalog/statusMaps.js +14 -7
  80. package/dist/core/catalog/types.d.ts +5 -0
  81. package/dist/core/detection/index.d.ts +1 -0
  82. package/dist/core/detection/index.js +1 -0
  83. package/dist/data/catalog.json +169 -3
  84. package/dist/generated/catalog.d.ts +1 -1
  85. package/dist/generated/catalog.js +183 -3
  86. package/dist/generated/registry.js +21 -0
  87. package/dist/server/openapi.json +1 -1
  88. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ import type { Stage } from '../../core/status/index.js';
2
+ import type { CarrierStatusMap } from '../../core/status/statusMap.js';
3
+ export declare function huaqiStage(code: string): Stage | undefined;
4
+ export declare const statusMap: CarrierStatusMap;
@@ -0,0 +1,9 @@
1
+ import statuses from './statuses.json' with { type: 'json' };
2
+ const ENTRIES = statuses.entries;
3
+ /** The stages of the scans Huaqi's rows are built around, as recorded in `statuses.json`. */
4
+ const CODES = new Map(ENTRIES.filter(entry => entry.code && entry.stage)
5
+ .map(entry => [entry.code, entry.stage]));
6
+ export function huaqiStage(code) {
7
+ return CODES.get(code);
8
+ }
9
+ export const statusMap = { stage: code => (code ? CODES.get(code) : undefined), gaps: [] };
@@ -0,0 +1,77 @@
1
+ {
2
+ "carrier": "huaqi-express",
3
+ "entries": [
4
+ {
5
+ "code": "已收件",
6
+ "wording": "已收件,收件网点【…】,扫描员是【…】",
7
+ "stage": "accepted",
8
+ "language": "zh",
9
+ "confirmedBy": "live",
10
+ "note": "Huaqi took the freight in at its branch; the adapter leaves out the scanner."
11
+ },
12
+ {
13
+ "code": "已入库",
14
+ "wording": "已入库,到达【…】,扫描员是【…】",
15
+ "stage": "in_transit",
16
+ "language": "zh",
17
+ "confirmedBy": "live",
18
+ "note": "Booked into Huaqi's warehouse."
19
+ },
20
+ {
21
+ "code": "离开",
22
+ "wording": "离开【…】,发往【…】 or 快件离开【…】,已在发往【…】的路上",
23
+ "stage": "in_transit",
24
+ "language": "zh",
25
+ "confirmedBy": "live",
26
+ "note": "Left a branch or hub for the next one."
27
+ },
28
+ {
29
+ "code": "完成分拣",
30
+ "wording": "快件在【…】完成分拣,准备发往【…】",
31
+ "stage": "in_transit",
32
+ "language": "zh",
33
+ "confirmedBy": "live",
34
+ "note": "Sorted at a hub of the partner network carrying the long-distance leg."
35
+ },
36
+ {
37
+ "code": "快件到达",
38
+ "wording": "快件到达【…】",
39
+ "stage": "in_transit",
40
+ "language": "zh",
41
+ "confirmedBy": "live",
42
+ "note": "Reached a hub or the delivering store."
43
+ },
44
+ {
45
+ "code": "长途运输",
46
+ "wording": "快件开始长途运输… or 车辆正在长途运输中…",
47
+ "stage": "in_transit",
48
+ "language": "zh",
49
+ "confirmedBy": "live",
50
+ "note": "On the long-distance truck; the row names a city it is near or the expected arrival."
51
+ },
52
+ {
53
+ "code": "派送途中",
54
+ "wording": "快件交给【…】,正在派送途中(…)",
55
+ "stage": "out_for_delivery",
56
+ "language": "zh",
57
+ "confirmedBy": "live",
58
+ "note": "Handed to the courier; the adapter leaves out the courier's name, phone and closing note."
59
+ },
60
+ {
61
+ "code": "已派送",
62
+ "wording": "您的快件已派送至本人,如有疑问请电联快递员【…】…",
63
+ "stage": "delivered",
64
+ "language": "zh",
65
+ "confirmedBy": "live",
66
+ "note": "Delivered to the recipient; the adapter leaves out the courier and the courtesy text."
67
+ },
68
+ {
69
+ "code": "已签收",
70
+ "wording": "快件已签收",
71
+ "stage": "delivered",
72
+ "language": "zh",
73
+ "confirmedBy": "live",
74
+ "note": "Signed for."
75
+ }
76
+ ]
77
+ }
@@ -0,0 +1,14 @@
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 { parseLindao } from './parser.js';
5
+ export declare class LindaoTracker {
6
+ private readonly options;
7
+ constructor(options?: {
8
+ fetcher?: typeof fetch;
9
+ recorder?: StepRecorder;
10
+ userAgent?: string;
11
+ });
12
+ fetch(raw: string, context?: TrackingContext): Promise<CarrierResult>;
13
+ }
14
+ export declare const adapter: AdapterFactory;
@@ -0,0 +1,42 @@
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, userAgentOf } from '../../core/transport/index.js';
6
+ import { LINDAO_PAGE, normalizeLindaoNumber, parseLindao, PROVIDER } from './parser.js';
7
+ export { parseLindao } from './parser.js';
8
+ const REDIRECTS = [301, 302, 303, 307, 308];
9
+ export class LindaoTracker {
10
+ options;
11
+ constructor(options = {}) {
12
+ this.options = options;
13
+ }
14
+ fetch(raw, context = {}) {
15
+ context.signal?.throwIfAborted();
16
+ const number = normalizeLindaoNumber(raw);
17
+ const read = async (signal, timeoutMs) => {
18
+ // The form the site's tracking page posts, one number, with no session, captcha or account.
19
+ const { response, bytes } = await fetchBounded(LINDAO_PAGE, { method: 'POST', signal, body: new URLSearchParams({ number }).toString(),
20
+ // The site fails with HTTP 500 on the `*` language fetch sends by default, so name one.
21
+ headers: { Accept: 'text/html,application/xhtml+xml', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Content-Type': 'application/x-www-form-urlencoded', Referer: LINDAO_PAGE,
22
+ 'User-Agent': userAgentOf(this.options.userAgent) } }, { provider: PROVIDER, fetcher: this.options.fetcher, maxBytes: 1_000_000, timeoutMs: Math.max(1, Math.floor(timeoutMs)),
23
+ redirect: 'manual', allowHttpStatuses: [...REDIRECTS, 401, 403, 404, 410] });
24
+ if ([401, 403].includes(response.status))
25
+ throw new ChallengeError(PROVIDER, 'Lindao refused its guest request');
26
+ // An unknown number is HTTP 200 too; anything else is a moved route.
27
+ if (response.status !== 200)
28
+ throw new TransportError(PROVIDER, 'Lindao tracking page moved', { status: response.status });
29
+ return parseLindao(decodeText(bytes), number);
30
+ };
31
+ // A request that fails to reach the server, or hangs, gets one more try in the rest of the budget.
32
+ return runSteps({ carrier: 'lindao-express', budgetMs: context.budgetMs ?? 15_000, signal: context.signal,
33
+ recorder: this.options.recorder ?? NOOP_RECORDER }, [
34
+ { id: 'direct', run: ({ signal, remainingMs }) => read(signal, firstAttemptMs(remainingMs)) },
35
+ networkRetryStep(({ signal, remainingMs }) => read(signal, remainingMs)),
36
+ ]);
37
+ }
38
+ }
39
+ export const adapter = environment => {
40
+ const tracker = new LindaoTracker({ fetcher: environment.fetcher, recorder: environment.recorder, userAgent: environment.userAgent });
41
+ return { id: 'lindao-express', recordsSteps: true, steps: ['direct', 'retry'], track: (input, context) => tracker.fetch(input.number, context) };
42
+ };
@@ -0,0 +1,68 @@
1
+ {
2
+ "id": "lindao-express",
3
+ "displayName": "Lindao Express",
4
+ "aliases": [
5
+ "林道货运",
6
+ "林道国际货运",
7
+ "上海林道国际货运代理有限公司"
8
+ ],
9
+ "region": {
10
+ "countries": [
11
+ "CN",
12
+ "JP"
13
+ ]
14
+ },
15
+ "brand": {
16
+ "color": "#1f5fa8"
17
+ },
18
+ "selectable": true,
19
+ "timezone": "Asia/Shanghai",
20
+ "tracking": {
21
+ "mode": "automatic",
22
+ "adapter": "lindao-express",
23
+ "steps": [
24
+ "direct",
25
+ "retry"
26
+ ],
27
+ "localClocks": true
28
+ },
29
+ "capabilities": [
30
+ "history",
31
+ "location",
32
+ "provider_code",
33
+ "delivery_tracking_number"
34
+ ],
35
+ "portal": {
36
+ "canaryUrl": "https://t.17track.net/",
37
+ "shows": [
38
+ "status",
39
+ "history",
40
+ "location",
41
+ "delivery_tracking_number"
42
+ ],
43
+ "scraped": [
44
+ "status",
45
+ "history",
46
+ "location",
47
+ "provider_code",
48
+ "delivery_tracking_number"
49
+ ],
50
+ "discarded": [],
51
+ "unavailable": [
52
+ "weight",
53
+ "service_name",
54
+ "eta",
55
+ "pieces",
56
+ "origin",
57
+ "destination",
58
+ "offset_timestamps",
59
+ "proof_of_delivery",
60
+ "signatory",
61
+ "sender_name",
62
+ "recipient_name",
63
+ "recipient_address"
64
+ ]
65
+ },
66
+ "links": [],
67
+ "detection": []
68
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "carrier": "lindao-express",
3
+ "records": [
4
+ {
5
+ "number": "506539694570",
6
+ "role": "shipment",
7
+ "evidence": "public_shipment_report",
8
+ "source": {
9
+ "url": "https://www.kuaidi.com/all/shlindao.html",
10
+ "date": "2026-11-22",
11
+ "dateKind": "capture",
12
+ "access": "full_page"
13
+ },
14
+ "context": {
15
+ "assessment": "confirmed"
16
+ },
17
+ "expect": {
18
+ "carrier": "unknown",
19
+ "confidence": "low",
20
+ "candidates": [
21
+ "mondial-relay",
22
+ "colis-prive",
23
+ "mrw",
24
+ "brt",
25
+ "japan-post",
26
+ "sf-express",
27
+ "sto",
28
+ "zto",
29
+ "yamato",
30
+ "j-and-t",
31
+ "lbc-express",
32
+ "metropolitan-warehouse",
33
+ "paquetexpress",
34
+ "sagawa",
35
+ "sending"
36
+ ]
37
+ },
38
+ "note": "An order kuaidi.com's Lindao page lists. Lindao's tracker answers it with a parcel taken in at Qingdao, flown to Japan, cleared and delivered by the Japanese carrier whose waybill it names."
39
+ },
40
+ {
41
+ "number": "506542880196",
42
+ "role": "shipment",
43
+ "evidence": "public_shipment_report",
44
+ "source": {
45
+ "url": "https://www.kuaidi.com/all/shlindao.html",
46
+ "date": "2026-11-22",
47
+ "dateKind": "capture",
48
+ "access": "full_page"
49
+ },
50
+ "context": {
51
+ "assessment": "confirmed"
52
+ },
53
+ "expect": {
54
+ "carrier": "unknown",
55
+ "confidence": "low",
56
+ "candidates": [
57
+ "mondial-relay",
58
+ "colis-prive",
59
+ "mrw",
60
+ "brt",
61
+ "purolator",
62
+ "japan-post",
63
+ "sf-express",
64
+ "sto",
65
+ "zto",
66
+ "yamato",
67
+ "j-and-t",
68
+ "lbc-express",
69
+ "metropolitan-warehouse",
70
+ "paquetexpress",
71
+ "sagawa",
72
+ "sending"
73
+ ]
74
+ },
75
+ "note": "An order kuaidi.com's Lindao page lists. Lindao's tracker answers it with a parcel flown from Dalian to Narita, cleared and delivered."
76
+ },
77
+ {
78
+ "number": "506543206606",
79
+ "role": "shipment",
80
+ "evidence": "public_shipment_report",
81
+ "source": {
82
+ "url": "https://www.kuaidi.com/all/shlindao.html",
83
+ "date": "2026-11-22",
84
+ "dateKind": "capture",
85
+ "access": "full_page"
86
+ },
87
+ "context": {
88
+ "assessment": "confirmed"
89
+ },
90
+ "expect": {
91
+ "carrier": "unknown",
92
+ "confidence": "low",
93
+ "candidates": [
94
+ "gls-ch",
95
+ "mondial-relay",
96
+ "gls-fr",
97
+ "colis-prive",
98
+ "gls-de",
99
+ "mrw",
100
+ "brt",
101
+ "japan-post",
102
+ "sf-express",
103
+ "sto",
104
+ "zto",
105
+ "yamato",
106
+ "j-and-t",
107
+ "gls-at",
108
+ "gls-nl",
109
+ "gls-pl",
110
+ "lbc-express",
111
+ "metropolitan-warehouse",
112
+ "paquetexpress",
113
+ "sagawa",
114
+ "sending"
115
+ ]
116
+ },
117
+ "note": "An order kuaidi.com's Lindao page lists. Lindao's tracker answers it with a parcel flown from Dalian to Narita, cleared and delivered."
118
+ }
119
+ ]
120
+ }
@@ -0,0 +1,13 @@
1
+ import type { CarrierResult } from '../../core/result/index.js';
2
+ export declare const PROVIDER = "Lindao Express";
3
+ /** The site's 货物追踪 page, whose form posts the numbers typed in back to it. */
4
+ export declare const LINDAO_PAGE = "http://www.ldxpress.com/home/goods/index.html";
5
+ /** Lindao's order numbers and the Japanese waybills it pairs them with are twelve digits. */
6
+ export declare function normalizeLindaoNumber(raw: string): string;
7
+ /**
8
+ * The tracking page for one number: Lindao's order number, the Japanese waybill its last leg
9
+ * travels under, then the scans newest first on the wall clocks of China and, once the parcel
10
+ * lands, Japan. One of the two numbers must be the whole number asked; a page saying the order
11
+ * does not exist is a number Lindao does not know.
12
+ */
13
+ export declare function parseLindao(html: string, raw: string): CarrierResult;
@@ -0,0 +1,80 @@
1
+ import { ChallengeError, InvalidInputError, NotFoundError, SchemaError } from '../../core/errors/index.js';
2
+ import { languageStageStatus } from '../../core/status/index.js';
3
+ import { calendarDay } from '../../core/time/index.js';
4
+ import { textFromHtml } from '../../core/transport/text.js';
5
+ import { lindaoStage } from './status.js';
6
+ export const PROVIDER = 'Lindao Express';
7
+ /** The site's 货物追踪 page, whose form posts the numbers typed in back to it. */
8
+ export const LINDAO_PAGE = 'http://www.ldxpress.com/home/goods/index.html';
9
+ const CHALLENGE = /_cf_chl_opt|cf-turnstile|<title>\s*Just a moment|acw_sc__v2|aliyun_waf|_____tmd_____|waf\.tencent|<title>\s*(?:滑动验证|验证码|安全验证|访问受限|访问被拒绝)/i;
10
+ const ROW = /<p>(\d{4})-(\d{2})-(\d{2}) ((?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d) ([^<]{1,300})<\/p>/g;
11
+ /** Lindao's order numbers and the Japanese waybills it pairs them with are twelve digits. */
12
+ export function normalizeLindaoNumber(raw) {
13
+ const number = typeof raw === 'string' && raw.length <= 64 ? raw.replace(/\s+/g, '') : '';
14
+ if (!/^\d{12}$/.test(number))
15
+ throw new InvalidInputError(PROVIDER, 'Lindao numbers are twelve digits');
16
+ return number;
17
+ }
18
+ /** The step a row names, without the place some of them carry, and that place. */
19
+ function step(text) {
20
+ const centre = /^抵达(.{1,20}操作中心)$/.exec(text);
21
+ if (centre)
22
+ return { code: '抵达操作中心', location: centre[1] };
23
+ const airport = /^(.{1,20}空港)(から出発|に到着予定)$/.exec(text);
24
+ if (airport)
25
+ return { code: `空港${airport[2]}`, location: airport[1] };
26
+ return { code: text.split(';')[0].trim() };
27
+ }
28
+ /**
29
+ * The tracking page for one number: Lindao's order number, the Japanese waybill its last leg
30
+ * travels under, then the scans newest first on the wall clocks of China and, once the parcel
31
+ * lands, Japan. One of the two numbers must be the whole number asked; a page saying the order
32
+ * does not exist is a number Lindao does not know.
33
+ */
34
+ export function parseLindao(html, raw) {
35
+ const number = normalizeLindaoNumber(raw);
36
+ if (typeof html !== 'string' || !html)
37
+ throw new SchemaError(PROVIDER, 'Lindao returned an empty page');
38
+ if (CHALLENGE.test(html.slice(0, 64_000)))
39
+ throw new ChallengeError(PROVIDER, 'Lindao answered with a browser check');
40
+ if (/<h3>\s*该订单不存在\s*<\/h3>/.test(html))
41
+ throw new NotFoundError(PROVIDER);
42
+ const start = html.indexOf('<div class="ncon_hw03">');
43
+ const block = start < 0 ? undefined : html.slice(start, html.indexOf('</div>', start));
44
+ if (!block)
45
+ throw new SchemaError(PROVIDER, 'Lindao returned a page without its tracking results');
46
+ const orders = [...block.matchAll(/<p>订单号\d+:<span class="hong">([^<]{0,40})<\/span><\/p>/g)].map(match => match[1].trim());
47
+ const waybills = [...block.matchAll(/<p>运单号\d+:<span class="hong">([^<]{0,40})<\/span><\/p>/g)].map(match => match[1].trim());
48
+ if (orders.length !== 1 || waybills.length !== 1 || ![orders[0], waybills[0]].includes(number)) {
49
+ throw new SchemaError(PROVIDER, 'Lindao returned another order');
50
+ }
51
+ const rows = [...block.matchAll(ROW)];
52
+ if (rows.length > 300 || rows.length !== (block.match(/<p>/g)?.length ?? 0) - 3)
53
+ throw new SchemaError(PROVIDER, 'Lindao returned an invalid scan row');
54
+ const events = [], seen = new Set();
55
+ for (const [, year, month, day, clock, text] of rows) {
56
+ const date = calendarDay(+year, +month, +day);
57
+ if (!date)
58
+ throw new SchemaError(PROVIDER, 'Lindao returned an invalid scan time');
59
+ const description = textFromHtml(text, 300);
60
+ if (!description)
61
+ continue;
62
+ const { code, location } = step(description), stage = lindaoStage(code);
63
+ const event = { local_time: `${date}T${clock}`, description, provider_code: code,
64
+ ...(location ? { location } : {}), ...(stage ? { stage, stage_source: 'carrier_map' } : {}) };
65
+ const key = JSON.stringify(event);
66
+ if (!seen.has(key)) {
67
+ seen.add(key);
68
+ events.push(event);
69
+ }
70
+ }
71
+ if (!events.length)
72
+ throw new NotFoundError(PROVIDER);
73
+ // Rows keep the page's order, newest first: China and Japan clocks an hour apart do not sort as instants.
74
+ const newest = events.find(event => event.stage === 'delivered') ?? events[0];
75
+ const stage = newest.stage;
76
+ const delivery = waybills[0] !== number && /^\d{8,20}$/.test(waybills[0]) ? waybills[0] : undefined;
77
+ return { status: stage ? languageStageStatus(stage) : 'unknown', ...(stage ? { current_stage: stage, current_stage_source: 'carrier_map' } : {}),
78
+ last_status_text: newest.description, last_update: null, last_update_local: newest.local_time,
79
+ ...(delivery ? { delivery_tracking_number: delivery } : {}), events: events.slice(0, 200) };
80
+ }
@@ -0,0 +1,4 @@
1
+ import type { Stage } from '../../core/status/index.js';
2
+ import type { CarrierStatusMap } from '../../core/status/statusMap.js';
3
+ export declare function lindaoStage(code: string): Stage | undefined;
4
+ export declare const statusMap: CarrierStatusMap;
@@ -0,0 +1,9 @@
1
+ import statuses from './statuses.json' with { type: 'json' };
2
+ const ENTRIES = statuses.entries;
3
+ /** The stages of the scans Lindao's rows name, as recorded in `statuses.json`. */
4
+ const CODES = new Map(ENTRIES.filter(entry => entry.code && entry.stage)
5
+ .map(entry => [entry.code, entry.stage]));
6
+ export function lindaoStage(code) {
7
+ return CODES.get(code);
8
+ }
9
+ export const statusMap = { stage: code => (code ? CODES.get(code) : undefined), gaps: [] };
@@ -0,0 +1,101 @@
1
+ {
2
+ "carrier": "lindao-express",
3
+ "entries": [
4
+ {
5
+ "code": "已揽件",
6
+ "wording": "已揽件",
7
+ "stage": "accepted",
8
+ "language": "zh",
9
+ "confirmedBy": "live",
10
+ "note": "Taken in by Lindao in China."
11
+ },
12
+ {
13
+ "code": "抵达操作中心",
14
+ "wording": "抵达…操作中心",
15
+ "stage": "in_transit",
16
+ "language": "zh",
17
+ "confirmedBy": "live",
18
+ "note": "Reached one of Lindao's Chinese operations centres, which the adapter keeps as the location."
19
+ },
20
+ {
21
+ "code": "订单已发出",
22
+ "wording": "订单已发出;预计起飞-到达时间:…",
23
+ "stage": "in_transit",
24
+ "language": "zh",
25
+ "confirmedBy": "live",
26
+ "note": "Dispatched to the airport, with the planned flight times."
27
+ },
28
+ {
29
+ "code": "空港から出発",
30
+ "wording": "…空港から出発",
31
+ "stage": "in_transit",
32
+ "language": "ja",
33
+ "confirmedBy": "live",
34
+ "note": "Left the Chinese airport named."
35
+ },
36
+ {
37
+ "code": "空港に到着予定",
38
+ "wording": "…空港に到着予定",
39
+ "stage": "in_transit",
40
+ "language": "ja",
41
+ "confirmedBy": "live",
42
+ "note": "Due at the Japanese airport named."
43
+ },
44
+ {
45
+ "code": "货物抵达日本清关中/フライト到着(輸入通関手続き中)",
46
+ "wording": "货物抵达日本清关中/フライト到着(輸入通関手続き中)",
47
+ "stage": "customs",
48
+ "language": "zh",
49
+ "confirmedBy": "live",
50
+ "note": "Landed in Japan and in import clearance."
51
+ },
52
+ {
53
+ "code": "进口清关完成/輸入通関許可",
54
+ "wording": "进口清关完成/輸入通関許可",
55
+ "stage": "in_transit",
56
+ "language": "zh",
57
+ "confirmedBy": "live",
58
+ "note": "Released by Japanese customs."
59
+ },
60
+ {
61
+ "code": "通関完了",
62
+ "wording": "通関完了",
63
+ "stage": "in_transit",
64
+ "language": "ja",
65
+ "confirmedBy": "live",
66
+ "note": "Released by Japanese customs."
67
+ },
68
+ {
69
+ "code": "集荷",
70
+ "wording": "集荷",
71
+ "stage": "in_transit",
72
+ "language": "ja",
73
+ "confirmedBy": "live",
74
+ "note": "Collected by the Japanese carrier for the last leg."
75
+ },
76
+ {
77
+ "code": "輸送中",
78
+ "wording": "輸送中",
79
+ "stage": "in_transit",
80
+ "language": "ja",
81
+ "confirmedBy": "live",
82
+ "note": "With the Japanese carrier."
83
+ },
84
+ {
85
+ "code": "配達中",
86
+ "wording": "配達中",
87
+ "stage": "out_for_delivery",
88
+ "language": "ja",
89
+ "confirmedBy": "live",
90
+ "note": "Out for delivery in Japan."
91
+ },
92
+ {
93
+ "code": "配達完了",
94
+ "wording": "配達完了",
95
+ "stage": "delivered",
96
+ "language": "ja",
97
+ "confirmedBy": "live",
98
+ "note": "Delivered."
99
+ }
100
+ ]
101
+ }
@@ -75,7 +75,7 @@
75
75
  },
76
76
  {
77
77
  "id": "ontrac-1",
78
- "pattern": "^[CD]\\d{14}$",
78
+ "pattern": "^(?!C2\\d(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\\d|3[01]))[CD]\\d{14}$",
79
79
  "confidence": "low",
80
80
  "checksum": "ontrac"
81
81
  },
@@ -443,6 +443,21 @@
443
443
  ]
444
444
  },
445
445
  "note": "A shipper reference archived from an OnTrac tracking link. OnTrac's tracker resolved it to the parcel and returned its history under the parcel's own number."
446
+ },
447
+ {
448
+ "number": "C26011599999907",
449
+ "role": "negative",
450
+ "evidence": "synthetic",
451
+ "derivedFrom": "official_shape",
452
+ "expect": {
453
+ "carrier": "unknown",
454
+ "confidence": "low",
455
+ "candidates": [
456
+ "paack",
457
+ "ecoscooting"
458
+ ]
459
+ },
460
+ "note": "Made-up SHEIN package number, C, the order date and eight digits, whose last digit passes OnTrac's check. OnTrac's C rule leaves SHEIN's dated numbers to the SHEIN rules."
446
461
  }
447
462
  ]
448
463
  }
@@ -119,7 +119,8 @@
119
119
  {
120
120
  "id": "paack-shein",
121
121
  "pattern": "^[CE]2\\d(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\\d|3[01])\\d{8}$",
122
- "confidence": "low"
122
+ "confidence": "low",
123
+ "servedCountriesOnly": true
123
124
  }
124
125
  ]
125
126
  }
@@ -0,0 +1,14 @@
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 { parseRiyu } from './parser.js';
5
+ export declare class RiyuTracker {
6
+ private readonly options;
7
+ constructor(options?: {
8
+ fetcher?: typeof fetch;
9
+ recorder?: StepRecorder;
10
+ userAgent?: string;
11
+ });
12
+ fetch(raw: string, context?: TrackingContext): Promise<CarrierResult>;
13
+ }
14
+ export declare const adapter: AdapterFactory;
@@ -0,0 +1,42 @@
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, userAgentOf } from '../../core/transport/index.js';
6
+ import { normalizeRiyuNumber, parseRiyu, PROVIDER, RIYU_ORIGIN, riyuJson, riyuLookupUrl, riyuPage } from './parser.js';
7
+ export { parseRiyu } from './parser.js';
8
+ const REDIRECTS = [301, 302, 303, 307, 308];
9
+ export class RiyuTracker {
10
+ options;
11
+ constructor(options = {}) {
12
+ this.options = options;
13
+ }
14
+ fetch(raw, context = {}) {
15
+ context.signal?.throwIfAborted();
16
+ const number = normalizeRiyuNumber(raw);
17
+ const read = async (signal, timeoutMs) => {
18
+ // The tracking page's request: the waybill alone in the query of an empty post, with no session, captcha or account.
19
+ const { response, bytes } = await fetchBounded(riyuLookupUrl(number), { method: 'POST', signal, headers: {
20
+ Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/x-www-form-urlencoded',
21
+ Origin: RIYU_ORIGIN, Referer: riyuPage(number), 'User-Agent': userAgentOf(this.options.userAgent),
22
+ } }, { provider: PROVIDER, fetcher: this.options.fetcher, maxBytes: 1_000_000, timeoutMs: Math.max(1, Math.floor(timeoutMs)),
23
+ redirect: 'manual', allowHttpStatuses: [...REDIRECTS, 401, 403, 404, 410] });
24
+ if ([401, 403].includes(response.status))
25
+ throw new ChallengeError(PROVIDER, 'Riyu refused its guest request');
26
+ // An unknown waybill is HTTP 200 too; anything else is a moved route.
27
+ if (response.status !== 200)
28
+ throw new TransportError(PROVIDER, 'Riyu tracking endpoint moved', { status: response.status });
29
+ return parseRiyu(riyuJson(decodeText(bytes)), number);
30
+ };
31
+ // A request that fails to reach the server, or hangs, gets one more try in the rest of the budget.
32
+ return runSteps({ carrier: 'riyu-logistics', budgetMs: context.budgetMs ?? 15_000, signal: context.signal,
33
+ recorder: this.options.recorder ?? NOOP_RECORDER }, [
34
+ { id: 'direct', run: ({ signal, remainingMs }) => read(signal, firstAttemptMs(remainingMs)) },
35
+ networkRetryStep(({ signal, remainingMs }) => read(signal, remainingMs)),
36
+ ]);
37
+ }
38
+ }
39
+ export const adapter = environment => {
40
+ const tracker = new RiyuTracker({ fetcher: environment.fetcher, recorder: environment.recorder, userAgent: environment.userAgent });
41
+ return { id: 'riyu-logistics', recordsSteps: true, steps: ['direct', 'retry'], track: (input, context) => tracker.fetch(input.number, context) };
42
+ };