@ph-itdev/parcel-tracker 0.2026.702
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 +26 -0
- package/bin/cli.js +72 -0
- package/example/index.html +88 -0
- package/index.d.ts +2 -0
- package/index.js +42 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @ph-itdev/parcel-tracker
|
|
2
|
+
|
|
3
|
+
Unified parcel tracking across carriers with status normalization, ETA prediction, and delivery event aggregation for multi-carrier logistics.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ph-itdev/parcel-tracker
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const { } = require('@ph-itdev/parcel-tracker');
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
See source code for full API documentation.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
MIT
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
*Auto-generated by logistics-npm pipeline — 2026-07-02*
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// @ph-itdev/parcel-tracker CLI
|
|
4
|
+
// Usage: npx @ph-itdev/parcel-tracker playground
|
|
5
|
+
|
|
6
|
+
const http = require('http');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const { exec } = require('child_process');
|
|
10
|
+
|
|
11
|
+
const args = process.argv.slice(2);
|
|
12
|
+
const command = args[0];
|
|
13
|
+
|
|
14
|
+
if (command === 'playground' || command === 'demo' || command === 'play') {
|
|
15
|
+
startPlayground();
|
|
16
|
+
} else if (command === 'help' || !command) {
|
|
17
|
+
console.log(`
|
|
18
|
+
📦 @ph-itdev/parcel-tracker
|
|
19
|
+
|
|
20
|
+
Commands:
|
|
21
|
+
npx @ph-itdev/parcel-tracker playground Open interactive playground in browser
|
|
22
|
+
npx @ph-itdev/parcel-tracker demo Same as playground
|
|
23
|
+
npx @ph-itdev/parcel-tracker help Show this help
|
|
24
|
+
`);
|
|
25
|
+
} else {
|
|
26
|
+
console.log(`Unknown command: ${command}. Run with "help" for usage.`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function startPlayground() {
|
|
30
|
+
const examplePath = path.join(__dirname, '..', 'example', 'index.html');
|
|
31
|
+
|
|
32
|
+
if (!fs.existsSync(examplePath)) {
|
|
33
|
+
console.error('❌ Example file not found. Try: npm install @ph-itdev/parcel-tracker');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const html = fs.readFileSync(examplePath, 'utf-8');
|
|
38
|
+
|
|
39
|
+
const server = http.createServer((req, res) => {
|
|
40
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
41
|
+
res.end(html);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const PORT = 3456;
|
|
45
|
+
|
|
46
|
+
server.listen(PORT, '127.0.0.1', () => {
|
|
47
|
+
const url = `http://localhost:${PORT}`;
|
|
48
|
+
console.log(`
|
|
49
|
+
📦 @ph-itdev/parcel-tracker — Playground running!
|
|
50
|
+
|
|
51
|
+
🌐 Open: ${url}
|
|
52
|
+
|
|
53
|
+
Press Ctrl+C to stop.
|
|
54
|
+
`);
|
|
55
|
+
const platform = process.platform;
|
|
56
|
+
if (platform === 'darwin') exec(`open ${url}`);
|
|
57
|
+
else if (platform === 'win32') exec(`start ${url}`);
|
|
58
|
+
else exec(`xdg-open ${url} 2>/dev/null || echo "Open ${url} in your browser"`);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
server.on('error', (err) => {
|
|
62
|
+
if (err.code === 'EADDRINUSE') {
|
|
63
|
+
console.log(`⚠️ Port ${PORT} in use. Opening http://localhost:${PORT} instead.`);
|
|
64
|
+
const platform = process.platform;
|
|
65
|
+
if (platform === 'darwin') exec(`open http://localhost:${PORT}`);
|
|
66
|
+
else if (platform === 'win32') exec(`start http://localhost:${PORT}`);
|
|
67
|
+
else exec(`xdg-open http://localhost:${PORT} 2>/dev/null`);
|
|
68
|
+
} else {
|
|
69
|
+
console.error('Server error:', err);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>@ph-itdev/parcel-tracker — Live Playground</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
body { font-family: 'JetBrains Mono','Fira Code',monospace; background: #0a0e1a; color: #e0e6f0; min-height: 100vh; }
|
|
10
|
+
.header { background: linear-gradient(135deg, #0c1430 0%, #1a0a2e 100%); border-bottom: 1px solid rgba(0,229,255,0.15); padding: 24px 32px; text-align: center; }
|
|
11
|
+
.header h1 { font-size: 28px; color: #00e5ff; margin-bottom: 6px; letter-spacing: 2px; }
|
|
12
|
+
.header p { color: #7eb8c9; font-size: 13px; opacity: 0.7; }
|
|
13
|
+
.header .badge { display: inline-block; background: rgba(0,229,255,0.1); border: 1px solid rgba(0,229,255,0.3); color: #00e5ff; padding: 4px 12px; border-radius: 4px; font-size: 12px; margin-top: 10px; }
|
|
14
|
+
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
|
|
15
|
+
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
|
|
16
|
+
@media (max-width: 768px) { .grid { grid-template-columns: 1fr; } }
|
|
17
|
+
.panel { background: rgba(12,20,48,0.8); border: 1px solid rgba(0,229,255,0.1); border-radius: 10px; padding: 18px; }
|
|
18
|
+
.panel h2 { font-size: 14px; color: #00e5ff; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px dashed rgba(0,229,255,0.15); }
|
|
19
|
+
label { display: block; font-size: 11px; color: #7eb8c9; margin-bottom: 4px; letter-spacing: 1px; }
|
|
20
|
+
input, select { width: 100%; background: rgba(0,229,255,0.04); border: 1px solid rgba(0,229,255,0.15); color: #e0e6f0; padding: 8px 12px; border-radius: 6px; font-family: inherit; font-size: 13px; margin-bottom: 10px; outline: none; }
|
|
21
|
+
input:focus, select:focus { border-color: rgba(0,229,255,0.5); }
|
|
22
|
+
select option { background: #0c1430; }
|
|
23
|
+
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
|
|
24
|
+
button { background: linear-gradient(135deg, rgba(0,229,255,0.15), rgba(0,229,255,0.05)); border: 1px solid rgba(0,229,255,0.35); color: #00e5ff; padding: 10px 18px; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 13px; letter-spacing: 1px; transition: all 0.2s; margin-top: 4px; }
|
|
25
|
+
button:hover { background: rgba(0,229,255,0.2); box-shadow: 0 0 12px rgba(0,229,255,0.2); }
|
|
26
|
+
button.danger { border-color: rgba(255,100,100,0.4); color: #ff6464; }
|
|
27
|
+
button.danger:hover { background: rgba(255,100,100,0.15); }
|
|
28
|
+
.output { background: #060a14; border: 1px solid rgba(0,229,255,0.08); border-radius: 8px; padding: 14px; font-size: 12px; line-height: 1.6; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
|
|
29
|
+
.output .log { color: #7eb8c9; } .output .success { color: #28c840; } .output .error { color: #ff6464; } .output .info { color: #00e5ff; } .output .warn { color: #ffb352; }
|
|
30
|
+
.full-width { grid-column: 1 / -1; }
|
|
31
|
+
::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.2); border-radius: 3px; }
|
|
32
|
+
</style>
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<div class="header">
|
|
36
|
+
<h1>📦 parcel-tracker</h1>
|
|
37
|
+
<p>Unified parcel tracking across carriers with status normalization, ETA prediction, and delivery event aggregation for multi-carrier logistics.</p>
|
|
38
|
+
<span class="badge">npm install @ph-itdev/parcel-tracker</span>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="container">
|
|
41
|
+
<div class="grid">
|
|
42
|
+
<div class="panel">
|
|
43
|
+
<h2>🚀 Try It</h2>
|
|
44
|
+
<p style="font-size:12px;color:#7eb8c9;margin-bottom:12px;">Run in your terminal:</p>
|
|
45
|
+
<div class="output" style="max-height:none;">
|
|
46
|
+
<div class="info"># Install</div>
|
|
47
|
+
<div class="success">npm install @ph-itdev/parcel-tracker</div>
|
|
48
|
+
<br>
|
|
49
|
+
<div class="info"># Open playground</div>
|
|
50
|
+
<div class="success">npx parcel-tracker playground</div>
|
|
51
|
+
<br>
|
|
52
|
+
<div class="info"># Use in code</div>
|
|
53
|
+
<div class="log">const pkg = require('@ph-itdev/parcel-tracker');</div>
|
|
54
|
+
<div class="log">console.log(Object.keys(pkg));</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="panel">
|
|
58
|
+
<h2>📦 Package Info</h2>
|
|
59
|
+
<div class="output" style="max-height:none;">
|
|
60
|
+
<div class="log">Name: @ph-itdev/parcel-tracker</div>
|
|
61
|
+
<div class="log">Version: 1.0.0</div>
|
|
62
|
+
<div class="log">License: MIT</div>
|
|
63
|
+
<div class="log">Author: @ph-itdev</div>
|
|
64
|
+
<div class="log">Registry: npmjs.com</div>
|
|
65
|
+
<div class="log">Repo: github.com/nilskie06/parcel-tracker</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="panel full-width">
|
|
69
|
+
<h2>💻 Console</h2>
|
|
70
|
+
<div id="console" class="output"></div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
<script>
|
|
75
|
+
function log(msg, cls='log') {
|
|
76
|
+
const el = document.getElementById('console');
|
|
77
|
+
const line = document.createElement('div');
|
|
78
|
+
line.className = cls;
|
|
79
|
+
line.textContent = '[' + new Date().toLocaleTimeString() + '] ' + msg;
|
|
80
|
+
el.appendChild(line);
|
|
81
|
+
el.scrollTop = el.scrollHeight;
|
|
82
|
+
}
|
|
83
|
+
log('🚀 Welcome! This is the interactive playground for @ph-itdev/parcel-tracker', 'info');
|
|
84
|
+
log(' Install: npm install @ph-itdev/parcel-tracker', 'info');
|
|
85
|
+
log(' CLI: npx parcel-tracker playground', 'info');
|
|
86
|
+
</script>
|
|
87
|
+
</body>
|
|
88
|
+
</html>
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Parcel Tracking Client
|
|
2
|
+
// Unified parcel tracking across carriers with status normalization, ETA prediction, and delivery event aggregation for multi-carrier logistics.
|
|
3
|
+
// Auto-generated by @ph-itdev/logistics-pipeline
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const STATUSES = { CREATED: 0, PICKED_UP: 1, IN_TRANSIT: 2, OUT_FOR_DELIVERY: 3, DELIVERED: 4, EXCEPTION: -1 };
|
|
7
|
+
|
|
8
|
+
class ParcelTracker {
|
|
9
|
+
constructor() { this.parcels = new Map(); this.events = []; }
|
|
10
|
+
registerParcel(trackingNumber, { carrier = 'generic', origin, destination, weight }) {
|
|
11
|
+
this.parcels.set(trackingNumber, { trackingNumber, carrier, origin, destination, weight, status: 'CREATED', statusLevel: 0, events: [], eta: null });
|
|
12
|
+
}
|
|
13
|
+
addEvent(trackingNumber, { status, location, details = '' }) {
|
|
14
|
+
const p = this.parcels.get(trackingNumber);
|
|
15
|
+
if (!p) throw new Error('Parcel not found');
|
|
16
|
+
const level = STATUSES[status] ?? 2;
|
|
17
|
+
const event = { status, location, details, timestamp: Date.now() };
|
|
18
|
+
p.events.push(event);
|
|
19
|
+
this.events.push({ trackingNumber, ...event });
|
|
20
|
+
if (level > p.statusLevel || status === 'EXCEPTION') { p.status = status; p.statusLevel = level; }
|
|
21
|
+
}
|
|
22
|
+
setETA(trackingNumber, eta) { const p = this.parcels.get(trackingNumber); if (p) p.eta = eta; }
|
|
23
|
+
getParcel(trackingNumber) { return this.parcels.get(trackingNumber) || null; }
|
|
24
|
+
getByStatus(status) { return [...this.parcels.values()].filter(p => p.status === status); }
|
|
25
|
+
getByCarrier(carrier) { return [...this.parcels.values()].filter(p => p.carrier === carrier); }
|
|
26
|
+
getTransitTime(trackingNumber) {
|
|
27
|
+
const p = this.parcels.get(trackingNumber);
|
|
28
|
+
if (!p || p.events.length < 2) return null;
|
|
29
|
+
return p.events[p.events.length - 1].timestamp - p.events[0].timestamp;
|
|
30
|
+
}
|
|
31
|
+
getAggregatedStats() {
|
|
32
|
+
const parcels = [...this.parcels.values()];
|
|
33
|
+
const byStatus = {};
|
|
34
|
+
for (const p of parcels) byStatus[p.status] = (byStatus[p.status] || 0) + 1;
|
|
35
|
+
const delivered = parcels.filter(p => p.statusLevel >= 4);
|
|
36
|
+
const avgTransit = delivered.length ? delivered.reduce((s, p) => s + this.getTransitTime(p.trackingNumber), 0) / delivered.length : 0;
|
|
37
|
+
return { total: parcels.length, byStatus, avgTransitTimeMs: Math.round(avgTransit) };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
module.exports = { ParcelTracker, STATUSES };
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ph-itdev/parcel-tracker",
|
|
3
|
+
"version": "0.2026.0702",
|
|
4
|
+
"description": "Unified parcel tracking across carriers with status normalization, ETA prediction, and delivery event aggregation for multi-carrier logistics.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"bin": {
|
|
9
|
+
"parcel-tracker": "bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
14
|
+
"bin/",
|
|
15
|
+
"example/",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "node test.js",
|
|
20
|
+
"lint": "echo 'lint ok'",
|
|
21
|
+
"playground": "node bin/cli.js playground"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"logistics",
|
|
25
|
+
"automation",
|
|
26
|
+
"shipping",
|
|
27
|
+
"supply-chain",
|
|
28
|
+
"parcel"
|
|
29
|
+
],
|
|
30
|
+
"author": "@ph-itdev",
|
|
31
|
+
"license": "MIT \u00a9 Nilo Besingga",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/nilskie06/parcel-tracker.git"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/nilskie06/parcel-tracker#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/nilskie06/parcel-tracker/issues"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=14.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|