@flowselections/floriday-authenticatie-module 1.0.41 → 1.0.43

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 (45) hide show
  1. package/dist-lib/components/settings/FlorydaySettingsCard.js +4 -9
  2. package/dist-lib/integrations/supabase/auth-middleware.d.ts +728 -9
  3. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  4. package/dist-lib/integrations/supabase/client.d.ts +728 -9
  5. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  6. package/dist-lib/integrations/supabase/client.server.d.ts +728 -9
  7. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  8. package/dist-lib/integrations/supabase/types.d.ts +736 -9
  9. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  10. package/dist-lib/lib/floricode.functions.d.ts +5412 -379
  11. package/dist-lib/lib/floricode.functions.d.ts.map +1 -1
  12. package/dist-lib/lib/floriday-auction-letters.functions.d.ts +728 -9
  13. package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
  14. package/dist-lib/lib/floriday-labels.functions.d.ts +728 -9
  15. package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
  16. package/dist-lib/lib/floriday-public.functions.d.ts +4605 -291
  17. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  18. package/dist-lib/lib/floriday-stickers.functions.d.ts +728 -9
  19. package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
  20. package/dist-lib/lib/floriday-sync.functions.d.ts +24780 -2491
  21. package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
  22. package/dist-lib/lib/floriday-tray-stickers.functions.d.ts +14 -0
  23. package/dist-lib/lib/floriday-tray-stickers.functions.d.ts.map +1 -0
  24. package/dist-lib/lib/floriday-tray-stickers.functions.js +66 -0
  25. package/dist-lib/lib/floriday-writes.functions.d.ts +52015 -515
  26. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  27. package/dist-lib/lib/floriday-writes.functions.js +17 -12
  28. package/dist-lib/lib/floriday.functions.d.ts +15017 -1229
  29. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  30. package/dist-lib/lib/floriday.functions.js +76 -21
  31. package/dist-lib/lib/gateway/fulfillment-order-body.d.ts +37 -1
  32. package/dist-lib/lib/gateway/fulfillment-order-body.d.ts.map +1 -1
  33. package/dist-lib/lib/gateway/fulfillment-order-body.js +179 -119
  34. package/dist-lib/lib/gateway/fulfillment-order-send.d.ts.map +1 -1
  35. package/dist-lib/lib/gateway/fulfillment-order-send.js +6 -0
  36. package/dist-lib/lib/gateway/fulfillment-order-status.d.ts +11 -0
  37. package/dist-lib/lib/gateway/fulfillment-order-status.d.ts.map +1 -0
  38. package/dist-lib/lib/gateway/fulfillment-order-status.js +84 -0
  39. package/dist-lib/lib/gateway/index.d.ts +1 -0
  40. package/dist-lib/lib/gateway/index.d.ts.map +1 -1
  41. package/dist-lib/lib/gateway/index.js +1 -0
  42. package/dist-lib/lib/gateway/pdf.d.ts +1 -1
  43. package/dist-lib/lib/gateway/pdf.d.ts.map +1 -1
  44. package/dist-lib/lib/gateway/pdf.js +11 -0
  45. package/package.json +10 -1
