@cosmicdrift/kumiko-samples 0.412.0 → 0.413.1

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 (135) 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/api-docs/anchors.ts +1 -1
  5. package/packages/bundled-features/src/auth-email-password/boot-rules.ts +9 -0
  6. package/packages/bundled-features/src/auth-email-password/feature.ts +6 -19
  7. package/packages/bundled-features/src/auth-email-password/validate-options.ts +20 -0
  8. package/packages/bundled-features/src/billing-foundation/boot-rules.ts +26 -0
  9. package/packages/bundled-features/src/billing-foundation/validate-options.ts +59 -46
  10. package/packages/bundled-features/src/cap-overview/boot-rules.ts +14 -0
  11. package/packages/bundled-features/src/cap-overview/feature.ts +12 -5
  12. package/packages/bundled-features/src/data-retention/changes.json +6 -0
  13. package/packages/bundled-features/src/data-retention/feature.ts +3 -2
  14. package/packages/bundled-features/src/documents/boot-rules.ts +14 -0
  15. package/packages/bundled-features/src/documents/feature.ts +8 -4
  16. package/packages/bundled-features/src/file-derivatives/boot-rules.ts +9 -0
  17. package/packages/bundled-features/src/file-derivatives/feature.ts +6 -3
  18. package/packages/bundled-features/src/folders/boot-rules.ts +9 -0
  19. package/packages/bundled-features/src/folders/feature.ts +6 -3
  20. package/packages/bundled-features/src/helpdesk/boot-rules.ts +9 -0
  21. package/packages/bundled-features/src/{contact → helpdesk}/challenge.ts +2 -2
  22. package/packages/bundled-features/src/{contact → helpdesk}/changes.json +18 -0
  23. package/packages/bundled-features/src/{contact/client/contact-client-source.ts → helpdesk/client/helpdesk-client-source.ts} +4 -4
  24. package/packages/bundled-features/src/helpdesk/client/helpdesk-website-client.ts +29 -0
  25. package/packages/bundled-features/src/helpdesk/client/index.ts +9 -0
  26. package/packages/bundled-features/src/{contact → helpdesk}/entity.ts +35 -31
  27. package/packages/bundled-features/src/{contact → helpdesk}/feature.ts +56 -52
  28. package/packages/bundled-features/src/{contact → helpdesk}/handlers/attempts.ts +3 -3
  29. package/packages/bundled-features/src/{contact → helpdesk}/handlers/challenge.query.ts +10 -10
  30. package/packages/bundled-features/src/{contact → helpdesk}/handlers/forward-request.write.ts +25 -23
  31. package/packages/bundled-features/src/{contact → helpdesk}/handlers/mark-done.write.ts +11 -11
  32. package/packages/bundled-features/src/{contact → helpdesk}/handlers/notify-reporter-in-app.write.ts +14 -14
  33. package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.query.ts +4 -4
  34. package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.ts +2 -2
  35. package/packages/bundled-features/src/{contact → helpdesk}/handlers/replies.query.ts +6 -6
  36. package/packages/bundled-features/src/{contact → helpdesk}/handlers/reply.write.ts +30 -30
  37. package/packages/bundled-features/src/{contact → helpdesk}/handlers/report.write.ts +29 -29
  38. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-delivery.query.ts +40 -40
  39. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-detail.query.ts +15 -15
  40. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-list.query.ts +2 -2
  41. package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-reply-mail.write.ts +24 -24
  42. package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-test.write.ts +18 -14
  43. package/packages/bundled-features/src/{contact → helpdesk}/handlers/submit.write.ts +32 -31
  44. package/packages/bundled-features/src/{contact → helpdesk}/handlers/take-over-uploads.ts +5 -5
  45. package/packages/bundled-features/src/{contact → helpdesk}/i18n.ts +78 -75
  46. package/packages/bundled-features/src/helpdesk/index.ts +29 -0
  47. package/packages/bundled-features/src/{contact → helpdesk}/lib.ts +32 -28
  48. package/packages/bundled-features/src/{contact → helpdesk}/mail.ts +56 -56
  49. package/packages/bundled-features/src/{contact → helpdesk}/options.ts +18 -16
  50. package/packages/bundled-features/src/helpdesk/panels.ts +28 -0
  51. package/packages/bundled-features/src/{contact → helpdesk}/payloads.ts +33 -33
  52. package/packages/bundled-features/src/{contact → helpdesk}/screens.ts +104 -104
  53. package/packages/bundled-features/src/{contact → helpdesk}/subject.ts +3 -3
  54. package/packages/bundled-features/src/{contact → helpdesk}/user-data-hooks.ts +17 -17
  55. package/packages/bundled-features/src/helpdesk/web/constants.ts +160 -0
  56. package/packages/bundled-features/src/helpdesk/web/index.ts +29 -0
  57. package/packages/bundled-features/src/host-routing/boot-rules.ts +27 -0
  58. package/packages/bundled-features/src/host-routing/validate-options.ts +36 -27
  59. package/packages/bundled-features/src/jobs/boot-rules.ts +9 -0
  60. package/packages/bundled-features/src/jobs/feature.ts +9 -4
  61. package/packages/bundled-features/src/legal-pages/boot-rules.ts +19 -0
  62. package/packages/bundled-features/src/legal-pages/feature.ts +6 -3
  63. package/packages/bundled-features/src/legal-pages/lib/validate-routes.ts +11 -5
  64. package/packages/bundled-features/src/metrics/boot-rules.ts +15 -0
  65. package/packages/bundled-features/src/metrics/validate.ts +8 -2
  66. package/packages/bundled-features/src/notes-history/boot-rules.ts +9 -0
  67. package/packages/bundled-features/src/notes-history/feature.ts +6 -3
  68. package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +9 -0
  69. package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +6 -3
  70. package/packages/bundled-features/src/presence/boot-rules.ts +9 -0
  71. package/packages/bundled-features/src/presence/options.ts +5 -1
  72. package/packages/bundled-features/src/readiness/boot-rules.ts +14 -0
  73. package/packages/bundled-features/src/readiness/probe-boot-check.ts +8 -6
  74. package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +6 -4
  75. package/packages/bundled-features/src/shared/boot-rules.ts +9 -0
  76. package/packages/bundled-features/src/subscription-mollie/boot-rules.ts +19 -0
  77. package/packages/bundled-features/src/subscription-mollie/feature.ts +18 -10
  78. package/packages/bundled-features/src/tags/boot-rules.ts +9 -0
  79. package/packages/bundled-features/src/tags/feature.ts +6 -3
  80. package/packages/bundled-features/src/template-resolver/boot-rules.ts +19 -0
  81. package/packages/bundled-features/src/template-resolver/feature.ts +14 -10
  82. package/packages/bundled-features/src/tenant/boot-rules.ts +9 -0
  83. package/packages/bundled-features/src/tenant/feature.ts +5 -3
  84. package/samples/apps/marketing-demo/README.md +1 -1
  85. package/samples/apps/marketing-demo/playwright.config.ts +1 -1
  86. package/samples/apps/marketing-demo/src/app/client.tsx +3 -3
  87. package/samples/apps/marketing-demo/src/app/seed-data.ts +1 -1
  88. package/samples/apps/marketing-demo/src/app/seed.ts +4 -4
  89. package/samples/apps/marketing-demo/src/app/server.ts +3 -3
  90. package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/feature.ts +15 -12
  91. package/samples/apps/marketing-demo/src/features/ticketing/i18n.ts +100 -0
  92. package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/ticket.ts +4 -4
  93. package/samples/apps/marketing-demo/src/features/ticketing/web/index.ts +7 -0
  94. package/samples/apps/use-all-bundled/feature-manifest.json +67 -67
  95. package/samples/apps/use-all-bundled/kumiko/migrations/0064_helpdesk-rename.rebuild.json +4 -0
  96. package/samples/apps/use-all-bundled/package.json +1 -1
  97. package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
  98. package/samples/apps/use-all-bundled/src/app/screens-feature.ts +10 -10
  99. package/samples/apps/use-all-bundled/src/run-config.ts +6 -6
  100. package/samples/recipes/api-docs/README.md +3 -3
  101. package/samples/recipes/api-docs/api-docs/de/events.md +14 -14
  102. package/samples/recipes/api-docs/api-docs/de/overview.md +3 -3
  103. package/samples/recipes/api-docs/api-docs/de/reference/tickets.md +10 -10
  104. package/samples/recipes/api-docs/api-docs/de/tokens.md +4 -4
  105. package/samples/recipes/api-docs/api-docs/en/events.md +14 -14
  106. package/samples/recipes/api-docs/api-docs/en/overview.md +3 -3
  107. package/samples/recipes/api-docs/api-docs/en/reference/tickets.md +10 -10
  108. package/samples/recipes/api-docs/api-docs/en/tokens.md +4 -4
  109. package/samples/recipes/api-docs/api-docs/index.json +22 -22
  110. package/samples/recipes/api-docs/api-docs/openapi.json +67 -67
  111. package/samples/recipes/api-docs/api-examples/ticket-close.json +1 -1
  112. package/samples/recipes/api-docs/api-examples/ticket-create.json +1 -1
  113. package/samples/recipes/api-docs/api-examples/ticket-detail.json +1 -1
  114. package/samples/recipes/api-docs/api-examples/ticket-list.json +1 -1
  115. package/samples/recipes/api-docs/api-examples/ticket-update.json +1 -1
  116. package/samples/recipes/api-docs/api-examples/webhooks/ticket-closed.json +1 -1
  117. package/samples/recipes/api-docs/kumiko.config.ts +4 -4
  118. package/samples/recipes/api-docs/src/feature.ts +44 -44
  119. package/samples/recipes/golden-path/src/feature.ts +1 -1
  120. package/samples/recipes/helpdesk/README.md +56 -0
  121. package/samples/recipes/{contact → helpdesk}/package.json +2 -2
  122. package/samples/recipes/{contact → helpdesk}/src/feature.ts +11 -8
  123. package/packages/bundled-features/src/contact/client/contact-website-client.ts +0 -29
  124. package/packages/bundled-features/src/contact/client/index.ts +0 -9
  125. package/packages/bundled-features/src/contact/index.ts +0 -29
  126. package/packages/bundled-features/src/contact/panels.ts +0 -28
  127. package/packages/bundled-features/src/contact/web/constants.ts +0 -160
  128. package/packages/bundled-features/src/contact/web/index.ts +0 -29
  129. package/samples/apps/marketing-demo/src/features/helpdesk/i18n.ts +0 -100
  130. package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +0 -7
  131. package/samples/recipes/contact/README.md +0 -52
  132. /package/packages/bundled-features/src/{contact → helpdesk}/handlers/access.ts +0 -0
  133. /package/packages/bundled-features/src/{contact → helpdesk}/pow.ts +0 -0
  134. /package/packages/bundled-features/src/{contact → helpdesk}/user-agent.ts +0 -0
  135. /package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/index.ts +0 -0
