@flowselections/floriday-authenticatie-module 1.0.38 → 1.0.39

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.
Files changed (51) hide show
  1. package/dist-lib/components/TemplatePage.d.ts +1 -1
  2. package/dist-lib/components/TemplatePage.d.ts.map +1 -1
  3. package/dist-lib/components/floriday/FlorydayConnectionPage.d.ts +1 -1
  4. package/dist-lib/components/floriday/FlorydayConnectionPage.d.ts.map +1 -1
  5. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +1 -1
  6. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -1
  7. package/dist-lib/components/floriday/FlorydaySyncJobsCard.d.ts +1 -1
  8. package/dist-lib/components/floriday/FlorydaySyncJobsCard.d.ts.map +1 -1
  9. package/dist-lib/components/floriday/TokenHealthCard.d.ts +1 -1
  10. package/dist-lib/components/floriday/TokenHealthCard.d.ts.map +1 -1
  11. package/dist-lib/components/settings/FloricodeSettingsCard.d.ts +1 -1
  12. package/dist-lib/components/settings/FloricodeSettingsCard.d.ts.map +1 -1
  13. package/dist-lib/components/settings/FlorydaySettingsCard.d.ts +1 -1
  14. package/dist-lib/components/settings/FlorydaySettingsCard.d.ts.map +1 -1
  15. package/dist-lib/integrations/supabase/auth-middleware.d.ts +1599 -318
  16. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  17. package/dist-lib/integrations/supabase/client.d.ts +1599 -318
  18. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  19. package/dist-lib/integrations/supabase/client.server.d.ts +1599 -318
  20. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  21. package/dist-lib/integrations/supabase/types.d.ts +1675 -362
  22. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  23. package/dist-lib/integrations/supabase/types.js +3 -0
  24. package/dist-lib/lib/error-page.js +30 -30
  25. package/dist-lib/lib/floricode.functions.d.ts +10626 -1659
  26. package/dist-lib/lib/floricode.functions.d.ts.map +1 -1
  27. package/dist-lib/lib/floriday-auction-letters.functions.d.ts +1599 -318
  28. package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
  29. package/dist-lib/lib/floriday-labels.functions.d.ts +1599 -318
  30. package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
  31. package/dist-lib/lib/floriday-public.functions.d.ts +9108 -1422
  32. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  33. package/dist-lib/lib/floriday-stickers.functions.d.ts +1599 -318
  34. package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
  35. package/dist-lib/lib/floriday-sync.functions.d.ts +47058 -7347
  36. package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
  37. package/dist-lib/lib/floriday-writes.functions.d.ts +9114 -1428
  38. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  39. package/dist-lib/lib/floriday.functions.d.ts +28842 -4503
  40. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  41. package/dist-lib/lib/print/floriday-print.d.ts +36 -0
  42. package/dist-lib/lib/print/floriday-print.d.ts.map +1 -0
  43. package/dist-lib/lib/print/floriday-print.js +204 -0
  44. package/dist-lib/lib/print/index.d.ts +3 -0
  45. package/dist-lib/lib/print/index.d.ts.map +1 -0
  46. package/dist-lib/lib/print/index.js +2 -0
  47. package/dist-lib/lib/print/pdf-to-base64.d.ts +5 -0
  48. package/dist-lib/lib/print/pdf-to-base64.d.ts.map +1 -0
  49. package/dist-lib/lib/print/pdf-to-base64.js +27 -0
  50. package/package.json +12 -2
  51. package/dist-lib/assets/floriday-logo.png.asset.json +0 -11
