@flowselections/logistiek-engine 1.0.94 → 1.0.99
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/MisluktVerzendbrievenCard.d.ts +2 -0
- package/dist-lib/components/MisluktVerzendbrievenCard.d.ts.map +1 -0
- package/dist-lib/components/MisluktVerzendbrievenCard.js +50 -0
- package/dist-lib/components/RegiePage.d.ts.map +1 -1
- package/dist-lib/components/RegiePage.js +2 -1
- package/dist-lib/components/RuleEnginePage.d.ts.map +1 -1
- package/dist-lib/components/RuleEnginePage.js +3 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +59 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +59 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/moduleClient.d.ts +59 -0
- package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +59 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cartCoverage.functions.d.ts +59 -0
- package/dist-lib/lib/cartCoverage.functions.d.ts.map +1 -1
- package/dist-lib/lib/controlScan.server.d.ts +2 -0
- package/dist-lib/lib/controlScan.server.d.ts.map +1 -1
- package/dist-lib/lib/controlScan.server.js +59 -53
- package/dist-lib/lib/expandGroups.test.d.ts +2 -0
- package/dist-lib/lib/expandGroups.test.d.ts.map +1 -0
- package/dist-lib/lib/expandGroups.test.js +80 -0
- package/dist-lib/lib/floridayDocuments.functions.d.ts +177 -0
- package/dist-lib/lib/floridayDocuments.functions.d.ts.map +1 -1
- package/dist-lib/lib/floridayPush.functions.d.ts +59 -0
- package/dist-lib/lib/floridayPush.functions.d.ts.map +1 -1
- package/dist-lib/lib/layoutPrint.server.d.ts +27 -0
- package/dist-lib/lib/layoutPrint.server.d.ts.map +1 -0
- package/dist-lib/lib/layoutPrint.server.js +48 -0
- package/dist-lib/lib/layoutPrint.test.d.ts +2 -0
- package/dist-lib/lib/layoutPrint.test.d.ts.map +1 -0
- package/dist-lib/lib/layoutPrint.test.js +47 -0
- package/dist-lib/lib/loadCarrierPlanning.functions.d.ts +295 -0
- package/dist-lib/lib/loadCarrierPlanning.functions.d.ts.map +1 -1
- package/dist-lib/lib/loadCarrierPlanning.server.d.ts.map +1 -1
- package/dist-lib/lib/loadCarrierPlanning.server.js +72 -8
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts +118 -0
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts.map +1 -1
- package/dist-lib/lib/logisticsRecalculate.functions.d.ts +59 -0
- package/dist-lib/lib/logisticsRecalculate.functions.d.ts.map +1 -1
- package/dist-lib/lib/modulePrompts.d.ts.map +1 -1
- package/dist-lib/lib/modulePrompts.js +54 -0
- package/dist-lib/lib/moduleVersion.d.ts +2 -0
- package/dist-lib/lib/moduleVersion.d.ts.map +1 -0
- package/dist-lib/lib/moduleVersion.js +2 -0
- package/dist-lib/lib/plannerDiff.functions.d.ts +59 -0
- package/dist-lib/lib/plannerDiff.functions.d.ts.map +1 -1
- package/dist-lib/lib/shippingNoteQueue.server.d.ts.map +1 -1
- package/dist-lib/lib/shippingNoteQueue.server.js +40 -49
- package/package.json +2 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
export interface LayoutPrintInput {
|
|
3
|
+
documenttype: string;
|
|
4
|
+
documentnaam: string;
|
|
5
|
+
pdfBase64?: string | null;
|
|
6
|
+
pdfUrl?: string | null;
|
|
7
|
+
layoutId?: string | null;
|
|
8
|
+
printPlekId?: string | null;
|
|
9
|
+
herkomst?: string | null;
|
|
10
|
+
isHerprint?: boolean;
|
|
11
|
+
/** Alleen snake_case-velden: print_plek_id, order_id, ordernummer, queue_item_id, cart_id, fulfillment_order_id. */
|
|
12
|
+
payload: Record<string, unknown>;
|
|
13
|
+
idempotentieSleutel: string;
|
|
14
|
+
}
|
|
15
|
+
export type LayoutPrintResult = {
|
|
16
|
+
ok: true;
|
|
17
|
+
jobId: string;
|
|
18
|
+
printerId: string | null;
|
|
19
|
+
bestaand: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
errorCode: string;
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function foutcode(message: string): string;
|
|
26
|
+
export declare function printViaLayout(sb: SupabaseClient, input: LayoutPrintInput): Promise<LayoutPrintResult>;
|
|
27
|
+
//# sourceMappingURL=layoutPrint.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutPrint.server.d.ts","sourceRoot":"","sources":["../../src/lib/layoutPrint.server.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oHAAoH;IACpH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACxE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKpD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,cAAc,EAClB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAkC5B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// src/lib/layoutPrint.server.ts
|
|
3
|
+
// De enige manier waarop de Engine vanuit TypeScript print: via
|
|
4
|
+
// public.layout_print_document van de Layout maker. Nooit rechtstreeks in
|
|
5
|
+
// print_jobs schrijven. De Layout maker kiest de printer (printplek, werkplek,
|
|
6
|
+
// standaardregels). Fouten (GEEN_PRINTER, GEEN_LAYOUT, GEEN_EXTERN_DOCUMENT)
|
|
7
|
+
// komen als leesbare fout terug; er is geen stille terugval.
|
|
8
|
+
// ============================================================================
|
|
9
|
+
const HINT = ' Los dit op bij Layouts en printers en druk daarna op "Opnieuw proberen"; opnieuw scannen is niet nodig.';
|
|
10
|
+
export function foutcode(message) {
|
|
11
|
+
const m = /^([A-Z_]+):/.exec(message.trim());
|
|
12
|
+
return m?.[1] ?? "PRINTFOUT";
|
|
13
|
+
}
|
|
14
|
+
export async function printViaLayout(sb, input) {
|
|
15
|
+
const { data, error } = await sb.rpc("layout_print_document", {
|
|
16
|
+
_documenttype: input.documenttype,
|
|
17
|
+
_documentnaam: input.documentnaam,
|
|
18
|
+
_pdf_base64: input.pdfBase64 ?? null,
|
|
19
|
+
_pdf_url: input.pdfUrl ?? null,
|
|
20
|
+
_layout_id: input.layoutId ?? null,
|
|
21
|
+
_print_plek_id: input.printPlekId ?? null,
|
|
22
|
+
_werkplek: null,
|
|
23
|
+
_kopieen: 1,
|
|
24
|
+
_herkomst: input.herkomst ?? null,
|
|
25
|
+
_is_herprint: input.isHerprint ?? false,
|
|
26
|
+
_payload: input.payload,
|
|
27
|
+
_idempotentie_sleutel: input.idempotentieSleutel,
|
|
28
|
+
});
|
|
29
|
+
if (error) {
|
|
30
|
+
return { ok: false, errorCode: foutcode(error.message), error: `${error.message}${HINT}` };
|
|
31
|
+
}
|
|
32
|
+
const rows = Array.isArray(data) ? data : data ? [data] : [];
|
|
33
|
+
const row = (rows[0] ?? null);
|
|
34
|
+
const jobId = row ? String(row["job_id"] ?? "") : "";
|
|
35
|
+
if (!jobId) {
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
errorCode: "PRINTFOUT",
|
|
39
|
+
error: `De Layout maker gaf geen printopdracht terug.${HINT}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
ok: true,
|
|
44
|
+
jobId,
|
|
45
|
+
printerId: row?.["printer_id"] ?? null,
|
|
46
|
+
bestaand: Boolean(row?.["bestaand"]),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutPrint.test.d.ts","sourceRoot":"","sources":["../../src/lib/layoutPrint.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { printViaLayout, foutcode } from "./layoutPrint.server";
|
|
3
|
+
function sbMet(result) {
|
|
4
|
+
const rpc = vi.fn().mockResolvedValue(result);
|
|
5
|
+
const from = vi.fn();
|
|
6
|
+
return { sb: { rpc, from }, rpc, from };
|
|
7
|
+
}
|
|
8
|
+
const basis = {
|
|
9
|
+
documenttype: "afleverbrief",
|
|
10
|
+
documentnaam: "Afleverbrief FO-1",
|
|
11
|
+
pdfBase64: "QUJD",
|
|
12
|
+
printPlekId: "plek-1",
|
|
13
|
+
herkomst: "floriday",
|
|
14
|
+
payload: { order_id: "o1", ordernummer: "FO-1", cart_id: "c1", print_plek_id: "plek-1" },
|
|
15
|
+
idempotentieSleutel: "controle-scan:1",
|
|
16
|
+
};
|
|
17
|
+
describe("printViaLayout", () => {
|
|
18
|
+
it("roept layout_print_document aan met snake_case en sleutel, zonder directe insert", async () => {
|
|
19
|
+
const { sb, rpc, from } = sbMet({ data: [{ job_id: "j1", printer_id: "p1", bestaand: false }], error: null });
|
|
20
|
+
const r = await printViaLayout(sb, basis);
|
|
21
|
+
expect(r).toEqual({ ok: true, jobId: "j1", printerId: "p1", bestaand: false });
|
|
22
|
+
expect(from).not.toHaveBeenCalled();
|
|
23
|
+
const [naam, args] = rpc.mock.calls[0];
|
|
24
|
+
expect(naam).toBe("layout_print_document");
|
|
25
|
+
expect(args._idempotentie_sleutel).toBe("controle-scan:1");
|
|
26
|
+
expect(args._print_plek_id).toBe("plek-1");
|
|
27
|
+
expect(Object.keys(args._payload)).not.toContain("cartId");
|
|
28
|
+
expect(Object.keys(args._payload)).not.toContain("printPlekId");
|
|
29
|
+
});
|
|
30
|
+
it("geeft bij een tweede aanroep dezelfde opdracht terug", async () => {
|
|
31
|
+
const { sb } = sbMet({ data: [{ job_id: "j1", printer_id: "p1", bestaand: true }], error: null });
|
|
32
|
+
const r = await printViaLayout(sb, basis);
|
|
33
|
+
expect(r.ok && r.bestaand && r.jobId === "j1").toBe(true);
|
|
34
|
+
});
|
|
35
|
+
it.each(["GEEN_PRINTER", "GEEN_LAYOUT", "GEEN_EXTERN_DOCUMENT"])("vertaalt %s naar een leesbare fout", async (code) => {
|
|
36
|
+
const { sb } = sbMet({ data: null, error: { message: `${code}: iets ontbreekt` } });
|
|
37
|
+
const r = await printViaLayout(sb, basis);
|
|
38
|
+
expect(r.ok).toBe(false);
|
|
39
|
+
if (!r.ok) {
|
|
40
|
+
expect(r.errorCode).toBe(code);
|
|
41
|
+
expect(r.error).toContain("Opnieuw proberen");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
it("onbekende fout wordt PRINTFOUT", () => {
|
|
45
|
+
expect(foutcode("netwerk weg")).toBe("PRINTFOUT");
|
|
46
|
+
});
|
|
47
|
+
});
|