@cosmicdrift/kumiko-bundled-features 0.412.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 (166) hide show
  1. package/dist/admin-shell/feature.d.ts +1 -1
  2. package/dist/agent-tools/api-docs/anchors.js +1 -1
  3. package/dist/auth-email-password/boot-rules.d.ts +7 -0
  4. package/dist/auth-email-password/boot-rules.js +7 -0
  5. package/dist/auth-email-password/feature.js +6 -13
  6. package/dist/auth-email-password/validate-options.d.ts +5 -0
  7. package/dist/auth-email-password/validate-options.js +15 -0
  8. package/dist/billing-foundation/boot-rules.d.ts +22 -0
  9. package/dist/billing-foundation/boot-rules.js +22 -0
  10. package/dist/billing-foundation/validate-options.js +56 -18
  11. package/dist/cap-overview/boot-rules.d.ts +12 -0
  12. package/dist/cap-overview/boot-rules.js +12 -0
  13. package/dist/cap-overview/feature.js +8 -3
  14. package/dist/documents/boot-rules.d.ts +12 -0
  15. package/dist/documents/boot-rules.js +12 -0
  16. package/dist/documents/feature.js +8 -3
  17. package/dist/file-derivatives/boot-rules.d.ts +7 -0
  18. package/dist/file-derivatives/boot-rules.js +7 -0
  19. package/dist/file-derivatives/feature.js +5 -2
  20. package/dist/folders/boot-rules.d.ts +7 -0
  21. package/dist/folders/boot-rules.js +7 -0
  22. package/dist/folders/feature.js +8 -5
  23. package/dist/helpdesk/boot-rules.d.ts +7 -0
  24. package/dist/helpdesk/boot-rules.js +7 -0
  25. package/dist/{contact → helpdesk}/challenge.js +2 -2
  26. package/dist/helpdesk/client/helpdesk-client-source.d.ts +1 -0
  27. package/dist/{contact/client/contact-client-source.js → helpdesk/client/helpdesk-client-source.js} +4 -4
  28. package/dist/helpdesk/client/helpdesk-website-client.d.ts +26 -0
  29. package/dist/helpdesk/client/index.d.ts +2 -0
  30. package/dist/helpdesk/client/index.js +1 -0
  31. package/dist/{contact → helpdesk}/entity.d.ts +6 -6
  32. package/dist/{contact → helpdesk}/entity.js +31 -27
  33. package/dist/helpdesk/feature.d.ts +3 -0
  34. package/dist/{contact → helpdesk}/feature.js +43 -39
  35. package/dist/{contact → helpdesk}/handlers/attempts.d.ts +2 -2
  36. package/dist/helpdesk/handlers/challenge.query.d.ts +9 -0
  37. package/dist/{contact → helpdesk}/handlers/challenge.query.js +5 -5
  38. package/dist/helpdesk/handlers/forward-request.write.d.ts +9 -0
  39. package/dist/{contact → helpdesk}/handlers/forward-request.write.js +17 -15
  40. package/dist/{contact → helpdesk}/handlers/mark-done.write.d.ts +2 -2
  41. package/dist/{contact → helpdesk}/handlers/mark-done.write.js +8 -8
  42. package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.d.ts +2 -2
  43. package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.js +11 -11
  44. package/dist/{contact → helpdesk}/handlers/open-count.js +2 -2
  45. package/dist/{contact → helpdesk}/handlers/open-count.query.js +4 -4
  46. package/dist/{contact → helpdesk}/handlers/replies.query.js +6 -6
  47. package/dist/{contact → helpdesk}/handlers/reply.write.d.ts +4 -4
  48. package/dist/{contact → helpdesk}/handlers/reply.write.js +16 -16
  49. package/dist/helpdesk/handlers/report.write.d.ts +16 -0
  50. package/dist/{contact → helpdesk}/handlers/report.write.js +17 -17
  51. package/dist/helpdesk/handlers/request-delivery.query.d.ts +16 -0
  52. package/dist/{contact → helpdesk}/handlers/request-delivery.query.js +24 -24
  53. package/dist/{contact → helpdesk}/handlers/request-detail.query.d.ts +3 -3
  54. package/dist/{contact → helpdesk}/handlers/request-detail.query.js +10 -10
  55. package/dist/{contact → helpdesk}/handlers/request-list.query.js +2 -2
  56. package/dist/helpdesk/handlers/send-reply-mail.write.d.ts +8 -0
  57. package/dist/{contact → helpdesk}/handlers/send-reply-mail.write.js +15 -15
  58. package/dist/helpdesk/handlers/send-test.write.d.ts +5 -0
  59. package/dist/{contact → helpdesk}/handlers/send-test.write.js +10 -10
  60. package/dist/{contact → helpdesk}/handlers/submit.write.d.ts +4 -4
  61. package/dist/{contact → helpdesk}/handlers/submit.write.js +17 -17
  62. package/dist/{contact → helpdesk}/handlers/take-over-uploads.js +5 -5
  63. package/dist/{contact → helpdesk}/i18n.d.ts +1 -1
  64. package/dist/{contact → helpdesk}/i18n.js +78 -75
  65. package/dist/helpdesk/index.d.ts +5 -0
  66. package/dist/helpdesk/index.js +4 -0
  67. package/dist/{contact → helpdesk}/lib.d.ts +5 -5
  68. package/dist/{contact → helpdesk}/lib.js +16 -16
  69. package/dist/{contact → helpdesk}/mail.d.ts +20 -20
  70. package/dist/{contact → helpdesk}/mail.js +47 -47
  71. package/dist/{contact → helpdesk}/options.d.ts +6 -6
  72. package/dist/helpdesk/options.js +36 -0
  73. package/dist/helpdesk/panels.d.ts +2 -0
  74. package/dist/helpdesk/panels.js +21 -0
  75. package/dist/{contact → helpdesk}/payloads.d.ts +11 -11
  76. package/dist/{contact → helpdesk}/payloads.js +28 -28
  77. package/dist/helpdesk/screens.d.ts +5 -0
  78. package/dist/{contact → helpdesk}/screens.js +87 -87
  79. package/dist/{contact → helpdesk}/subject.js +3 -3
  80. package/dist/helpdesk/user-data-hooks.d.ts +3 -0
  81. package/dist/{contact → helpdesk}/user-data-hooks.js +15 -15
  82. package/dist/helpdesk/web/constants.d.ts +127 -0
  83. package/dist/helpdesk/web/constants.js +126 -0
  84. package/dist/helpdesk/web/index.d.ts +1 -0
  85. package/dist/helpdesk/web/index.js +1 -0
  86. package/dist/host-routing/boot-rules.d.ts +22 -0
  87. package/dist/host-routing/boot-rules.js +22 -0
  88. package/dist/host-routing/validate-options.js +35 -11
  89. package/dist/jobs/boot-rules.d.ts +7 -0
  90. package/dist/jobs/boot-rules.js +7 -0
  91. package/dist/jobs/feature.js +5 -2
  92. package/dist/legal-pages/boot-rules.d.ts +17 -0
  93. package/dist/legal-pages/boot-rules.js +17 -0
  94. package/dist/legal-pages/feature.js +5 -2
  95. package/dist/legal-pages/lib/validate-routes.js +11 -3
  96. package/dist/metrics/boot-rules.d.ts +12 -0
  97. package/dist/metrics/boot-rules.js +12 -0
  98. package/dist/metrics/validate.js +8 -2
  99. package/dist/notes-history/boot-rules.d.ts +7 -0
  100. package/dist/notes-history/boot-rules.js +7 -0
  101. package/dist/notes-history/feature.js +7 -4
  102. package/dist/personal-access-tokens/boot-rules.d.ts +7 -0
  103. package/dist/personal-access-tokens/boot-rules.js +7 -0
  104. package/dist/personal-access-tokens/scope-events-check.js +7 -4
  105. package/dist/presence/boot-rules.d.ts +7 -0
  106. package/dist/presence/boot-rules.js +7 -0
  107. package/dist/presence/options.js +5 -1
  108. package/dist/readiness/boot-rules.d.ts +12 -0
  109. package/dist/readiness/boot-rules.js +12 -0
  110. package/dist/readiness/probe-boot-check.js +8 -3
  111. package/dist/shared/assert-no-where-rule-in-ownership-write.d.ts +1 -1
  112. package/dist/shared/assert-no-where-rule-in-ownership-write.js +11 -7
  113. package/dist/shared/boot-rules.d.ts +7 -0
  114. package/dist/shared/boot-rules.js +7 -0
  115. package/dist/subscription-mollie/boot-rules.d.ts +17 -0
  116. package/dist/subscription-mollie/boot-rules.js +17 -0
  117. package/dist/subscription-mollie/feature.js +13 -6
  118. package/dist/tags/boot-rules.d.ts +7 -0
  119. package/dist/tags/boot-rules.js +7 -0
  120. package/dist/tags/feature.js +8 -5
  121. package/dist/template-resolver/boot-rules.d.ts +17 -0
  122. package/dist/template-resolver/boot-rules.js +17 -0
  123. package/dist/template-resolver/feature.js +14 -5
  124. package/dist/tenant/boot-rules.d.ts +7 -0
  125. package/dist/tenant/boot-rules.js +7 -0
  126. package/dist/tenant/feature.js +5 -2
  127. package/kumiko-es-tables.json +4 -4
  128. package/package.json +29 -29
  129. package/src/{contact → helpdesk}/changes.json +6 -0
  130. package/dist/contact/client/contact-client-source.d.ts +0 -1
  131. package/dist/contact/client/contact-website-client.d.ts +0 -26
  132. package/dist/contact/client/index.d.ts +0 -2
  133. package/dist/contact/client/index.js +0 -1
  134. package/dist/contact/feature.d.ts +0 -3
  135. package/dist/contact/handlers/challenge.query.d.ts +0 -9
  136. package/dist/contact/handlers/forward-request.write.d.ts +0 -9
  137. package/dist/contact/handlers/report.write.d.ts +0 -16
  138. package/dist/contact/handlers/request-delivery.query.d.ts +0 -16
  139. package/dist/contact/handlers/send-reply-mail.write.d.ts +0 -8
  140. package/dist/contact/handlers/send-test.write.d.ts +0 -5
  141. package/dist/contact/index.d.ts +0 -5
  142. package/dist/contact/index.js +0 -4
  143. package/dist/contact/options.js +0 -32
  144. package/dist/contact/panels.d.ts +0 -2
  145. package/dist/contact/panels.js +0 -21
  146. package/dist/contact/screens.d.ts +0 -5
  147. package/dist/contact/user-data-hooks.d.ts +0 -3
  148. package/dist/contact/web/constants.d.ts +0 -127
  149. package/dist/contact/web/constants.js +0 -126
  150. package/dist/contact/web/index.d.ts +0 -1
  151. package/dist/contact/web/index.js +0 -1
  152. /package/dist/{contact → helpdesk}/challenge.d.ts +0 -0
  153. /package/dist/{contact/client/contact-website-client.js → helpdesk/client/helpdesk-website-client.js} +0 -0
  154. /package/dist/{contact → helpdesk}/handlers/access.d.ts +0 -0
  155. /package/dist/{contact → helpdesk}/handlers/access.js +0 -0
  156. /package/dist/{contact → helpdesk}/handlers/attempts.js +0 -0
  157. /package/dist/{contact → helpdesk}/handlers/open-count.d.ts +0 -0
  158. /package/dist/{contact → helpdesk}/handlers/open-count.query.d.ts +0 -0
  159. /package/dist/{contact → helpdesk}/handlers/replies.query.d.ts +0 -0
  160. /package/dist/{contact → helpdesk}/handlers/request-list.query.d.ts +0 -0
  161. /package/dist/{contact → helpdesk}/handlers/take-over-uploads.d.ts +0 -0
  162. /package/dist/{contact → helpdesk}/pow.d.ts +0 -0
  163. /package/dist/{contact → helpdesk}/pow.js +0 -0
  164. /package/dist/{contact → helpdesk}/subject.d.ts +0 -0
  165. /package/dist/{contact → helpdesk}/user-agent.d.ts +0 -0
  166. /package/dist/{contact → helpdesk}/user-agent.js +0 -0