@@ -0,0 +1,36 @@
1
+ import type { SupabaseClient } from "@supabase/supabase-js";
2
+ export type FloridayDocumenttype = "sticker" | "afleverbrief" | "veilingbrief";
3
+ export type PrintDocumentStatus = "verzonden" | "overgeslagen" | "mislukt";
4
+ export interface PrintDocumentResult {
5
+ documenttype: FloridayDocumenttype;
6
+ status: PrintDocumentStatus;
7
+ jobId?: string;
8
+ foutmelding?: string;
9
+ }
10
+ export interface PrintFloridayOrderOptions {
11
+ /** Documentnaam, bijvoorbeeld het ordernummer. Zonder tijdstempel. */
12
+ documentnaam: string;
13
+ /** Werkplek zoals de shell die per scherm/sessie bepaalt. */
14
+ werkplek: string;
15
+ /** Bronverwijzingen voor de afleverbrief. Ten minste één is nodig. */
16
+ deliveryOrderId?: string;
17
+ salesOrderId?: string;
18
+ fulfillmentOrderId?: string;
19
+ /** Alleen printen als deze is meegegeven én Floriday een PDF levert. */
20
+ stickerId?: string;
21
+ clockSupplyId?: string;
22
+ kopieen?: number;
23
+ /** Alleen `true` bij een bewuste herprint. */
24
+ isHerprint?: boolean;
25
+ papierformaat?: string;
26
+ /** Gegevens voor een eigen ontwerp (terugval afleverbrief). */
27
+ payload?: Record<string, unknown>;
28
+ }
29
+ /**
30
+ * Print de Floriday-documenten van één order: sticker (indien beschikbaar),
31
+ * afleverbrief (altijd) en veilingbrief (indien beschikbaar).
32
+ *
33
+ * Roep dit aan vanuit de browser. Een mislukt document stopt de reeks niet.
34
+ */
35
+ export declare function printFloridayOrderDocuments(supabase: SupabaseClient, opts: PrintFloridayOrderOptions): Promise<PrintDocumentResult[]>;
36
+ //# sourceMappingURL=floriday-print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floriday-print.d.ts","sourceRoot":"","sources":["../../../src/lib/print/floriday-print.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,cAAc,GAAG,cAAc,CAAC;AAE/E,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,cAAc,GAAG,SAAS,CAAC;AAE3E,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,oBAAoB,CAAC;IACnC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IAEjB,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AA2ID;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAuFhC"}
@@ -0,0 +1,204 @@
1
+ // ============================================================================
2
+ // Printen van Floriday-documenten via de module "Layouts en printers"
3
+ // ----------------------------------------------------------------------------
4
+ // Eén exporteerbare functie, geen UI. Er wordt nooit rechtstreeks met PrintNode
5
+ // of window.print() gewerkt: alle printopdrachten gaan via
6
+ // @flowselections/layout-maker.
7
+ //
8
+ // BELANGRIJK: deze functie draait in de BROWSER (component of event-handler van
9
+ // de shell), niet in een server function. De print-API werkt met de
10
+ // client-Supabase van de shell (sessie van de ingelogde gebruiker) en kiest
11
+ // zelf haar client. De `supabase`-parameter hieronder wordt uitsluitend gebruikt
12
+ // om de Floriday-documenten op te halen.
13
+ //
14
+ // Volgorde is strikt sequentieel: sticker -> afleverbrief -> veilingbrief.
15
+ // ============================================================================
16
+ import { fetchPdfAsBase64 } from "./pdf-to-base64.js";
17
+ const HERKOMST = "floriday";
18
+ async function loadPrintApi() {
19
+ // Specifier via een variabele: het pakket is een optionele peer dependency,
20
+ // dus type-resolutie mag hier niet vereist zijn.
21
+ const specifier = "@flowselections/layout-maker";
22
+ try {
23
+ const mod = await import(/* @vite-ignore */ specifier);
24
+ if (typeof mod?.printDocument !== "function") {
25
+ throw new Error("printDocument ontbreekt");
26
+ }
27
+ return mod;
28
+ }
29
+ catch {
30
+ throw new Error('Printen is niet beschikbaar: de module "Layouts en printers" is niet aan deze shell toegevoegd.');
31
+ }
32
+ }
33
+ function isDubbeleAanvraag(api, err) {
34
+ if (api.DubbeleAanvraagFout && err instanceof api.DubbeleAanvraagFout) {
35
+ return true;
36
+ }
37
+ const name = err?.name ?? "";
38
+ const code = err?.code ?? "";
39
+ return name === "DubbeleAanvraagFout" || code === "dubbele_aanvraag";
40
+ }
41
+ function foutTekst(err) {
42
+ const msg = err?.message;
43
+ return typeof msg === "string" && msg.trim() ? msg : String(err);
44
+ }
45
+ // ---------------------------------------------------------------------------
46
+ // Floriday-documenten ophalen
47
+ // ---------------------------------------------------------------------------
48
+ /**
49
+ * Haalt één Floriday-document op als base64. Geeft `null` terug wanneer
50
+ * Floriday geen document levert (dan is het document "niet beschikbaar").
51
+ */
52
+ async function haalFloridayPdf(supabase, input) {
53
+ const { getFlorydayDocument } = await import("../gateway/documents.js");
54
+ let result;
55
+ try {
56
+ result = await getFlorydayDocument(supabase, input);
57
+ }
58
+ catch {
59
+ return null;
60
+ }
61
+ if (!result?.ok || typeof result.url !== "string" || !result.url) {
62
+ return null;
63
+ }
64
+ try {
65
+ return await fetchPdfAsBase64(result.url);
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ }
71
+ // ---------------------------------------------------------------------------
72
+ // Printen
73
+ // ---------------------------------------------------------------------------
74
+ async function printEen(api, documenttype, opts, extra) {
75
+ // Vooraf-controle met dezelfde volgorde als de wachtrij
76
+ // (werkplek-uitzondering -> layout-koppeling -> papierformaat).
77
+ if (typeof api.printerVoorDocumenttype === "function") {
78
+ try {
79
+ const printer = await api.printerVoorDocumenttype(documenttype, opts.papierformaat, opts.werkplek);
80
+ if (!printer) {
81
+ return {
82
+ documenttype,
83
+ status: "mislukt",
84
+ foutmelding: `Geen printer ingesteld voor ${documenttype} op werkplek ${opts.werkplek}. Stel deze in via de module Layouts en printers.`,
85
+ };
86
+ }
87
+ }
88
+ catch (err) {
89
+ return { documenttype, status: "mislukt", foutmelding: foutTekst(err) };
90
+ }
91
+ }
92
+ try {
93
+ // printerId sturen we bewust niet mee: de wachtrij bepaalt hem opnieuw.
94
+ const job = await api.printDocument({
95
+ documenttype,
96
+ documentnaam: opts.documentnaam,
97
+ herkomst: HERKOMST,
98
+ werkplek: opts.werkplek,
99
+ ...(opts.kopieen ? { kopieen: opts.kopieen } : {}),
100
+ ...(opts.isHerprint ? { isHerprint: true } : {}),
101
+ ...(opts.papierformaat ? { papierformaat: opts.papierformaat } : {}),
102
+ ...extra,
103
+ });
104
+ return {
105
+ documenttype,
106
+ status: "verzonden",
107
+ jobId: job?.jobId ?? job?.id ?? undefined,
108
+ };
109
+ }
110
+ catch (err) {
111
+ if (isDubbeleAanvraag(api, err)) {
112
+ return {
113
+ documenttype,
114
+ status: "overgeslagen",
115
+ foutmelding: "Dit document is kort geleden al aangevraagd en wordt niet opnieuw geprint. Gebruik een herprint als je het toch nog een keer wilt afdrukken.",
116
+ };
117
+ }
118
+ return { documenttype, status: "mislukt", foutmelding: foutTekst(err) };
119
+ }
120
+ }
121
+ /**
122
+ * Print de Floriday-documenten van één order: sticker (indien beschikbaar),
123
+ * afleverbrief (altijd) en veilingbrief (indien beschikbaar).
124
+ *
125
+ * Roep dit aan vanuit de browser. Een mislukt document stopt de reeks niet.
126
+ */
127
+ export async function printFloridayOrderDocuments(supabase, opts) {
128
+ if (!opts?.documentnaam?.trim()) {
129
+ throw new Error("documentnaam is verplicht");
130
+ }
131
+ if (!opts?.werkplek?.trim()) {
132
+ throw new Error("werkplek is verplicht");
133
+ }
134
+ const api = await loadPrintApi();
135
+ const resultaten = [];
136
+ // 1) Sticker — alleen als Floriday er een levert.
137
+ if (opts.stickerId) {
138
+ const pdfBase64 = await haalFloridayPdf(supabase, {
139
+ kind: "customer-sticker",
140
+ stickerId: opts.stickerId,
141
+ });
142
+ if (!pdfBase64) {
143
+ resultaten.push({
144
+ documenttype: "sticker",
145
+ status: "overgeslagen",
146
+ foutmelding: "Floriday levert geen klantsticker voor deze order.",
147
+ });
148
+ }
149
+ else {
150
+ resultaten.push(await printEen(api, "sticker", opts, { pdfBase64 }));
151
+ }
152
+ }
153
+ else {
154
+ resultaten.push({
155
+ documenttype: "sticker",
156
+ status: "overgeslagen",
157
+ foutmelding: "Geen klantsticker bekend voor deze order.",
158
+ });
159
+ }
160
+ // 2) Afleverbrief — altijd. PDF uit Floriday, anders eigen ontwerp.
161
+ const afleverPdf = opts.deliveryOrderId || opts.salesOrderId || opts.fulfillmentOrderId
162
+ ? await haalFloridayPdf(supabase, {
163
+ kind: "delivery-note",
164
+ ...(opts.fulfillmentOrderId
165
+ ? { fulfillmentOrderId: opts.fulfillmentOrderId }
166
+ : {}),
167
+ ...(opts.deliveryOrderId
168
+ ? { deliveryOrderId: opts.deliveryOrderId }
169
+ : {}),
170
+ ...(opts.salesOrderId ? { salesOrderId: opts.salesOrderId } : {}),
171
+ })
172
+ : null;
173
+ resultaten.push(await printEen(api, "afleverbrief", opts, afleverPdf
174
+ ? { pdfBase64: afleverPdf }
175
+ : // Terugval op een eigen ontwerp. Is in Documentroutering
176
+ // "Document van Floriday" ingesteld, dan weigert de wachtrij dit
177
+ // bewust; die foutmelding geven we ongewijzigd door.
178
+ { payload: opts.payload ?? {} }));
179
+ // 3) Veilingbrief — alleen als Floriday er een levert.
180
+ if (opts.clockSupplyId) {
181
+ const pdfBase64 = await haalFloridayPdf(supabase, {
182
+ kind: "auction-letter",
183
+ clockSupplyId: opts.clockSupplyId,
184
+ });
185
+ if (!pdfBase64) {
186
+ resultaten.push({
187
+ documenttype: "veilingbrief",
188
+ status: "overgeslagen",
189
+ foutmelding: "Floriday levert geen veilingbrief voor deze order.",
190
+ });
191
+ }
192
+ else {
193
+ resultaten.push(await printEen(api, "veilingbrief", opts, { pdfBase64 }));
194
+ }
195
+ }
196
+ else {
197
+ resultaten.push({
198
+ documenttype: "veilingbrief",
199
+ status: "overgeslagen",
200
+ foutmelding: "Geen veilingaanvoer bekend voor deze order.",
201
+ });
202
+ }
203
+ return resultaten;
204
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./floriday-print.js";
2
+ export * from "./pdf-to-base64.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/print/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./floriday-print.js";
2
+ export * from "./pdf-to-base64.js";
@@ -0,0 +1,5 @@
1
+ /** Zet een ArrayBuffer om naar een base64-string (browser-veilig, geen Buffer). */
2
+ export declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
3
+ /** Downloadt een (signed) PDF-URL en geeft de inhoud terug als base64. */
4
+ export declare function fetchPdfAsBase64(url: string): Promise<string>;
5
+ //# sourceMappingURL=pdf-to-base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-to-base64.d.ts","sourceRoot":"","sources":["../../../src/lib/print/pdf-to-base64.ts"],"names":[],"mappings":"AAMA,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAU/D;AAED,0EAA0E;AAC1E,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYnE"}
@@ -0,0 +1,27 @@
1
+ // Hulpfunctie: signed PDF-URL -> base64-string.
2
+ //
3
+ // De documentlaag van deze module levert een tijdelijke signed URL naar de
4
+ // gecachte PDF in Supabase Storage. De printmodule wil de bytes zelf hebben
5
+ // (`pdfBase64`), zodat PrintNode niet afhankelijk is van storage-bereikbaarheid.
6
+ /** Zet een ArrayBuffer om naar een base64-string (browser-veilig, geen Buffer). */
7
+ export function arrayBufferToBase64(buffer) {
8
+ const bytes = new Uint8Array(buffer);
9
+ let binary = "";
10
+ const chunk = 0x8000;
11
+ for (let i = 0; i < bytes.length; i += chunk) {
12
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
13
+ }
14
+ return btoa(binary);
15
+ }
16
+ /** Downloadt een (signed) PDF-URL en geeft de inhoud terug als base64. */
17
+ export async function fetchPdfAsBase64(url) {
18
+ const res = await fetch(url);
19
+ if (!res.ok) {
20
+ throw new Error(`Kon het PDF-document niet ophalen (HTTP ${res.status}).`);
21
+ }
22
+ const buf = await res.arrayBuffer();
23
+ if (!buf.byteLength) {
24
+ throw new Error("Het opgehaalde PDF-document is leeg.");
25
+ }
26
+ return arrayBufferToBase64(buf);
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowselections/floriday-authenticatie-module",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "main": "./dist-lib/index.js",
@@ -17,6 +17,10 @@
17
17
  "./cron": {
18
18
  "types": "./dist-lib/lib/cron/index.d.ts",
19
19
  "default": "./dist-lib/lib/cron/index.js"
20
+ },
21
+ "./print": {
22
+ "types": "./dist-lib/lib/print/index.d.ts",
23
+ "default": "./dist-lib/lib/print/index.js"
20
24
  }
21
25
  },
22
26
  "files": [
@@ -38,7 +42,8 @@
38
42
  "peerDependencies": {
39
43
  "react": "^18 || ^19",
40
44
  "react-dom": "^18 || ^19",
41
- "@flowselections/core": "*"
45
+ "@flowselections/core": "*",
46
+ "@flowselections/layout-maker": "*"
42
47
  },
43
48
  "dependencies": {
44
49
  "@supabase/supabase-js": "^2.105.4",
@@ -479,5 +484,10 @@
479
484
  ]
480
485
  }
481
486
  ]
487
+ },
488
+ "peerDependenciesMeta": {
489
+ "@flowselections/layout-maker": {
490
+ "optional": true
491
+ }
482
492
  }
483
493
  }
@@ -1,11 +0,0 @@
1
- {
2
- "version": 1,
3
- "asset_id": "6db44648-6f9b-4335-8b88-714ad7aaee9d",
4
- "project_id": "27b6733b-2e2f-4518-b204-681958559055",
5
- "url": "/__l5e/assets-v1/6db44648-6f9b-4335-8b88-714ad7aaee9d/floriday-logo.png",
6
- "r2_key": "a/v1/27b6733b-2e2f-4518-b204-681958559055/6db44648-6f9b-4335-8b88-714ad7aaee9d/floriday-logo.png",
7
- "original_filename": "floriday-logo.png",
8
- "size": 6921,
9
- "content_type": "image/png",
10
- "created_at": "2026-06-24T12:45:45Z"
11
- }