@flowselections/floriday-afhandeling-module 1.0.17 → 1.0.19
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/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.js +26 -7
- package/dist-lib/lib/authGateway.server.d.ts.map +1 -1
- package/dist-lib/lib/authGateway.server.js +11 -12
- package/dist-lib/lib/centralSecrets.server.d.ts +13 -0
- package/dist-lib/lib/centralSecrets.server.d.ts.map +1 -0
- package/dist-lib/lib/centralSecrets.server.js +83 -0
- package/dist-lib/lib/deliveryNotePrint.d.ts.map +1 -1
- package/dist-lib/lib/deliveryNotePrint.js +3 -3
- package/dist-lib/lib/floridayAutoProcess.d.ts.map +1 -1
- package/dist-lib/lib/floridayAutoProcess.js +3 -3
- package/dist-lib/lib/gatewayBase.d.ts +8 -0
- package/dist-lib/lib/gatewayBase.d.ts.map +1 -0
- package/dist-lib/lib/gatewayBase.js +26 -0
- package/dist-lib/lib/gatewayBase.server.d.ts +2 -0
- package/dist-lib/lib/gatewayBase.server.d.ts.map +1 -0
- package/dist-lib/lib/gatewayBase.server.js +18 -0
- package/dist-lib/lib/pickstationOrders.server.d.ts +4 -3
- package/dist-lib/lib/pickstationOrders.server.d.ts.map +1 -1
- package/dist-lib/lib/pickstationOrders.server.js +6 -6
- package/dist-lib/lib/serverRoutes/dispatchCarrierSignups.handler.d.ts +3 -0
- package/dist-lib/lib/serverRoutes/dispatchCarrierSignups.handler.d.ts.map +1 -0
- package/dist-lib/lib/serverRoutes/dispatchCarrierSignups.handler.js +321 -0
- package/dist-lib/lib/serverRoutes/index.d.ts +6 -0
- package/dist-lib/lib/serverRoutes/index.d.ts.map +1 -0
- package/dist-lib/lib/serverRoutes/index.js +8 -0
- package/dist-lib/lib/serverRoutes/logisticsTick.handler.d.ts +3 -0
- package/dist-lib/lib/serverRoutes/logisticsTick.handler.d.ts.map +1 -0
- package/dist-lib/lib/serverRoutes/logisticsTick.handler.js +37 -0
- package/dist-lib/lib/serverRoutes/pickstationOrders.handler.d.ts +3 -0
- package/dist-lib/lib/serverRoutes/pickstationOrders.handler.d.ts.map +1 -0
- package/dist-lib/lib/serverRoutes/pickstationOrders.handler.js +58 -0
- package/dist-lib/lib/serverRoutes/pickstationPrint.handler.d.ts +3 -0
- package/dist-lib/lib/serverRoutes/pickstationPrint.handler.d.ts.map +1 -0
- package/dist-lib/lib/serverRoutes/pickstationPrint.handler.js +116 -0
- package/dist-lib/lib/serverRoutes/pickstationStatus.handler.d.ts +3 -0
- package/dist-lib/lib/serverRoutes/pickstationStatus.handler.d.ts.map +1 -0
- package/dist-lib/lib/serverRoutes/pickstationStatus.handler.js +28 -0
- package/package.json +154 -128
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Very small in-memory rate limit per worker instance: max 60 prints / minute per IP.
|
|
2
|
+
const buckets = new Map();
|
|
3
|
+
function rateLimited(ip) {
|
|
4
|
+
const now = Date.now();
|
|
5
|
+
const b = buckets.get(ip);
|
|
6
|
+
if (!b || now - b.ts > 60000) {
|
|
7
|
+
buckets.set(ip, { ts: now, count: 1 });
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
b.count++;
|
|
11
|
+
return b.count > 60;
|
|
12
|
+
}
|
|
13
|
+
export async function handlePickstationPrint(request, supabase) {
|
|
14
|
+
const requestId = crypto.randomUUID();
|
|
15
|
+
const startedAt = Date.now();
|
|
16
|
+
const ip = request.headers.get("cf-connecting-ip") ??
|
|
17
|
+
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ??
|
|
18
|
+
null;
|
|
19
|
+
console.info("[pickstation-api] POST print", {
|
|
20
|
+
requestId,
|
|
21
|
+
at: new Date().toISOString(),
|
|
22
|
+
ip: ip ? "present" : "missing",
|
|
23
|
+
});
|
|
24
|
+
if (ip && rateLimited(ip)) {
|
|
25
|
+
return Response.json({ error: "Te veel verzoeken" }, { status: 429 });
|
|
26
|
+
}
|
|
27
|
+
let body;
|
|
28
|
+
try {
|
|
29
|
+
body = await request.json();
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return Response.json({ error: "Ongeldige body" }, { status: 400 });
|
|
33
|
+
}
|
|
34
|
+
if (!body.orderId || typeof body.orderId !== "string") {
|
|
35
|
+
return Response.json({ error: "orderId verplicht" }, { status: 400 });
|
|
36
|
+
}
|
|
37
|
+
const docs = Array.isArray(body.documents) ? body.documents.slice(0, 5) : [];
|
|
38
|
+
const wantsAuction = docs.includes("auction-letter");
|
|
39
|
+
const wantsDeliveryNote = docs.includes("delivery-note");
|
|
40
|
+
const isConfirmation = body.confirmed === true;
|
|
41
|
+
const { fetchFloridayAuctionLetterPdf, fetchFloridayDeliveryNotePdf, logPrint } = await import("../pickstationOrders.server");
|
|
42
|
+
const sourceOrderId = typeof body.sourceOrderId === "string" && body.sourceOrderId
|
|
43
|
+
? body.sourceOrderId
|
|
44
|
+
: body.orderId;
|
|
45
|
+
let auctionLetter = null;
|
|
46
|
+
let deliveryNote = null;
|
|
47
|
+
if (!isConfirmation) {
|
|
48
|
+
const tasks = [];
|
|
49
|
+
if (wantsAuction) {
|
|
50
|
+
tasks.push((async () => {
|
|
51
|
+
try {
|
|
52
|
+
auctionLetter = await fetchFloridayAuctionLetterPdf(sourceOrderId);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.warn("[pickstation-api] auction letter unavailable", {
|
|
56
|
+
requestId,
|
|
57
|
+
sourceOrderId,
|
|
58
|
+
message: e instanceof Error ? e.message : String(e),
|
|
59
|
+
});
|
|
60
|
+
auctionLetter = null;
|
|
61
|
+
}
|
|
62
|
+
})());
|
|
63
|
+
}
|
|
64
|
+
if (wantsDeliveryNote) {
|
|
65
|
+
tasks.push((async () => {
|
|
66
|
+
try {
|
|
67
|
+
deliveryNote = await fetchFloridayDeliveryNotePdf(sourceOrderId);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
console.warn("[pickstation-api] delivery note unavailable", {
|
|
71
|
+
requestId,
|
|
72
|
+
sourceOrderId,
|
|
73
|
+
message: e instanceof Error ? e.message : String(e),
|
|
74
|
+
});
|
|
75
|
+
deliveryNote = null;
|
|
76
|
+
}
|
|
77
|
+
})());
|
|
78
|
+
}
|
|
79
|
+
if (tasks.length > 0)
|
|
80
|
+
await Promise.all(tasks);
|
|
81
|
+
}
|
|
82
|
+
const printedDocs = docs;
|
|
83
|
+
let warning;
|
|
84
|
+
if (isConfirmation && printedDocs.length > 0) {
|
|
85
|
+
try {
|
|
86
|
+
await logPrint(body.orderId, body.orderNumber ?? null, body.customerName ?? null, printedDocs, ip, supabase);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
const message = e instanceof Error ? e.message : "Onbekende fout";
|
|
90
|
+
warning = `De printstatus kon niet worden opgeslagen: ${message}`;
|
|
91
|
+
console.error("[pickstation-api] print log failed", {
|
|
92
|
+
requestId,
|
|
93
|
+
orderId: body.orderId,
|
|
94
|
+
message,
|
|
95
|
+
stack: e instanceof Error ? e.stack : undefined,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
console.info("[pickstation-api] POST print completed", {
|
|
100
|
+
requestId,
|
|
101
|
+
orderId: body.orderId,
|
|
102
|
+
printedDocuments: printedDocs,
|
|
103
|
+
auctionLetter: auctionLetter ? "present" : "absent",
|
|
104
|
+
deliveryNote: deliveryNote ? "present" : "absent",
|
|
105
|
+
warning: warning ?? null,
|
|
106
|
+
durationMs: Date.now() - startedAt,
|
|
107
|
+
});
|
|
108
|
+
return Response.json({
|
|
109
|
+
ok: !warning,
|
|
110
|
+
warning,
|
|
111
|
+
auctionLetter,
|
|
112
|
+
deliveryNote,
|
|
113
|
+
printedDocuments: printedDocs,
|
|
114
|
+
requestId,
|
|
115
|
+
}, { headers: { "Cache-Control": "no-store", "X-Robots-Tag": "noindex, nofollow" } });
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickstationStatus.handler.d.ts","sourceRoot":"","sources":["../../../src/lib/serverRoutes/pickstationStatus.handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAwCnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const ALLOWED = ["pending", "checked", "ready", "shipped", "delivered"];
|
|
2
|
+
export async function handlePickstationStatus(request, supabase) {
|
|
3
|
+
const requestId = crypto.randomUUID();
|
|
4
|
+
let body;
|
|
5
|
+
try {
|
|
6
|
+
body = await request.json();
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return Response.json({ error: "Ongeldige body" }, { status: 400 });
|
|
10
|
+
}
|
|
11
|
+
if (!body.orderId ||
|
|
12
|
+
(body.orderSource !== "floriday" && body.orderSource !== "manual") ||
|
|
13
|
+
typeof body.cartIndex !== "number" ||
|
|
14
|
+
!body.status ||
|
|
15
|
+
!ALLOWED.includes(body.status)) {
|
|
16
|
+
return Response.json({ error: "Ongeldige invoer" }, { status: 400 });
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const { setCartStatus } = await import("../pickstationOrders.server");
|
|
20
|
+
await setCartStatus(body.orderSource, body.orderId, body.cartIndex, body.status, supabase);
|
|
21
|
+
return Response.json({ ok: true, requestId }, { headers: { "Cache-Control": "no-store", "X-Robots-Tag": "noindex, nofollow" } });
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
25
|
+
console.error("[pickstation-api] set status failed", { requestId, message });
|
|
26
|
+
return Response.json({ ok: false, error: message }, { status: 500 });
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,128 +1,154 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@flowselections/floriday-afhandeling-module",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"sideEffects": false,
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist-lib/index.js",
|
|
8
|
-
"types": "./dist-lib/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist-lib/index.d.ts",
|
|
12
|
-
"default": "./dist-lib/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
},
|
|
42
|
-
"
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"react": "^
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
"export": "
|
|
80
|
-
"route": "afhandeling/leveringen
|
|
81
|
-
"title": "
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"export": "
|
|
91
|
-
"route": "afhandeling/
|
|
92
|
-
"title": "
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"export": "
|
|
96
|
-
"route": "
|
|
97
|
-
"title": "
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowselections/floriday-afhandeling-module",
|
|
3
|
+
"version": "1.0.19",
|
|
4
|
+
"private": false,
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist-lib/index.js",
|
|
8
|
+
"types": "./dist-lib/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist-lib/index.d.ts",
|
|
12
|
+
"default": "./dist-lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./server-routes": {
|
|
15
|
+
"types": "./dist-lib/lib/serverRoutes/index.d.ts",
|
|
16
|
+
"default": "./dist-lib/lib/serverRoutes/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./styles": "./dist-lib/styles.css"
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
"files": [
|
|
22
|
+
"dist-lib"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "vite dev",
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
|
|
31
|
+
"build:lib:watch": "tsc -p tsconfig.build.json --watch",
|
|
32
|
+
"build:dev": "vite build --mode development",
|
|
33
|
+
"preview": "vite preview",
|
|
34
|
+
"lint": "eslint ."
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@flowselections/core": "*",
|
|
38
|
+
"@tanstack/react-query": "^5",
|
|
39
|
+
"react": "^18 || ^19",
|
|
40
|
+
"react-dom": "^18 || ^19"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@ai-sdk/openai-compatible": "^3.0.9",
|
|
44
|
+
"@supabase/supabase-js": "^2.106.2",
|
|
45
|
+
"ai": "^7.0.26"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@cloudflare/vite-plugin": "^1.25.5",
|
|
49
|
+
"@eslint/js": "^9.32.0",
|
|
50
|
+
"@flowselections/core": "1.0.16",
|
|
51
|
+
"@lovable.dev/vite-tanstack-config": "2.7.7",
|
|
52
|
+
"@rsbuild/core": "^1.0.0",
|
|
53
|
+
"@tailwindcss/vite": "^4.2.1",
|
|
54
|
+
"@tanstack/react-query": "^5.83.0",
|
|
55
|
+
"@tanstack/router-plugin": "^1.167.10",
|
|
56
|
+
"@types/node": "^22.16.5",
|
|
57
|
+
"@types/react": "^19.2.0",
|
|
58
|
+
"@types/react-dom": "^19.2.0",
|
|
59
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
60
|
+
"eslint": "^9.32.0",
|
|
61
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
62
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
63
|
+
"globals": "^15.15.0",
|
|
64
|
+
"react": "^19.2.0",
|
|
65
|
+
"react-dom": "^19.2.0",
|
|
66
|
+
"tailwindcss": "^4.2.1",
|
|
67
|
+
"tw-animate-css": "^1.3.4",
|
|
68
|
+
"typescript": "^5.8.3",
|
|
69
|
+
"tsc-alias": "^1.8.0",
|
|
70
|
+
"typescript-eslint": "^8.56.1",
|
|
71
|
+
"vite": "^7.3.1",
|
|
72
|
+
"vite-tsconfig-paths": "^6.0.2",
|
|
73
|
+
"nitro": "3.0.260603-beta"
|
|
74
|
+
},
|
|
75
|
+
"flowselections": {
|
|
76
|
+
"moduleId": "Afhandeling",
|
|
77
|
+
"pages": [
|
|
78
|
+
{
|
|
79
|
+
"export": "LeveringenPage",
|
|
80
|
+
"route": "afhandeling/leveringen",
|
|
81
|
+
"title": "Planning en Leveringen"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"export": "NieuweLeveringPage",
|
|
85
|
+
"route": "afhandeling/leveringen/nieuw",
|
|
86
|
+
"title": "Levering aanmaken",
|
|
87
|
+
"nav": false
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"export": "PickingPage",
|
|
91
|
+
"route": "afhandeling/picking",
|
|
92
|
+
"title": "Pick Agenda"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"export": "ControlePage",
|
|
96
|
+
"route": "afhandeling/controle",
|
|
97
|
+
"title": "Controle Karren"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"export": "PickstationPage",
|
|
101
|
+
"route": "pickstation",
|
|
102
|
+
"title": "Pickstation",
|
|
103
|
+
"nav": false,
|
|
104
|
+
"public": true
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"export": "KioskControle",
|
|
108
|
+
"route": "controle",
|
|
109
|
+
"title": "KioskControle",
|
|
110
|
+
"nav": false,
|
|
111
|
+
"public": true
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"export": "VervoerdersPage",
|
|
115
|
+
"route": "afhandeling/vervoerders",
|
|
116
|
+
"title": "Vervoerders",
|
|
117
|
+
"nav": false
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"export": "VervoerderForm",
|
|
121
|
+
"route": "afhandeling/vervoerders/nieuw",
|
|
122
|
+
"title": "Nieuwe vervoerder",
|
|
123
|
+
"nav": false
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"export": "VervoerderForm",
|
|
127
|
+
"route": "afhandeling/vervoerders/$id/bewerken",
|
|
128
|
+
"title": "Vervoerder bewerken",
|
|
129
|
+
"nav": false
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"serverRoutes": [
|
|
133
|
+
{
|
|
134
|
+
"routePath": "/api/public/pickstation/orders",
|
|
135
|
+
"import": "@flowselections/floriday-afhandeling-module/server-routes",
|
|
136
|
+
"handler": "handlePickstationOrders",
|
|
137
|
+
"methods": ["GET"]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"routePath": "/api/public/pickstation/print",
|
|
141
|
+
"import": "@flowselections/floriday-afhandeling-module/server-routes",
|
|
142
|
+
"handler": "handlePickstationPrint",
|
|
143
|
+
"methods": ["POST"]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"routePath": "/api/public/pickstation/status",
|
|
147
|
+
"import": "@flowselections/floriday-afhandeling-module/server-routes",
|
|
148
|
+
"handler": "handlePickstationStatus",
|
|
149
|
+
"methods": ["POST"]
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|