@flowselections/floriday-klanten-module 1.0.99 → 1.0.100
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/klanten/BulkStickerUploadDialog.d.ts +10 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.js +32 -11
- package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerAssortmentTab.js +19 -5
- package/dist-lib/components/klanten/CustomerStickerCell.d.ts +4 -1
- package/dist-lib/components/klanten/CustomerStickerCell.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerStickerCell.js +6 -4
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts +3 -1
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.js +5 -4
- package/dist-lib/components/klanten/StickerSizeLine.d.ts +3 -1
- package/dist-lib/components/klanten/StickerSizeLine.d.ts.map +1 -1
- package/dist-lib/components/klanten/StickerSizeLine.js +4 -4
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +243 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.d.ts +37 -1
- package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.js +132 -82
- package/dist-lib/lib/pdf-thumbnail.d.ts +4 -0
- package/dist-lib/lib/pdf-thumbnail.d.ts.map +1 -0
- package/dist-lib/lib/pdf-thumbnail.js +49 -0
- package/dist-lib/lib/sticker-soort.d.ts +20 -0
- package/dist-lib/lib/sticker-soort.d.ts.map +1 -0
- package/dist-lib/lib/sticker-soort.js +20 -0
- package/package.json +2 -1
- package/schema/klanten.sql +27 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type StickerSizeResult } from "./sticker-size.js";
|
|
2
|
+
import { type StickerSoort } from "./sticker-soort.js";
|
|
3
|
+
export type { StickerSoort } from "./sticker-soort.js";
|
|
2
4
|
export declare const ALLOWED_STICKER_MIME: readonly ["application/pdf", "image/png", "image/jpeg", "image/svg+xml"];
|
|
3
5
|
export type CustomerSticker = {
|
|
4
6
|
trade_item_key: string;
|
|
@@ -11,6 +13,7 @@ export type CustomerSticker = {
|
|
|
11
13
|
source: "manual" | "floriday";
|
|
12
14
|
width_mm: number | null;
|
|
13
15
|
height_mm: number | null;
|
|
16
|
+
soort: StickerSoort;
|
|
14
17
|
};
|
|
15
18
|
export type StickerFormat = {
|
|
16
19
|
width_mm: number;
|
|
@@ -19,14 +22,18 @@ export type StickerFormat = {
|
|
|
19
22
|
export type CustomerStickersResult = {
|
|
20
23
|
stickers: CustomerSticker[];
|
|
21
24
|
format: StickerFormat | null;
|
|
25
|
+
soort: StickerSoort;
|
|
22
26
|
};
|
|
23
27
|
export type StickerUploadSize = Pick<StickerSizeResult, "method" | "size" | "suggestion">;
|
|
28
|
+
/** Kern van listCustomerStickers (los aanroepbaar voor tests). */
|
|
29
|
+
export declare function listCustomerStickersKern(data: any, context: any): Promise<CustomerStickersResult>;
|
|
24
30
|
export declare const listCustomerStickers: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
25
31
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
26
32
|
userId: string;
|
|
27
33
|
claims: import("@supabase/auth-js").JwtPayload;
|
|
28
34
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
29
35
|
customerKey: string;
|
|
36
|
+
soort: "product" | "fust";
|
|
30
37
|
}, Promise<CustomerStickersResult>>;
|
|
31
38
|
export declare const confirmStickerUpload: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
32
39
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
@@ -38,6 +45,7 @@ export declare const confirmStickerUpload: import("@tanstack/start-client-core")
|
|
|
38
45
|
filePath: string;
|
|
39
46
|
fileName: string;
|
|
40
47
|
mimeType: string;
|
|
48
|
+
soort: "product" | "fust";
|
|
41
49
|
fileSize?: number | null | undefined;
|
|
42
50
|
}, Promise<{
|
|
43
51
|
method: import("./sticker-size.js").SizeMethod;
|
|
@@ -60,6 +68,7 @@ export declare const deleteCustomerSticker: import("@tanstack/start-client-core"
|
|
|
60
68
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
61
69
|
customerKey: string;
|
|
62
70
|
tradeItemKey: string;
|
|
71
|
+
soort: "product" | "fust";
|
|
63
72
|
}, Promise<{
|
|
64
73
|
ok: true;
|
|
65
74
|
}>>;
|
|
@@ -69,6 +78,7 @@ export declare const getCustomerStickerSettings: import("@tanstack/start-client-
|
|
|
69
78
|
claims: import("@supabase/auth-js").JwtPayload;
|
|
70
79
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
71
80
|
customerKey: string;
|
|
81
|
+
soort: "product" | "fust";
|
|
72
82
|
}, Promise<StickerFormat | null>>;
|
|
73
83
|
export declare const setCustomerStickerSettings: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
74
84
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
@@ -78,6 +88,7 @@ export declare const setCustomerStickerSettings: import("@tanstack/start-client-
|
|
|
78
88
|
customerKey: string;
|
|
79
89
|
widthMm: number;
|
|
80
90
|
heightMm: number;
|
|
91
|
+
soort: "product" | "fust";
|
|
81
92
|
}, Promise<{
|
|
82
93
|
ok: true;
|
|
83
94
|
}>>;
|
|
@@ -85,6 +96,14 @@ export declare const setCustomerStickerSettings: import("@tanstack/start-client-
|
|
|
85
96
|
* Aanknopingspunt voor de pick-/printmodule: geeft het stickerbestand en het
|
|
86
97
|
* ingestelde formaat terug, of null als er geen klantsticker gekoppeld is.
|
|
87
98
|
*/
|
|
99
|
+
/** Kern van getStickerForPrint (los aanroepbaar voor tests). */
|
|
100
|
+
export declare function getStickerForPrintKern(data: any, context: any): Promise<{
|
|
101
|
+
url: string | null;
|
|
102
|
+
file_name: string;
|
|
103
|
+
mime_type: string | null;
|
|
104
|
+
width_mm: number | null;
|
|
105
|
+
height_mm: number | null;
|
|
106
|
+
} | null>;
|
|
88
107
|
export declare const getStickerForPrint: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
89
108
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
90
109
|
userId: string;
|
|
@@ -92,6 +111,7 @@ export declare const getStickerForPrint: import("@tanstack/start-client-core").O
|
|
|
92
111
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
93
112
|
customerKey: string;
|
|
94
113
|
tradeItemKey: string;
|
|
114
|
+
soort: "product" | "fust";
|
|
95
115
|
}, Promise<{
|
|
96
116
|
url: string | null;
|
|
97
117
|
file_name: string;
|
|
@@ -148,6 +168,20 @@ export declare const suggestStickerMatches: import("@tanstack/start-client-core"
|
|
|
148
168
|
suggestions: StickerMatchSuggestion[];
|
|
149
169
|
aiError?: string | null;
|
|
150
170
|
}>>;
|
|
171
|
+
/** Kern van commitStickerBatch (los aanroepbaar voor tests). */
|
|
172
|
+
export declare function commitStickerBatchKern(data: any, context: any): Promise<{
|
|
173
|
+
linked: number;
|
|
174
|
+
replaced: number;
|
|
175
|
+
skipped: number;
|
|
176
|
+
failed: {
|
|
177
|
+
fileName: string;
|
|
178
|
+
reason: string;
|
|
179
|
+
}[];
|
|
180
|
+
sizes: ({
|
|
181
|
+
fileName: string;
|
|
182
|
+
tradeItemKey: string;
|
|
183
|
+
} & StickerUploadSize)[];
|
|
184
|
+
}>;
|
|
151
185
|
export declare const commitStickerBatch: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
152
186
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
153
187
|
userId: string;
|
|
@@ -163,6 +197,7 @@ export declare const commitStickerBatch: import("@tanstack/start-client-core").O
|
|
|
163
197
|
replaceExisting: boolean;
|
|
164
198
|
fileSize?: number | null | undefined;
|
|
165
199
|
}[];
|
|
200
|
+
soort: "product" | "fust";
|
|
166
201
|
}, Promise<{
|
|
167
202
|
linked: number;
|
|
168
203
|
replaced: number;
|
|
@@ -196,6 +231,7 @@ export declare const setStickerSize: import("@tanstack/start-client-core").Optio
|
|
|
196
231
|
tradeItemKey: string;
|
|
197
232
|
widthMm: number;
|
|
198
233
|
heightMm: number;
|
|
234
|
+
soort: "product" | "fust";
|
|
199
235
|
}, Promise<{
|
|
200
236
|
ok: true;
|
|
201
237
|
}>>;
|
|
@@ -207,6 +243,7 @@ export declare const suggestStickerSize: import("@tanstack/start-client-core").O
|
|
|
207
243
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
208
244
|
customerKey: string;
|
|
209
245
|
tradeItemKey: string;
|
|
246
|
+
soort: "product" | "fust";
|
|
210
247
|
}, Promise<StickerUploadSize>>;
|
|
211
248
|
export type StickerSizePreviewRow = {
|
|
212
249
|
customer_key: string;
|
|
@@ -224,5 +261,4 @@ export declare const previewStickerSizes: import("@tanstack/start-client-core").
|
|
|
224
261
|
userId: string;
|
|
225
262
|
claims: import("@supabase/auth-js").JwtPayload;
|
|
226
263
|
}, undefined, undefined, undefined>], undefined, Promise<StickerSizePreviewRow[]>>;
|
|
227
|
-
export {};
|
|
228
264
|
//# sourceMappingURL=customer-stickers.functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer-stickers.functions.d.ts","sourceRoot":"","sources":["../../src/lib/customer-stickers.functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"customer-stickers.functions.d.ts","sourceRoot":"","sources":["../../src/lib/customer-stickers.functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAepD,eAAO,MAAM,oBAAoB,0EAKvB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AA0DF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,MAAM,GAAG,YAAY,CAAC,CAAC;AAO1F,kEAAkE;AAClE,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAsCvG;AAED,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;mCAG+C,CAAC;AAEjF,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;;;;;;;;;;;;;;;;;;;GA4D7B,CAAC;AAEL,eAAO,MAAM,qBAAqB;;;;8CAER,OAAO;;;;;;GAyB7B,CAAC;AAEL,eAAO,MAAM,0BAA0B;;;;8CAEb,OAAO;;;iCAa7B,CAAC;AAEL,eAAO,MAAM,0BAA0B;;;;8CAEb,OAAO;;;;;;;GAsB7B,CAAC;AAEL;;;GAGG;AACH,gEAAgE;AAChE,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;;eAoBpC,MAAM;eACI,MAAM,GAAG,IAAI;;;UAItD;AAED,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;eATD,MAAM;eACI,MAAM,GAAG,IAAI;;;UAauB,CAAC;AAS/E,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM,WAAuC,CAAC;AAEhF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;IACzE,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;CACjH,CAAC;AAEF,gGAAgG;AAChG,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAClC,OAAO,CAAC;IAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAoM7E;AAED,eAAO,MAAM,qBAAqB;;;;8CAER,OAAO;;;;;;;;;;;;;;iBAxMP,sBAAsB,EAAE;cAAY,MAAM,GAAG,IAAI;GAoOI,CAAC;AAEhF,gEAAgE;AAChE,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;;;;;kBASxC,MAAM;gBAAU,MAAM;;;kBACtB,MAAM;sBAAgB,MAAM;;GAyEvD;AAED,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;;;;;;;;;;kBA9EL,MAAM;gBAAU,MAAM;;;kBACtB,MAAM;sBAAgB,MAAM;;GAkGsB,CAAC;AAE/E,eAAO,MAAM,mBAAmB;;;;8CAEN,OAAO;;;;;GAU7B,CAAC;AAGL,0EAA0E;AAC1E,eAAO,MAAM,cAAc;;;;8CAED,OAAO;;;;;;;;GAqB7B,CAAC;AAEL,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;8BAc7B,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,mBAAmB;;;;kFA8B5B,CAAC"}
|
|
@@ -3,6 +3,17 @@ import { z } from "zod";
|
|
|
3
3
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
4
4
|
import { detectStickerSize, parseLoadedLabel, } from "./sticker-size.js";
|
|
5
5
|
import { geminiGenerateUrl, matchByFileName } from "./sticker-match.js";
|
|
6
|
+
import { isTabelOntbreekt } from "./tabel-ontbreekt.js";
|
|
7
|
+
import { FUST_NIET_BESCHIKBAAR, formaatVoorSoort, stickerDoelpad, stickerTabel, } from "./sticker-soort.js";
|
|
8
|
+
const soortSchema = z.enum(["product", "fust"]).default("product");
|
|
9
|
+
/** Vertaalt een ontbrekende fusttabel naar een rustige melding; andere fouten ongewijzigd. */
|
|
10
|
+
function soortFout(soort, error) {
|
|
11
|
+
if (soort === "fust" && isTabelOntbreekt(error)) {
|
|
12
|
+
console.error("customer_fust_stickers ontbreekt in deze database", error);
|
|
13
|
+
return new Error(FUST_NIET_BESCHIKBAAR);
|
|
14
|
+
}
|
|
15
|
+
return new Error(error.message);
|
|
16
|
+
}
|
|
6
17
|
const BUCKET = "customer-stickers";
|
|
7
18
|
const SIGNED_TTL = 60 * 60; // 1 uur
|
|
8
19
|
export const ALLOWED_STICKER_MIME = [
|
|
@@ -11,6 +22,20 @@ export const ALLOWED_STICKER_MIME = [
|
|
|
11
22
|
"image/jpeg",
|
|
12
23
|
"image/svg+xml",
|
|
13
24
|
];
|
|
25
|
+
/** Leest stickerinstellingen; fustkolommen alleen erbij voor soort 'fust'. */
|
|
26
|
+
async function leesInstellingen(sb, customerKey, soort) {
|
|
27
|
+
const cols = soort === "fust" ? "width_mm, height_mm, fust_width_mm, fust_height_mm" : "width_mm, height_mm";
|
|
28
|
+
const { data, error } = await sb
|
|
29
|
+
.from("customer_sticker_settings")
|
|
30
|
+
.select(cols)
|
|
31
|
+
.eq("customer_key", customerKey)
|
|
32
|
+
.maybeSingle();
|
|
33
|
+
if (error) {
|
|
34
|
+
console.error("Stickerinstellingen lezen mislukt", error);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return data ?? null;
|
|
38
|
+
}
|
|
14
39
|
/** Geladen etiketten uit Layouts (printers + routes). Ontbreekt iets: lege lijst, geen fout. */
|
|
15
40
|
async function loadLabels(sb) {
|
|
16
41
|
const out = [];
|
|
@@ -61,17 +86,22 @@ async function signed(sb, path) {
|
|
|
61
86
|
const { data } = await sb.storage.from(BUCKET).createSignedUrl(path, SIGNED_TTL);
|
|
62
87
|
return data?.signedUrl ?? null;
|
|
63
88
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.handler(async ({ data, context }) => {
|
|
89
|
+
/** Kern van listCustomerStickers (los aanroepbaar voor tests). */
|
|
90
|
+
export async function listCustomerStickersKern(data, context) {
|
|
91
|
+
data = { ...data, soort: data?.soort === "fust" ? "fust" : "product" };
|
|
68
92
|
const sb = context.supabase;
|
|
69
93
|
const { data: rows, error } = await sb
|
|
70
|
-
.from(
|
|
94
|
+
.from(stickerTabel(data.soort))
|
|
71
95
|
.select("trade_item_key, file_path, file_name, mime_type, file_size, updated_at, source, width_mm, height_mm")
|
|
72
96
|
.eq("customer_key", data.customerKey);
|
|
73
|
-
if (error)
|
|
97
|
+
if (error) {
|
|
98
|
+
// Fusttabel nog niet geïnstalleerd: lege fustlijst, productstickers werken door.
|
|
99
|
+
if (data.soort === "fust" && isTabelOntbreekt(error)) {
|
|
100
|
+
console.error("customer_fust_stickers ontbreekt in deze database", error);
|
|
101
|
+
return { stickers: [], format: null, soort: "fust" };
|
|
102
|
+
}
|
|
74
103
|
throw new Error(error.message);
|
|
104
|
+
}
|
|
75
105
|
const stickers = [];
|
|
76
106
|
for (const r of rows ?? []) {
|
|
77
107
|
stickers.push({
|
|
@@ -85,18 +115,16 @@ export const listCustomerStickers = createServerFn({ method: "POST" })
|
|
|
85
115
|
source: r.source === "floriday" ? "floriday" : "manual",
|
|
86
116
|
width_mm: r.width_mm != null ? Number(r.width_mm) : null,
|
|
87
117
|
height_mm: r.height_mm != null ? Number(r.height_mm) : null,
|
|
118
|
+
soort: data.soort,
|
|
88
119
|
});
|
|
89
120
|
}
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
format: fmt ? { width_mm: Number(fmt.width_mm), height_mm: Number(fmt.height_mm) } : null,
|
|
98
|
-
};
|
|
99
|
-
});
|
|
121
|
+
const fmt = await leesInstellingen(sb, data.customerKey, data.soort);
|
|
122
|
+
return { stickers, format: formaatVoorSoort(fmt, data.soort), soort: data.soort };
|
|
123
|
+
}
|
|
124
|
+
export const listCustomerStickers = createServerFn({ method: "POST" })
|
|
125
|
+
.middleware([requireSupabaseAuth])
|
|
126
|
+
.inputValidator((input) => z.object({ customerKey: z.string().min(1), soort: soortSchema }).parse(input))
|
|
127
|
+
.handler(async ({ data, context }) => listCustomerStickersKern(data, context));
|
|
100
128
|
export const confirmStickerUpload = createServerFn({ method: "POST" })
|
|
101
129
|
.middleware([requireSupabaseAuth])
|
|
102
130
|
.inputValidator((input) => z
|
|
@@ -107,10 +135,12 @@ export const confirmStickerUpload = createServerFn({ method: "POST" })
|
|
|
107
135
|
fileName: z.string().min(1),
|
|
108
136
|
mimeType: z.string().min(1),
|
|
109
137
|
fileSize: z.number().nullable().optional(),
|
|
138
|
+
soort: soortSchema,
|
|
110
139
|
})
|
|
111
140
|
.parse(input))
|
|
112
141
|
.handler(async ({ data, context }) => {
|
|
113
142
|
const sb = context.supabase;
|
|
143
|
+
const tabel = stickerTabel(data.soort);
|
|
114
144
|
if (!ALLOWED_STICKER_MIME.includes(data.mimeType)) {
|
|
115
145
|
throw new Error("Dit bestandstype wordt niet ondersteund. Gebruik PDF, PNG, JPG of SVG.");
|
|
116
146
|
}
|
|
@@ -119,14 +149,16 @@ export const confirmStickerUpload = createServerFn({ method: "POST" })
|
|
|
119
149
|
!data.filePath.startsWith(`${safe(data.customerKey)}/`)) {
|
|
120
150
|
throw new Error("Ongeldig bestandspad.");
|
|
121
151
|
}
|
|
122
|
-
const { data: existing } = await sb
|
|
123
|
-
.from(
|
|
152
|
+
const { data: existing, error: exErr } = await sb
|
|
153
|
+
.from(tabel)
|
|
124
154
|
.select("file_path")
|
|
125
155
|
.eq("customer_key", data.customerKey)
|
|
126
156
|
.eq("trade_item_key", data.tradeItemKey)
|
|
127
157
|
.maybeSingle();
|
|
158
|
+
if (exErr)
|
|
159
|
+
throw soortFout(data.soort, exErr);
|
|
128
160
|
const det = await detectForPath(sb, data.filePath, data.mimeType, await loadLabels(sb));
|
|
129
|
-
const
|
|
161
|
+
const rij = {
|
|
130
162
|
customer_key: data.customerKey,
|
|
131
163
|
trade_item_key: data.tradeItemKey,
|
|
132
164
|
width_mm: det.size?.width_mm ?? null,
|
|
@@ -137,12 +169,14 @@ export const confirmStickerUpload = createServerFn({ method: "POST" })
|
|
|
137
169
|
file_size: data.fileSize ?? null,
|
|
138
170
|
uploaded_by: context.userId ?? null,
|
|
139
171
|
source: "manual",
|
|
140
|
-
floriday_sticker_id: null,
|
|
141
172
|
content_hash: null,
|
|
142
173
|
updated_at: new Date().toISOString(),
|
|
143
|
-
}
|
|
174
|
+
};
|
|
175
|
+
if (data.soort === "product")
|
|
176
|
+
rij.floriday_sticker_id = null;
|
|
177
|
+
const { error } = await sb.from(tabel).upsert(rij, { onConflict: "customer_key,trade_item_key" });
|
|
144
178
|
if (error)
|
|
145
|
-
throw
|
|
179
|
+
throw soortFout(data.soort, error);
|
|
146
180
|
if (existing?.file_path && existing.file_path !== data.filePath) {
|
|
147
181
|
await sb.storage.from(BUCKET).remove([existing.file_path]);
|
|
148
182
|
}
|
|
@@ -152,40 +186,44 @@ export const confirmStickerUpload = createServerFn({ method: "POST" })
|
|
|
152
186
|
export const deleteCustomerSticker = createServerFn({ method: "POST" })
|
|
153
187
|
.middleware([requireSupabaseAuth])
|
|
154
188
|
.inputValidator((input) => z
|
|
155
|
-
.object({ customerKey: z.string().min(1), tradeItemKey: z.string().min(1) })
|
|
189
|
+
.object({ customerKey: z.string().min(1), tradeItemKey: z.string().min(1), soort: soortSchema })
|
|
156
190
|
.parse(input))
|
|
157
191
|
.handler(async ({ data, context }) => {
|
|
158
192
|
const sb = context.supabase;
|
|
159
|
-
const
|
|
160
|
-
|
|
193
|
+
const tabel = stickerTabel(data.soort);
|
|
194
|
+
const { data: row, error: rowErr } = await sb
|
|
195
|
+
.from(tabel)
|
|
161
196
|
.select("file_path")
|
|
162
197
|
.eq("customer_key", data.customerKey)
|
|
163
198
|
.eq("trade_item_key", data.tradeItemKey)
|
|
164
199
|
.maybeSingle();
|
|
200
|
+
if (rowErr)
|
|
201
|
+
throw soortFout(data.soort, rowErr);
|
|
165
202
|
const { error } = await sb
|
|
166
|
-
.from(
|
|
203
|
+
.from(tabel)
|
|
167
204
|
.delete()
|
|
168
205
|
.eq("customer_key", data.customerKey)
|
|
169
206
|
.eq("trade_item_key", data.tradeItemKey);
|
|
170
207
|
if (error)
|
|
171
|
-
throw
|
|
208
|
+
throw soortFout(data.soort, error);
|
|
172
209
|
if (row?.file_path)
|
|
173
210
|
await sb.storage.from(BUCKET).remove([row.file_path]);
|
|
174
211
|
return { ok: true };
|
|
175
212
|
});
|
|
176
213
|
export const getCustomerStickerSettings = createServerFn({ method: "POST" })
|
|
177
214
|
.middleware([requireSupabaseAuth])
|
|
178
|
-
.inputValidator((input) => z.object({ customerKey: z.string().min(1) }).parse(input))
|
|
215
|
+
.inputValidator((input) => z.object({ customerKey: z.string().min(1), soort: soortSchema }).parse(input))
|
|
179
216
|
.handler(async ({ data, context }) => {
|
|
180
217
|
const sb = context.supabase;
|
|
218
|
+
const cols = data.soort === "fust" ? "width_mm, height_mm, fust_width_mm, fust_height_mm" : "width_mm, height_mm";
|
|
181
219
|
const { data: fmt, error } = await sb
|
|
182
220
|
.from("customer_sticker_settings")
|
|
183
|
-
.select(
|
|
221
|
+
.select(cols)
|
|
184
222
|
.eq("customer_key", data.customerKey)
|
|
185
223
|
.maybeSingle();
|
|
186
224
|
if (error)
|
|
187
225
|
throw new Error(error.message);
|
|
188
|
-
return
|
|
226
|
+
return formaatVoorSoort(fmt, data.soort);
|
|
189
227
|
});
|
|
190
228
|
export const setCustomerStickerSettings = createServerFn({ method: "POST" })
|
|
191
229
|
.middleware([requireSupabaseAuth])
|
|
@@ -194,16 +232,15 @@ export const setCustomerStickerSettings = createServerFn({ method: "POST" })
|
|
|
194
232
|
customerKey: z.string().min(1),
|
|
195
233
|
widthMm: z.number().positive(),
|
|
196
234
|
heightMm: z.number().positive(),
|
|
235
|
+
soort: soortSchema,
|
|
197
236
|
})
|
|
198
237
|
.parse(input))
|
|
199
238
|
.handler(async ({ data, context }) => {
|
|
200
239
|
const sb = context.supabase;
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
width_mm: data.widthMm,
|
|
204
|
-
|
|
205
|
-
updated_at: new Date().toISOString(),
|
|
206
|
-
}, { onConflict: "customer_key" });
|
|
240
|
+
const maat = data.soort === "fust"
|
|
241
|
+
? { fust_width_mm: data.widthMm, fust_height_mm: data.heightMm }
|
|
242
|
+
: { width_mm: data.widthMm, height_mm: data.heightMm };
|
|
243
|
+
const { error } = await sb.from("customer_sticker_settings").upsert({ customer_key: data.customerKey, ...maat, updated_at: new Date().toISOString() }, { onConflict: "customer_key" });
|
|
207
244
|
if (error)
|
|
208
245
|
throw new Error(error.message);
|
|
209
246
|
return { ok: true };
|
|
@@ -212,35 +249,38 @@ export const setCustomerStickerSettings = createServerFn({ method: "POST" })
|
|
|
212
249
|
* Aanknopingspunt voor de pick-/printmodule: geeft het stickerbestand en het
|
|
213
250
|
* ingestelde formaat terug, of null als er geen klantsticker gekoppeld is.
|
|
214
251
|
*/
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
.object({ customerKey: z.string().min(1), tradeItemKey: z.string().min(1) })
|
|
219
|
-
.parse(input))
|
|
220
|
-
.handler(async ({ data, context }) => {
|
|
252
|
+
/** Kern van getStickerForPrint (los aanroepbaar voor tests). */
|
|
253
|
+
export async function getStickerForPrintKern(data, context) {
|
|
254
|
+
data = { ...data, soort: data?.soort === "fust" ? "fust" : "product" };
|
|
221
255
|
const sb = context.supabase;
|
|
222
|
-
const { data: row } = await sb
|
|
223
|
-
.from(
|
|
256
|
+
const { data: row, error: rowErr } = await sb
|
|
257
|
+
.from(stickerTabel(data.soort))
|
|
224
258
|
.select("file_path, file_name, mime_type, width_mm, height_mm")
|
|
225
259
|
.eq("customer_key", data.customerKey)
|
|
226
260
|
.eq("trade_item_key", data.tradeItemKey)
|
|
227
261
|
.maybeSingle();
|
|
262
|
+
if (rowErr && data.soort === "fust" && isTabelOntbreekt(rowErr)) {
|
|
263
|
+
console.error("customer_fust_stickers ontbreekt in deze database", rowErr);
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
228
266
|
if (!row?.file_path)
|
|
229
267
|
return null;
|
|
230
268
|
const own = row.width_mm != null && row.height_mm != null;
|
|
231
|
-
const
|
|
232
|
-
.from("customer_sticker_settings")
|
|
233
|
-
.select("width_mm, height_mm")
|
|
234
|
-
.eq("customer_key", data.customerKey)
|
|
235
|
-
.maybeSingle();
|
|
269
|
+
const fmt = formaatVoorSoort(await leesInstellingen(sb, data.customerKey, data.soort), data.soort);
|
|
236
270
|
return {
|
|
237
271
|
url: await signed(sb, row.file_path),
|
|
238
272
|
file_name: row.file_name,
|
|
239
273
|
mime_type: (row.mime_type ?? null),
|
|
240
|
-
width_mm: own ? Number(row.width_mm) : fmt ?
|
|
241
|
-
height_mm: own ? Number(row.height_mm) : fmt ?
|
|
274
|
+
width_mm: own ? Number(row.width_mm) : fmt ? fmt.width_mm : null,
|
|
275
|
+
height_mm: own ? Number(row.height_mm) : fmt ? fmt.height_mm : null,
|
|
242
276
|
};
|
|
243
|
-
}
|
|
277
|
+
}
|
|
278
|
+
export const getStickerForPrint = createServerFn({ method: "POST" })
|
|
279
|
+
.middleware([requireSupabaseAuth])
|
|
280
|
+
.inputValidator((input) => z
|
|
281
|
+
.object({ customerKey: z.string().min(1), tradeItemKey: z.string().min(1), soort: soortSchema })
|
|
282
|
+
.parse(input))
|
|
283
|
+
.handler(async ({ data, context }) => getStickerForPrintKern(data, context));
|
|
244
284
|
// ---------------------------------------------------------------------------
|
|
245
285
|
// Bulk-upload met AI-herkenning
|
|
246
286
|
// ---------------------------------------------------------------------------
|
|
@@ -452,26 +492,11 @@ export const suggestStickerMatches = createServerFn({ method: "POST" })
|
|
|
452
492
|
})
|
|
453
493
|
.parse(input))
|
|
454
494
|
.handler(async ({ data, context }) => koppelStickerSuggesties(data, context));
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
.object({
|
|
459
|
-
customerKey: z.string().min(1),
|
|
460
|
-
batchId: z.string().min(1),
|
|
461
|
-
items: z
|
|
462
|
-
.array(z.object({
|
|
463
|
-
inboxPath: z.string().min(1),
|
|
464
|
-
fileName: z.string().min(1),
|
|
465
|
-
mimeType: z.string().min(1),
|
|
466
|
-
fileSize: z.number().nullable().optional(),
|
|
467
|
-
tradeItemKey: z.string().min(1),
|
|
468
|
-
replaceExisting: z.boolean().default(false),
|
|
469
|
-
}))
|
|
470
|
-
.min(1),
|
|
471
|
-
})
|
|
472
|
-
.parse(input))
|
|
473
|
-
.handler(async ({ data, context }) => {
|
|
495
|
+
/** Kern van commitStickerBatch (los aanroepbaar voor tests). */
|
|
496
|
+
export async function commitStickerBatchKern(data, context) {
|
|
497
|
+
data = { ...data, soort: data?.soort === "fust" ? "fust" : "product" };
|
|
474
498
|
const sb = context.supabase;
|
|
499
|
+
const tabel = stickerTabel(data.soort);
|
|
475
500
|
const prefix = `${safeStorageKey(data.customerKey)}/_inbox/${safeStorageKey(data.batchId)}/`;
|
|
476
501
|
let linked = 0;
|
|
477
502
|
let replaced = 0;
|
|
@@ -488,24 +513,26 @@ export const commitStickerBatch = createServerFn({ method: "POST" })
|
|
|
488
513
|
}
|
|
489
514
|
if ((it.fileSize ?? 0) > MAX_STICKER_SIZE)
|
|
490
515
|
throw new Error("Bestand is groter dan 10 MB.");
|
|
491
|
-
const { data: existing } = await sb
|
|
492
|
-
.from(
|
|
516
|
+
const { data: existing, error: exErr } = await sb
|
|
517
|
+
.from(tabel)
|
|
493
518
|
.select("file_path")
|
|
494
519
|
.eq("customer_key", data.customerKey)
|
|
495
520
|
.eq("trade_item_key", it.tradeItemKey)
|
|
496
521
|
.maybeSingle();
|
|
522
|
+
if (exErr)
|
|
523
|
+
throw soortFout(data.soort, exErr);
|
|
497
524
|
if (existing?.file_path && !it.replaceExisting) {
|
|
498
525
|
skipped++;
|
|
499
526
|
continue;
|
|
500
527
|
}
|
|
501
528
|
const ext = (/\.([a-z0-9]+)$/i.exec(it.fileName)?.[1] ?? "bin").toLowerCase();
|
|
502
|
-
const target =
|
|
529
|
+
const target = stickerDoelpad(safeStorageKey(data.customerKey), safeStorageKey(it.tradeItemKey), data.soort, `${crypto.randomUUID()}.${ext}`);
|
|
503
530
|
const { error: moveErr } = await sb.storage.from(BUCKET).move(it.inboxPath, target);
|
|
504
531
|
if (moveErr)
|
|
505
532
|
throw new Error(moveErr.message);
|
|
506
533
|
const det = await detectForPath(sb, target, it.mimeType, labels);
|
|
507
534
|
sizes.push({ fileName: it.fileName, tradeItemKey: it.tradeItemKey, method: det.method, size: det.size, suggestion: det.suggestion });
|
|
508
|
-
const
|
|
535
|
+
const rij = {
|
|
509
536
|
customer_key: data.customerKey,
|
|
510
537
|
trade_item_key: it.tradeItemKey,
|
|
511
538
|
file_path: target,
|
|
@@ -516,12 +543,14 @@ export const commitStickerBatch = createServerFn({ method: "POST" })
|
|
|
516
543
|
file_size: it.fileSize ?? null,
|
|
517
544
|
uploaded_by: context.userId ?? null,
|
|
518
545
|
source: "manual",
|
|
519
|
-
floriday_sticker_id: null,
|
|
520
546
|
content_hash: null,
|
|
521
547
|
updated_at: new Date().toISOString(),
|
|
522
|
-
}
|
|
548
|
+
};
|
|
549
|
+
if (data.soort === "product")
|
|
550
|
+
rij.floriday_sticker_id = null;
|
|
551
|
+
const { error: upErr } = await sb.from(tabel).upsert(rij, { onConflict: "customer_key,trade_item_key" });
|
|
523
552
|
if (upErr)
|
|
524
|
-
throw
|
|
553
|
+
throw soortFout(data.soort, upErr);
|
|
525
554
|
if (existing?.file_path) {
|
|
526
555
|
await sb.storage.from(BUCKET).remove([existing.file_path]);
|
|
527
556
|
replaced++;
|
|
@@ -540,7 +569,27 @@ export const commitStickerBatch = createServerFn({ method: "POST" })
|
|
|
540
569
|
if (paths.length)
|
|
541
570
|
await sb.storage.from(BUCKET).remove(paths);
|
|
542
571
|
return { linked, replaced, skipped, failed, sizes };
|
|
543
|
-
}
|
|
572
|
+
}
|
|
573
|
+
export const commitStickerBatch = createServerFn({ method: "POST" })
|
|
574
|
+
.middleware([requireSupabaseAuth])
|
|
575
|
+
.inputValidator((input) => z
|
|
576
|
+
.object({
|
|
577
|
+
customerKey: z.string().min(1),
|
|
578
|
+
batchId: z.string().min(1),
|
|
579
|
+
items: z
|
|
580
|
+
.array(z.object({
|
|
581
|
+
inboxPath: z.string().min(1),
|
|
582
|
+
fileName: z.string().min(1),
|
|
583
|
+
mimeType: z.string().min(1),
|
|
584
|
+
fileSize: z.number().nullable().optional(),
|
|
585
|
+
tradeItemKey: z.string().min(1),
|
|
586
|
+
replaceExisting: z.boolean().default(false),
|
|
587
|
+
}))
|
|
588
|
+
.min(1),
|
|
589
|
+
soort: soortSchema,
|
|
590
|
+
})
|
|
591
|
+
.parse(input))
|
|
592
|
+
.handler(async ({ data, context }) => commitStickerBatchKern(data, context));
|
|
544
593
|
export const discardStickerBatch = createServerFn({ method: "POST" })
|
|
545
594
|
.middleware([requireSupabaseAuth])
|
|
546
595
|
.inputValidator((input) => z.object({ customerKey: z.string().min(1), batchId: z.string().min(1) }).parse(input))
|
|
@@ -562,13 +611,14 @@ export const setStickerSize = createServerFn({ method: "POST" })
|
|
|
562
611
|
tradeItemKey: z.string().min(1),
|
|
563
612
|
widthMm: z.number().positive().max(1000),
|
|
564
613
|
heightMm: z.number().positive().max(1000),
|
|
614
|
+
soort: soortSchema,
|
|
565
615
|
})
|
|
566
616
|
.parse(input))
|
|
567
617
|
.handler(async ({ data, context }) => {
|
|
568
618
|
const sb = context.supabase;
|
|
569
619
|
const r = (v) => Math.round(v * 10) / 10;
|
|
570
620
|
const { error } = await sb
|
|
571
|
-
.from(
|
|
621
|
+
.from(stickerTabel(data.soort))
|
|
572
622
|
.update({ width_mm: r(data.widthMm), height_mm: r(data.heightMm), updated_at: new Date().toISOString() })
|
|
573
623
|
.eq("customer_key", data.customerKey)
|
|
574
624
|
.eq("trade_item_key", data.tradeItemKey);
|
|
@@ -579,11 +629,11 @@ export const setStickerSize = createServerFn({ method: "POST" })
|
|
|
579
629
|
/** Voorstel voor één sticker zonder maat (voor de knop in de stickercel). */
|
|
580
630
|
export const suggestStickerSize = createServerFn({ method: "POST" })
|
|
581
631
|
.middleware([requireSupabaseAuth])
|
|
582
|
-
.inputValidator((input) => z.object({ customerKey: z.string().min(1), tradeItemKey: z.string().min(1) }).parse(input))
|
|
632
|
+
.inputValidator((input) => z.object({ customerKey: z.string().min(1), tradeItemKey: z.string().min(1), soort: soortSchema }).parse(input))
|
|
583
633
|
.handler(async ({ data, context }) => {
|
|
584
634
|
const sb = context.supabase;
|
|
585
635
|
const { data: row } = await sb
|
|
586
|
-
.from(
|
|
636
|
+
.from(stickerTabel(data.soort))
|
|
587
637
|
.select("file_path, mime_type")
|
|
588
638
|
.eq("customer_key", data.customerKey)
|
|
589
639
|
.eq("trade_item_key", data.tradeItemKey)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type PdfLoader = () => Promise<typeof import("pdfjs-dist")>;
|
|
2
|
+
/** Rendert pagina 1 naar JPEG (max. 1024 px). Mislukt = null, nooit een fout. */
|
|
3
|
+
export declare function renderPdfThumbnail(file: Blob, loader?: PdfLoader, max?: number): Promise<string | null>;
|
|
4
|
+
//# sourceMappingURL=pdf-thumbnail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-thumbnail.d.ts","sourceRoot":"","sources":["../../src/lib/pdf-thumbnail.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,cAAc,YAAY,CAAC,CAAC,CAAC;AASnE,iFAAiF;AACjF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,MAAM,GAAE,SAAyB,EACjC,GAAG,SAAO,GACT,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Voorbeeldplaatje van de eerste pagina van een PDF, alleen in de browser.
|
|
2
|
+
// pdf.js wordt pas geladen als er een PDF is. De worker wordt als module
|
|
3
|
+
// ingeladen (zet globalThis.pdfjsWorker); er wordt geen workerSrc gezet, dus
|
|
4
|
+
// pdf.js gebruikt die ingeladen worker in de hoofdthread. Geen CDN.
|
|
5
|
+
const defaultLoader = async () => {
|
|
6
|
+
await import("pdfjs-dist/build/pdf.worker.min.mjs");
|
|
7
|
+
return import("pdfjs-dist");
|
|
8
|
+
};
|
|
9
|
+
let queue = Promise.resolve();
|
|
10
|
+
/** Rendert pagina 1 naar JPEG (max. 1024 px). Mislukt = null, nooit een fout. */
|
|
11
|
+
export function renderPdfThumbnail(file, loader = defaultLoader, max = 1024) {
|
|
12
|
+
// Eén voor één, zodat veel PDF's de browser niet laten vastlopen.
|
|
13
|
+
const run = queue.then(() => renderNow(file, loader, max));
|
|
14
|
+
queue = run.catch(() => undefined);
|
|
15
|
+
return run;
|
|
16
|
+
}
|
|
17
|
+
async function renderNow(file, loader, max) {
|
|
18
|
+
if (typeof document === "undefined")
|
|
19
|
+
return null;
|
|
20
|
+
try {
|
|
21
|
+
const pdfjs = await loader();
|
|
22
|
+
const data = new Uint8Array(await file.arrayBuffer());
|
|
23
|
+
const task = pdfjs.getDocument({ data });
|
|
24
|
+
const doc = await task.promise;
|
|
25
|
+
try {
|
|
26
|
+
const page = await doc.getPage(1);
|
|
27
|
+
const base = page.getViewport({ scale: 1 });
|
|
28
|
+
const scale = Math.min(4, max / Math.max(base.width || max, base.height || max));
|
|
29
|
+
const viewport = page.getViewport({ scale });
|
|
30
|
+
const canvas = document.createElement("canvas");
|
|
31
|
+
canvas.width = Math.max(1, Math.round(viewport.width));
|
|
32
|
+
canvas.height = Math.max(1, Math.round(viewport.height));
|
|
33
|
+
const ctx = canvas.getContext("2d");
|
|
34
|
+
if (!ctx)
|
|
35
|
+
return null;
|
|
36
|
+
ctx.fillStyle = "#ffffff";
|
|
37
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
38
|
+
await page.render({ canvas, canvasContext: ctx, viewport }).promise;
|
|
39
|
+
return canvas.toDataURL("image/jpeg", 0.85);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
void task.destroy();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
console.error("PDF-voorbeeld maken mislukt", e);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Soort klantsticker: productsticker (bestaand) of fuststicker (aparte tabel). */
|
|
2
|
+
export type StickerSoort = "product" | "fust";
|
|
3
|
+
export declare const FUST_NIET_BESCHIKBAAR = "Fuststickers zijn hier nog niet beschikbaar. Neem contact op met de beheerder.";
|
|
4
|
+
/** Eén plek die de tabel kiest; productstickers blijven in customer_product_stickers. */
|
|
5
|
+
export declare function stickerTabel(soort?: StickerSoort): "customer_product_stickers" | "customer_fust_stickers";
|
|
6
|
+
/** Opslagpad: fuststickers in een eigen submap, zodat ze productstickers nooit overschrijven. */
|
|
7
|
+
export declare function stickerDoelpad(klant: string, product: string, soort: StickerSoort, bestand: string): string;
|
|
8
|
+
type InstellingenRij = {
|
|
9
|
+
width_mm?: unknown;
|
|
10
|
+
height_mm?: unknown;
|
|
11
|
+
fust_width_mm?: unknown;
|
|
12
|
+
fust_height_mm?: unknown;
|
|
13
|
+
} | null;
|
|
14
|
+
/** Formaat per soort; fust zonder eigen formaat = geen formaat (null). */
|
|
15
|
+
export declare function formaatVoorSoort(rij: InstellingenRij, soort?: StickerSoort): {
|
|
16
|
+
width_mm: number;
|
|
17
|
+
height_mm: number;
|
|
18
|
+
} | null;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=sticker-soort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticker-soort.d.ts","sourceRoot":"","sources":["../../src/lib/sticker-soort.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9C,eAAO,MAAM,qBAAqB,mFACgD,CAAC;AAEnF,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,KAAK,GAAE,YAAwB,GAAG,2BAA2B,GAAG,wBAAwB,CAEpH;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3G;AAED,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,IAAI,CAAC;AAET,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,eAAe,EACpB,KAAK,GAAE,YAAwB,GAC9B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOhD"}
|