@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
@@ -2,34 +2,34 @@ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import {
4
4
  adminAccess,
5
- contactDb,
5
+ helpdeskDb,
6
6
  loadUserLabel,
7
7
  pickReplyChannels,
8
8
  platformActor,
9
9
  requestExecutor,
10
10
  } from "../lib.ts";
11
- import type { ContactOptions } from "../options.ts";
12
- import { ContactIdSchema } from "../payloads.ts";
11
+ import type { HelpdeskOptions } from "../options.ts";
12
+ import { HelpdeskIdSchema } from "../payloads.ts";
13
13
  import {
14
- CONTACT_ORIGIN,
15
- CONTACT_REQUEST_ENTITY,
16
- CONTACT_SOURCE,
17
- ContactConfigKeys,
14
+ HELPDESK_ORIGIN,
15
+ HELPDESK_REQUEST_ENTITY,
16
+ HELPDESK_SOURCE,
17
+ HelpdeskConfigKeys,
18
18
  } from "../web/constants.ts";
19
19
 
20
- export function createRequestDetailQuery(opts: ContactOptions) {
20
+ export function createRequestDetailQuery(opts: HelpdeskOptions) {
21
21
  return defineQueryHandler({
22
22
  name: "request-detail",
23
- schema: ContactIdSchema,
23
+ schema: HelpdeskIdSchema,
24
24
  access: adminAccess,
25
25
  description:
26
26
  "Returns one contact request with its origin fields plus what the detail screen shows around it: the Reply-To address a reply goes out with (the caller's own email while none is configured), the channels a reply reaches the reporter on, the app version label and whether the request came from the website or the admin.",
27
27
  handler: async (event, ctx) => {
28
- const db = contactDb(ctx);
28
+ const db = helpdeskDb(ctx);
29
29
  const request = await requestExecutor.detail({ id: event.payload.id }, platformActor(), db);
30
- if (!request) throw new NotFoundError(CONTACT_REQUEST_ENTITY, event.payload.id);
30
+ if (!request) throw new NotFoundError(HELPDESK_REQUEST_ENTITY, event.payload.id);
31
31
 
32
- const configuredReplyTo = await ctx.config?.(ContactConfigKeys.replyTo);
32
+ const configuredReplyTo = await ctx.config?.(HelpdeskConfigKeys.replyTo);
33
33
  const replyTo =
34
34
  typeof configuredReplyTo === "string" && configuredReplyTo !== ""
35
35
  ? configuredReplyTo
@@ -41,9 +41,9 @@ export function createRequestDetailQuery(opts: ContactOptions) {
41
41
  replyChannels: await pickReplyChannels(ctx, request.reporterUserId),
42
42
  versionLabel: opts.appVersion !== undefined ? `${opts.appName} ${opts.appVersion}` : null,
43
43
  origin:
44
- request.source === CONTACT_SOURCE.Admin
45
- ? CONTACT_ORIGIN.AdminReport
46
- : CONTACT_ORIGIN.Website,
44
+ request.source === HELPDESK_SOURCE.Admin
45
+ ? HELPDESK_ORIGIN.AdminReport
46
+ : HELPDESK_ORIGIN.Website,
47
47
  };
48
48
  },
49
49
  });
@@ -3,10 +3,10 @@ import {
3
3
  type EntityDefinition,
4
4
  } from "@cosmicdrift/kumiko-framework/engine";
5
5
  import { adminAccess } from "../lib.ts";
6
- import { CONTACT_REQUEST_ENTITY } from "../web/constants.ts";
6
+ import { HELPDESK_REQUEST_ENTITY } from "../web/constants.ts";
7
7
 
8
8
  export function createRequestListQuery(requestEntity: EntityDefinition) {
9
- return defineEntityListHandler(CONTACT_REQUEST_ENTITY, requestEntity, {
9
+ return defineEntityListHandler(HELPDESK_REQUEST_ENTITY, requestEntity, {
10
10
  access: adminAccess,
11
11
  description:
12
12
  "Lists contact requests for the SystemAdmin inbox: searchable, filterable by status, kind and source, newest first; the open named filter backs the dashboard tile.",
@@ -9,7 +9,7 @@ import { fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
9
9
  import type { FileAttachmentRef } from "../../delivery/index.ts";
10
10
  import { decryptStoredPii } from "../../shared/index.ts";
11
11
  import {
12
- contactDb,
12
+ helpdeskDb,
13
13
  internalAccess,
14
14
  loadUserLabel,
15
15
  platformActor,
@@ -17,20 +17,20 @@ import {
17
17
  requestExecutor,
18
18
  sendBestEffort,
19
19
  } from "../lib.ts";
20
- import { contactReplyVariables, resolveContactMailLocale } from "../mail.ts";
21
- import type { ContactOptions } from "../options.ts";
22
- import { ContactSendReplyMailSchema } from "../payloads.ts";
20
+ import { helpdeskReplyVariables, resolveHelpdeskMailLocale } from "../mail.ts";
21
+ import type { HelpdeskOptions } from "../options.ts";
22
+ import { HelpdeskSendReplyMailSchema } from "../payloads.ts";
23
23
  import {
24
- CONTACT_NOTIFICATION_TYPES,
25
- CONTACT_REPLY_ENTITY,
26
- CONTACT_REQUEST_ENTITY,
27
- ContactConfigKeys,
28
- contactIdempotencyKeys,
24
+ HELPDESK_NOTIFICATION_TYPES,
25
+ HELPDESK_REPLY_ENTITY,
26
+ HELPDESK_REQUEST_ENTITY,
27
+ HelpdeskConfigKeys,
28
+ helpdeskIdempotencyKeys,
29
29
  } from "../web/constants.ts";
30
30
 
31
- const ATTACHMENT_LOOKUP_REASON = "contact:reply-attachment";
31
+ const ATTACHMENT_LOOKUP_REASON = "helpdesk:reply-attachment";
32
32
 
33
- export type ContactSendReplyMailData = { readonly kind: "sent"; readonly attachmentCount: number };
33
+ export type HelpdeskSendReplyMailData = { readonly kind: "sent"; readonly attachmentCount: number };
34
34
 
35
35
  type FileRefNameRow = { readonly fileName: string };
36
36
 
@@ -38,7 +38,7 @@ async function resolveAttachments(
38
38
  ctx: HandlerContext,
39
39
  fileIds: readonly string[],
40
40
  ): Promise<readonly FileAttachmentRef[]> {
41
- const db = contactDb(ctx);
41
+ const db = helpdeskDb(ctx);
42
42
  const attachments: FileAttachmentRef[] = [];
43
43
  for (const fileRefId of fileIds) {
44
44
  const row = await fetchOne<FileRefNameRow>(db, fileRefsTable, {
@@ -57,7 +57,7 @@ async function resolveReplyTo(
57
57
  ctx: HandlerContext,
58
58
  authorEmail: string | undefined,
59
59
  ): Promise<string | undefined> {
60
- const configured = await ctx.config?.(ContactConfigKeys.replyTo);
60
+ const configured = await ctx.config?.(HelpdeskConfigKeys.replyTo);
61
61
  return typeof configured === "string" && configured.trim() !== ""
62
62
  ? configured.trim()
63
63
  : authorEmail;
@@ -65,26 +65,26 @@ async function resolveReplyTo(
65
65
 
66
66
  // Runs as the platform identity: the delivery channel reads attachments of the sending tenant,
67
67
  // and the reply files live in the system tenant, whichever tenant the answering admin is in.
68
- export function createSendReplyMailHandler(opts: ContactOptions) {
68
+ export function createSendReplyMailHandler(opts: HelpdeskOptions) {
69
69
  return defineWriteHandler<
70
70
  "send-reply-mail",
71
- typeof ContactSendReplyMailSchema,
72
- ContactSendReplyMailData
71
+ typeof HelpdeskSendReplyMailSchema,
72
+ HelpdeskSendReplyMailData
73
73
  >({
74
74
  name: "send-reply-mail",
75
- schema: ContactSendReplyMailSchema,
75
+ schema: HelpdeskSendReplyMailSchema,
76
76
  access: internalAccess,
77
77
  agent: { expose: false },
78
78
  description:
79
79
  "Internal: mails a stored reply to the reporter with Reply-To, the quoted request and the reply files attached. Only the platform identity can call it.",
80
80
  handler: async (event, ctx) => {
81
- const db = contactDb(ctx);
81
+ const db = helpdeskDb(ctx);
82
82
  const { replyId } = event.payload;
83
83
  const reply = await replyExecutor.detail({ id: replyId }, platformActor(), db);
84
- if (!reply) return writeFailure(new NotFoundError(CONTACT_REPLY_ENTITY, replyId));
84
+ if (!reply) return writeFailure(new NotFoundError(HELPDESK_REPLY_ENTITY, replyId));
85
85
  const request = await requestExecutor.detail({ id: reply.requestId }, platformActor(), db);
86
86
  if (!request) {
87
- return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, reply.requestId));
87
+ return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, reply.requestId));
88
88
  }
89
89
 
90
90
  const author = await loadUserLabel(db, reply.authorUserId);
@@ -96,11 +96,11 @@ export function createSendReplyMailHandler(opts: ContactOptions) {
96
96
  const locale = request.locale ?? undefined;
97
97
 
98
98
  await sendBestEffort(ctx, "reply mail", (notify) =>
99
- notify(CONTACT_NOTIFICATION_TYPES.reply, {
99
+ notify(HELPDESK_NOTIFICATION_TYPES.reply, {
100
100
  route: { email: recipientEmail },
101
101
  recipientId: request.id,
102
102
  data: {
103
- ...contactReplyVariables({
103
+ ...helpdeskReplyVariables({
104
104
  requestSubject: request.subject,
105
105
  requestMessage: request.message,
106
106
  requestSubmittedAt: Number(request.submittedAt.epochMilliseconds),
@@ -112,9 +112,9 @@ export function createSendReplyMailHandler(opts: ContactOptions) {
112
112
  ...(replyTo !== undefined && { replyTo }),
113
113
  ...(attachments.length > 0 && { attachments }),
114
114
  },
115
- idempotencyKey: contactIdempotencyKeys.reply(replyId),
115
+ idempotencyKey: helpdeskIdempotencyKeys.reply(replyId),
116
116
  priority: "normal",
117
- locale: resolveContactMailLocale(locale),
117
+ locale: resolveHelpdeskMailLocale(locale),
118
118
  }),
119
119
  );
120
120
 
@@ -5,39 +5,43 @@ import {
5
5
  writeFailure,
6
6
  } from "@cosmicdrift/kumiko-framework/errors";
7
7
  import { adminAccess } from "../lib.ts";
8
- import { contactTestVariables, resolveContactMailLocale } from "../mail.ts";
9
- import type { ContactOptions } from "../options.ts";
10
- import { ContactEmptySchema } from "../payloads.ts";
11
- import { CONTACT_NOTIFICATION_TYPES, ContactConfigKeys, ContactErrors } from "../web/constants.ts";
8
+ import { helpdeskTestVariables, resolveHelpdeskMailLocale } from "../mail.ts";
9
+ import type { HelpdeskOptions } from "../options.ts";
10
+ import { HelpdeskEmptySchema } from "../payloads.ts";
11
+ import {
12
+ HELPDESK_NOTIFICATION_TYPES,
13
+ HelpdeskConfigKeys,
14
+ HelpdeskErrors,
15
+ } from "../web/constants.ts";
12
16
 
13
- export type ContactSendTestData = { readonly kind: "sent" };
17
+ export type HelpdeskSendTestData = { readonly kind: "sent" };
14
18
 
15
- export function createSendTestHandler(opts: ContactOptions) {
16
- return defineWriteHandler<"send-test", typeof ContactEmptySchema, ContactSendTestData>({
19
+ export function createSendTestHandler(opts: HelpdeskOptions) {
20
+ return defineWriteHandler<"send-test", typeof HelpdeskEmptySchema, HelpdeskSendTestData>({
17
21
  name: "send-test",
18
- schema: ContactEmptySchema,
22
+ schema: HelpdeskEmptySchema,
19
23
  access: adminAccess,
20
24
  agent: { expose: false },
21
25
  description:
22
26
  "Sends a test message to the configured Telegram chat; fails with a typed error when no chat is configured or the provider does not accept the message, so a SystemAdmin can verify bot token and chat id.",
23
27
  handler: async (event, ctx) => {
24
- const chatId = await ctx.config?.(ContactConfigKeys.telegramChat);
28
+ const chatId = await ctx.config?.(HelpdeskConfigKeys.telegramChat);
25
29
  if (typeof chatId !== "string" || chatId.trim() === "") {
26
- return writeFailure(new UnprocessableError(ContactErrors.telegramChatMissing));
30
+ return writeFailure(new UnprocessableError(HelpdeskErrors.telegramChatMissing));
27
31
  }
28
32
  if (!ctx.notify) {
29
33
  throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
30
34
  }
31
35
  const locale = opts.adminLocale ?? "en";
32
- const result = await ctx.notify(CONTACT_NOTIFICATION_TYPES.test, {
36
+ const result = await ctx.notify(HELPDESK_NOTIFICATION_TYPES.test, {
33
37
  route: { telegram: chatId.trim() },
34
38
  recipientId: event.user.id,
35
- data: contactTestVariables({ appName: opts.appName, locale }),
39
+ data: helpdeskTestVariables({ appName: opts.appName, locale }),
36
40
  immediate: true,
37
- locale: resolveContactMailLocale(locale),
41
+ locale: resolveHelpdeskMailLocale(locale),
38
42
  });
39
43
  if (result.deliveries.some((d) => d.status === "failed")) {
40
- return writeFailure(new UnprocessableError(ContactErrors.telegramTestFailed));
44
+ return writeFailure(new UnprocessableError(HelpdeskErrors.telegramTestFailed));
41
45
  }
42
46
  return { isSuccess: true, data: { kind: "sent" } };
43
47
  },
@@ -16,37 +16,37 @@ import { generateId } from "@cosmicdrift/kumiko-framework/utils";
16
16
  import type { PayloadRateLimitOption } from "@cosmicdrift/kumiko-types/handlers";
17
17
  import { consumeChallenge } from "../challenge.ts";
18
18
  import {
19
- contactDb,
19
+ helpdeskDb,
20
20
  normalizeEmail,
21
21
  phoneProblem,
22
22
  platformActor,
23
23
  requestExecutor,
24
24
  sendBestEffort,
25
25
  } from "../lib.ts";
26
- import { contactAcknowledgementVariables, resolveContactMailLocale } from "../mail.ts";
26
+ import { helpdeskAcknowledgementVariables, resolveHelpdeskMailLocale } from "../mail.ts";
27
27
  import {
28
- type ContactOptions,
29
- type ContactSettings,
30
28
  DEFAULT_SUBMIT_EMAIL_RATE_LIMITS,
31
29
  DEFAULT_SUBMIT_RATE_LIMIT,
30
+ type HelpdeskOptions,
31
+ type HelpdeskSettings,
32
32
  } from "../options.ts";
33
- import { type ContactSubmitInput, ContactSubmitSchema } from "../payloads.ts";
33
+ import { type HelpdeskSubmitInput, HelpdeskSubmitSchema } from "../payloads.ts";
34
34
  import { verifyProofOfWork } from "../pow.ts";
35
35
  import { deriveSubjectFromMessage } from "../subject.ts";
36
36
  import { summarizeUserAgent } from "../user-agent.ts";
37
37
  import {
38
- CONTACT_NOTIFICATION_TYPES,
39
- CONTACT_SOURCE,
40
- CONTACT_STATUS,
41
- ContactHandlers,
42
- contactIdempotencyKeys,
38
+ HELPDESK_NOTIFICATION_TYPES,
39
+ HELPDESK_SOURCE,
40
+ HELPDESK_STATUS,
41
+ HelpdeskHandlers,
42
+ helpdeskIdempotencyKeys,
43
43
  } from "../web/constants.ts";
44
44
  import { SUBMIT_ROLES } from "./access.ts";
45
45
 
46
- export type ContactSubmitData = { readonly kind: "submitted" };
46
+ export type HelpdeskSubmitData = { readonly kind: "submitted" };
47
47
 
48
48
  // Identical body for stored and silently dropped submits, so a bot learns nothing from it.
49
- const SUBMITTED: WriteResult<ContactSubmitData> = {
49
+ const SUBMITTED: WriteResult<HelpdeskSubmitData> = {
50
50
  isSuccess: true,
51
51
  data: { kind: "submitted" },
52
52
  };
@@ -54,7 +54,7 @@ const SUBMITTED: WriteResult<ContactSubmitData> = {
54
54
  type DropReason = "honeypot" | "challenge" | "too_fast" | "proof_of_work";
55
55
 
56
56
  // An explicitly bound `undefined` is an error for the postgres driver; a missing key is not.
57
- function presentOptionalFields(payload: ContactSubmitInput) {
57
+ function presentOptionalFields(payload: HelpdeskSubmitInput) {
58
58
  return {
59
59
  ...(payload.phone !== undefined && payload.phone !== "" && { phone: payload.phone }),
60
60
  ...(payload.page !== undefined && payload.page !== "" && { page: payload.page }),
@@ -62,15 +62,15 @@ function presentOptionalFields(payload: ContactSubmitInput) {
62
62
  }
63
63
 
64
64
  async function findDropReason(
65
- payload: ContactSubmitInput,
65
+ payload: HelpdeskSubmitInput,
66
66
  ctx: HandlerContext,
67
- settings: ContactSettings,
67
+ settings: HelpdeskSettings,
68
68
  ): Promise<DropReason | null> {
69
69
  if (payload.website !== undefined && payload.website.trim() !== "") return "honeypot";
70
70
  const redis = ctx.services.redis;
71
71
  if (!redis) {
72
72
  throw new InternalError({
73
- message: "contact:submit requires ctx.services.redis for the challenge store",
73
+ message: "helpdesk:submit requires ctx.services.redis for the challenge store",
74
74
  });
75
75
  }
76
76
  const issued = await consumeChallenge(redis, payload.challenge);
@@ -89,18 +89,19 @@ async function findDropReason(
89
89
  // real owner out. Only submits that passed the spam checks count. An empty list disables the limit.
90
90
  async function enforceEmailLimits(
91
91
  ctx: HandlerContext,
92
- payload: ContactSubmitInput,
92
+ payload: HelpdeskSubmitInput,
93
93
  limits: readonly PayloadRateLimitOption[],
94
94
  ): Promise<WriteFailure | null> {
95
95
  if (limits.length === 0) return null;
96
96
  const { rateLimit } = ctx.services;
97
97
  if (!rateLimit || !ctx.rateLimitDigest) {
98
98
  throw new InternalError({
99
- message: "contact:submit declares an email rate limit but no rate limiter or digest is wired",
99
+ message:
100
+ "helpdesk:submit declares an email rate limit but no rate limiter or digest is wired",
100
101
  });
101
102
  }
102
103
  const requests = limits.map(({ per, limit, windowSeconds, cost, normalize }) => ({
103
- bucket: `contact-submit:${per.payloadField}:${ctx.rateLimitDigest?.(
104
+ bucket: `helpdesk-submit:${per.payloadField}:${ctx.rateLimitDigest?.(
104
105
  normalizePayloadBucketValue(payload.email, normalize),
105
106
  )}`,
106
107
  config: { limit, windowSeconds, ...(cost !== undefined && { cost }) },
@@ -114,11 +115,11 @@ async function enforceEmailLimits(
114
115
  return null;
115
116
  }
116
117
 
117
- export function createSubmitHandler(opts: ContactOptions, settings: ContactSettings) {
118
+ export function createSubmitHandler(opts: HelpdeskOptions, settings: HelpdeskSettings) {
118
119
  const emailRateLimits = opts.emailRateLimits ?? DEFAULT_SUBMIT_EMAIL_RATE_LIMITS;
119
- return defineWriteHandler<"submit", typeof ContactSubmitSchema, ContactSubmitData>({
120
+ return defineWriteHandler<"submit", typeof HelpdeskSubmitSchema, HelpdeskSubmitData>({
120
121
  name: "submit",
121
- schema: ContactSubmitSchema,
122
+ schema: HelpdeskSubmitSchema,
122
123
  access: { roles: SUBMIT_ROLES, personalData: "public-intake", anySignedIn: true },
123
124
  rateLimit: opts.rateLimit ?? DEFAULT_SUBMIT_RATE_LIMIT,
124
125
  agent: { expose: false },
@@ -128,7 +129,7 @@ export function createSubmitHandler(opts: ContactOptions, settings: ContactSetti
128
129
  const payload = event.payload;
129
130
  const dropReason = await findDropReason(payload, ctx, settings);
130
131
  if (dropReason !== null) {
131
- ctx.obs.log?.info("[contact:submit] dropped", { reason: dropReason });
132
+ ctx.obs.log?.info("[helpdesk:submit] dropped", { reason: dropReason });
132
133
  return SUBMITTED;
133
134
  }
134
135
 
@@ -146,8 +147,8 @@ export function createSubmitHandler(opts: ContactOptions, settings: ContactSetti
146
147
  {
147
148
  id: requestId,
148
149
  kind: payload.kind,
149
- status: CONTACT_STATUS.Open,
150
- source: CONTACT_SOURCE.Website,
150
+ status: HELPDESK_STATUS.Open,
151
+ source: HELPDESK_SOURCE.Website,
151
152
  subject: deriveSubjectFromMessage(payload.message),
152
153
  message: payload.message,
153
154
  name: payload.name,
@@ -161,30 +162,30 @@ export function createSubmitHandler(opts: ContactOptions, settings: ContactSetti
161
162
  replyCount: 0,
162
163
  },
163
164
  platformActor(),
164
- contactDb(ctx),
165
+ helpdeskDb(ctx),
165
166
  );
166
167
  if (!created.isSuccess) return created;
167
168
 
168
169
  await sendBestEffort(ctx, "forward request", async () => {
169
170
  const forwarded = await ctx.dispatch.writeAs(
170
171
  platformActor(),
171
- ContactHandlers.forwardRequest,
172
+ HelpdeskHandlers.forwardRequest,
172
173
  { requestId },
173
174
  );
174
175
  if (!forwarded.isSuccess) throw new Error(forwarded.error.message);
175
176
  });
176
177
 
177
178
  await sendBestEffort(ctx, "confirmation mail", (notify) =>
178
- notify(CONTACT_NOTIFICATION_TYPES.acknowledgement, {
179
+ notify(HELPDESK_NOTIFICATION_TYPES.acknowledgement, {
179
180
  route: { email },
180
181
  recipientId: requestId,
181
- data: contactAcknowledgementVariables({
182
+ data: helpdeskAcknowledgementVariables({
182
183
  appName: opts.appName,
183
184
  locale: payload.locale,
184
185
  }),
185
- idempotencyKey: contactIdempotencyKeys.confirmation(requestId),
186
+ idempotencyKey: helpdeskIdempotencyKeys.confirmation(requestId),
186
187
  priority: "normal",
187
- locale: resolveContactMailLocale(payload.locale),
188
+ locale: resolveHelpdeskMailLocale(payload.locale),
188
189
  }),
189
190
  );
190
191
 
@@ -6,8 +6,8 @@ import {
6
6
  import { copyPendingFileRefsToTenant } from "@cosmicdrift/kumiko-framework/files";
7
7
  import type { WriteResult } from "@cosmicdrift/kumiko-types/handlers";
8
8
  import { fileContextForTenant } from "../../file-foundation/index.ts";
9
- import { contactDb, platformActor } from "../lib.ts";
10
- import { CONTACT_UPLOAD_FIELD } from "../web/constants.ts";
9
+ import { helpdeskDb, platformActor } from "../lib.ts";
10
+ import { HELPDESK_UPLOAD_FIELD } from "../web/constants.ts";
11
11
 
12
12
  // The form uploads into the submitter's tenant; the request or reply lives in the system tenant.
13
13
  export async function takeOverUploads(
@@ -21,7 +21,7 @@ export async function takeOverUploads(
21
21
  },
22
22
  ): Promise<WriteResult<readonly string[]>> {
23
23
  if (args.fileIds.length === 0) return { isSuccess: true, data: [] };
24
- const db = contactDb(ctx);
24
+ const db = helpdeskDb(ctx);
25
25
  const submitterTenantId = args.user.tenantId;
26
26
  return copyPendingFileRefsToTenant({
27
27
  source: {
@@ -29,7 +29,7 @@ export async function takeOverUploads(
29
29
  user: args.user,
30
30
  files: fileContextForTenant(ctx, submitterTenantId, submitterTenantId),
31
31
  entityType: args.screen,
32
- fieldName: CONTACT_UPLOAD_FIELD,
32
+ fieldName: HELPDESK_UPLOAD_FIELD,
33
33
  },
34
34
  target: {
35
35
  db,
@@ -38,7 +38,7 @@ export async function takeOverUploads(
38
38
  files: fileContextForTenant(ctx, submitterTenantId, SYSTEM_TENANT_ID),
39
39
  attachTo: {
40
40
  entityType: args.entityType,
41
- fieldName: CONTACT_UPLOAD_FIELD,
41
+ fieldName: HELPDESK_UPLOAD_FIELD,
42
42
  entityId: args.entityId,
43
43
  },
44
44
  },