@@ -1,19 +1,19 @@
1
1
  import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
- import { adminAccess, contactDb, listRepliesOf, platformActor, requestExecutor } from "../lib.js";
4
- import { ContactIdSchema } from "../payloads.js";
5
- import { CONTACT_REQUEST_ENTITY } from "../web/constants.js";
3
+ import { adminAccess, helpdeskDb, listRepliesOf, platformActor, requestExecutor } from "../lib.js";
4
+ import { HelpdeskIdSchema } from "../payloads.js";
5
+ import { HELPDESK_REQUEST_ENTITY } from "../web/constants.js";
6
6
  export const repliesQuery = defineQueryHandler({
7
7
  name: "replies",
8
- schema: ContactIdSchema,
8
+ schema: HelpdeskIdSchema,
9
9
  access: adminAccess,
10
10
  description: "Returns the answers SystemAdmins sent to one contact request (id, sent time, author name, message), oldest first, as flat rows for a related list; the request itself is not part of it.",
11
11
  handler: async (event, ctx) => {
12
- const db = contactDb(ctx);
12
+ const db = helpdeskDb(ctx);
13
13
  const { id } = event.payload;
14
14
  const request = await requestExecutor.detail({ id }, platformActor(), db);
15
15
  if (!request)
16
- throw new NotFoundError(CONTACT_REQUEST_ENTITY, id);
16
+ throw new NotFoundError(HELPDESK_REQUEST_ENTITY, id);
17
17
  const replies = await listRepliesOf(db, id);
18
18
  return {
19
19
  rows: replies.map((reply) => ({
@@ -1,12 +1,12 @@
1
- import { CONTACT_STATUS } from "../web/constants.ts";
2
- export type ContactReplyData = {
1
+ import { HELPDESK_STATUS } from "../web/constants.ts";
2
+ export type HelpdeskReplyData = {
3
3
  readonly kind: "replied";
4
4
  readonly id: string;
5
- readonly status: typeof CONTACT_STATUS.Answered | typeof CONTACT_STATUS.Done;
5
+ readonly status: typeof HELPDESK_STATUS.Answered | typeof HELPDESK_STATUS.Done;
6
6
  };
7
7
  export declare function createReplyHandler(): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"reply", import("zod").ZodObject<{
8
8
  requestId: import("zod").ZodUUID;
9
9
  message: import("zod").ZodString;
10
10
  fileIds: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUUID>>;
11
11
  markDone: import("zod").ZodDefault<import("zod").ZodBoolean>;
12
- }, import("zod/v4/core").$strict>, ContactReplyData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
12
+ }, import("zod/v4/core").$strict>, HelpdeskReplyData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -2,9 +2,9 @@ import { createSystemUser, defineWriteHandler, } from "@cosmicdrift/kumiko-frame
2
2
  import { NotFoundError, UnprocessableError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import { generateId } from "@cosmicdrift/kumiko-framework/utils";
4
4
  import { parseTenantId } from "@cosmicdrift/kumiko-types/identifiers";
5
- import { adminAccess, contactDb, loadUserLabel, pickReplyChannels, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
6
- import { ContactReplySchema } from "../payloads.js";
7
- import { CONTACT_REPLY_CHANNELS, CONTACT_REPLY_ENTITY, CONTACT_REQUEST_ENTITY, CONTACT_STATUS, ContactErrors, ContactHandlers, ContactScreens, } from "../web/constants.js";
5
+ import { adminAccess, helpdeskDb, loadUserLabel, pickReplyChannels, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
6
+ import { HelpdeskReplySchema } from "../payloads.js";
7
+ import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HELPDESK_STATUS, HelpdeskErrors, HelpdeskHandlers, HelpdeskScreens, } from "../web/constants.js";
8
8
  import { takeOverUploads } from "./take-over-uploads.js";
9
9
  async function noteReporterInApp(ctx, args) {
10
10
  const { request } = args;
@@ -13,7 +13,7 @@ async function noteReporterInApp(ctx, args) {
13
13
  if (!request.reporterUserId || tenantId === null)
14
14
  return;
15
15
  await sendBestEffort(ctx, "reply in-app note", async () => {
16
- const noted = await ctx.dispatch.writeAs(createSystemUser(tenantId), ContactHandlers.notifyReporterInApp, {
16
+ const noted = await ctx.dispatch.writeAs(createSystemUser(tenantId), HelpdeskHandlers.notifyReporterInApp, {
17
17
  replyId: args.replyId,
18
18
  requestId: request.id,
19
19
  userId: request.reporterUserId,
@@ -47,7 +47,7 @@ async function persistReply(ctx, db, args) {
47
47
  changes: {
48
48
  status: args.status,
49
49
  answeredAt: sentAt,
50
- ...(args.status === CONTACT_STATUS.Done && { closedAt: sentAt }),
50
+ ...(args.status === HELPDESK_STATUS.Done && { closedAt: sentAt }),
51
51
  replyCount: (request.replyCount ?? 0) + 1,
52
52
  },
53
53
  }, platformActor(), db);
@@ -55,41 +55,41 @@ async function persistReply(ctx, db, args) {
55
55
  }
56
56
  // The drawer variant the admin used is chosen by the reply channels, and pending uploads hang under that screen.
57
57
  function replyScreenFor(channels) {
58
- return channels === CONTACT_REPLY_CHANNELS.EmailAndInApp
59
- ? ContactScreens.reply
60
- : ContactScreens.replyMail;
58
+ return channels === HELPDESK_REPLY_CHANNELS.EmailAndInApp
59
+ ? HelpdeskScreens.reply
60
+ : HelpdeskScreens.replyMail;
61
61
  }
62
62
  export function createReplyHandler() {
63
63
  return defineWriteHandler({
64
64
  name: "reply",
65
- schema: ContactReplySchema,
65
+ schema: HelpdeskReplySchema,
66
66
  access: adminAccess,
67
67
  description: "A SystemAdmin answers a contact request: stores the reply (uploaded files are taken over into the system tenant), mails it to the reporter (Reply-To set, optional attachments, quoting the original request) and, for a signed-in reporter, adds an in-app note in the reporter's tenant. Marks the request answered, or done when markDone is set.",
68
68
  // The reply mail leaves the platform and cannot be recalled; reporter text may carry prompt injection.
69
69
  agent: { expose: false },
70
70
  handler: async (event, ctx) => {
71
71
  const { requestId, message, markDone } = event.payload;
72
- const db = contactDb(ctx);
72
+ const db = helpdeskDb(ctx);
73
73
  const request = await requestExecutor.detail({ id: requestId }, platformActor(), db);
74
74
  if (!request)
75
- return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, requestId));
75
+ return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, requestId));
76
76
  const replyId = generateId();
77
77
  const reporterUserId = request.reporterUserId ?? undefined;
78
78
  const channels = await pickReplyChannels(ctx, reporterUserId);
79
79
  const uploaded = await takeOverUploads(ctx, {
80
80
  user: event.user,
81
81
  screen: replyScreenFor(channels),
82
- entityType: CONTACT_REPLY_ENTITY,
82
+ entityType: HELPDESK_REPLY_ENTITY,
83
83
  entityId: replyId,
84
84
  fileIds: event.payload.fileIds ?? [],
85
85
  });
86
86
  if (!uploaded.isSuccess) {
87
- return writeFailure(new UnprocessableError(ContactErrors.attachmentNotFound));
87
+ return writeFailure(new UnprocessableError(HelpdeskErrors.attachmentNotFound));
88
88
  }
89
89
  const fileIds = uploaded.data;
90
90
  const author = await loadUserLabel(db, event.user.id);
91
91
  const authorName = author?.name ?? event.user.id;
92
- const status = markDone ? CONTACT_STATUS.Done : CONTACT_STATUS.Answered;
92
+ const status = markDone ? HELPDESK_STATUS.Done : HELPDESK_STATUS.Answered;
93
93
  const failed = await persistReply(ctx, db, {
94
94
  replyId,
95
95
  request,
@@ -103,13 +103,13 @@ export function createReplyHandler() {
103
103
  if (failed !== null)
104
104
  return failed;
105
105
  await sendBestEffort(ctx, "reply mail", async () => {
106
- const sent = await ctx.dispatch.writeAs(platformActor(), ContactHandlers.sendReplyMail, {
106
+ const sent = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.sendReplyMail, {
107
107
  replyId,
108
108
  });
109
109
  if (!sent.isSuccess)
110
110
  throw new Error(sent.error.message);
111
111
  });
112
- if (channels === CONTACT_REPLY_CHANNELS.EmailAndInApp) {
112
+ if (channels === HELPDESK_REPLY_CHANNELS.EmailAndInApp) {
113
113
  await noteReporterInApp(ctx, { replyId, request, authorName });
114
114
  }
115
115
  return { isSuccess: true, data: { kind: "replied", id: replyId, status } };
@@ -0,0 +1,16 @@
1
+ import { type HelpdeskOptions, type HelpdeskSettings } from "../options.ts";
2
+ export type HelpdeskReportData = {
3
+ readonly kind: "reported";
4
+ readonly id: string;
5
+ };
6
+ export declare function createReportHandler(opts: HelpdeskOptions, settings: HelpdeskSettings): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"report", import("zod").ZodObject<{
7
+ kind: import("zod").ZodEnum<{
8
+ bug: "bug";
9
+ question: "question";
10
+ wish: "wish";
11
+ }>;
12
+ subject: import("zod").ZodString;
13
+ message: import("zod").ZodString;
14
+ phone: import("zod").ZodOptional<import("zod").ZodString>;
15
+ fileIds: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUUID>>;
16
+ }, import("zod/v4/core").$strict>, HelpdeskReportData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -2,18 +2,18 @@ import { requestContext } from "@cosmicdrift/kumiko-framework/api";
2
2
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
3
3
  import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
4
4
  import { generateId } from "@cosmicdrift/kumiko-framework/utils";
5
- import { contactDb, loadTenantName, loadTenantPlan, loadUserLabel, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
6
- import { contactConfirmationVariables, resolveContactMailLocale } from "../mail.js";
5
+ import { helpdeskDb, loadTenantName, loadTenantPlan, loadUserLabel, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
6
+ import { helpdeskConfirmationVariables, resolveHelpdeskMailLocale } from "../mail.js";
7
7
  import { REPORT_RATE_LIMIT } from "../options.js";
8
- import { ContactReportSchema } from "../payloads.js";
8
+ import { HelpdeskReportSchema } from "../payloads.js";
9
9
  import { summarizeUserAgent } from "../user-agent.js";
10
- import { CONTACT_NOTIFICATION_TYPES, CONTACT_REQUEST_ENTITY, CONTACT_SOURCE, CONTACT_STATUS, CONTACT_UPLOAD_FIELD, ContactErrors, ContactHandlers, ContactScreens, contactIdempotencyKeys, } from "../web/constants.js";
10
+ import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_REQUEST_ENTITY, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_UPLOAD_FIELD, HelpdeskErrors, HelpdeskHandlers, HelpdeskScreens, helpdeskIdempotencyKeys, } from "../web/constants.js";
11
11
  import { REPORT_ACCESS } from "./access.js";
12
12
  import { takeOverUploads } from "./take-over-uploads.js";
13
13
  export function createReportHandler(opts, settings) {
14
14
  return defineWriteHandler({
15
15
  name: "report",
16
- schema: ContactReportSchema,
16
+ schema: HelpdeskReportSchema,
17
17
  access: REPORT_ACCESS,
18
18
  rateLimit: REPORT_RATE_LIMIT,
19
19
  agent: { expose: false },
@@ -23,10 +23,10 @@ export function createReportHandler(opts, settings) {
23
23
  const phoneIssue = phoneProblem(settings.phone, payload.phone);
24
24
  if (phoneIssue !== null)
25
25
  return writeFailure(new UnprocessableError(phoneIssue));
26
- const db = contactDb(ctx);
26
+ const db = helpdeskDb(ctx);
27
27
  const reporter = await loadUserLabel(db, event.user.id);
28
28
  if (!reporter?.email) {
29
- return writeFailure(new UnprocessableError(ContactErrors.reporterEmailMissing));
29
+ return writeFailure(new UnprocessableError(HelpdeskErrors.reporterEmailMissing));
30
30
  }
31
31
  const tenantName = await loadTenantName(db, event.user.tenantId);
32
32
  const email = normalizeEmail(reporter.email);
@@ -35,8 +35,8 @@ export function createReportHandler(opts, settings) {
35
35
  const requestId = generateId();
36
36
  const uploaded = await takeOverUploads(ctx, {
37
37
  user: event.user,
38
- screen: ContactScreens.report,
39
- entityType: CONTACT_REQUEST_ENTITY,
38
+ screen: HelpdeskScreens.report,
39
+ entityType: HELPDESK_REQUEST_ENTITY,
40
40
  entityId: requestId,
41
41
  fileIds: payload.fileIds ?? [],
42
42
  });
@@ -46,8 +46,8 @@ export function createReportHandler(opts, settings) {
46
46
  const created = await requestExecutor.create({
47
47
  id: requestId,
48
48
  kind: payload.kind,
49
- status: CONTACT_STATUS.Open,
50
- source: CONTACT_SOURCE.Admin,
49
+ status: HELPDESK_STATUS.Open,
50
+ source: HELPDESK_SOURCE.Admin,
51
51
  subject: payload.subject,
52
52
  message: payload.message,
53
53
  name: reporter.name,
@@ -61,28 +61,28 @@ export function createReportHandler(opts, settings) {
61
61
  ...(opts.appVersion !== undefined && { appVersion: opts.appVersion }),
62
62
  ...(browser !== null && { browser }),
63
63
  submittedAt: ctx.tz.now(),
64
- ...(fileIds.length > 0 && { [CONTACT_UPLOAD_FIELD]: fileIds }),
64
+ ...(fileIds.length > 0 && { [HELPDESK_UPLOAD_FIELD]: fileIds }),
65
65
  fileCount: fileIds.length,
66
66
  replyCount: 0,
67
67
  }, platformActor(), db);
68
68
  if (!created.isSuccess)
69
69
  return created;
70
70
  await sendBestEffort(ctx, "forward request", async () => {
71
- const forwarded = await ctx.dispatch.writeAs(platformActor(), ContactHandlers.forwardRequest, { requestId });
71
+ const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, { requestId });
72
72
  if (!forwarded.isSuccess)
73
73
  throw new Error(forwarded.error.message);
74
74
  });
75
- await sendBestEffort(ctx, "confirmation mail", (notify) => notify(CONTACT_NOTIFICATION_TYPES.confirmation, {
75
+ await sendBestEffort(ctx, "confirmation mail", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.confirmation, {
76
76
  route: { email },
77
77
  recipientId: requestId,
78
- data: contactConfirmationVariables({
78
+ data: helpdeskConfirmationVariables({
79
79
  appName: opts.appName,
80
80
  message: payload.message,
81
81
  locale: ctx.locale,
82
82
  }),
83
- idempotencyKey: contactIdempotencyKeys.confirmation(requestId),
83
+ idempotencyKey: helpdeskIdempotencyKeys.confirmation(requestId),
84
84
  priority: "normal",
85
- locale: resolveContactMailLocale(ctx.locale),
85
+ locale: resolveHelpdeskMailLocale(ctx.locale),
86
86
  }));
87
87
  return { isSuccess: true, data: { kind: "reported", id: requestId } };
88
88
  },
@@ -0,0 +1,16 @@
1
+ import type { HelpdeskOptions } from "../options.ts";
2
+ import { type HelpdeskDeliveryChannel, type HelpdeskDeliveryStatus } from "../web/constants.ts";
3
+ type DeliveryRow = {
4
+ readonly id: string;
5
+ readonly channel: HelpdeskDeliveryChannel;
6
+ readonly recipient: string;
7
+ readonly at: string;
8
+ readonly status: HelpdeskDeliveryStatus;
9
+ };
10
+ export declare function createRequestDeliveryQuery(opts: HelpdeskOptions): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"request-delivery", import("zod").ZodObject<{
11
+ id: import("zod").ZodUUID;
12
+ }, import("zod/v4/core").$strict>, {
13
+ rows: DeliveryRow[];
14
+ nextCursor: null;
15
+ }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
16
+ export {};
@@ -1,20 +1,20 @@
1
1
  import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import { parseTenantId } from "@cosmicdrift/kumiko-types/identifiers";
4
- import { adminAccess, contactDb, listRepliesOf, loadUserLabel, platformActor, requestExecutor, } from "../lib.js";
5
- import { ContactIdSchema } from "../payloads.js";
6
- import { CONTACT_DELIVERY_CHANNEL, CONTACT_DELIVERY_STATUS, CONTACT_REQUEST_ENTITY, ContactConfigKeys, contactIdempotencyKeys, } from "../web/constants.js";
4
+ import { adminAccess, helpdeskDb, listRepliesOf, loadUserLabel, platformActor, requestExecutor, } from "../lib.js";
5
+ import { HelpdeskIdSchema } from "../payloads.js";
6
+ import { HELPDESK_DELIVERY_CHANNEL, HELPDESK_DELIVERY_STATUS, HELPDESK_REQUEST_ENTITY, HelpdeskConfigKeys, helpdeskIdempotencyKeys, } from "../web/constants.js";
7
7
  import { loadAttemptsByKey, loadReadAtByKey } from "./attempts.js";
8
8
  function displayStatus(attemptStatus) {
9
9
  switch (attemptStatus) {
10
10
  case "sent":
11
- return CONTACT_DELIVERY_STATUS.Delivered;
11
+ return HELPDESK_DELIVERY_STATUS.Delivered;
12
12
  case "failed":
13
- return CONTACT_DELIVERY_STATUS.Failed;
13
+ return HELPDESK_DELIVERY_STATUS.Failed;
14
14
  case "skipped":
15
- return CONTACT_DELIVERY_STATUS.Skipped;
15
+ return HELPDESK_DELIVERY_STATUS.Skipped;
16
16
  default:
17
- return CONTACT_DELIVERY_STATUS.Pending;
17
+ return HELPDESK_DELIVERY_STATUS.Pending;
18
18
  }
19
19
  }
20
20
  function attemptsOf(attempts, key) {
@@ -27,35 +27,35 @@ function rowOf(attempt, channel, recipient, readAt) {
27
27
  channel,
28
28
  recipient,
29
29
  at: (read ? readAt : attempt.createdAt).toString(),
30
- status: read ? CONTACT_DELIVERY_STATUS.Read : displayStatus(attempt.status),
30
+ status: read ? HELPDESK_DELIVERY_STATUS.Read : displayStatus(attempt.status),
31
31
  };
32
32
  }
33
33
  async function adminRows(db, attempts, requestId) {
34
34
  const rows = [];
35
- for (const attempt of attemptsOf(attempts, contactIdempotencyKeys.admins(requestId))) {
35
+ for (const attempt of attemptsOf(attempts, helpdeskIdempotencyKeys.admins(requestId))) {
36
36
  const admin = attempt.recipientId ? await loadUserLabel(db, attempt.recipientId) : null;
37
- rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.Email, `${admin?.name ?? "?"} (SystemAdmin)`, null));
37
+ rows.push(rowOf(attempt, HELPDESK_DELIVERY_CHANNEL.Email, `${admin?.name ?? "?"} (SystemAdmin)`, null));
38
38
  }
39
39
  return rows;
40
40
  }
41
41
  export function createRequestDeliveryQuery(opts) {
42
42
  return defineQueryHandler({
43
43
  name: "request-delivery",
44
- schema: ContactIdSchema,
44
+ schema: HelpdeskIdSchema,
45
45
  access: adminAccess,
46
46
  description: "Returns where one contact request went and how: the admin mails, the Telegram message and each answer as mail and in-app note, each with channel, recipient, time and delivery status (an in-app note shows as read with the time it was opened), as flat rows for a related list.",
47
47
  handler: async (event, ctx) => {
48
- const db = contactDb(ctx);
48
+ const db = helpdeskDb(ctx);
49
49
  const { id } = event.payload;
50
50
  const request = await requestExecutor.detail({ id }, platformActor(), db);
51
51
  if (!request)
52
- throw new NotFoundError(CONTACT_REQUEST_ENTITY, id);
52
+ throw new NotFoundError(HELPDESK_REQUEST_ENTITY, id);
53
53
  const replies = await listRepliesOf(db, id);
54
- const replyInAppKeys = replies.map((reply) => contactIdempotencyKeys.replyInApp(reply.id));
54
+ const replyInAppKeys = replies.map((reply) => helpdeskIdempotencyKeys.replyInApp(reply.id));
55
55
  const attempts = await loadAttemptsByKey(ctx, event.user, [
56
- contactIdempotencyKeys.admins(id),
57
- contactIdempotencyKeys.telegram(id),
58
- ...replies.map((reply) => contactIdempotencyKeys.reply(reply.id)),
56
+ helpdeskIdempotencyKeys.admins(id),
57
+ helpdeskIdempotencyKeys.telegram(id),
58
+ ...replies.map((reply) => helpdeskIdempotencyKeys.reply(reply.id)),
59
59
  ...replyInAppKeys,
60
60
  ]);
61
61
  const reporterTenantId = parseTenantId(request.reporterTenantId);
@@ -64,19 +64,19 @@ export function createRequestDeliveryQuery(opts) {
64
64
  : await loadReadAtByKey(ctx, reporterTenantId, replyInAppKeys);
65
65
  const rows = [...(await adminRows(db, attempts, id))];
66
66
  if (opts.telegram) {
67
- const chat = await ctx.config?.(ContactConfigKeys.telegramChat);
68
- for (const attempt of attemptsOf(attempts, contactIdempotencyKeys.telegram(id))) {
69
- rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.Telegram, typeof chat === "string" ? chat : "", null));
67
+ const chat = await ctx.config?.(HelpdeskConfigKeys.telegramChat);
68
+ for (const attempt of attemptsOf(attempts, helpdeskIdempotencyKeys.telegram(id))) {
69
+ rows.push(rowOf(attempt, HELPDESK_DELIVERY_CHANNEL.Telegram, typeof chat === "string" ? chat : "", null));
70
70
  }
71
71
  }
72
72
  for (const reply of replies) {
73
- const mailKey = contactIdempotencyKeys.reply(reply.id);
73
+ const mailKey = helpdeskIdempotencyKeys.reply(reply.id);
74
74
  for (const attempt of attemptsOf(attempts, mailKey)) {
75
- rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.ReplyEmail, request.name, null));
75
+ rows.push(rowOf(attempt, HELPDESK_DELIVERY_CHANNEL.ReplyEmail, request.name, null));
76
76
  }
77
- const inAppKey = contactIdempotencyKeys.replyInApp(reply.id);
77
+ const inAppKey = helpdeskIdempotencyKeys.replyInApp(reply.id);
78
78
  for (const attempt of attemptsOf(attempts, inAppKey)) {
79
- rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.ReplyInApp, request.name, readAtByKey.get(inAppKey)));
79
+ rows.push(rowOf(attempt, HELPDESK_DELIVERY_CHANNEL.ReplyInApp, request.name, readAtByKey.get(inAppKey)));
80
80
  }
81
81
  }
82
82
  return { rows, nextCursor: null };
@@ -1,5 +1,5 @@
1
- import type { ContactOptions } from "../options.ts";
2
- export declare function createRequestDetailQuery(opts: ContactOptions): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"request-detail", import("zod").ZodObject<{
1
+ import type { HelpdeskOptions } from "../options.ts";
2
+ export declare function createRequestDetailQuery(opts: HelpdeskOptions): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"request-detail", import("zod").ZodObject<{
3
3
  id: import("zod").ZodUUID;
4
4
  }, import("zod/v4/core").$strict>, {
5
5
  id: string;
@@ -13,7 +13,7 @@ export declare function createRequestDetailQuery(opts: ContactOptions): import("
13
13
  deletedAt?: Temporal.Instant | null | undefined;
14
14
  deletedById?: string | null | undefined;
15
15
  replyTo: string | null;
16
- replyChannels: import("../web/constants.ts").ContactReplyChannels;
16
+ replyChannels: import("../web/constants.ts").HelpdeskReplyChannels;
17
17
  versionLabel: string | null;
18
18
  origin: "admin-report" | "website";
19
19
  answeredAt: Temporal.Instant | null;
@@ -1,20 +1,20 @@
1
1
  import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
- import { adminAccess, contactDb, loadUserLabel, pickReplyChannels, platformActor, requestExecutor, } from "../lib.js";
4
- import { ContactIdSchema } from "../payloads.js";
5
- import { CONTACT_ORIGIN, CONTACT_REQUEST_ENTITY, CONTACT_SOURCE, ContactConfigKeys, } from "../web/constants.js";
3
+ import { adminAccess, helpdeskDb, loadUserLabel, pickReplyChannels, platformActor, requestExecutor, } from "../lib.js";
4
+ import { HelpdeskIdSchema } from "../payloads.js";
5
+ import { HELPDESK_ORIGIN, HELPDESK_REQUEST_ENTITY, HELPDESK_SOURCE, HelpdeskConfigKeys, } from "../web/constants.js";
6
6
  export function createRequestDetailQuery(opts) {
7
7
  return defineQueryHandler({
8
8
  name: "request-detail",
9
- schema: ContactIdSchema,
9
+ schema: HelpdeskIdSchema,
10
10
  access: adminAccess,
11
11
  description: "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.",
12
12
  handler: async (event, ctx) => {
13
- const db = contactDb(ctx);
13
+ const db = helpdeskDb(ctx);
14
14
  const request = await requestExecutor.detail({ id: event.payload.id }, platformActor(), db);
15
15
  if (!request)
16
- throw new NotFoundError(CONTACT_REQUEST_ENTITY, event.payload.id);
17
- const configuredReplyTo = await ctx.config?.(ContactConfigKeys.replyTo);
16
+ throw new NotFoundError(HELPDESK_REQUEST_ENTITY, event.payload.id);
17
+ const configuredReplyTo = await ctx.config?.(HelpdeskConfigKeys.replyTo);
18
18
  const replyTo = typeof configuredReplyTo === "string" && configuredReplyTo !== ""
19
19
  ? configuredReplyTo
20
20
  : ((await loadUserLabel(db, event.user.id))?.email ?? null);
@@ -23,9 +23,9 @@ export function createRequestDetailQuery(opts) {
23
23
  replyTo,
24
24
  replyChannels: await pickReplyChannels(ctx, request.reporterUserId),
25
25
  versionLabel: opts.appVersion !== undefined ? `${opts.appName} ${opts.appVersion}` : null,
26
- origin: request.source === CONTACT_SOURCE.Admin
27
- ? CONTACT_ORIGIN.AdminReport
28
- : CONTACT_ORIGIN.Website,
26
+ origin: request.source === HELPDESK_SOURCE.Admin
27
+ ? HELPDESK_ORIGIN.AdminReport
28
+ : HELPDESK_ORIGIN.Website,
29
29
  };
30
30
  },
31
31
  });
@@ -1,8 +1,8 @@
1
1
  import { defineEntityListHandler, } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { adminAccess } from "../lib.js";
3
- import { CONTACT_REQUEST_ENTITY } from "../web/constants.js";
3
+ import { HELPDESK_REQUEST_ENTITY } from "../web/constants.js";
4
4
  export function createRequestListQuery(requestEntity) {
5
- return defineEntityListHandler(CONTACT_REQUEST_ENTITY, requestEntity, {
5
+ return defineEntityListHandler(HELPDESK_REQUEST_ENTITY, requestEntity, {
6
6
  access: adminAccess,
7
7
  description: "Lists contact requests for the SystemAdmin inbox: searchable, filterable by status, kind and source, newest first; the open named filter backs the dashboard tile.",
8
8
  });
@@ -0,0 +1,8 @@
1
+ import type { HelpdeskOptions } from "../options.ts";
2
+ export type HelpdeskSendReplyMailData = {
3
+ readonly kind: "sent";
4
+ readonly attachmentCount: number;
5
+ };
6
+ export declare function createSendReplyMailHandler(opts: HelpdeskOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"send-reply-mail", import("zod").ZodObject<{
7
+ replyId: import("zod").ZodUUID;
8
+ }, import("zod/v4/core").$strict>, HelpdeskSendReplyMailData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -3,13 +3,13 @@ import { defineWriteHandler, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-frame
3
3
  import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
4
4
  import { fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
5
5
  import { decryptStoredPii } from "../../shared/index.js";
6
- import { contactDb, internalAccess, loadUserLabel, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
7
- import { contactReplyVariables, resolveContactMailLocale } from "../mail.js";
8
- import { ContactSendReplyMailSchema } from "../payloads.js";
9
- import { CONTACT_NOTIFICATION_TYPES, CONTACT_REPLY_ENTITY, CONTACT_REQUEST_ENTITY, ContactConfigKeys, contactIdempotencyKeys, } from "../web/constants.js";
10
- const ATTACHMENT_LOOKUP_REASON = "contact:reply-attachment";
6
+ import { helpdeskDb, internalAccess, loadUserLabel, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
7
+ import { helpdeskReplyVariables, resolveHelpdeskMailLocale } from "../mail.js";
8
+ import { HelpdeskSendReplyMailSchema } from "../payloads.js";
9
+ import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HelpdeskConfigKeys, helpdeskIdempotencyKeys, } from "../web/constants.js";
10
+ const ATTACHMENT_LOOKUP_REASON = "helpdesk:reply-attachment";
11
11
  async function resolveAttachments(ctx, fileIds) {
12
- const db = contactDb(ctx);
12
+ const db = helpdeskDb(ctx);
13
13
  const attachments = [];
14
14
  for (const fileRefId of fileIds) {
15
15
  const row = await fetchOne(db, fileRefsTable, {
@@ -25,7 +25,7 @@ async function resolveAttachments(ctx, fileIds) {
25
25
  return attachments;
26
26
  }
27
27
  async function resolveReplyTo(ctx, authorEmail) {
28
- const configured = await ctx.config?.(ContactConfigKeys.replyTo);
28
+ const configured = await ctx.config?.(HelpdeskConfigKeys.replyTo);
29
29
  return typeof configured === "string" && configured.trim() !== ""
30
30
  ? configured.trim()
31
31
  : authorEmail;
@@ -35,19 +35,19 @@ async function resolveReplyTo(ctx, authorEmail) {
35
35
  export function createSendReplyMailHandler(opts) {
36
36
  return defineWriteHandler({
37
37
  name: "send-reply-mail",
38
- schema: ContactSendReplyMailSchema,
38
+ schema: HelpdeskSendReplyMailSchema,
39
39
  access: internalAccess,
40
40
  agent: { expose: false },
41
41
  description: "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.",
42
42
  handler: async (event, ctx) => {
43
- const db = contactDb(ctx);
43
+ const db = helpdeskDb(ctx);
44
44
  const { replyId } = event.payload;
45
45
  const reply = await replyExecutor.detail({ id: replyId }, platformActor(), db);
46
46
  if (!reply)
47
- return writeFailure(new NotFoundError(CONTACT_REPLY_ENTITY, replyId));
47
+ return writeFailure(new NotFoundError(HELPDESK_REPLY_ENTITY, replyId));
48
48
  const request = await requestExecutor.detail({ id: reply.requestId }, platformActor(), db);
49
49
  if (!request) {
50
- return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, reply.requestId));
50
+ return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, reply.requestId));
51
51
  }
52
52
  const author = await loadUserLabel(db, reply.authorUserId);
53
53
  const reporterUserId = request.reporterUserId ?? undefined;
@@ -56,11 +56,11 @@ export function createSendReplyMailHandler(opts) {
56
56
  const replyTo = await resolveReplyTo(ctx, author?.email ?? undefined);
57
57
  const attachments = await resolveAttachments(ctx, reply.fileIds ?? []);
58
58
  const locale = request.locale ?? undefined;
59
- await sendBestEffort(ctx, "reply mail", (notify) => notify(CONTACT_NOTIFICATION_TYPES.reply, {
59
+ await sendBestEffort(ctx, "reply mail", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.reply, {
60
60
  route: { email: recipientEmail },
61
61
  recipientId: request.id,
62
62
  data: {
63
- ...contactReplyVariables({
63
+ ...helpdeskReplyVariables({
64
64
  requestSubject: request.subject,
65
65
  requestMessage: request.message,
66
66
  requestSubmittedAt: Number(request.submittedAt.epochMilliseconds),
@@ -72,9 +72,9 @@ export function createSendReplyMailHandler(opts) {
72
72
  ...(replyTo !== undefined && { replyTo }),
73
73
  ...(attachments.length > 0 && { attachments }),
74
74
  },
75
- idempotencyKey: contactIdempotencyKeys.reply(replyId),
75
+ idempotencyKey: helpdeskIdempotencyKeys.reply(replyId),
76
76
  priority: "normal",
77
- locale: resolveContactMailLocale(locale),
77
+ locale: resolveHelpdeskMailLocale(locale),
78
78
  }));
79
79
  return { isSuccess: true, data: { kind: "sent", attachmentCount: attachments.length } };
80
80
  },
@@ -0,0 +1,5 @@
1
+ import type { HelpdeskOptions } from "../options.ts";
2
+ export type HelpdeskSendTestData = {
3
+ readonly kind: "sent";
4
+ };
5
+ export declare function createSendTestHandler(opts: HelpdeskOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"send-test", import("zod").ZodObject<{}, import("zod/v4/core").$strict>, HelpdeskSendTestData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -1,34 +1,34 @@
1
1
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { InternalError, UnprocessableError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import { adminAccess } from "../lib.js";
4
- import { contactTestVariables, resolveContactMailLocale } from "../mail.js";
5
- import { ContactEmptySchema } from "../payloads.js";
6
- import { CONTACT_NOTIFICATION_TYPES, ContactConfigKeys, ContactErrors } from "../web/constants.js";
4
+ import { helpdeskTestVariables, resolveHelpdeskMailLocale } from "../mail.js";
5
+ import { HelpdeskEmptySchema } from "../payloads.js";
6
+ import { HELPDESK_NOTIFICATION_TYPES, HelpdeskConfigKeys, HelpdeskErrors, } from "../web/constants.js";
7
7
  export function createSendTestHandler(opts) {
8
8
  return defineWriteHandler({
9
9
  name: "send-test",
10
- schema: ContactEmptySchema,
10
+ schema: HelpdeskEmptySchema,
11
11
  access: adminAccess,
12
12
  agent: { expose: false },
13
13
  description: "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.",
14
14
  handler: async (event, ctx) => {
15
- const chatId = await ctx.config?.(ContactConfigKeys.telegramChat);
15
+ const chatId = await ctx.config?.(HelpdeskConfigKeys.telegramChat);
16
16
  if (typeof chatId !== "string" || chatId.trim() === "") {
17
- return writeFailure(new UnprocessableError(ContactErrors.telegramChatMissing));
17
+ return writeFailure(new UnprocessableError(HelpdeskErrors.telegramChatMissing));
18
18
  }
19
19
  if (!ctx.notify) {
20
20
  throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
21
21
  }
22
22
  const locale = opts.adminLocale ?? "en";
23
- const result = await ctx.notify(CONTACT_NOTIFICATION_TYPES.test, {
23
+ const result = await ctx.notify(HELPDESK_NOTIFICATION_TYPES.test, {
24
24
  route: { telegram: chatId.trim() },
25
25
  recipientId: event.user.id,
26
- data: contactTestVariables({ appName: opts.appName, locale }),
26
+ data: helpdeskTestVariables({ appName: opts.appName, locale }),
27
27
  immediate: true,
28
- locale: resolveContactMailLocale(locale),
28
+ locale: resolveHelpdeskMailLocale(locale),
29
29
  });
30
30
  if (result.deliveries.some((d) => d.status === "failed")) {
31
- return writeFailure(new UnprocessableError(ContactErrors.telegramTestFailed));
31
+ return writeFailure(new UnprocessableError(HelpdeskErrors.telegramTestFailed));
32
32
  }
33
33
  return { isSuccess: true, data: { kind: "sent" } };
34
34
  },
@@ -1,8 +1,8 @@
1
- import { type ContactOptions, type ContactSettings } from "../options.ts";
2
- export type ContactSubmitData = {
1
+ import { type HelpdeskOptions, type HelpdeskSettings } from "../options.ts";
2
+ export type HelpdeskSubmitData = {
3
3
  readonly kind: "submitted";
4
4
  };
5
- export declare function createSubmitHandler(opts: ContactOptions, settings: ContactSettings): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"submit", import("zod").ZodObject<{
5
+ export declare function createSubmitHandler(opts: HelpdeskOptions, settings: HelpdeskSettings): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"submit", import("zod").ZodObject<{
6
6
  kind: import("zod").ZodEnum<{
7
7
  bug: "bug";
8
8
  contact: "contact";
@@ -17,4 +17,4 @@ export declare function createSubmitHandler(opts: ContactOptions, settings: Cont
17
17
  challenge: import("zod").ZodString;
18
18
  nonce: import("zod").ZodString;
19
19
  page: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>>;
20
- }, import("zod/v4/core").$strict>, ContactSubmitData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
20
+ }, import("zod/v4/core").$strict>, HelpdeskSubmitData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;