@flowselections/mailbox-orders 1.0.27 → 1.0.28
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.
- package/dist-lib/components/MailboxProcessedPage.js +4 -4
- package/dist-lib/components/MailboxProposalsPage.js +10 -10
- package/dist-lib/components/settings/MailboxAiPromptCard.js +2 -2
- package/dist-lib/components/settings/MailboxOrderTemplateCard.js +1 -1
- package/dist-lib/index.d.ts +7 -7
- package/dist-lib/index.js +9 -9
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +1 -1
- package/dist-lib/integrations/supabase/auth-middleware.js +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +346 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/ai-config.server.d.ts +1 -1
- package/dist-lib/lib/mailbox-ai-settings.functions.d.ts +2 -2
- package/dist-lib/lib/mailbox-ai-settings.functions.js +2 -2
- package/dist-lib/lib/mailbox-ai.server.d.ts +2 -2
- package/dist-lib/lib/mailbox-ai.server.js +3 -3
- package/dist-lib/lib/mailbox-ingest.server.d.ts +2 -2
- package/dist-lib/lib/mailbox-ingest.server.js +8 -8
- package/dist-lib/lib/mailbox-template.functions.d.ts +8 -8
- package/dist-lib/lib/mailbox-template.functions.js +1 -1
- package/dist-lib/lib/mailbox.functions.d.ts +26 -26
- package/dist-lib/lib/mailbox.functions.js +24 -24
- package/package.json +2 -2
- package/dist-lib/components/CartAssignmentWizard.d.ts +0 -6
- package/dist-lib/components/CartAssignmentWizard.d.ts.map +0 -1
- package/dist-lib/components/CartAssignmentWizard.js +0 -199
- package/dist-lib/components/MailboxInboxPage.d.ts +0 -2
- package/dist-lib/components/MailboxInboxPage.d.ts.map +0 -1
- package/dist-lib/components/MailboxInboxPage.js +0 -120
- package/dist-lib/components/settings/ImapAccountsCard.d.ts +0 -2
- package/dist-lib/components/settings/ImapAccountsCard.d.ts.map +0 -1
- package/dist-lib/components/settings/ImapAccountsCard.js +0 -136
- package/dist-lib/components/settings/ImapProfilesCard.d.ts +0 -2
- package/dist-lib/components/settings/ImapProfilesCard.d.ts.map +0 -1
- package/dist-lib/components/settings/ImapProfilesCard.js +0 -101
- package/dist-lib/components/settings/MailboxSettingsCard.d.ts +0 -2
- package/dist-lib/components/settings/MailboxSettingsCard.d.ts.map +0 -1
- package/dist-lib/components/settings/MailboxSettingsCard.js +0 -85
- package/dist-lib/lib/imap.functions.d.ts +0 -32852
- package/dist-lib/lib/imap.functions.d.ts.map +0 -1
- package/dist-lib/lib/imap.functions.js +0 -235
- package/dist-lib/lib/mailbox-auto.server.d.ts +0 -9
- package/dist-lib/lib/mailbox-auto.server.d.ts.map +0 -1
- package/dist-lib/lib/mailbox-auto.server.js +0 -198
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import type { Database } from "../integrations/supabase/types";
|
|
2
|
+
import type { Database } from "../integrations/supabase/types.js";
|
|
3
3
|
type AdminClient = SupabaseClient<Database>;
|
|
4
4
|
export interface ModuleAiConfig {
|
|
5
5
|
moduleKey: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const getMailboxAiSettings: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
2
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
2
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
3
3
|
userId: string;
|
|
4
4
|
claims: import("@supabase/auth-js").User;
|
|
5
5
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -10,7 +10,7 @@ export declare const getMailboxAiSettings: import("@tanstack/start-client-core")
|
|
|
10
10
|
default_prompt: string;
|
|
11
11
|
}>>;
|
|
12
12
|
export declare const saveMailboxAiSettings: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
13
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
13
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
14
14
|
userId: string;
|
|
15
15
|
claims: import("@supabase/auth-js").User;
|
|
16
16
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Beheer van de centrale systeemprompt en verplichte velden voor de mailbox-AI.
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
3
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { DEFAULT_MAILBOX_SYSTEM_PROMPT, DEFAULT_REQUIRED_FIELDS } from "./mailbox-ai-prompt";
|
|
5
|
+
import { DEFAULT_MAILBOX_SYSTEM_PROMPT, DEFAULT_REQUIRED_FIELDS } from "./mailbox-ai-prompt.js";
|
|
6
6
|
export const getMailboxAiSettings = createServerFn({ method: "GET" })
|
|
7
7
|
.middleware([requireSupabaseAuth])
|
|
8
8
|
.handler(async ({ context }) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import type { Database } from "../integrations/supabase/types";
|
|
3
|
-
import { DEFAULT_MAILBOX_SYSTEM_PROMPT } from "./mailbox-ai-prompt";
|
|
2
|
+
import type { Database } from "../integrations/supabase/types.js";
|
|
3
|
+
import { DEFAULT_MAILBOX_SYSTEM_PROMPT } from "./mailbox-ai-prompt.js";
|
|
4
4
|
export { DEFAULT_MAILBOX_SYSTEM_PROMPT };
|
|
5
5
|
type AdminClient = SupabaseClient<Database>;
|
|
6
6
|
export declare const MAILBOX_AI_MODULE_KEY = "mailbox-bestellingen";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// AI-parsing van bestelmails. De provider, het model en de API-sleutel komen
|
|
2
2
|
// uit de centrale AI-Authenticatie module (zie ai-config.server.ts).
|
|
3
3
|
// Er wordt GEEN gebruik gemaakt van Lovable AI / de Lovable AI Gateway.
|
|
4
|
-
import { resolveModuleAi, logAiCall } from "./ai-config.server";
|
|
5
|
-
import { DEFAULT_MAILBOX_SYSTEM_PROMPT } from "./mailbox-ai-prompt";
|
|
4
|
+
import { resolveModuleAi, logAiCall } from "./ai-config.server.js";
|
|
5
|
+
import { DEFAULT_MAILBOX_SYSTEM_PROMPT } from "./mailbox-ai-prompt.js";
|
|
6
6
|
export { DEFAULT_MAILBOX_SYSTEM_PROMPT };
|
|
7
7
|
export const MAILBOX_AI_MODULE_KEY = "mailbox-bestellingen";
|
|
8
8
|
/** Huidige vingerafdruk van de gekoppelde AI-agent, of null als AI niet beschikbaar is. */
|
|
@@ -261,7 +261,7 @@ export class AiUnavailableError extends Error {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
export async function parseOrderEmail(admin, args) {
|
|
264
|
-
const { resolveModuleAiAll } = await import("./ai-config.server");
|
|
264
|
+
const { resolveModuleAiAll } = await import("./ai-config.server.js");
|
|
265
265
|
const resolution = await resolveModuleAiAll(admin, MAILBOX_AI_MODULE_KEY);
|
|
266
266
|
if (!resolution.ok)
|
|
267
267
|
throw new AiUnavailableError(resolution.reason, false, 0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import type { Database } from "../integrations/supabase/types";
|
|
2
|
+
import type { Database } from "../integrations/supabase/types.js";
|
|
3
3
|
type AdminClient = SupabaseClient<Database>;
|
|
4
4
|
/** Centrale AI-instellingen van deze module (aanpasbaar via Instellingen). */
|
|
5
5
|
export declare function loadMailboxAiSettings(admin: AdminClient): Promise<{
|
|
@@ -11,7 +11,7 @@ export declare function loadMailboxAiSettings(admin: AdminClient): Promise<{
|
|
|
11
11
|
* verplichte velden. Ontbrekende of onzekere gegevens worden expliciet
|
|
12
12
|
* benoemd in plaats van stilzwijgend leeg gelaten.
|
|
13
13
|
*/
|
|
14
|
-
export declare function computeValidation(parsed: import("./mailbox-ai.server").ParsedOrder, requiredFields: string[], extra: {
|
|
14
|
+
export declare function computeValidation(parsed: import("./mailbox-ai.server.js").ParsedOrder, requiredFields: string[], extra: {
|
|
15
15
|
customerId: string | null;
|
|
16
16
|
}): {
|
|
17
17
|
missing: string[];
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// GEEN imports van "@/integrations/supabase/client.server" op module-scope —
|
|
9
9
|
// die worden per aanroep dynamisch geladen (client-reachable modules mogen
|
|
10
10
|
// server-only helpers niet direct binnenhalen).
|
|
11
|
-
import { emailBodyText } from "./mailbox-body";
|
|
12
|
-
import { detectLoadCarrierInText, isLoadCarrierAllowed, loadCarrierLabel, normalizeAllowedLoadCarriers, } from "./load-carriers";
|
|
11
|
+
import { emailBodyText } from "./mailbox-body.js";
|
|
12
|
+
import { detectLoadCarrierInText, isLoadCarrierAllowed, loadCarrierLabel, normalizeAllowedLoadCarriers, } from "./load-carriers.js";
|
|
13
13
|
/**
|
|
14
14
|
* Ladingdragers komen live uit de Logistics Engine — nooit cachen, nooit een
|
|
15
15
|
* eigen lijst bijhouden.
|
|
@@ -216,7 +216,7 @@ async function aiParseMessage(admin, messageId, customerId) {
|
|
|
216
216
|
if (!bodyText.trim())
|
|
217
217
|
throw new Error("Bericht bevat geen tekst om te lezen.");
|
|
218
218
|
const ctx = await buildAiContext(admin, customerId);
|
|
219
|
-
const { parseOrderEmail } = await import("./mailbox-ai.server");
|
|
219
|
+
const { parseOrderEmail } = await import("./mailbox-ai.server.js");
|
|
220
220
|
const res = await parseOrderEmail(admin, {
|
|
221
221
|
bodyText,
|
|
222
222
|
subject: msg?.subject ?? "",
|
|
@@ -231,7 +231,7 @@ async function aiParseMessage(admin, messageId, customerId) {
|
|
|
231
231
|
}
|
|
232
232
|
catch (e) {
|
|
233
233
|
const msg = String(e?.message ?? e);
|
|
234
|
-
const { isTransientAiError } = await import("./mailbox-ai.server");
|
|
234
|
+
const { isTransientAiError } = await import("./mailbox-ai.server.js");
|
|
235
235
|
const transient = e?.name === "AiUnavailableError" ? Boolean(e.transient) : isTransientAiError(msg);
|
|
236
236
|
return { parsed: null, meta: null, error: msg.slice(0, 500), transient, requiredFields: [] };
|
|
237
237
|
}
|
|
@@ -426,7 +426,7 @@ export async function createStubProposal(admin, messageId, fromEmail) {
|
|
|
426
426
|
auto_match_candidates: matchResult.candidates,
|
|
427
427
|
};
|
|
428
428
|
// --- AI-parse (best effort) ---------------------------------------------
|
|
429
|
-
const { currentAiFingerprint } = await import("./mailbox-ai.server");
|
|
429
|
+
const { currentAiFingerprint } = await import("./mailbox-ai.server.js");
|
|
430
430
|
const fingerprint = await currentAiFingerprint(admin).catch(() => null);
|
|
431
431
|
const attempt = await aiParseMessage(admin, messageId, matchResult.customerId);
|
|
432
432
|
const parsed = attempt.parsed;
|
|
@@ -557,7 +557,7 @@ export async function reparseProposal(admin, proposalId) {
|
|
|
557
557
|
const rematch = matchedCustomerId ? null : await matchCustomerByEmail(admin, senderEmail);
|
|
558
558
|
if (rematch?.customerId)
|
|
559
559
|
matchedCustomerId = rematch.customerId;
|
|
560
|
-
const { currentAiFingerprint } = await import("./mailbox-ai.server");
|
|
560
|
+
const { currentAiFingerprint } = await import("./mailbox-ai.server.js");
|
|
561
561
|
const fingerprint = await currentAiFingerprint(admin).catch(() => null);
|
|
562
562
|
const attempt = await aiParseMessage(admin, prop.message_id, matchedCustomerId);
|
|
563
563
|
const prevBase = (prop.parsed_payload && typeof prop.parsed_payload === "object" ? prop.parsed_payload : {});
|
|
@@ -663,7 +663,7 @@ export async function reparseProposal(admin, proposalId) {
|
|
|
663
663
|
* opgeslagen vingerafdruk afwijkt van de huidige worden opnieuw geanalyseerd.
|
|
664
664
|
*/
|
|
665
665
|
export async function reparseChangedAgentProposals(admin, limit = 25) {
|
|
666
|
-
const { currentAiFingerprint } = await import("./mailbox-ai.server");
|
|
666
|
+
const { currentAiFingerprint } = await import("./mailbox-ai.server.js");
|
|
667
667
|
const fingerprint = await currentAiFingerprint(admin).catch(() => null);
|
|
668
668
|
if (!fingerprint)
|
|
669
669
|
return { checked: 0, reparsed: 0, failed: 0, fingerprint: null };
|
|
@@ -799,7 +799,7 @@ async function ingestSingleEvent(admin, connectionId, ev) {
|
|
|
799
799
|
}
|
|
800
800
|
// De volledige pipeline. Alle triggers roepen dit aan.
|
|
801
801
|
export async function runIngest(trigger) {
|
|
802
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
802
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
803
803
|
// 1. Actieve orders/receive connectie ophalen (service_role → geen bearer nodig).
|
|
804
804
|
const { data: active, error: activeErr } = await supabaseAdmin.rpc("email_auth_for_purpose", {
|
|
805
805
|
_purpose: "orders",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const listTemplateFields: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
2
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
2
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
3
3
|
userId: string;
|
|
4
4
|
claims: import("@supabase/auth-js").User;
|
|
5
5
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -7,12 +7,12 @@ export declare const listTemplateFields: import("@tanstack/start-client-core").O
|
|
|
7
7
|
ai_enabled: boolean;
|
|
8
8
|
ai_hint: string | null;
|
|
9
9
|
created_at: string;
|
|
10
|
-
default_value: import("../integrations/supabase/types").Json | null;
|
|
10
|
+
default_value: import("../integrations/supabase/types.js").Json | null;
|
|
11
11
|
field_type: string;
|
|
12
12
|
id: string;
|
|
13
13
|
key: string;
|
|
14
14
|
label: string;
|
|
15
|
-
options: import("../integrations/supabase/types").Json | null;
|
|
15
|
+
options: import("../integrations/supabase/types.js").Json | null;
|
|
16
16
|
required: boolean;
|
|
17
17
|
sort_order: number;
|
|
18
18
|
source: string;
|
|
@@ -22,7 +22,7 @@ export declare const listTemplateFields: import("@tanstack/start-client-core").O
|
|
|
22
22
|
}[];
|
|
23
23
|
}>>;
|
|
24
24
|
export declare const upsertTemplateField: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
25
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
25
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
26
26
|
userId: string;
|
|
27
27
|
claims: import("@supabase/auth-js").User;
|
|
28
28
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -47,7 +47,7 @@ export declare const upsertTemplateField: import("@tanstack/start-client-core").
|
|
|
47
47
|
id: string;
|
|
48
48
|
}>>;
|
|
49
49
|
export declare const deleteTemplateField: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
50
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
50
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
51
51
|
userId: string;
|
|
52
52
|
claims: import("@supabase/auth-js").User;
|
|
53
53
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -56,7 +56,7 @@ export declare const deleteTemplateField: import("@tanstack/start-client-core").
|
|
|
56
56
|
ok: true;
|
|
57
57
|
}>>;
|
|
58
58
|
export declare const reorderTemplateFields: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
59
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
59
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
60
60
|
userId: string;
|
|
61
61
|
claims: import("@supabase/auth-js").User;
|
|
62
62
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -65,7 +65,7 @@ export declare const reorderTemplateFields: import("@tanstack/start-client-core"
|
|
|
65
65
|
ok: true;
|
|
66
66
|
}>>;
|
|
67
67
|
export declare const listPlantTypesForPicker: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
68
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
68
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
69
69
|
userId: string;
|
|
70
70
|
claims: import("@supabase/auth-js").User;
|
|
71
71
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -75,7 +75,7 @@ export declare const listPlantTypesForPicker: import("@tanstack/start-client-cor
|
|
|
75
75
|
}[];
|
|
76
76
|
}>>;
|
|
77
77
|
export declare const listSuppliersForPicker: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
78
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
78
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
79
79
|
userId: string;
|
|
80
80
|
claims: import("@supabase/auth-js").User;
|
|
81
81
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// CRUD voor de configureerbare ordertemplate.
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
3
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
const FieldType = z.enum([
|
|
6
6
|
"text", "number", "date", "select", "multiselect",
|
|
@@ -34,7 +34,7 @@ export declare const getActiveOrdersMailbox: import("@tanstack/start-client-core
|
|
|
34
34
|
}>>;
|
|
35
35
|
export declare const syncMailboxNow: import("@tanstack/start-client-core").OptionalFetcher<undefined, (input: unknown) => {
|
|
36
36
|
trigger: "realtime" | "manual";
|
|
37
|
-
}, Promise<import("
|
|
37
|
+
}, Promise<import("./mailbox-ingest.server.js").IngestRunResult | {
|
|
38
38
|
ok: false;
|
|
39
39
|
error: string;
|
|
40
40
|
processed: 0;
|
|
@@ -42,7 +42,7 @@ export declare const syncMailboxNow: import("@tanstack/start-client-core").Optio
|
|
|
42
42
|
errors: 1;
|
|
43
43
|
}>>;
|
|
44
44
|
export declare const getLastIngestRun: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
45
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
45
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
46
46
|
userId: string;
|
|
47
47
|
claims: import("@supabase/auth-js").User;
|
|
48
48
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -59,7 +59,7 @@ export declare const getLastIngestRun: import("@tanstack/start-client-core").Opt
|
|
|
59
59
|
}>>;
|
|
60
60
|
/** Handmatig één voorstel opnieuw laten analyseren met de huidige AI-agent. */
|
|
61
61
|
export declare const reparseProposalNow: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
62
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
62
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
63
63
|
userId: string;
|
|
64
64
|
claims: import("@supabase/auth-js").User;
|
|
65
65
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -70,7 +70,7 @@ export declare const reparseProposalNow: import("@tanstack/start-client-core").O
|
|
|
70
70
|
}>>;
|
|
71
71
|
/** Detecteert een gewijzigde AI-agent en herverwerkt openstaande voorstellen. */
|
|
72
72
|
export declare const refreshProposalsForAgentChange: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
73
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
73
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
74
74
|
userId: string;
|
|
75
75
|
claims: import("@supabase/auth-js").User;
|
|
76
76
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -80,7 +80,7 @@ export declare const refreshProposalsForAgentChange: import("@tanstack/start-cli
|
|
|
80
80
|
fingerprint: string | null;
|
|
81
81
|
}>>;
|
|
82
82
|
export declare const listMessages: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
83
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
83
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
84
84
|
userId: string;
|
|
85
85
|
claims: import("@supabase/auth-js").User;
|
|
86
86
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -97,7 +97,7 @@ export declare const listMessages: import("@tanstack/start-client-core").Optiona
|
|
|
97
97
|
}[];
|
|
98
98
|
}>>;
|
|
99
99
|
export declare const parseMessage: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
100
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
100
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
101
101
|
userId: string;
|
|
102
102
|
claims: import("@supabase/auth-js").User;
|
|
103
103
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -106,7 +106,7 @@ export declare const parseMessage: import("@tanstack/start-client-core").Optiona
|
|
|
106
106
|
ok: true;
|
|
107
107
|
}>>;
|
|
108
108
|
export declare const listProposals: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
109
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
109
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
110
110
|
userId: string;
|
|
111
111
|
claims: import("@supabase/auth-js").User;
|
|
112
112
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -116,7 +116,7 @@ export declare const listProposals: import("@tanstack/start-client-core").Option
|
|
|
116
116
|
}>>;
|
|
117
117
|
/** Eén voorstel volledig: mailtekst, bestelregels en veldwaarden. */
|
|
118
118
|
export declare const getProposalDetail: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
119
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
119
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
120
120
|
userId: string;
|
|
121
121
|
claims: import("@supabase/auth-js").User;
|
|
122
122
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -125,17 +125,17 @@ export declare const getProposalDetail: import("@tanstack/start-client-core").Op
|
|
|
125
125
|
item: any;
|
|
126
126
|
}>>;
|
|
127
127
|
export declare const listAllowedLoadCarriers: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
128
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
128
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
129
129
|
userId: string;
|
|
130
130
|
claims: import("@supabase/auth-js").User;
|
|
131
131
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
132
132
|
error: string | null;
|
|
133
133
|
allowed: string[];
|
|
134
134
|
default: string | null;
|
|
135
|
-
carriers: import("./load-carriers").EngineLoadCarrier[];
|
|
135
|
+
carriers: import("./load-carriers.js").EngineLoadCarrier[];
|
|
136
136
|
}>>;
|
|
137
137
|
export declare const approveProposal: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
138
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
138
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
139
139
|
userId: string;
|
|
140
140
|
claims: import("@supabase/auth-js").User;
|
|
141
141
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -163,7 +163,7 @@ export declare const approveProposal: import("@tanstack/start-client-core").Opti
|
|
|
163
163
|
shortages: any[];
|
|
164
164
|
}>>;
|
|
165
165
|
export declare const rejectProposal: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
166
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
166
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
167
167
|
userId: string;
|
|
168
168
|
claims: import("@supabase/auth-js").User;
|
|
169
169
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -173,7 +173,7 @@ export declare const rejectProposal: import("@tanstack/start-client-core").Optio
|
|
|
173
173
|
ok: true;
|
|
174
174
|
}>>;
|
|
175
175
|
export declare const reopenProposal: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
176
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
176
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
177
177
|
userId: string;
|
|
178
178
|
claims: import("@supabase/auth-js").User;
|
|
179
179
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -182,14 +182,14 @@ export declare const reopenProposal: import("@tanstack/start-client-core").Optio
|
|
|
182
182
|
ok: true;
|
|
183
183
|
}>>;
|
|
184
184
|
export declare const listCustomersForPicker: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
185
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
185
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
186
186
|
userId: string;
|
|
187
187
|
claims: import("@supabase/auth-js").User;
|
|
188
188
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
189
189
|
items: any[];
|
|
190
190
|
}>>;
|
|
191
191
|
export declare const createCustomerFromGroup: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
192
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
192
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
193
193
|
userId: string;
|
|
194
194
|
claims: import("@supabase/auth-js").User;
|
|
195
195
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -211,7 +211,7 @@ export declare const createCustomerFromGroup: import("@tanstack/start-client-cor
|
|
|
211
211
|
created: true;
|
|
212
212
|
}>>;
|
|
213
213
|
export declare const listProductsForPicker: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
214
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
214
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
215
215
|
userId: string;
|
|
216
216
|
claims: import("@supabase/auth-js").User;
|
|
217
217
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -219,7 +219,7 @@ export declare const listProductsForPicker: import("@tanstack/start-client-core"
|
|
|
219
219
|
allowBackorder: boolean;
|
|
220
220
|
}>>;
|
|
221
221
|
export declare const planAndSaveAutoCarts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
222
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
222
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
223
223
|
userId: string;
|
|
224
224
|
claims: import("@supabase/auth-js").User;
|
|
225
225
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -250,7 +250,7 @@ export declare const planAndSaveAutoCarts: import("@tanstack/start-client-core")
|
|
|
250
250
|
nextCartNumber: number;
|
|
251
251
|
}>>;
|
|
252
252
|
export declare const saveManualCarts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
253
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
253
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
254
254
|
userId: string;
|
|
255
255
|
claims: import("@supabase/auth-js").User;
|
|
256
256
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -271,7 +271,7 @@ export declare const saveManualCarts: import("@tanstack/start-client-core").Opti
|
|
|
271
271
|
ok: true;
|
|
272
272
|
}>>;
|
|
273
273
|
export declare const listOrderCarts: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
274
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
274
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
275
275
|
userId: string;
|
|
276
276
|
claims: import("@supabase/auth-js").User;
|
|
277
277
|
}, undefined, undefined, undefined>], (d: {
|
|
@@ -288,7 +288,7 @@ export declare const listOrderCarts: import("@tanstack/start-client-core").Requi
|
|
|
288
288
|
order_cart_items: {
|
|
289
289
|
boxes: number | null;
|
|
290
290
|
cart_id: string;
|
|
291
|
-
components: import("../integrations/supabase/types").Json | null;
|
|
291
|
+
components: import("../integrations/supabase/types.js").Json | null;
|
|
292
292
|
crates: number;
|
|
293
293
|
crates_in_layer: number | null;
|
|
294
294
|
crates_per_layer: number;
|
|
@@ -307,7 +307,7 @@ export declare const listOrderCarts: import("@tanstack/start-client-core").Requi
|
|
|
307
307
|
}[];
|
|
308
308
|
}>>;
|
|
309
309
|
export declare const listDeliveryLocationsForCustomer: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
310
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
310
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
311
311
|
userId: string;
|
|
312
312
|
claims: import("@supabase/auth-js").User;
|
|
313
313
|
}, undefined, undefined, undefined>], (d: {
|
|
@@ -334,7 +334,7 @@ export declare const listDeliveryLocationsForCustomer: import("@tanstack/start-c
|
|
|
334
334
|
}[];
|
|
335
335
|
}>>;
|
|
336
336
|
export declare const listPickupLocations: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
337
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
337
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
338
338
|
userId: string;
|
|
339
339
|
claims: import("@supabase/auth-js").User;
|
|
340
340
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -346,7 +346,7 @@ export declare const listPickupLocations: import("@tanstack/start-client-core").
|
|
|
346
346
|
}[];
|
|
347
347
|
}>>;
|
|
348
348
|
export declare const listCarriersForPicker: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
349
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
349
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
350
350
|
userId: string;
|
|
351
351
|
claims: import("@supabase/auth-js").User;
|
|
352
352
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
@@ -358,18 +358,18 @@ export declare const listCarriersForPicker: import("@tanstack/start-client-core"
|
|
|
358
358
|
delivery_days: number | null;
|
|
359
359
|
pickup_weekdays: number[];
|
|
360
360
|
delivery_weekdays: number[];
|
|
361
|
-
pickup_moments: import("../integrations/supabase/types").Json;
|
|
361
|
+
pickup_moments: import("../integrations/supabase/types.js").Json;
|
|
362
362
|
}[];
|
|
363
363
|
}>>;
|
|
364
364
|
export declare const getOrderPickDays: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
365
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
365
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
366
366
|
userId: string;
|
|
367
367
|
claims: import("@supabase/auth-js").User;
|
|
368
368
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
369
369
|
pickDays: number;
|
|
370
370
|
}>>;
|
|
371
371
|
export declare const listBeladingOptionsForProducts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
372
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
372
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
373
373
|
userId: string;
|
|
374
374
|
claims: import("@supabase/auth-js").User;
|
|
375
375
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Server functions voor de Mailbox-bestellingen module
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
3
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
4
4
|
import { createClient } from "@supabase/supabase-js";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { computeEarliestDelivery } from "
|
|
7
|
-
import { emailBodyText, inlineCidImages, normalizeAddressList, normalizeAttachments, sanitizeEmailHtml, stripInvisible, } from "./mailbox-body";
|
|
8
|
-
import { EMPTY_LOAD_CARRIERS, isLoadCarrierAllowed, loadCarrierLabel, normalizeAllowedLoadCarriers, } from "./load-carriers";
|
|
6
|
+
import { computeEarliestDelivery } from "./delivery-date.js";
|
|
7
|
+
import { emailBodyText, inlineCidImages, normalizeAddressList, normalizeAttachments, sanitizeEmailHtml, stripInvisible, } from "./mailbox-body.js";
|
|
8
|
+
import { EMPTY_LOAD_CARRIERS, isLoadCarrierAllowed, loadCarrierLabel, normalizeAllowedLoadCarriers, } from "./load-carriers.js";
|
|
9
9
|
// ─── Actieve mailbox (uit gedeelde e-mail-auth module) ──────────────────────
|
|
10
10
|
// Geen auth-middleware: de RPC is SECURITY DEFINER en EXECUTE staat ook aan
|
|
11
11
|
// `anon`. Zo blijft de status-banner werken als de bearer-token tijdelijk
|
|
@@ -66,7 +66,7 @@ export const syncMailboxNow = createServerFn({ method: "POST" })
|
|
|
66
66
|
if (userErr || !userData?.user) {
|
|
67
67
|
return { ok: false, error: "unauthorized", processed: 0, inserted: 0, errors: 1 };
|
|
68
68
|
}
|
|
69
|
-
const { runIngest } = await import("
|
|
69
|
+
const { runIngest } = await import("./mailbox-ingest.server.js");
|
|
70
70
|
return await runIngest(data.trigger);
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
@@ -82,7 +82,7 @@ export const syncMailboxNow = createServerFn({ method: "POST" })
|
|
|
82
82
|
export const getLastIngestRun = createServerFn({ method: "GET" })
|
|
83
83
|
.middleware([requireSupabaseAuth])
|
|
84
84
|
.handler(async () => {
|
|
85
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
85
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
86
86
|
const { data } = await supabaseAdmin
|
|
87
87
|
.from("mailbox_ingest_runs")
|
|
88
88
|
.select("id, trigger, started_at, finished_at, processed, inserted, errors, error_sample")
|
|
@@ -96,23 +96,23 @@ export const reparseProposalNow = createServerFn({ method: "POST" })
|
|
|
96
96
|
.middleware([requireSupabaseAuth])
|
|
97
97
|
.inputValidator((input) => z.object({ proposalId: z.string().uuid() }).parse(input))
|
|
98
98
|
.handler(async ({ data }) => {
|
|
99
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
100
|
-
const { reparseProposal } = await import("
|
|
99
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
100
|
+
const { reparseProposal } = await import("./mailbox-ingest.server.js");
|
|
101
101
|
return reparseProposal(supabaseAdmin, data.proposalId);
|
|
102
102
|
});
|
|
103
103
|
/** Detecteert een gewijzigde AI-agent en herverwerkt openstaande voorstellen. */
|
|
104
104
|
export const refreshProposalsForAgentChange = createServerFn({ method: "POST" })
|
|
105
105
|
.middleware([requireSupabaseAuth])
|
|
106
106
|
.handler(async () => {
|
|
107
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
108
|
-
const { reparseChangedAgentProposals } = await import("
|
|
107
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
108
|
+
const { reparseChangedAgentProposals } = await import("./mailbox-ingest.server.js");
|
|
109
109
|
return reparseChangedAgentProposals(supabaseAdmin);
|
|
110
110
|
});
|
|
111
111
|
// ─── Messages & Proposals ────────────────────────────────────────────────────
|
|
112
112
|
export const listMessages = createServerFn({ method: "GET" })
|
|
113
113
|
.middleware([requireSupabaseAuth])
|
|
114
114
|
.handler(async () => {
|
|
115
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
115
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
116
116
|
const { data, error } = await supabaseAdmin
|
|
117
117
|
.from("mailbox_messages")
|
|
118
118
|
.select("id, uid, from_email, from_name, subject, received_at, status, error_message, created_at")
|
|
@@ -126,8 +126,8 @@ export const parseMessage = createServerFn({ method: "POST" })
|
|
|
126
126
|
.middleware([requireSupabaseAuth])
|
|
127
127
|
.inputValidator((input) => z.object({ messageId: z.string().uuid() }).parse(input))
|
|
128
128
|
.handler(async ({ data }) => {
|
|
129
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
130
|
-
const { createStubProposal } = await import("
|
|
129
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
130
|
+
const { createStubProposal } = await import("./mailbox-ingest.server.js");
|
|
131
131
|
const { data: msg, error: msgErr } = await supabaseAdmin
|
|
132
132
|
.from("mailbox_messages").select("*").eq("id", data.messageId).single();
|
|
133
133
|
if (msgErr || !msg)
|
|
@@ -142,7 +142,7 @@ export const listProposals = createServerFn({ method: "GET" })
|
|
|
142
142
|
.middleware([requireSupabaseAuth])
|
|
143
143
|
.inputValidator((input) => z.object({ status: z.enum(["pending", "approved", "rejected"]).optional() }).parse(input ?? {}))
|
|
144
144
|
.handler(async ({ data }) => {
|
|
145
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
145
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
146
146
|
// Alleen de kolommen die de lijstweergave toont. De mailtekst (body_text /
|
|
147
147
|
// body_html) en de bestelregels zijn bewust NIET opgenomen: die worden pas
|
|
148
148
|
// opgehaald zodra een voorstel geopend wordt (`getProposalDetail`).
|
|
@@ -178,7 +178,7 @@ export const getProposalDetail = createServerFn({ method: "GET" })
|
|
|
178
178
|
.middleware([requireSupabaseAuth])
|
|
179
179
|
.inputValidator((input) => z.object({ proposalId: z.string().uuid() }).parse(input))
|
|
180
180
|
.handler(async ({ data }) => {
|
|
181
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
181
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
182
182
|
const sel = (s) => s;
|
|
183
183
|
const { data: row, error } = await supabaseAdmin
|
|
184
184
|
.from("mailbox_order_proposals")
|
|
@@ -252,7 +252,7 @@ export const approveProposal = createServerFn({ method: "POST" })
|
|
|
252
252
|
fieldValues: z.array(FieldValueInput).max(100).optional(),
|
|
253
253
|
}).parse(input))
|
|
254
254
|
.handler(async ({ data, context }) => {
|
|
255
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
255
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
256
256
|
const customFields = {};
|
|
257
257
|
(data.fieldValues ?? []).forEach((fv) => {
|
|
258
258
|
customFields[fv.field_key] = fv.value;
|
|
@@ -384,7 +384,7 @@ export const rejectProposal = createServerFn({ method: "POST" })
|
|
|
384
384
|
.middleware([requireSupabaseAuth])
|
|
385
385
|
.inputValidator((input) => z.object({ proposalId: z.string().uuid(), reason: z.string().max(500).optional() }).parse(input))
|
|
386
386
|
.handler(async ({ data, context }) => {
|
|
387
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
387
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
388
388
|
await supabaseAdmin.from("mailbox_order_proposals").update({
|
|
389
389
|
status: "rejected",
|
|
390
390
|
reviewed_by: context.userId,
|
|
@@ -398,7 +398,7 @@ export const reopenProposal = createServerFn({ method: "POST" })
|
|
|
398
398
|
.middleware([requireSupabaseAuth])
|
|
399
399
|
.inputValidator((input) => z.object({ proposalId: z.string().uuid() }).parse(input))
|
|
400
400
|
.handler(async ({ data }) => {
|
|
401
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
401
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
402
402
|
await supabaseAdmin.from("mailbox_order_proposals").update({
|
|
403
403
|
status: "pending",
|
|
404
404
|
reviewed_by: null,
|
|
@@ -413,7 +413,7 @@ export const reopenProposal = createServerFn({ method: "POST" })
|
|
|
413
413
|
export const listCustomersForPicker = createServerFn({ method: "GET" })
|
|
414
414
|
.middleware([requireSupabaseAuth])
|
|
415
415
|
.handler(async () => {
|
|
416
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
416
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
417
417
|
const sb = supabaseAdmin;
|
|
418
418
|
const { data: grouped } = await sb
|
|
419
419
|
.from("external_customers_grouped")
|
|
@@ -474,7 +474,7 @@ export const createCustomerFromGroup = createServerFn({ method: "POST" })
|
|
|
474
474
|
phone: z.string().max(50).nullable().optional(),
|
|
475
475
|
}).parse(input))
|
|
476
476
|
.handler(async ({ data }) => {
|
|
477
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
477
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
478
478
|
const sb = supabaseAdmin;
|
|
479
479
|
const email = (data.email ?? "").trim().toLowerCase() || null;
|
|
480
480
|
const name = data.companyName.trim();
|
|
@@ -512,7 +512,7 @@ export const createCustomerFromGroup = createServerFn({ method: "POST" })
|
|
|
512
512
|
export const listProductsForPicker = createServerFn({ method: "GET" })
|
|
513
513
|
.middleware([requireSupabaseAuth])
|
|
514
514
|
.handler(async ({ context }) => {
|
|
515
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
515
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
516
516
|
// ── 1. Voorraad verzamelen ──────────────────────────────────────────────
|
|
517
517
|
const { data: stockRows } = await supabaseAdmin
|
|
518
518
|
.from("trade_item_stock")
|
|
@@ -633,7 +633,7 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
|
|
|
633
633
|
.eq("order_id", data.orderId);
|
|
634
634
|
if (itErr)
|
|
635
635
|
throw new Error(itErr.message);
|
|
636
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
636
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
637
637
|
// Reset eventuele eerdere auto-karren (idempotent)
|
|
638
638
|
await supabaseAdmin.from("order_carts").delete().eq("order_id", data.orderId).eq("is_auto", true);
|
|
639
639
|
let cartNumber = 1;
|
|
@@ -743,7 +743,7 @@ export const saveManualCarts = createServerFn({ method: "POST" })
|
|
|
743
743
|
.middleware([requireSupabaseAuth])
|
|
744
744
|
.inputValidator((input) => z.object({ orderId: z.string().uuid(), carts: z.array(ManualCart) }).parse(input))
|
|
745
745
|
.handler(async ({ data }) => {
|
|
746
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
746
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
747
747
|
// Verwijder eerdere handmatige karren (replace strategy)
|
|
748
748
|
await supabaseAdmin.from("order_carts").delete()
|
|
749
749
|
.eq("order_id", data.orderId).eq("is_auto", false);
|
|
@@ -875,7 +875,7 @@ export const listBeladingOptionsForProducts = createServerFn({ method: "POST" })
|
|
|
875
875
|
.middleware([requireSupabaseAuth])
|
|
876
876
|
.inputValidator((input) => z.object({ productIds: z.array(z.string()).max(200) }).parse(input))
|
|
877
877
|
.handler(async ({ data }) => {
|
|
878
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
878
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
879
879
|
const ids = Array.from(new Set((data.productIds ?? []).filter(Boolean)));
|
|
880
880
|
const byProduct = {};
|
|
881
881
|
function sortCombos(list) {
|