@flowselections/floriday-authenticatie-module 1.0.53 → 1.0.55

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 (46) hide show
  1. package/dist-lib/components/floriday/FlorydayConnectionPage.d.ts.map +1 -1
  2. package/dist-lib/components/floriday/FlorydayConnectionPage.js +2 -1
  3. package/dist-lib/components/floriday/FlorydayShellRoutesCard.d.ts +2 -0
  4. package/dist-lib/components/floriday/FlorydayShellRoutesCard.d.ts.map +1 -0
  5. package/dist-lib/components/floriday/FlorydayShellRoutesCard.js +22 -0
  6. package/dist-lib/components/settings/FlorydaySettingsCard.d.ts.map +1 -1
  7. package/dist-lib/components/settings/FlorydaySettingsCard.js +26 -48
  8. package/dist-lib/index.js +1 -1
  9. package/dist-lib/integrations/supabase/client.server.d.ts +2 -32082
  10. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  11. package/dist-lib/integrations/supabase/types.d.ts +1418 -6
  12. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  13. package/dist-lib/lib/cron/process-stock-queue.d.ts +44 -5
  14. package/dist-lib/lib/cron/process-stock-queue.d.ts.map +1 -1
  15. package/dist-lib/lib/cron/process-stock-queue.js +167 -96
  16. package/dist-lib/lib/floriday-gln.d.ts +6 -0
  17. package/dist-lib/lib/floriday-gln.d.ts.map +1 -0
  18. package/dist-lib/lib/floriday-gln.js +22 -0
  19. package/dist-lib/lib/floriday-own-config.d.ts +68 -0
  20. package/dist-lib/lib/floriday-own-config.d.ts.map +1 -0
  21. package/dist-lib/lib/floriday-own-config.js +73 -0
  22. package/dist-lib/lib/floriday-scopes.d.ts +7 -0
  23. package/dist-lib/lib/floriday-scopes.d.ts.map +1 -1
  24. package/dist-lib/lib/floriday-scopes.js +34 -0
  25. package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/floriday-sync.functions.js +12 -2
  27. package/dist-lib/lib/floriday.functions.d.ts +49 -12
  28. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  29. package/dist-lib/lib/floriday.functions.js +221 -63
  30. package/dist-lib/lib/gateway/diagnostics.d.ts.map +1 -1
  31. package/dist-lib/lib/gateway/diagnostics.js +12 -0
  32. package/dist-lib/lib/gateway/floriday-get.d.ts +55 -0
  33. package/dist-lib/lib/gateway/floriday-get.d.ts.map +1 -0
  34. package/dist-lib/lib/gateway/floriday-get.js +185 -0
  35. package/dist-lib/lib/gateway/index.d.ts +1 -0
  36. package/dist-lib/lib/gateway/index.d.ts.map +1 -1
  37. package/dist-lib/lib/gateway/index.js +1 -0
  38. package/dist-lib/lib/gateway/webhook-subscribe.d.ts.map +1 -1
  39. package/dist-lib/lib/gateway/webhook-subscribe.js +13 -1
  40. package/dist-lib/lib/shell-base.d.ts +2 -0
  41. package/dist-lib/lib/shell-base.d.ts.map +1 -0
  42. package/dist-lib/lib/shell-base.js +31 -0
  43. package/dist-lib/lib/shell-routes.d.ts +25 -0
  44. package/dist-lib/lib/shell-routes.d.ts.map +1 -0
  45. package/dist-lib/lib/shell-routes.js +127 -0
  46. package/package.json +6 -489
