@flowselections/mailbox-orders 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/EmailPreview.d.ts +26 -0
- package/dist-lib/components/EmailPreview.d.ts.map +1 -0
- package/dist-lib/components/EmailPreview.js +56 -0
- package/dist-lib/components/MailboxFilterBar.d.ts +31 -0
- package/dist-lib/components/MailboxFilterBar.d.ts.map +1 -0
- package/dist-lib/components/MailboxFilterBar.js +67 -0
- package/dist-lib/components/MailboxProcessedPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProcessedPage.js +45 -3
- package/dist-lib/components/MailboxProposalsPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProposalsPage.js +77 -38
- package/dist-lib/components/TablePagination.d.ts +12 -0
- package/dist-lib/components/TablePagination.d.ts.map +1 -0
- package/dist-lib/components/TablePagination.js +14 -0
- package/dist-lib/index.d.ts +3 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +3 -0
- package/dist-lib/integrations/supabase/client.d.ts +140 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +140 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +140 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/mailbox-body.d.ts +26 -0
- package/dist-lib/lib/mailbox-body.d.ts.map +1 -1
- package/dist-lib/lib/mailbox-body.js +77 -1
- package/dist-lib/lib/mailbox-ingest.server.d.ts.map +1 -1
- package/dist-lib/lib/mailbox-ingest.server.js +5 -0
- package/dist-lib/lib/mailbox.functions.d.ts +10 -0
- package/dist-lib/lib/mailbox.functions.d.ts.map +1 -1
- package/dist-lib/lib/mailbox.functions.js +63 -11
- package/package.json +1 -1
|
@@ -1,7 +1,33 @@
|
|
|
1
|
+
/** Verwijdert onzichtbare tekens (zero-width / BOM) die mails onleesbaar maken. */
|
|
2
|
+
export declare function stripInvisible(s: string): string;
|
|
1
3
|
export declare function htmlToText(html: string): string;
|
|
2
4
|
/**
|
|
3
5
|
* Kiest de meest volledige tekstversie van een bericht: de HTML-body wint
|
|
4
6
|
* zodra die duidelijk meer inhoud bevat dan de (mogelijk afgekapte) preview.
|
|
5
7
|
*/
|
|
6
8
|
export declare function emailBodyText(bodyText: string | null | undefined, bodyHtml: string | null | undefined): string;
|
|
9
|
+
/**
|
|
10
|
+
* Maakt mail-HTML veilig om te renderen zonder de weergave uit te kleden.
|
|
11
|
+
* Afbeeldingen, stijlen, tabellen, iframes en embeds blijven behouden; alleen
|
|
12
|
+
* actieve scripting wordt verwijderd. De HTML draait daarnaast in een
|
|
13
|
+
* sandbox-iframe zonder scripts en zonder toegang tot de applicatie.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizeEmailHtml(html: string | null | undefined): string;
|
|
16
|
+
export type EmailAddress = {
|
|
17
|
+
name?: string | null;
|
|
18
|
+
email?: string | null;
|
|
19
|
+
};
|
|
20
|
+
/** Normaliseert de verschillende vormen waarin providers ontvangers aanleveren. */
|
|
21
|
+
export declare function normalizeAddressList(value: unknown): EmailAddress[];
|
|
22
|
+
export type EmailAttachment = {
|
|
23
|
+
name: string;
|
|
24
|
+
contentType?: string | null;
|
|
25
|
+
size?: number | null;
|
|
26
|
+
contentId?: string | null;
|
|
27
|
+
contentBytes?: string | null;
|
|
28
|
+
url?: string | null;
|
|
29
|
+
};
|
|
30
|
+
export declare function normalizeAttachments(value: unknown): EmailAttachment[];
|
|
31
|
+
/** Vervangt `cid:`-verwijzingen door data-URL's van de bijbehorende bijlage. */
|
|
32
|
+
export declare function inlineCidImages(html: string, attachments: EmailAttachment[]): string;
|
|
7
33
|
//# sourceMappingURL=mailbox-body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox-body.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox-body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,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,MAAM,CAUpF"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
// Gedeelde helper: zet de HTML-versie van een e-mail om naar leesbare tekst.
|
|
2
2
|
// Nodig omdat Microsoft Graph in `body_text` vaak alleen een korte preview
|
|
3
3
|
// (~255 tekens) meestuurt, terwijl de volledige inhoud in `body_html` zit.
|
|
4
|
+
/** Verwijdert onzichtbare tekens (zero-width / BOM) die mails onleesbaar maken. */
|
|
5
|
+
export function stripInvisible(s) {
|
|
6
|
+
return (s ?? "")
|
|
7
|
+
.replace(/&#(?:65279|8203|8204|8205|8288);/gi, "")
|
|
8
|
+
.replace(/&#x(?:feff|200b|200c|200d|2060);/gi, "")
|
|
9
|
+
.replace(/[\u200b-\u200d\u2060\ufeff]/g, "");
|
|
10
|
+
}
|
|
4
11
|
export function htmlToText(html) {
|
|
5
|
-
return (html ?? "")
|
|
12
|
+
return stripInvisible(html ?? "")
|
|
6
13
|
.replace(/<style[\s\S]*?<\/style>/gi, " ")
|
|
7
14
|
.replace(/<script[\s\S]*?<\/script>/gi, " ")
|
|
8
15
|
.replace(/<!--[\s\S]*?-->/g, " ")
|
|
@@ -36,3 +43,72 @@ export function emailBodyText(bodyText, bodyHtml) {
|
|
|
36
43
|
return plain;
|
|
37
44
|
return fromHtml.length > plain.length + 20 ? fromHtml : plain;
|
|
38
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Maakt mail-HTML veilig om te renderen zonder de weergave uit te kleden.
|
|
48
|
+
* Afbeeldingen, stijlen, tabellen, iframes en embeds blijven behouden; alleen
|
|
49
|
+
* actieve scripting wordt verwijderd. De HTML draait daarnaast in een
|
|
50
|
+
* sandbox-iframe zonder scripts en zonder toegang tot de applicatie.
|
|
51
|
+
*/
|
|
52
|
+
export function sanitizeEmailHtml(html) {
|
|
53
|
+
let out = stripInvisible(html ?? "");
|
|
54
|
+
out = out
|
|
55
|
+
.replace(/<script[\s\S]*?<\/script>/gi, "")
|
|
56
|
+
.replace(/<script[^>]*\/?>/gi, "")
|
|
57
|
+
.replace(/<meta[^>]*http-equiv=["']?refresh[\s\S]*?>/gi, "")
|
|
58
|
+
.replace(/\son[a-z]+\s*=\s*"[^"]*"/gi, "")
|
|
59
|
+
.replace(/\son[a-z]+\s*=\s*'[^']*'/gi, "")
|
|
60
|
+
.replace(/\son[a-z]+\s*=\s*[^\s>]+/gi, "")
|
|
61
|
+
.replace(/(href|src|action)\s*=\s*(["']?)\s*javascript:[^"'\s>]*/gi, "$1=$2#");
|
|
62
|
+
return out.trim();
|
|
63
|
+
}
|
|
64
|
+
/** Normaliseert de verschillende vormen waarin providers ontvangers aanleveren. */
|
|
65
|
+
export function normalizeAddressList(value) {
|
|
66
|
+
const raw = Array.isArray(value) ? value : value ? [value] : [];
|
|
67
|
+
const out = [];
|
|
68
|
+
for (const v of raw) {
|
|
69
|
+
if (!v)
|
|
70
|
+
continue;
|
|
71
|
+
if (typeof v === "string") {
|
|
72
|
+
out.push({ email: v });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const o = v;
|
|
76
|
+
const email = o["email"] ?? o["address"] ?? o["emailAddress"]?.address ?? null;
|
|
77
|
+
const name = o["name"] ?? o["displayName"] ?? o["emailAddress"]?.name ?? null;
|
|
78
|
+
if (email || name)
|
|
79
|
+
out.push({ name, email });
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
export function normalizeAttachments(value) {
|
|
84
|
+
const raw = Array.isArray(value) ? value : [];
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const v of raw) {
|
|
87
|
+
if (!v || typeof v !== "object")
|
|
88
|
+
continue;
|
|
89
|
+
const o = v;
|
|
90
|
+
out.push({
|
|
91
|
+
name: String(o["name"] ?? o["filename"] ?? o["fileName"] ?? "bijlage"),
|
|
92
|
+
contentType: o["contentType"] ?? o["content_type"] ?? o["mimeType"] ?? null,
|
|
93
|
+
size: typeof o["size"] === "number" ? o["size"] : Number(o["size"]) || null,
|
|
94
|
+
contentId: o["contentId"] ?? o["content_id"] ?? o["cid"] ?? null,
|
|
95
|
+
contentBytes: o["contentBytes"] ?? o["content_bytes"] ?? o["content"] ?? null,
|
|
96
|
+
url: o["url"] ?? o["downloadUrl"] ?? null,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
/** Vervangt `cid:`-verwijzingen door data-URL's van de bijbehorende bijlage. */
|
|
102
|
+
export function inlineCidImages(html, attachments) {
|
|
103
|
+
if (!html || attachments.length === 0)
|
|
104
|
+
return html;
|
|
105
|
+
let out = html;
|
|
106
|
+
for (const a of attachments) {
|
|
107
|
+
if (!a.contentId || !a.contentBytes)
|
|
108
|
+
continue;
|
|
109
|
+
const cid = a.contentId.replace(/^<|>$/g, "");
|
|
110
|
+
const dataUrl = `data:${a.contentType || "application/octet-stream"};base64,${a.contentBytes}`;
|
|
111
|
+
out = out.replace(new RegExp(`cid:${cid.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "gi"), dataUrl);
|
|
112
|
+
}
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox-ingest.server.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox-ingest.server.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAU9D,KAAK,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAuK5C,8EAA8E;AAC9E,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC;IACvE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC,CAWD;AAsHD;;;;GAIG;AACH,wBAAgB,iBAAiB,C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O,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC,CAAC;AAGF,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAkI1E"}
|
|
@@ -769,6 +769,11 @@ async function ingestSingleEvent(admin, connectionId, ev) {
|
|
|
769
769
|
subject,
|
|
770
770
|
body_text: bodyText,
|
|
771
771
|
body_html: bodyHtml,
|
|
772
|
+
to_recipients: (Array.isArray(p?.to) ? p.to : []),
|
|
773
|
+
cc_recipients: (Array.isArray(p?.cc) ? p.cc : []),
|
|
774
|
+
attachments: (Array.isArray(p?.attachments) ? p.attachments : []),
|
|
775
|
+
has_attachments: p?.has_attachments === true ||
|
|
776
|
+
(Array.isArray(p?.attachments) && p.attachments.length > 0),
|
|
772
777
|
received_at: receivedAt,
|
|
773
778
|
status: "new",
|
|
774
779
|
})
|
|
@@ -115,6 +115,16 @@ export declare const listProposals: import("@tanstack/start-client-core").Option
|
|
|
115
115
|
}, Promise<{
|
|
116
116
|
items: any[];
|
|
117
117
|
}>>;
|
|
118
|
+
/** Eén voorstel volledig: mailtekst, bestelregels en veldwaarden. */
|
|
119
|
+
export declare const getProposalDetail: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
120
|
+
supabase: import("@supabase/supabase-js").SupabaseClient<Database>;
|
|
121
|
+
userId: string;
|
|
122
|
+
claims: import("@supabase/auth-js").User;
|
|
123
|
+
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
124
|
+
proposalId: string;
|
|
125
|
+
}, Promise<{
|
|
126
|
+
item: any;
|
|
127
|
+
}>>;
|
|
118
128
|
export declare const listAllowedLoadCarriers: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
119
129
|
supabase: import("@supabase/supabase-js").SupabaseClient<Database>;
|
|
120
130
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox.functions.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox.functions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"mailbox.functions.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox.functions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAwB9D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;QAiBf,MAAM;cACM,MAAM;mBACI,MAAM;kBACE,MAAM,GAAG,IAAI;YACzB,MAAM,GAAG,IAAI;gBACL,MAAM,GAAG,IAAI;sBACD,MAAM,GAAG,IAAI;;;GAGnE,CAAC;AAWL,eAAO,MAAM,cAAc,2EACD,OAAO;;;;;;;;GA+B7B,CAAC;AAGL,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;GAWzB,CAAC;AAEL,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;GAK7B,CAAC;AAEL,iFAAiF;AACjF,eAAO,MAAM,8BAA8B;;;;;;;;;GAMvC,CAAC;AAML,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;GAWrB,CAAC;AAEL,eAAO,MAAM,YAAY;;;;8CAEC,OAAO;;;;GAa7B,CAAC;AAKL,eAAO,MA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jC,CAAC;AAEL,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;GAS9B,CAAC;AAGL,eAAO,MAAM,gBAAgB;;;;;;GAUzB,CAAC;AAiBL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;0BAOT,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;oBAC/D,OAAO;oBACP,MAAM,GAAG,IAAI;oBAAc,MAAM,GAAG,IAAI;sBACtC,MAAM,GAAG,IAAI;sBAAgB,MAAM,GAAG,IAAI;;yBAEO,MAAM;yBAAmB,MAAM;;;0BAL5E,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;oBAC/D,OAAO;oBACP,MAAM,GAAG,IAAI;oBAAc,MAAM,GAAG,IAAI;sBACtC,MAAM,GAAG,IAAI;sBAAgB,MAAM,GAAG,IAAI;;;;;GAsM1D,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
|
4
4
|
import { createClient } from "@supabase/supabase-js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { computeEarliestDelivery } from "../lib/delivery-date";
|
|
7
|
-
import { emailBodyText } from "./mailbox-body";
|
|
7
|
+
import { emailBodyText, inlineCidImages, normalizeAddressList, normalizeAttachments, sanitizeEmailHtml, stripInvisible, } from "./mailbox-body";
|
|
8
8
|
import { EMPTY_LOAD_CARRIERS, isLoadCarrierAllowed, loadCarrierLabel, normalizeAllowedLoadCarriers, } from "./load-carriers";
|
|
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
|
|
@@ -143,28 +143,80 @@ export const listProposals = createServerFn({ method: "GET" })
|
|
|
143
143
|
.inputValidator((input) => z.object({ status: z.enum(["pending", "approved", "rejected"]).optional() }).parse(input ?? {}))
|
|
144
144
|
.handler(async ({ data }) => {
|
|
145
145
|
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
//
|
|
146
|
+
// Alleen de kolommen die de lijstweergave toont. De mailtekst (body_text /
|
|
147
|
+
// body_html) en de bestelregels zijn bewust NIET opgenomen: die worden pas
|
|
148
|
+
// opgehaald zodra een voorstel geopend wordt (`getProposalDetail`).
|
|
149
|
+
const sel = (s) => s;
|
|
149
150
|
let q = supabaseAdmin
|
|
150
151
|
.from("mailbox_order_proposals")
|
|
151
|
-
.select("
|
|
152
|
+
.select(sel("id, status, created_at, reviewed_at, matched_customer_id, ai_ok:parsed_payload->ai->>ok, " +
|
|
153
|
+
"mailbox_messages(subject, from_email, from_name, received_at, connection_id, body_text), " +
|
|
154
|
+
"mailbox_proposal_field_values(field_key, value, needs_review)"))
|
|
152
155
|
.order("created_at", { ascending: false })
|
|
153
|
-
.limit(
|
|
156
|
+
.limit(200);
|
|
154
157
|
if (data.status)
|
|
155
158
|
q = q.eq("status", data.status);
|
|
156
159
|
const { data: rows, error } = await q;
|
|
157
160
|
if (error)
|
|
158
161
|
throw new Error(error.message);
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
// Korte preview (Outlook-stijl) i.p.v. de volledige mailtekst meesturen.
|
|
163
|
+
const items = (Array.isArray(rows) ? rows : []).map((row) => {
|
|
164
|
+
const m = row?.mailbox_messages;
|
|
161
165
|
if (!m)
|
|
162
|
-
return
|
|
163
|
-
const {
|
|
164
|
-
|
|
166
|
+
return row;
|
|
167
|
+
const { body_text, ...rest } = m;
|
|
168
|
+
const preview = stripInvisible(String(body_text ?? ""))
|
|
169
|
+
.replace(/\s+/g, " ")
|
|
170
|
+
.trim()
|
|
171
|
+
.slice(0, 180);
|
|
172
|
+
return { ...row, mailbox_messages: { ...rest, preview } };
|
|
165
173
|
});
|
|
166
174
|
return { items };
|
|
167
175
|
});
|
|
176
|
+
/** Eén voorstel volledig: mailtekst, bestelregels en veldwaarden. */
|
|
177
|
+
export const getProposalDetail = createServerFn({ method: "GET" })
|
|
178
|
+
.middleware([requireSupabaseAuth])
|
|
179
|
+
.inputValidator((input) => z.object({ proposalId: z.string().uuid() }).parse(input))
|
|
180
|
+
.handler(async ({ data }) => {
|
|
181
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
182
|
+
const sel = (s) => s;
|
|
183
|
+
const { data: row, error } = await supabaseAdmin
|
|
184
|
+
.from("mailbox_order_proposals")
|
|
185
|
+
.select(sel("*, mailbox_messages(subject, from_email, from_name, body_text, body_html, received_at, connection_id, to_recipients, cc_recipients, attachments, has_attachments), " +
|
|
186
|
+
"mailbox_proposal_lines(*), mailbox_proposal_field_values(*)"))
|
|
187
|
+
.eq("id", data.proposalId)
|
|
188
|
+
.maybeSingle();
|
|
189
|
+
if (error)
|
|
190
|
+
throw new Error(error.message);
|
|
191
|
+
if (!row)
|
|
192
|
+
return { item: null };
|
|
193
|
+
const m = row.mailbox_messages;
|
|
194
|
+
if (!m)
|
|
195
|
+
return { item: row };
|
|
196
|
+
const attachments = normalizeAttachments(m.attachments);
|
|
197
|
+
const html = inlineCidImages(sanitizeEmailHtml(m.body_html), attachments);
|
|
198
|
+
return {
|
|
199
|
+
item: {
|
|
200
|
+
...row,
|
|
201
|
+
mailbox_messages: {
|
|
202
|
+
...m,
|
|
203
|
+
body_text: emailBodyText(m.body_text, m.body_html),
|
|
204
|
+
body_html: html,
|
|
205
|
+
to_recipients: normalizeAddressList(m.to_recipients),
|
|
206
|
+
cc_recipients: normalizeAddressList(m.cc_recipients),
|
|
207
|
+
// contentBytes kan groot zijn; alleen metadata + eventuele download-url
|
|
208
|
+
attachments: attachments.map((a) => ({
|
|
209
|
+
name: a.name,
|
|
210
|
+
contentType: a.contentType ?? null,
|
|
211
|
+
size: a.size ?? null,
|
|
212
|
+
contentId: a.contentId ?? null,
|
|
213
|
+
url: a.url ?? null,
|
|
214
|
+
})),
|
|
215
|
+
has_attachments: m.has_attachments === true || attachments.length > 0,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
});
|
|
168
220
|
// ─── Ladingdragers uit de Logistics Engine ─────────────────────────────────
|
|
169
221
|
// Nooit cachen: de instelling kan op elk moment wijzigen.
|
|
170
222
|
export const listAllowedLoadCarriers = createServerFn({ method: "GET" })
|