@@ -0,0 +1,29 @@
1
+ export {
2
+ helpdeskReplyEntity,
3
+ helpdeskReplyTable,
4
+ helpdeskRequestEntity,
5
+ helpdeskRequestTable,
6
+ } from "./entity.ts";
7
+ export { createHelpdeskFeature } from "./feature.ts";
8
+ export type { HelpdeskOptions } from "./options.ts";
9
+ export { helpdeskOpenRequestsPanels } from "./panels.ts";
10
+ export {
11
+ HELPDESK_ADMIN_KINDS,
12
+ HELPDESK_CLIENT_PATH,
13
+ HELPDESK_DELIVERY_CHANNEL,
14
+ HELPDESK_DELIVERY_STATUS,
15
+ HELPDESK_FEATURE,
16
+ HELPDESK_FIELD_LIMITS,
17
+ HELPDESK_KIND,
18
+ HELPDESK_NOTIFICATION_TYPES,
19
+ HELPDESK_ORIGIN,
20
+ HELPDESK_REPLY_CHANNELS,
21
+ HELPDESK_SOURCE,
22
+ HELPDESK_STATUS,
23
+ HELPDESK_WEBSITE_KINDS,
24
+ HelpdeskConfigKeys,
25
+ HelpdeskErrors,
26
+ HelpdeskHandlers,
27
+ HelpdeskQueries,
28
+ HelpdeskScreens,
29
+ } from "./web/constants.ts";
@@ -19,37 +19,41 @@ import { tenantTable } from "../tenant/index.ts";
19
19
  import { TierEngineQueries } from "../tier-engine/index.ts";
