@flowselections/floriday-klanten-module 1.0.35 → 1.0.36

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 (73) hide show
  1. package/dist-lib/components/klanten/BewerkKlant.d.ts.map +1 -1
  2. package/dist-lib/components/klanten/BewerkKlant.js +21 -1
  3. package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts +14 -0
  4. package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts.map +1 -0
  5. package/dist-lib/components/klanten/BulkStickerUploadDialog.js +231 -0
  6. package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts.map +1 -1
  7. package/dist-lib/components/klanten/CustomerAssortmentTab.js +37 -5
  8. package/dist-lib/components/klanten/CustomerStickerCell.d.ts +7 -0
  9. package/dist-lib/components/klanten/CustomerStickerCell.d.ts.map +1 -0
  10. package/dist-lib/components/klanten/CustomerStickerCell.js +90 -0
  11. package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts +7 -0
  12. package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts.map +1 -0
  13. package/dist-lib/components/klanten/CustomerStickerFormatDialog.js +36 -0
  14. package/dist-lib/index.d.ts +4 -0
  15. package/dist-lib/index.d.ts.map +1 -1
  16. package/dist-lib/index.js +4 -0
  17. package/dist-lib/integrations/supabase/auth-middleware.d.ts +565 -0
  18. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  19. package/dist-lib/integrations/supabase/client.d.ts +565 -0
  20. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  21. package/dist-lib/integrations/supabase/client.server.d.ts +565 -0
  22. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  23. package/dist-lib/integrations/supabase/types.d.ts +568 -0
  24. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  25. package/dist-lib/lib/accounting/twinfield/worker.functions.d.ts +1695 -0
  26. package/dist-lib/lib/accounting/twinfield/worker.functions.d.ts.map +1 -1
  27. package/dist-lib/lib/accounting.functions.d.ts +1695 -0
  28. package/dist-lib/lib/accounting.functions.d.ts.map +1 -1
  29. package/dist-lib/lib/ai-module.server.d.ts +20 -0
  30. package/dist-lib/lib/ai-module.server.d.ts.map +1 -0
  31. package/dist-lib/lib/ai-module.server.js +86 -0
  32. package/dist-lib/lib/customer-analytics.functions.d.ts +565 -0
  33. package/dist-lib/lib/customer-analytics.functions.d.ts.map +1 -1
  34. package/dist-lib/lib/customer-assortment.functions.d.ts +565 -0
  35. package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -1
  36. package/dist-lib/lib/customer-notes.functions.d.ts +1130 -0
  37. package/dist-lib/lib/customer-notes.functions.d.ts.map +1 -1
  38. package/dist-lib/lib/customer-revenue.functions.d.ts +565 -0
  39. package/dist-lib/lib/customer-revenue.functions.d.ts.map +1 -1
  40. package/dist-lib/lib/customer-stickers.functions.d.ts +244731 -0
  41. package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -0
  42. package/dist-lib/lib/customer-stickers.functions.js +467 -0
  43. package/dist-lib/lib/customers.functions.d.ts +5085 -0
  44. package/dist-lib/lib/customers.functions.d.ts.map +1 -1
  45. package/dist-lib/lib/delivery-locations.functions.d.ts +2825 -0
  46. package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
  47. package/dist-lib/lib/external-customers.functions.d.ts +2260 -0
  48. package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
  49. package/dist-lib/lib/floriday-assortment.functions.d.ts +565 -0
  50. package/dist-lib/lib/floriday-assortment.functions.d.ts.map +1 -1
  51. package/dist-lib/lib/floriday-discounts.functions.d.ts +1130 -0
  52. package/dist-lib/lib/floriday-discounts.functions.d.ts.map +1 -1
  53. package/dist-lib/lib/floriday-price-import.functions.d.ts +1130 -0
  54. package/dist-lib/lib/floriday-price-import.functions.d.ts.map +1 -1
  55. package/dist-lib/lib/floriday-trade-items.functions.d.ts +565 -0
  56. package/dist-lib/lib/floriday-trade-items.functions.d.ts.map +1 -1
  57. package/dist-lib/lib/local-discounts.functions.d.ts +3956 -1
  58. package/dist-lib/lib/local-discounts.functions.d.ts.map +1 -1
  59. package/dist-lib/lib/logistics-events.functions.d.ts +565 -0
  60. package/dist-lib/lib/logistics-events.functions.d.ts.map +1 -1
  61. package/dist-lib/lib/logistics-strategy.functions.d.ts +2260 -0
  62. package/dist-lib/lib/logistics-strategy.functions.d.ts.map +1 -1
  63. package/dist-lib/lib/overdue-invoices.functions.d.ts +565 -0
  64. package/dist-lib/lib/overdue-invoices.functions.d.ts.map +1 -1
  65. package/dist-lib/lib/price-groups-local.functions.d.ts +7348 -3
  66. package/dist-lib/lib/price-groups-local.functions.d.ts.map +1 -1
  67. package/dist-lib/lib/price-groups.functions.d.ts +565 -0
  68. package/dist-lib/lib/price-groups.functions.d.ts.map +1 -1
  69. package/dist-lib/lib/twinfield-adopt.functions.d.ts +1130 -0
  70. package/dist-lib/lib/twinfield-adopt.functions.d.ts.map +1 -1
  71. package/dist-lib/lib/twinfield-ledger.functions.d.ts +565 -0
  72. package/dist-lib/lib/twinfield-ledger.functions.d.ts.map +1 -1
  73. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ export type ResolvedAiModel = {
2
+ providerSlug: string;
3
+ baseUrl: string;
4
+ modelSlug: string;
5
+ apiKey: string;
6
+ };
7
+ export declare class AiModuleError extends Error {
8
+ }
9
+ export declare function resolveModuleModel(moduleKey: string): Promise<ResolvedAiModel>;
10
+ export declare function logAiCall(entry: {
11
+ moduleKey: string;
12
+ providerSlug: string;
13
+ modelSlug: string;
14
+ status: string;
15
+ durationMs?: number | null;
16
+ errorCode?: string | null;
17
+ errorMessage?: string | null;
18
+ createdBy?: string | null;
19
+ }): Promise<void>;
20
+ //# sourceMappingURL=ai-module.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-module.server.d.ts","sourceRoot":"","sources":["../../src/lib/ai-module.server.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK;CAAG;AAE3C,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAsEpF;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,iBAeA"}
@@ -0,0 +1,86 @@
1
+ // Server-only: haalt provider, model en API-sleutel op bij de AI-authenticatiemodule.
2
+ // De sleutel verlaat de server nooit.
3
+ import { supabaseAdmin } from "../integrations/supabase/client.server";
4
+ export class AiModuleError extends Error {
5
+ }
6
+ export async function resolveModuleModel(moduleKey) {
7
+ const sb = supabaseAdmin;
8
+ const { data: mod, error: modErr } = await sb
9
+ .from("ai_modules")
10
+ .select("ai_enabled")
11
+ .eq("module_key", moduleKey)
12
+ .maybeSingle();
13
+ if (modErr)
14
+ throw new AiModuleError(modErr.message);
15
+ if (!mod) {
16
+ throw new AiModuleError("Deze module is nog niet aangemeld bij AI-authenticatie. Meld hem daar aan.");
17
+ }
18
+ if (mod.ai_enabled === false) {
19
+ throw new AiModuleError("AI staat uit voor deze module — zet dit aan bij AI-authenticatie.");
20
+ }
21
+ const { data: binding, error: bindErr } = await sb
22
+ .from("ai_module_bindings")
23
+ .select("model_id, credential_id, is_default")
24
+ .eq("consumer_module_id", moduleKey)
25
+ .order("is_default", { ascending: false })
26
+ .limit(1)
27
+ .maybeSingle();
28
+ if (bindErr)
29
+ throw new AiModuleError(bindErr.message);
30
+ if (!binding?.model_id || !binding?.credential_id) {
31
+ throw new AiModuleError("Er is nog geen AI-model gekoppeld aan deze module. Stel dit in bij AI-authenticatie.");
32
+ }
33
+ const { data: model, error: modelErr } = await sb
34
+ .from("ai_models")
35
+ .select("slug, active, provider_id")
36
+ .eq("id", binding.model_id)
37
+ .maybeSingle();
38
+ if (modelErr)
39
+ throw new AiModuleError(modelErr.message);
40
+ if (!model?.slug || model.active === false) {
41
+ throw new AiModuleError("Het gekoppelde AI-model is niet actief. Kies er een bij AI-authenticatie.");
42
+ }
43
+ const { data: provider, error: provErr } = await sb
44
+ .from("ai_providers")
45
+ .select("slug, base_url, active")
46
+ .eq("id", model.provider_id)
47
+ .maybeSingle();
48
+ if (provErr)
49
+ throw new AiModuleError(provErr.message);
50
+ if (!provider?.base_url || provider.active === false) {
51
+ throw new AiModuleError("De AI-aanbieder is niet actief. Controleer dit bij AI-authenticatie.");
52
+ }
53
+ const { data: cred, error: credErr } = await sb
54
+ .from("ai_credentials")
55
+ .select("api_key, active")
56
+ .eq("id", binding.credential_id)
57
+ .maybeSingle();
58
+ if (credErr)
59
+ throw new AiModuleError(credErr.message);
60
+ if (!cred?.api_key || cred.active === false) {
61
+ throw new AiModuleError("Er is geen actieve AI-sleutel gekoppeld. Voeg die toe bij AI-authenticatie.");
62
+ }
63
+ return {
64
+ providerSlug: String(provider.slug),
65
+ baseUrl: String(provider.base_url).replace(/\/+$/, ""),
66
+ modelSlug: String(model.slug),
67
+ apiKey: String(cred.api_key),
68
+ };
69
+ }
70
+ export async function logAiCall(entry) {
71
+ try {
72
+ await supabaseAdmin.from("ai_call_log").insert({
73
+ consumer_module_id: entry.moduleKey,
74
+ provider_slug: entry.providerSlug,
75
+ model_slug: entry.modelSlug,
76
+ status: entry.status,
77
+ duration_ms: entry.durationMs ?? null,
78
+ error_code: entry.errorCode ?? null,
79
+ error_message: entry.errorMessage ?? null,
80
+ created_by: entry.createdBy ?? null,
81
+ });
82
+ }
83
+ catch {
84
+ // logging mag de functionaliteit nooit blokkeren
85
+ }
86
+ }