@@ -1 +1 @@
1
- {"version":3,"file":"FlorydayConnectionPage.d.ts","sourceRoot":"","sources":["../../../src/components/floriday/FlorydayConnectionPage.tsx"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB,4CAcrC"}
1
+ {"version":3,"file":"FlorydayConnectionPage.d.ts","sourceRoot":"","sources":["../../../src/components/floriday/FlorydayConnectionPage.tsx"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,4CAerC"}
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { FlorydaySettingsCard } from "../settings/FlorydaySettingsCard.js";
3
3
  import { FloricodeSettingsCard } from "../settings/FloricodeSettingsCard.js";
4
4
  import { FlorydayWebhooksCard } from "./FlorydayWebhooksCard.js";
5
+ import { FlorydayShellRoutesCard } from "./FlorydayShellRoutesCard.js";
5
6
  export function FlorydayConnectionPage() {
6
- return (_jsxs("main", { className: "p-6 max-w-4xl mx-auto space-y-6", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold", children: "Floriday koppeling" }), _jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Verbind je Floriday-account om automatisch gegevens uit te wisselen met het platform." })] }), _jsx(FlorydaySettingsCard, {}), _jsx(FlorydayWebhooksCard, {}), _jsx(FloricodeSettingsCard, {})] }));
7
+ return (_jsxs("main", { className: "p-6 max-w-4xl mx-auto space-y-6", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold", children: "Floriday koppeling" }), _jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Verbind je Floriday-account om automatisch gegevens uit te wisselen met het platform." })] }), _jsx(FlorydaySettingsCard, {}), _jsx(FlorydayWebhooksCard, {}), _jsx(FlorydayShellRoutesCard, {}), _jsx(FloricodeSettingsCard, {})] }));
7
8
  }
@@ -0,0 +1,2 @@
1
+ export declare function FlorydayShellRoutesCard(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=FlorydayShellRoutesCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlorydayShellRoutesCard.d.ts","sourceRoot":"","sources":["../../../src/components/floriday/FlorydayShellRoutesCard.tsx"],"names":[],"mappings":"AAIA,wBAAgB,uBAAuB,4CAoDtC"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3
+ import { useServerFn } from "@tanstack/react-start";
4
+ import { getFlorydayShellRoutesStatus } from "../../lib/floriday.functions.js";
5
+ export function FlorydayShellRoutesCard() {
6
+ const qc = useQueryClient();
7
+ const check = useServerFn(getFlorydayShellRoutesStatus);
8
+ const q = useQuery({ queryKey: ["floriday-shell-routes"], queryFn: () => check({ data: {} }) });
9
+ const recheck = useMutation({
10
+ mutationFn: () => check({ data: { force: true } }),
11
+ onSuccess: (r) => qc.setQueryData(["floriday-shell-routes"], r),
12
+ });
13
+ const r = q.data;
14
+ let badge = { text: "Controleren…", cls: "bg-muted text-muted-foreground" };
15
+ if (r?.error)
16
+ badge = { text: "Kan Shell niet controleren", cls: "bg-destructive/15 text-destructive" };
17
+ else if (r && r.ok)
18
+ badge = { text: "Alle routes aanwezig", cls: "bg-primary/15 text-primary" };
19
+ else if (r)
20
+ badge = { text: `${r.missing.length} route(s) ontbreken`, cls: "bg-destructive/15 text-destructive" };
21
+ return (_jsxs("div", { className: "rounded-lg border p-4 space-y-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("h2", { className: "font-semibold", children: "Bereikbaarheid via de Shell" }), _jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "Andere modules roepen deze koppeling aan via het Shell-adres. Hier zie je of de Shell alle adressen van deze module kent. Dit wordt elk uur en bij een nieuwe koppeling gecontroleerd." })] }), _jsx("span", { className: `text-xs px-2 py-1 rounded whitespace-nowrap ${badge.cls}`, children: badge.text })] }), r?.shellHost && _jsxs("div", { className: "text-xs text-muted-foreground", children: ["Shell: ", r.shellHost] }), r?.error && _jsx("div", { className: "text-sm text-destructive", children: r.error }), r && !r.ok && !r.error && (_jsxs("div", { className: "text-sm space-y-1", children: [_jsx("div", { className: "text-destructive", children: r.advice }), _jsx("ul", { className: "list-disc pl-5 text-xs", children: r.missing.map((p) => (_jsx("li", { children: p }, p))) })] })), _jsxs("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [_jsxs("span", { children: ["Laatst gecontroleerd: ", r?.checkedAt ? new Date(r.checkedAt).toLocaleString("nl-NL") : "—"] }), _jsx("button", { type: "button", className: "underline disabled:opacity-50", disabled: recheck.isPending, onClick: () => recheck.mutate(), children: recheck.isPending ? "Bezig…" : "Nu opnieuw controleren" })] })] }));
22
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"FlorydaySettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/FlorydaySettingsCard.tsx"],"names":[],"mappings":"AA8EA,wBAAgB,oBAAoB,4CAqHnC"}
1
+ {"version":3,"file":"FlorydaySettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/FlorydaySettingsCard.tsx"],"names":[],"mappings":"AA4EA,wBAAgB,oBAAoB,4CAqHnC"}
@@ -5,7 +5,7 @@ import { ChevronDown } from "lucide-react";
5
5
  import { useServerFn } from "@tanstack/react-start";