20
20
  import { USER_STATUS, userTable } from "../user/index.ts";
21
21
  import {
22
- contactReplyEntity,
23
- contactReplyTable,
24
- contactRequestEntity,
25
- contactRequestTable,
22
+ helpdeskReplyEntity,
23
+ helpdeskReplyTable,
24
+ helpdeskRequestEntity,
25
+ helpdeskRequestTable,
26
26
  } from "./entity.ts";
27
27
  import {
28
- CONTACT_REPLY_CHANNELS,
29
- CONTACT_REPLY_ENTITY,
30
- CONTACT_REQUEST_ENTITY,
31
- ContactErrors,
32
- type ContactPhoneMode,
33
- type ContactReplyChannels,
28
+ HELPDESK_REPLY_CHANNELS,
29
+ HELPDESK_REPLY_ENTITY,
30
+ HELPDESK_REQUEST_ENTITY,
31
+ HelpdeskErrors,
32
+ type HelpdeskPhoneMode,
33
+ type HelpdeskReplyChannels,
34
34
  } from "./web/constants.ts";
35
35
 
36
36
  export const IN_APP_FEATURE = "channel-in-app";
37
37
  export const TELEGRAM_FEATURE = "channel-telegram";
38
38
 
39
- export const CONTACT_CROSS_TENANT_REASON = "contact is platform-wide (systemScope)";
39
+ export const HELPDESK_CROSS_TENANT_REASON = "helpdesk is platform-wide (systemScope)";
40
40
 
41
41
  export const SYSTEM_ADMIN_ROLE = "SystemAdmin";
42
- const PII_DECRYPT_REASON = "contact:user-lookup";
42
+ const PII_DECRYPT_REASON = "helpdesk:user-lookup";
43
43
 
