@cosmicdrift/kumiko-bundled-features 0.414.0 → 0.416.0
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/agent-tools/tool-catalog.js +20 -1
- package/dist/agent-tools/tool-dispatch.js +14 -5
- package/dist/auth-email-password/signup-token-store.d.ts +2 -2
- package/dist/auth-email-password/signup-token-store.js +2 -4
- package/dist/auth-email-password/web/session.js +2 -1
- package/dist/billing-foundation/checkout-core.d.ts +2 -0
- package/dist/billing-foundation/checkout-core.js +9 -0
- package/dist/billing-foundation/checkout-ledger.d.ts +7 -0
- package/dist/billing-foundation/checkout-ledger.js +6 -0
- package/dist/billing-foundation/events.d.ts +1 -0
- package/dist/billing-foundation/events.js +6 -5
- package/dist/billing-foundation/handlers/create-checkout-session.write.js +2 -1
- package/dist/billing-foundation/handlers/process-event.write.d.ts +3 -1
- package/dist/billing-foundation/handlers/process-event.write.js +57 -32
- package/dist/billing-foundation/handlers/process-payment-event.write.js +5 -5
- package/dist/billing-foundation/handlers/start-plan-checkout.write.js +2 -1
- package/dist/billing-foundation/webhook-handler.js +2 -2
- package/dist/channel-whatsapp/constants.d.ts +1 -0
- package/dist/channel-whatsapp/constants.js +1 -0
- package/dist/channel-whatsapp/events.d.ts +3 -0
- package/dist/channel-whatsapp/events.js +4 -3
- package/dist/channel-whatsapp/graph-client.d.ts +2 -0
- package/dist/channel-whatsapp/graph-client.js +29 -2
- package/dist/channel-whatsapp/inbound-handlers.js +24 -3
- package/dist/channel-whatsapp/webhook-normalize.js +21 -6
- package/dist/compliance-profiles/handlers/set-profile.write.js +2 -0
- package/dist/data-retention/feature.js +1 -0
- package/dist/delivery/handlers/opted-in-user-ids.query.js +12 -3
- package/dist/document-ingest-foundation/feature.js +1 -0
- package/dist/document-ingest-foundation/report-ingest-progress.js +4 -1
- package/dist/documents/feature.d.ts +2 -2
- package/dist/documents/feature.js +7 -2
- package/dist/form-draft/feature.js +1 -0
- package/dist/handbook-knowledge/constants.d.ts +6 -0
- package/dist/handbook-knowledge/constants.js +6 -0
- package/dist/handbook-knowledge/feature.d.ts +9 -0
- package/dist/handbook-knowledge/feature.js +17 -0
- package/dist/handbook-knowledge/handbook-index.d.ts +26 -0
- package/dist/handbook-knowledge/handbook-index.js +51 -0
- package/dist/handbook-knowledge/handlers.d.ts +28 -0
- package/dist/handbook-knowledge/handlers.js +67 -0
- package/dist/handbook-knowledge/index.d.ts +3 -0
- package/dist/handbook-knowledge/index.js +2 -0
- package/dist/helpdesk/feature.js +1 -0
- package/dist/helpdesk/handlers/reply.write.js +3 -3
- package/dist/helpdesk/handlers/report.write.js +3 -2
- package/dist/helpdesk/handlers/submit.write.js +3 -2
- package/dist/helpdesk/legacy-contact-streams.js +5 -2
- package/dist/helpdesk/lib.d.ts +1 -1
- package/dist/helpdesk/lib.js +4 -4
- package/dist/inbound-mail-foundation/account-poll.js +2 -0
- package/dist/inbound-mail-foundation/content-refetch.d.ts +3 -0
- package/dist/inbound-mail-foundation/content-refetch.js +2 -6
- package/dist/inbound-mail-foundation/entities.js +10 -9
- package/dist/inbound-mail-foundation/events.js +10 -9
- package/dist/inbound-mail-foundation/handlers/connect-account.write.js +2 -1
- package/dist/inbound-mail-foundation/handlers/forget-message.write.js +4 -0
- package/dist/inbound-mail-foundation/handlers/ingest-message-schema.js +12 -5
- package/dist/inbound-mail-foundation/normalize-inbound-message.d.ts +6 -0
- package/dist/inbound-mail-foundation/normalize-inbound-message.js +21 -8
- package/dist/inbound-mail-foundation/sanitize-inbound-html.d.ts +0 -1
- package/dist/inbound-mail-foundation/sanitize-inbound-html.js +2 -4
- package/dist/managed-pages/web/page-edit-screen.js +12 -5
- package/dist/shared/hmac-signature.js +4 -2
- package/dist/shared/index.d.ts +2 -1
- package/dist/shared/index.js +2 -1
- package/dist/shared/normalize-email.d.ts +1 -0
- package/dist/shared/normalize-email.js +3 -0
- package/dist/shared/send-best-effort.d.ts +1 -0
- package/dist/shared/send-best-effort.js +10 -5
- package/dist/signature/entity.d.ts +552 -0
- package/dist/signature/entity.js +156 -0
- package/dist/signature/feature.d.ts +3 -0
- package/dist/signature/feature.js +91 -0
- package/dist/signature/files.d.ts +23 -0
- package/dist/signature/files.js +64 -0
- package/dist/signature/grant.d.ts +32 -0
- package/dist/signature/grant.js +44 -0
- package/dist/signature/handlers/anonymous.write.d.ts +14 -0
- package/dist/signature/handlers/anonymous.write.js +52 -0
- package/dist/signature/handlers/cancel.write.d.ts +6 -0
- package/dist/signature/handlers/cancel.write.js +30 -0
- package/dist/signature/handlers/issue-link.write.d.ts +9 -0
- package/dist/signature/handlers/issue-link.write.js +57 -0
- package/dist/signature/handlers/lifecycle.write.d.ts +16 -0
- package/dist/signature/handlers/lifecycle.write.js +70 -0
- package/dist/signature/handlers/link-internal.write.d.ts +23 -0
- package/dist/signature/handlers/link-internal.write.js +186 -0
- package/dist/signature/handlers/request.write.d.ts +19 -0
- package/dist/signature/handlers/request.write.js +67 -0
- package/dist/signature/handlers/revoke-link.write.d.ts +6 -0
- package/dist/signature/handlers/revoke-link.write.js +18 -0
- package/dist/signature/handlers/sign-in-person.write.d.ts +8 -0
- package/dist/signature/handlers/sign-in-person.write.js +52 -0
- package/dist/signature/i18n.d.ts +6 -0
- package/dist/signature/i18n.js +49 -0
- package/dist/signature/index.d.ts +5 -0
- package/dist/signature/index.js +2 -0
- package/dist/signature/lib.d.ts +54 -0
- package/dist/signature/lib.js +68 -0
- package/dist/signature/options.d.ts +31 -0
- package/dist/signature/options.js +5 -0
- package/dist/signature/payloads.d.ts +60 -0
- package/dist/signature/payloads.js +53 -0
- package/dist/signature/png.d.ts +11 -0
- package/dist/signature/png.js +159 -0
- package/dist/signature/screens.d.ts +3 -0
- package/dist/signature/screens.js +95 -0
- package/dist/signature/signature-page.d.ts +25 -0
- package/dist/signature/signature-page.js +62 -0
- package/dist/signature/signing.d.ts +19 -0
- package/dist/signature/signing.js +46 -0
- package/dist/signature/static-sign.d.ts +17 -0
- package/dist/signature/static-sign.js +44 -0
- package/dist/signature/sweep.d.ts +3 -0
- package/dist/signature/sweep.js +113 -0
- package/dist/signature/user-data.d.ts +3 -0
- package/dist/signature/user-data.js +135 -0
- package/dist/signature/web/constants.d.ts +69 -0
- package/dist/signature/web/constants.js +68 -0
- package/dist/signature/web/index.d.ts +3 -0
- package/dist/signature/web/index.js +2 -0
- package/dist/signature/web/pad.d.ts +20 -0
- package/dist/signature/web/pad.js +104 -0
- package/dist/signature/web/signature-pad.d.ts +19 -0
- package/dist/signature/web/signature-pad.js +36 -0
- package/dist/step-dispatcher/deliver-dispatch-request.js +5 -3
- package/dist/step-dispatcher/feature.js +11 -0
- package/dist/step-dispatcher/sweep-abandoned.d.ts +1 -0
- package/dist/step-dispatcher/sweep-abandoned.js +3 -0
- package/dist/subscription-paddle/backfill-checkout-ledger.js +2 -0
- package/dist/subscription-paddle/redeliver-legacy-checkout.js +19 -2
- package/dist/subscription-stripe/feature.d.ts +6 -0
- package/dist/subscription-stripe/feature.js +3 -0
- package/dist/subscription-stripe/plugin-methods.d.ts +3 -1
- package/dist/subscription-stripe/plugin-methods.js +2 -1
- package/dist/subscription-stripe/verify-webhook.js +16 -6
- package/dist/template-resolver/seeding.js +32 -7
- package/dist/template-resolver/web/web-preview-renderer.js +5 -1
- package/dist/tenant-inactivity/check-inactive-tenants.js +27 -16
- package/dist/tenant-inactivity/handlers/keep-account.write.js +7 -0
- package/dist/tenant-inactivity/state-store.d.ts +2 -1
- package/dist/tenant-inactivity/state-store.js +7 -0
- package/dist/tenant-lifecycle/feature.js +1 -0
- package/dist/user/resolve-verified-user-email.js +3 -3
- package/dist/user-data-rights/feature.js +1 -0
- package/dist/waitlist/handlers/reject.write.js +2 -1
- package/dist/waitlist/handlers/submit.write.js +2 -2
- package/dist/waitlist/import.js +2 -1
- package/dist/waitlist/lib.d.ts +0 -1
- package/dist/waitlist/lib.js +1 -4
- package/dist/waitlist/link-on-signup.js +2 -2
- package/dist/workflow-runner/handlers/resume-run.write.js +4 -3
- package/package.json +43 -11
- package/src/agent-tools/changes.json +6 -0
- package/src/auth-mfa/changes.json +6 -0
- package/src/billing-foundation/changes.json +24 -0
- package/src/channel-whatsapp/changes.json +30 -0
- package/src/compliance-profiles/changes.json +5 -0
- package/src/delivery/changes.json +6 -0
- package/src/document-ingest-foundation/changes.json +6 -0
- package/src/documents/changes.json +6 -0
- package/src/handbook-knowledge/changes.json +8 -0
- package/src/helpdesk/changes.json +6 -0
- package/src/inbound-mail-foundation/changes.json +6 -0
- package/src/shared/changes.json +6 -0
- package/src/signature/changes.json +15 -0
- package/src/step-dispatcher/changes.json +6 -0
- package/src/subscription-paddle/changes.json +6 -0
- package/src/subscription-stripe/changes.json +12 -0
- package/src/template-resolver/changes.json +12 -0
- package/src/tenant-inactivity/changes.json +6 -0
- package/src/tenant-lifecycle/changes.json +6 -0
- package/src/workflow-runner/changes.json +6 -0
package/dist/helpdesk/lib.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
|
2
2
|
import { createEventStoreExecutor, fetchOne, selectMany, } from "@cosmicdrift/kumiko-framework/db";
|
|
3
3
|
import { access, createSystemUser, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
4
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
5
|
-
import { acknowledgedSystemDb, decryptStoredPii, sendBestEffort as sendSharedBestEffort, } from "../shared/index.js";
|
|
5
|
+
import { acknowledgedSystemDb, decryptStoredPii, runBestEffort as runSharedBestEffort, sendBestEffort as sendSharedBestEffort, } from "../shared/index.js";
|
|
6
6
|
import { tenantTable } from "../tenant/index.js";
|
|
7
7
|
import { TierEngineQueries } from "../tier-engine/index.js";
|
|
8
8
|
import { USER_STATUS, userTable } from "../user/index.js";
|
|
@@ -39,9 +39,6 @@ export function listRepliesOf(db, requestId) {
|
|
|
39
39
|
...page,
|
|
40
40
|
}, platformActor(), db));
|
|
41
41
|
}
|
|
42
|
-
export function normalizeEmail(email) {
|
|
43
|
-
return email.toLowerCase();
|
|
44
|
-
}
|
|
45
42
|
export function helpdeskDb(ctx) {
|
|
46
43
|
return acknowledgedSystemDb(ctx, "helpdesk", HELPDESK_CROSS_TENANT_REASON);
|
|
47
44
|
}
|
|
@@ -64,6 +61,9 @@ export async function loadUserLabel(db, userId) {
|
|
|
64
61
|
export async function sendBestEffort(ctx, label, send) {
|
|
65
62
|
return sendSharedBestEffort(ctx, `[helpdesk] ${label} failed`, send);
|
|
66
63
|
}
|
|
64
|
+
export async function runBestEffort(ctx, label, run) {
|
|
65
|
+
return runSharedBestEffort(ctx, `[helpdesk] ${label} failed`, run);
|
|
66
|
+
}
|
|
67
67
|
export async function forwardHelpdeskRequest(ctx, requestId) {
|
|
68
68
|
const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, {
|
|
69
69
|
requestId,
|
|
@@ -8,6 +8,7 @@ import { retryQuarantinedMessages } from "./quarantine-retry.js";
|
|
|
8
8
|
const SEEN_LOOKUP_CHUNK_SIZE = 1000;
|
|
9
9
|
export function createAccountPoller(deps) {
|
|
10
10
|
const { systemDb, cursors, ingester, health, providerCtx, backfillWindowDays, maxMessagesPerPoll, resolveAccessToken, handleSyncError, log, } = deps;
|
|
11
|
+
const scanResumePoint = new Map();
|
|
11
12
|
function unknownMessageIdsFilterFor(account) {
|
|
12
13
|
return async (providerMessageIds) => {
|
|
13
14
|
if (providerMessageIds.length === 0)
|
|
@@ -45,6 +46,7 @@ export function createAccountPoller(deps) {
|
|
|
45
46
|
const accessToken = await resolveAccessToken(account, plugin);
|
|
46
47
|
await refetchSnippetOnlyMessages({
|
|
47
48
|
db: systemDb,
|
|
49
|
+
scanResumePoint,
|
|
48
50
|
dispatchWrite: deps.dispatchWrite,
|
|
49
51
|
providerCtx,
|
|
50
52
|
account,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
2
3
|
import type { DispatchWrite } from "./supervisor-ingest.ts";
|
|
3
4
|
import type { InboundMailContext, InboundMailProviderPlugin, MailAccountRecord } from "./types.ts";
|
|
4
5
|
export declare const CONTENT_REFETCH_BUDGET_PER_TICK = 50;
|
|
5
6
|
export declare const CONTENT_REFETCH_SCAN_ROWS_PER_TICK: number;
|
|
7
|
+
export type ScanResumePoints = Map<string, Temporal.Instant>;
|
|
6
8
|
export declare function refetchSnippetOnlyMessages(args: {
|
|
7
9
|
readonly db: DbConnection;
|
|
10
|
+
readonly scanResumePoint: ScanResumePoints;
|
|
8
11
|
readonly dispatchWrite: DispatchWrite;
|
|
9
12
|
readonly providerCtx: InboundMailContext;
|
|
10
13
|
readonly account: MailAccountRecord;
|
|
@@ -13,15 +13,11 @@ export const CONTENT_REFETCH_BUDGET_PER_TICK = 50;
|
|
|
13
13
|
const SEEN_PAGE_SIZE = 250;
|
|
14
14
|
const SEEN_MAX_PAGES = 4;
|
|
15
15
|
export const CONTENT_REFETCH_SCAN_ROWS_PER_TICK = SEEN_PAGE_SIZE * SEEN_MAX_PAGES;
|
|
16
|
-
// Where the previous tick stopped scanning, per account. Without it every tick re-reads the newest
|
|
17
|
-
// rows and snippet-only mails further back would never be reached. Lost on restart, which only
|
|
18
|
-
// means the scan starts at the newest mail again.
|
|
19
|
-
const scanResumePoint = new Map();
|
|
20
16
|
function needsContent(row) {
|
|
21
17
|
const bodyMissing = row.bodyRef === undefined || row.bodyRef === null || row.bodyRef === "";
|
|
22
18
|
return bodyMissing && (row.contentState == null || row.contentState === "snippet");
|
|
23
19
|
}
|
|
24
|
-
async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
20
|
+
async function findSnippetOnlyMessageIds(db, scanResumePoint, account, windowDays) {
|
|
25
21
|
const cutoff = Temporal.Now.instant().subtract({ hours: windowDays * 24 });
|
|
26
22
|
const found = [];
|
|
27
23
|
let before = scanResumePoint.get(account.id);
|
|
@@ -68,7 +64,7 @@ export async function refetchSnippetOnlyMessages(args) {
|
|
|
68
64
|
// skip: the provider cannot reload content.
|
|
69
65
|
if (!plugin.fetchContent)
|
|
70
66
|
return;
|
|
71
|
-
const ids = await findSnippetOnlyMessageIds(args.db, account, args.windowDays);
|
|
67
|
+
const ids = await findSnippetOnlyMessageIds(args.db, args.scanResumePoint, account, args.windowDays);
|
|
72
68
|
// skip: no snippet-only mail to reload.
|
|
73
69
|
if (ids.length === 0)
|
|
74
70
|
return;
|
|
@@ -2,6 +2,7 @@ import { collectPiiSubjectFields, piiCiphertextMaxLengthFor, } from "@cosmicdrif
|
|
|
2
2
|
import { deriveEntityTableMeta, isSchemaTable, physicalColumnName, } from "@cosmicdrift/kumiko-framework/db";
|
|
3
3
|
import { access, createBooleanField, createEntity, createFilesField, createLongTextField, createNumberField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
4
|
import { DEFAULT_INBOUND_MAIL_ADMIN_ROLES, DEFAULT_INBOUND_MAIL_USER_ROLES } from "./mail-roles.js";
|
|
5
|
+
import { INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, INBOUND_BODY_HTML_MAX_BYTES, INBOUND_BODY_TEXT_MAX_CHARS, INBOUND_FROM_MAX_CHARS, INBOUND_MAIL_ADDRESS_MAX_CHARS, INBOUND_SNIPPET_MAX_CHARS, INBOUND_SUBJECT_MAX_CHARS, } from "./normalize-inbound-message.js";
|
|
5
6
|
// ============================================================================
|
|
6
7
|
// Read models for the three event-sourced aggregates
|
|
7
8
|
// ============================================================================
|
|
@@ -52,7 +53,7 @@ export const mailAccountEntity = createEntity({
|
|
|
52
53
|
// Mailbox address — tenant PII.
|
|
53
54
|
address: createTextField({
|
|
54
55
|
required: true,
|
|
55
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
56
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_MAIL_ADDRESS_MAX_CHARS),
|
|
56
57
|
personal: "tenant",
|
|
57
58
|
find: "none",
|
|
58
59
|
}),
|
|
@@ -124,28 +125,28 @@ export function createInboundMessageEntity(memberRoles) {
|
|
|
124
125
|
}),
|
|
125
126
|
from: createTextField({
|
|
126
127
|
required: true,
|
|
127
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
128
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_FROM_MAX_CHARS),
|
|
128
129
|
personal: "tenant",
|
|
129
130
|
find: "none",
|
|
130
131
|
}),
|
|
131
132
|
// JSON-stringified string[] — als Ganzes encrypted.
|
|
132
133
|
to: createTextField({
|
|
133
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
134
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS),
|
|
134
135
|
personal: "tenant",
|
|
135
136
|
find: "none",
|
|
136
137
|
}),
|
|
137
138
|
cc: createTextField({
|
|
138
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
139
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS),
|
|
139
140
|
personal: "tenant",
|
|
140
141
|
find: "none",
|
|
141
142
|
}),
|
|
142
143
|
subject: createTextField({
|
|
143
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
144
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS),
|
|
144
145
|
personal: "tenant",
|
|
145
146
|
find: "none",
|
|
146
147
|
}),
|
|
147
148
|
snippet: createTextField({
|
|
148
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
149
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_SNIPPET_MAX_CHARS),
|
|
149
150
|
personal: "tenant",
|
|
150
151
|
find: "none",
|
|
151
152
|
}),
|
|
@@ -155,7 +156,7 @@ export function createInboundMessageEntity(memberRoles) {
|
|
|
155
156
|
// Null on rows from before the column; list-messages never selects it.
|
|
156
157
|
// Plaintext is clipped to INBOUND_BODY_TEXT_MAX_CHARS (32_000) before encryption.
|
|
157
158
|
bodyText: createLongTextField({
|
|
158
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
159
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_BODY_TEXT_MAX_CHARS),
|
|
159
160
|
personal: "tenant",
|
|
160
161
|
find: "none",
|
|
161
162
|
}),
|
|
@@ -163,7 +164,7 @@ export function createInboundMessageEntity(memberRoles) {
|
|
|
163
164
|
// Sanitized HTML of the mail, null when the mail has none or it was too large: sanitizeInboundHtml
|
|
164
165
|
// drops anything over 500_000 bytes after sanitizing, before encryption.
|
|
165
166
|
bodyHtml: createLongTextField({
|
|
166
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
167
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_BODY_HTML_MAX_BYTES),
|
|
167
168
|
personal: "tenant",
|
|
168
169
|
find: "none",
|
|
169
170
|
}),
|
|
@@ -216,7 +217,7 @@ export const mailThreadEntity = createEntity({
|
|
|
216
217
|
reason: "technical_reference",
|
|
217
218
|
}),
|
|
218
219
|
subject: createTextField({
|
|
219
|
-
maxLength: piiCiphertextMaxLengthFor(
|
|
220
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS),
|
|
220
221
|
personal: "tenant",
|
|
221
222
|
find: "none",
|
|
222
223
|
}),
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import { piiCiphertextMaxLengthFor } from "@cosmicdrift/kumiko-framework/crypto";
|
|
23
23
|
import * as z from "zod";
|
|
24
24
|
import { INBOUND_MAIL_FOUNDATION_FEATURE, InboundMailAccountStatuses } from "./constants.js";
|
|
25
|
+
import { INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, INBOUND_BODY_HTML_MAX_BYTES, INBOUND_BODY_TEXT_MAX_CHARS, INBOUND_FROM_MAX_CHARS, INBOUND_MAIL_ADDRESS_MAX_CHARS, INBOUND_SNIPPET_MAX_CHARS, INBOUND_SUBJECT_MAX_CHARS, } from "./normalize-inbound-message.js";
|
|
25
26
|
import { senderAuthenticationFieldSchema } from "./sender-auth.js";
|
|
26
27
|
// Aggregate types for the event store.
|
|
27
28
|
export const MAIL_ACCOUNT_AGGREGATE_TYPE = "mail-account";
|
|
@@ -62,7 +63,7 @@ export const mailAccountEventPayloadSchema = z.object({
|
|
|
62
63
|
/** null = shared by the tenant; otherwise, this user's personal mailbox. */
|
|
63
64
|
ownerUserId: z.string().max(36).nullable(),
|
|
64
65
|
displayName: z.string().max(200),
|
|
65
|
-
address: z.string().min(1).max(piiCiphertextMaxLengthFor(
|
|
66
|
+
address: z.string().min(1).max(piiCiphertextMaxLengthFor(INBOUND_MAIL_ADDRESS_MAX_CHARS)),
|
|
66
67
|
status: accountStatusEnum,
|
|
67
68
|
/** Provider-agnostic watch state ("idle", "watching", "backoff:3", ...)
|
|
68
69
|
* — an operational signal only, not PII. */
|
|
@@ -95,10 +96,10 @@ export const skippedAttachmentSchema = z.object({
|
|
|
95
96
|
// Shared by inbound-message-received (v2+) and inbound-message-content-fetched.
|
|
96
97
|
// bodyText is ciphertext of at most INBOUND_BODY_TEXT_MAX_CHARS (32_000) characters.
|
|
97
98
|
const inboundMessageContentShape = {
|
|
98
|
-
bodyText: z.string().max(piiCiphertextMaxLengthFor(
|
|
99
|
+
bodyText: z.string().max(piiCiphertextMaxLengthFor(INBOUND_BODY_TEXT_MAX_CHARS)),
|
|
99
100
|
bodyTextTruncated: z.boolean(),
|
|
100
101
|
/** Sanitized HTML body as PII ciphertext. sanitizeInboundHtml drops anything over 500_000 bytes after sanitizing. Null: none or too large. */
|
|
101
|
-
bodyHtml: z.string().max(piiCiphertextMaxLengthFor(
|
|
102
|
+
bodyHtml: z.string().max(piiCiphertextMaxLengthFor(INBOUND_BODY_HTML_MAX_BYTES)).nullable(),
|
|
102
103
|
/** file-foundation FileRef ids (plaintext uuids). Attachments outlive the mail: apps turn them
|
|
103
104
|
* into documents, so the retention sweep never deletes them. */
|
|
104
105
|
attachmentFileIds: z.array(z.uuid()).max(50),
|
|
@@ -127,13 +128,13 @@ export const inboundMessageEventPayloadSchema = z.object({
|
|
|
127
128
|
/** Normalized thread key (References-chain root or provider thread ID,
|
|
128
129
|
* prefixed by the provider). */
|
|
129
130
|
threadKey: z.string().min(1).max(500),
|
|
130
|
-
from: z.string().min(1).max(piiCiphertextMaxLengthFor(
|
|
131
|
+
from: z.string().min(1).max(piiCiphertextMaxLengthFor(INBOUND_FROM_MAX_CHARS)),
|
|
131
132
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
132
|
-
to: z.string().max(piiCiphertextMaxLengthFor(
|
|
133
|
+
to: z.string().max(piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS)),
|
|
133
134
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
134
|
-
cc: z.string().max(piiCiphertextMaxLengthFor(
|
|
135
|
-
subject: z.string().max(piiCiphertextMaxLengthFor(
|
|
136
|
-
snippet: z.string().max(piiCiphertextMaxLengthFor(
|
|
135
|
+
cc: z.string().max(piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS)),
|
|
136
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS)),
|
|
137
|
+
snippet: z.string().max(piiCiphertextMaxLengthFor(INBOUND_SNIPPET_MAX_CHARS)),
|
|
137
138
|
/** ISO instant — receipt time reported by the provider (INTERNALDATE or
|
|
138
139
|
* receivedDateTime), not ingest time. */
|
|
139
140
|
receivedAtIso: z.string().min(1),
|
|
@@ -165,7 +166,7 @@ export const inboundMessageContentFetchedEventPayloadSchema = z.object({
|
|
|
165
166
|
// ============================================================================
|
|
166
167
|
export const mailThreadEventPayloadSchema = z.object({
|
|
167
168
|
threadKey: z.string().min(1).max(500),
|
|
168
|
-
subject: z.string().max(piiCiphertextMaxLengthFor(
|
|
169
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS)),
|
|
169
170
|
lastMessageAtIso: z.string().min(1),
|
|
170
171
|
messageCount: z.number().int().min(1),
|
|
171
172
|
});
|
|
@@ -22,6 +22,7 @@ import { InboundMailAccountStatuses, InboundMailAuthMethods, InboundMailConnectE
|
|
|
22
22
|
import { MAIL_ACCOUNT_PII_FIELDS, mailAccountEntity } from "../entities.js";
|
|
23
23
|
import { MAIL_ACCOUNT_AGGREGATE_TYPE, MAIL_ACCOUNT_CONNECTED_EVENT_QN, } from "../events.js";
|
|
24
24
|
import { accessRolesOf } from "../mail-roles.js";
|
|
25
|
+
import { INBOUND_MAIL_ADDRESS_MAX_CHARS } from "../normalize-inbound-message.js";
|
|
25
26
|
import { connectConflictOf, findMailboxByAddress, normalizeMailAddress, } from "./account-address.js";
|
|
26
27
|
// 'inma': serializes the duplicate-address check and the append per tenant and address (the lock key is tenant-scoped).
|
|
27
28
|
const CONNECT_ADDRESS_LOCK_NAMESPACE = 0x696e6d61;
|
|
@@ -37,7 +38,7 @@ export const connectAccountSchema = z
|
|
|
37
38
|
]),
|
|
38
39
|
displayName: z.string().trim().max(200),
|
|
39
40
|
/** Mailbox address in plaintext; it is encrypted here. */
|
|
40
|
-
address: z.string().min(1).max(
|
|
41
|
+
address: z.string().min(1).max(INBOUND_MAIL_ADDRESS_MAX_CHARS),
|
|
41
42
|
/** "shared" = shared across the tenant (info@) · "user" = the caller's
|
|
42
43
|
* personal mailbox (ownerUserId is taken from the session, never from
|
|
43
44
|
* the payload—preventing claims on another user's mailbox). */
|
|
@@ -24,6 +24,10 @@ export function createForgetMessageHandler({ memberRoles, adminRoles, }) {
|
|
|
24
24
|
return writeFailure(new AccessDeniedError({ details: { reason: "not_mailbox_owner" } }));
|
|
25
25
|
}
|
|
26
26
|
const { files } = ctx.services;
|
|
27
|
+
// Without file storage the original could not be deleted, and the row held its only reference.
|
|
28
|
+
if (row.bodyRef && !files) {
|
|
29
|
+
throw new Error(`forget-message: no file storage to delete the stored original of ${messageId}`);
|
|
30
|
+
}
|
|
27
31
|
const purged = await purgeInboundMessages({
|
|
28
32
|
db: ctx.db,
|
|
29
33
|
tenantId: event.user.tenantId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
+
import { INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, INBOUND_FROM_MAX_CHARS, INBOUND_SNIPPET_MAX_CHARS, INBOUND_SUBJECT_MAX_CHARS, } from "../normalize-inbound-message.js";
|
|
2
3
|
import { senderAuthenticationFieldSchema } from "../sender-auth.js";
|
|
3
4
|
import { inboundContentPayloadShape } from "./message-content.js";
|
|
4
5
|
// =============================================================================
|
|
@@ -7,6 +8,12 @@ import { inboundContentPayloadShape } from "./message-content.js";
|
|
|
7
8
|
// original and attachments ride in-process as bytes and are persisted to file
|
|
8
9
|
// storage here; the event itself stays blob-free (references only).
|
|
9
10
|
// =============================================================================
|
|
11
|
+
const addressListSchema = z
|
|
12
|
+
.array(z.string().max(2000))
|
|
13
|
+
.max(200)
|
|
14
|
+
.refine((list) => JSON.stringify(list).length <= INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, {
|
|
15
|
+
message: "serialized address list too long",
|
|
16
|
+
});
|
|
10
17
|
export const ingestMessageSchema = z.object({
|
|
11
18
|
accountId: z.uuid(),
|
|
12
19
|
/** Scope inherited from the account — the supervisor knows the
|
|
@@ -20,11 +27,11 @@ export const ingestMessageSchema = z.object({
|
|
|
20
27
|
providerThreadId: z.string().min(1).max(500).nullable(),
|
|
21
28
|
/** References/In-Reply-To chain, oldest first. */
|
|
22
29
|
references: z.array(z.string().min(1).max(500)).max(200),
|
|
23
|
-
from: z.string().min(1).max(
|
|
24
|
-
to:
|
|
25
|
-
cc:
|
|
26
|
-
subject: z.string().max(
|
|
27
|
-
snippet: z.string().max(
|
|
30
|
+
from: z.string().min(1).max(INBOUND_FROM_MAX_CHARS),
|
|
31
|
+
to: addressListSchema,
|
|
32
|
+
cc: addressListSchema,
|
|
33
|
+
subject: z.string().max(INBOUND_SUBJECT_MAX_CHARS),
|
|
34
|
+
snippet: z.string().max(INBOUND_SNIPPET_MAX_CHARS),
|
|
28
35
|
receivedAtIso: z.string().min(1),
|
|
29
36
|
/** From the app's storeBody hook; empty lets the handler store the original itself. */
|
|
30
37
|
bodyRef: z.string().max(500),
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { RawInboundAttachment, RawInboundMessage, SkippedInboundAttachment } from "./types.ts";
|
|
2
2
|
export declare const INBOUND_MISSING_SENDER = "(no sender)";
|
|
3
3
|
export declare const INBOUND_BODY_TEXT_MAX_CHARS = 32000;
|
|
4
|
+
export declare const INBOUND_BODY_HTML_MAX_BYTES = 500000;
|
|
4
5
|
export declare const INBOUND_BODY_HTML_MAX_CHARS = 5000000;
|
|
5
6
|
export declare const INBOUND_ATTACHMENT_MAX_BYTES: number;
|
|
6
7
|
export declare const INBOUND_MAIL_ATTACHMENTS_MAX_BYTES: number;
|
|
7
8
|
export declare const INBOUND_RAW_MIME_MAX_BYTES: number;
|
|
8
9
|
export declare const INBOUND_ATTACHMENTS_MAX_COUNT = 50;
|
|
9
10
|
export declare const INBOUND_SKIPPED_ATTACHMENTS_MAX_COUNT = 200;
|
|
11
|
+
export declare const INBOUND_FROM_MAX_CHARS = 2000;
|
|
12
|
+
export declare const INBOUND_SUBJECT_MAX_CHARS = 4000;
|
|
13
|
+
export declare const INBOUND_SNIPPET_MAX_CHARS = 4000;
|
|
14
|
+
export declare const INBOUND_MAIL_ADDRESS_MAX_CHARS = 320;
|
|
15
|
+
export declare const INBOUND_ADDRESS_LIST_JSON_MAX_CHARS = 8000;
|
|
10
16
|
export type NormalizedInboundMessage = Omit<RawInboundMessage, "text" | "html" | "attachments" | "skippedAttachments"> & {
|
|
11
17
|
readonly bodyText: string;
|
|
12
18
|
readonly bodyTextTruncated: boolean;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// mail would otherwise block the cursor of its mailbox forever.
|
|
4
4
|
export const INBOUND_MISSING_SENDER = "(no sender)";
|
|
5
5
|
export const INBOUND_BODY_TEXT_MAX_CHARS = 32_000;
|
|
6
|
+
// Counted in UTF-8 bytes, not characters: the ciphertext grows with the bytes, and a CJK or emoji
|
|
7
|
+
// mail of 500,000 characters would encrypt past the event's bodyHtml maximum.
|
|
8
|
+
export const INBOUND_BODY_HTML_MAX_BYTES = 500_000;
|
|
6
9
|
export const INBOUND_BODY_HTML_MAX_CHARS = 5_000_000;
|
|
7
10
|
export const INBOUND_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;
|
|
8
11
|
export const INBOUND_MAIL_ATTACHMENTS_MAX_BYTES = 50 * 1024 * 1024;
|
|
@@ -10,13 +13,16 @@ export const INBOUND_MAIL_ATTACHMENTS_MAX_BYTES = 50 * 1024 * 1024;
|
|
|
10
13
|
export const INBOUND_RAW_MIME_MAX_BYTES = INBOUND_MAIL_ATTACHMENTS_MAX_BYTES;
|
|
11
14
|
export const INBOUND_ATTACHMENTS_MAX_COUNT = 50;
|
|
12
15
|
export const INBOUND_SKIPPED_ATTACHMENTS_MAX_COUNT = 200;
|
|
13
|
-
const
|
|
16
|
+
export const INBOUND_FROM_MAX_CHARS = 2000;
|
|
17
|
+
export const INBOUND_SUBJECT_MAX_CHARS = 4000;
|
|
18
|
+
export const INBOUND_SNIPPET_MAX_CHARS = 4000;
|
|
19
|
+
export const INBOUND_MAIL_ADDRESS_MAX_CHARS = 320;
|
|
20
|
+
// Plaintext of one JSON-stringified to/cc list; its ciphertext must fit the event and entity field.
|
|
21
|
+
export const INBOUND_ADDRESS_LIST_JSON_MAX_CHARS = 8000;
|
|
14
22
|
const ADDRESS_MAX = 2000;
|
|
15
23
|
const ADDRESS_LIST_MAX = 200;
|
|
16
24
|
const REFERENCE_MAX = 500;
|
|
17
25
|
const REFERENCES_MAX = 200;
|
|
18
|
-
const SUBJECT_MAX = 4000;
|
|
19
|
-
const SNIPPET_MAX = 4000;
|
|
20
26
|
const MESSAGE_ID_HEADER_MAX = 500;
|
|
21
27
|
function isHighSurrogate(code) {
|
|
22
28
|
return code >= 0xd800 && code <= 0xdbff;
|
|
@@ -28,6 +34,13 @@ function clip(value, max) {
|
|
|
28
34
|
const cut = isHighSurrogate(value.charCodeAt(max - 1)) ? max - 1 : max;
|
|
29
35
|
return value.slice(0, cut);
|
|
30
36
|
}
|
|
37
|
+
function limitAddressList(list) {
|
|
38
|
+
const kept = list.slice(0, ADDRESS_LIST_MAX).map((a) => clip(a, ADDRESS_MAX));
|
|
39
|
+
while (kept.length > 0 && JSON.stringify(kept).length > INBOUND_ADDRESS_LIST_JSON_MAX_CHARS) {
|
|
40
|
+
kept.pop();
|
|
41
|
+
}
|
|
42
|
+
return kept;
|
|
43
|
+
}
|
|
31
44
|
function limitReferences(references) {
|
|
32
45
|
const usable = references.filter((r) => r.length > 0 && r.length <= REFERENCE_MAX);
|
|
33
46
|
if (usable.length <= REFERENCES_MAX)
|
|
@@ -76,11 +89,11 @@ export function normalizeRawInboundMessage(msg) {
|
|
|
76
89
|
? msg.messageIdHeader
|
|
77
90
|
: null,
|
|
78
91
|
references: limitReferences(msg.references),
|
|
79
|
-
from: from.length === 0 ? INBOUND_MISSING_SENDER : clip(from,
|
|
80
|
-
to: msg.to
|
|
81
|
-
cc: msg.cc
|
|
82
|
-
subject: clip(msg.subject,
|
|
83
|
-
snippet: clip(msg.snippet,
|
|
92
|
+
from: from.length === 0 ? INBOUND_MISSING_SENDER : clip(from, INBOUND_FROM_MAX_CHARS),
|
|
93
|
+
to: limitAddressList(msg.to),
|
|
94
|
+
cc: limitAddressList(msg.cc),
|
|
95
|
+
subject: clip(msg.subject, INBOUND_SUBJECT_MAX_CHARS),
|
|
96
|
+
snippet: clip(msg.snippet, INBOUND_SNIPPET_MAX_CHARS),
|
|
84
97
|
bodyText: clip(fullText, INBOUND_BODY_TEXT_MAX_CHARS),
|
|
85
98
|
bodyTextTruncated: fullText.length > INBOUND_BODY_TEXT_MAX_CHARS,
|
|
86
99
|
bodyHtml: bodyHtml !== null && bodyHtml.length <= INBOUND_BODY_HTML_MAX_CHARS ? bodyHtml : null,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// Allowlist sanitizer for the HTML part of an inbound mail. The result is stored in the event and
|
|
2
2
|
// shown by the reader inside a script-free sandboxed iframe; this is the first of the two layers.
|
|
3
3
|
import sanitizeHtml from "sanitize-html";
|
|
4
|
-
|
|
5
|
-
// mail of 500,000 characters would encrypt past the event's bodyHtml maximum.
|
|
6
|
-
export const BODY_HTML_MAX_BYTES = 500_000;
|
|
4
|
+
import { INBOUND_BODY_HTML_MAX_BYTES } from "./normalize-inbound-message.js";
|
|
7
5
|
const ALLOWED_TAGS = [
|
|
8
6
|
"p",
|
|
9
7
|
"br",
|
|
@@ -129,7 +127,7 @@ export function sanitizeInboundHtml(html) {
|
|
|
129
127
|
// An image whose src was stripped (cid:, data:, other scheme) is only a broken placeholder.
|
|
130
128
|
exclusiveFilter: (frame) => frame.tag === "img" && frame.attribs["src"] === undefined,
|
|
131
129
|
}).trim();
|
|
132
|
-
return clean.length === 0 || Buffer.byteLength(clean, "utf8") >
|
|
130
|
+
return clean.length === 0 || Buffer.byteLength(clean, "utf8") > INBOUND_BODY_HTML_MAX_BYTES
|
|
133
131
|
? null
|
|
134
132
|
: clean;
|
|
135
133
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { dispatcherErrorTextWithFieldIssues, PreviewPane, useMutation, useNav, usePrimitives, useQuery, useTranslation, useUnsavedInputSource, } from "@cosmicdrift/kumiko-renderer";
|
|
3
3
|
import { EditorWorkbench, LoadingState, StatusBadge } from "@cosmicdrift/kumiko-renderer/web";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
5
|
import { DocumentContentEditor } from "../../template-resolver/web/index.js";
|
|
6
6
|
import { PAGE_CREATE_HANDLER, PAGE_DETAIL_QUERY, PAGE_EDIT_SCREEN_ID, PAGE_LIST_SCREEN_ID, PAGE_UPDATE_HANDLER, } from "./constants.js";
|
|
7
7
|
import { changesOf, createdIdOf, createPayloadOf, draftOfRecord, EMPTY_PAGE_DRAFT, isDraftDirty, lossyFeaturesOfRecord, } from "./page-edit-draft.js";
|
|
@@ -17,8 +17,10 @@ const TEST_ID = "page-workbench";
|
|
|
17
17
|
function PageEditor({ record, onSaved, }) {
|
|
18
18
|
const t = useTranslation();
|
|
19
19
|
const { Banner } = usePrimitives();
|
|
20
|
-
|
|
21
|
-
const
|
|
20
|
+
// Computed once: the editor is remounted per record version, and every keystroke re-renders it.
|
|
21
|
+
const [initial] = useState(() => (record === null ? EMPTY_PAGE_DRAFT : draftOfRecord(record)));
|
|
22
|
+
const [lossyOnOpen] = useState(() => (record === null ? [] : lossyFeaturesOfRecord(record)));
|
|
23
|
+
const savedRef = useRef(false);
|
|
22
24
|
const [draft, setDraft] = useState(initial);
|
|
23
25
|
const [bodyEdited, setBodyEdited] = useState(false);
|
|
24
26
|
const [resetCount, setResetCount] = useState(0);
|
|
@@ -26,8 +28,12 @@ function PageEditor({ record, onSaved, }) {
|
|
|
26
28
|
const create = useMutation(PAGE_CREATE_HANDLER);
|
|
27
29
|
const update = useMutation(PAGE_UPDATE_HANDLER);
|
|
28
30
|
const dirty = isDraftDirty(draft, initial);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
// The leave guard runs synchronously after save, before React re-renders with the saved state.
|
|
32
|
+
useUnsavedInputSource(() => dirty && !savedRef.current);
|
|
33
|
+
const patch = (changes) => {
|
|
34
|
+
savedRef.current = false;
|
|
35
|
+
setDraft((current) => ({ ...current, ...changes }));
|
|
36
|
+
};
|
|
31
37
|
const canSave = dirty && draft.slug !== "" && draft.title !== "";
|
|
32
38
|
const save = async () => {
|
|
33
39
|
setSaveError(null);
|
|
@@ -42,6 +48,7 @@ function PageEditor({ record, onSaved, }) {
|
|
|
42
48
|
setSaveError(dispatcherErrorTextWithFieldIssues(result.error, t));
|
|
43
49
|
return;
|
|
44
50
|
}
|
|
51
|
+
savedRef.current = true;
|
|
45
52
|
onSaved(record === null ? createdIdOf(result.data) : record.id);
|
|
46
53
|
};
|
|
47
54
|
const discard = () => {
|
|
@@ -3,8 +3,10 @@ export function signHmacSha256Base64Url(input, secret) {
|
|
|
3
3
|
return createHmac("sha256", secret).update(input).digest("base64url");
|
|
4
4
|
}
|
|
5
5
|
export function hmacSignatureMatches(expectedBase64Url, providedBase64Url) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// The text is compared, not the decoded bytes: decoding ignores the unused trailing bits of the
|
|
7
|
+
// last character, so one signature would have several accepted spellings.
|
|
8
|
+
const expectedBuf = Buffer.from(expectedBase64Url);
|
|
9
|
+
const providedBuf = Buffer.from(providedBase64Url);
|
|
8
10
|
// timingSafeEqual throws on a length mismatch, and the throw itself is a timing signal.
|
|
9
11
|
return expectedBuf.length === providedBuf.length && timingSafeEqual(expectedBuf, providedBuf);
|
|
10
12
|
}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { createLockoutCounter, type LockoutCounterState } from "./lockout-counte
|
|
|
19
19
|
export { createMailLocaleTemplates } from "./mail-locale-templates.ts";
|
|
20
20
|
export { mailHeading, mailParagraph, mailParagraphWithLink, mailRepeatedRows, } from "./mail-template-body.ts";
|
|
21
21
|
export { mapWithConcurrency } from "./map-with-concurrency.ts";
|
|
22
|
+
export { normalizeEmail } from "./normalize-email.ts";
|
|
22
23
|
export { denyUnlessJoinRowParentVisible, hostRowIsGone, joinRowParentIsVisible, parentRowIsVisible, visibleParentRowIds, } from "./parent-visibility.ts";
|
|
23
24
|
export { hashPassword, verifyDummyPassword, verifyPassword } from "./password-hashing.ts";
|
|
24
25
|
export { type PriceEnvProvider, type PriceEnvShape, priceEnvSchema, priceEnvShape, } from "./price-env-shape.ts";
|
|
@@ -35,7 +36,7 @@ export { resolveFeatureAccess } from "./resolve-feature-access.ts";
|
|
|
35
36
|
export { extensionForResourceContentType, isResourceImageContentType, isResourceImageFormat, RESOURCE_IMAGE_FORMATS, type ResourceImageContentType, type ResourceImageFormat, } from "./resource-image-formats.ts";
|
|
36
37
|
export { type RowBoundGrantResult, redeemRowBoundGrant, signRowBoundGrant, } from "./row-bound-grant.ts";
|
|
37
38
|
export { runInSubTransaction } from "./run-in-sub-transaction.ts";
|
|
38
|
-
export { sendBestEffort } from "./send-best-effort.ts";
|
|
39
|
+
export { runBestEffort, sendBestEffort } from "./send-best-effort.ts";
|
|
39
40
|
export { registrationLocaleFromRequest, sessionLocaleField } from "./session-locale-field.ts";
|
|
40
41
|
export { sessionTimezoneField } from "./session-timezone-field.ts";
|
|
41
42
|
export { assertNotSvg, MAX_INPUT_PIXELS, SHARP_INPUT_OPTIONS } from "./sharp-input-limits.ts";
|
package/dist/shared/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export { createLockoutCounter } from "./lockout-counter.js";
|
|
|
19
19
|
export { createMailLocaleTemplates } from "./mail-locale-templates.js";
|
|
20
20
|
export { mailHeading, mailParagraph, mailParagraphWithLink, mailRepeatedRows, } from "./mail-template-body.js";
|
|
21
21
|
export { mapWithConcurrency } from "./map-with-concurrency.js";
|
|
22
|
+
export { normalizeEmail } from "./normalize-email.js";
|
|
22
23
|
export { denyUnlessJoinRowParentVisible, hostRowIsGone, joinRowParentIsVisible, parentRowIsVisible, visibleParentRowIds, } from "./parent-visibility.js";
|
|
23
24
|
export { hashPassword, verifyDummyPassword, verifyPassword } from "./password-hashing.js";
|
|
24
25
|
export { priceEnvSchema, priceEnvShape, } from "./price-env-shape.js";
|
|
@@ -35,7 +36,7 @@ export { resolveFeatureAccess } from "./resolve-feature-access.js";
|
|
|
35
36
|
export { extensionForResourceContentType, isResourceImageContentType, isResourceImageFormat, RESOURCE_IMAGE_FORMATS, } from "./resource-image-formats.js";
|
|
36
37
|
export { redeemRowBoundGrant, signRowBoundGrant, } from "./row-bound-grant.js";
|
|
37
38
|
export { runInSubTransaction } from "./run-in-sub-transaction.js";
|
|
38
|
-
export { sendBestEffort } from "./send-best-effort.js";
|
|
39
|
+
export { runBestEffort, sendBestEffort } from "./send-best-effort.js";
|
|
39
40
|
export { registrationLocaleFromRequest, sessionLocaleField } from "./session-locale-field.js";
|
|
40
41
|
export { sessionTimezoneField } from "./session-timezone-field.js";
|
|
41
42
|
export { assertNotSvg, MAX_INPUT_PIXELS, SHARP_INPUT_OPTIONS } from "./sharp-input-limits.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeEmail(email: string): string;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
export declare function runBestEffort(ctx: Pick<HandlerContext, "obs">, logMessage: string, run: () => Promise<unknown>): Promise<void>;
|
|
2
3
|
export declare function sendBestEffort(ctx: Pick<HandlerContext, "notify" | "obs">, logMessage: string, send: (notify: NonNullable<HandlerContext["notify"]>) => Promise<unknown>): Promise<void>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
2
|
-
export async function
|
|
2
|
+
export async function runBestEffort(ctx, logMessage, run) {
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
|
|
6
|
-
}
|
|
7
|
-
await send(ctx.notify);
|
|
4
|
+
await run();
|
|
8
5
|
}
|
|
9
6
|
catch (err) {
|
|
10
7
|
ctx.obs.log?.warn(logMessage, {
|
|
@@ -12,3 +9,11 @@ export async function sendBestEffort(ctx, logMessage, send) {
|
|
|
12
9
|
});
|
|
13
10
|
}
|
|
14
11
|
}
|
|
12
|
+
export async function sendBestEffort(ctx, logMessage, send) {
|
|
13
|
+
await runBestEffort(ctx, logMessage, async () => {
|
|
14
|
+
if (!ctx.notify) {
|
|
15
|
+
throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
|
|
16
|
+
}
|
|
17
|
+
await send(ctx.notify);
|
|
18
|
+
});
|
|
19
|
+
}
|