@cosmicdrift/kumiko-bundled-features 0.412.0 → 0.413.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-shell/feature.d.ts +1 -1
- package/dist/agent-tools/api-docs/anchors.js +1 -1
- package/dist/auth-email-password/boot-rules.d.ts +7 -0
- package/dist/auth-email-password/boot-rules.js +7 -0
- package/dist/auth-email-password/feature.js +6 -13
- package/dist/auth-email-password/validate-options.d.ts +5 -0
- package/dist/auth-email-password/validate-options.js +15 -0
- package/dist/billing-foundation/boot-rules.d.ts +22 -0
- package/dist/billing-foundation/boot-rules.js +22 -0
- package/dist/billing-foundation/validate-options.js +56 -18
- package/dist/cap-overview/boot-rules.d.ts +12 -0
- package/dist/cap-overview/boot-rules.js +12 -0
- package/dist/cap-overview/feature.js +8 -3
- package/dist/data-retention/feature.js +3 -2
- package/dist/documents/boot-rules.d.ts +12 -0
- package/dist/documents/boot-rules.js +12 -0
- package/dist/documents/feature.js +8 -3
- package/dist/file-derivatives/boot-rules.d.ts +7 -0
- package/dist/file-derivatives/boot-rules.js +7 -0
- package/dist/file-derivatives/feature.js +5 -2
- package/dist/folders/boot-rules.d.ts +7 -0
- package/dist/folders/boot-rules.js +7 -0
- package/dist/folders/feature.js +8 -5
- package/dist/helpdesk/boot-rules.d.ts +7 -0
- package/dist/helpdesk/boot-rules.js +7 -0
- package/dist/{contact → helpdesk}/challenge.js +2 -2
- package/dist/helpdesk/client/helpdesk-client-source.d.ts +1 -0
- package/dist/{contact/client/contact-client-source.js → helpdesk/client/helpdesk-client-source.js} +4 -4
- package/dist/helpdesk/client/helpdesk-website-client.d.ts +26 -0
- package/dist/helpdesk/client/index.d.ts +2 -0
- package/dist/helpdesk/client/index.js +1 -0
- package/dist/{contact → helpdesk}/entity.d.ts +6 -6
- package/dist/{contact → helpdesk}/entity.js +31 -27
- package/dist/helpdesk/feature.d.ts +3 -0
- package/dist/{contact → helpdesk}/feature.js +43 -39
- package/dist/{contact → helpdesk}/handlers/attempts.d.ts +2 -2
- package/dist/helpdesk/handlers/challenge.query.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/challenge.query.js +5 -5
- package/dist/helpdesk/handlers/forward-request.write.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/forward-request.write.js +17 -15
- package/dist/{contact → helpdesk}/handlers/mark-done.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/mark-done.write.js +8 -8
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.js +11 -11
- package/dist/{contact → helpdesk}/handlers/open-count.js +2 -2
- package/dist/{contact → helpdesk}/handlers/open-count.query.js +4 -4
- package/dist/{contact → helpdesk}/handlers/replies.query.js +6 -6
- package/dist/{contact → helpdesk}/handlers/reply.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/reply.write.js +16 -16
- package/dist/helpdesk/handlers/report.write.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/report.write.js +17 -17
- package/dist/helpdesk/handlers/request-delivery.query.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/request-delivery.query.js +24 -24
- package/dist/{contact → helpdesk}/handlers/request-detail.query.d.ts +3 -3
- package/dist/{contact → helpdesk}/handlers/request-detail.query.js +10 -10
- package/dist/{contact → helpdesk}/handlers/request-list.query.js +2 -2
- package/dist/helpdesk/handlers/send-reply-mail.write.d.ts +8 -0
- package/dist/{contact → helpdesk}/handlers/send-reply-mail.write.js +15 -15
- package/dist/helpdesk/handlers/send-test.write.d.ts +5 -0
- package/dist/{contact → helpdesk}/handlers/send-test.write.js +10 -10
- package/dist/{contact → helpdesk}/handlers/submit.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/submit.write.js +17 -17
- package/dist/{contact → helpdesk}/handlers/take-over-uploads.js +5 -5
- package/dist/{contact → helpdesk}/i18n.d.ts +1 -1
- package/dist/{contact → helpdesk}/i18n.js +78 -75
- package/dist/helpdesk/index.d.ts +5 -0
- package/dist/helpdesk/index.js +4 -0
- package/dist/{contact → helpdesk}/lib.d.ts +5 -5
- package/dist/{contact → helpdesk}/lib.js +16 -16
- package/dist/{contact → helpdesk}/mail.d.ts +20 -20
- package/dist/{contact → helpdesk}/mail.js +47 -47
- package/dist/{contact → helpdesk}/options.d.ts +6 -6
- package/dist/helpdesk/options.js +36 -0
- package/dist/helpdesk/panels.d.ts +2 -0
- package/dist/helpdesk/panels.js +21 -0
- package/dist/{contact → helpdesk}/payloads.d.ts +11 -11
- package/dist/{contact → helpdesk}/payloads.js +28 -28
- package/dist/helpdesk/screens.d.ts +5 -0
- package/dist/{contact → helpdesk}/screens.js +87 -87
- package/dist/{contact → helpdesk}/subject.js +3 -3
- package/dist/helpdesk/user-data-hooks.d.ts +3 -0
- package/dist/{contact → helpdesk}/user-data-hooks.js +15 -15
- package/dist/helpdesk/web/constants.d.ts +127 -0
- package/dist/helpdesk/web/constants.js +126 -0
- package/dist/helpdesk/web/index.d.ts +1 -0
- package/dist/helpdesk/web/index.js +1 -0
- package/dist/host-routing/boot-rules.d.ts +22 -0
- package/dist/host-routing/boot-rules.js +22 -0
- package/dist/host-routing/validate-options.js +35 -11
- package/dist/jobs/boot-rules.d.ts +7 -0
- package/dist/jobs/boot-rules.js +7 -0
- package/dist/jobs/feature.js +5 -2
- package/dist/legal-pages/boot-rules.d.ts +17 -0
- package/dist/legal-pages/boot-rules.js +17 -0
- package/dist/legal-pages/feature.js +5 -2
- package/dist/legal-pages/lib/validate-routes.js +11 -3
- package/dist/metrics/boot-rules.d.ts +12 -0
- package/dist/metrics/boot-rules.js +12 -0
- package/dist/metrics/validate.js +8 -2
- package/dist/notes-history/boot-rules.d.ts +7 -0
- package/dist/notes-history/boot-rules.js +7 -0
- package/dist/notes-history/feature.js +7 -4
- package/dist/personal-access-tokens/boot-rules.d.ts +7 -0
- package/dist/personal-access-tokens/boot-rules.js +7 -0
- package/dist/personal-access-tokens/scope-events-check.js +7 -4
- package/dist/presence/boot-rules.d.ts +7 -0
- package/dist/presence/boot-rules.js +7 -0
- package/dist/presence/options.js +5 -1
- package/dist/readiness/boot-rules.d.ts +12 -0
- package/dist/readiness/boot-rules.js +12 -0
- package/dist/readiness/probe-boot-check.js +8 -3
- package/dist/shared/assert-no-where-rule-in-ownership-write.d.ts +1 -1
- package/dist/shared/assert-no-where-rule-in-ownership-write.js +11 -7
- package/dist/shared/boot-rules.d.ts +7 -0
- package/dist/shared/boot-rules.js +7 -0
- package/dist/subscription-mollie/boot-rules.d.ts +17 -0
- package/dist/subscription-mollie/boot-rules.js +17 -0
- package/dist/subscription-mollie/feature.js +13 -6
- package/dist/tags/boot-rules.d.ts +7 -0
- package/dist/tags/boot-rules.js +7 -0
- package/dist/tags/feature.js +8 -5
- package/dist/template-resolver/boot-rules.d.ts +17 -0
- package/dist/template-resolver/boot-rules.js +17 -0
- package/dist/template-resolver/feature.js +14 -5
- package/dist/tenant/boot-rules.d.ts +7 -0
- package/dist/tenant/boot-rules.js +7 -0
- package/dist/tenant/feature.js +5 -2
- package/kumiko-es-tables.json +4 -4
- package/package.json +29 -29
- package/src/data-retention/changes.json +6 -0
- package/src/{contact → helpdesk}/changes.json +18 -0
- package/dist/contact/client/contact-client-source.d.ts +0 -1
- package/dist/contact/client/contact-website-client.d.ts +0 -26
- package/dist/contact/client/index.d.ts +0 -2
- package/dist/contact/client/index.js +0 -1
- package/dist/contact/feature.d.ts +0 -3
- package/dist/contact/handlers/challenge.query.d.ts +0 -9
- package/dist/contact/handlers/forward-request.write.d.ts +0 -9
- package/dist/contact/handlers/report.write.d.ts +0 -16
- package/dist/contact/handlers/request-delivery.query.d.ts +0 -16
- package/dist/contact/handlers/send-reply-mail.write.d.ts +0 -8
- package/dist/contact/handlers/send-test.write.d.ts +0 -5
- package/dist/contact/index.d.ts +0 -5
- package/dist/contact/index.js +0 -4
- package/dist/contact/options.js +0 -32
- package/dist/contact/panels.d.ts +0 -2
- package/dist/contact/panels.js +0 -21
- package/dist/contact/screens.d.ts +0 -5
- package/dist/contact/user-data-hooks.d.ts +0 -3
- package/dist/contact/web/constants.d.ts +0 -127
- package/dist/contact/web/constants.js +0 -126
- package/dist/contact/web/index.d.ts +0 -1
- package/dist/contact/web/index.js +0 -1
- /package/dist/{contact → helpdesk}/challenge.d.ts +0 -0
- /package/dist/{contact/client/contact-website-client.js → helpdesk/client/helpdesk-website-client.js} +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/attempts.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/replies.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/request-list.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/take-over-uploads.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.js +0 -0
- /package/dist/{contact → helpdesk}/subject.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.js +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export type HelpdeskWebsiteKind = (typeof HELPDESK_WEBSITE_KINDS)[number];
|
|
5
|
+
export type HelpdeskWebsiteFormOptions = {
|
|
6
|
+
readonly phone: HelpdeskPhoneMode;
|
|
7
|
+
readonly kinds: readonly HelpdeskWebsiteKind[];
|
|
8
|
+
};
|
|
9
|
+
export type HelpdeskWebsiteSubmitFields = Omit<z.input<typeof HelpdeskSubmitSchema>, "challenge" | "nonce" | "locale"> & {
|
|
10
|
+
readonly locale?: z.input<typeof HelpdeskSubmitSchema>["locale"];
|
|
11
|
+
};
|
|
12
|
+
export type HelpdeskWebsiteSubmitResult = {
|
|
13
|
+
readonly kind: "sent";
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "rate-limited";
|
|
16
|
+
readonly retryAfterSeconds?: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "failed";
|
|
19
|
+
};
|
|
20
|
+
export type HelpdeskWebsiteClient = {
|
|
21
|
+
load(): Promise<HelpdeskWebsiteFormOptions>;
|
|
22
|
+
submit(fields: HelpdeskWebsiteSubmitFields): Promise<HelpdeskWebsiteSubmitResult>;
|
|
23
|
+
};
|
|
24
|
+
export type HelpdeskWebsiteWindow = {
|
|
25
|
+
readonly KumikoHelpdesk?: HelpdeskWebsiteClient;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HELPDESK_CLIENT_SOURCE } from "./helpdesk-client-source.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function createHelpdeskRequestEntity(retentionKeepFor?: string): import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
2
2
|
readonly kind: {
|
|
3
3
|
readonly type: "select";
|
|
4
4
|
readonly description?: string;
|
|
@@ -200,7 +200,7 @@ export declare function createContactRequestEntity(retentionKeepFor?: string): i
|
|
|
200
200
|
required: false;
|
|
201
201
|
};
|
|
202
202
|
}, "global">;
|
|
203
|
-
export declare function
|
|
203
|
+
export declare function createHelpdeskReplyEntity(retentionKeepFor?: string): import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
204
204
|
readonly requestId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
|
|
205
205
|
required: true;
|
|
206
206
|
};
|
|
@@ -257,7 +257,7 @@ export declare function createContactReplyEntity(retentionKeepFor?: string): imp
|
|
|
257
257
|
required: true;
|
|
258
258
|
};
|
|
259
259
|
}, "global">;
|
|
260
|
-
export declare const
|
|
260
|
+
export declare const helpdeskRequestEntity: import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
261
261
|
readonly kind: {
|
|
262
262
|
readonly type: "select";
|
|
263
263
|
readonly description?: string;
|
|
@@ -459,7 +459,7 @@ export declare const contactRequestEntity: import("@cosmicdrift/kumiko-types/fie
|
|
|
459
459
|
required: false;
|
|
460
460
|
};
|
|
461
461
|
}, "global">;
|
|
462
|
-
export declare const
|
|
462
|
+
export declare const helpdeskReplyEntity: import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
463
463
|
readonly requestId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
|
|
464
464
|
required: true;
|
|
465
465
|
};
|
|
@@ -516,7 +516,7 @@ export declare const contactReplyEntity: import("@cosmicdrift/kumiko-types/field
|
|
|
516
516
|
required: true;
|
|
517
517
|
};
|
|
518
518
|
}, "global">;
|
|
519
|
-
export declare const
|
|
519
|
+
export declare const helpdeskRequestTable: import("@cosmicdrift/kumiko-framework/db").EntityTable<import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
520
520
|
readonly kind: {
|
|
521
521
|
readonly type: "select";
|
|
522
522
|
readonly description?: string;
|
|
@@ -718,7 +718,7 @@ export declare const contactRequestTable: import("@cosmicdrift/kumiko-framework/
|
|
|
718
718
|
required: false;
|
|
719
719
|
};
|
|
720
720
|
}, "global">>;
|
|
721
|
-
export declare const
|
|
721
|
+
export declare const helpdeskReplyTable: import("@cosmicdrift/kumiko-framework/db").EntityTable<import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
722
722
|
readonly requestId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
|
|
723
723
|
required: true;
|
|
724
724
|
};
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { buildEntityTable } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import { createEntity, createFilesField, createLongTextField, createNumberField, createSelectField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { DEFAULT_RETENTION_KEEP_FOR } from "./options.js";
|
|
4
|
-
import {
|
|
4
|
+
import { HELPDESK_KIND, HELPDESK_MAX_FILES, HELPDESK_REPLY_CHANNELS, HELPDESK_SOURCE, HELPDESK_STATUS, } from "./web/constants.js";
|
|
5
5
|
const KIND_OPTIONS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
HELPDESK_KIND.Question,
|
|
7
|
+
HELPDESK_KIND.Contact,
|
|
8
|
+
HELPDESK_KIND.Bug,
|
|
9
|
+
HELPDESK_KIND.Wish,
|
|
10
10
|
];
|
|
11
|
-
const STATUS_OPTIONS = [
|
|
12
|
-
|
|
11
|
+
const STATUS_OPTIONS = [
|
|
12
|
+
HELPDESK_STATUS.Open,
|
|
13
|
+
HELPDESK_STATUS.Answered,
|
|
14
|
+
HELPDESK_STATUS.Done,
|
|
15
|
+
];
|
|
16
|
+
const SOURCE_OPTIONS = [HELPDESK_SOURCE.Website, HELPDESK_SOURCE.Admin];
|
|
13
17
|
const REPLY_CHANNEL_OPTIONS = [
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
HELPDESK_REPLY_CHANNELS.Email,
|
|
19
|
+
HELPDESK_REPLY_CHANNELS.EmailAndInApp,
|
|
16
20
|
];
|
|
17
21
|
// A signed-in reporter is the data subject; an anonymous reporter has no user id, so the row
|
|
18
22
|
// itself is the crypto-shredding subject.
|
|
19
23
|
const REPORTER_SUBJECT = { of: "reporterUserId", whenAbsent: "self" };
|
|
20
24
|
const MAX_FILE_SIZE = "10MB";
|
|
21
|
-
export function
|
|
25
|
+
export function createHelpdeskRequestEntity(retentionKeepFor = DEFAULT_RETENTION_KEEP_FOR) {
|
|
22
26
|
return createEntity({
|
|
23
|
-
table: "
|
|
27
|
+
table: "read_helpdesk_requests",
|
|
24
28
|
description: "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.",
|
|
25
29
|
systemStream: true,
|
|
26
30
|
tenancy: "global",
|
|
@@ -32,22 +36,22 @@ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_
|
|
|
32
36
|
filterable: true,
|
|
33
37
|
sortable: true,
|
|
34
38
|
optionTones: {
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
+
[HELPDESK_KIND.Bug]: "bad",
|
|
40
|
+
[HELPDESK_KIND.Question]: "accent",
|
|
41
|
+
[HELPDESK_KIND.Contact]: "accent",
|
|
42
|
+
[HELPDESK_KIND.Wish]: "neutral",
|
|
39
43
|
},
|
|
40
44
|
}),
|
|
41
45
|
status: createSelectField({
|
|
42
46
|
options: STATUS_OPTIONS,
|
|
43
47
|
required: true,
|
|
44
|
-
default:
|
|
48
|
+
default: HELPDESK_STATUS.Open,
|
|
45
49
|
filterable: true,
|
|
46
50
|
sortable: true,
|
|
47
51
|
optionTones: {
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
52
|
+
[HELPDESK_STATUS.Open]: "warn",
|
|
53
|
+
[HELPDESK_STATUS.Answered]: "accent",
|
|
54
|
+
[HELPDESK_STATUS.Done]: "ok",
|
|
51
55
|
},
|
|
52
56
|
}),
|
|
53
57
|
source: createSelectField({
|
|
@@ -85,7 +89,7 @@ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_
|
|
|
85
89
|
browser: createTextField({ personal: false, reason: "is_browser_summary" }),
|
|
86
90
|
locale: createTextField({ personal: false, reason: "is_ui_language_preference" }),
|
|
87
91
|
fileIds: createFilesField({
|
|
88
|
-
maxCount:
|
|
92
|
+
maxCount: HELPDESK_MAX_FILES,
|
|
89
93
|
maxSize: MAX_FILE_SIZE,
|
|
90
94
|
personal: REPORTER_SUBJECT,
|
|
91
95
|
}),
|
|
@@ -102,9 +106,9 @@ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_
|
|
|
102
106
|
},
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
|
-
export function
|
|
109
|
+
export function createHelpdeskReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KEEP_FOR) {
|
|
106
110
|
return createEntity({
|
|
107
|
-
table: "
|
|
111
|
+
table: "read_helpdesk_replies",
|
|
108
112
|
description: "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.",
|
|
109
113
|
systemStream: true,
|
|
110
114
|
tenancy: "global",
|
|
@@ -124,7 +128,7 @@ export function createContactReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KE
|
|
|
124
128
|
}),
|
|
125
129
|
authorName: createTextField({ required: true, personal: false, reason: "is_admin_label" }),
|
|
126
130
|
fileIds: createFilesField({
|
|
127
|
-
maxCount:
|
|
131
|
+
maxCount: HELPDESK_MAX_FILES,
|
|
128
132
|
maxSize: MAX_FILE_SIZE,
|
|
129
133
|
personal: false,
|
|
130
134
|
reason: "is_business_data",
|
|
@@ -139,7 +143,7 @@ export function createContactReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KE
|
|
|
139
143
|
},
|
|
140
144
|
});
|
|
141
145
|
}
|
|
142
|
-
export const
|
|
143
|
-
export const
|
|
144
|
-
export const
|
|
145
|
-
export const
|
|
146
|
+
export const helpdeskRequestEntity = createHelpdeskRequestEntity();
|
|
147
|
+
export const helpdeskReplyEntity = createHelpdeskReplyEntity();
|
|
148
|
+
export const helpdeskRequestTable = buildEntityTable("helpdesk-request", helpdeskRequestEntity);
|
|
149
|
+
export const helpdeskReplyTable = buildEntityTable("helpdesk-reply", helpdeskReplyEntity);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { access, createSystemConfig, defineFeature, EXT_USER_DATA, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { HELPDESK_CLIENT_SOURCE } from "./client/helpdesk-client-source.js";
|
|
3
|
+
import { createHelpdeskReplyEntity, createHelpdeskRequestEntity, helpdeskReplyEntity, helpdeskRequestEntity, } from "./entity.js";
|
|
4
4
|
import { createChallengeQuery } from "./handlers/challenge.query.js";
|
|
5
5
|
import { createForwardRequestHandler } from "./handlers/forward-request.write.js";
|
|
6
6
|
import { markDoneHandler } from "./handlers/mark-done.write.js";
|
|
@@ -15,25 +15,27 @@ import { createRequestListQuery } from "./handlers/request-list.query.js";
|
|
|
15
15
|
import { createSendReplyMailHandler } from "./handlers/send-reply-mail.write.js";
|
|
16
16
|
import { createSendTestHandler } from "./handlers/send-test.write.js";
|
|
17
17
|
import { createSubmitHandler } from "./handlers/submit.write.js";
|
|
18
|
-
import {
|
|
18
|
+
import { createHelpdeskI18n } from "./i18n.js";
|
|
19
19
|
import { TELEGRAM_FEATURE } from "./lib.js";
|
|
20
|
-
import {
|
|
21
|
-
import { DEFAULT_RETENTION_KEEP_FOR,
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
20
|
+
import { HELPDESK_ACKNOWLEDGEMENT_VARIABLES, HELPDESK_CONFIRMATION_VARIABLES, HELPDESK_NEW_REQUEST_VARIABLES, HELPDESK_REPLY_VARIABLES, HELPDESK_TEST_VARIABLES, helpdeskAcknowledgementTemplate, helpdeskConfirmationTemplate, helpdeskNewRequestTemplate, helpdeskReplyTemplate, helpdeskTestTemplate, inAppTemplate, telegramTemplate, } from "./mail.js";
|
|
21
|
+
import { DEFAULT_RETENTION_KEEP_FOR, resolveHelpdeskSettings, } from "./options.js";
|
|
22
|
+
import { createHelpdeskScreens } from "./screens.js";
|
|
23
|
+
import { helpdeskDeleteHook, helpdeskExportHook } from "./user-data-hooks.js";
|
|
24
|
+
import { HELPDESK_FEATURE } from "./web/constants.js";
|
|
25
25
|
const REPLY_CONTEXT_FIELDS = ["name", "email", "replyTo"];
|
|
26
|
-
export function
|
|
27
|
-
const settings =
|
|
26
|
+
export function createHelpdeskFeature(opts) {
|
|
27
|
+
const settings = resolveHelpdeskSettings(opts);
|
|
28
28
|
const telegram = opts.telegram === true;
|
|
29
29
|
const keepFor = opts.retentionKeepFor ?? DEFAULT_RETENTION_KEEP_FOR;
|
|
30
30
|
const requestEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
|
|
31
|
-
?
|
|
32
|
-
:
|
|
33
|
-
const replyEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
? helpdeskRequestEntity
|
|
32
|
+
: createHelpdeskRequestEntity(keepFor);
|
|
33
|
+
const replyEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
|
|
34
|
+
? helpdeskReplyEntity
|
|
35
|
+
: createHelpdeskReplyEntity(keepFor);
|
|
36
|
+
return defineFeature(HELPDESK_FEATURE, (r) => {
|
|
37
|
+
r.describe("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.");
|
|
38
|
+
r.uiHints({ displayLabel: "Helpdesk", category: "communication", recommended: false });
|
|
37
39
|
r.systemScope();
|
|
38
40
|
r.requires({ features: ["config", "delivery", "user-data-rights", "files", "notes-history"] });
|
|
39
41
|
// The feature manifest and reference are built from one mounted instance, so the off
|
|
@@ -43,7 +45,7 @@ export function createContactFeature(opts) {
|
|
|
43
45
|
else
|
|
44
46
|
r.optionalRequires(TELEGRAM_FEATURE);
|
|
45
47
|
r.adoptsBundledLists();
|
|
46
|
-
r.translations({ keys:
|
|
48
|
+
r.translations({ keys: createHelpdeskI18n() });
|
|
47
49
|
r.config({
|
|
48
50
|
keys: {
|
|
49
51
|
replyTo: createSystemConfig("text", {
|
|
@@ -67,32 +69,34 @@ export function createContactFeature(opts) {
|
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
r.notification("new-request", {
|
|
70
|
-
variables:
|
|
71
|
-
localizedTemplate:
|
|
72
|
+
variables: HELPDESK_NEW_REQUEST_VARIABLES,
|
|
73
|
+
localizedTemplate: helpdeskNewRequestTemplate,
|
|
72
74
|
...(telegram && { templates: { telegram: telegramTemplate } }),
|
|
73
75
|
});
|
|
74
76
|
r.notification("confirmation", {
|
|
75
|
-
variables:
|
|
76
|
-
localizedTemplate:
|
|
77
|
+
variables: HELPDESK_CONFIRMATION_VARIABLES,
|
|
78
|
+
localizedTemplate: helpdeskConfirmationTemplate,
|
|
77
79
|
});
|
|
78
80
|
r.notification("acknowledgement", {
|
|
79
|
-
variables:
|
|
80
|
-
localizedTemplate:
|
|
81
|
+
variables: HELPDESK_ACKNOWLEDGEMENT_VARIABLES,
|
|
82
|
+
localizedTemplate: helpdeskAcknowledgementTemplate,
|
|
81
83
|
});
|
|
82
84
|
r.notification("reply", {
|
|
83
|
-
variables:
|
|
84
|
-
localizedTemplate:
|
|
85
|
+
variables: HELPDESK_REPLY_VARIABLES,
|
|
86
|
+
localizedTemplate: helpdeskReplyTemplate,
|
|
87
|
+
});
|
|
88
|
+
r.notification("reply-in-app", {
|
|
89
|
+
templates: { inApp: inAppTemplate },
|
|
85
90
|
});
|
|
86
|
-
r.notification("reply-in-app", { templates: { inApp: inAppTemplate } });
|
|
87
91
|
if (telegram) {
|
|
88
92
|
r.notification("test", {
|
|
89
|
-
variables:
|
|
90
|
-
localizedTemplate:
|
|
93
|
+
variables: HELPDESK_TEST_VARIABLES,
|
|
94
|
+
localizedTemplate: helpdeskTestTemplate,
|
|
91
95
|
templates: { telegram: telegramTemplate },
|
|
92
96
|
});
|
|
93
97
|
}
|
|
94
|
-
r.entity({ name: "
|
|
95
|
-
r.entity({ name: "
|
|
98
|
+
r.entity({ name: "helpdesk-request", ...requestEntity });
|
|
99
|
+
r.entity({ name: "helpdesk-reply", ...replyEntity });
|
|
96
100
|
r.writeHandler(createSubmitHandler(opts, settings));
|
|
97
101
|
r.writeHandler(createReportHandler(opts, settings));
|
|
98
102
|
r.writeHandler(createForwardRequestHandler(opts));
|
|
@@ -109,24 +113,24 @@ export function createContactFeature(opts) {
|
|
|
109
113
|
r.queryHandler(createRequestDetailQuery(opts));
|
|
110
114
|
r.queryHandler(repliesQuery);
|
|
111
115
|
r.queryHandler(createRequestDeliveryQuery(opts));
|
|
112
|
-
for (const screen of
|
|
116
|
+
for (const screen of createHelpdeskScreens(opts, settings))
|
|
113
117
|
r.screen(screen);
|
|
114
118
|
r.httpRoute({
|
|
115
119
|
method: "GET",
|
|
116
|
-
// A literal, not
|
|
117
|
-
path: "/
|
|
120
|
+
// A literal, not HELPDESK_CLIENT_PATH: the feature-AST extractor only reads string literals.
|
|
121
|
+
path: "/helpdesk/client.js",
|
|
118
122
|
anonymous: true,
|
|
119
|
-
handler: async (c) => c.body(
|
|
123
|
+
handler: async (c) => c.body(HELPDESK_CLIENT_SOURCE, 200, {
|
|
120
124
|
"content-type": "application/javascript; charset=utf-8",
|
|
121
125
|
"cache-control": "public, max-age=300",
|
|
122
126
|
}),
|
|
123
127
|
});
|
|
124
|
-
r.useExtension(EXT_USER_DATA, "
|
|
125
|
-
export:
|
|
126
|
-
delete:
|
|
128
|
+
r.useExtension(EXT_USER_DATA, "helpdesk-request", {
|
|
129
|
+
export: helpdeskExportHook,
|
|
130
|
+
delete: helpdeskDeleteHook,
|
|
127
131
|
});
|
|
128
|
-
// Replies are exported nested under their request and erased with it (
|
|
129
|
-
r.useExtension(EXT_USER_DATA, "
|
|
132
|
+
// Replies are exported nested under their request and erased with it (helpdeskDeleteHook).
|
|
133
|
+
r.useExtension(EXT_USER_DATA, "helpdesk-reply", {
|
|
130
134
|
export: async () => null,
|
|
131
135
|
delete: async () => { },
|
|
132
136
|
});
|
|
@@ -8,7 +8,7 @@ declare const attemptSchema: z.ZodObject<{
|
|
|
8
8
|
status: z.ZodString;
|
|
9
9
|
createdAt: z.ZodCustom<globalThis.Temporal.Instant, globalThis.Temporal.Instant>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
|
-
export type
|
|
12
|
-
export declare function loadAttemptsByKey(ctx: Pick<HandlerContext, "dispatch">, user: SessionUser, keys: readonly string[]): Promise<readonly
|
|
11
|
+
export type HelpdeskAttempt = z.infer<typeof attemptSchema>;
|
|
12
|
+
export declare function loadAttemptsByKey(ctx: Pick<HandlerContext, "dispatch">, user: SessionUser, keys: readonly string[]): Promise<readonly HelpdeskAttempt[]>;
|
|
13
13
|
export declare function loadReadAtByKey(ctx: Pick<HandlerContext, "dispatch" | "registry">, reporterTenantId: TenantId, keys: readonly string[]): Promise<ReadonlyMap<string, Temporal.Instant | null>>;
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HelpdeskSettings } from "../options.ts";
|
|
2
|
+
import { type HelpdeskPhoneMode } from "../web/constants.ts";
|
|
3
|
+
export type HelpdeskChallengeData = {
|
|
4
|
+
readonly challenge: string;
|
|
5
|
+
readonly bits: number;
|
|
6
|
+
readonly phone: HelpdeskPhoneMode;
|
|
7
|
+
readonly kinds: readonly string[];
|
|
8
|
+
};
|
|
9
|
+
export declare function createChallengeQuery(settings: HelpdeskSettings): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"challenge", import("zod").ZodObject<{}, import("zod/v4/core").$strict>, HelpdeskChallengeData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
|
|
@@ -2,13 +2,13 @@ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
|
2
2
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
import { issueChallenge } from "../challenge.js";
|
|
4
4
|
import { CHALLENGE_RATE_LIMIT } from "../options.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { HelpdeskEmptySchema } from "../payloads.js";
|
|
6
|
+
import { HELPDESK_WEBSITE_KINDS } from "../web/constants.js";
|
|
7
7
|
import { SUBMIT_ROLES } from "./access.js";
|
|
8
8
|
export function createChallengeQuery(settings) {
|
|
9
9
|
return defineQueryHandler({
|
|
10
10
|
name: "challenge",
|
|
11
|
-
schema:
|
|
11
|
+
schema: HelpdeskEmptySchema,
|
|
12
12
|
access: { roles: SUBMIT_ROLES, personalData: "public-intake", anySignedIn: true },
|
|
13
13
|
rateLimit: CHALLENGE_RATE_LIMIT,
|
|
14
14
|
agent: { expose: false },
|
|
@@ -16,7 +16,7 @@ export function createChallengeQuery(settings) {
|
|
|
16
16
|
handler: async (_event, ctx) => {
|
|
17
17
|
if (!ctx.services.redis) {
|
|
18
18
|
throw new InternalError({
|
|
19
|
-
message: "
|
|
19
|
+
message: "helpdesk:challenge requires ctx.services.redis for the challenge store",
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
const challenge = await issueChallenge(ctx.services.redis, {
|
|
@@ -28,7 +28,7 @@ export function createChallengeQuery(settings) {
|
|
|
28
28
|
challenge,
|
|
29
29
|
bits: settings.proofOfWorkBits,
|
|
30
30
|
phone: settings.phone,
|
|
31
|
-
kinds:
|
|
31
|
+
kinds: HELPDESK_WEBSITE_KINDS,
|
|
32
32
|
};
|
|
33
33
|
},
|
|
34
34
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HelpdeskOptions } from "../options.ts";
|
|
2
|
+
export type HelpdeskForwardData = {
|
|
3
|
+
readonly kind: "forwarded";
|
|
4
|
+
readonly adminCount: number;
|
|
5
|
+
readonly telegram: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function createForwardRequestHandler(opts: HelpdeskOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"forward-request", import("zod").ZodObject<{
|
|
8
|
+
requestId: import("zod").ZodUUID;
|
|
9
|
+
}, import("zod/v4/core").$strict>, HelpdeskForwardData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { helpdeskDb, internalAccess, listSystemAdminIds, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
4
|
+
import { helpdeskNewRequestVariables, resolveHelpdeskMailLocale } from "../mail.js";
|
|
5
|
+
import { HelpdeskForwardRequestSchema } from "../payloads.js";
|
|
6
|
+
import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_REQUEST_ENTITY, HelpdeskConfigKeys, helpdeskIdempotencyKeys, } from "../web/constants.js";
|
|
7
7
|
const EMAIL_CHANNEL = "email";
|
|
8
8
|
// Runs as the platform identity so the notification, the config and the bot token secret are
|
|
9
9
|
// read in the system tenant, whoever filed the request.
|
|
10
10
|
export function createForwardRequestHandler(opts) {
|
|
11
11
|
return defineWriteHandler({
|
|
12
12
|
name: "forward-request",
|
|
13
|
-
schema:
|
|
13
|
+
schema: HelpdeskForwardRequestSchema,
|
|
14
14
|
access: internalAccess,
|
|
15
15
|
agent: { expose: false },
|
|
16
16
|
description: "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.",
|
|
17
17
|
handler: async (event, ctx) => {
|
|
18
|
-
const db =
|
|
18
|
+
const db = helpdeskDb(ctx);
|
|
19
19
|
const request = await requestExecutor.detail({ id: event.payload.requestId }, platformActor(), db);
|
|
20
20
|
if (!request) {
|
|
21
|
-
return writeFailure(new NotFoundError(
|
|
21
|
+
return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, event.payload.requestId));
|
|
22
22
|
}
|
|
23
23
|
const requestId = event.payload.requestId;
|
|
24
24
|
const adminLocale = opts.adminLocale;
|
|
25
25
|
const link = opts.requestLink?.(requestId);
|
|
26
|
-
const data =
|
|
26
|
+
const data = helpdeskNewRequestVariables({
|
|
27
27
|
kind: request.kind,
|
|
28
28
|
appName: opts.appName,
|
|
29
29
|
link,
|
|
@@ -31,25 +31,27 @@ export function createForwardRequestHandler(opts) {
|
|
|
31
31
|
});
|
|
32
32
|
const adminIds = await listSystemAdminIds(db);
|
|
33
33
|
if (adminIds.length > 0) {
|
|
34
|
-
await sendBestEffort(ctx, "admin mail", (notify) => notify(
|
|
34
|
+
await sendBestEffort(ctx, "admin mail", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.newRequest, {
|
|
35
35
|
to: adminIds,
|
|
36
36
|
channels: [EMAIL_CHANNEL],
|
|
37
37
|
data,
|
|
38
|
-
idempotencyKey:
|
|
38
|
+
idempotencyKey: helpdeskIdempotencyKeys.admins(requestId),
|
|
39
39
|
priority: "normal",
|
|
40
|
-
locale:
|
|
40
|
+
locale: resolveHelpdeskMailLocale(adminLocale),
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
43
|
-
const chatId = opts.telegram
|
|
43
|
+
const chatId = opts.telegram
|
|
44
|
+
? await ctx.config?.(HelpdeskConfigKeys.telegramChat)
|
|
45
|
+
: undefined;
|
|
44
46
|
const telegram = opts.telegram === true && typeof chatId === "string" && chatId.trim() !== "";
|
|
45
47
|
if (telegram) {
|
|
46
|
-
await sendBestEffort(ctx, "telegram", (notify) => notify(
|
|
48
|
+
await sendBestEffort(ctx, "telegram", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.newRequest, {
|
|
47
49
|
route: { telegram: chatId.trim() },
|
|
48
50
|
recipientId: requestId,
|
|
49
51
|
data,
|
|
50
|
-
idempotencyKey:
|
|
52
|
+
idempotencyKey: helpdeskIdempotencyKeys.telegram(requestId),
|
|
51
53
|
priority: "normal",
|
|
52
|
-
locale:
|
|
54
|
+
locale: resolveHelpdeskMailLocale(adminLocale),
|
|
53
55
|
}));
|
|
54
56
|
}
|
|
55
57
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type HelpdeskMarkDoneData = {
|
|
2
2
|
readonly kind: "marked";
|
|
3
3
|
readonly changed: number;
|
|
4
4
|
};
|
|
5
5
|
export declare const markDoneHandler: import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"mark-done", import("zod").ZodObject<{
|
|
6
6
|
id: import("zod").ZodUUID;
|
|
7
|
-
}, import("zod/v4/core").$strict>,
|
|
7
|
+
}, import("zod/v4/core").$strict>, HelpdeskMarkDoneData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
-
import { adminAccess,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { adminAccess, helpdeskDb, platformActor, requestExecutor } from "../lib.js";
|
|
4
|
+
import { HelpdeskMarkDoneSchema } from "../payloads.js";
|
|
5
|
+
import { HELPDESK_REQUEST_ENTITY, HELPDESK_STATUS } from "../web/constants.js";
|
|
6
6
|
export const markDoneHandler = defineWriteHandler({
|
|
7
7
|
name: "mark-done",
|
|
8
|
-
schema:
|
|
8
|
+
schema: HelpdeskMarkDoneSchema,
|
|
9
9
|
access: adminAccess,
|
|
10
10
|
agent: { expose: false },
|
|
11
11
|
description: "Marks one contact request as done without sending a reply; a finished request is left as it is.",
|
|
12
12
|
handler: async (event, ctx) => {
|
|
13
|
-
const db =
|
|
13
|
+
const db = helpdeskDb(ctx);
|
|
14
14
|
const { id } = event.payload;
|
|
15
15
|
const request = await requestExecutor.detail({ id }, platformActor(), db);
|
|
16
16
|
if (!request)
|
|
17
|
-
return writeFailure(new NotFoundError(
|
|
18
|
-
if (request.status ===
|
|
17
|
+
return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, id));
|
|
18
|
+
if (request.status === HELPDESK_STATUS.Done) {
|
|
19
19
|
return { isSuccess: true, data: { kind: "marked", changed: 0 } };
|
|
20
20
|
}
|
|
21
21
|
const updated = await requestExecutor.update({
|
|
22
22
|
id,
|
|
23
23
|
version: request.version,
|
|
24
|
-
changes: { status:
|
|
24
|
+
changes: { status: HELPDESK_STATUS.Done, closedAt: ctx.tz.now() },
|
|
25
25
|
}, platformActor(), db);
|
|
26
26
|
if (!updated.isSuccess)
|
|
27
27
|
return updated;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type HelpdeskNotifyReporterData = {
|
|
2
2
|
readonly kind: "notified" | "skipped";
|
|
3
3
|
};
|
|
4
4
|
export declare const notifyReporterInAppHandler: import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"notify-reporter-in-app", import("zod").ZodObject<{
|
|
@@ -7,4 +7,4 @@ export declare const notifyReporterInAppHandler: import("@cosmicdrift/kumiko-typ
|
|
|
7
7
|
userId: import("zod").ZodUUID;
|
|
8
8
|
authorName: import("zod").ZodString;
|
|
9
9
|
locale: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
-
}, import("zod/v4/core").$strict>,
|
|
10
|
+
}, import("zod/v4/core").$strict>, HelpdeskNotifyReporterData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,35 +1,35 @@
|
|
|
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.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { helpdeskDb, IN_APP_FEATURE, internalAccess, sendBestEffort } from "../lib.js";
|
|
5
|
+
import { helpdeskReplyInAppData, resolveHelpdeskMailLocale } from "../mail.js";
|
|
6
|
+
import { HelpdeskNotifyReporterInAppSchema } from "../payloads.js";
|
|
7
|
+
import { HELPDESK_NOTIFICATION_TYPES, helpdeskIdempotencyKeys } from "../web/constants.js";
|
|
8
8
|
// Runs as the platform identity of the reporter's tenant, so the in-app note lands in that
|
|
9
9
|
// tenant's inbox. The note names the author only; the answer itself goes by mail.
|
|
10
10
|
export const notifyReporterInAppHandler = defineWriteHandler({
|
|
11
11
|
name: "notify-reporter-in-app",
|
|
12
|
-
schema:
|
|
12
|
+
schema: HelpdeskNotifyReporterInAppSchema,
|
|
13
13
|
access: internalAccess,
|
|
14
14
|
agent: { expose: false },
|
|
15
|
-
description: "Internal: adds an in-app note about a
|
|
15
|
+
description: "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.",
|
|
16
16
|
handler: async (event, ctx) => {
|
|
17
17
|
const { userId, replyId, authorName, locale } = event.payload;
|
|
18
18
|
if (!(await ctx.hasFeature(IN_APP_FEATURE)))
|
|
19
19
|
return { isSuccess: true, data: { kind: "skipped" } };
|
|
20
|
-
const membership = await fetchOne(
|
|
20
|
+
const membership = await fetchOne(helpdeskDb(ctx), tenantMembershipsTable, {
|
|
21
21
|
userId,
|
|
22
22
|
tenantId: event.user.tenantId,
|
|
23
23
|
});
|
|
24
24
|
if (!membership)
|
|
25
25
|
return { isSuccess: true, data: { kind: "skipped" } };
|
|
26
|
-
await sendBestEffort(ctx, "reply in-app note", (notify) => notify(
|
|
26
|
+
await sendBestEffort(ctx, "reply in-app note", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.replyInApp, {
|
|
27
27
|
route: { inApp: userId },
|
|
28
28
|
recipientId: userId,
|
|
29
|
-
data:
|
|
30
|
-
idempotencyKey:
|
|
29
|
+
data: helpdeskReplyInAppData({ authorName, locale }),
|
|
30
|
+
idempotencyKey: helpdeskIdempotencyKeys.replyInApp(replyId),
|
|
31
31
|
priority: "normal",
|
|
32
|
-
locale:
|
|
32
|
+
locale: resolveHelpdeskMailLocale(locale),
|
|
33
33
|
}));
|
|
34
34
|
return { isSuccess: true, data: { kind: "notified" } };
|
|
35
35
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { platformActor, requestExecutor } from "../lib.js";
|
|
2
|
-
import {
|
|
2
|
+
import { HELPDESK_STATUS } from "../web/constants.js";
|
|
3
3
|
// Open means no answer yet; an answered request counts as handled even before it is marked done.
|
|
4
4
|
export async function countOpenRequests(db) {
|
|
5
5
|
const found = await requestExecutor.list({
|
|
6
|
-
filter: { field: "status", op: "eq", value:
|
|
6
|
+
filter: { field: "status", op: "eq", value: HELPDESK_STATUS.Open },
|
|
7
7
|
limit: 1,
|
|
8
8
|
totalCount: true,
|
|
9
9
|
}, platformActor(), db);
|