@flowselections/floriday-verkoop-module 1.0.44 → 1.0.46

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 (116) hide show
  1. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +9 -0
  2. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
  3. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +26 -0
  4. package/dist-lib/components/karindeling/AfmetingenTab.d.ts +6 -0
  5. package/dist-lib/components/karindeling/AfmetingenTab.d.ts.map +1 -0
  6. package/dist-lib/components/karindeling/AfmetingenTab.js +128 -0
  7. package/dist-lib/components/karindeling/KarindelingPage.d.ts +2 -0
  8. package/dist-lib/components/karindeling/KarindelingPage.d.ts.map +1 -0
  9. package/dist-lib/components/karindeling/KarindelingPage.js +102 -0
  10. package/dist-lib/components/ui/dropdown-menu.d.ts +9 -0
  11. package/dist-lib/components/ui/dropdown-menu.d.ts.map +1 -0
  12. package/dist-lib/components/ui/dropdown-menu.js +14 -0
  13. package/dist-lib/components/verkoop/AnalyticsCards.d.ts +1 -1
  14. package/dist-lib/components/verkoop/AnalyticsCards.d.ts.map +1 -1
  15. package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts +1 -1
  16. package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts.map +1 -1
  17. package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts +1 -1
  18. package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts.map +1 -1
  19. package/dist-lib/components/verkoop/CreateOrderDialog.d.ts +5 -0
  20. package/dist-lib/components/verkoop/CreateOrderDialog.d.ts.map +1 -0
  21. package/dist-lib/components/verkoop/CreateOrderDialog.js +33 -0
  22. package/dist-lib/components/verkoop/CreateOrderPage.d.ts +1 -1
  23. package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
  24. package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts +1 -1
  25. package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts.map +1 -1
  26. package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts +1 -1
  27. package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
  28. package/dist-lib/components/verkoop/EngineBufferCard.d.ts +1 -1
  29. package/dist-lib/components/verkoop/EngineBufferCard.d.ts.map +1 -1
  30. package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts +1 -1
  31. package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts.map +1 -1
  32. package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts +1 -1
  33. package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts.map +1 -1
  34. package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts +1 -1
  35. package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts.map +1 -1
  36. package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts +1 -1
  37. package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts.map +1 -1
  38. package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts +1 -1
  39. package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
  40. package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts +1 -1
  41. package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
  42. package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts +1 -1
  43. package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
  44. package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts +1 -1
  45. package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
  46. package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +1 -1
  47. package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
  48. package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +1 -1
  49. package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
  50. package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +1 -1
  51. package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
  52. package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +1 -2
  53. package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
  54. package/dist-lib/components/verkoop/SearchableSelect.d.ts +1 -1
  55. package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
  56. package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts +1 -1
  57. package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
  58. package/dist-lib/components/verkoop/WeekCalendar.d.ts +1 -1
  59. package/dist-lib/components/verkoop/WeekCalendar.d.ts.map +1 -1
  60. package/dist-lib/integrations/supabase/auth-middleware.d.ts +520 -145
  61. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  62. package/dist-lib/integrations/supabase/client.d.ts +520 -145
  63. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  64. package/dist-lib/integrations/supabase/client.server.d.ts +520 -145
  65. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  66. package/dist-lib/integrations/supabase/types.d.ts +545 -161
  67. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  68. package/dist-lib/lib/cart-lock.functions.d.ts +520 -145
  69. package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
  70. package/dist-lib/lib/cart-planning-settings.functions.d.ts +5720 -1595
  71. package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -1
  72. package/dist-lib/lib/cart-replan.functions.d.ts +1560 -435
  73. package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
  74. package/dist-lib/lib/create-order.functions.d.ts +8840 -2465
  75. package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
  76. package/dist-lib/lib/floriday/floriday.server.d.ts +14 -0
  77. package/dist-lib/lib/floriday/floriday.server.d.ts.map +1 -0
  78. package/dist-lib/lib/floriday/floriday.server.js +92 -0
  79. package/dist-lib/lib/floriday/sales-orders.functions.d.ts +4736 -0
  80. package/dist-lib/lib/floriday/sales-orders.functions.d.ts.map +1 -0
  81. package/dist-lib/lib/floriday/sales-orders.functions.js +193 -0
  82. package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +1560 -435
  83. package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
  84. package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +520 -145
  85. package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
  86. package/dist-lib/lib/floriday-mirror.functions.d.ts +520 -145
  87. package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
  88. package/dist-lib/lib/floriday-public.functions.d.ts +3640 -1015
  89. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  90. package/dist-lib/lib/floriday-writes.functions.d.ts +2600 -725
  91. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  92. package/dist-lib/lib/invoice-timing.functions.d.ts +2080 -580
  93. package/dist-lib/lib/invoice-timing.functions.d.ts.map +1 -1
  94. package/dist-lib/lib/load-carriers.functions.d.ts +520 -145
  95. package/dist-lib/lib/load-carriers.functions.d.ts.map +1 -1
  96. package/dist-lib/lib/logistics-engine.functions.d.ts +2600 -725
  97. package/dist-lib/lib/logistics-engine.functions.d.ts.map +1 -1
  98. package/dist-lib/lib/logistics-stock.functions.d.ts +1040 -290
  99. package/dist-lib/lib/logistics-stock.functions.d.ts.map +1 -1
  100. package/dist-lib/lib/order-addresses.functions.d.ts +520 -145
  101. package/dist-lib/lib/order-addresses.functions.d.ts.map +1 -1
  102. package/dist-lib/lib/order-buffers.functions.d.ts +1560 -435
  103. package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -1
  104. package/dist-lib/lib/order-carrier.functions.d.ts +1040 -290
  105. package/dist-lib/lib/order-carrier.functions.d.ts.map +1 -1
  106. package/dist-lib/lib/order-pickup.functions.d.ts +1040 -290
  107. package/dist-lib/lib/order-pickup.functions.d.ts.map +1 -1
  108. package/dist-lib/lib/order-shipments.functions.d.ts +2080 -580
  109. package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
  110. package/dist-lib/lib/salesorders-list.functions.d.ts +520 -145
  111. package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
  112. package/dist-lib/lib/salesorders.functions.d.ts +2600 -725
  113. package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
  114. package/dist-lib/lib/tradeitems.functions.d.ts +520 -145
  115. package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
  116. package/package.json +3 -3
