@flowselections/logistiek-engine 1.0.109 → 1.0.111
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/components/FlowOrders.js +1 -1
- package/dist-lib/components/MinuutrondeCard.d.ts.map +1 -1
- package/dist-lib/components/MinuutrondeCard.js +9 -1
- package/dist-lib/components/MisluktVerzendbrievenCard.js +1 -1
- package/dist-lib/hooks/useAfrondWachtrij.js +1 -1
- package/dist-lib/hooks/useBeladingsafwijkingen.js +1 -1
- package/dist-lib/hooks/useGeblokkeerdeOrders.js +1 -1
- package/dist-lib/hooks/useLogisticsTrace.js +1 -1
- package/dist-lib/hooks/useMinuutronde.js +1 -1
- package/dist-lib/hooks/useOrderTrace.js +1 -1
- package/dist-lib/hooks/useOrderVersies.js +1 -1
- package/dist-lib/hooks/usePlanWachtrij.js +1 -1
- package/dist-lib/hooks/useRecalcJob.js +1 -1
- package/dist-lib/hooks/useShellAdres.d.ts +20 -0
- package/dist-lib/hooks/useShellAdres.d.ts.map +1 -0
- package/dist-lib/hooks/useShellAdres.js +60 -0
- package/dist-lib/hooks/useTaakGezondheid.js +1 -1
- package/dist-lib/hooks/useWerktijden.js +1 -1
- package/dist-lib/hooks/useWerkwijzeStatus.js +1 -1
- package/dist-lib/index.d.ts +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +2 -0
- package/dist-lib/integrations/supabase/client.server.d.ts +2 -32181
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/moduleClient.d.ts +1 -32181
- package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +941 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/attachAuthToken.js +1 -1
- package/dist-lib/lib/cartCoverage.functions.d.ts +1 -1
- package/dist-lib/lib/cartCoverage.functions.js +3 -3
- package/dist-lib/lib/floridayDocuments.functions.d.ts +3 -3
- package/dist-lib/lib/floridayDocuments.functions.js +5 -5
- package/dist-lib/lib/floridayPush.functions.d.ts +1 -1
- package/dist-lib/lib/floridayPush.functions.js +3 -3
- package/dist-lib/lib/handlers/index.d.ts +1 -0
- package/dist-lib/lib/handlers/index.d.ts.map +1 -1
- package/dist-lib/lib/handlers/index.js +1 -0
- package/dist-lib/lib/handlers/logistics-ping.server.d.ts +4 -0
- package/dist-lib/lib/handlers/logistics-ping.server.d.ts.map +1 -0
- package/dist-lib/lib/handlers/logistics-ping.server.js +28 -0
- package/dist-lib/lib/handlers/logistics-tick.server.d.ts.map +1 -1
- package/dist-lib/lib/handlers/logistics-tick.server.js +2 -1
- package/dist-lib/lib/loadCarrierPlanning.functions.d.ts +5 -5
- package/dist-lib/lib/loadCarrierPlanning.functions.js +7 -7
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts +2 -2
- package/dist-lib/lib/logisticsRecalcJob.functions.js +4 -4
- package/dist-lib/lib/logisticsRecalculate.functions.d.ts +1 -1
- package/dist-lib/lib/logisticsRecalculate.functions.js +2 -2
- package/dist-lib/lib/modulePrompts.d.ts.map +1 -1
- package/dist-lib/lib/modulePrompts.js +29 -0
- package/dist-lib/lib/moduleVersion.d.ts +1 -1
- package/dist-lib/lib/moduleVersion.js +1 -1
- package/dist-lib/lib/plannerDiff.functions.d.ts +1 -1
- package/dist-lib/lib/plannerDiff.functions.js +3 -3
- package/dist-lib/lib/shellAdres.d.ts +15 -0
- package/dist-lib/lib/shellAdres.d.ts.map +1 -0
- package/dist-lib/lib/shellAdres.functions.d.ts +15 -0
- package/dist-lib/lib/shellAdres.functions.d.ts.map +1 -0
- package/dist-lib/lib/shellAdres.functions.js +41 -0
- package/dist-lib/lib/shellAdres.js +50 -0
- package/package.json +13 -3
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// we herkennen de sleutel op zijn vorm (sb-...-auth-token).
|
|
9
9
|
// ============================================================================
|
|
10
10
|
import { createMiddleware } from "@tanstack/react-start";
|
|
11
|
-
import { supabase } from "../integrations/supabase/moduleClient";
|
|
11
|
+
import { supabase } from "../integrations/supabase/moduleClient.js";
|
|
12
12
|
function tokenFromStorage() {
|
|
13
13
|
if (typeof window === "undefined")
|
|
14
14
|
return null;
|
|
@@ -18,7 +18,7 @@ export interface CoverageResult {
|
|
|
18
18
|
afwijkingen: CoverageAfwijking[];
|
|
19
19
|
}
|
|
20
20
|
export declare const getCartCoverage: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
21
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
21
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
22
22
|
userId: string;
|
|
23
23
|
claims: import("@supabase/auth-js").User;
|
|
24
24
|
}, undefined, undefined, undefined>], undefined, Promise<CoverageResult>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Alleen-lezen controle: staat elke bestelregel correct op een kar?
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
4
|
-
import { readableServerErrors } from "
|
|
3
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
4
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
5
5
|
export const getCartCoverage = createServerFn({ method: "GET" })
|
|
6
6
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
7
7
|
.handler(async () => {
|
|
8
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
8
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
9
9
|
const { data, error } = await supabaseAdmin.rpc("logistics_cart_coverage_check");
|
|
10
10
|
if (error)
|
|
11
11
|
throw new Error(error.message);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** Actieve Floriday-koppeling voor de banner in het instellingenscherm. */
|
|
2
2
|
export declare const getFloridayConnection: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], undefined, Promise<import("./floridayDocuments.server").FloridayActiveConnection | import("./floridayDocuments.server").FloridayConnectionError>>;
|
|
7
7
|
/** Eén document voor een printtaak. ok:false is een printfout, geen crash. */
|
|
8
8
|
export declare const fetchLogisticsDocument: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
9
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
9
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
10
10
|
userId: string;
|
|
11
11
|
claims: import("@supabase/auth-js").User;
|
|
12
12
|
}, undefined, undefined, undefined>], (input: {
|
|
@@ -45,7 +45,7 @@ export declare const fetchLogisticsDocument: import("@tanstack/start-client-core
|
|
|
45
45
|
}>>;
|
|
46
46
|
/** Meerdere regels van één kar/afmelding als één printjob. */
|
|
47
47
|
export declare const fetchMergedLogisticsDocuments: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
48
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
48
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
49
49
|
userId: string;
|
|
50
50
|
claims: import("@supabase/auth-js").User;
|
|
51
51
|
}, undefined, undefined, undefined>], (input: {
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
// createServerFn-declaraties. Alle logica staat in floridayDocuments.server.ts.
|
|
5
5
|
// ============================================================================
|
|
6
6
|
import { createServerFn } from "@tanstack/react-start";
|
|
7
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
8
|
-
import { readableServerErrors } from "
|
|
7
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
8
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
9
9
|
/** Actieve Floriday-koppeling voor de banner in het instellingenscherm. */
|
|
10
10
|
export const getFloridayConnection = createServerFn({ method: "GET" })
|
|
11
11
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
12
12
|
.handler(async () => {
|
|
13
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
13
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
14
14
|
const { getFlorydayActiveConnection } = await import("./floridayDocuments.server");
|
|
15
15
|
return getFlorydayActiveConnection(supabaseAdmin);
|
|
16
16
|
});
|
|
@@ -19,7 +19,7 @@ export const fetchLogisticsDocument = createServerFn({ method: "POST" })
|
|
|
19
19
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
20
20
|
.inputValidator((input) => input)
|
|
21
21
|
.handler(async ({ data }) => {
|
|
22
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
22
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
23
23
|
const { getFlorydayDocument, claimDocumentPrint, finishDocumentPrint } = await import("./floridayDocuments.server");
|
|
24
24
|
const supabase = supabaseAdmin;
|
|
25
25
|
const claim = await claimDocumentPrint(supabase, {
|
|
@@ -48,7 +48,7 @@ export const fetchMergedLogisticsDocuments = createServerFn({ method: "POST" })
|
|
|
48
48
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
49
49
|
.inputValidator((input) => input)
|
|
50
50
|
.handler(async ({ data }) => {
|
|
51
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
51
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
52
52
|
const { getFlorydayMergedDocument, claimDocumentPrint, finishDocumentPrint } = await import("./floridayDocuments.server");
|
|
53
53
|
const supabase = supabaseAdmin;
|
|
54
54
|
const claim = await claimDocumentPrint(supabase, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Zet een order opnieuw in de wachtrij (handmatig opnieuw proberen). */
|
|
2
2
|
export declare const retryFloridayPush: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], (data: {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// src/lib/floridayPush.functions.ts — server functions (thin wrappers)
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import { createServerFn } from "@tanstack/react-start";
|
|
5
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
6
|
-
import { readableServerErrors } from "
|
|
5
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
6
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
7
7
|
/** Zet een order opnieuw in de wachtrij (handmatig opnieuw proberen). */
|
|
8
8
|
export const retryFloridayPush = createServerFn({ method: "POST" })
|
|
9
9
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
@@ -14,7 +14,7 @@ export const retryFloridayPush = createServerFn({ method: "POST" })
|
|
|
14
14
|
return data;
|
|
15
15
|
})
|
|
16
16
|
.handler(async ({ data }) => {
|
|
17
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
17
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
18
18
|
const { queueFloridayPush } = await import("./floridayPush.server");
|
|
19
19
|
await queueFloridayPush(supabaseAdmin, data.orderRef);
|
|
20
20
|
return { ok: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/handlers/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/handlers/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
export { handleLogisticsTick } from "./logistics-tick.server.js";
|
|
5
5
|
export { handleShippingNoteNow } from "./logistics-shipping-note-now.server.js";
|
|
6
|
+
export { handleLogisticsPing } from "./logistics-ping.server.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logistics-ping.server.d.ts","sourceRoot":"","sources":["../../../src/lib/handlers/logistics-ping.server.ts"],"names":[],"mappings":"AAiBA,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACjC,OAAO,CAAC,QAAQ,CAAC,CAiBnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// src/lib/handlers/logistics-ping.server.ts — testroute "bedient de Shell mij?"
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// /api/public/hooks/logistics-ping. Doet niets in de database. Geeft altijd een
|
|
5
|
+
// eigen, herkenbaar antwoord (engine = "logistiek-engine"): 200 met geldige
|
|
6
|
+
// sleutel, 401 zonder. Zo is een 404 of websitepagina altijd te onderscheiden.
|
|
7
|
+
// Sleutel komt uit de omgeving (fail closed: ontbreekt hij, dan 401).
|
|
8
|
+
// ============================================================================
|
|
9
|
+
import { engineIdent } from "./logistics-tick.server.js";
|
|
10
|
+
const CORS_HEADERS = {
|
|
11
|
+
"Access-Control-Allow-Origin": "*",
|
|
12
|
+
"Access-Control-Allow-Headers": "apikey, authorization, content-type",
|
|
13
|
+
"Access-Control-Allow-Methods": "POST, GET, OPTIONS",
|
|
14
|
+
};
|
|
15
|
+
export async function handleLogisticsPing(request, opts) {
|
|
16
|
+
if (request.method === "OPTIONS") {
|
|
17
|
+
return new Response(null, { status: 204, headers: CORS_HEADERS });
|
|
18
|
+
}
|
|
19
|
+
const ident = engineIdent(opts);
|
|
20
|
+
const apikey = request.headers.get("apikey") ??
|
|
21
|
+
request.headers.get("authorization")?.replace(/^Bearer /i, "") ??
|
|
22
|
+
"";
|
|
23
|
+
const expected = (process.env["SUPABASE_PUBLISHABLE_KEY"] ?? process.env["SUPABASE_ANON_KEY"] ?? "").replace(/^["']|["']$/g, "");
|
|
24
|
+
if (!expected || apikey !== expected) {
|
|
25
|
+
return Response.json({ ...ident, ok: false, error: "Unauthorized" }, { status: 401, headers: CORS_HEADERS });
|
|
26
|
+
}
|
|
27
|
+
return Response.json({ ...ident, ok: true, ping: true }, { status: 200, headers: CORS_HEADERS });
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logistics-tick.server.d.ts","sourceRoot":"","sources":["../../../src/lib/handlers/logistics-tick.server.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE;;;;EAE7D;AAQD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACjC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"logistics-tick.server.d.ts","sourceRoot":"","sources":["../../../src/lib/handlers/logistics-tick.server.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE;;;;EAE7D;AAQD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACjC,OAAO,CAAC,QAAQ,CAAC,CA6EnB;AAED,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,eAAe,CAAC"}
|
|
@@ -31,7 +31,8 @@ export async function handleLogisticsTick(request, supabase, opts) {
|
|
|
31
31
|
process.env["SUPABASE_ANON_KEY"] ??
|
|
32
32
|
"").replace(/^["']|["']$/g, "");
|
|
33
33
|
if (!expected || apikey !== expected) {
|
|
34
|
-
|
|
34
|
+
// Eigen, herkenbare weigering: de Shell-adrescontrole telt dit als "route aanwezig".
|
|
35
|
+
return new Response(JSON.stringify({ ...ident, ok: false, error: "Unauthorized" }), {
|
|
35
36
|
status: 401,
|
|
36
37
|
headers: { "Content-Type": "application/json", ...CORS_HEADERS },
|
|
37
38
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const replanOrderLoadCarriers: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
2
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
2
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
3
3
|
userId: string;
|
|
4
4
|
claims: import("@supabase/auth-js").User;
|
|
5
5
|
}, undefined, undefined, undefined>], (data: {
|
|
@@ -12,7 +12,7 @@ export declare const replanOrderLoadCarriers: import("@tanstack/start-client-cor
|
|
|
12
12
|
carrierType?: string | null;
|
|
13
13
|
}, Promise<import("./loadCarrierPlanning.server").ReplanResult | null>>;
|
|
14
14
|
export declare const replanBufferLoadCarriers: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
15
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
15
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
16
16
|
userId: string;
|
|
17
17
|
claims: import("@supabase/auth-js").User;
|
|
18
18
|
}, undefined, undefined, undefined>], (data: {
|
|
@@ -29,7 +29,7 @@ export declare const replanBufferLoadCarriers: import("@tanstack/start-client-co
|
|
|
29
29
|
* `done` waar is en schakelt dan door naar de volgende fase.
|
|
30
30
|
*/
|
|
31
31
|
export declare const planAllLoadCarriers: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
32
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
32
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
33
33
|
userId: string;
|
|
34
34
|
claims: import("@supabase/auth-js").User;
|
|
35
35
|
}, undefined, undefined, undefined>], (data?: {
|
|
@@ -46,7 +46,7 @@ export declare const planAllLoadCarriers: import("@tanstack/start-client-core").
|
|
|
46
46
|
* de volledige keten (inclusief load.compose) aanmaakt.
|
|
47
47
|
*/
|
|
48
48
|
export declare const ensureLogisticsTasks: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
49
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
49
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
50
50
|
userId: string;
|
|
51
51
|
claims: import("@supabase/auth-js").User;
|
|
52
52
|
}, undefined, undefined, undefined>], (data?: {
|
|
@@ -61,7 +61,7 @@ export declare const ensureLogisticsTasks: import("@tanstack/start-client-core")
|
|
|
61
61
|
errors: string[];
|
|
62
62
|
}>>;
|
|
63
63
|
export declare const previewLoadCarrierPlan: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
64
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
64
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
65
65
|
userId: string;
|
|
66
66
|
claims: import("@supabase/auth-js").User;
|
|
67
67
|
}, undefined, undefined, undefined>], (data: {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// src/lib/loadCarrierPlanning.functions.ts — server functions (thin wrappers)
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import { createServerFn } from "@tanstack/react-start";
|
|
5
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
6
|
-
import { readableServerErrors } from "
|
|
5
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
6
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
7
7
|
export const replanOrderLoadCarriers = createServerFn({ method: "POST" })
|
|
8
8
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
9
9
|
.inputValidator((data) => {
|
|
@@ -13,7 +13,7 @@ export const replanOrderLoadCarriers = createServerFn({ method: "POST" })
|
|
|
13
13
|
return data;
|
|
14
14
|
})
|
|
15
15
|
.handler(async ({ data }) => {
|
|
16
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
16
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
17
17
|
const { replanOrderInternal } = await import("./loadCarrierPlanning.server");
|
|
18
18
|
const { attachIndelingToTasks } = await import("./loadCarrierTaskSync.server");
|
|
19
19
|
const result = await replanOrderInternal(supabaseAdmin, data.orderId, {
|
|
@@ -33,7 +33,7 @@ export const replanBufferLoadCarriers = createServerFn({ method: "POST" })
|
|
|
33
33
|
return data;
|
|
34
34
|
})
|
|
35
35
|
.handler(async ({ data }) => {
|
|
36
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
36
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
37
37
|
const { replanBufferInternal } = await import("./loadCarrierPlanning.server");
|
|
38
38
|
const { attachIndelingToTasks } = await import("./loadCarrierTaskSync.server");
|
|
39
39
|
const result = await replanBufferInternal(supabaseAdmin, data.bufferId, {
|
|
@@ -52,7 +52,7 @@ export const planAllLoadCarriers = createServerFn({ method: "POST" })
|
|
|
52
52
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
53
53
|
.inputValidator((data) => data ?? {})
|
|
54
54
|
.handler(async ({ data }) => {
|
|
55
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
55
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
56
56
|
const { planBuffersBatch, planLooseOrdersBatch } = await import("./bulkLoadCarrierPlanning.server");
|
|
57
57
|
const limit = Math.min(Math.max(Number(data.limit ?? 20), 1), 50);
|
|
58
58
|
const cursor = data.cursor ?? null;
|
|
@@ -68,7 +68,7 @@ export const ensureLogisticsTasks = createServerFn({ method: "POST" })
|
|
|
68
68
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
69
69
|
.inputValidator((data) => data ?? {})
|
|
70
70
|
.handler(async ({ data, context }) => {
|
|
71
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
71
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
72
72
|
const { findOrdersWithoutTasks } = await import("./bulkLoadCarrierPlanning.server");
|
|
73
73
|
const limit = Math.min(Math.max(Number(data.limit ?? 50), 1), 200);
|
|
74
74
|
const orders = await findOrdersWithoutTasks(supabaseAdmin, limit);
|
|
@@ -106,7 +106,7 @@ export const previewLoadCarrierPlan = createServerFn({ method: "POST" })
|
|
|
106
106
|
return data;
|
|
107
107
|
})
|
|
108
108
|
.handler(async ({ data }) => {
|
|
109
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
109
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
110
110
|
const { replanOrderInternal } = await import("./loadCarrierPlanning.server");
|
|
111
111
|
return replanOrderInternal(supabaseAdmin, data.orderId, { dryRun: true, carrierType: data.carrierType ?? null });
|
|
112
112
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const startRecalcJob: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
2
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
2
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
3
3
|
userId: string;
|
|
4
4
|
claims: import("@supabase/auth-js").User;
|
|
5
5
|
}, undefined, undefined, undefined>], (data?: {
|
|
@@ -12,7 +12,7 @@ export declare const startRecalcJob: import("@tanstack/start-client-core").Optio
|
|
|
12
12
|
phase: "orders" | "buffers" | "finalize";
|
|
13
13
|
}>>;
|
|
14
14
|
export declare const tickRecalcJob: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
15
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
15
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
16
16
|
userId: string;
|
|
17
17
|
claims: import("@supabase/auth-js").User;
|
|
18
18
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// src/lib/logisticsRecalcJob.functions.ts — server functions (thin wrappers)
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import { createServerFn } from "@tanstack/react-start";
|
|
5
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
6
|
-
import { readableServerErrors } from "
|
|
5
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
6
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
7
7
|
export const startRecalcJob = createServerFn({ method: "POST" })
|
|
8
8
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
9
9
|
.inputValidator((data) => data ?? {})
|
|
10
10
|
.handler(async ({ data, context }) => {
|
|
11
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
11
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
12
12
|
const { startJob } = await import("./logisticsRecalcJob.server");
|
|
13
13
|
const job = await startJob(supabaseAdmin, context.userId ?? null, data.strategyId ?? null);
|
|
14
14
|
return { id: job.id, status: job.status, phase: job.phase };
|
|
@@ -16,7 +16,7 @@ export const startRecalcJob = createServerFn({ method: "POST" })
|
|
|
16
16
|
export const tickRecalcJob = createServerFn({ method: "POST" })
|
|
17
17
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
18
18
|
.handler(async () => {
|
|
19
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
19
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
20
20
|
const { tickJob } = await import("./logisticsRecalcJob.server");
|
|
21
21
|
const job = await tickJob(supabaseAdmin);
|
|
22
22
|
return job
|
|
@@ -4,7 +4,7 @@ export interface RecalculateStep {
|
|
|
4
4
|
error?: string;
|
|
5
5
|
}
|
|
6
6
|
export declare const recalculateLogistics: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
7
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
7
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
8
8
|
userId: string;
|
|
9
9
|
claims: import("@supabase/auth-js").User;
|
|
10
10
|
}, undefined, undefined, undefined>], (data?: {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// capaciteitscontrole.
|
|
7
7
|
// ============================================================================
|
|
8
8
|
import { createServerFn } from "@tanstack/react-start";
|
|
9
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
10
|
-
import { readableServerErrors } from "
|
|
9
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
10
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
11
11
|
export const recalculateLogistics = createServerFn({ method: "POST" })
|
|
12
12
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
13
13
|
.inputValidator((data) => data ?? {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modulePrompts.d.ts","sourceRoot":"","sources":["../../src/lib/modulePrompts.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAIvB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAKhE,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,oBAAoB,EAAE,CAAC;CACnC;
|
|
1
|
+
{"version":3,"file":"modulePrompts.d.ts","sourceRoot":"","sources":["../../src/lib/modulePrompts.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAIvB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAKhE,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,oBAAoB,EAAE,CAAC;CACnC;AAi3ID,eAAO,MAAM,cAAc,EAAE,YAAY,EAUL,CAAC;AAErC,gEAAgE;AAChE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,oBAAoB,GAC7B,MAAM,CAeR;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE9D;AAED,oEAAoE;AACpE,wBAAgB,qBAAqB,IAAI,MAAM,CAiB9C;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,eAAe,EAC1B,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,CAIR"}
|
|
@@ -3794,6 +3794,35 @@ CONTROLELIJST
|
|
|
3794
3794
|
[ ] Onbekende actie wordt geweigerd, niet toegestaan.
|
|
3795
3795
|
[ ] Geen URL's, sleutels, project-refs, klantnamen of vaste id's in code.`,
|
|
3796
3796
|
},
|
|
3797
|
+
{
|
|
3798
|
+
number: 6,
|
|
3799
|
+
title: "Bestaande voorraadsleutel ook zonder Floriday-koppeling teruggeven",
|
|
3800
|
+
date: "2026-10-08",
|
|
3801
|
+
withSharedContract: false,
|
|
3802
|
+
summary: "ensure_trade_item_stock_row_key geeft nu NULL zonder actieve Floriday-koppeling, ook als de rij al bestaat. Geef dan de bestaande canonieke sleutel terug.",
|
|
3803
|
+
body: `WAAROM
|
|
3804
|
+
In een shell zonder actieve Floriday-koppeling geeft
|
|
3805
|
+
public.ensure_trade_item_stock_row_key(p_key) altijd NULL, omdat de controle op
|
|
3806
|
+
de koppeling vóór het opzoeken staat. De reserveringsherberekening van de Engine
|
|
3807
|
+
kan dan geen enkele sleutel bepalen; zonder extra opvang zou de reservering daar
|
|
3808
|
+
nooit worden berekend (risico op oververkoop). De Engine vangt het nu op met een
|
|
3809
|
+
alleen-lezende terugval, maar de juiste plek is deze functie.
|
|
3810
|
+
|
|
3811
|
+
WAT JE AANPAST (alleen in de Voorraad-module)
|
|
3812
|
+
1. Bepaal eerst de canonieke sleutel (zoals nu).
|
|
3813
|
+
2. Bestaat er al een rij met die sleutel, geef de sleutel terug — ook zonder
|
|
3814
|
+
actieve koppeling.
|
|
3815
|
+
3. Alleen als er een NIEUWE rij nodig is en er geen koppeling is: NULL
|
|
3816
|
+
teruggeven (geen rij aanmaken, geen terugvalwaarde verzinnen).
|
|
3817
|
+
Naam, parameters en returntype blijven exact gelijk.
|
|
3818
|
+
|
|
3819
|
+
CONTROLELIJST
|
|
3820
|
+
[ ] Zonder koppeling: bestaande sleutel komt terug, er wordt niets ingevoegd.
|
|
3821
|
+
[ ] Zonder koppeling en zonder rij: NULL, geen rij.
|
|
3822
|
+
[ ] Met koppeling: gedrag ongewijzigd.
|
|
3823
|
+
[ ] Fysiek, minimum en inkomend worden nooit geraakt.
|
|
3824
|
+
[ ] Geen URL's, sleutels, project-refs, klantnamen of vaste id's in code of migratie.`,
|
|
3825
|
+
},
|
|
3797
3826
|
],
|
|
3798
3827
|
},
|
|
3799
3828
|
klanten: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MODULE_VERSION = "1.0.
|
|
1
|
+
export declare const MODULE_VERSION = "1.0.111";
|
|
2
2
|
//# sourceMappingURL=moduleVersion.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatisch gegenereerd door prebuild:lib; niet handmatig aanpassen.
|
|
2
|
-
export const MODULE_VERSION = "1.0.
|
|
2
|
+
export const MODULE_VERSION = "1.0.111";
|
|
@@ -19,7 +19,7 @@ export interface PlannerDiffOverview {
|
|
|
19
19
|
afwijkingen: PlannerDiffRow[];
|
|
20
20
|
}
|
|
21
21
|
export declare const getPlannerDiffOverview: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
22
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
22
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
23
23
|
userId: string;
|
|
24
24
|
claims: import("@supabase/auth-js").User;
|
|
25
25
|
}, undefined, undefined, undefined>], undefined, Promise<PlannerDiffOverview>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Alleen-lezen overzicht van de vergelijkende planner (dry-run).
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
4
|
-
import { readableServerErrors } from "
|
|
3
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
4
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
5
5
|
import { summarizeDiffRuns } from "./plannerDiff";
|
|
6
6
|
export const getPlannerDiffOverview = createServerFn({ method: "GET" })
|
|
7
7
|
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
8
8
|
.handler(async () => {
|
|
9
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
9
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
10
10
|
const sb = supabaseAdmin;
|
|
11
11
|
const { data: modus } = await sb.rpc("logistics_planner_diff_mode");
|
|
12
12
|
const { data, error } = await sb
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const SHELL_ADRES_STATUSSEN: readonly ["wachtend", "geslaagd", "al_actueel", "shell_adres_onbekend", "sleutel_ontbreekt", "route_ontbreekt", "oud_adres_geweigerd"];
|
|
2
|
+
export type ShellAdresStatus = (typeof SHELL_ADRES_STATUSSEN)[number];
|
|
3
|
+
/** Gedeelde sleutel in module_runtime_config; eigenaar: Floriday-authenticatiemodule. */
|
|
4
|
+
export declare const SHELL_BASE_URL_KEY = "shell_base_url";
|
|
5
|
+
export declare const LOGISTICS_PING_PATH = "/api/public/hooks/logistics-ping";
|
|
6
|
+
export declare const SHELL_ADRES_TEKST: Record<ShellAdresStatus, string>;
|
|
7
|
+
export declare function isShellAdresStatus(v: unknown): v is ShellAdresStatus;
|
|
8
|
+
/**
|
|
9
|
+
* Telt een antwoord als "eigen antwoord of weigering van de Engine"?
|
|
10
|
+
* Zelfde regel als in logistics_base_url_checks_resolve(): status 200 of 401
|
|
11
|
+
* én JSON met engine = "logistiek-engine". 404, HTML, time-out of een ander
|
|
12
|
+
* JSON-antwoord telt niet.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isEngineAntwoord(status: number | null | undefined, body: string | null | undefined): boolean;
|
|
15
|
+
//# sourceMappingURL=shellAdres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shellAdres.d.ts","sourceRoot":"","sources":["../../src/lib/shellAdres.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,wIAQxB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,yFAAyF;AACzF,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,mBAAmB,qCAAqC,CAAC;AAEtE,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAQ9D,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAS5G"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const getShellAdresStand: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
2
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
3
|
+
userId: string;
|
|
4
|
+
claims: import("@supabase/auth-js").User;
|
|
5
|
+
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
6
|
+
json: string;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare const startShellAdresControle: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, undefined, undefined, undefined, undefined>, import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
9
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
10
|
+
userId: string;
|
|
11
|
+
claims: import("@supabase/auth-js").User;
|
|
12
|
+
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
13
|
+
status: string;
|
|
14
|
+
}>>;
|
|
15
|
+
//# sourceMappingURL=shellAdres.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shellAdres.functions.d.ts","sourceRoot":"","sources":["../../src/lib/shellAdres.functions.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,kBAAkB;;;;;UAEM,MAAM;GAKvC,CAAC;AAEL,eAAO,MAAM,uBAAuB;;;;;YAEc,MAAM;GAUpD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// src/lib/shellAdres.functions.ts — knop "Shell-adres controleren" + stand
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Rol wordt eerst gecontroleerd als de gebruiker zelf (admin, superadmin of
|
|
5
|
+
// developer); pas daarna roept de server de databasefunctie aan.
|
|
6
|
+
// ============================================================================
|
|
7
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
8
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
9
|
+
import { readableServerErrors } from "./readableServerErrors.js";
|
|
10
|
+
const ROLLEN = ["admin", "superadmin", "developer"];
|
|
11
|
+
async function magBeheren(sb, userId) {
|
|
12
|
+
for (const rol of ROLLEN) {
|
|
13
|
+
const { data, error } = await sb.rpc("has_role", { _user_id: userId, _role: rol });
|
|
14
|
+
if (!error && data === true)
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
export const getShellAdresStand = createServerFn({ method: "GET" })
|
|
20
|
+
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
21
|
+
.handler(async () => {
|
|
22
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
23
|
+
const { data, error } = await supabaseAdmin.rpc("logistics_base_url_check_status");
|
|
24
|
+
if (error)
|
|
25
|
+
throw new Error(error.message);
|
|
26
|
+
return { json: JSON.stringify(data ?? {}) };
|
|
27
|
+
});
|
|
28
|
+
export const startShellAdresControle = createServerFn({ method: "POST" })
|
|
29
|
+
.middleware([readableServerErrors, requireSupabaseAuth])
|
|
30
|
+
.handler(async ({ context }) => {
|
|
31
|
+
const { supabase, userId } = context;
|
|
32
|
+
if (!(await magBeheren(supabase, userId))) {
|
|
33
|
+
throw new Error("Alleen admin, superadmin of developer mag het Shell-adres controleren");
|
|
34
|
+
}
|
|
35
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
36
|
+
const { data, error } = await supabaseAdmin.rpc("logistics_tick_base_url_check");
|
|
37
|
+
if (error)
|
|
38
|
+
throw new Error(error.message);
|
|
39
|
+
const status = data?.status;
|
|
40
|
+
return { status: typeof status === "string" ? status : "onbekend" };
|
|
41
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// src/lib/shellAdres.ts — controle van het Shell-adres voor de minuutronde
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Vastgelegde, toegestane waarden (gelijk aan de CHECK in de database,
|
|
5
|
+
// tabel logistics_base_url_checks). Nieuwe waarde? Eerst hier én in het
|
|
6
|
+
// contractdocument vastleggen, dan pas in een migratie.
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export const SHELL_ADRES_STATUSSEN = [
|
|
9
|
+
"wachtend",
|
|
10
|
+
"geslaagd",
|
|
11
|
+
"al_actueel",
|
|
12
|
+
"shell_adres_onbekend",
|
|
13
|
+
"sleutel_ontbreekt",
|
|
14
|
+
"route_ontbreekt",
|
|
15
|
+
"oud_adres_geweigerd",
|
|
16
|
+
];
|
|
17
|
+
/** Gedeelde sleutel in module_runtime_config; eigenaar: Floriday-authenticatiemodule. */
|
|
18
|
+
export const SHELL_BASE_URL_KEY = "shell_base_url";
|
|
19
|
+
export const LOGISTICS_PING_PATH = "/api/public/hooks/logistics-ping";
|
|
20
|
+
export const SHELL_ADRES_TEKST = {
|
|
21
|
+
wachtend: "Controle loopt, wacht op antwoord",
|
|
22
|
+
geslaagd: "Overgestapt naar het Shell-adres",
|
|
23
|
+
al_actueel: "Het adres wijst al naar de Shell",
|
|
24
|
+
shell_adres_onbekend: "Shell-adres onbekend",
|
|
25
|
+
sleutel_ontbreekt: "Sleutel voor de minuutronde ontbreekt (logistics_tick_apikey)",
|
|
26
|
+
route_ontbreekt: "Route ontbreekt in de Shell, module opnieuw uitbrengen en installeren",
|
|
27
|
+
oud_adres_geweigerd: "Shell-adres is een eerder gebruikt adres; niet teruggezet",
|
|
28
|
+
};
|
|
29
|
+
export function isShellAdresStatus(v) {
|
|
30
|
+
return typeof v === "string" && SHELL_ADRES_STATUSSEN.includes(v);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Telt een antwoord als "eigen antwoord of weigering van de Engine"?
|
|
34
|
+
* Zelfde regel als in logistics_base_url_checks_resolve(): status 200 of 401
|
|
35
|
+
* én JSON met engine = "logistiek-engine". 404, HTML, time-out of een ander
|
|
36
|
+
* JSON-antwoord telt niet.
|
|
37
|
+
*/
|
|
38
|
+
export function isEngineAntwoord(status, body) {
|
|
39
|
+
if (status !== 200 && status !== 401)
|
|
40
|
+
return false;
|
|
41
|
+
if (!body)
|
|
42
|
+
return false;
|
|
43
|
+
try {
|
|
44
|
+
const j = JSON.parse(body);
|
|
45
|
+
return !!j && typeof j === "object" && j["engine"] === "logistiek-engine";
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|