6
6
  import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
7
7
  import { Card, Button, Input, Label, Badge, Tabs, TabsList, TabsTrigger, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, toast, } from "@flowselections/core";
8
- import { listFlorydayConnections, upsertFlorydayConnection, testFlorydayConnection, deleteFlorydayConnection, getFlorydaySettings, setFlorydayActiveEnvironment, listFlorydayWarehouses, updateFlorydayPublishingSettings, validateGln, syncFlorydayConnections, getFlorydaySyncStatus, getFlorydayShellHostStatus, } from "../../lib/floriday.functions.js";
8
+ import { listFlorydayConnections, upsertFlorydayConnection, testFlorydayConnection, deleteFlorydayConnection, getFlorydaySettings, setFlorydayActiveEnvironment, getFlorydayOwnConfigStatus, updateFlorydayPublishingSettings, syncFlorydayConnections, getFlorydaySyncStatus, getFlorydayShellHostStatus, } from "../../lib/floriday.functions.js";
9
9
  import { syncFlorydayTradeItems, syncFlorydaySalesOrders, syncFlorydayCustomerOrganizations, syncFlorydayCarriers, syncFlorydayFulfillmentOrders, syncFlorydayCustomerStickers, syncFlorydayWarehouses, syncFlorydayPackings, syncFlorydayDeliveryLocations, syncFlorydayClockSupplies, syncFlorydayDeliveryOrders, syncFlorydayClockPresales, syncFlorydayContracts, syncFlorydayBlanketOrders, syncFlorydayAdditionalServices, syncFlorydayCommercialServiceTypes, syncFlorydayCollections, syncFlorydayPriceGroups, syncFlorydayDeliveryConditionSets, syncFlorydaySalesStrategies, syncFlorydayBaseItems, syncFlorydayContractTradeItemGroups, syncFlorydayCatalogPrices, } from "../../lib/floriday-sync.functions.js";
10
10
  import { FlorydayCredentialStatusBanner } from "../floriday/FlorydayCredentialStatusBanner.js";
