@cosmicdrift/kumiko-samples 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 (132) 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/documents/boot-rules.ts +14 -0
  13. package/packages/bundled-features/src/documents/feature.ts +8 -4
  14. package/packages/bundled-features/src/file-derivatives/boot-rules.ts +9 -0
  15. package/packages/bundled-features/src/file-derivatives/feature.ts +6 -3
  16. package/packages/bundled-features/src/folders/boot-rules.ts +9 -0
  17. package/packages/bundled-features/src/folders/feature.ts +6 -3
  18. package/packages/bundled-features/src/helpdesk/boot-rules.ts +9 -0
  19. package/packages/bundled-features/src/{contact → helpdesk}/challenge.ts +2 -2
  20. package/packages/bundled-features/src/{contact → helpdesk}/changes.json +6 -0
  21. package/packages/bundled-features/src/{contact/client/contact-client-source.ts → helpdesk/client/helpdesk-client-source.ts} +4 -4
  22. package/packages/bundled-features/src/helpdesk/client/helpdesk-website-client.ts +29 -0
  23. package/packages/bundled-features/src/helpdesk/client/index.ts +9 -0
  24. package/packages/bundled-features/src/{contact → helpdesk}/entity.ts +35 -31
  25. package/packages/bundled-features/src/{contact → helpdesk}/feature.ts +56 -52
  26. package/packages/bundled-features/src/{contact → helpdesk}/handlers/attempts.ts +3 -3
  27. package/packages/bundled-features/src/{contact → helpdesk}/handlers/challenge.query.ts +10 -10
  28. package/packages/bundled-features/src/{contact → helpdesk}/handlers/forward-request.write.ts +25 -23
  29. package/packages/bundled-features/src/{contact → helpdesk}/handlers/mark-done.write.ts +11 -11
  30. package/packages/bundled-features/src/{contact → helpdesk}/handlers/notify-reporter-in-app.write.ts +14 -14
  31. package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.query.ts +4 -4
  32. package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.ts +2 -2
  33. package/packages/bundled-features/src/{contact → helpdesk}/handlers/replies.query.ts +6 -6
  34. package/packages/bundled-features/src/{contact → helpdesk}/handlers/reply.write.ts +30 -30
  35. package/packages/bundled-features/src/{contact → helpdesk}/handlers/report.write.ts +29 -29
  36. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-delivery.query.ts +40 -40
  37. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-detail.query.ts +15 -15
  38. package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-list.query.ts +2 -2
  39. package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-reply-mail.write.ts +24 -24
  40. package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-test.write.ts +18 -14
  41. package/packages/bundled-features/src/{contact → helpdesk}/handlers/submit.write.ts +32 -31
  42. package/packages/bundled-features/src/{contact → helpdesk}/handlers/take-over-uploads.ts +5 -5
  43. package/packages/bundled-features/src/{contact → helpdesk}/i18n.ts +78 -75
  44. package/packages/bundled-features/src/helpdesk/index.ts +29 -0
  45. package/packages/bundled-features/src/{contact → helpdesk}/lib.ts +32 -28
  46. package/packages/bundled-features/src/{contact → helpdesk}/mail.ts +56 -56
  47. package/packages/bundled-features/src/{contact → helpdesk}/options.ts +18 -16
  48. package/packages/bundled-features/src/helpdesk/panels.ts +28 -0
  49. package/packages/bundled-features/src/{contact → helpdesk}/payloads.ts +33 -33
  50. package/packages/bundled-features/src/{contact → helpdesk}/screens.ts +104 -104
  51. package/packages/bundled-features/src/{contact → helpdesk}/subject.ts +3 -3
  52. package/packages/bundled-features/src/{contact → helpdesk}/user-data-hooks.ts +17 -17
  53. package/packages/bundled-features/src/helpdesk/web/constants.ts +160 -0
  54. package/packages/bundled-features/src/helpdesk/web/index.ts +29 -0
  55. package/packages/bundled-features/src/host-routing/boot-rules.ts +27 -0
  56. package/packages/bundled-features/src/host-routing/validate-options.ts +36 -27
  57. package/packages/bundled-features/src/jobs/boot-rules.ts +9 -0
  58. package/packages/bundled-features/src/jobs/feature.ts +9 -4
  59. package/packages/bundled-features/src/legal-pages/boot-rules.ts +19 -0
  60. package/packages/bundled-features/src/legal-pages/feature.ts +6 -3
  61. package/packages/bundled-features/src/legal-pages/lib/validate-routes.ts +11 -5
  62. package/packages/bundled-features/src/metrics/boot-rules.ts +15 -0
  63. package/packages/bundled-features/src/metrics/validate.ts +8 -2
  64. package/packages/bundled-features/src/notes-history/boot-rules.ts +9 -0
  65. package/packages/bundled-features/src/notes-history/feature.ts +6 -3
  66. package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +9 -0
  67. package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +6 -3
  68. package/packages/bundled-features/src/presence/boot-rules.ts +9 -0
  69. package/packages/bundled-features/src/presence/options.ts +5 -1
  70. package/packages/bundled-features/src/readiness/boot-rules.ts +14 -0
  71. package/packages/bundled-features/src/readiness/probe-boot-check.ts +8 -6
  72. package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +6 -4
  73. package/packages/bundled-features/src/shared/boot-rules.ts +9 -0
  74. package/packages/bundled-features/src/subscription-mollie/boot-rules.ts +19 -0
  75. package/packages/bundled-features/src/subscription-mollie/feature.ts +18 -10
  76. package/packages/bundled-features/src/tags/boot-rules.ts +9 -0
  77. package/packages/bundled-features/src/tags/feature.ts +6 -3
  78. package/packages/bundled-features/src/template-resolver/boot-rules.ts +19 -0
  79. package/packages/bundled-features/src/template-resolver/feature.ts +14 -10
  80. package/packages/bundled-features/src/tenant/boot-rules.ts +9 -0
  81. package/packages/bundled-features/src/tenant/feature.ts +5 -3
  82. package/samples/apps/marketing-demo/README.md +1 -1
  83. package/samples/apps/marketing-demo/playwright.config.ts +1 -1
  84. package/samples/apps/marketing-demo/src/app/client.tsx +3 -3
  85. package/samples/apps/marketing-demo/src/app/seed-data.ts +1 -1
  86. package/samples/apps/marketing-demo/src/app/seed.ts +4 -4
  87. package/samples/apps/marketing-demo/src/app/server.ts +3 -3
  88. package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/feature.ts +15 -12
  89. package/samples/apps/marketing-demo/src/features/ticketing/i18n.ts +100 -0
  90. package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/ticket.ts +4 -4
  91. package/samples/apps/marketing-demo/src/features/ticketing/web/index.ts +7 -0
  92. package/samples/apps/use-all-bundled/feature-manifest.json +67 -67
  93. package/samples/apps/use-all-bundled/kumiko/migrations/0064_helpdesk-rename.rebuild.json +4 -0
  94. package/samples/apps/use-all-bundled/package.json +1 -1
  95. package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
  96. package/samples/apps/use-all-bundled/src/app/screens-feature.ts +10 -10
  97. package/samples/apps/use-all-bundled/src/run-config.ts +6 -6
  98. package/samples/recipes/api-docs/README.md +3 -3
  99. package/samples/recipes/api-docs/api-docs/de/events.md +14 -14
  100. package/samples/recipes/api-docs/api-docs/de/overview.md +3 -3
  101. package/samples/recipes/api-docs/api-docs/de/reference/tickets.md +10 -10
  102. package/samples/recipes/api-docs/api-docs/de/tokens.md +4 -4
  103. package/samples/recipes/api-docs/api-docs/en/events.md +14 -14
  104. package/samples/recipes/api-docs/api-docs/en/overview.md +3 -3
  105. package/samples/recipes/api-docs/api-docs/en/reference/tickets.md +10 -10
  106. package/samples/recipes/api-docs/api-docs/en/tokens.md +4 -4
  107. package/samples/recipes/api-docs/api-docs/index.json +22 -22
  108. package/samples/recipes/api-docs/api-docs/openapi.json +67 -67
  109. package/samples/recipes/api-docs/api-examples/ticket-close.json +1 -1
  110. package/samples/recipes/api-docs/api-examples/ticket-create.json +1 -1
  111. package/samples/recipes/api-docs/api-examples/ticket-detail.json +1 -1
  112. package/samples/recipes/api-docs/api-examples/ticket-list.json +1 -1
  113. package/samples/recipes/api-docs/api-examples/ticket-update.json +1 -1
  114. package/samples/recipes/api-docs/api-examples/webhooks/ticket-closed.json +1 -1
  115. package/samples/recipes/api-docs/kumiko.config.ts +4 -4
  116. package/samples/recipes/api-docs/src/feature.ts +44 -44
  117. package/samples/recipes/golden-path/src/feature.ts +1 -1
  118. package/samples/recipes/{contact → helpdesk}/README.md +16 -16
  119. package/samples/recipes/{contact → helpdesk}/package.json +2 -2
  120. package/samples/recipes/{contact → helpdesk}/src/feature.ts +6 -6
  121. package/packages/bundled-features/src/contact/client/contact-website-client.ts +0 -29
  122. package/packages/bundled-features/src/contact/client/index.ts +0 -9
  123. package/packages/bundled-features/src/contact/index.ts +0 -29
  124. package/packages/bundled-features/src/contact/panels.ts +0 -28
  125. package/packages/bundled-features/src/contact/web/constants.ts +0 -160
  126. package/packages/bundled-features/src/contact/web/index.ts +0 -29
  127. package/samples/apps/marketing-demo/src/features/helpdesk/i18n.ts +0 -100
  128. package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +0 -7
  129. /package/packages/bundled-features/src/{contact → helpdesk}/handlers/access.ts +0 -0
  130. /package/packages/bundled-features/src/{contact → helpdesk}/pow.ts +0 -0
  131. /package/packages/bundled-features/src/{contact → helpdesk}/user-agent.ts +0 -0
  132. /package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/index.ts +0 -0
