@cosmicdrift/kumiko-samples 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/package.json +1 -1
- package/packages/bundled-features/package.json +13 -13
- package/packages/bundled-features/src/admin-shell/feature.ts +1 -1
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +64 -3
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +13 -130
- package/packages/bundled-features/src/agent-tools/api-docs/anchors.ts +60 -0
- package/packages/bundled-features/src/agent-tools/api-docs/check.ts +25 -0
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +140 -0
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +175 -0
- package/packages/bundled-features/src/agent-tools/api-docs/curl.ts +28 -0
- package/packages/bundled-features/src/agent-tools/api-docs/error-table.ts +45 -0
- package/packages/bundled-features/src/agent-tools/api-docs/examples.ts +43 -0
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +179 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index-json.ts +29 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +21 -0
- package/packages/bundled-features/src/agent-tools/api-docs/list-parameters.ts +38 -0
- package/packages/bundled-features/src/agent-tools/api-docs/markdown.ts +70 -0
- package/packages/bundled-features/src/agent-tools/api-docs/menu-path.ts +82 -0
- package/packages/bundled-features/src/agent-tools/api-docs/model.ts +83 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +58 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-events.ts +76 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +216 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-overview.ts +86 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-reference.ts +79 -0
- package/packages/bundled-features/src/agent-tools/api-docs/render-tokens.ts +136 -0
- package/packages/bundled-features/src/agent-tools/api-docs/schema-fields.ts +167 -0
- package/packages/bundled-features/src/agent-tools/api-docs/section-ids.ts +28 -0
- package/packages/bundled-features/src/agent-tools/api-docs/system-only.ts +11 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/de.ts +166 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/en.ts +159 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/es.ts +162 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/fr.ts +169 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/index.ts +67 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/it.ts +165 -0
- package/packages/bundled-features/src/agent-tools/api-docs/texts/types.ts +130 -0
- package/packages/bundled-features/src/agent-tools/api-docs/ui-writes.ts +81 -0
- package/packages/bundled-features/src/agent-tools/changes.json +24 -0
- package/packages/bundled-features/src/agent-tools/handler-schema.ts +45 -0
- package/packages/bundled-features/src/agent-tools/index.ts +24 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +181 -0
- package/packages/bundled-features/src/auth-email-password/boot-rules.ts +9 -0
- package/packages/bundled-features/src/auth-email-password/feature.ts +6 -19
- package/packages/bundled-features/src/auth-email-password/validate-options.ts +20 -0
- package/packages/bundled-features/src/billing-foundation/boot-rules.ts +26 -0
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +59 -46
- package/packages/bundled-features/src/cap-overview/boot-rules.ts +14 -0
- package/packages/bundled-features/src/cap-overview/feature.ts +12 -5
- package/packages/bundled-features/src/documents/boot-rules.ts +14 -0
- package/packages/bundled-features/src/documents/feature.ts +8 -4
- package/packages/bundled-features/src/file-derivatives/boot-rules.ts +9 -0
- package/packages/bundled-features/src/file-derivatives/feature.ts +6 -3
- package/packages/bundled-features/src/folders/boot-rules.ts +9 -0
- package/packages/bundled-features/src/folders/feature.ts +6 -3
- package/packages/bundled-features/src/helpdesk/boot-rules.ts +9 -0
- package/packages/bundled-features/src/{contact → helpdesk}/challenge.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/changes.json +6 -0
- package/packages/bundled-features/src/{contact/client/contact-client-source.ts → helpdesk/client/helpdesk-client-source.ts} +4 -4
- package/packages/bundled-features/src/helpdesk/client/helpdesk-website-client.ts +29 -0
- package/packages/bundled-features/src/helpdesk/client/index.ts +9 -0
- package/packages/bundled-features/src/{contact → helpdesk}/entity.ts +35 -31
- package/packages/bundled-features/src/{contact → helpdesk}/feature.ts +56 -52
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/attempts.ts +3 -3
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/challenge.query.ts +10 -10
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/forward-request.write.ts +25 -23
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/mark-done.write.ts +11 -11
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/notify-reporter-in-app.write.ts +14 -14
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.query.ts +4 -4
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/replies.query.ts +6 -6
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/reply.write.ts +30 -30
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/report.write.ts +29 -29
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-delivery.query.ts +40 -40
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-detail.query.ts +15 -15
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-list.query.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-reply-mail.write.ts +24 -24
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-test.write.ts +18 -14
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/submit.write.ts +32 -31
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/take-over-uploads.ts +5 -5
- package/packages/bundled-features/src/{contact → helpdesk}/i18n.ts +78 -75
- package/packages/bundled-features/src/helpdesk/index.ts +29 -0
- package/packages/bundled-features/src/{contact → helpdesk}/lib.ts +32 -28
- package/packages/bundled-features/src/{contact → helpdesk}/mail.ts +56 -56
- package/packages/bundled-features/src/{contact → helpdesk}/options.ts +18 -16
- package/packages/bundled-features/src/helpdesk/panels.ts +28 -0
- package/packages/bundled-features/src/{contact → helpdesk}/payloads.ts +33 -33
- package/packages/bundled-features/src/{contact → helpdesk}/screens.ts +104 -104
- package/packages/bundled-features/src/{contact → helpdesk}/subject.ts +3 -3
- package/packages/bundled-features/src/{contact → helpdesk}/user-data-hooks.ts +17 -17
- package/packages/bundled-features/src/helpdesk/web/constants.ts +160 -0
- package/packages/bundled-features/src/helpdesk/web/index.ts +29 -0
- package/packages/bundled-features/src/host-routing/boot-rules.ts +27 -0
- package/packages/bundled-features/src/host-routing/validate-options.ts +36 -27
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +99 -71
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +2 -2
- package/packages/bundled-features/src/jobs/boot-rules.ts +9 -0
- package/packages/bundled-features/src/jobs/feature.ts +9 -4
- package/packages/bundled-features/src/legal-pages/boot-rules.ts +19 -0
- package/packages/bundled-features/src/legal-pages/feature.ts +6 -3
- package/packages/bundled-features/src/legal-pages/lib/validate-routes.ts +11 -5
- package/packages/bundled-features/src/metrics/boot-rules.ts +15 -0
- package/packages/bundled-features/src/metrics/validate.ts +8 -2
- package/packages/bundled-features/src/notes-history/boot-rules.ts +9 -0
- package/packages/bundled-features/src/notes-history/feature.ts +6 -3
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +9 -0
- package/packages/bundled-features/src/personal-access-tokens/changes.json +6 -0
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -2
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +7 -2
- package/packages/bundled-features/src/personal-access-tokens/i18n.ts +6 -1
- package/packages/bundled-features/src/personal-access-tokens/index.ts +37 -2
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -0
- package/packages/bundled-features/src/personal-access-tokens/screens.ts +9 -1
- package/packages/bundled-features/src/personal-access-tokens/web/constants.ts +1 -0
- package/packages/bundled-features/src/personal-access-tokens/web/scopes.ts +14 -0
- package/packages/bundled-features/src/presence/boot-rules.ts +9 -0
- package/packages/bundled-features/src/presence/options.ts +5 -1
- package/packages/bundled-features/src/readiness/boot-rules.ts +14 -0
- package/packages/bundled-features/src/readiness/probe-boot-check.ts +8 -6
- package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +6 -4
- package/packages/bundled-features/src/shared/boot-rules.ts +9 -0
- package/packages/bundled-features/src/subscription-mollie/boot-rules.ts +19 -0
- package/packages/bundled-features/src/subscription-mollie/feature.ts +18 -10
- package/packages/bundled-features/src/tags/boot-rules.ts +9 -0
- package/packages/bundled-features/src/tags/feature.ts +6 -3
- package/packages/bundled-features/src/template-resolver/boot-rules.ts +19 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +14 -10
- package/packages/bundled-features/src/tenant/boot-rules.ts +9 -0
- package/packages/bundled-features/src/tenant/feature.ts +5 -3
- package/samples/apps/marketing-demo/README.md +1 -1
- package/samples/apps/marketing-demo/playwright.config.ts +1 -1
- package/samples/apps/marketing-demo/src/app/client.tsx +3 -3
- package/samples/apps/marketing-demo/src/app/seed-data.ts +1 -1
- package/samples/apps/marketing-demo/src/app/seed.ts +4 -4
- package/samples/apps/marketing-demo/src/app/server.ts +3 -3
- package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/feature.ts +15 -12
- package/samples/apps/marketing-demo/src/features/ticketing/i18n.ts +100 -0
- package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/ticket.ts +4 -4
- package/samples/apps/marketing-demo/src/features/ticketing/web/index.ts +7 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +67 -67
- package/samples/apps/use-all-bundled/kumiko/migrations/0064_helpdesk-rename.rebuild.json +4 -0
- package/samples/apps/use-all-bundled/package.json +1 -1
- package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
- package/samples/apps/use-all-bundled/src/app/screens-feature.ts +10 -10
- package/samples/apps/use-all-bundled/src/run-config.ts +6 -6
- package/samples/recipes/api-docs/README.md +52 -0
- package/samples/recipes/api-docs/api-docs/de/events.md +62 -0
- package/samples/recipes/api-docs/api-docs/de/overview.md +100 -0
- package/samples/recipes/api-docs/api-docs/de/reference/tickets.md +305 -0
- package/samples/recipes/api-docs/api-docs/de/tokens.md +66 -0
- package/samples/recipes/api-docs/api-docs/en/events.md +62 -0
- package/samples/recipes/api-docs/api-docs/en/overview.md +100 -0
- package/samples/recipes/api-docs/api-docs/en/reference/tickets.md +305 -0
- package/samples/recipes/api-docs/api-docs/en/tokens.md +66 -0
- package/samples/recipes/api-docs/api-docs/index.json +371 -0
- package/samples/recipes/api-docs/api-docs/openapi.json +982 -0
- package/samples/recipes/api-docs/api-examples/ticket-close.json +21 -0
- package/samples/recipes/api-docs/api-examples/ticket-create.json +42 -0
- package/samples/recipes/api-docs/api-examples/ticket-detail.json +28 -0
- package/samples/recipes/api-docs/api-examples/ticket-list.json +31 -0
- package/samples/recipes/api-docs/api-examples/ticket-update.json +54 -0
- package/samples/recipes/api-docs/api-examples/webhooks/ticket-closed.json +8 -0
- package/samples/recipes/api-docs/api-examples/webhooks/ticket-created.json +10 -0
- package/samples/recipes/api-docs/kumiko.config.ts +33 -0
- package/samples/recipes/api-docs/package.json +14 -0
- package/samples/recipes/api-docs/src/feature.ts +218 -0
- package/samples/recipes/api-docs/tsconfig.json +22 -0
- package/samples/recipes/golden-path/src/feature.ts +1 -1
- package/samples/recipes/{contact → helpdesk}/README.md +16 -16
- package/samples/recipes/{contact → helpdesk}/package.json +2 -2
- package/samples/recipes/{contact → helpdesk}/src/feature.ts +6 -6
- package/packages/bundled-features/src/contact/client/contact-website-client.ts +0 -29
- package/packages/bundled-features/src/contact/client/index.ts +0 -9
- package/packages/bundled-features/src/contact/index.ts +0 -29
- package/packages/bundled-features/src/contact/panels.ts +0 -28
- package/packages/bundled-features/src/contact/web/constants.ts +0 -160
- package/packages/bundled-features/src/contact/web/index.ts +0 -29
- package/samples/apps/marketing-demo/src/features/helpdesk/i18n.ts +0 -100
- package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +0 -7
- /package/packages/bundled-features/src/{contact → helpdesk}/handlers/access.ts +0 -0
- /package/packages/bundled-features/src/{contact → helpdesk}/pow.ts +0 -0
- /package/packages/bundled-features/src/{contact → helpdesk}/user-agent.ts +0 -0
- /package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/index.ts +0 -0
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
mailParagraphWithLink,
|
|
10
10
|
mailRepeatedRows,
|
|
11
11
|
} from "../shared/index.ts";
|
|
12
|
-
import {
|
|
12
|
+
import { HELPDESK_KIND, type HelpdeskKind } from "./web/constants.ts";
|
|
13
13
|
|
|
14
|
-
export type
|
|
14
|
+
export type HelpdeskMailLocale = "en" | "de";
|
|
15
15
|
|
|
16
16
|
const QUOTE_MAX_CHARS = 280;
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ function languageOf(locale: string | undefined): string {
|
|
|
19
19
|
return (locale ?? "").split("-")[0]?.toLowerCase() ?? "";
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function
|
|
22
|
+
export function resolveHelpdeskMailLocale(locale: string | undefined): HelpdeskMailLocale {
|
|
23
23
|
return languageOf(locale) === "de" ? "de" : "en";
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -33,28 +33,28 @@ export function truncateText(text: string, maxChars: number): string {
|
|
|
33
33
|
.trimEnd()}…`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const KIND_LABELS: Readonly<Record<
|
|
36
|
+
const KIND_LABELS: Readonly<Record<HelpdeskMailLocale, Readonly<Record<HelpdeskKind, string>>>> = {
|
|
37
37
|
en: {
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
38
|
+
[HELPDESK_KIND.Question]: "Question",
|
|
39
|
+
[HELPDESK_KIND.Contact]: "Contact request",
|
|
40
|
+
[HELPDESK_KIND.Bug]: "Problem",
|
|
41
|
+
[HELPDESK_KIND.Wish]: "Wish",
|
|
42
42
|
},
|
|
43
43
|
de: {
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
44
|
+
[HELPDESK_KIND.Question]: "Frage",
|
|
45
|
+
[HELPDESK_KIND.Contact]: "Kontaktwunsch",
|
|
46
|
+
[HELPDESK_KIND.Bug]: "Problem",
|
|
47
|
+
[HELPDESK_KIND.Wish]: "Wunsch",
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export function
|
|
52
|
-
const labels: Readonly<Record<string, string>> = KIND_LABELS[
|
|
51
|
+
export function helpdeskKindLabel(kind: string, locale: string | undefined): string {
|
|
52
|
+
const labels: Readonly<Record<string, string>> = KIND_LABELS[resolveHelpdeskMailLocale(locale)];
|
|
53
53
|
return labels[kind] ?? kind;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function
|
|
57
|
-
return new Intl.DateTimeFormat(
|
|
56
|
+
export function formatHelpdeskDate(atEpochMs: number, locale: string | undefined): string {
|
|
57
|
+
return new Intl.DateTimeFormat(resolveHelpdeskMailLocale(locale), {
|
|
58
58
|
dateStyle: "long",
|
|
59
59
|
timeZone: "UTC",
|
|
60
60
|
}).format(atEpochMs);
|
|
@@ -74,19 +74,19 @@ type NewRequestStrings = {
|
|
|
74
74
|
readonly header: string;
|
|
75
75
|
readonly linkIntro: string;
|
|
76
76
|
readonly linkLabel: string;
|
|
77
|
-
readonly title: Readonly<Record<
|
|
77
|
+
readonly title: Readonly<Record<HelpdeskKind, (appName: string) => string>>;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const NEW_REQUEST_STRINGS: Readonly<Record<
|
|
80
|
+
const NEW_REQUEST_STRINGS: Readonly<Record<HelpdeskMailLocale, NewRequestStrings>> = {
|
|
81
81
|
en: {
|
|
82
82
|
header: "New request",
|
|
83
83
|
linkIntro: "Open it in the admin:",
|
|
84
84
|
linkLabel: "Show request",
|
|
85
85
|
title: {
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
86
|
+
[HELPDESK_KIND.Question]: (app) => `New question on ${app}`,
|
|
87
|
+
[HELPDESK_KIND.Contact]: (app) => `New contact request on ${app}`,
|
|
88
|
+
[HELPDESK_KIND.Bug]: (app) => `New problem report on ${app}`,
|
|
89
|
+
[HELPDESK_KIND.Wish]: (app) => `New wish on ${app}`,
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
de: {
|
|
@@ -94,15 +94,15 @@ const NEW_REQUEST_STRINGS: Readonly<Record<ContactMailLocale, NewRequestStrings>
|
|
|
94
94
|
linkIntro: "Im Admin öffnen:",
|
|
95
95
|
linkLabel: "Meldung anzeigen",
|
|
96
96
|
title: {
|
|
97
|
-
[
|
|
98
|
-
[
|
|
99
|
-
[
|
|
100
|
-
[
|
|
97
|
+
[HELPDESK_KIND.Question]: (app) => `Neue Frage auf ${app}`,
|
|
98
|
+
[HELPDESK_KIND.Contact]: (app) => `Neuer Kontaktwunsch auf ${app}`,
|
|
99
|
+
[HELPDESK_KIND.Bug]: (app) => `Neue Problemmeldung auf ${app}`,
|
|
100
|
+
[HELPDESK_KIND.Wish]: (app) => `Neuer Wunsch auf ${app}`,
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
export const
|
|
105
|
+
export const HELPDESK_NEW_REQUEST_VARIABLES: TemplateVariables = {
|
|
106
106
|
subject: templateVariable.text({ required: true }),
|
|
107
107
|
intro: templateVariable.text({ required: true }),
|
|
108
108
|
requestUrl: templateVariable.link(),
|
|
@@ -115,11 +115,11 @@ export type NewRequestMailArgs = {
|
|
|
115
115
|
readonly locale: string | undefined;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
export function
|
|
118
|
+
export function helpdeskNewRequestVariables(args: NewRequestMailArgs) {
|
|
119
119
|
const titles: Readonly<Record<string, (appName: string) => string>> =
|
|
120
|
-
NEW_REQUEST_STRINGS[
|
|
120
|
+
NEW_REQUEST_STRINGS[resolveHelpdeskMailLocale(args.locale)].title;
|
|
121
121
|
const title =
|
|
122
|
-
(titles[args.kind] ?? titles[
|
|
122
|
+
(titles[args.kind] ?? titles[HELPDESK_KIND.Question])?.(args.appName) ?? args.appName;
|
|
123
123
|
return {
|
|
124
124
|
subject: title,
|
|
125
125
|
intro: title,
|
|
@@ -131,7 +131,7 @@ export function contactNewRequestVariables(args: NewRequestMailArgs) {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
export function
|
|
134
|
+
export function helpdeskNewRequestTemplate(): NotificationLocalizedTemplate {
|
|
135
135
|
return Object.fromEntries(
|
|
136
136
|
Object.entries(NEW_REQUEST_STRINGS).map(([locale, t]) => [
|
|
137
137
|
locale,
|
|
@@ -154,7 +154,7 @@ type ConfirmationStrings = {
|
|
|
154
154
|
readonly quoteIntro: string;
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
const CONFIRMATION_STRINGS: Readonly<Record<
|
|
157
|
+
const CONFIRMATION_STRINGS: Readonly<Record<HelpdeskMailLocale, ConfirmationStrings>> = {
|
|
158
158
|
en: {
|
|
159
159
|
subject: "Your message to {{appName}}",
|
|
160
160
|
header: "Thanks for your message",
|
|
@@ -177,7 +177,7 @@ type AcknowledgementStrings = {
|
|
|
177
177
|
readonly intro: (appName: string) => string;
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
const ACKNOWLEDGEMENT_STRINGS: Readonly<Record<
|
|
180
|
+
const ACKNOWLEDGEMENT_STRINGS: Readonly<Record<HelpdeskMailLocale, AcknowledgementStrings>> = {
|
|
181
181
|
en: {
|
|
182
182
|
subject: "Your message to {{appName}}",
|
|
183
183
|
header: "Thanks for your message",
|
|
@@ -192,7 +192,7 @@ const ACKNOWLEDGEMENT_STRINGS: Readonly<Record<ContactMailLocale, Acknowledgemen
|
|
|
192
192
|
},
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
export const
|
|
195
|
+
export const HELPDESK_CONFIRMATION_VARIABLES: TemplateVariables = {
|
|
196
196
|
appName: templateVariable.text({ required: true }),
|
|
197
197
|
intro: templateVariable.text({ required: true }),
|
|
198
198
|
quoteIntro: templateVariable.text({ required: true }),
|
|
@@ -202,12 +202,12 @@ export const CONTACT_CONFIRMATION_VARIABLES: TemplateVariables = {
|
|
|
202
202
|
),
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
-
export function
|
|
205
|
+
export function helpdeskConfirmationVariables(args: {
|
|
206
206
|
readonly appName: string;
|
|
207
207
|
readonly message: string;
|
|
208
208
|
readonly locale: string | undefined;
|
|
209
209
|
}) {
|
|
210
|
-
const t = CONFIRMATION_STRINGS[
|
|
210
|
+
const t = CONFIRMATION_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
211
211
|
return {
|
|
212
212
|
appName: args.appName,
|
|
213
213
|
intro: t.intro(args.appName),
|
|
@@ -218,20 +218,20 @@ export function contactConfirmationVariables(args: {
|
|
|
218
218
|
|
|
219
219
|
// Website senders are unverified addresses: the mail must not echo anything they typed, or the
|
|
220
220
|
// form becomes a mail relay. Only the signed-in admin report gets the copy above.
|
|
221
|
-
export const
|
|
221
|
+
export const HELPDESK_ACKNOWLEDGEMENT_VARIABLES: TemplateVariables = {
|
|
222
222
|
appName: templateVariable.text({ required: true }),
|
|
223
223
|
intro: templateVariable.text({ required: true }),
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
export function
|
|
226
|
+
export function helpdeskAcknowledgementVariables(args: {
|
|
227
227
|
readonly appName: string;
|
|
228
228
|
readonly locale: string | undefined;
|
|
229
229
|
}) {
|
|
230
|
-
const t = ACKNOWLEDGEMENT_STRINGS[
|
|
230
|
+
const t = ACKNOWLEDGEMENT_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
231
231
|
return { appName: args.appName, intro: t.intro(args.appName) };
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
export function
|
|
234
|
+
export function helpdeskAcknowledgementTemplate(): NotificationLocalizedTemplate {
|
|
235
235
|
return Object.fromEntries(
|
|
236
236
|
Object.entries(ACKNOWLEDGEMENT_STRINGS).map(([locale, t]) => [
|
|
237
237
|
locale,
|
|
@@ -243,7 +243,7 @@ export function contactAcknowledgementTemplate(): NotificationLocalizedTemplate
|
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
export function
|
|
246
|
+
export function helpdeskConfirmationTemplate(): NotificationLocalizedTemplate {
|
|
247
247
|
return Object.fromEntries(
|
|
248
248
|
Object.entries(CONFIRMATION_STRINGS).map(([locale, t]) => [
|
|
249
249
|
locale,
|
|
@@ -262,7 +262,7 @@ export function contactConfirmationTemplate(): NotificationLocalizedTemplate {
|
|
|
262
262
|
|
|
263
263
|
type ReplyStrings = { readonly footer: string; readonly quoteIntro: (date: string) => string };
|
|
264
264
|
|
|
265
|
-
const REPLY_STRINGS: Readonly<Record<
|
|
265
|
+
const REPLY_STRINGS: Readonly<Record<HelpdeskMailLocale, ReplyStrings>> = {
|
|
266
266
|
en: {
|
|
267
267
|
footer: "You can reply directly to this email.",
|
|
268
268
|
quoteIntro: (date) => `Your request from ${date}:`,
|
|
@@ -273,7 +273,7 @@ const REPLY_STRINGS: Readonly<Record<ContactMailLocale, ReplyStrings>> = {
|
|
|
273
273
|
},
|
|
274
274
|
};
|
|
275
275
|
|
|
276
|
-
export const
|
|
276
|
+
export const HELPDESK_REPLY_VARIABLES: TemplateVariables = {
|
|
277
277
|
subject: templateVariable.text({ required: true }),
|
|
278
278
|
paragraphs: templateVariable.list(
|
|
279
279
|
{ text: templateVariable.text({ required: true }) },
|
|
@@ -285,7 +285,7 @@ export const CONTACT_REPLY_VARIABLES: TemplateVariables = {
|
|
|
285
285
|
footer: templateVariable.text({ required: true }),
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
export function
|
|
288
|
+
export function helpdeskReplyVariables(args: {
|
|
289
289
|
readonly requestSubject: string;
|
|
290
290
|
readonly requestMessage: string;
|
|
291
291
|
readonly requestSubmittedAt: number;
|
|
@@ -294,18 +294,18 @@ export function contactReplyVariables(args: {
|
|
|
294
294
|
readonly appName: string;
|
|
295
295
|
readonly locale: string | undefined;
|
|
296
296
|
}) {
|
|
297
|
-
const t = REPLY_STRINGS[
|
|
297
|
+
const t = REPLY_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
298
298
|
return {
|
|
299
299
|
subject: `Re: ${args.requestSubject}`,
|
|
300
300
|
paragraphs: toParagraphRows(args.replyMessage),
|
|
301
301
|
signedBy: `${args.authorName}, ${args.appName}`,
|
|
302
|
-
quoteIntro: t.quoteIntro(
|
|
302
|
+
quoteIntro: t.quoteIntro(formatHelpdeskDate(args.requestSubmittedAt, args.locale)),
|
|
303
303
|
quote: truncateText(args.requestMessage.replace(/\s+/g, " "), QUOTE_MAX_CHARS),
|
|
304
304
|
footer: t.footer,
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
export function
|
|
308
|
+
export function helpdeskReplyTemplate(): NotificationLocalizedTemplate {
|
|
309
309
|
return Object.fromEntries(
|
|
310
310
|
Object.keys(REPLY_STRINGS).map((locale) => [
|
|
311
311
|
locale,
|
|
@@ -325,11 +325,11 @@ export function contactReplyTemplate(): NotificationLocalizedTemplate {
|
|
|
325
325
|
|
|
326
326
|
type TestStrings = { readonly subject: string; readonly header: string; readonly intro: string };
|
|
327
327
|
|
|
328
|
-
const TEST_STRINGS: Readonly<Record<
|
|
328
|
+
const TEST_STRINGS: Readonly<Record<HelpdeskMailLocale, TestStrings>> = {
|
|
329
329
|
en: {
|
|
330
330
|
subject: "Test message from {{appName}}",
|
|
331
331
|
header: "Test message",
|
|
332
|
-
intro: "This is a test message of the
|
|
332
|
+
intro: "This is a test message of the helpdesk forwarding.",
|
|
333
333
|
},
|
|
334
334
|
de: {
|
|
335
335
|
subject: "Testnachricht von {{appName}}",
|
|
@@ -338,15 +338,15 @@ const TEST_STRINGS: Readonly<Record<ContactMailLocale, TestStrings>> = {
|
|
|
338
338
|
},
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
-
export const
|
|
341
|
+
export const HELPDESK_TEST_VARIABLES: TemplateVariables = {
|
|
342
342
|
appName: templateVariable.text({ required: true }),
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
-
export function
|
|
345
|
+
export function helpdeskTestVariables(args: {
|
|
346
346
|
readonly appName: string;
|
|
347
347
|
readonly locale: string | undefined;
|
|
348
348
|
}) {
|
|
349
|
-
const t = TEST_STRINGS[
|
|
349
|
+
const t = TEST_STRINGS[resolveHelpdeskMailLocale(args.locale)];
|
|
350
350
|
return {
|
|
351
351
|
appName: args.appName,
|
|
352
352
|
telegramTitle: t.subject.replace("{{appName}}", args.appName),
|
|
@@ -354,7 +354,7 @@ export function contactTestVariables(args: {
|
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
export function
|
|
357
|
+
export function helpdeskTestTemplate(): NotificationLocalizedTemplate {
|
|
358
358
|
return Object.fromEntries(
|
|
359
359
|
Object.entries(TEST_STRINGS).map(([locale, t]) => [
|
|
360
360
|
locale,
|
|
@@ -367,7 +367,7 @@ export function contactTestTemplate(): NotificationLocalizedTemplate {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
const REPLY_IN_APP_STRINGS: Readonly<
|
|
370
|
-
Record<
|
|
370
|
+
Record<HelpdeskMailLocale, (authorName: string) => { title: string; body: string }>
|
|
371
371
|
> = {
|
|
372
372
|
en: (authorName) => ({
|
|
373
373
|
title: "Answer to your request",
|
|
@@ -379,11 +379,11 @@ const REPLY_IN_APP_STRINGS: Readonly<
|
|
|
379
379
|
}),
|
|
380
380
|
};
|
|
381
381
|
|
|
382
|
-
export function
|
|
382
|
+
export function helpdeskReplyInAppData(args: {
|
|
383
383
|
readonly authorName: string;
|
|
384
384
|
readonly locale: string | undefined;
|
|
385
385
|
}): { readonly inAppTitle: string; readonly inAppBody: string } {
|
|
386
|
-
const copy = REPLY_IN_APP_STRINGS[
|
|
386
|
+
const copy = REPLY_IN_APP_STRINGS[resolveHelpdeskMailLocale(args.locale)](args.authorName);
|
|
387
387
|
return { inAppTitle: copy.title, inAppBody: copy.body };
|
|
388
388
|
}
|
|
389
389
|
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
2
|
import type {
|
|
2
3
|
PayloadRateLimitOption,
|
|
3
4
|
RateLimitDeclaration,
|
|
4
5
|
RateLimitOption,
|
|
5
6
|
} from "@cosmicdrift/kumiko-types/handlers";
|
|
7
|
+
import { HELPDESK_BOOT_RULES } from "./boot-rules.ts";
|
|
6
8
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type
|
|
9
|
+
HELPDESK_DEFAULT_CHALLENGE_TTL_MINUTES,
|
|
10
|
+
HELPDESK_DEFAULT_MIN_SUBMIT_SECONDS,
|
|
11
|
+
HELPDESK_POW_BITS,
|
|
12
|
+
type HelpdeskPhoneMode,
|
|
11
13
|
} from "./web/constants.ts";
|
|
12
14
|
|
|
13
|
-
export type
|
|
15
|
+
export type HelpdeskOptions = {
|
|
14
16
|
/** Name shown in the notification mails ("Testnachricht von <appName>") and in the hint of the report form. */
|
|
15
17
|
readonly appName: string;
|
|
16
18
|
/** Default { phone: "off" }. Controls both the public form (challenge query reports it) and the admin report form. */
|
|
17
|
-
readonly fields?: { readonly phone?:
|
|
19
|
+
readonly fields?: { readonly phone?: HelpdeskPhoneMode };
|
|
18
20
|
/** Shown as "Version" in the request origin; omitted when unset. */
|
|
19
21
|
readonly appVersion?: string;
|
|
20
22
|
/** Default false. true requires channel-telegram and adds the `telegramChat` config key, the `send-test` handler and the forward to that chat. */
|
|
@@ -70,26 +72,26 @@ export const DEFAULT_SUBMIT_EMAIL_RATE_LIMITS: readonly PayloadRateLimitOption[]
|
|
|
70
72
|
|
|
71
73
|
export const DEFAULT_RETENTION_KEEP_FOR = "365d";
|
|
72
74
|
|
|
73
|
-
export type
|
|
74
|
-
readonly phone:
|
|
75
|
+
export type HelpdeskSettings = {
|
|
76
|
+
readonly phone: HelpdeskPhoneMode;
|
|
75
77
|
readonly proofOfWorkBits: number;
|
|
76
78
|
readonly minSubmitMs: number;
|
|
77
79
|
readonly challengeTtlSeconds: number;
|
|
78
80
|
};
|
|
79
81
|
|
|
80
|
-
export function
|
|
81
|
-
const bits = opts.spamProtection?.proofOfWorkBits ??
|
|
82
|
-
if (!Number.isInteger(bits) || bits <
|
|
83
|
-
throw
|
|
84
|
-
`
|
|
85
|
-
);
|
|
82
|
+
export function resolveHelpdeskSettings(opts: HelpdeskOptions): HelpdeskSettings {
|
|
83
|
+
const bits = opts.spamProtection?.proofOfWorkBits ?? HELPDESK_POW_BITS.default;
|
|
84
|
+
if (!Number.isInteger(bits) || bits < HELPDESK_POW_BITS.min || bits > HELPDESK_POW_BITS.max) {
|
|
85
|
+
throw bootRuleError(HELPDESK_BOOT_RULES.invalidProofOfWorkBits, {
|
|
86
|
+
message: `helpdesk: spamProtection.proofOfWorkBits must be an integer between ${HELPDESK_POW_BITS.min} and ${HELPDESK_POW_BITS.max}, got ${bits}`,
|
|
87
|
+
});
|
|
86
88
|
}
|
|
87
89
|
return {
|
|
88
90
|
phone: opts.fields?.phone ?? "off",
|
|
89
91
|
proofOfWorkBits: bits,
|
|
90
92
|
minSubmitMs:
|
|
91
|
-
(opts.spamProtection?.minSubmitSeconds ??
|
|
93
|
+
(opts.spamProtection?.minSubmitSeconds ?? HELPDESK_DEFAULT_MIN_SUBMIT_SECONDS) * 1000,
|
|
92
94
|
challengeTtlSeconds:
|
|
93
|
-
(opts.spamProtection?.challengeTtlMinutes ??
|
|
95
|
+
(opts.spamProtection?.challengeTtlMinutes ?? HELPDESK_DEFAULT_CHALLENGE_TTL_MINUTES) * 60,
|
|
94
96
|
};
|
|
95
97
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DashboardStatPanel } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import {
|
|
3
|
+
HELPDESK_FEATURE,
|
|
4
|
+
HELPDESK_STATUS,
|
|
5
|
+
HelpdeskQueries,
|
|
6
|
+
HelpdeskScreens,
|
|
7
|
+
} from "./web/constants.ts";
|
|
8
|
+
|
|
9
|
+
// Stat tile for a dashboard: how many contact requests still wait for a first answer.
|
|
10
|
+
export function helpdeskOpenRequestsPanels(): readonly DashboardStatPanel[] {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
kind: "stat",
|
|
14
|
+
id: `${HELPDESK_FEATURE}-open-requests`,
|
|
15
|
+
label: "helpdesk:overview.open",
|
|
16
|
+
query: HelpdeskQueries.requestList,
|
|
17
|
+
params: {
|
|
18
|
+
filters: [{ field: "status", op: "eq", value: HELPDESK_STATUS.Open }],
|
|
19
|
+
limit: 1,
|
|
20
|
+
totalCount: true,
|
|
21
|
+
},
|
|
22
|
+
ignoreScreenFilter: true,
|
|
23
|
+
valueField: "total",
|
|
24
|
+
tone: "warn",
|
|
25
|
+
navigate: { screen: HelpdeskScreens.requestList },
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { canonicalizeLocaleTag, isValidLocaleTag } from "@cosmicdrift/kumiko-framework/i18n";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
HELPDESK_ADMIN_KINDS,
|
|
5
|
+
HELPDESK_FIELD_LIMITS,
|
|
6
|
+
HELPDESK_MAX_FILES,
|
|
7
|
+
HELPDESK_WEBSITE_KINDS,
|
|
8
8
|
} from "./web/constants.ts";
|
|
9
9
|
|
|
10
10
|
// Submitted text lands in mail subjects; CR/LF there would allow header injection.
|
|
@@ -28,14 +28,14 @@ const multiLine = (max: number) =>
|
|
|
28
28
|
const phone = z
|
|
29
29
|
.string()
|
|
30
30
|
.trim()
|
|
31
|
-
.max(
|
|
31
|
+
.max(HELPDESK_FIELD_LIMITS.phone)
|
|
32
32
|
.refine(noControlChars, CONTROL_CHARS_MESSAGE)
|
|
33
33
|
.optional();
|
|
34
34
|
|
|
35
35
|
const pagePath = z
|
|
36
36
|
.string()
|
|
37
37
|
.trim()
|
|
38
|
-
.max(
|
|
38
|
+
.max(HELPDESK_FIELD_LIMITS.page)
|
|
39
39
|
.refine(noControlChars, CONTROL_CHARS_MESSAGE)
|
|
40
40
|
// Query strings and fragments carry tokens and ids (reset links, session hints) that must not
|
|
41
41
|
// end up in an inbox that is kept for a year.
|
|
@@ -44,63 +44,63 @@ const pagePath = z
|
|
|
44
44
|
|
|
45
45
|
const locale = z
|
|
46
46
|
.string()
|
|
47
|
-
.max(
|
|
47
|
+
.max(HELPDESK_FIELD_LIMITS.locale)
|
|
48
48
|
.refine(isValidLocaleTag, "invalid locale tag")
|
|
49
49
|
.transform(canonicalizeLocaleTag);
|
|
50
50
|
|
|
51
|
-
export const
|
|
51
|
+
export const HelpdeskSubmitSchema = z
|
|
52
52
|
.object({
|
|
53
|
-
kind: z.enum(
|
|
54
|
-
name: singleLine(
|
|
55
|
-
email: z.email().max(
|
|
53
|
+
kind: z.enum(HELPDESK_WEBSITE_KINDS),
|
|
54
|
+
name: singleLine(HELPDESK_FIELD_LIMITS.name),
|
|
55
|
+
email: z.email().max(HELPDESK_FIELD_LIMITS.email),
|
|
56
56
|
phone,
|
|
57
|
-
message: multiLine(
|
|
57
|
+
message: multiLine(HELPDESK_FIELD_LIMITS.message),
|
|
58
58
|
locale,
|
|
59
59
|
// Honeypot: bots fill it, humans leave it empty.
|
|
60
|
-
website: z.string().max(
|
|
61
|
-
challenge: z.string().max(
|
|
62
|
-
nonce: z.string().max(
|
|
60
|
+
website: z.string().max(HELPDESK_FIELD_LIMITS.honeypot).optional(),
|
|
61
|
+
challenge: z.string().max(HELPDESK_FIELD_LIMITS.challenge),
|
|
62
|
+
nonce: z.string().max(HELPDESK_FIELD_LIMITS.nonce),
|
|
63
63
|
page: pagePath,
|
|
64
64
|
})
|
|
65
65
|
.strict();
|
|
66
|
-
export type
|
|
66
|
+
export type HelpdeskSubmitInput = z.infer<typeof HelpdeskSubmitSchema>;
|
|
67
67
|
|
|
68
|
-
export const
|
|
68
|
+
export const HelpdeskReportSchema = z
|
|
69
69
|
.object({
|
|
70
|
-
kind: z.enum(
|
|
71
|
-
subject: singleLine(
|
|
72
|
-
message: multiLine(
|
|
70
|
+
kind: z.enum(HELPDESK_ADMIN_KINDS),
|
|
71
|
+
subject: singleLine(HELPDESK_FIELD_LIMITS.subject),
|
|
72
|
+
message: multiLine(HELPDESK_FIELD_LIMITS.message),
|
|
73
73
|
phone,
|
|
74
|
-
fileIds: z.array(z.uuid()).max(
|
|
74
|
+
fileIds: z.array(z.uuid()).max(HELPDESK_MAX_FILES).optional(),
|
|
75
75
|
})
|
|
76
76
|
.strict();
|
|
77
|
-
export type
|
|
77
|
+
export type HelpdeskReportInput = z.infer<typeof HelpdeskReportSchema>;
|
|
78
78
|
|
|
79
|
-
export const
|
|
79
|
+
export const HelpdeskIdSchema = z.object({ id: z.uuid() }).strict();
|
|
80
80
|
|
|
81
|
-
export const
|
|
81
|
+
export const HelpdeskReplySchema = z
|
|
82
82
|
.object({
|
|
83
83
|
requestId: z.uuid(),
|
|
84
|
-
message: multiLine(
|
|
85
|
-
fileIds: z.array(z.uuid()).max(
|
|
84
|
+
message: multiLine(HELPDESK_FIELD_LIMITS.message),
|
|
85
|
+
fileIds: z.array(z.uuid()).max(HELPDESK_MAX_FILES).optional(),
|
|
86
86
|
markDone: z.boolean().default(false),
|
|
87
87
|
})
|
|
88
88
|
.strict();
|
|
89
89
|
|
|
90
|
-
export const
|
|
90
|
+
export const HelpdeskMarkDoneSchema = HelpdeskIdSchema;
|
|
91
91
|
|
|
92
|
-
export const
|
|
92
|
+
export const HelpdeskForwardRequestSchema = z.object({ requestId: z.uuid() }).strict();
|
|
93
93
|
|
|
94
|
-
export const
|
|
94
|
+
export const HelpdeskSendReplyMailSchema = z.object({ replyId: z.uuid() }).strict();
|
|
95
95
|
|
|
96
|
-
export const
|
|
96
|
+
export const HelpdeskNotifyReporterInAppSchema = z
|
|
97
97
|
.object({
|
|
98
98
|
replyId: z.uuid(),
|
|
99
99
|
requestId: z.uuid(),
|
|
100
100
|
userId: z.uuid(),
|
|
101
|
-
authorName: z.string().max(
|
|
102
|
-
locale: z.string().max(
|
|
101
|
+
authorName: z.string().max(HELPDESK_FIELD_LIMITS.name),
|
|
102
|
+
locale: z.string().max(HELPDESK_FIELD_LIMITS.locale).optional(),
|
|
103
103
|
})
|
|
104
104
|
.strict();
|
|
105
105
|
|
|
106
|
-
export const
|
|
106
|
+
export const HelpdeskEmptySchema = z.object({}).strict();
|