11
11
  export function FlorydaySettingsCard() {
@@ -109,65 +109,43 @@ function ShellHostStatus() {
109
109
  }
110
110
  function PublishingSettings({ env, connection, }) {
111
111
  const qc = useQueryClient();
112
- const listWarehouses = useServerFn(listFlorydayWarehouses);
112
+ const getStatus = useServerFn(getFlorydayOwnConfigStatus);
113
113
  const updateSettings = useServerFn(updateFlorydayPublishingSettings);
114
- const [gln, setGln] = useState(connection?.gln_code ?? "");
115
- const [warehouseId, setWarehouseId] = useState(connection?.preferred_warehouse_id ?? "");
116
- const warehousesQuery = useQuery({
117
- queryKey: ["floriday-warehouses", env],
118
- queryFn: () => listWarehouses({ data: { environment: env } }),
114
+ const [warehouseId, setWarehouseId] = useState("");
115
+ const statusQuery = useQuery({
116
+ queryKey: ["floriday-own-config", env],
117
+ queryFn: () => getStatus({ data: { environment: env } }),
119
118
  enabled: Boolean(connection),
120
119
  });
121
- const warehouses = warehousesQuery.data?.ok && Array.isArray(warehousesQuery.data.warehouses)
122
- ? warehousesQuery.data.warehouses
123
- : [];
124
- const warehousesError = warehousesQuery.data && !warehousesQuery.data.ok ? warehousesQuery.data.error : null;
125
- // Auto-preselect het default-magazijn van Floriday wanneer de gebruiker
126
- // nog geen keuze heeft gemaakt.
120
+ const status = statusQuery.data;
127
121
  useEffect(() => {
128
- if (warehouseId)
129
- return;
130
- if (!warehouses.length)
131
- return;
132
- const def = warehouses.find((w) => w.isDefault) ?? warehouses[0];
133
- if (def)
134
- setWarehouseId(def.id);
135
- // eslint-disable-next-line react-hooks/exhaustive-deps
136
- }, [warehouses.length]);
122
+ setWarehouseId(status?.preferredWarehouseId ?? "");
123
+ }, [status?.preferredWarehouseId]);
137
124
  const saveMutation = useMutation({
138
- mutationFn: () => {
139
- const selected = warehouses.find((w) => w.id === warehouseId);
140
- return updateSettings({
141
- data: {
142
- environment: env,
143
- gln_code: gln,
144
- preferred_warehouse_id: warehouseId || null,
145
- preferred_warehouse_name: selected?.name ?? null,
146
- },
147
- });
148
- },
125
+ mutationFn: () => updateSettings({ data: { environment: env, preferred_warehouse_id: warehouseId } }),
149
126
  onSuccess: () => {
150
- toast.success("Publicatie-instellingen opgeslagen");
127
+ toast.success("Voorkeursmagazijn opgeslagen");
128
+ qc.invalidateQueries({ queryKey: ["floriday-own-config", env] });
151
129
  qc.invalidateQueries({ queryKey: ["floriday-connections"] });
152
130
  },
153
131
  onError: (e) => toast.error(e?.message ?? "Opslaan mislukt"),
154
132
  });
155
133
  if (!connection) {
156
- return (_jsx("p", { className: "text-xs text-muted-foreground", children: "Sla eerst je verbindingsgegevens op om publicatie-instellingen te beheren." }));
134
+ return (_jsx("p", { className: "text-xs text-muted-foreground", children: "Sla eerst je verbindingsgegevens op om publicatie-instellingen te zien." }));
135
+ }
136
+ if (statusQuery.isLoading) {
137
+ return _jsx("p", { className: "text-xs text-muted-foreground", children: "Gegevens uit Floriday laden\u2026" });
138
+ }
139
+ if (statusQuery.error || !status) {
140
+ return (_jsxs("p", { className: "text-[11px] text-destructive", children: ["Publicatie-instellingen niet beschikbaar: ", String(statusQuery.error?.message ?? "onbekende fout")] }));
157
141
  }
158
- const glnError = gln.trim() ? validateGln(gln) : null;
159
- return (_jsxs("div", { className: "rounded-lg border border-border/60 bg-card p-4 space-y-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: `${env}-gln`, className: "text-xs", children: "GLN-code organisatie" }), _jsx(Input, { id: `${env}-gln`, value: gln, onChange: (e) => setGln(e.target.value.replace(/\s+/g, "")), placeholder: "Bijv. 8712345000005", inputMode: "numeric", maxLength: 13, autoComplete: "off", "aria-invalid": Boolean(glnError) }), glnError ? (_jsx("p", { className: "text-[11px] text-red-600", children: glnError })) : (_jsx("p", { className: "text-[11px] text-muted-foreground", children: "De Global Location Number van je organisatie in Floriday (13 cijfers)." }))] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: `${env}-warehouse`, className: "text-xs", children: "Voorkeursmagazijn" }), _jsxs(Select, { value: warehouseId || undefined, onValueChange: setWarehouseId, children: [_jsx(SelectTrigger, { id: `${env}-warehouse`, children: _jsx(SelectValue, { placeholder: warehousesQuery.isLoading
160
- ? "Magazijnen laden…"
161
- : warehouses.length === 0
162
- ? "Geen magazijnen beschikbaar"
163
- : "Kies een magazijn", children: (() => {
164
- const selected = warehouses.find((w) => w.id === warehouseId);
165
- if (!selected)
166
- return null;
167
- return (_jsxs("span", { className: "flex items-baseline gap-2 truncate", children: [_jsx("span", { className: "truncate", children: selected.name }), selected.gln && (_jsx("span", { className: "text-[11px] text-muted-foreground font-mono", children: selected.gln }))] }));
168
- })() }) }), _jsx(SelectContent, { children: warehouses.map((w) => (_jsx(SelectItem, { value: w.id, children: _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { children: w.name }), w.gln && (_jsx("span", { className: "text-[11px] text-muted-foreground font-mono", children: w.gln }))] }) }, w.id))) })] }), _jsx("p", { className: "text-[11px] text-muted-foreground", children: "Alleen magazijnen die in Floriday aan je organisatie gekoppeld zijn." }), warehousesError && (_jsxs("p", { className: "text-[11px] text-red-600", children: ["Magazijnen niet beschikbaar: ", warehousesError] }))] }), _jsx("div", { children: _jsx(Button, { size: "sm", onClick: () => saveMutation.mutate(), disabled: saveMutation.isPending ||
169
- Boolean(glnError) ||
170
- (!gln.trim() && !warehouseId), children: saveMutation.isPending ? "Opslaan…" : "Instellingen opslaan" }) })] }));
142
+ const gln = status.gln;
143
+ const wh = status.warehouse;
144
+ const own = status.ownWarehouses;
145
+ const showChoice = own.length > 1 || wh?.kind === "missing" || wh?.kind === "choice_needed";
146
+ const dirty = Boolean(warehouseId) && warehouseId !== (status.preferredWarehouseId ?? "");
147
+ const current = own.find((w) => w.id === status.preferredWarehouseId);
148
+ return (_jsxs("div", { className: "rounded-lg border border-border/60 bg-card p-4 space-y-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { className: "text-xs", children: "GLN-code organisatie" }), _jsx("p", { className: "font-mono text-sm", children: status.storedGln ?? "—" }), _jsx("p", { className: "text-[11px] text-muted-foreground", children: "Automatisch uit Floriday." }), gln?.kind === "mismatch" && (_jsxs("p", { className: "text-[11px] text-destructive", children: ["GLN in Floriday (", gln.fromFloriday, ") wijkt af van de opgeslagen GLN (", gln.stored, "); waarschijnlijk is er met een ander account gekoppeld. De opgeslagen waarde is niet overschreven."] })), gln?.kind === "unavailable" && (_jsx("p", { className: "text-[11px] text-muted-foreground", children: "GLN niet beschikbaar in Floriday." })), gln?.kind === "invalid" && (_jsxs("p", { className: "text-[11px] text-destructive", children: ["De GLN in Floriday (", gln.fromFloriday, ") is ongeldig en is niet opgeslagen: ", gln.error] }))] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: `${env}-warehouse`, className: "text-xs", children: "Voorkeursmagazijn" }), wh?.kind === "none" ? (_jsx("p", { className: "text-[11px] text-destructive", children: "Er zijn geen eigen magazijnen in Floriday voor deze koppeling." })) : !showChoice ? (_jsxs("p", { className: "text-sm", children: [current?.name ?? status.preferredWarehouseName ?? "—", current?.gln && (_jsx("span", { className: "ml-2 text-[11px] text-muted-foreground font-mono", children: current.gln }))] })) : (_jsxs(Select, { value: warehouseId || undefined, onValueChange: setWarehouseId, children: [_jsx(SelectTrigger, { id: `${env}-warehouse`, children: _jsx(SelectValue, { placeholder: "Kies een magazijn" }) }), _jsx(SelectContent, { children: own.map((w) => (_jsx(SelectItem, { value: w.id, children: _jsxs("div", { className: "flex flex-col", children: [_jsxs("span", { children: [w.name, w.isDefault ? " (standaard in Floriday)" : ""] }), w.gln && (_jsx("span", { className: "text-[11px] text-muted-foreground font-mono", children: w.gln }))] }) }, w.id))) })] })), wh?.kind === "fill" && wh.reason === "single" && (_jsx("p", { className: "text-[11px] text-muted-foreground", children: "Automatisch: het enige eigen magazijn." })), wh?.kind === "fill" && wh.reason === "default" && (_jsx("p", { className: "text-[11px] text-muted-foreground", children: "Automatisch: standaardmagazijn in Floriday." })), wh?.kind === "choice_needed" && (_jsx("p", { className: "text-[11px] text-destructive", children: "Keuze nodig: er zijn meerdere eigen magazijnen." })), wh?.kind === "missing" && (_jsx("p", { className: "text-[11px] text-destructive", children: "Gekozen magazijn niet meer beschikbaar in Floriday, kies opnieuw." }))] }), showChoice && dirty && (_jsx("div", { children: _jsx(Button, { size: "sm", onClick: () => saveMutation.mutate(), disabled: saveMutation.isPending, children: saveMutation.isPending ? "Opslaan…" : "Instellingen opslaan" }) }))] }));
171
149
  }
172
150
  function formatRelative(iso) {
173
151
  if (!iso)
package/dist-lib/index.js CHANGED
@@ -27,7 +27,7 @@ export const floridayAuthenticatieModule = {
27
27
  },
28
28
  {
29
29
  label: "Logboek",
30
- href: "/floriday-logboek",
30
+ href: "/floriday-connection/logboek",
31
31
  icon: ScrollText,
32
32
  },
33
33
  ],