universal-parcel-scraper 0.49.2-main.561 → 0.49.2-main.562

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.
@@ -70,6 +70,18 @@ function pickupPoint(raw) {
70
70
  }
71
71
  return [name, city].filter(Boolean).join('\n');
72
72
  }
73
+ /**
74
+ * Whether the parcel waits at its pickup point, or was collected there: its
75
+ * last movement before the delivery made it ready for pickup. Notices prove
76
+ * no movement.
77
+ */
78
+ function atPickupPoint(stage, events) {
79
+ if (stage === 'ready_for_pickup')
80
+ return true;
81
+ if (stage !== 'delivered')
82
+ return false;
83
+ return events.find((event) => !['pending', 'delivered'].includes(event.stage ?? ''))?.stage === 'ready_for_pickup';
84
+ }
73
85
  function measurement(raw, units) {
74
86
  if (!isRecord(raw) || typeof raw.unit !== 'string' || !Object.hasOwn(units, raw.unit.toLowerCase()))
75
87
  return null;
@@ -130,7 +142,7 @@ export function parse(payload, trackingNumber) {
130
142
  weight_kg: measurement(measurements.weight, { kg: 1, g: 0.001 }),
131
143
  dimensions_text: dimensions.every((value) => value !== null) ? `${dimensions.join(' × ')} cm` : null,
132
144
  // Posti's tracker shows the point at any status, a planned one in transit included.
133
- pickup_point: current?.stage === 'ready_for_pickup' ? pickupPoint(hit.pickupPoint) : null,
145
+ pickup_point: atPickupPoint(current?.stage, events) ? pickupPoint(hit.pickupPoint) : null,
134
146
  timezone: 'Europe/Helsinki',
135
147
  events,
136
148
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-parcel-scraper",
3
- "version": "0.49.2-main.561",
3
+ "version": "0.49.2-main.562",
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",