universal-parcel-scraper 0.802.0-main.4307 → 0.802.1-main.4309

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.
@@ -71,6 +71,13 @@ const VERIFIED_WORDING = {
71
71
  "we've received your order details, and we're expecting your parcel shortly": 'registered',
72
72
  'your parcel has been dropped off at a dpd pickup shop': 'accepted',
73
73
  };
74
+ // A parcel its sender hands in at a Pickup shop: the order record of a label that waits for it, and
75
+ // the drop-off. The account that booked such a label did not send it; on a return or donation label
76
+ // it is the recipient.
77
+ const HANDED_IN = new Set([
78
+ "we've received your order details, and we're expecting your parcel shortly",
79
+ 'your parcel has been dropped off at a dpd pickup shop',
80
+ ]);
74
81
  // A round that missed the recipient, with the day of the next one.
75
82
  const MISSED = /^we missed you\. your driver won't be back today but we'll be back [a-z]{3} \d{1,2} [a-z]+ with your parcel$/;
76
83
  /**
@@ -159,6 +166,8 @@ export function parseDpdUkHistory(detailPayload, historyPayload, raw, code) {
159
166
  return true;
160
167
  }).slice(0, 100);
161
168
  const latest = retained[0];
169
+ // A parcel handed in by its sender names none: null drops the account an earlier check named.
170
+ const handedIn = events.some(event => HANDED_IN.has(dpdUkWording(event.description)));
162
171
  const summary = publicDescription(detail.trackingStatusCurrent);
163
172
  const summaryClassification = classifyDpdUkWording(summary);
164
173
  const current = summary ? summaryClassification : classifyDpdUkWording(latest.description);
@@ -166,6 +175,6 @@ export function parseDpdUkHistory(detailPayload, historyPayload, raw, code) {
166
175
  ...(current.source !== 'none' ? { current_stage: current.stage, current_stage_source: current.source } : {}),
167
176
  last_status_text: summary || latest.description, last_update: latest.time ?? null,
168
177
  ...(latest.local_time ? { last_update_local: latest.local_time } : {}),
169
- ...(sender ? { sender_name: sender } : {}),
178
+ ...(handedIn ? { sender_name: null } : sender ? { sender_name: sender } : {}),
170
179
  ...(current.stage === 'delivered' && latest.stage === 'delivered' && latest.time ? { delivered_at: latest.time } : {}), events: retained };
171
180
  }
@@ -102,12 +102,16 @@ export function parseIntelcom(payload, rawNumber) {
102
102
  const events = history.map(scan);
103
103
  if (!events.length && !latest.time)
104
104
  throw new IndeterminateError(PROVIDER, 'Intelcom returned no dated shipment activity');
105
+ // A return collected from the customer goes to the client, which is then its recipient, not its sender:
106
+ // null drops the client an earlier check named.
107
+ const collected = [latestRaw, ...history].some(row => isRecord(row) && row.task_type === 'last_mile_pickup');
108
+ const client = typeof result.client_code === 'string' && Object.hasOwn(SHOWN_CLIENTS, result.client_code) ? SHOWN_CLIENTS[result.client_code] : undefined;
105
109
  const output = { status: latest.stage ? languageStageStatus(latest.stage) : 'unknown',
106
110
  last_status_text: latest.description, last_update: latest.time ?? null,
107
111
  ...(latest.stage ? { current_stage: latest.stage, current_stage_source: latest.stage_source } : {}),
108
112
  ...(latest.stage === 'delivered' && latest.time ? { delivered_at: latest.time } : {}),
109
113
  ...estimate(result, latestRaw, latest.time ? Date.parse(latest.time) : null),
110
- ...(typeof result.client_code === 'string' && Object.hasOwn(SHOWN_CLIENTS, result.client_code) ? { sender_name: SHOWN_CLIENTS[result.client_code] } : {}),
114
+ ...(collected ? { sender_name: null } : client ? { sender_name: client } : {}),
111
115
  ...(events.length ? { events: events.slice(0, 100) } : { summary_only: true, events: [] }) };
112
116
  return output;
113
117
  }
@@ -67,6 +67,10 @@ export interface CarrierResult extends JsonObject {
67
67
  last_update?: string | null;
68
68
  expected_delivery?: string | null;
69
69
  expected_delivery_from?: string | null;
70
+ /**
71
+ * Who sent the parcel. Null when the name the carrier gives is not its sender, as the account
72
+ * a return goes back to: a name an earlier answer gave no longer stands. Absent says nothing.
73
+ */
70
74
  sender_name?: string | null;
71
75
  receiver_name?: string | null;
72
76
  /**
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Universal Parcel Scraper",
5
- "version": "0.802.0-main.4307"
5
+ "version": "0.802.1-main.4309"
6
6
  },
7
7
  "paths": {
8
8
  "/health": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-parcel-scraper",
3
- "version": "0.802.0-main.4307",
3
+ "version": "0.802.1-main.4309",
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",