44
44
  export const adminAccess = { roles: access.systemAdmin } as const;
45
45
  export const internalAccess = { roles: access.system } as const;
46
46
 
47
- export const requestExecutor = createEventStoreExecutor(contactRequestTable, contactRequestEntity, {
48
- entityName: CONTACT_REQUEST_ENTITY,
49
- });
47
+ export const requestExecutor = createEventStoreExecutor(
48
+ helpdeskRequestTable,
49
+ helpdeskRequestEntity,
50
+ {
51
+ entityName: HELPDESK_REQUEST_ENTITY,
52
+ },
53
+ );
50
54
 
51
- export const replyExecutor = createEventStoreExecutor(contactReplyTable, contactReplyEntity, {
52
- entityName: CONTACT_REPLY_ENTITY,
55
+ export const replyExecutor = createEventStoreExecutor(helpdeskReplyTable, helpdeskReplyEntity, {
56
+ entityName: HELPDESK_REPLY_ENTITY,
53
57
  });
54
58
 
55
59
  const MAX_REPLIES_PER_REQUEST = 200;
@@ -72,13 +76,13 @@ export function normalizeEmail(email: string): string {
72
76
  return email.toLowerCase();
73
77
  }
74
78
 
75
- export function contactDb(ctx: Pick<AppContext, "systemDb">): TenantDb {
79
+ export function helpdeskDb(ctx: Pick<AppContext, "systemDb">): TenantDb {
76
80
  if (!ctx.systemDb) {
77
81
  throw new InternalError({
78
- message: "contact requires ctx.systemDb — is r.systemScope() set on the feature?",
82
+ message: "helpdesk requires ctx.systemDb — is r.systemScope() set on the feature?",
79
83
  });
80
84
  }
81
- return ctx.systemDb.acknowledgeCrossTenant(CONTACT_CROSS_TENANT_REASON);
85
+ return ctx.systemDb.acknowledgeCrossTenant(HELPDESK_CROSS_TENANT_REASON);
82
86
  }
83
87
 
84
88
  // Requests and replies are systemStream rows, so every write targets the system tenant's stream.
@@ -119,7 +123,7 @@ export async function sendBestEffort(
119
123
  }
120
124
  await send(ctx.notify);
121
125
  } catch (err) {
122
- ctx.obs.log?.warn(`[contact] ${label} failed`, {
126
+ ctx.obs.log?.warn(`[helpdesk] ${label} failed`, {
123
127
  error: err instanceof Error ? err.message : String(err),
124
128
  });
125
129
  }
@@ -128,18 +132,18 @@ export async function sendBestEffort(
128
132
  export async function pickReplyChannels(
129
133
  ctx: Pick<HandlerContext, "hasFeature">,
130
134
  reporterUserId: string | null | undefined,
131
- ): Promise<ContactReplyChannels> {
135
+ ): Promise<HelpdeskReplyChannels> {
132
136
  const hasInApp = reporterUserId && (await ctx.hasFeature(IN_APP_FEATURE));
133
- return hasInApp ? CONTACT_REPLY_CHANNELS.EmailAndInApp : CONTACT_REPLY_CHANNELS.Email;
137
+ return hasInApp ? HELPDESK_REPLY_CHANNELS.EmailAndInApp : HELPDESK_REPLY_CHANNELS.Email;
134
138
  }
135
139
 
136
140
  export function phoneProblem(
137
- mode: ContactPhoneMode,
141
+ mode: HelpdeskPhoneMode,
138
142
  phone: string | undefined,
139
- ): (typeof ContactErrors)[keyof typeof ContactErrors] | null {
143
+ ): (typeof HelpdeskErrors)[keyof typeof HelpdeskErrors] | null {
140
144
  const present = phone !== undefined && phone !== "";
141
- if (mode === "off") return present ? ContactErrors.phoneNotAllowed : null;
142
- if (mode === "required") return present ? null : ContactErrors.phoneRequired;
145
+ if (mode === "off") return present ? HelpdeskErrors.phoneNotAllowed : null;
146
+ if (mode === "required") return present ? null : HelpdeskErrors.phoneRequired;
143
147
  return null;
144
148
  }
145
149
 
@@ -168,7 +172,7 @@ export async function loadTenantPlan(
168
172
  const tier = propertyOf(assignment, "tier");
169
173
  return typeof tier === "string" && tier !== "" ? planDisplayName(tier) : null;
170
174
  } catch (err) {
171
- ctx.obs.log?.warn("[contact] tenant plan lookup failed", {
175
+ ctx.obs.log?.warn("[helpdesk] tenant plan lookup failed", {
172
176
  error: err instanceof Error ? err.message : String(err),
173
177
  });
174
178
  return null;
@@ -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
+ }