@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.
Files changed (182) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +13 -13
  3. package/packages/bundled-features/src/admin-shell/feature.ts +1 -1
  4. package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +64 -3
  5. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +13 -130
  6. package/packages/bundled-features/src/agent-tools/api-docs/anchors.ts +60 -0
  7. package/packages/bundled-features/src/agent-tools/api-docs/check.ts +25 -0
  8. package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +140 -0
  9. package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +175 -0
  10. package/packages/bundled-features/src/agent-tools/api-docs/curl.ts +28 -0
  11. package/packages/bundled-features/src/agent-tools/api-docs/error-table.ts +45 -0
  12. package/packages/bundled-features/src/agent-tools/api-docs/examples.ts +43 -0
  13. package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +179 -0
  14. package/packages/bundled-features/src/agent-tools/api-docs/index-json.ts +29 -0
  15. package/packages/bundled-features/src/agent-tools/api-docs/index.ts +21 -0
  16. package/packages/bundled-features/src/agent-tools/api-docs/list-parameters.ts +38 -0
  17. package/packages/bundled-features/src/agent-tools/api-docs/markdown.ts +70 -0
  18. package/packages/bundled-features/src/agent-tools/api-docs/menu-path.ts +82 -0
  19. package/packages/bundled-features/src/agent-tools/api-docs/model.ts +83 -0
  20. package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +58 -0
  21. package/packages/bundled-features/src/agent-tools/api-docs/render-events.ts +76 -0
  22. package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +216 -0
  23. package/packages/bundled-features/src/agent-tools/api-docs/render-overview.ts +86 -0
  24. package/packages/bundled-features/src/agent-tools/api-docs/render-reference.ts +79 -0
  25. package/packages/bundled-features/src/agent-tools/api-docs/render-tokens.ts +136 -0
  26. package/packages/bundled-features/src/agent-tools/api-docs/schema-fields.ts +167 -0
  27. package/packages/bundled-features/src/agent-tools/api-docs/section-ids.ts +28 -0
  28. package/packages/bundled-features/src/agent-tools/api-docs/system-only.ts +11 -0
  29. package/packages/bundled-features/src/agent-tools/api-docs/texts/de.ts +166 -0
  30. package/packages/bundled-features/src/agent-tools/api-docs/texts/en.ts +159 -0
  31. package/packages/bundled-features/src/agent-tools/api-docs/texts/es.ts +162 -0
  32. package/packages/bundled-features/src/agent-tools/api-docs/texts/fr.ts +169 -0
  33. package/packages/bundled-features/src/agent-tools/api-docs/texts/index.ts +67 -0
  34. package/packages/bundled-features/src/agent-tools/api-docs/texts/it.ts +165 -0
  35. package/packages/bundled-features/src/agent-tools/api-docs/texts/types.ts +130 -0
  36. package/packages/bundled-features/src/agent-tools/api-docs/ui-writes.ts +81 -0
  37. package/packages/bundled-features/src/agent-tools/changes.json +24 -0
  38. package/packages/bundled-features/src/agent-tools/handler-schema.ts +45 -0
  39. package/packages/bundled-features/src/agent-tools/index.ts +24 -0
  40. package/packages/bundled-features/src/agent-tools/labels.ts +181 -0
  41. package/packages/bundled-features/src/auth-email-password/boot-rules.ts +9 -0
  42. package/packages/bundled-features/src/auth-email-password/feature.ts +6 -19
  43. package/packages/bundled-features/src/auth-email-password/validate-options.ts +20 -0
  44. package/packages/bundled-features/src/billing-foundation/boot-rules.ts +26 -0
  45. package/packages/bundled-features/src/billing-foundation/validate-options.ts +59 -46
  46. package/packages/bundled-features/src/cap-overview/boot-rules.ts +14 -0
  47. package/packages/bundled-features/src/cap-overview/feature.ts +12 -5
  48. package/packages/bundled-features/src/documents/boot-rules.ts +14 -0
  49. package/packages/bundled-features/src/documents/feature.ts +8 -4
  50. package/packages/bundled-features/src/file-derivatives/boot-rules.ts +9 -0
  51. package/packages/bundled-features/src/file-derivatives/feature.ts +6 -3
  52. package/packages/bundled-features/src/folders/boot-rules.ts +9 -0
  53. package/packages/bundled-features/src/folders/feature.ts +6 -3
  54. package/packages/bundled-features/src/helpdesk/boot-rules.ts +9 -0
  55. package/packages/bundled-features/src/{contact → helpdesk}/challenge.ts +2 -2
  56. package/packages/bundled-features/src/{contact → helpdesk}/changes.json +6 -0
  57. package/packages/bundled-features/src/{contact/client/contact-client-source.ts → helpdesk/client/helpdesk-client-source.ts} +4 -4
  58. package/packages/bundled-features/src/helpdesk/client/helpdesk-website-client.ts +29 -0
  59. package/packages/bundled-features/src/helpdesk/client/index.ts +9 -0
  60. package/packages/bundled-features/src/{contact → helpdesk}/entity.ts +35 -31
  61. package/packages/bundled-features/src/{contact → helpdesk}/feature.ts +56 -52
  62. package/packages/bundled-features/src/{contact → helpdesk}/handlers/attempts.ts +3 -3
  63. package/packages/bundled-features/src/{contact → helpdesk}/handlers/challenge.query.ts +10 -10
  64. package/packages/bundled-features/src/{contact → helpdesk}/handlers/forward-request.write.ts +25 -23
  65. package/packages/bundled-features/src/{contact → helpdesk}/handlers/mark-done.write.ts +11 -11
  66. package/packages/bundled-features/src/{contact → helpdesk}/handlers/notify-reporter-in-app.write.ts +14 -14
  67. package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.query.ts +4 -4
  68. package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.ts +2 -2
  69. package/packages/bundled-features/src/{contact → helpdesk}/handlers/replies.query.ts +6 -6
  70. package/packages/bundled-features/src/{contact → helpdesk}/handlers/reply.write.ts +30 -30
  71. package/packages/bundled-features/src/{contact → helpdesk}/handlers/report.write.ts +29 -29
  72. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-delivery.query.ts +40 -40
  73. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-detail.query.ts +15 -15
  74. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-list.query.ts +2 -2
  75. package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-reply-mail.write.ts +24 -24
  76. package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-test.write.ts +18 -14
  77. package/packages/bundled-features/src/{contact → helpdesk}/handlers/submit.write.ts +32 -31
  78. package/packages/bundled-features/src/{contact → helpdesk}/handlers/take-over-uploads.ts +5 -5
  79. package/packages/bundled-features/src/{contact → helpdesk}/i18n.ts +78 -75
  80. package/packages/bundled-features/src/helpdesk/index.ts +29 -0
  81. package/packages/bundled-features/src/{contact → helpdesk}/lib.ts +32 -28
  82. package/packages/bundled-features/src/{contact → helpdesk}/mail.ts +56 -56
  83. package/packages/bundled-features/src/{contact → helpdesk}/options.ts +18 -16
  84. package/packages/bundled-features/src/helpdesk/panels.ts +28 -0
  85. package/packages/bundled-features/src/{contact → helpdesk}/payloads.ts +33 -33
  86. package/packages/bundled-features/src/{contact → helpdesk}/screens.ts +104 -104
  87. package/packages/bundled-features/src/{contact → helpdesk}/subject.ts +3 -3
  88. package/packages/bundled-features/src/{contact → helpdesk}/user-data-hooks.ts +17 -17
  89. package/packages/bundled-features/src/helpdesk/web/constants.ts +160 -0
  90. package/packages/bundled-features/src/helpdesk/web/index.ts +29 -0
  91. package/packages/bundled-features/src/host-routing/boot-rules.ts +27 -0
  92. package/packages/bundled-features/src/host-routing/validate-options.ts +36 -27
  93. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +6 -0
  94. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +99 -71
  95. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +2 -2
  96. package/packages/bundled-features/src/jobs/boot-rules.ts +9 -0
  97. package/packages/bundled-features/src/jobs/feature.ts +9 -4
  98. package/packages/bundled-features/src/legal-pages/boot-rules.ts +19 -0
  99. package/packages/bundled-features/src/legal-pages/feature.ts +6 -3
  100. package/packages/bundled-features/src/legal-pages/lib/validate-routes.ts +11 -5
  101. package/packages/bundled-features/src/metrics/boot-rules.ts +15 -0
  102. package/packages/bundled-features/src/metrics/validate.ts +8 -2
  103. package/packages/bundled-features/src/notes-history/boot-rules.ts +9 -0
  104. package/packages/bundled-features/src/notes-history/feature.ts +6 -3
  105. package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +9 -0
  106. package/packages/bundled-features/src/personal-access-tokens/changes.json +6 -0
  107. package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -2
  108. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +7 -2
  109. package/packages/bundled-features/src/personal-access-tokens/i18n.ts +6 -1
  110. package/packages/bundled-features/src/personal-access-tokens/index.ts +37 -2
  111. package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -0
  112. package/packages/bundled-features/src/personal-access-tokens/screens.ts +9 -1
  113. package/packages/bundled-features/src/personal-access-tokens/web/constants.ts +1 -0
  114. package/packages/bundled-features/src/personal-access-tokens/web/scopes.ts +14 -0
  115. package/packages/bundled-features/src/presence/boot-rules.ts +9 -0
  116. package/packages/bundled-features/src/presence/options.ts +5 -1
  117. package/packages/bundled-features/src/readiness/boot-rules.ts +14 -0
  118. package/packages/bundled-features/src/readiness/probe-boot-check.ts +8 -6
  119. package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +6 -4
  120. package/packages/bundled-features/src/shared/boot-rules.ts +9 -0
  121. package/packages/bundled-features/src/subscription-mollie/boot-rules.ts +19 -0
  122. package/packages/bundled-features/src/subscription-mollie/feature.ts +18 -10
  123. package/packages/bundled-features/src/tags/boot-rules.ts +9 -0
  124. package/packages/bundled-features/src/tags/feature.ts +6 -3
  125. package/packages/bundled-features/src/template-resolver/boot-rules.ts +19 -0
  126. package/packages/bundled-features/src/template-resolver/feature.ts +14 -10
  127. package/packages/bundled-features/src/tenant/boot-rules.ts +9 -0
  128. package/packages/bundled-features/src/tenant/feature.ts +5 -3
  129. package/samples/apps/marketing-demo/README.md +1 -1
  130. package/samples/apps/marketing-demo/playwright.config.ts +1 -1
  131. package/samples/apps/marketing-demo/src/app/client.tsx +3 -3
  132. package/samples/apps/marketing-demo/src/app/seed-data.ts +1 -1
  133. package/samples/apps/marketing-demo/src/app/seed.ts +4 -4
  134. package/samples/apps/marketing-demo/src/app/server.ts +3 -3
  135. package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/feature.ts +15 -12
  136. package/samples/apps/marketing-demo/src/features/ticketing/i18n.ts +100 -0
  137. package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/ticket.ts +4 -4
  138. package/samples/apps/marketing-demo/src/features/ticketing/web/index.ts +7 -0
  139. package/samples/apps/use-all-bundled/feature-manifest.json +67 -67
  140. package/samples/apps/use-all-bundled/kumiko/migrations/0064_helpdesk-rename.rebuild.json +4 -0
  141. package/samples/apps/use-all-bundled/package.json +1 -1
  142. package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
  143. package/samples/apps/use-all-bundled/src/app/screens-feature.ts +10 -10
  144. package/samples/apps/use-all-bundled/src/run-config.ts +6 -6
  145. package/samples/recipes/api-docs/README.md +52 -0
  146. package/samples/recipes/api-docs/api-docs/de/events.md +62 -0
  147. package/samples/recipes/api-docs/api-docs/de/overview.md +100 -0
  148. package/samples/recipes/api-docs/api-docs/de/reference/tickets.md +305 -0
  149. package/samples/recipes/api-docs/api-docs/de/tokens.md +66 -0
  150. package/samples/recipes/api-docs/api-docs/en/events.md +62 -0
  151. package/samples/recipes/api-docs/api-docs/en/overview.md +100 -0
  152. package/samples/recipes/api-docs/api-docs/en/reference/tickets.md +305 -0
  153. package/samples/recipes/api-docs/api-docs/en/tokens.md +66 -0
  154. package/samples/recipes/api-docs/api-docs/index.json +371 -0
  155. package/samples/recipes/api-docs/api-docs/openapi.json +982 -0
  156. package/samples/recipes/api-docs/api-examples/ticket-close.json +21 -0
  157. package/samples/recipes/api-docs/api-examples/ticket-create.json +42 -0
  158. package/samples/recipes/api-docs/api-examples/ticket-detail.json +28 -0
  159. package/samples/recipes/api-docs/api-examples/ticket-list.json +31 -0
  160. package/samples/recipes/api-docs/api-examples/ticket-update.json +54 -0
  161. package/samples/recipes/api-docs/api-examples/webhooks/ticket-closed.json +8 -0
  162. package/samples/recipes/api-docs/api-examples/webhooks/ticket-created.json +10 -0
  163. package/samples/recipes/api-docs/kumiko.config.ts +33 -0
  164. package/samples/recipes/api-docs/package.json +14 -0
  165. package/samples/recipes/api-docs/src/feature.ts +218 -0
  166. package/samples/recipes/api-docs/tsconfig.json +22 -0
  167. package/samples/recipes/golden-path/src/feature.ts +1 -1
  168. package/samples/recipes/{contact → helpdesk}/README.md +16 -16
  169. package/samples/recipes/{contact → helpdesk}/package.json +2 -2
  170. package/samples/recipes/{contact → helpdesk}/src/feature.ts +6 -6
  171. package/packages/bundled-features/src/contact/client/contact-website-client.ts +0 -29
  172. package/packages/bundled-features/src/contact/client/index.ts +0 -9
  173. package/packages/bundled-features/src/contact/index.ts +0 -29
  174. package/packages/bundled-features/src/contact/panels.ts +0 -28
  175. package/packages/bundled-features/src/contact/web/constants.ts +0 -160
  176. package/packages/bundled-features/src/contact/web/index.ts +0 -29
  177. package/samples/apps/marketing-demo/src/features/helpdesk/i18n.ts +0 -100
  178. package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +0 -7
  179. /package/packages/bundled-features/src/{contact → helpdesk}/handlers/access.ts +0 -0
  180. /package/packages/bundled-features/src/{contact → helpdesk}/pow.ts +0 -0
  181. /package/packages/bundled-features/src/{contact → helpdesk}/user-agent.ts +0 -0
  182. /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 { CONTACT_KIND, type ContactKind } from "./web/constants.ts";
