@ph-itdev/delivery-window-scheduler 0.2026.630

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 ADDED
@@ -0,0 +1,26 @@
1
+ # @ph-itdev/delivery-window-scheduler
2
+
3
+ Schedule and manage delivery windows with conflict detection, priority routing, and SLA compliance tracking for last-mile logistics.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ph-itdev/delivery-window-scheduler
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```javascript
14
+ const { } = require('@ph-itdev/delivery-window-scheduler');
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-06-30*
package/bin/cli.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ // @ph-itdev/delivery-window-scheduler CLI
4
+ // Usage: npx @ph-itdev/delivery-window-scheduler 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/delivery-window-scheduler
19
+
20
+ Commands:
21
+ npx @ph-itdev/delivery-window-scheduler playground Open interactive playground in browser
22
+ npx @ph-itdev/delivery-window-scheduler demo Same as playground
23
+ npx @ph-itdev/delivery-window-scheduler 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/delivery-window-scheduler');
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/delivery-window-scheduler — 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/delivery-window-scheduler — 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>📦 delivery-window-scheduler</h1>
37
+ <p>Schedule and manage delivery windows with conflict detection, priority routing, and SLA compliance tracking for last-mile logistics.</p>
38
+ <span class="badge">npm install @ph-itdev/delivery-window-scheduler</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/delivery-window-scheduler</div>
48
+ <br>
49
+ <div class="info"># Open playground</div>
50
+ <div class="success">npx delivery-window-scheduler playground</div>
51
+ <br>
52
+ <div class="info"># Use in code</div>
53
+ <div class="log">const pkg = require('@ph-itdev/delivery-window-scheduler');</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/delivery-window-scheduler</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/delivery-window-scheduler</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/delivery-window-scheduler', 'info');
84
+ log(' Install: npm install @ph-itdev/delivery-window-scheduler', 'info');
85
+ log(' CLI: npx delivery-window-scheduler playground', 'info');
86
+ </script>
87
+ </body>
88
+ </html>
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Type definitions for @ph-itdev/delivery-window-scheduler
2
+ export * from './index.js';
package/index.js ADDED
@@ -0,0 +1,54 @@
1
+ // Delivery Window Scheduler
2
+ // Schedule and manage delivery windows with conflict detection, priority routing, and SLA compliance tracking for last-mile logistics.
3
+ // Auto-generated by @ph-itdev/logistics-pipeline
4
+
5
+
6
+ class DeliveryWindowScheduler {
7
+ constructor({ businessHours = { start: 8, end: 18 } } = {}) {
8
+ this.windows = new Map();
9
+ this.bookings = [];
10
+ this.businessHours = businessHours;
11
+ }
12
+ createWindow(id, { date, startHour, endHour, maxDeliveries = 5, zone = 'default' }) {
13
+ if (startHour < this.businessHours.start || endHour > this.businessHours.end)
14
+ throw new Error(`Window must be within business hours (${this.businessHours.start}-${this.businessHours.end})`);
15
+ this.windows.set(id, { id, date, startHour, endHour, maxDeliveries, zone, bookings: [] });
16
+ }
17
+ bookDelivery(windowId, { orderId, address, priority = 'normal', etaMinutes = 30 }) {
18
+ const w = this.windows.get(windowId);
19
+ if (!w) throw new Error('Window not found');
20
+ if (w.bookings.length >= w.maxDeliveries) throw new Error('Window is full');
21
+ const conflict = w.bookings.find(b => b.orderId === orderId);
22
+ if (conflict) throw new Error('Order already booked in this window');
23
+ const sla = { promisedBy: w.endHour, estimatedDelivery: w.startHour + (etaMinutes / 60), priority };
24
+ sla.compliant = sla.estimatedDelivery <= sla.promisedBy || priority === 'urgent';
25
+ const booking = { orderId, address, priority, etaMinutes, windowId, ts: Date.now(), sla };
26
+ w.bookings.push(booking);
27
+ this.bookings.push(booking);
28
+ return booking;
29
+ }
30
+ cancelBooking(windowId, orderId) {
31
+ const w = this.windows.get(windowId);
32
+ if (!w) throw new Error('Window not found');
33
+ const idx = w.bookings.findIndex(b => b.orderId === orderId);
34
+ if (idx === -1) throw new Error('Booking not found');
35
+ w.bookings.splice(idx, 1);
36
+ this.bookings = this.bookings.filter(b => !(b.windowId === windowId && b.orderId === orderId));
37
+ }
38
+ getWindowStatus(windowId) {
39
+ const w = this.windows.get(windowId);
40
+ if (!w) throw new Error('Window not found');
41
+ return { id: w.id, date: w.date, hours: `${w.startHour}:00-${w.endHour}:00`, zone: w.zone, filled: w.bookings.length, capacity: w.maxDeliveries, available: w.maxDeliveries - w.bookings.length };
42
+ }
43
+ getSLAReport() {
44
+ const total = this.bookings.length;
45
+ const compliant = this.bookings.filter(b => b.sla.compliant).length;
46
+ return { total, compliant, violations: total - compliant, complianceRate: total ? +((compliant / total) * 100).toFixed(1) : 100 };
47
+ }
48
+ getOverbookedWindows() {
49
+ return [...this.windows.values()].filter(w => w.bookings.length >= w.maxDeliveries).map(w => ({ id: w.id, date: w.date, zone: w.zone }));
50
+ }
51
+ }
52
+
53
+
54
+ module.exports = { DeliveryWindowScheduler };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@ph-itdev/delivery-window-scheduler",
3
+ "version": "0.2026.0630",
4
+ "description": "Schedule and manage delivery windows with conflict detection, priority routing, and SLA compliance tracking for last-mile logistics.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "commonjs",
8
+ "bin": {
9
+ "delivery-window-scheduler": "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
+ "delivery"
29
+ ],
30
+ "author": "@ph-itdev",
31
+ "license": "MIT \u00a9 Nilo Besingga",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/nilskie06/delivery-window-scheduler.git"
35
+ },
36
+ "homepage": "https://github.com/nilskie06/delivery-window-scheduler#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/nilskie06/delivery-window-scheduler/issues"
39
+ },
40
+ "engines": {
41
+ "node": ">=14.0.0"
42
+ }
43
+ }