@@ -0,0 +1,14 @@
1
+ export interface FlorIdayConn {
2
+ id: string;
3
+ environment: "staging" | "production" | string;
4
+ client_id: string;
5
+ client_secret: string;
6
+ api_key: string;
7
+ access_token: string | null;
8
+ token_expires_at: string | null;
9
+ organization_name: string | null;
10
+ gln_code: string | null;
11
+ }
12
+ export declare function getActiveConnection(): Promise<FlorIdayConn>;
13
+ export declare function florIdayFetch<T = unknown>(path: string, init?: RequestInit): Promise<T>;
14
+ //# sourceMappingURL=floriday.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floriday.server.d.ts","sourceRoot":"","sources":["../../../src/lib/floriday/floriday.server.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAiBD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,YAAY,CAAC,CAsBjE;AAqCD,wBAAsB,aAAa,CAAC,CAAC,GAAG,OAAO,EAC7C,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
@@ -0,0 +1,92 @@
1
+ // Floriday Suppliers API client (server-only)
2
+ import { supabaseAdmin } from "../../integrations/supabase/client.server";
3
+ function endpoints(env) {
4
+ const isProd = env === "production" || env === "prod";
5
+ return {
6
+ auth: isProd
7
+ ? "https://accounts.floriday.io/oauth/token"
8
+ : "https://accounts.staging.floriday.io/oauth/token",
9
+ audience: isProd
10
+ ? "https://api.floriday.io"
11
+ : "https://api.staging.floriday.io",
12
+ api: isProd
13
+ ? "https://api.floriday.io/suppliers-api-2026v1"
14
+ : "https://api.staging.floriday.io/suppliers-api-2026v1",
15
+ };
16
+ }
17
+ export async function getActiveConnection() {
18
+ const { data: settings } = await supabaseAdmin
19
+ .from("floriday_settings")
20
+ .select("active_environment")
21
+ .eq("id", 1)
22
+ .maybeSingle();
23
+ const env = settings?.active_environment ?? "staging";
24
+ const { data, error } = await supabaseAdmin
25
+ .from("floriday_connections")
26
+ .select("id,environment,client_id,client_secret,api_key,access_token,token_expires_at,organization_name,gln_code,is_active")
27
+ .eq("environment", env)
28
+ .eq("is_active", true)
29
+ .order("updated_at", { ascending: false })
30
+ .limit(1)
31
+ .maybeSingle();
32
+ if (error)
33
+ throw new Error(`Floriday connectie ophalen mislukt: ${error.message}`);
34
+ if (!data)
35
+ throw new Error(`Geen actieve Floriday connectie voor omgeving "${env}"`);
36
+ return data;
37
+ }
38
+ async function fetchToken(conn) {
39
+ const ep = endpoints(conn.environment);
40
+ const body = new URLSearchParams({
41
+ grant_type: "client_credentials",
42
+ client_id: conn.client_id,
43
+ client_secret: conn.client_secret,
44
+ audience: ep.audience,
45
+ });
46
+ const res = await fetch(ep.auth, {
47
+ method: "POST",
48
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
49
+ body,
50
+ });
51
+ const text = await res.text();
52
+ if (!res.ok) {
53
+ throw new Error(`Floriday OAuth fout [${res.status}]: ${text.slice(0, 300)}`);
54
+ }
55
+ const json = JSON.parse(text);
56
+ const token = json.access_token;
57
+ const expiresIn = json.expires_in ?? 3600;
58
+ const expiresAt = new Date(Date.now() + (expiresIn - 60) * 1000).toISOString();
59
+ await supabaseAdmin
60
+ .from("floriday_connections")
61
+ .update({ access_token: token, token_expires_at: expiresAt })
62
+ .eq("id", conn.id);
63
+ return { token, expiresAt };
64
+ }
65
+ async function ensureToken(conn) {
66
+ const exp = conn.token_expires_at ? new Date(conn.token_expires_at).getTime() : 0;
67
+ if (conn.access_token && exp > Date.now() + 60000)
68
+ return conn.access_token;
69
+ const { token } = await fetchToken(conn);
70
+ return token;
71
+ }
72
+ export async function florIdayFetch(path, init = {}) {
73
+ const conn = await getActiveConnection();
74
+ const token = await ensureToken(conn);
75
+ const ep = endpoints(conn.environment);
76
+ const url = path.startsWith("http") ? path : `${ep.api}${path}`;
77
+ const res = await fetch(url, {
78
+ ...init,
79
+ headers: {
80
+ Accept: "application/json",
81
+ "Content-Type": "application/json",
82
+ Authorization: `Bearer ${token}`,
83
+ "x-api-key": conn.api_key,
84
+ ...init.headers,
85
+ },
86
+ });
87
+ const text = await res.text();
88
+ if (!res.ok) {
89
+ throw new Error(`Floriday API ${res.status} ${path}: ${text.slice(0, 400)}`);
90
+ }
91
+ return (text ? JSON.parse(text) : null);
92
+ }