@flowselections/mailbox-orders 1.0.27 → 1.0.29
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/CartAssignmentWizard.js +1 -1
- package/dist-lib/components/MailboxInboxPage.js +2 -2
- package/dist-lib/components/MailboxProcessedPage.js +4 -4
- package/dist-lib/components/MailboxProposalsPage.js +10 -10
- package/dist-lib/components/settings/ImapAccountsCard.js +1 -1
- package/dist-lib/components/settings/ImapProfilesCard.js +1 -1
- package/dist-lib/components/settings/MailboxAiPromptCard.js +2 -2
- package/dist-lib/components/settings/MailboxOrderTemplateCard.js +1 -1
- package/dist-lib/components/settings/MailboxSettingsCard.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/imap.functions.d.ts +1386 -1386
- package/dist-lib/lib/imap.functions.js +8 -8
- 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-auto.server.js +4 -4
- 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
|
@@ -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 "../lib/delivery-date";
|
|
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 "../lib/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("../lib/mailbox-ingest.server");
|
|
69
|
+
const { runIngest } = await import("../lib/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("../lib/mailbox-ingest.server");
|
|
99
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
100
|
+
const { reparseProposal } = await import("../lib/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("../lib/mailbox-ingest.server");
|
|
107
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
108
|
+
const { reparseChangedAgentProposals } = await import("../lib/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("../lib/mailbox-ingest.server");
|
|
129
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
130
|
+
const { createStubProposal } = await import("../lib/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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowselections/mailbox-orders",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"dev": "vite dev",
|
|
29
29
|
"build": "vite build",
|
|
30
|
-
"build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
|
|
30
|
+
"build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
|
|
31
31
|
"build:lib:watch": "tsc -p tsconfig.build.json --watch",
|
|
32
32
|
"build:dev": "vite build --mode development",
|
|
33
33
|
"preview": "vite preview",
|