@@ -0,0 +1,14 @@
1
+ import type { SupabaseClient } from "@supabase/supabase-js";
2
+ import { type FlorydayEnvironment } from "./floriday.functions.js";
3
+ export interface FlorydayTrayStickers {
4
+ deliveryOrderId: string;
5
+ url: string;
6
+ expiresAt: string;
7
+ contentType: string;
8
+ }
9
+ /** Server-helper voor de HTTP-gateway (eigen Supabase-client). */
10
+ export declare function resolveTrayStickers(supabase: SupabaseClient, input: {
11
+ environment: FlorydayEnvironment;
12
+ deliveryOrderId: string;
13
+ }): Promise<FlorydayTrayStickers>;
14
+ //# sourceMappingURL=floriday-tray-stickers.functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floriday-tray-stickers.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-tray-stickers.functions.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAKjC,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAkDD,kEAAkE;AAClE,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE;IAAE,WAAW,EAAE,mBAAmB,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAAC,oBAAoB,CAAC,CA0B/B"}
@@ -0,0 +1,66 @@
1
+ // ============================================================================
2
+ // Floriday tray-stickers per delivery-order — lazy PDF fetch + storage cache
3
+ // ----------------------------------------------------------------------------
4
+ // GET /delivery-orders/{deliveryOrderId}/stickers (scope fulfillment:read)
5
+ // levert de fustsstickers als PDF. Zelfde patroon als de logistieke labels en
6
+ // klantstickers: eerst Storage, bij een miss ophalen bij Floriday.
7
+ // ============================================================================
8
+ import { SUPPLIERS_API_VERSION, florydayFetch, getActiveFlorydayCredentials, } from "./floriday.functions.js";
9
+ const BUCKET = "floriday-logistic-labels";
10
+ const SIGNED_URL_TTL_S = 60 * 60; // 1 uur
11
+ async function ensureTrayStickersInStorage(supabase, env, connectionId, deliveryOrderId) {
12
+ const path = `/${SUPPLIERS_API_VERSION}/delivery-orders/${encodeURIComponent(deliveryOrderId)}/stickers`;
13
+ const res = await florydayFetch(supabase, env, path, {
14
+ cache: "no-store",
15
+ headers: { Accept: "application/pdf, application/json" },
16
+ });
17
+ if (!res.ok) {
18
+ const body = await res.text().catch(() => "");
19
+ throw new Error(`Floriday delivery-order stickers ${res.status}: ${body.slice(0, 200)}`);
20
+ }
21
+ const contentType = (res.headers.get("content-type") ?? "").toLowerCase();
22
+ let bytes;
23
+ let storedContentType = "application/pdf";
24
+ if (contentType.includes("application/json")) {
25
+ const json = await res.json();
26
+ const first = Array.isArray(json) ? json[0] : json;
27
+ const b64 = first?.pdfBase64 ?? first?.contentBase64 ?? first?.base64 ?? first?.pdf;
28
+ if (!b64)
29
+ throw new Error("Sticker-response bevat geen PDF-data");
30
+ const binary = atob(b64);
31
+ bytes = new Uint8Array(binary.length);
32
+ for (let i = 0; i < binary.length; i++)
33
+ bytes[i] = binary.charCodeAt(i);
34
+ }
35
+ else {
36
+ bytes = new Uint8Array(await res.arrayBuffer());
37
+ storedContentType = contentType || "application/pdf";
38
+ }
39
+ const storagePath = `${connectionId}/delivery-orders/${deliveryOrderId}/tray-stickers.pdf`;
40
+ const { error: upErr } = await supabase.storage
41
+ .from(BUCKET)
42
+ .upload(storagePath, bytes, { contentType: storedContentType, upsert: true });
43
+ if (upErr)
44
+ throw new Error(`Storage upload: ${upErr.message}`);
45
+ return { storagePath, contentType: storedContentType };
46
+ }
47
+ /** Server-helper voor de HTTP-gateway (eigen Supabase-client). */
48
+ export async function resolveTrayStickers(supabase, input) {
49
+ const row = await getActiveFlorydayCredentials(supabase, input.environment);
50
+ if (!row) {
51
+ throw new Error(`Geen actieve Floriday-koppeling voor ${input.environment}`);
52
+ }
53
+ const { storagePath, contentType } = await ensureTrayStickersInStorage(supabase, input.environment, row.id, input.deliveryOrderId);
54
+ const { data: signed, error: signErr } = await supabase.storage
55
+ .from(BUCKET)
56
+ .createSignedUrl(storagePath, SIGNED_URL_TTL_S);
57
+ if (signErr || !signed?.signedUrl) {
58
+ throw new Error(`Signed URL: ${signErr?.message ?? "onbekend"}`);
59
+ }
60
+ return {
61
+ deliveryOrderId: input.deliveryOrderId,
62
+ url: signed.signedUrl,
63
+ expiresAt: new Date(Date.now() + SIGNED_URL_TTL_S * 1000).toISOString(),
64
+ contentType,
65
+ };
66
+ }