@@ -0,0 +1,29 @@
1
+ import type * as z from "zod";
2
+ import type { HelpdeskSubmitSchema } from "../payloads.ts";
3
+ import type { HELPDESK_WEBSITE_KINDS, HelpdeskPhoneMode } from "../web/constants.ts";
4
+
5
+ export type HelpdeskWebsiteKind = (typeof HELPDESK_WEBSITE_KINDS)[number];
6
+
7
+ export type HelpdeskWebsiteFormOptions = {
8
+ readonly phone: HelpdeskPhoneMode;
9
+ readonly kinds: readonly HelpdeskWebsiteKind[];
10
+ };
11
+
12
+ // The client adds challenge and nonce itself and falls back to the page language for locale.
13
+ export type HelpdeskWebsiteSubmitFields = Omit<
14
+ z.input<typeof HelpdeskSubmitSchema>,
15
+ "challenge" | "nonce" | "locale"
16
+ > & { readonly locale?: z.input<typeof HelpdeskSubmitSchema>["locale"] };
17
+
18
+ export type HelpdeskWebsiteSubmitResult =
19
+ | { readonly kind: "sent" }
20
+ | { readonly kind: "rate-limited"; readonly retryAfterSeconds?: number }
21
+ | { readonly kind: "failed" };
22
+
23
+ export type HelpdeskWebsiteClient = {
24
+ load(): Promise<HelpdeskWebsiteFormOptions>;
25
+ submit(fields: HelpdeskWebsiteSubmitFields): Promise<HelpdeskWebsiteSubmitResult>;
26
+ };
27
+
28
+ // Registered by HELPDESK_CLIENT_SOURCE as window.KumikoHelpdesk.
29
+ export type HelpdeskWebsiteWindow = { readonly KumikoHelpdesk?: HelpdeskWebsiteClient };
@@ -0,0 +1,9 @@
1
+ export { HELPDESK_CLIENT_SOURCE } from "./helpdesk-client-source.ts";
2
+ export type {
3
+ HelpdeskWebsiteClient,
4
+ HelpdeskWebsiteFormOptions,
5
+ HelpdeskWebsiteKind,
6
+ HelpdeskWebsiteSubmitFields,
7
+ HelpdeskWebsiteSubmitResult,
8
+ HelpdeskWebsiteWindow,
9
+ } from "./helpdesk-website-client.ts";
@@ -11,24 +11,28 @@ import {
11
11
  import type { PersonalSubject } from "@cosmicdrift/kumiko-types/fields";
12
12
  import { DEFAULT_RETENTION_KEEP_FOR } from "./options.ts";
13
13
  import {
14
- CONTACT_KIND,
15
- CONTACT_MAX_FILES,
16
- CONTACT_REPLY_CHANNELS,
17
- CONTACT_SOURCE,
18
- CONTACT_STATUS,
14
+ HELPDESK_KIND,
15
+ HELPDESK_MAX_FILES,
16
+ HELPDESK_REPLY_CHANNELS,
17
+ HELPDESK_SOURCE,
18
+ HELPDESK_STATUS,
19
19
  } from "./web/constants.ts";
20
20
 
21
21
  const KIND_OPTIONS = [
22
- CONTACT_KIND.Question,
23
- CONTACT_KIND.Contact,
24
- CONTACT_KIND.Bug,
25
- CONTACT_KIND.Wish,
22
+ HELPDESK_KIND.Question,
23
+ HELPDESK_KIND.Contact,
24
+ HELPDESK_KIND.Bug,
25
+ HELPDESK_KIND.Wish,
26
26
  ] as const;
27
- const STATUS_OPTIONS = [CONTACT_STATUS.Open, CONTACT_STATUS.Answered, CONTACT_STATUS.Done] as const;
28
- const SOURCE_OPTIONS = [CONTACT_SOURCE.Website, CONTACT_SOURCE.Admin] as const;
27
+ const STATUS_OPTIONS = [
28
+ HELPDESK_STATUS.Open,
29
+ HELPDESK_STATUS.Answered,
30
+ HELPDESK_STATUS.Done,
31
+ ] as const;
32
+ const SOURCE_OPTIONS = [HELPDESK_SOURCE.Website, HELPDESK_SOURCE.Admin] as const;
29
33
  const REPLY_CHANNEL_OPTIONS = [
30
- CONTACT_REPLY_CHANNELS.Email,
31
- CONTACT_REPLY_CHANNELS.EmailAndInApp,
34
+ HELPDESK_REPLY_CHANNELS.Email,
35
+ HELPDESK_REPLY_CHANNELS.EmailAndInApp,
32
36
  ] as const;
33
37
 
34
38
  // A signed-in reporter is the data subject; an anonymous reporter has no user id, so the row
@@ -37,9 +41,9 @@ const REPORTER_SUBJECT: PersonalSubject = { of: "reporterUserId", whenAbsent: "s
37
41
 
38
42
  const MAX_FILE_SIZE = "10MB";
39
43
 
40
- export function createContactRequestEntity(retentionKeepFor: string = DEFAULT_RETENTION_KEEP_FOR) {
44
+ export function createHelpdeskRequestEntity(retentionKeepFor: string = DEFAULT_RETENTION_KEEP_FOR) {
41
45
  return createEntity({
42
- table: "read_contact_requests",
46
+ table: "read_helpdesk_requests",
43
47
  description:
44
48
  "A message from a website visitor or a signed-in user to the platform operators (question, contact request, bug report or wish), tracked through open, answered and done as SystemAdmins process it; name, email, phone, subject and message are the reporter's personal data.",
45
49
  systemStream: true,
@@ -52,22 +56,22 @@ export function createContactRequestEntity(retentionKeepFor: string = DEFAULT_RE
52
56
  filterable: true,
53
57
  sortable: true,
54
58
  optionTones: {
55
- [CONTACT_KIND.Bug]: "bad",
56
- [CONTACT_KIND.Question]: "accent",
57
- [CONTACT_KIND.Contact]: "accent",
58
- [CONTACT_KIND.Wish]: "neutral",
59
+ [HELPDESK_KIND.Bug]: "bad",
60
+ [HELPDESK_KIND.Question]: "accent",
61
+ [HELPDESK_KIND.Contact]: "accent",
62
+ [HELPDESK_KIND.Wish]: "neutral",
59
63
  },
60
64
  }),
61
65
  status: createSelectField({
62
66
  options: STATUS_OPTIONS,
63
67
  required: true,
64
- default: CONTACT_STATUS.Open,
68
+ default: HELPDESK_STATUS.Open,
65
69
  filterable: true,
66
70
  sortable: true,
67
71
  optionTones: {
68
- [CONTACT_STATUS.Open]: "warn",
69
- [CONTACT_STATUS.Answered]: "accent",
70
- [CONTACT_STATUS.Done]: "ok",
72
+ [HELPDESK_STATUS.Open]: "warn",
73
+ [HELPDESK_STATUS.Answered]: "accent",
74
+ [HELPDESK_STATUS.Done]: "ok",
71
75
  },
72
76
  }),
73
77
  source: createSelectField({
@@ -105,7 +109,7 @@ export function createContactRequestEntity(retentionKeepFor: string = DEFAULT_RE
105
109
  browser: createTextField({ personal: false, reason: "is_browser_summary" }),
106
110
  locale: createTextField({ personal: false, reason: "is_ui_language_preference" }),
107
111
  fileIds: createFilesField({
108
- maxCount: CONTACT_MAX_FILES,
112
+ maxCount: HELPDESK_MAX_FILES,
109
113
  maxSize: MAX_FILE_SIZE,
110
114
  personal: REPORTER_SUBJECT,
111
115
  }),
@@ -123,9 +127,9 @@ export function createContactRequestEntity(retentionKeepFor: string = DEFAULT_RE
123
127
  });
124
128
  }
125
129
 
126
- export function createContactReplyEntity(retentionKeepFor: string = DEFAULT_RETENTION_KEEP_FOR) {
130
+ export function createHelpdeskReplyEntity(retentionKeepFor: string = DEFAULT_RETENTION_KEEP_FOR) {
127
131
  return createEntity({
128
- table: "read_contact_replies",
132
+ table: "read_helpdesk_replies",
129
133
  description:
130
134
  "A SystemAdmin's answer to a contact request, with the channels it went out on; the message is the reporter's personal data because it quotes and addresses them.",
131
135
  systemStream: true,
@@ -146,7 +150,7 @@ export function createContactReplyEntity(retentionKeepFor: string = DEFAULT_RETE
146
150
  }),
147
151
  authorName: createTextField({ required: true, personal: false, reason: "is_admin_label" }),
148
152
  fileIds: createFilesField({
149
- maxCount: CONTACT_MAX_FILES,
153
+ maxCount: HELPDESK_MAX_FILES,
150
154
  maxSize: MAX_FILE_SIZE,
151
155
  personal: false,
152
156
  reason: "is_business_data",
@@ -162,7 +166,7 @@ export function createContactReplyEntity(retentionKeepFor: string = DEFAULT_RETE
162
166
  });
163
167
  }
164
168
 
165
- export const contactRequestEntity = createContactRequestEntity();
166
- export const contactReplyEntity = createContactReplyEntity();
167
- export const contactRequestTable = buildEntityTable("contact-request", contactRequestEntity);
168
- export const contactReplyTable = buildEntityTable("contact-reply", contactReplyEntity);
169
+ export const helpdeskRequestEntity = createHelpdeskRequestEntity();
170
+ export const helpdeskReplyEntity = createHelpdeskReplyEntity();
171
+ export const helpdeskRequestTable = buildEntityTable("helpdesk-request", helpdeskRequestEntity);
172
+ export const helpdeskReplyTable = buildEntityTable("helpdesk-reply", helpdeskReplyEntity);
@@ -5,12 +5,12 @@ import {
5
5
  EXT_USER_DATA,
6
6
  type FeatureDefinition,
7
7
  } from "@cosmicdrift/kumiko-framework/engine";
8
- import { CONTACT_CLIENT_SOURCE } from "./client/contact-client-source.ts";
8
+ import { HELPDESK_CLIENT_SOURCE } from "./client/helpdesk-client-source.ts";
9
9
  import {
10
- contactReplyEntity,
11
- contactRequestEntity,
12
- createContactReplyEntity,
13
- createContactRequestEntity,
10
+ createHelpdeskReplyEntity,
11
+ createHelpdeskRequestEntity,
12
+ helpdeskReplyEntity,
13
+ helpdeskRequestEntity,
14
14
  } from "./entity.ts";
15
15
  import { createChallengeQuery } from "./handlers/challenge.query.ts";
16
16
  import { createForwardRequestHandler } from "./handlers/forward-request.write.ts";
@@ -26,49 +26,51 @@ import { createRequestListQuery } from "./handlers/request-list.query.ts";
26
26
  import { createSendReplyMailHandler } from "./handlers/send-reply-mail.write.ts";
27
27
  import { createSendTestHandler } from "./handlers/send-test.write.ts";
28
28
  import { createSubmitHandler } from "./handlers/submit.write.ts";
29
- import { createContactI18n } from "./i18n.ts";
29
+ import { createHelpdeskI18n } from "./i18n.ts";
30
30
  import { TELEGRAM_FEATURE } from "./lib.ts";
31
31
  import {
32
- CONTACT_ACKNOWLEDGEMENT_VARIABLES,
33
- CONTACT_CONFIRMATION_VARIABLES,
34
- CONTACT_NEW_REQUEST_VARIABLES,
35
- CONTACT_REPLY_VARIABLES,
36
- CONTACT_TEST_VARIABLES,
37
- contactAcknowledgementTemplate,
38
- contactConfirmationTemplate,
39
- contactNewRequestTemplate,
40
- contactReplyTemplate,
41
- contactTestTemplate,
32
+ HELPDESK_ACKNOWLEDGEMENT_VARIABLES,
33
+ HELPDESK_CONFIRMATION_VARIABLES,
34
+ HELPDESK_NEW_REQUEST_VARIABLES,
35
+ HELPDESK_REPLY_VARIABLES,
36
+ HELPDESK_TEST_VARIABLES,
37
+ helpdeskAcknowledgementTemplate,
38
+ helpdeskConfirmationTemplate,
39
+ helpdeskNewRequestTemplate,
40
+ helpdeskReplyTemplate,
41
+ helpdeskTestTemplate,
42
42
  inAppTemplate,
43
43
  telegramTemplate,
44
44
  } from "./mail.ts";
45
45
  import {
46
- type ContactOptions,
47
46
  DEFAULT_RETENTION_KEEP_FOR,
48
- resolveContactSettings,
47
+ type HelpdeskOptions,
48
+ resolveHelpdeskSettings,
49
49
  } from "./options.ts";
50
- import { createContactScreens } from "./screens.ts";
51
- import { contactDeleteHook, contactExportHook } from "./user-data-hooks.ts";
52
- import { CONTACT_FEATURE } from "./web/constants.ts";
50
+ import { createHelpdeskScreens } from "./screens.ts";
51
+ import { helpdeskDeleteHook, helpdeskExportHook } from "./user-data-hooks.ts";
52
+ import { HELPDESK_FEATURE } from "./web/constants.ts";
53
53
 
54
54
  const REPLY_CONTEXT_FIELDS = ["name", "email", "replyTo"];
55
55
 
56
- export function createContactFeature(opts: ContactOptions): FeatureDefinition {
57
- const settings = resolveContactSettings(opts);
56
+ export function createHelpdeskFeature(opts: HelpdeskOptions): FeatureDefinition {
57
+ const settings = resolveHelpdeskSettings(opts);
58
58
  const telegram = opts.telegram === true;
59
59
  const keepFor = opts.retentionKeepFor ?? DEFAULT_RETENTION_KEEP_FOR;
60
60
  const requestEntity =
61
61
  keepFor === DEFAULT_RETENTION_KEEP_FOR
62
- ? contactRequestEntity
63
- : createContactRequestEntity(keepFor);
62
+ ? helpdeskRequestEntity
63
+ : createHelpdeskRequestEntity(keepFor);
64
64
  const replyEntity =
65
- keepFor === DEFAULT_RETENTION_KEEP_FOR ? contactReplyEntity : createContactReplyEntity(keepFor);
65
+ keepFor === DEFAULT_RETENTION_KEEP_FOR
66
+ ? helpdeskReplyEntity
67
+ : createHelpdeskReplyEntity(keepFor);
66
68
 
67
- return defineFeature(CONTACT_FEATURE, (r) => {
69
+ return defineFeature(HELPDESK_FEATURE, (r) => {
68
70
  r.describe(
69
- "Contact inbox: an anonymous browser client (GET /contact/client.js) submits questions, contact requests, bug reports and wishes behind a honeypot, a minimum submit time and a single-use proof-of-work challenge; signed-in users file reports from the admin. Every request is stored platform-wide and every SystemAdmin is notified by mail, optionally also in a Telegram chat (option `telegram`, off by default); the notification names only the kind, the app and a link, never name, address, phone, subject or message, because mail and Telegram cannot be shredded. SystemAdmins reply by mail (Reply-To set, attachments, quoting the original) and mark requests done; a website sender gets a fixed acknowledgement, a signed-in reporter a copy and an in-app note. Personal data is crypto-shredding-ready and the EXT_USER_DATA hooks export and erase a user's requests.",
71
+ "Helpdesk inbox: an anonymous browser client (GET /helpdesk/client.js) submits questions, contact requests, bug reports and wishes behind a honeypot, a minimum submit time and a single-use proof-of-work challenge; signed-in users file reports from the admin. Every request is stored platform-wide and every SystemAdmin is notified by mail, optionally also in a Telegram chat (option `telegram`, off by default); the notification names only the kind, the app and a link, never name, address, phone, subject or message, because mail and Telegram cannot be shredded. SystemAdmins reply by mail (Reply-To set, attachments, quoting the original) and mark requests done; a website sender gets a fixed acknowledgement, a signed-in reporter a copy and an in-app note. Personal data is crypto-shredding-ready and the EXT_USER_DATA hooks export and erase a user's requests.",
70
72
  );
71
- r.uiHints({ displayLabel: "Contact", category: "communication", recommended: false });
73
+ r.uiHints({ displayLabel: "Helpdesk", category: "communication", recommended: false });
72
74
  r.systemScope();
73
75
  r.requires({ features: ["config", "delivery", "user-data-rights", "files", "notes-history"] });
74
76
  // The feature manifest and reference are built from one mounted instance, so the off
@@ -76,7 +78,7 @@ export function createContactFeature(opts: ContactOptions): FeatureDefinition {
76
78
  if (telegram) r.requires({ features: [TELEGRAM_FEATURE] });
77
79
  else r.optionalRequires(TELEGRAM_FEATURE);
78
80
  r.adoptsBundledLists();
79
- r.translations({ keys: createContactI18n() });
81
+ r.translations({ keys: createHelpdeskI18n() });
80
82
 
81
83
  r.config({
82
84
  keys: {
@@ -102,33 +104,35 @@ export function createContactFeature(opts: ContactOptions): FeatureDefinition {
102
104
  }
103
105
 
104
106
  r.notification("new-request", {
105
- variables: CONTACT_NEW_REQUEST_VARIABLES,
106
- localizedTemplate: contactNewRequestTemplate,
107
+ variables: HELPDESK_NEW_REQUEST_VARIABLES,
108
+ localizedTemplate: helpdeskNewRequestTemplate,
107
109
  ...(telegram && { templates: { telegram: telegramTemplate } }),
108
110
  });
109
111
  r.notification("confirmation", {
110
- variables: CONTACT_CONFIRMATION_VARIABLES,
111
- localizedTemplate: contactConfirmationTemplate,
112
+ variables: HELPDESK_CONFIRMATION_VARIABLES,
113
+ localizedTemplate: helpdeskConfirmationTemplate,
112
114
  });
113
115
  r.notification("acknowledgement", {
114
- variables: CONTACT_ACKNOWLEDGEMENT_VARIABLES,
115
- localizedTemplate: contactAcknowledgementTemplate,
116
+ variables: HELPDESK_ACKNOWLEDGEMENT_VARIABLES,
117
+ localizedTemplate: helpdeskAcknowledgementTemplate,
116
118
  });
117
119
  r.notification("reply", {
118
- variables: CONTACT_REPLY_VARIABLES,
119
- localizedTemplate: contactReplyTemplate,
120
+ variables: HELPDESK_REPLY_VARIABLES,
121
+ localizedTemplate: helpdeskReplyTemplate,
122
+ });
123
+ r.notification("reply-in-app", {
124
+ templates: { inApp: inAppTemplate },
120
125
  });
121
- r.notification("reply-in-app", { templates: { inApp: inAppTemplate } });
122
126
  if (telegram) {
123
127
  r.notification("test", {
124
- variables: CONTACT_TEST_VARIABLES,
125
- localizedTemplate: contactTestTemplate,
128
+ variables: HELPDESK_TEST_VARIABLES,
129
+ localizedTemplate: helpdeskTestTemplate,
126
130
  templates: { telegram: telegramTemplate },
127
131
  });
128
132
  }
129
133
 
130
- r.entity({ name: "contact-request", ...requestEntity });
131
- r.entity({ name: "contact-reply", ...replyEntity });
134
+ r.entity({ name: "helpdesk-request", ...requestEntity });
135
+ r.entity({ name: "helpdesk-reply", ...replyEntity });
132
136
 
133
137
  r.writeHandler(createSubmitHandler(opts, settings));
134
138
  r.writeHandler(createReportHandler(opts, settings));
@@ -147,26 +151,26 @@ export function createContactFeature(opts: ContactOptions): FeatureDefinition {
147
151
  r.queryHandler(repliesQuery);
148
152
  r.queryHandler(createRequestDeliveryQuery(opts));
149
153
 
150
- for (const screen of createContactScreens(opts, settings)) r.screen(screen);
154
+ for (const screen of createHelpdeskScreens(opts, settings)) r.screen(screen);
151
155
 
152
156
  r.httpRoute({
153
157
  method: "GET",
154
- // A literal, not CONTACT_CLIENT_PATH: the feature-AST extractor only reads string literals.
155
- path: "/contact/client.js",
158
+ // A literal, not HELPDESK_CLIENT_PATH: the feature-AST extractor only reads string literals.
159
+ path: "/helpdesk/client.js",
156
160
  anonymous: true,
157
161
  handler: async (c) =>
158
- c.body(CONTACT_CLIENT_SOURCE, 200, {
162
+ c.body(HELPDESK_CLIENT_SOURCE, 200, {
159
163
  "content-type": "application/javascript; charset=utf-8",
160
164
  "cache-control": "public, max-age=300",
161
165
  }),
162
166
  });
163
167
 
164
- r.useExtension(EXT_USER_DATA, "contact-request", {
165
- export: contactExportHook,
166
- delete: contactDeleteHook,
168
+ r.useExtension(EXT_USER_DATA, "helpdesk-request", {
169
+ export: helpdeskExportHook,
170
+ delete: helpdeskDeleteHook,
167
171
  });
168
- // Replies are exported nested under their request and erased with it (contactDeleteHook).
169
- r.useExtension(EXT_USER_DATA, "contact-reply", {
172
+ // Replies are exported nested under their request and erased with it (helpdeskDeleteHook).
173
+ r.useExtension(EXT_USER_DATA, "helpdesk-reply", {
170
174
  export: async () => null,
171
175
  delete: async () => {},
172
176
  });
@@ -28,7 +28,7 @@ const readStateResultSchema = z.object({
28
28
  rows: z.array(z.object({ key: z.string(), readAt: instant.nullable() })),
29
29
  });
30
30
 
31
- export type ContactAttempt = z.infer<typeof attemptSchema>;
31
+ export type HelpdeskAttempt = z.infer<typeof attemptSchema>;
32
32
 
33
33
  function chunked(keys: readonly string[]): readonly (readonly string[])[] {
34
34
  const chunks: string[][] = [];
@@ -42,8 +42,8 @@ export async function loadAttemptsByKey(
42
42
  ctx: Pick<HandlerContext, "dispatch">,
43
43
  user: SessionUser,
44
44
  keys: readonly string[],
45
- ): Promise<readonly ContactAttempt[]> {
46
- const rows: ContactAttempt[] = [];
45
+ ): Promise<readonly HelpdeskAttempt[]> {
46
+ const rows: HelpdeskAttempt[] = [];
47
47
  for (const chunk of chunked(keys)) {
48
48
  const result = await ctx.dispatch.queryAs(user, DeliveryQueries.attemptsByKeys, {
49
49
  keys: chunk,
@@ -1,31 +1,31 @@
1
1
  import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import { issueChallenge } from "../challenge.ts";
4
- import { CHALLENGE_RATE_LIMIT, type ContactSettings } from "../options.ts";
5
- import { ContactEmptySchema } from "../payloads.ts";
6
- import { CONTACT_WEBSITE_KINDS, type ContactPhoneMode } from "../web/constants.ts";
4
+ import { CHALLENGE_RATE_LIMIT, type HelpdeskSettings } from "../options.ts";
5
+ import { HelpdeskEmptySchema } from "../payloads.ts";
6
+ import { HELPDESK_WEBSITE_KINDS, type HelpdeskPhoneMode } from "../web/constants.ts";
7
7
  import { SUBMIT_ROLES } from "./access.ts";
8
8
 
9
- export type ContactChallengeData = {
9
+ export type HelpdeskChallengeData = {
10
10
  readonly challenge: string;
11
11
  readonly bits: number;
12
- readonly phone: ContactPhoneMode;
12
+ readonly phone: HelpdeskPhoneMode;
13
13
  readonly kinds: readonly string[];
14
14
  };
15
15
 
16
- export function createChallengeQuery(settings: ContactSettings) {
16
+ export function createChallengeQuery(settings: HelpdeskSettings) {
17
17
  return defineQueryHandler({
18
18
  name: "challenge",
19
- schema: ContactEmptySchema,
19
+ schema: HelpdeskEmptySchema,
20
20
  access: { roles: SUBMIT_ROLES, personalData: "public-intake", anySignedIn: true },
21
21
  rateLimit: CHALLENGE_RATE_LIMIT,
22
22
  agent: { expose: false },
23
23
  description:
24
24
  "Public contact form bootstrap: issues a single-use proof-of-work challenge and reports which fields the form shows (phone mode, request kinds).",
25
- handler: async (_event, ctx): Promise<ContactChallengeData> => {
25
+ handler: async (_event, ctx): Promise<HelpdeskChallengeData> => {
26
26
  if (!ctx.services.redis) {
27
27
  throw new InternalError({
28
- message: "contact:challenge requires ctx.services.redis for the challenge store",
28
+ message: "helpdesk:challenge requires ctx.services.redis for the challenge store",
29
29
  });
30
30
  }
31
31
  const challenge = await issueChallenge(ctx.services.redis, {
@@ -37,7 +37,7 @@ export function createChallengeQuery(settings: ContactSettings) {
37
37
  challenge,
38
38
  bits: settings.proofOfWorkBits,
39
39
  phone: settings.phone,
40
- kinds: CONTACT_WEBSITE_KINDS,
40
+ kinds: HELPDESK_WEBSITE_KINDS,
41
41
  };
42
42
  },
43
43
  });
@@ -1,26 +1,26 @@
1
1
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import {
4
- contactDb,
4
+ helpdeskDb,
5
5
  internalAccess,
6
6
  listSystemAdminIds,
7
7
  platformActor,
8
8
  requestExecutor,
9
9
  sendBestEffort,
10
10
  } from "../lib.ts";
11
- import { contactNewRequestVariables, resolveContactMailLocale } from "../mail.ts";
12
- import type { ContactOptions } from "../options.ts";
13
- import { ContactForwardRequestSchema } from "../payloads.ts";
11
+ import { helpdeskNewRequestVariables, resolveHelpdeskMailLocale } from "../mail.ts";
12
+ import type { HelpdeskOptions } from "../options.ts";
13
+ import { HelpdeskForwardRequestSchema } from "../payloads.ts";
14
14
  import {
15
- CONTACT_NOTIFICATION_TYPES,
16
- CONTACT_REQUEST_ENTITY,
17
- ContactConfigKeys,
18
- contactIdempotencyKeys,
15
+ HELPDESK_NOTIFICATION_TYPES,
16
+ HELPDESK_REQUEST_ENTITY,
17
+ HelpdeskConfigKeys,
18
+ helpdeskIdempotencyKeys,
19
19
  } from "../web/constants.ts";
20
20
 
21
21
  const EMAIL_CHANNEL = "email";
22
22
 
23
- export type ContactForwardData = {
23
+ export type HelpdeskForwardData = {
24
24
  readonly kind: "forwarded";
25
25
  readonly adminCount: number;
26
26
  readonly telegram: boolean;
@@ -28,32 +28,32 @@ export type ContactForwardData = {
28
28
 
29
29
  // Runs as the platform identity so the notification, the config and the bot token secret are
30
30
  // read in the system tenant, whoever filed the request.
31
- export function createForwardRequestHandler(opts: ContactOptions) {
31
+ export function createForwardRequestHandler(opts: HelpdeskOptions) {
32
32
  return defineWriteHandler<
33
33
  "forward-request",
34
- typeof ContactForwardRequestSchema,
35
- ContactForwardData
34
+ typeof HelpdeskForwardRequestSchema,
35
+ HelpdeskForwardData
36
36
  >({
37
37
  name: "forward-request",
38
- schema: ContactForwardRequestSchema,
38
+ schema: HelpdeskForwardRequestSchema,
39
39
  access: internalAccess,
40
40
  agent: { expose: false },
41
41
  description:
42
42
  "Internal: forwards a stored contact request to every SystemAdmin by mail and, when a Telegram chat is configured, to that chat. Only the platform identity can call it.",
43
43
  handler: async (event, ctx) => {
44
- const db = contactDb(ctx);
44
+ const db = helpdeskDb(ctx);
45
45
  const request = await requestExecutor.detail(
46
46
  { id: event.payload.requestId },
47
47
  platformActor(),
48
48
  db,
49
49
  );
50
50
  if (!request) {
51
- return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, event.payload.requestId));
51
+ return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, event.payload.requestId));
52
52
  }
53
53
  const requestId = event.payload.requestId;
54
54
  const adminLocale = opts.adminLocale;
55
55
  const link = opts.requestLink?.(requestId);
56
- const data = contactNewRequestVariables({
56
+ const data = helpdeskNewRequestVariables({
57
57
  kind: request.kind,
58
58
  appName: opts.appName,
59
59
  link,
@@ -63,28 +63,30 @@ export function createForwardRequestHandler(opts: ContactOptions) {
63
63
  const adminIds = await listSystemAdminIds(db);
64
64
  if (adminIds.length > 0) {
65
65
  await sendBestEffort(ctx, "admin mail", (notify) =>
66
- notify(CONTACT_NOTIFICATION_TYPES.newRequest, {
66
+ notify(HELPDESK_NOTIFICATION_TYPES.newRequest, {
67
67
  to: adminIds,
68
68
  channels: [EMAIL_CHANNEL],
69
69
  data,
70
- idempotencyKey: contactIdempotencyKeys.admins(requestId),
70
+ idempotencyKey: helpdeskIdempotencyKeys.admins(requestId),
71
71
  priority: "normal",
72
- locale: resolveContactMailLocale(adminLocale),
72
+ locale: resolveHelpdeskMailLocale(adminLocale),
73
73
  }),
74
74
  );
75
75
  }
76
76
 
77
- const chatId = opts.telegram ? await ctx.config?.(ContactConfigKeys.telegramChat) : undefined;
77
+ const chatId = opts.telegram
78
+ ? await ctx.config?.(HelpdeskConfigKeys.telegramChat)
79
+ : undefined;
78
80
  const telegram = opts.telegram === true && typeof chatId === "string" && chatId.trim() !== "";
79
81
  if (telegram) {
80
82
  await sendBestEffort(ctx, "telegram", (notify) =>
81
- notify(CONTACT_NOTIFICATION_TYPES.newRequest, {
83
+ notify(HELPDESK_NOTIFICATION_TYPES.newRequest, {
82
84
  route: { telegram: chatId.trim() },
83
85
  recipientId: requestId,
84
86
  data,
85
- idempotencyKey: contactIdempotencyKeys.telegram(requestId),
87
+ idempotencyKey: helpdeskIdempotencyKeys.telegram(requestId),
86
88
  priority: "normal",
87
- locale: resolveContactMailLocale(adminLocale),
89
+ locale: resolveHelpdeskMailLocale(adminLocale),
88
90
  }),
89
91
  );
90
92
  }
@@ -1,35 +1,35 @@
1
1
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
3
- import { adminAccess, contactDb, platformActor, requestExecutor } from "../lib.ts";
4
- import { ContactMarkDoneSchema } from "../payloads.ts";
5
- import { CONTACT_REQUEST_ENTITY, CONTACT_STATUS } from "../web/constants.ts";
3
+ import { adminAccess, helpdeskDb, platformActor, requestExecutor } from "../lib.ts";
4
+ import { HelpdeskMarkDoneSchema } from "../payloads.ts";
5
+ import { HELPDESK_REQUEST_ENTITY, HELPDESK_STATUS } from "../web/constants.ts";
6
6
 
7
- export type ContactMarkDoneData = { readonly kind: "marked"; readonly changed: number };
7
+ export type HelpdeskMarkDoneData = { readonly kind: "marked"; readonly changed: number };
8
8
 
9
9
  export const markDoneHandler = defineWriteHandler<
10
10
  "mark-done",
11
- typeof ContactMarkDoneSchema,
12
- ContactMarkDoneData
11
+ typeof HelpdeskMarkDoneSchema,
12
+ HelpdeskMarkDoneData
13
13
  >({
14
14
  name: "mark-done",
15
- schema: ContactMarkDoneSchema,
15
+ schema: HelpdeskMarkDoneSchema,
16
16
  access: adminAccess,
17
17
  agent: { expose: false },
18
18
  description:
19
19
  "Marks one contact request as done without sending a reply; a finished request is left as it is.",
20
20
  handler: async (event, ctx) => {
21
- const db = contactDb(ctx);
21
+ const db = helpdeskDb(ctx);
22
22
  const { id } = event.payload;
23
23
  const request = await requestExecutor.detail({ id }, platformActor(), db);
24
- if (!request) return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, id));
25
- if (request.status === CONTACT_STATUS.Done) {
24
+ if (!request) return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, id));
25
+ if (request.status === HELPDESK_STATUS.Done) {
26
26
  return { isSuccess: true, data: { kind: "marked", changed: 0 } };
27
27
  }
28
28
  const updated = await requestExecutor.update(
29
29
  {
30
30
  id,
31
31
  version: request.version,
32
- changes: { status: CONTACT_STATUS.Done, closedAt: ctx.tz.now() },
32
+ changes: { status: HELPDESK_STATUS.Done, closedAt: ctx.tz.now() },
33
33
  },
34
34
  platformActor(),
35
35
  db,
@@ -1,12 +1,12 @@
1
1
  import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
2
2
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
3
3
  import { tenantMembershipsTable } from "../../tenant/index.ts";
4
- import { contactDb, IN_APP_FEATURE, internalAccess, sendBestEffort } from "../lib.ts";
5
- import { contactReplyInAppData, resolveContactMailLocale } from "../mail.ts";
6
- import { ContactNotifyReporterInAppSchema } from "../payloads.ts";
7
- import { CONTACT_NOTIFICATION_TYPES, contactIdempotencyKeys } from "../web/constants.ts";
4
+ import { helpdeskDb, IN_APP_FEATURE, internalAccess, sendBestEffort } from "../lib.ts";
5
+ import { helpdeskReplyInAppData, resolveHelpdeskMailLocale } from "../mail.ts";
6
+ import { HelpdeskNotifyReporterInAppSchema } from "../payloads.ts";
7
+ import { HELPDESK_NOTIFICATION_TYPES, helpdeskIdempotencyKeys } from "../web/constants.ts";
8
8
 
9
- export type ContactNotifyReporterData = {
9
+ export type HelpdeskNotifyReporterData = {
10
10
  readonly kind: "notified" | "skipped";
11
11
  };
12
12
 
@@ -14,33 +14,33 @@ export type ContactNotifyReporterData = {
14
14
  // tenant's inbox. The note names the author only; the answer itself goes by mail.
15
15
  export const notifyReporterInAppHandler = defineWriteHandler<
16
16
  "notify-reporter-in-app",
17
- typeof ContactNotifyReporterInAppSchema,
18
- ContactNotifyReporterData
17
+ typeof HelpdeskNotifyReporterInAppSchema,
18
+ HelpdeskNotifyReporterData
19
19
  >({
20
20
  name: "notify-reporter-in-app",
21
- schema: ContactNotifyReporterInAppSchema,
21
+ schema: HelpdeskNotifyReporterInAppSchema,
22
22
  access: internalAccess,
23
23
  agent: { expose: false },
24
24
  description:
25
- "Internal: adds an in-app note about a contact reply to a signed-in reporter in the reporter's own tenant; skipped when the reporter is no longer a member or in-app delivery is not mounted.",
25
+ "Internal: adds an in-app note about a helpdesk reply to a signed-in reporter in the reporter's own tenant; skipped when the reporter is no longer a member or in-app delivery is not mounted.",
26
26
  handler: async (event, ctx) => {
27
27
  const { userId, replyId, authorName, locale } = event.payload;
28
28
  if (!(await ctx.hasFeature(IN_APP_FEATURE)))
29
29
  return { isSuccess: true, data: { kind: "skipped" } };
30
- const membership = await fetchOne(contactDb(ctx), tenantMembershipsTable, {
30
+ const membership = await fetchOne(helpdeskDb(ctx), tenantMembershipsTable, {
31
31
  userId,
32
32
  tenantId: event.user.tenantId,
33
33
  });
34
34
  if (!membership) return { isSuccess: true, data: { kind: "skipped" } };
35
35
 
36
36
  await sendBestEffort(ctx, "reply in-app note", (notify) =>
37
- notify(CONTACT_NOTIFICATION_TYPES.replyInApp, {
37
+ notify(HELPDESK_NOTIFICATION_TYPES.replyInApp, {
38
38
  route: { inApp: userId },
39
39
  recipientId: userId,
40
- data: contactReplyInAppData({ authorName, locale }),
41
- idempotencyKey: contactIdempotencyKeys.replyInApp(replyId),
40
+ data: helpdeskReplyInAppData({ authorName, locale }),
41
+ idempotencyKey: helpdeskIdempotencyKeys.replyInApp(replyId),
42
42
  priority: "normal",
43
- locale: resolveContactMailLocale(locale),
43
+ locale: resolveHelpdeskMailLocale(locale),
44
44
  }),
45
45
  );
46
46
  return { isSuccess: true, data: { kind: "notified" } };