@flowselections/floriday-authenticatie-module 1.0.13 → 1.0.14

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 (48) hide show
  1. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +20 -0
  2. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
  3. package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +35 -0
  4. package/dist-lib/components/settings/FlorydaySettingsCard.d.ts.map +1 -1
  5. package/dist-lib/components/settings/FlorydaySettingsCard.js +75 -53
  6. package/dist-lib/integrations/supabase/auth-middleware.d.ts +6121 -2360
  7. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  8. package/dist-lib/integrations/supabase/client.d.ts +6121 -2360
  9. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  10. package/dist-lib/integrations/supabase/client.server.d.ts +6121 -2360
  11. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  12. package/dist-lib/integrations/supabase/types.d.ts +6259 -2382
  13. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  14. package/dist-lib/integrations/supabase/types.js +10 -1
  15. package/dist-lib/lib/floricode-product-features.d.ts +50 -0
  16. package/dist-lib/lib/floricode-product-features.d.ts.map +1 -0
  17. package/dist-lib/lib/floricode-product-features.js +314 -0
  18. package/dist-lib/lib/floricode-regulatory-features.d.ts +41 -0
  19. package/dist-lib/lib/floricode-regulatory-features.d.ts.map +1 -0
  20. package/dist-lib/lib/floricode-regulatory-features.js +226 -0
  21. package/dist-lib/lib/floriday-auction-letters.functions.d.ts +9307 -0
  22. package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -0
  23. package/dist-lib/lib/floriday-auction-letters.functions.js +129 -0
  24. package/dist-lib/lib/floriday-gateway-hmac.d.ts +29 -0
  25. package/dist-lib/lib/floriday-gateway-hmac.d.ts.map +1 -0
  26. package/dist-lib/lib/floriday-gateway-hmac.js +119 -0
  27. package/dist-lib/lib/floriday-labels.functions.d.ts +9312 -0
  28. package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -0
  29. package/dist-lib/lib/floriday-labels.functions.js +141 -0
  30. package/dist-lib/lib/floriday-public.functions.d.ts +55883 -0
  31. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -0
  32. package/dist-lib/lib/floriday-public.functions.js +241 -0
  33. package/dist-lib/lib/floriday-scopes.d.ts +20 -0
  34. package/dist-lib/lib/floriday-scopes.d.ts.map +1 -0
  35. package/dist-lib/lib/floriday-scopes.js +89 -0
  36. package/dist-lib/lib/floriday-stickers.functions.d.ts +9304 -0
  37. package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -0
  38. package/dist-lib/lib/floriday-stickers.functions.js +128 -0
  39. package/dist-lib/lib/floriday-sync.functions.d.ts +240368 -1916
  40. package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
  41. package/dist-lib/lib/floriday-sync.functions.js +836 -35
  42. package/dist-lib/lib/floriday-writes.functions.d.ts +55812 -0
  43. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -0
  44. package/dist-lib/lib/floriday-writes.functions.js +160 -0
  45. package/dist-lib/lib/floriday.functions.d.ts +125816 -46888
  46. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  47. package/dist-lib/lib/floriday.functions.js +451 -58
  48. package/package.json +2 -2
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Floriday-schrijfacties — typed helpers voor andere modules.
3
+ *
4
+ * Alle Floriday-modules (Verkoop, Magazijn, Catalogus, …) doen schrijfacties
5
+ * via deze helpers. Niemand bouwt zelf een fetch/Authorization-header. Onder
6
+ * water draait alles door `florydayWrite` in `floriday.functions.ts`, dat
7
+ * token-refresh, retry, idempotency en write-log voor zijn rekening neemt.
8
+ *
9
+ * Conventie:
10
+ * - Iedere helper geeft `module` mee aan de write-log (filterbaar in admin).
11
+ * - Iedere helper kiest een logische `action` zodat dezelfde call binnen
12
+ * dezelfde input automatisch idempotent is.
13
+ * - Helpers gooien geen excepties bij Floriday-fouten: ze geven het
14
+ * resultaat van `florydayWrite` terug (`{ ok, status, data, error }`).
15
+ */
16
+ import { createServerFn } from "@tanstack/react-start";
17
+ import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
18
+ import { florydayWrite, } from "./floriday.functions";
19
+ // ─── Verkoop ────────────────────────────────────────────────────────────────
20
+ export const acknowledgeSalesOrder = createServerFn({ method: "POST" })
21
+ .middleware([requireSupabaseAuth])
22
+ .inputValidator((input) => {
23
+ if (!["staging", "live"].includes(input.environment)) {
24
+ throw new Error("Ongeldige environment");
25
+ }
26
+ if (!input.salesOrderId?.trim())
27
+ throw new Error("salesOrderId is verplicht");
28
+ return input;
29
+ })
30
+ .handler(async ({ data, context }) => {
31
+ return florydayWrite(context.supabase, data.environment, {
32
+ module: "sales",
33
+ action: "acknowledge-sales-order",
34
+ method: "POST",
35
+ path: `/sales-orders/${encodeURIComponent(data.salesOrderId)}/acknowledge`,
36
+ referenceId: data.salesOrderId,
37
+ body: data.lines ? { lines: data.lines } : undefined,
38
+ });
39
+ });
40
+ export const rejectSalesOrder = createServerFn({ method: "POST" })
41
+ .middleware([requireSupabaseAuth])
42
+ .inputValidator((input) => {
43
+ if (!["staging", "live"].includes(input.environment)) {
44
+ throw new Error("Ongeldige environment");
45
+ }
46
+ if (!input.salesOrderId?.trim())
47
+ throw new Error("salesOrderId is verplicht");
48
+ if (!input.reason?.trim())
49
+ throw new Error("Geef een reden voor afwijzing op");
50
+ return input;
51
+ })
52
+ .handler(async ({ data, context }) => {
53
+ return florydayWrite(context.supabase, data.environment, {
54
+ module: "sales",
55
+ action: "reject-sales-order",
56
+ method: "POST",
57
+ path: `/sales-orders/${encodeURIComponent(data.salesOrderId)}/reject`,
58
+ referenceId: data.salesOrderId,
59
+ body: { reason: data.reason },
60
+ });
61
+ });
62
+ // ─── Fulfillment / Magazijn ─────────────────────────────────────────────────
63
+ export const confirmFulfillmentOrder = createServerFn({ method: "POST" })
64
+ .middleware([requireSupabaseAuth])
65
+ .inputValidator((input) => {
66
+ if (!["staging", "live"].includes(input.environment)) {
67
+ throw new Error("Ongeldige environment");
68
+ }
69
+ if (!input.fulfillmentOrderId?.trim()) {
70
+ throw new Error("fulfillmentOrderId is verplicht");
71
+ }
72
+ return input;
73
+ })
74
+ .handler(async ({ data, context }) => {
75
+ return florydayWrite(context.supabase, data.environment, {
76
+ module: "warehouse",
77
+ action: "confirm-fulfillment-order",
78
+ method: "POST",
79
+ path: `/fulfillment-orders/${encodeURIComponent(data.fulfillmentOrderId)}/confirm`,
80
+ referenceId: data.fulfillmentOrderId,
81
+ body: data.lines ? { lines: data.lines } : undefined,
82
+ });
83
+ });
84
+ // ─── Catalogus (catalog:write) ──────────────────────────────────────────────
85
+ export const publishTradeItem = createServerFn({ method: "POST" })
86
+ .middleware([requireSupabaseAuth])
87
+ .inputValidator((input) => {
88
+ if (!["staging", "live"].includes(input.environment)) {
89
+ throw new Error("Ongeldige environment");
90
+ }
91
+ if (!input.tradeItemId?.trim())
92
+ throw new Error("tradeItemId is verplicht");
93
+ return input;
94
+ })
95
+ .handler(async ({ data, context }) => {
96
+ return florydayWrite(context.supabase, data.environment, {
97
+ module: "catalog",
98
+ action: "publish-trade-item",
99
+ method: "PUT",
100
+ path: `/trade-items/${encodeURIComponent(data.tradeItemId)}`,
101
+ referenceId: data.tradeItemId,
102
+ body: data.payload,
103
+ });
104
+ });
105
+ export const upsertSupplyLine = createServerFn({ method: "POST" })
106
+ .middleware([requireSupabaseAuth])
107
+ .inputValidator((input) => {
108
+ if (!["staging", "live"].includes(input.environment)) {
109
+ throw new Error("Ongeldige environment");
110
+ }
111
+ if (!input.supplyLineId?.trim())
112
+ throw new Error("supplyLineId is verplicht");
113
+ return input;
114
+ })
115
+ .handler(async ({ data, context }) => {
116
+ return florydayWrite(context.supabase, data.environment, {
117
+ module: "catalog",
118
+ action: "upsert-supply-line",
119
+ method: "PUT",
120
+ path: `/supply-lines/${encodeURIComponent(data.supplyLineId)}`,
121
+ referenceId: data.supplyLineId,
122
+ body: data.payload,
123
+ // Pre-flight enum-validatie tegen lokale Floriday code-list-cache.
124
+ // Voorkomt 400-roundtrips bij typo's in valuta/eenheid/locatie.
125
+ validateEnums: [
126
+ { field: "currency", listName: "Currency" },
127
+ { field: "salesUnit", listName: "SalesUnit" },
128
+ { field: "auctionLocation", listName: "AuctionLocation" },
129
+ { field: "supplyType", listName: "SupplyType" },
130
+ { field: "loadCarrierType", listName: "SupplyLoadCarrierType" },
131
+ ],
132
+ });
133
+ });
134
+ /**
135
+ * Generieke schrijf-passthrough voor andere Floriday-modules die hun
136
+ * eigen body en pad opbouwen, maar wél van token-refresh, idempotency,
137
+ * write-log en code-list-validatie willen profiteren.
138
+ */
139
+ export const florydayWriteThrough = createServerFn({ method: "POST" })
140
+ .middleware([requireSupabaseAuth])
141
+ .inputValidator((input) => {
142
+ if (!["staging", "live"].includes(input.environment)) {
143
+ throw new Error("Ongeldige environment");
144
+ }
145
+ if (!input.module || !input.action || !input.method || !input.path) {
146
+ throw new Error("module, action, method en path zijn verplicht");
147
+ }
148
+ return input;
149
+ })
150
+ .handler(async ({ data, context }) => {
151
+ return florydayWrite(context.supabase, data.environment, {
152
+ module: data.module,
153
+ action: data.action,
154
+ method: data.method,
155
+ path: data.path,
156
+ body: data.body,
157
+ referenceId: data.referenceId,
158
+ validateEnums: data.validateEnums,
159
+ });
160
+ });