12
+ import { HELPDESK_KIND, type HelpdeskKind } from "./web/constants.ts";
13
13
 
14
- export type ContactMailLocale = "en" | "de";
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 resolveContactMailLocale(locale: string | undefined): ContactMailLocale {
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<ContactMailLocale, Readonly<Record<ContactKind, string>>>> = {
36
+ const KIND_LABELS: Readonly<Record<HelpdeskMailLocale, Readonly<Record<HelpdeskKind, string>>>> = {
37
37
  en: {
38
- [CONTACT_KIND.Question]: "Question",
39
- [CONTACT_KIND.Contact]: "Contact request",
40
- [CONTACT_KIND.Bug]: "Problem",
41
- [CONTACT_KIND.Wish]: "Wish",
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
- [CONTACT_KIND.Question]: "Frage",
45
- [CONTACT_KIND.Contact]: "Kontaktwunsch",
46
- [CONTACT_KIND.Bug]: "Problem",
47
- [CONTACT_KIND.Wish]: "Wunsch",
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 contactKindLabel(kind: string, locale: string | undefined): string {
52
- const labels: Readonly<Record<string, string>> = KIND_LABELS[resolveContactMailLocale(locale)];
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 formatContactDate(atEpochMs: number, locale: string | undefined): string {
57
- return new Intl.DateTimeFormat(resolveContactMailLocale(locale), {
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<ContactKind, (appName: string) => string>>;
77
+ readonly title: Readonly<Record<HelpdeskKind, (appName: string) => string>>;
78
78
  };
79
79
 
80
- const NEW_REQUEST_STRINGS: Readonly<Record<ContactMailLocale, NewRequestStrings>> = {
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
- [CONTACT_KIND.Question]: (app) => `New question on ${app}`,
87
- [CONTACT_KIND.Contact]: (app) => `New contact request on ${app}`,
88
- [CONTACT_KIND.Bug]: (app) => `New problem report on ${app}`,
89
- [CONTACT_KIND.Wish]: (app) => `New wish on ${app}`,
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
- [CONTACT_KIND.Question]: (app) => `Neue Frage auf ${app}`,
98
- [CONTACT_KIND.Contact]: (app) => `Neuer Kontaktwunsch auf ${app}`,
99
- [CONTACT_KIND.Bug]: (app) => `Neue Problemmeldung auf ${app}`,
100
- [CONTACT_KIND.Wish]: (app) => `Neuer Wunsch auf ${app}`,
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 CONTACT_NEW_REQUEST_VARIABLES: TemplateVariables = {
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 contactNewRequestVariables(args: NewRequestMailArgs) {
118
+ export function helpdeskNewRequestVariables(args: NewRequestMailArgs) {
119
119
  const titles: Readonly<Record<string, (appName: string) => string>> =
120
- NEW_REQUEST_STRINGS[resolveContactMailLocale(args.locale)].title;
120
+ NEW_REQUEST_STRINGS[resolveHelpdeskMailLocale(args.locale)].title;
121
121
  const title =
122
- (titles[args.kind] ?? titles[CONTACT_KIND.Question])?.(args.appName) ?? args.appName;
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 contactNewRequestTemplate(): NotificationLocalizedTemplate {
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<ContactMailLocale, ConfirmationStrings>> = {
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<ContactMailLocale, AcknowledgementStrings>> = {
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 CONTACT_CONFIRMATION_VARIABLES: TemplateVariables = {
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 contactConfirmationVariables(args: {
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[resolveContactMailLocale(args.locale)];
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 CONTACT_ACKNOWLEDGEMENT_VARIABLES: TemplateVariables = {
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 contactAcknowledgementVariables(args: {
226
+ export function helpdeskAcknowledgementVariables(args: {
227
227
  readonly appName: string;
228
228
  readonly locale: string | undefined;
229
229
  }) {
230
- const t = ACKNOWLEDGEMENT_STRINGS[resolveContactMailLocale(args.locale)];
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 contactAcknowledgementTemplate(): NotificationLocalizedTemplate {
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 contactConfirmationTemplate(): NotificationLocalizedTemplate {
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<ContactMailLocale, ReplyStrings>> = {
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 CONTACT_REPLY_VARIABLES: TemplateVariables = {
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 contactReplyVariables(args: {
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[resolveContactMailLocale(args.locale)];
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(formatContactDate(args.requestSubmittedAt, args.locale)),
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 contactReplyTemplate(): NotificationLocalizedTemplate {
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<ContactMailLocale, TestStrings>> = {
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 contact forwarding.",
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 CONTACT_TEST_VARIABLES: TemplateVariables = {
341
+ export const HELPDESK_TEST_VARIABLES: TemplateVariables = {
342
342
  appName: templateVariable.text({ required: true }),
343
343
  };
344
344
 
345
- export function contactTestVariables(args: {
345
+ export function helpdeskTestVariables(args: {
346
346
  readonly appName: string;
347
347
  readonly locale: string | undefined;
348
348
  }) {
349
- const t = TEST_STRINGS[resolveContactMailLocale(args.locale)];
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 contactTestTemplate(): NotificationLocalizedTemplate {
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<ContactMailLocale, (authorName: string) => { title: string; body: string }>
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 contactReplyInAppData(args: {
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[resolveContactMailLocale(args.locale)](args.authorName);
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
- CONTACT_DEFAULT_CHALLENGE_TTL_MINUTES,
8
- CONTACT_DEFAULT_MIN_SUBMIT_SECONDS,
9
- CONTACT_POW_BITS,
10
- type ContactPhoneMode,
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 ContactOptions = {
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?: ContactPhoneMode };
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 ContactSettings = {
74
- readonly phone: ContactPhoneMode;
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 resolveContactSettings(opts: ContactOptions): ContactSettings {
81
- const bits = opts.spamProtection?.proofOfWorkBits ?? CONTACT_POW_BITS.default;
82
- if (!Number.isInteger(bits) || bits < CONTACT_POW_BITS.min || bits > CONTACT_POW_BITS.max) {
83
- throw new Error(
84
- `contact: spamProtection.proofOfWorkBits must be an integer between ${CONTACT_POW_BITS.min} and ${CONTACT_POW_BITS.max}, got ${bits}`,
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 ?? CONTACT_DEFAULT_MIN_SUBMIT_SECONDS) * 1000,
93
+ (opts.spamProtection?.minSubmitSeconds ?? HELPDESK_DEFAULT_MIN_SUBMIT_SECONDS) * 1000,
92
94
  challengeTtlSeconds:
93
- (opts.spamProtection?.challengeTtlMinutes ?? CONTACT_DEFAULT_CHALLENGE_TTL_MINUTES) * 60,
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
- CONTACT_ADMIN_KINDS,
5
- CONTACT_FIELD_LIMITS,
6
- CONTACT_MAX_FILES,
7
- CONTACT_WEBSITE_KINDS,
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(CONTACT_FIELD_LIMITS.phone)
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(CONTACT_FIELD_LIMITS.page)
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(CONTACT_FIELD_LIMITS.locale)
47
+ .max(HELPDESK_FIELD_LIMITS.locale)
48
48
  .refine(isValidLocaleTag, "invalid locale tag")
49
49
  .transform(canonicalizeLocaleTag);
50
50
 
51
- export const ContactSubmitSchema = z
51
+ export const HelpdeskSubmitSchema = z
52
52
  .object({
53
- kind: z.enum(CONTACT_WEBSITE_KINDS),
54
- name: singleLine(CONTACT_FIELD_LIMITS.name),
55
- email: z.email().max(CONTACT_FIELD_LIMITS.email),
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(CONTACT_FIELD_LIMITS.message),
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(CONTACT_FIELD_LIMITS.honeypot).optional(),
61
- challenge: z.string().max(CONTACT_FIELD_LIMITS.challenge),
62
- nonce: z.string().max(CONTACT_FIELD_LIMITS.nonce),
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 ContactSubmitInput = z.infer<typeof ContactSubmitSchema>;
66
+ export type HelpdeskSubmitInput = z.infer<typeof HelpdeskSubmitSchema>;
67
67
 
68
- export const ContactReportSchema = z
68
+ export const HelpdeskReportSchema = z
69
69
  .object({
70
- kind: z.enum(CONTACT_ADMIN_KINDS),
71
- subject: singleLine(CONTACT_FIELD_LIMITS.subject),
72
- message: multiLine(CONTACT_FIELD_LIMITS.message),
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(CONTACT_MAX_FILES).optional(),
74
+ fileIds: z.array(z.uuid()).max(HELPDESK_MAX_FILES).optional(),
75
75
  })
76
76
  .strict();
77
- export type ContactReportInput = z.infer<typeof ContactReportSchema>;
77
+ export type HelpdeskReportInput = z.infer<typeof HelpdeskReportSchema>;
78
78
 
79
- export const ContactIdSchema = z.object({ id: z.uuid() }).strict();
79
+ export const HelpdeskIdSchema = z.object({ id: z.uuid() }).strict();
80
80
 
81
- export const ContactReplySchema = z
81
+ export const HelpdeskReplySchema = z
82
82
  .object({
83
83
  requestId: z.uuid(),
84
- message: multiLine(CONTACT_FIELD_LIMITS.message),
85
- fileIds: z.array(z.uuid()).max(CONTACT_MAX_FILES).optional(),
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 ContactMarkDoneSchema = ContactIdSchema;
90
+ export const HelpdeskMarkDoneSchema = HelpdeskIdSchema;
91
91
 
92
- export const ContactForwardRequestSchema = z.object({ requestId: z.uuid() }).strict();
92
+ export const HelpdeskForwardRequestSchema = z.object({ requestId: z.uuid() }).strict();
93
93
 
94
- export const ContactSendReplyMailSchema = z.object({ replyId: z.uuid() }).strict();
94
+ export const HelpdeskSendReplyMailSchema = z.object({ replyId: z.uuid() }).strict();
95
95
 
96
- export const ContactNotifyReporterInAppSchema = z
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(CONTACT_FIELD_LIMITS.name),
102
- locale: z.string().max(CONTACT_FIELD_LIMITS.locale).optional(),
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 ContactEmptySchema = z.object({}).strict();
106
+ export const HelpdeskEmptySchema = z.object({}).strict();