@cosmicdrift/kumiko-bundled-features 0.411.0 → 0.413.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/admin-shell/feature.d.ts +1 -1
- package/dist/agent-tools/agent-doc-lint.d.ts +9 -0
- package/dist/agent-tools/agent-doc-lint.js +42 -5
- package/dist/agent-tools/agent-manifest.d.ts +0 -1
- package/dist/agent-tools/agent-manifest.js +9 -99
- package/dist/agent-tools/api-docs/anchors.d.ts +14 -0
- package/dist/agent-tools/api-docs/anchors.js +49 -0
- package/dist/agent-tools/api-docs/check.d.ts +7 -0
- package/dist/agent-tools/api-docs/check.js +15 -0
- package/dist/agent-tools/api-docs/collect-events.d.ts +10 -0
- package/dist/agent-tools/api-docs/collect-events.js +90 -0
- package/dist/agent-tools/api-docs/collect.d.ts +15 -0
- package/dist/agent-tools/api-docs/collect.js +108 -0
- package/dist/agent-tools/api-docs/curl.d.ts +5 -0
- package/dist/agent-tools/api-docs/curl.js +24 -0
- package/dist/agent-tools/api-docs/error-table.d.ts +9 -0
- package/dist/agent-tools/api-docs/error-table.js +31 -0
- package/dist/agent-tools/api-docs/examples.d.ts +16 -0
- package/dist/agent-tools/api-docs/examples.js +25 -0
- package/dist/agent-tools/api-docs/generate.d.ts +19 -0
- package/dist/agent-tools/api-docs/generate.js +104 -0
- package/dist/agent-tools/api-docs/index-json.d.ts +15 -0
- package/dist/agent-tools/api-docs/index-json.js +6 -0
- package/dist/agent-tools/api-docs/index.d.ts +9 -0
- package/dist/agent-tools/api-docs/index.js +6 -0
- package/dist/agent-tools/api-docs/list-parameters.d.ts +61 -0
- package/dist/agent-tools/api-docs/list-parameters.js +28 -0
- package/dist/agent-tools/api-docs/markdown.d.ts +29 -0
- package/dist/agent-tools/api-docs/markdown.js +48 -0
- package/dist/agent-tools/api-docs/menu-path.d.ts +8 -0
- package/dist/agent-tools/api-docs/menu-path.js +60 -0
- package/dist/agent-tools/api-docs/model.d.ts +76 -0
- package/dist/agent-tools/api-docs/problems.d.ts +32 -0
- package/dist/agent-tools/api-docs/problems.js +28 -0
- package/dist/agent-tools/api-docs/render-events.d.ts +12 -0
- package/dist/agent-tools/api-docs/render-events.js +55 -0
- package/dist/agent-tools/api-docs/render-openapi.d.ts +10 -0
- package/dist/agent-tools/api-docs/render-openapi.js +170 -0
- package/dist/agent-tools/api-docs/render-overview.d.ts +11 -0
- package/dist/agent-tools/api-docs/render-overview.js +60 -0
- package/dist/agent-tools/api-docs/render-reference.d.ts +14 -0
- package/dist/agent-tools/api-docs/render-reference.js +50 -0
- package/dist/agent-tools/api-docs/render-tokens.d.ts +12 -0
- package/dist/agent-tools/api-docs/render-tokens.js +101 -0
- package/dist/agent-tools/api-docs/schema-fields.d.ts +16 -0
- package/dist/agent-tools/api-docs/schema-fields.js +141 -0
- package/dist/agent-tools/api-docs/section-ids.d.ts +25 -0
- package/dist/agent-tools/api-docs/section-ids.js +26 -0
- package/dist/agent-tools/api-docs/system-only.d.ts +5 -0
- package/dist/agent-tools/api-docs/system-only.js +7 -0
- package/dist/agent-tools/api-docs/texts/de.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/de.js +123 -0
- package/dist/agent-tools/api-docs/texts/en.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/en.js +123 -0
- package/dist/agent-tools/api-docs/texts/es.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/es.js +123 -0
- package/dist/agent-tools/api-docs/texts/fr.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/fr.js +123 -0
- package/dist/agent-tools/api-docs/texts/index.d.ts +14 -0
- package/dist/agent-tools/api-docs/texts/index.js +55 -0
- package/dist/agent-tools/api-docs/texts/it.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/it.js +123 -0
- package/dist/agent-tools/api-docs/texts/types.d.ts +18 -0
- package/dist/agent-tools/api-docs/texts/types.js +104 -0
- package/dist/agent-tools/api-docs/ui-writes.d.ts +12 -0
- package/dist/agent-tools/api-docs/ui-writes.js +73 -0
- package/dist/agent-tools/handler-schema.d.ts +5 -0
- package/dist/agent-tools/handler-schema.js +37 -0
- package/dist/agent-tools/index.d.ts +2 -1
- package/dist/agent-tools/index.js +2 -1
- package/dist/agent-tools/labels.d.ts +26 -0
- package/dist/agent-tools/labels.js +131 -0
- package/dist/auth-email-password/boot-rules.d.ts +7 -0
- package/dist/auth-email-password/boot-rules.js +7 -0
- package/dist/auth-email-password/feature.js +6 -13
- package/dist/auth-email-password/validate-options.d.ts +5 -0
- package/dist/auth-email-password/validate-options.js +15 -0
- package/dist/billing-foundation/boot-rules.d.ts +22 -0
- package/dist/billing-foundation/boot-rules.js +22 -0
- package/dist/billing-foundation/validate-options.js +56 -18
- package/dist/cap-overview/boot-rules.d.ts +12 -0
- package/dist/cap-overview/boot-rules.js +12 -0
- package/dist/cap-overview/feature.js +8 -3
- package/dist/documents/boot-rules.d.ts +12 -0
- package/dist/documents/boot-rules.js +12 -0
- package/dist/documents/feature.js +8 -3
- package/dist/file-derivatives/boot-rules.d.ts +7 -0
- package/dist/file-derivatives/boot-rules.js +7 -0
- package/dist/file-derivatives/feature.js +5 -2
- package/dist/folders/boot-rules.d.ts +7 -0
- package/dist/folders/boot-rules.js +7 -0
- package/dist/folders/feature.js +8 -5
- package/dist/helpdesk/boot-rules.d.ts +7 -0
- package/dist/helpdesk/boot-rules.js +7 -0
- package/dist/{contact → helpdesk}/challenge.js +2 -2
- package/dist/helpdesk/client/helpdesk-client-source.d.ts +1 -0
- package/dist/{contact/client/contact-client-source.js → helpdesk/client/helpdesk-client-source.js} +4 -4
- package/dist/helpdesk/client/helpdesk-website-client.d.ts +26 -0
- package/dist/helpdesk/client/helpdesk-website-client.js +1 -0
- package/dist/helpdesk/client/index.d.ts +2 -0
- package/dist/helpdesk/client/index.js +1 -0
- package/dist/{contact → helpdesk}/entity.d.ts +6 -6
- package/dist/{contact → helpdesk}/entity.js +31 -27
- package/dist/helpdesk/feature.d.ts +3 -0
- package/dist/{contact → helpdesk}/feature.js +43 -39
- package/dist/{contact → helpdesk}/handlers/attempts.d.ts +2 -2
- package/dist/helpdesk/handlers/challenge.query.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/challenge.query.js +5 -5
- package/dist/helpdesk/handlers/forward-request.write.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/forward-request.write.js +17 -15
- package/dist/{contact → helpdesk}/handlers/mark-done.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/mark-done.write.js +8 -8
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.js +11 -11
- package/dist/{contact → helpdesk}/handlers/open-count.js +2 -2
- package/dist/{contact → helpdesk}/handlers/open-count.query.js +4 -4
- package/dist/{contact → helpdesk}/handlers/replies.query.js +6 -6
- package/dist/{contact → helpdesk}/handlers/reply.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/reply.write.js +16 -16
- package/dist/helpdesk/handlers/report.write.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/report.write.js +17 -17
- package/dist/helpdesk/handlers/request-delivery.query.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/request-delivery.query.js +24 -24
- package/dist/{contact → helpdesk}/handlers/request-detail.query.d.ts +3 -3
- package/dist/{contact → helpdesk}/handlers/request-detail.query.js +10 -10
- package/dist/{contact → helpdesk}/handlers/request-list.query.js +2 -2
- package/dist/helpdesk/handlers/send-reply-mail.write.d.ts +8 -0
- package/dist/{contact → helpdesk}/handlers/send-reply-mail.write.js +15 -15
- package/dist/helpdesk/handlers/send-test.write.d.ts +5 -0
- package/dist/{contact → helpdesk}/handlers/send-test.write.js +10 -10
- package/dist/{contact → helpdesk}/handlers/submit.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/submit.write.js +17 -17
- package/dist/{contact → helpdesk}/handlers/take-over-uploads.js +5 -5
- package/dist/{contact → helpdesk}/i18n.d.ts +1 -1
- package/dist/{contact → helpdesk}/i18n.js +78 -75
- package/dist/helpdesk/index.d.ts +5 -0
- package/dist/helpdesk/index.js +4 -0
- package/dist/{contact → helpdesk}/lib.d.ts +5 -5
- package/dist/{contact → helpdesk}/lib.js +16 -16
- package/dist/{contact → helpdesk}/mail.d.ts +20 -20
- package/dist/{contact → helpdesk}/mail.js +47 -47
- package/dist/{contact → helpdesk}/options.d.ts +6 -6
- package/dist/helpdesk/options.js +36 -0
- package/dist/helpdesk/panels.d.ts +2 -0
- package/dist/helpdesk/panels.js +21 -0
- package/dist/{contact → helpdesk}/payloads.d.ts +11 -11
- package/dist/{contact → helpdesk}/payloads.js +28 -28
- package/dist/helpdesk/screens.d.ts +5 -0
- package/dist/{contact → helpdesk}/screens.js +87 -87
- package/dist/{contact → helpdesk}/subject.js +3 -3
- package/dist/helpdesk/user-data-hooks.d.ts +3 -0
- package/dist/{contact → helpdesk}/user-data-hooks.js +15 -15
- package/dist/helpdesk/web/constants.d.ts +127 -0
- package/dist/helpdesk/web/constants.js +126 -0
- package/dist/helpdesk/web/index.d.ts +1 -0
- package/dist/helpdesk/web/index.js +1 -0
- package/dist/host-routing/boot-rules.d.ts +22 -0
- package/dist/host-routing/boot-rules.js +22 -0
- package/dist/host-routing/validate-options.js +35 -11
- package/dist/inbound-mail-foundation/entities.d.ts +84 -0
- package/dist/inbound-mail-foundation/entities.js +96 -71
- package/dist/inbound-mail-foundation/feature.js +2 -2
- package/dist/jobs/boot-rules.d.ts +7 -0
- package/dist/jobs/boot-rules.js +7 -0
- package/dist/jobs/feature.js +5 -2
- package/dist/legal-pages/boot-rules.d.ts +17 -0
- package/dist/legal-pages/boot-rules.js +17 -0
- package/dist/legal-pages/feature.js +5 -2
- package/dist/legal-pages/lib/validate-routes.js +11 -3
- package/dist/metrics/boot-rules.d.ts +12 -0
- package/dist/metrics/boot-rules.js +12 -0
- package/dist/metrics/validate.js +8 -2
- package/dist/notes-history/boot-rules.d.ts +7 -0
- package/dist/notes-history/boot-rules.js +7 -0
- package/dist/notes-history/feature.js +7 -4
- package/dist/personal-access-tokens/boot-rules.d.ts +7 -0
- package/dist/personal-access-tokens/boot-rules.js +7 -0
- package/dist/personal-access-tokens/feature.d.ts +1 -0
- package/dist/personal-access-tokens/feature.js +4 -2
- package/dist/personal-access-tokens/handlers/create.write.js +2 -2
- package/dist/personal-access-tokens/i18n.js +5 -1
- package/dist/personal-access-tokens/index.d.ts +4 -2
- package/dist/personal-access-tokens/index.js +29 -2
- package/dist/personal-access-tokens/scope-events-check.d.ts +3 -0
- package/dist/personal-access-tokens/scope-events-check.js +21 -0
- package/dist/personal-access-tokens/screens.js +8 -2
- package/dist/personal-access-tokens/web/constants.d.ts +1 -0
- package/dist/personal-access-tokens/web/constants.js +1 -0
- package/dist/personal-access-tokens/web/scopes.d.ts +2 -0
- package/dist/personal-access-tokens/web/scopes.js +12 -0
- package/dist/presence/boot-rules.d.ts +7 -0
- package/dist/presence/boot-rules.js +7 -0
- package/dist/presence/options.js +5 -1
- package/dist/readiness/boot-rules.d.ts +12 -0
- package/dist/readiness/boot-rules.js +12 -0
- package/dist/readiness/probe-boot-check.js +8 -3
- package/dist/shared/assert-no-where-rule-in-ownership-write.d.ts +1 -1
- package/dist/shared/assert-no-where-rule-in-ownership-write.js +11 -7
- package/dist/shared/boot-rules.d.ts +7 -0
- package/dist/shared/boot-rules.js +7 -0
- package/dist/subscription-mollie/boot-rules.d.ts +17 -0
- package/dist/subscription-mollie/boot-rules.js +17 -0
- package/dist/subscription-mollie/feature.js +13 -6
- package/dist/tags/boot-rules.d.ts +7 -0
- package/dist/tags/boot-rules.js +7 -0
- package/dist/tags/feature.js +8 -5
- package/dist/template-resolver/boot-rules.d.ts +17 -0
- package/dist/template-resolver/boot-rules.js +17 -0
- package/dist/template-resolver/feature.js +14 -5
- package/dist/tenant/boot-rules.d.ts +7 -0
- package/dist/tenant/boot-rules.js +7 -0
- package/dist/tenant/feature.js +5 -2
- package/kumiko-es-tables.json +4 -4
- package/package.json +29 -29
- package/src/agent-tools/changes.json +24 -0
- package/src/{contact → helpdesk}/changes.json +6 -0
- package/src/inbound-mail-foundation/changes.json +6 -0
- package/src/personal-access-tokens/changes.json +6 -0
- package/dist/contact/client/contact-client-source.d.ts +0 -1
- package/dist/contact/client/contact-website-client.d.ts +0 -26
- package/dist/contact/client/index.d.ts +0 -2
- package/dist/contact/client/index.js +0 -1
- package/dist/contact/feature.d.ts +0 -3
- package/dist/contact/handlers/challenge.query.d.ts +0 -9
- package/dist/contact/handlers/forward-request.write.d.ts +0 -9
- package/dist/contact/handlers/report.write.d.ts +0 -16
- package/dist/contact/handlers/request-delivery.query.d.ts +0 -16
- package/dist/contact/handlers/send-reply-mail.write.d.ts +0 -8
- package/dist/contact/handlers/send-test.write.d.ts +0 -5
- package/dist/contact/index.d.ts +0 -5
- package/dist/contact/index.js +0 -4
- package/dist/contact/options.js +0 -32
- package/dist/contact/panels.d.ts +0 -2
- package/dist/contact/panels.js +0 -21
- package/dist/contact/screens.d.ts +0 -5
- package/dist/contact/user-data-hooks.d.ts +0 -3
- package/dist/contact/web/constants.d.ts +0 -127
- package/dist/contact/web/constants.js +0 -126
- package/dist/contact/web/index.d.ts +0 -1
- package/dist/contact/web/index.js +0 -1
- /package/dist/{contact/client/contact-website-client.js → agent-tools/api-docs/model.js} +0 -0
- /package/dist/{contact → helpdesk}/challenge.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/attempts.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/replies.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/request-list.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/take-over-uploads.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.js +0 -0
- /package/dist/{contact → helpdesk}/subject.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.js +0 -0
|
@@ -6,20 +6,20 @@ import { decryptStoredPii } 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";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { helpdeskReplyEntity, helpdeskReplyTable, helpdeskRequestEntity, helpdeskRequestTable, } from "./entity.js";
|
|
10
|
+
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HelpdeskErrors, } from "./web/constants.js";
|
|
11
11
|
export const IN_APP_FEATURE = "channel-in-app";
|
|
12
12
|
export const TELEGRAM_FEATURE = "channel-telegram";
|
|
13
|
-
export const
|
|
13
|
+
export const HELPDESK_CROSS_TENANT_REASON = "helpdesk is platform-wide (systemScope)";
|
|
14
14
|
export const SYSTEM_ADMIN_ROLE = "SystemAdmin";
|
|
15
|
-
const PII_DECRYPT_REASON = "
|
|
15
|
+
const PII_DECRYPT_REASON = "helpdesk:user-lookup";
|
|
16
16
|
export const adminAccess = { roles: access.systemAdmin };
|
|
17
17
|
export const internalAccess = { roles: access.system };
|
|
18
|
-
export const requestExecutor = createEventStoreExecutor(
|
|
19
|
-
entityName:
|
|
18
|
+
export const requestExecutor = createEventStoreExecutor(helpdeskRequestTable, helpdeskRequestEntity, {
|
|
19
|
+
entityName: HELPDESK_REQUEST_ENTITY,
|
|
20
20
|
});
|
|
21
|
-
export const replyExecutor = createEventStoreExecutor(
|
|
22
|
-
entityName:
|
|
21
|
+
export const replyExecutor = createEventStoreExecutor(helpdeskReplyTable, helpdeskReplyEntity, {
|
|
22
|
+
entityName: HELPDESK_REPLY_ENTITY,
|
|
23
23
|
});
|
|
24
24
|
const MAX_REPLIES_PER_REQUEST = 200;
|
|
25
25
|
export async function listRepliesOf(db, requestId) {
|
|
@@ -34,13 +34,13 @@ export async function listRepliesOf(db, requestId) {
|
|
|
34
34
|
export function normalizeEmail(email) {
|
|
35
35
|
return email.toLowerCase();
|
|
36
36
|
}
|
|
37
|
-
export function
|
|
37
|
+
export function helpdeskDb(ctx) {
|
|
38
38
|
if (!ctx.systemDb) {
|
|
39
39
|
throw new InternalError({
|
|
40
|
-
message: "
|
|
40
|
+
message: "helpdesk requires ctx.systemDb — is r.systemScope() set on the feature?",
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
return ctx.systemDb.acknowledgeCrossTenant(
|
|
43
|
+
return ctx.systemDb.acknowledgeCrossTenant(HELPDESK_CROSS_TENANT_REASON);
|
|
44
44
|
}
|
|
45
45
|
// Requests and replies are systemStream rows, so every write targets the system tenant's stream.
|
|
46
46
|
export function platformActor() {
|
|
@@ -66,21 +66,21 @@ export async function sendBestEffort(ctx, label, send) {
|
|
|
66
66
|
await send(ctx.notify);
|
|
67
67
|
}
|
|
68
68
|
catch (err) {
|
|
69
|
-
ctx.obs.log?.warn(`[
|
|
69
|
+
ctx.obs.log?.warn(`[helpdesk] ${label} failed`, {
|
|
70
70
|
error: err instanceof Error ? err.message : String(err),
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
export async function pickReplyChannels(ctx, reporterUserId) {
|
|
75
75
|
const hasInApp = reporterUserId && (await ctx.hasFeature(IN_APP_FEATURE));
|
|
76
|
-
return hasInApp ?
|
|
76
|
+
return hasInApp ? HELPDESK_REPLY_CHANNELS.EmailAndInApp : HELPDESK_REPLY_CHANNELS.Email;
|
|
77
77
|
}
|
|
78
78
|
export function phoneProblem(mode, phone) {
|
|
79
79
|
const present = phone !== undefined && phone !== "";
|
|
80
80
|
if (mode === "off")
|
|
81
|
-
return present ?
|
|
81
|
+
return present ? HelpdeskErrors.phoneNotAllowed : null;
|
|
82
82
|
if (mode === "required")
|
|
83
|
-
return present ? null :
|
|
83
|
+
return present ? null : HelpdeskErrors.phoneRequired;
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
86
|
export async function loadTenantName(db, tenantId) {
|
|
@@ -101,7 +101,7 @@ export async function loadTenantPlan(ctx, tenantId) {
|
|
|
101
101
|
return typeof tier === "string" && tier !== "" ? planDisplayName(tier) : null;
|
|
102
102
|
}
|
|
103
103
|
catch (err) {
|
|
104
|
-
ctx.obs.log?.warn("[
|
|
104
|
+
ctx.obs.log?.warn("[helpdesk] tenant plan lookup failed", {
|
|
105
105
|
error: err instanceof Error ? err.message : String(err),
|
|
106
106
|
});
|
|
107
107
|
return null;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { type NotificationLocalizedTemplate, type TemplateVariables } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
export type
|
|
3
|
-
export declare function
|
|
2
|
+
export type HelpdeskMailLocale = "en" | "de";
|
|
3
|
+
export declare function resolveHelpdeskMailLocale(locale: string | undefined): HelpdeskMailLocale;
|
|
4
4
|
export declare function truncateText(text: string, maxChars: number): string;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare const
|
|
5
|
+
export declare function helpdeskKindLabel(kind: string, locale: string | undefined): string;
|
|
6
|
+
export declare function formatHelpdeskDate(atEpochMs: number, locale: string | undefined): string;
|
|
7
|
+
export declare const HELPDESK_NEW_REQUEST_VARIABLES: TemplateVariables;
|
|
8
8
|
export type NewRequestMailArgs = {
|
|
9
9
|
readonly kind: string;
|
|
10
10
|
readonly appName: string;
|
|
11
11
|
readonly link: string | undefined;
|
|
12
12
|
readonly locale: string | undefined;
|
|
13
13
|
};
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function helpdeskNewRequestVariables(args: NewRequestMailArgs): {
|
|
15
15
|
subject: string;
|
|
16
16
|
intro: string;
|
|
17
17
|
requestUrl?: string | undefined;
|
|
@@ -20,9 +20,9 @@ export declare function contactNewRequestVariables(args: NewRequestMailArgs): {
|
|
|
20
20
|
telegramTitle: string;
|
|
21
21
|
telegramBody: string;
|
|
22
22
|
};
|
|
23
|
-
export declare function
|
|
24
|
-
export declare const
|
|
25
|
-
export declare function
|
|
23
|
+
export declare function helpdeskNewRequestTemplate(): NotificationLocalizedTemplate;
|
|
24
|
+
export declare const HELPDESK_CONFIRMATION_VARIABLES: TemplateVariables;
|
|
25
|
+
export declare function helpdeskConfirmationVariables(args: {
|
|
26
26
|
readonly appName: string;
|
|
27
27
|
readonly message: string;
|
|
28
28
|
readonly locale: string | undefined;
|
|
@@ -34,18 +34,18 @@ export declare function contactConfirmationVariables(args: {
|
|
|
34
34
|
readonly text: string;
|
|
35
35
|
}[];
|
|
36
36
|
};
|
|
37
|
-
export declare const
|
|
38
|
-
export declare function
|
|
37
|
+
export declare const HELPDESK_ACKNOWLEDGEMENT_VARIABLES: TemplateVariables;
|
|
38
|
+
export declare function helpdeskAcknowledgementVariables(args: {
|
|
39
39
|
readonly appName: string;
|
|
40
40
|
readonly locale: string | undefined;
|
|
41
41
|
}): {
|
|
42
42
|
appName: string;
|
|
43
43
|
intro: string;
|
|
44
44
|
};
|
|
45
|
-
export declare function
|
|
46
|
-
export declare function
|
|
47
|
-
export declare const
|
|
48
|
-
export declare function
|
|
45
|
+
export declare function helpdeskAcknowledgementTemplate(): NotificationLocalizedTemplate;
|
|
46
|
+
export declare function helpdeskConfirmationTemplate(): NotificationLocalizedTemplate;
|
|
47
|
+
export declare const HELPDESK_REPLY_VARIABLES: TemplateVariables;
|
|
48
|
+
export declare function helpdeskReplyVariables(args: {
|
|
49
49
|
readonly requestSubject: string;
|
|
50
50
|
readonly requestMessage: string;
|
|
51
51
|
readonly requestSubmittedAt: number;
|
|
@@ -63,9 +63,9 @@ export declare function contactReplyVariables(args: {
|
|
|
63
63
|
quote: string;
|
|
64
64
|
footer: string;
|
|
65
65
|
};
|
|
66
|
-
export declare function
|
|
67
|
-
export declare const
|
|
68
|
-
export declare function
|
|
66
|
+
export declare function helpdeskReplyTemplate(): NotificationLocalizedTemplate;
|
|
67
|
+
export declare const HELPDESK_TEST_VARIABLES: TemplateVariables;
|
|
68
|
+
export declare function helpdeskTestVariables(args: {
|
|
69
69
|
readonly appName: string;
|
|
70
70
|
readonly locale: string | undefined;
|
|
71
71
|
}): {
|
|
@@ -73,8 +73,8 @@ export declare function contactTestVariables(args: {
|
|
|
73
73
|
telegramTitle: string;
|
|
74
74
|
telegramBody: string;
|
|
75
75
|
};
|
|
76
|
-
export declare function
|
|
77
|
-
export declare function
|
|
76
|
+
export declare function helpdeskTestTemplate(): NotificationLocalizedTemplate;
|
|
77
|
+
export declare function helpdeskReplyInAppData(args: {
|
|
78
78
|
readonly authorName: string;
|
|
79
79
|
readonly locale: string | undefined;
|
|
80
80
|
}): {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { templateVariable, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { mailHeading, mailParagraph, mailParagraphWithLink, mailRepeatedRows, } from "../shared/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { HELPDESK_KIND } from "./web/constants.js";
|
|
4
4
|
const QUOTE_MAX_CHARS = 280;
|
|
5
5
|
function languageOf(locale) {
|
|
6
6
|
return (locale ?? "").split("-")[0]?.toLowerCase() ?? "";
|
|
7
7
|
}
|
|
8
|
-
export function
|
|
8
|
+
export function resolveHelpdeskMailLocale(locale) {
|
|
9
9
|
return languageOf(locale) === "de" ? "de" : "en";
|
|
10
10
|
}
|
|
11
11
|
export function truncateText(text, maxChars) {
|
|
@@ -19,24 +19,24 @@ export function truncateText(text, maxChars) {
|
|
|
19
19
|
}
|
|
20
20
|
const KIND_LABELS = {
|
|
21
21
|
en: {
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
22
|
+
[HELPDESK_KIND.Question]: "Question",
|
|
23
|
+
[HELPDESK_KIND.Contact]: "Contact request",
|
|
24
|
+
[HELPDESK_KIND.Bug]: "Problem",
|
|
25
|
+
[HELPDESK_KIND.Wish]: "Wish",
|
|
26
26
|
},
|
|
27
27
|
de: {
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
28
|
+
[HELPDESK_KIND.Question]: "Frage",
|
|
29
|
+
[HELPDESK_KIND.Contact]: "Kontaktwunsch",
|
|
30
|
+
[HELPDESK_KIND.Bug]: "Problem",
|
|
31
|
+
[HELPDESK_KIND.Wish]: "Wunsch",
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
|
-
export function
|
|
35
|
-
const labels = KIND_LABELS[
|
|
34
|
+
export function helpdeskKindLabel(kind, locale) {
|
|
35
|
+
const labels = KIND_LABELS[resolveHelpdeskMailLocale(locale)];
|
|
36
36
|
return labels[kind] ?? kind;
|
|
37
37
|
}
|
|
38
|
-
export function
|
|
39
|
-
return new Intl.DateTimeFormat(
|
|
38
|
+
export function formatHelpdeskDate(atEpochMs, locale) {
|
|
39
|
+
return new Intl.DateTimeFormat(resolveHelpdeskMailLocale(locale), {
|
|
40
40
|
dateStyle: "long",
|
|
41
41
|
timeZone: "UTC",
|
|
42
42
|
}).format(atEpochMs);
|
|
@@ -54,10 +54,10 @@ const NEW_REQUEST_STRINGS = {
|
|
|
54
54
|
linkIntro: "Open it in the admin:",
|
|
55
55
|
linkLabel: "Show request",
|
|
56
56
|
title: {
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
57
|
+
[HELPDESK_KIND.Question]: (app) => `New question on ${app}`,
|
|
58
|
+
[HELPDESK_KIND.Contact]: (app) => `New contact request on ${app}`,
|
|
59
|
+
[HELPDESK_KIND.Bug]: (app) => `New problem report on ${app}`,
|
|
60
|
+
[HELPDESK_KIND.Wish]: (app) => `New wish on ${app}`,
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
de: {
|
|
@@ -65,21 +65,21 @@ const NEW_REQUEST_STRINGS = {
|
|
|
65
65
|
linkIntro: "Im Admin öffnen:",
|
|
66
66
|
linkLabel: "Meldung anzeigen",
|
|
67
67
|
title: {
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
[
|
|
68
|
+
[HELPDESK_KIND.Question]: (app) => `Neue Frage auf ${app}`,
|
|
69
|
+
[HELPDESK_KIND.Contact]: (app) => `Neuer Kontaktwunsch auf ${app}`,
|
|
70
|
+
[HELPDESK_KIND.Bug]: (app) => `Neue Problemmeldung auf ${app}`,
|
|
71
|
+
[HELPDESK_KIND.Wish]: (app) => `Neuer Wunsch auf ${app}`,
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
-
export const
|
|
75
|
+
export const HELPDESK_NEW_REQUEST_VARIABLES = {
|
|
76
76
|
subject: templateVariable.text({ required: true }),
|
|
77
77
|
intro: templateVariable.text({ required: true }),
|
|
78
78
|
requestUrl: templateVariable.link(),
|
|
79
79
|
};
|
|
80
|
-
export function
|
|
81
|
-
const titles = NEW_REQUEST_STRINGS[
|
|
82
|
-
const title = (titles[args.kind] ?? titles[
|
|
80
|
+
export function helpdeskNewRequestVariables(args) {
|
|
81
|
+
const titles = NEW_REQUEST_STRINGS[resolveHelpdeskMailLocale(args.locale)].title;
|
|
82
|
+
const title = (titles[args.kind] ?? titles[HELPDESK_KIND.Question])?.(args.appName) ?? args.appName;
|
|
83
83
|
return {
|
|
84
84
|
subject: title,
|
|
85
85
|
intro: title,
|
|
@@ -90,7 +90,7 @@ export function contactNewRequestVariables(args) {
|
|
|
90
90
|
telegramBody: args.link ?? args.appName,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
export function
|
|
93
|
+
export function helpdeskNewRequestTemplate() {
|
|
94
94
|
return Object.fromEntries(Object.entries(NEW_REQUEST_STRINGS).map(([locale, t]) => [
|
|
95
95
|
locale,
|
|
96
96
|
{
|
|
@@ -129,14 +129,14 @@ const ACKNOWLEDGEMENT_STRINGS = {
|
|
|
129
129
|
intro: (appName) => `Deine Nachricht ist beim ${appName}-Team angekommen, wir melden uns persönlich bei dir.`,
|
|
130
130
|
},
|
|
131
131
|
};
|
|
132
|
-
export const
|
|
132
|
+
export const HELPDESK_CONFIRMATION_VARIABLES = {
|
|
133
133
|
appName: templateVariable.text({ required: true }),
|
|
134
134
|
intro: templateVariable.text({ required: true }),
|
|
135
135
|
quoteIntro: templateVariable.text({ required: true }),
|
|
136
136
|
paragraphs: templateVariable.list({ text: templateVariable.text({ required: true }) }, { required: true }),
|
|
137
137
|
};
|
|
138
|
-
export function
|
|
139
|
-
const t = CONFIRMATION_STRINGS[
|
|
138
|
+
export function helpdeskConfirmationVariables(args) {
|
|
139
|
+
const t = CONFIRMATION_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
140
140
|
return {
|
|
141
141
|
appName: args.appName,
|
|
142
142
|
intro: t.intro(args.appName),
|
|
@@ -146,15 +146,15 @@ export function contactConfirmationVariables(args) {
|
|
|
146
146
|
}
|
|
147
147
|
// Website senders are unverified addresses: the mail must not echo anything they typed, or the
|
|
148
148
|
// form becomes a mail relay. Only the signed-in admin report gets the copy above.
|
|
149
|
-
export const
|
|
149
|
+
export const HELPDESK_ACKNOWLEDGEMENT_VARIABLES = {
|
|
150
150
|
appName: templateVariable.text({ required: true }),
|
|
151
151
|
intro: templateVariable.text({ required: true }),
|
|
152
152
|
};
|
|
153
|
-
export function
|
|
154
|
-
const t = ACKNOWLEDGEMENT_STRINGS[
|
|
153
|
+
export function helpdeskAcknowledgementVariables(args) {
|
|
154
|
+
const t = ACKNOWLEDGEMENT_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
155
155
|
return { appName: args.appName, intro: t.intro(args.appName) };
|
|
156
156
|
}
|
|
157
|
-
export function
|
|
157
|
+
export function helpdeskAcknowledgementTemplate() {
|
|
158
158
|
return Object.fromEntries(Object.entries(ACKNOWLEDGEMENT_STRINGS).map(([locale, t]) => [
|
|
159
159
|
locale,
|
|
160
160
|
{
|
|
@@ -163,7 +163,7 @@ export function contactAcknowledgementTemplate() {
|
|
|
163
163
|
},
|
|
164
164
|
]));
|
|
165
165
|
}
|
|
166
|
-
export function
|
|
166
|
+
export function helpdeskConfirmationTemplate() {
|
|
167
167
|
return Object.fromEntries(Object.entries(CONFIRMATION_STRINGS).map(([locale, t]) => [
|
|
168
168
|
locale,
|
|
169
169
|
{
|
|
@@ -187,7 +187,7 @@ const REPLY_STRINGS = {
|
|
|
187
187
|
quoteIntro: (date) => `Deine Meldung vom ${date}:`,
|
|
188
188
|
},
|
|
189
189
|
};
|
|
190
|
-
export const
|
|
190
|
+
export const HELPDESK_REPLY_VARIABLES = {
|
|
191
191
|
subject: templateVariable.text({ required: true }),
|
|
192
192
|
paragraphs: templateVariable.list({ text: templateVariable.text({ required: true }) }, { required: true }),
|
|
193
193
|
signedBy: templateVariable.text({ required: true }),
|
|
@@ -195,18 +195,18 @@ export const CONTACT_REPLY_VARIABLES = {
|
|
|
195
195
|
quote: templateVariable.text({ required: true }),
|
|
196
196
|
footer: templateVariable.text({ required: true }),
|
|
197
197
|
};
|
|
198
|
-
export function
|
|
199
|
-
const t = REPLY_STRINGS[
|
|
198
|
+
export function helpdeskReplyVariables(args) {
|
|
199
|
+
const t = REPLY_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
200
200
|
return {
|
|
201
201
|
subject: `Re: ${args.requestSubject}`,
|
|
202
202
|
paragraphs: toParagraphRows(args.replyMessage),
|
|
203
203
|
signedBy: `${args.authorName}, ${args.appName}`,
|
|
204
|
-
quoteIntro: t.quoteIntro(
|
|
204
|
+
quoteIntro: t.quoteIntro(formatHelpdeskDate(args.requestSubmittedAt, args.locale)),
|
|
205
205
|
quote: truncateText(args.requestMessage.replace(/\s+/g, " "), QUOTE_MAX_CHARS),
|
|
206
206
|
footer: t.footer,
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
export function
|
|
209
|
+
export function helpdeskReplyTemplate() {
|
|
210
210
|
return Object.fromEntries(Object.keys(REPLY_STRINGS).map((locale) => [
|
|
211
211
|
locale,
|
|
212
212
|
{
|
|
@@ -225,7 +225,7 @@ const TEST_STRINGS = {
|
|
|
225
225
|
en: {
|
|
226
226
|
subject: "Test message from {{appName}}",
|
|
227
227
|
header: "Test message",
|
|
228
|
-
intro: "This is a test message of the
|
|
228
|
+
intro: "This is a test message of the helpdesk forwarding.",
|
|
229
229
|
},
|
|
230
230
|
de: {
|
|
231
231
|
subject: "Testnachricht von {{appName}}",
|
|
@@ -233,18 +233,18 @@ const TEST_STRINGS = {
|
|
|
233
233
|
intro: "Das ist eine Testnachricht der Weiterleitung von Meldungen.",
|
|
234
234
|
},
|
|
235
235
|
};
|
|
236
|
-
export const
|
|
236
|
+
export const HELPDESK_TEST_VARIABLES = {
|
|
237
237
|
appName: templateVariable.text({ required: true }),
|
|
238
238
|
};
|
|
239
|
-
export function
|
|
240
|
-
const t = TEST_STRINGS[
|
|
239
|
+
export function helpdeskTestVariables(args) {
|
|
240
|
+
const t = TEST_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
241
241
|
return {
|
|
242
242
|
appName: args.appName,
|
|
243
243
|
telegramTitle: t.subject.replace("{{appName}}", args.appName),
|
|
244
244
|
telegramBody: t.intro,
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
-
export function
|
|
247
|
+
export function helpdeskTestTemplate() {
|
|
248
248
|
return Object.fromEntries(Object.entries(TEST_STRINGS).map(([locale, t]) => [
|
|
249
249
|
locale,
|
|
250
250
|
{
|
|
@@ -263,8 +263,8 @@ const REPLY_IN_APP_STRINGS = {
|
|
|
263
263
|
body: `${authorName} hat geantwortet. Die Antwort liegt in deinem Postfach.`,
|
|
264
264
|
}),
|
|
265
265
|
};
|
|
266
|
-
export function
|
|
267
|
-
const copy = REPLY_IN_APP_STRINGS[
|
|
266
|
+
export function helpdeskReplyInAppData(args) {
|
|
267
|
+
const copy = REPLY_IN_APP_STRINGS[resolveHelpdeskMailLocale(args.locale)](args.authorName);
|
|
268
268
|
return { inAppTitle: copy.title, inAppBody: copy.body };
|
|
269
269
|
}
|
|
270
270
|
function stringField(data, key) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PayloadRateLimitOption, RateLimitDeclaration, RateLimitOption } from "@cosmicdrift/kumiko-types/handlers";
|
|
2
|
-
import { type
|
|
3
|
-
export type
|
|
2
|
+
import { type HelpdeskPhoneMode } from "./web/constants.ts";
|
|
3
|
+
export type HelpdeskOptions = {
|
|
4
4
|
/** Name shown in the notification mails ("Testnachricht von <appName>") and in the hint of the report form. */
|
|
5
5
|
readonly appName: string;
|
|
6
6
|
/** Default { phone: "off" }. Controls both the public form (challenge query reports it) and the admin report form. */
|
|
7
7
|
readonly fields?: {
|
|
8
|
-
readonly phone?:
|
|
8
|
+
readonly phone?: HelpdeskPhoneMode;
|
|
9
9
|
};
|
|
10
10
|
/** Shown as "Version" in the request origin; omitted when unset. */
|
|
11
11
|
readonly appVersion?: string;
|
|
@@ -42,10 +42,10 @@ export declare const REPORT_RATE_LIMIT: RateLimitOption;
|
|
|
42
42
|
export declare const CHALLENGE_RATE_LIMIT: RateLimitOption;
|
|
43
43
|
export declare const DEFAULT_SUBMIT_EMAIL_RATE_LIMITS: readonly PayloadRateLimitOption[];
|
|
44
44
|
export declare const DEFAULT_RETENTION_KEEP_FOR = "365d";
|
|
45
|
-
export type
|
|
46
|
-
readonly phone:
|
|
45
|
+
export type HelpdeskSettings = {
|
|
46
|
+
readonly phone: HelpdeskPhoneMode;
|
|
47
47
|
readonly proofOfWorkBits: number;
|
|
48
48
|
readonly minSubmitMs: number;
|
|
49
49
|
readonly challengeTtlSeconds: number;
|
|
50
50
|
};
|
|
51
|
-
export declare function
|
|
51
|
+
export declare function resolveHelpdeskSettings(opts: HelpdeskOptions): HelpdeskSettings;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { HELPDESK_BOOT_RULES } from "./boot-rules.js";
|
|
3
|
+
import { HELPDESK_DEFAULT_CHALLENGE_TTL_MINUTES, HELPDESK_DEFAULT_MIN_SUBMIT_SECONDS, HELPDESK_POW_BITS, } from "./web/constants.js";
|
|
4
|
+
export const DEFAULT_SUBMIT_RATE_LIMIT = {
|
|
5
|
+
per: "ip+handler",
|
|
6
|
+
limit: 5,
|
|
7
|
+
windowSeconds: 10 * 60,
|
|
8
|
+
};
|
|
9
|
+
export const REPORT_RATE_LIMIT = {
|
|
10
|
+
per: "user+handler",
|
|
11
|
+
limit: 10,
|
|
12
|
+
windowSeconds: 60 * 60,
|
|
13
|
+
};
|
|
14
|
+
export const CHALLENGE_RATE_LIMIT = {
|
|
15
|
+
per: "ip+handler",
|
|
16
|
+
limit: 30,
|
|
17
|
+
windowSeconds: 10 * 60,
|
|
18
|
+
};
|
|
19
|
+
export const DEFAULT_SUBMIT_EMAIL_RATE_LIMITS = [
|
|
20
|
+
{ per: { payloadField: "email" }, limit: 3, windowSeconds: 24 * 60 * 60, normalize: "email" },
|
|
21
|
+
];
|
|
22
|
+
export const DEFAULT_RETENTION_KEEP_FOR = "365d";
|
|
23
|
+
export function resolveHelpdeskSettings(opts) {
|
|
24
|
+
const bits = opts.spamProtection?.proofOfWorkBits ?? HELPDESK_POW_BITS.default;
|
|
25
|
+
if (!Number.isInteger(bits) || bits < HELPDESK_POW_BITS.min || bits > HELPDESK_POW_BITS.max) {
|
|
26
|
+
throw bootRuleError(HELPDESK_BOOT_RULES.invalidProofOfWorkBits, {
|
|
27
|
+
message: `helpdesk: spamProtection.proofOfWorkBits must be an integer between ${HELPDESK_POW_BITS.min} and ${HELPDESK_POW_BITS.max}, got ${bits}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
phone: opts.fields?.phone ?? "off",
|
|
32
|
+
proofOfWorkBits: bits,
|
|
33
|
+
minSubmitMs: (opts.spamProtection?.minSubmitSeconds ?? HELPDESK_DEFAULT_MIN_SUBMIT_SECONDS) * 1000,
|
|
34
|
+
challengeTtlSeconds: (opts.spamProtection?.challengeTtlMinutes ?? HELPDESK_DEFAULT_CHALLENGE_TTL_MINUTES) * 60,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HELPDESK_FEATURE, HELPDESK_STATUS, HelpdeskQueries, HelpdeskScreens, } from "./web/constants.js";
|
|
2
|
+
// Stat tile for a dashboard: how many contact requests still wait for a first answer.
|
|
3
|
+
export function helpdeskOpenRequestsPanels() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
kind: "stat",
|
|
7
|
+
id: `${HELPDESK_FEATURE}-open-requests`,
|
|
8
|
+
label: "helpdesk:overview.open",
|
|
9
|
+
query: HelpdeskQueries.requestList,
|
|
10
|
+
params: {
|
|
11
|
+
filters: [{ field: "status", op: "eq", value: HELPDESK_STATUS.Open }],
|
|
12
|
+
limit: 1,
|
|
13
|
+
totalCount: true,
|
|
14
|
+
},
|
|
15
|
+
ignoreScreenFilter: true,
|
|
16
|
+
valueField: "total",
|
|
17
|
+
tone: "warn",
|
|
18
|
+
navigate: { screen: HelpdeskScreens.requestList },
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const HelpdeskSubmitSchema: z.ZodObject<{
|
|
3
3
|
kind: z.ZodEnum<{
|
|
4
4
|
bug: "bug";
|
|
5
5
|
contact: "contact";
|
|
@@ -15,8 +15,8 @@ export declare const ContactSubmitSchema: z.ZodObject<{
|
|
|
15
15
|
nonce: z.ZodString;
|
|
16
16
|
page: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
17
17
|
}, z.core.$strict>;
|
|
18
|
-
export type
|
|
19
|
-
export declare const
|
|
18
|
+
export type HelpdeskSubmitInput = z.infer<typeof HelpdeskSubmitSchema>;
|
|
19
|
+
export declare const HelpdeskReportSchema: z.ZodObject<{
|
|
20
20
|
kind: z.ZodEnum<{
|
|
21
21
|
bug: "bug";
|
|
22
22
|
question: "question";
|
|
@@ -27,30 +27,30 @@ export declare const ContactReportSchema: z.ZodObject<{
|
|
|
27
27
|
phone: z.ZodOptional<z.ZodString>;
|
|
28
28
|
fileIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
29
29
|
}, z.core.$strict>;
|
|
30
|
-
export type
|
|
31
|
-
export declare const
|
|
30
|
+
export type HelpdeskReportInput = z.infer<typeof HelpdeskReportSchema>;
|
|
31
|
+
export declare const HelpdeskIdSchema: z.ZodObject<{
|
|
32
32
|
id: z.ZodUUID;
|
|
33
33
|
}, z.core.$strict>;
|
|
34
|
-
export declare const
|
|
34
|
+
export declare const HelpdeskReplySchema: z.ZodObject<{
|
|
35
35
|
requestId: z.ZodUUID;
|
|
36
36
|
message: z.ZodString;
|
|
37
37
|
fileIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
38
38
|
markDone: z.ZodDefault<z.ZodBoolean>;
|
|
39
39
|
}, z.core.$strict>;
|
|
40
|
-
export declare const
|
|
40
|
+
export declare const HelpdeskMarkDoneSchema: z.ZodObject<{
|
|
41
41
|
id: z.ZodUUID;
|
|
42
42
|
}, z.core.$strict>;
|
|
43
|
-
export declare const
|
|
43
|
+
export declare const HelpdeskForwardRequestSchema: z.ZodObject<{
|
|
44
44
|
requestId: z.ZodUUID;
|
|
45
45
|
}, z.core.$strict>;
|
|
46
|
-
export declare const
|
|
46
|
+
export declare const HelpdeskSendReplyMailSchema: z.ZodObject<{
|
|
47
47
|
replyId: z.ZodUUID;
|
|
48
48
|
}, z.core.$strict>;
|
|
49
|
-
export declare const
|
|
49
|
+
export declare const HelpdeskNotifyReporterInAppSchema: z.ZodObject<{
|
|
50
50
|
replyId: z.ZodUUID;
|
|
51
51
|
requestId: z.ZodUUID;
|
|
52
52
|
userId: z.ZodUUID;
|
|
53
53
|
authorName: z.ZodString;
|
|
54
54
|
locale: z.ZodOptional<z.ZodString>;
|
|
55
55
|
}, z.core.$strict>;
|
|
56
|
-
export declare const
|
|
56
|
+
export declare const HelpdeskEmptySchema: z.ZodObject<{}, z.core.$strict>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { canonicalizeLocaleTag, isValidLocaleTag } from "@cosmicdrift/kumiko-framework/i18n";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { HELPDESK_ADMIN_KINDS, HELPDESK_FIELD_LIMITS, HELPDESK_MAX_FILES, HELPDESK_WEBSITE_KINDS, } from "./web/constants.js";
|
|
4
4
|
// Submitted text lands in mail subjects; CR/LF there would allow header injection.
|
|
5
5
|
const NO_CONTROL_CHARS = /^\P{Cc}*$/u;
|
|
6
6
|
const NO_CONTROL_CHARS_EXCEPT_WHITESPACE = /^(?:[^\p{Cc}]|[\n\r\t])*$/u;
|
|
@@ -17,13 +17,13 @@ const multiLine = (max) => z
|
|
|
17
17
|
const phone = z
|
|
18
18
|
.string()
|
|
19
19
|
.trim()
|
|
20
|
-
.max(
|
|
20
|
+
.max(HELPDESK_FIELD_LIMITS.phone)
|
|
21
21
|
.refine(noControlChars, CONTROL_CHARS_MESSAGE)
|
|
22
22
|
.optional();
|
|
23
23
|
const pagePath = z
|
|
24
24
|
.string()
|
|
25
25
|
.trim()
|
|
26
|
-
.max(
|
|
26
|
+
.max(HELPDESK_FIELD_LIMITS.page)
|
|
27
27
|
.refine(noControlChars, CONTROL_CHARS_MESSAGE)
|
|
28
28
|
// Query strings and fragments carry tokens and ids (reset links, session hints) that must not
|
|
29
29
|
// end up in an inbox that is kept for a year.
|
|
@@ -31,52 +31,52 @@ const pagePath = z
|
|
|
31
31
|
.optional();
|
|
32
32
|
const locale = z
|
|
33
33
|
.string()
|
|
34
|
-
.max(
|
|
34
|
+
.max(HELPDESK_FIELD_LIMITS.locale)
|
|
35
35
|
.refine(isValidLocaleTag, "invalid locale tag")
|
|
36
36
|
.transform(canonicalizeLocaleTag);
|
|
37
|
-
export const
|
|
37
|
+
export const HelpdeskSubmitSchema = z
|
|
38
38
|
.object({
|
|
39
|
-
kind: z.enum(
|
|
40
|
-
name: singleLine(
|
|
41
|
-
email: z.email().max(
|
|
39
|
+
kind: z.enum(HELPDESK_WEBSITE_KINDS),
|
|
40
|
+
name: singleLine(HELPDESK_FIELD_LIMITS.name),
|
|
41
|
+
email: z.email().max(HELPDESK_FIELD_LIMITS.email),
|
|
42
42
|
phone,
|
|
43
|
-
message: multiLine(
|
|
43
|
+
message: multiLine(HELPDESK_FIELD_LIMITS.message),
|
|
44
44
|
locale,
|
|
45
45
|
// Honeypot: bots fill it, humans leave it empty.
|
|
46
|
-
website: z.string().max(
|
|
47
|
-
challenge: z.string().max(
|
|
48
|
-
nonce: z.string().max(
|
|
46
|
+
website: z.string().max(HELPDESK_FIELD_LIMITS.honeypot).optional(),
|
|
47
|
+
challenge: z.string().max(HELPDESK_FIELD_LIMITS.challenge),
|
|
48
|
+
nonce: z.string().max(HELPDESK_FIELD_LIMITS.nonce),
|
|
49
49
|
page: pagePath,
|
|
50
50
|
})
|
|
51
51
|
.strict();
|
|
52
|
-
export const
|
|
52
|
+
export const HelpdeskReportSchema = z
|
|
53
53
|
.object({
|
|
54
|
-
kind: z.enum(
|
|
55
|
-
subject: singleLine(
|
|
56
|
-
message: multiLine(
|
|
54
|
+
kind: z.enum(HELPDESK_ADMIN_KINDS),
|
|
55
|
+
subject: singleLine(HELPDESK_FIELD_LIMITS.subject),
|
|
56
|
+
message: multiLine(HELPDESK_FIELD_LIMITS.message),
|
|
57
57
|
phone,
|
|
58
|
-
fileIds: z.array(z.uuid()).max(
|
|
58
|
+
fileIds: z.array(z.uuid()).max(HELPDESK_MAX_FILES).optional(),
|
|
59
59
|
})
|
|
60
60
|
.strict();
|
|
61
|
-
export const
|
|
62
|
-
export const
|
|
61
|
+
export const HelpdeskIdSchema = z.object({ id: z.uuid() }).strict();
|
|
62
|
+
export const HelpdeskReplySchema = z
|
|
63
63
|
.object({
|
|
64
64
|
requestId: z.uuid(),
|
|
65
|
-
message: multiLine(
|
|
66
|
-
fileIds: z.array(z.uuid()).max(
|
|
65
|
+
message: multiLine(HELPDESK_FIELD_LIMITS.message),
|
|
66
|
+
fileIds: z.array(z.uuid()).max(HELPDESK_MAX_FILES).optional(),
|
|
67
67
|
markDone: z.boolean().default(false),
|
|
68
68
|
})
|
|
69
69
|
.strict();
|
|
70
|
-
export const
|
|
71
|
-
export const
|
|
72
|
-
export const
|
|
73
|
-
export const
|
|
70
|
+
export const HelpdeskMarkDoneSchema = HelpdeskIdSchema;
|
|
71
|
+
export const HelpdeskForwardRequestSchema = z.object({ requestId: z.uuid() }).strict();
|
|
72
|
+
export const HelpdeskSendReplyMailSchema = z.object({ replyId: z.uuid() }).strict();
|
|
73
|
+
export const HelpdeskNotifyReporterInAppSchema = z
|
|
74
74
|
.object({
|
|
75
75
|
replyId: z.uuid(),
|
|
76
76
|
requestId: z.uuid(),
|
|
77
77
|
userId: z.uuid(),
|
|
78
|
-
authorName: z.string().max(
|
|
79
|
-
locale: z.string().max(
|
|
78
|
+
authorName: z.string().max(HELPDESK_FIELD_LIMITS.name),
|
|
79
|
+
locale: z.string().max(HELPDESK_FIELD_LIMITS.locale).optional(),
|
|
80
80
|
})
|
|
81
81
|
.strict();
|
|
82
|
-
export const
|
|
82
|
+
export const HelpdeskEmptySchema = z.object({}).strict();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { HelpdeskOptions, HelpdeskSettings } from "./options.ts";
|
|
3
|
+
export declare const REPORT_FIELD_LABEL: string;
|
|
4
|
+
export declare const REPLY_FIELD_LABEL: string;
|
|
5
|
+
export declare function createHelpdeskScreens(opts: HelpdeskOptions, settings: HelpdeskSettings): readonly ScreenDefinition[];
|