@cosmicdrift/kumiko-samples 0.412.0 → 0.413.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/bundled-features/package.json +13 -13
- package/packages/bundled-features/src/admin-shell/feature.ts +1 -1
- package/packages/bundled-features/src/agent-tools/api-docs/anchors.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/boot-rules.ts +9 -0
- package/packages/bundled-features/src/auth-email-password/feature.ts +6 -19
- package/packages/bundled-features/src/auth-email-password/validate-options.ts +20 -0
- package/packages/bundled-features/src/billing-foundation/boot-rules.ts +26 -0
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +59 -46
- package/packages/bundled-features/src/cap-overview/boot-rules.ts +14 -0
- package/packages/bundled-features/src/cap-overview/feature.ts +12 -5
- package/packages/bundled-features/src/data-retention/changes.json +6 -0
- package/packages/bundled-features/src/data-retention/feature.ts +3 -2
- package/packages/bundled-features/src/documents/boot-rules.ts +14 -0
- package/packages/bundled-features/src/documents/feature.ts +8 -4
- package/packages/bundled-features/src/file-derivatives/boot-rules.ts +9 -0
- package/packages/bundled-features/src/file-derivatives/feature.ts +6 -3
- package/packages/bundled-features/src/folders/boot-rules.ts +9 -0
- package/packages/bundled-features/src/folders/feature.ts +6 -3
- package/packages/bundled-features/src/helpdesk/boot-rules.ts +9 -0
- package/packages/bundled-features/src/{contact → helpdesk}/challenge.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/changes.json +18 -0
- package/packages/bundled-features/src/{contact/client/contact-client-source.ts → helpdesk/client/helpdesk-client-source.ts} +4 -4
- package/packages/bundled-features/src/helpdesk/client/helpdesk-website-client.ts +29 -0
- package/packages/bundled-features/src/helpdesk/client/index.ts +9 -0
- package/packages/bundled-features/src/{contact → helpdesk}/entity.ts +35 -31
- package/packages/bundled-features/src/{contact → helpdesk}/feature.ts +56 -52
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/attempts.ts +3 -3
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/challenge.query.ts +10 -10
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/forward-request.write.ts +25 -23
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/mark-done.write.ts +11 -11
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/notify-reporter-in-app.write.ts +14 -14
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.query.ts +4 -4
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/open-count.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/replies.query.ts +6 -6
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/reply.write.ts +30 -30
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/report.write.ts +29 -29
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-delivery.query.ts +40 -40
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-detail.query.ts +15 -15
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/request-list.query.ts +2 -2
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-reply-mail.write.ts +24 -24
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/send-test.write.ts +18 -14
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/submit.write.ts +32 -31
- package/packages/bundled-features/src/{contact → helpdesk}/handlers/take-over-uploads.ts +5 -5
- package/packages/bundled-features/src/{contact → helpdesk}/i18n.ts +78 -75
- package/packages/bundled-features/src/helpdesk/index.ts +29 -0
- package/packages/bundled-features/src/{contact → helpdesk}/lib.ts +32 -28
- package/packages/bundled-features/src/{contact → helpdesk}/mail.ts +56 -56
- package/packages/bundled-features/src/{contact → helpdesk}/options.ts +18 -16
- package/packages/bundled-features/src/helpdesk/panels.ts +28 -0
- package/packages/bundled-features/src/{contact → helpdesk}/payloads.ts +33 -33
- package/packages/bundled-features/src/{contact → helpdesk}/screens.ts +104 -104
- package/packages/bundled-features/src/{contact → helpdesk}/subject.ts +3 -3
- package/packages/bundled-features/src/{contact → helpdesk}/user-data-hooks.ts +17 -17
- package/packages/bundled-features/src/helpdesk/web/constants.ts +160 -0
- package/packages/bundled-features/src/helpdesk/web/index.ts +29 -0
- package/packages/bundled-features/src/host-routing/boot-rules.ts +27 -0
- package/packages/bundled-features/src/host-routing/validate-options.ts +36 -27
- package/packages/bundled-features/src/jobs/boot-rules.ts +9 -0
- package/packages/bundled-features/src/jobs/feature.ts +9 -4
- package/packages/bundled-features/src/legal-pages/boot-rules.ts +19 -0
- package/packages/bundled-features/src/legal-pages/feature.ts +6 -3
- package/packages/bundled-features/src/legal-pages/lib/validate-routes.ts +11 -5
- package/packages/bundled-features/src/metrics/boot-rules.ts +15 -0
- package/packages/bundled-features/src/metrics/validate.ts +8 -2
- package/packages/bundled-features/src/notes-history/boot-rules.ts +9 -0
- package/packages/bundled-features/src/notes-history/feature.ts +6 -3
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +9 -0
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +6 -3
- package/packages/bundled-features/src/presence/boot-rules.ts +9 -0
- package/packages/bundled-features/src/presence/options.ts +5 -1
- package/packages/bundled-features/src/readiness/boot-rules.ts +14 -0
- package/packages/bundled-features/src/readiness/probe-boot-check.ts +8 -6
- package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +6 -4
- package/packages/bundled-features/src/shared/boot-rules.ts +9 -0
- package/packages/bundled-features/src/subscription-mollie/boot-rules.ts +19 -0
- package/packages/bundled-features/src/subscription-mollie/feature.ts +18 -10
- package/packages/bundled-features/src/tags/boot-rules.ts +9 -0
- package/packages/bundled-features/src/tags/feature.ts +6 -3
- package/packages/bundled-features/src/template-resolver/boot-rules.ts +19 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +14 -10
- package/packages/bundled-features/src/tenant/boot-rules.ts +9 -0
- package/packages/bundled-features/src/tenant/feature.ts +5 -3
- package/samples/apps/marketing-demo/README.md +1 -1
- package/samples/apps/marketing-demo/playwright.config.ts +1 -1
- package/samples/apps/marketing-demo/src/app/client.tsx +3 -3
- package/samples/apps/marketing-demo/src/app/seed-data.ts +1 -1
- package/samples/apps/marketing-demo/src/app/seed.ts +4 -4
- package/samples/apps/marketing-demo/src/app/server.ts +3 -3
- package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/feature.ts +15 -12
- package/samples/apps/marketing-demo/src/features/ticketing/i18n.ts +100 -0
- package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/ticket.ts +4 -4
- package/samples/apps/marketing-demo/src/features/ticketing/web/index.ts +7 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +67 -67
- package/samples/apps/use-all-bundled/kumiko/migrations/0064_helpdesk-rename.rebuild.json +4 -0
- package/samples/apps/use-all-bundled/package.json +1 -1
- package/samples/apps/use-all-bundled/src/app/client.tsx +1 -1
- package/samples/apps/use-all-bundled/src/app/screens-feature.ts +10 -10
- package/samples/apps/use-all-bundled/src/run-config.ts +6 -6
- package/samples/recipes/api-docs/README.md +3 -3
- package/samples/recipes/api-docs/api-docs/de/events.md +14 -14
- package/samples/recipes/api-docs/api-docs/de/overview.md +3 -3
- package/samples/recipes/api-docs/api-docs/de/reference/tickets.md +10 -10
- package/samples/recipes/api-docs/api-docs/de/tokens.md +4 -4
- package/samples/recipes/api-docs/api-docs/en/events.md +14 -14
- package/samples/recipes/api-docs/api-docs/en/overview.md +3 -3
- package/samples/recipes/api-docs/api-docs/en/reference/tickets.md +10 -10
- package/samples/recipes/api-docs/api-docs/en/tokens.md +4 -4
- package/samples/recipes/api-docs/api-docs/index.json +22 -22
- package/samples/recipes/api-docs/api-docs/openapi.json +67 -67
- package/samples/recipes/api-docs/api-examples/ticket-close.json +1 -1
- package/samples/recipes/api-docs/api-examples/ticket-create.json +1 -1
- package/samples/recipes/api-docs/api-examples/ticket-detail.json +1 -1
- package/samples/recipes/api-docs/api-examples/ticket-list.json +1 -1
- package/samples/recipes/api-docs/api-examples/ticket-update.json +1 -1
- package/samples/recipes/api-docs/api-examples/webhooks/ticket-closed.json +1 -1
- package/samples/recipes/api-docs/kumiko.config.ts +4 -4
- package/samples/recipes/api-docs/src/feature.ts +44 -44
- package/samples/recipes/golden-path/src/feature.ts +1 -1
- package/samples/recipes/helpdesk/README.md +56 -0
- package/samples/recipes/{contact → helpdesk}/package.json +2 -2
- package/samples/recipes/{contact → helpdesk}/src/feature.ts +11 -8
- package/packages/bundled-features/src/contact/client/contact-website-client.ts +0 -29
- package/packages/bundled-features/src/contact/client/index.ts +0 -9
- package/packages/bundled-features/src/contact/index.ts +0 -29
- package/packages/bundled-features/src/contact/panels.ts +0 -28
- package/packages/bundled-features/src/contact/web/constants.ts +0 -160
- package/packages/bundled-features/src/contact/web/index.ts +0 -29
- package/samples/apps/marketing-demo/src/features/helpdesk/i18n.ts +0 -100
- package/samples/apps/marketing-demo/src/features/helpdesk/web/index.ts +0 -7
- package/samples/recipes/contact/README.md +0 -52
- /package/packages/bundled-features/src/{contact → helpdesk}/handlers/access.ts +0 -0
- /package/packages/bundled-features/src/{contact → helpdesk}/pow.ts +0 -0
- /package/packages/bundled-features/src/{contact → helpdesk}/user-agent.ts +0 -0
- /package/samples/apps/marketing-demo/src/features/{helpdesk → ticketing}/schema/index.ts +0 -0
|
@@ -13,13 +13,13 @@ import { collectErasureFailure, decryptStoredPii, throwIfErasureFailed } from ".
|
|
|
13
13
|
import { userTable } from "../user/index.ts";
|
|
14
14
|
import { normalizeEmail, platformActor, replyExecutor, requestExecutor } from "./lib.ts";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
HELPDESK_REPLY_ENTITY,
|
|
17
|
+
HELPDESK_REQUEST_ENTITY,
|
|
18
|
+
HELPDESK_UPLOAD_FIELD,
|
|
19
19
|
} from "./web/constants.ts";
|
|
20
20
|
|
|
21
|
-
const PII_DECRYPT_REASON = "
|
|
22
|
-
const ERASE_REASON = "
|
|
21
|
+
const PII_DECRYPT_REASON = "helpdesk:user-data";
|
|
22
|
+
const ERASE_REASON = "helpdesk:user-data-forget";
|
|
23
23
|
const LOOKUP_LIMIT = 200;
|
|
24
24
|
|
|
25
25
|
// Anonymous requests are matched by email, so the user must have proven they own it: otherwise
|
|
@@ -62,7 +62,7 @@ async function findAttachments(ctx: UserDataHookCtx, entity: string, id: string)
|
|
|
62
62
|
tenantId: SYSTEM_TENANT_ID,
|
|
63
63
|
entityType: entity,
|
|
64
64
|
entityId: id,
|
|
65
|
-
fieldName:
|
|
65
|
+
fieldName: HELPDESK_UPLOAD_FIELD,
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -75,18 +75,18 @@ async function purgeAttachments(ctx: UserDataHookCtx, entity: string, id: string
|
|
|
75
75
|
const provider = await ctx.buildStorageProvider?.(SYSTEM_TENANT_ID);
|
|
76
76
|
if (!provider) {
|
|
77
77
|
throw new InternalError({
|
|
78
|
-
message: `[
|
|
78
|
+
message: `[helpdesk:user-data] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
for (const attachment of attachments) {
|
|
82
82
|
const failed = await deleteStoredFileAndDerivatives(
|
|
83
83
|
attachment.storageKey,
|
|
84
84
|
provider,
|
|
85
|
-
"
|
|
85
|
+
"helpdesk:user-data",
|
|
86
86
|
);
|
|
87
87
|
if (failed.length > 0) {
|
|
88
88
|
throw new InternalError({
|
|
89
|
-
message: `[
|
|
89
|
+
message: `[helpdesk:user-data] ${failed.length} attachment byte delete(s) failed for ${entity} ${id}`,
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -111,7 +111,7 @@ async function findReplies(ctx: UserDataHookCtx, requestId: string) {
|
|
|
111
111
|
return found.rows;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export const
|
|
114
|
+
export const helpdeskExportHook: UserDataExportHook = async (ctx) => {
|
|
115
115
|
const requests = await findRequests(ctx);
|
|
116
116
|
if (requests.length === 0) return null;
|
|
117
117
|
const rows = [];
|
|
@@ -128,7 +128,7 @@ export const contactExportHook: UserDataExportHook = async (ctx) => {
|
|
|
128
128
|
phone: request.phone,
|
|
129
129
|
page: request.page,
|
|
130
130
|
submittedAt: String(request.submittedAt),
|
|
131
|
-
attachments: (await findAttachments(ctx,
|
|
131
|
+
attachments: (await findAttachments(ctx, HELPDESK_REQUEST_ENTITY, request.id)).map(
|
|
132
132
|
(file) => file.fileName,
|
|
133
133
|
),
|
|
134
134
|
replies: replies.map((reply) => ({
|
|
@@ -138,13 +138,13 @@ export const contactExportHook: UserDataExportHook = async (ctx) => {
|
|
|
138
138
|
})),
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
return { entity:
|
|
141
|
+
return { entity: HELPDESK_REQUEST_ENTITY, rows };
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// Requests and replies carry no statutory retention duty, so both strategies erase: rows are
|
|
145
145
|
// purged through the executor (replays on rebuild) and the record subject keys are shredded so
|
|
146
146
|
// the event log's ciphertext becomes unreadable. Replies go with their request.
|
|
147
|
-
export const
|
|
147
|
+
export const helpdeskDeleteHook: UserDataDeleteHook = async (ctx) => {
|
|
148
148
|
const kms = configuredPiiSubjectKms();
|
|
149
149
|
const failures: string[] = [];
|
|
150
150
|
const erase = async (
|
|
@@ -162,16 +162,16 @@ export const contactDeleteHook: UserDataDeleteHook = async (ctx) => {
|
|
|
162
162
|
};
|
|
163
163
|
for (const request of await findRequests(ctx)) {
|
|
164
164
|
for (const reply of await findReplies(ctx, request.id)) {
|
|
165
|
-
await purgeAttachments(ctx,
|
|
165
|
+
await purgeAttachments(ctx, HELPDESK_REPLY_ENTITY, reply.id);
|
|
166
166
|
await erase(
|
|
167
|
-
|
|
167
|
+
HELPDESK_REPLY_ENTITY,
|
|
168
168
|
reply.id,
|
|
169
169
|
await replyExecutor.forget({ id: reply.id }, platformActor(), ctx.db),
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
|
-
await purgeAttachments(ctx,
|
|
172
|
+
await purgeAttachments(ctx, HELPDESK_REQUEST_ENTITY, request.id);
|
|
173
173
|
await erase(
|
|
174
|
-
|
|
174
|
+
HELPDESK_REQUEST_ENTITY,
|
|
175
175
|
request.id,
|
|
176
176
|
await requestExecutor.forget({ id: request.id }, platformActor(), ctx.db),
|
|
177
177
|
);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Pure string constants, safe for browser code (see waitlist/web/constants.ts).
|
|
2
|
+
export const HELPDESK_FEATURE = "helpdesk" as const;
|
|
3
|
+
|
|
4
|
+
export const HELPDESK_KIND = {
|
|
5
|
+
Question: "question",
|
|
6
|
+
Contact: "contact",
|
|
7
|
+
Bug: "bug",
|
|
8
|
+
Wish: "wish",
|
|
9
|
+
} as const;
|
|
10
|
+
export type HelpdeskKind = (typeof HELPDESK_KIND)[keyof typeof HELPDESK_KIND];
|
|
11
|
+
|
|
12
|
+
export const HELPDESK_WEBSITE_KINDS = [
|
|
13
|
+
HELPDESK_KIND.Question,
|
|
14
|
+
HELPDESK_KIND.Contact,
|
|
15
|
+
HELPDESK_KIND.Bug,
|
|
16
|
+
] as const;
|
|
17
|
+
export const HELPDESK_ADMIN_KINDS = [
|
|
18
|
+
HELPDESK_KIND.Question,
|
|
19
|
+
HELPDESK_KIND.Bug,
|
|
20
|
+
HELPDESK_KIND.Wish,
|
|
21
|
+
] as const;
|
|
22
|
+
|
|
23
|
+
export const HELPDESK_STATUS = {
|
|
24
|
+
Open: "open",
|
|
25
|
+
Answered: "answered",
|
|
26
|
+
Done: "done",
|
|
27
|
+
} as const;
|
|
28
|
+
export type HelpdeskStatus = (typeof HELPDESK_STATUS)[keyof typeof HELPDESK_STATUS];
|
|
29
|
+
|
|
30
|
+
export const HELPDESK_SOURCE = {
|
|
31
|
+
Website: "website",
|
|
32
|
+
Admin: "admin",
|
|
33
|
+
} as const;
|
|
34
|
+
export type HelpdeskSource = (typeof HELPDESK_SOURCE)[keyof typeof HELPDESK_SOURCE];
|
|
35
|
+
|
|
36
|
+
export const HELPDESK_REPLY_CHANNELS = {
|
|
37
|
+
Email: "email",
|
|
38
|
+
EmailAndInApp: "email+inApp",
|
|
39
|
+
} as const;
|
|
40
|
+
export type HelpdeskReplyChannels =
|
|
41
|
+
(typeof HELPDESK_REPLY_CHANNELS)[keyof typeof HELPDESK_REPLY_CHANNELS];
|
|
42
|
+
|
|
43
|
+
export const HELPDESK_ORIGIN = {
|
|
44
|
+
Website: "website",
|
|
45
|
+
AdminReport: "admin-report",
|
|
46
|
+
} as const;
|
|
47
|
+
export type HelpdeskOrigin = (typeof HELPDESK_ORIGIN)[keyof typeof HELPDESK_ORIGIN];
|
|
48
|
+
|
|
49
|
+
export const HELPDESK_DELIVERY_CHANNEL = {
|
|
50
|
+
Email: "email",
|
|
51
|
+
Telegram: "telegram",
|
|
52
|
+
ReplyEmail: "reply-email",
|
|
53
|
+
ReplyInApp: "reply-in-app",
|
|
54
|
+
} as const;
|
|
55
|
+
export type HelpdeskDeliveryChannel =
|
|
56
|
+
(typeof HELPDESK_DELIVERY_CHANNEL)[keyof typeof HELPDESK_DELIVERY_CHANNEL];
|
|
57
|
+
|
|
58
|
+
export const HELPDESK_DELIVERY_STATUS = {
|
|
59
|
+
Pending: "pending",
|
|
60
|
+
Delivered: "delivered",
|
|
61
|
+
Failed: "failed",
|
|
62
|
+
Skipped: "skipped",
|
|
63
|
+
Read: "read",
|
|
64
|
+
} as const;
|
|
65
|
+
export type HelpdeskDeliveryStatus =
|
|
66
|
+
(typeof HELPDESK_DELIVERY_STATUS)[keyof typeof HELPDESK_DELIVERY_STATUS];
|
|
67
|
+
|
|
68
|
+
export type HelpdeskPhoneMode = "off" | "optional" | "required";
|
|
69
|
+
|
|
70
|
+
export const HelpdeskHandlers = {
|
|
71
|
+
submit: "helpdesk:write:submit",
|
|
72
|
+
report: "helpdesk:write:report",
|
|
73
|
+
reply: "helpdesk:write:reply",
|
|
74
|
+
markDone: "helpdesk:write:mark-done",
|
|
75
|
+
sendTest: "helpdesk:write:send-test",
|
|
76
|
+
forwardRequest: "helpdesk:write:forward-request",
|
|
77
|
+
sendReplyMail: "helpdesk:write:send-reply-mail",
|
|
78
|
+
notifyReporterInApp: "helpdesk:write:notify-reporter-in-app",
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
export const HelpdeskQueries = {
|
|
82
|
+
challenge: "helpdesk:query:challenge",
|
|
83
|
+
openCount: "helpdesk:query:open-count",
|
|
84
|
+
requestDetail: "helpdesk:query:request-detail",
|
|
85
|
+
replies: "helpdesk:query:replies",
|
|
86
|
+
requestDelivery: "helpdesk:query:request-delivery",
|
|
87
|
+
// Entity-convention list QN: entityList screens resolve their query by this shape.
|
|
88
|
+
requestList: "helpdesk:query:helpdesk-request:list",
|
|
89
|
+
} as const;
|
|
90
|
+
|
|
91
|
+
export const HelpdeskScreens = {
|
|
92
|
+
requestList: "helpdesk:screen:request-list",
|
|
93
|
+
requestDetail: "helpdesk:screen:request-detail",
|
|
94
|
+
report: "helpdesk:screen:report",
|
|
95
|
+
reply: "helpdesk:screen:reply",
|
|
96
|
+
replyMail: "helpdesk:screen:reply-mail",
|
|
97
|
+
forwarding: "helpdesk:screen:forwarding",
|
|
98
|
+
} as const;
|
|
99
|
+
|
|
100
|
+
// Files field of both upload forms (report, reply); the uploads are pending under the screen QN.
|
|
101
|
+
export const HELPDESK_UPLOAD_FIELD = "fileIds" as const;
|
|
102
|
+
|
|
103
|
+
export const HelpdeskConfigKeys = {
|
|
104
|
+
replyTo: "helpdesk:config:reply-to",
|
|
105
|
+
telegramChat: "helpdesk:config:telegram-chat",
|
|
106
|
+
} as const;
|
|
107
|
+
|
|
108
|
+
export const HelpdeskErrors = {
|
|
109
|
+
telegramChatMissing: "telegram_chat_missing",
|
|
110
|
+
telegramTestFailed: "telegram_test_failed",
|
|
111
|
+
notFound: "helpdesk_request_not_found",
|
|
112
|
+
phoneNotAllowed: "helpdesk_phone_not_allowed",
|
|
113
|
+
phoneRequired: "helpdesk_phone_required",
|
|
114
|
+
reporterEmailMissing: "helpdesk_reporter_email_missing",
|
|
115
|
+
attachmentNotFound: "helpdesk_attachment_not_found",
|
|
116
|
+
} as const;
|
|
117
|
+
|
|
118
|
+
export const HELPDESK_NOTIFICATION_TYPES = {
|
|
119
|
+
newRequest: "helpdesk:notify:new-request",
|
|
120
|
+
confirmation: "helpdesk:notify:confirmation",
|
|
121
|
+
acknowledgement: "helpdesk:notify:acknowledgement",
|
|
122
|
+
reply: "helpdesk:notify:reply",
|
|
123
|
+
replyInApp: "helpdesk:notify:reply-in-app",
|
|
124
|
+
test: "helpdesk:notify:test",
|
|
125
|
+
} as const;
|
|
126
|
+
|
|
127
|
+
export const HELPDESK_CLIENT_PATH = "/helpdesk/client.js" as const;
|
|
128
|
+
|
|
129
|
+
export const HELPDESK_FIELD_LIMITS = {
|
|
130
|
+
name: 120,
|
|
131
|
+
email: 254,
|
|
132
|
+
phone: 40,
|
|
133
|
+
subject: 200,
|
|
134
|
+
message: 5000,
|
|
135
|
+
locale: 35,
|
|
136
|
+
honeypot: 500,
|
|
137
|
+
page: 300,
|
|
138
|
+
challenge: 64,
|
|
139
|
+
nonce: 32,
|
|
140
|
+
} as const;
|
|
141
|
+
|
|
142
|
+
export const HELPDESK_MAX_FILES = 5;
|
|
143
|
+
|
|
144
|
+
export const HELPDESK_SUBJECT_MAX_CHARS = 80;
|
|
145
|
+
|
|
146
|
+
export const HELPDESK_POW_BITS = { min: 8, max: 26, default: 19 } as const;
|
|
147
|
+
export const HELPDESK_DEFAULT_MIN_SUBMIT_SECONDS = 3;
|
|
148
|
+
export const HELPDESK_DEFAULT_CHALLENGE_TTL_MINUTES = 30;
|
|
149
|
+
export const HELPDESK_CHALLENGE_REDIS_PREFIX = "helpdesk:challenge:" as const;
|
|
150
|
+
|
|
151
|
+
export const HELPDESK_REQUEST_ENTITY = "helpdesk-request" as const;
|
|
152
|
+
export const HELPDESK_REPLY_ENTITY = "helpdesk-reply" as const;
|
|
153
|
+
|
|
154
|
+
export const helpdeskIdempotencyKeys = {
|
|
155
|
+
admins: (requestId: string) => `helpdesk:request:${requestId}:admins`,
|
|
156
|
+
telegram: (requestId: string) => `helpdesk:request:${requestId}:telegram`,
|
|
157
|
+
confirmation: (requestId: string) => `helpdesk:request:${requestId}:confirmation`,
|
|
158
|
+
reply: (replyId: string) => `helpdesk:reply:${replyId}`,
|
|
159
|
+
replyInApp: (replyId: string) => `helpdesk:reply:${replyId}:in-app`,
|
|
160
|
+
} as const;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
HELPDESK_ADMIN_KINDS,
|
|
3
|
+
HELPDESK_CLIENT_PATH,
|
|
4
|
+
HELPDESK_DELIVERY_CHANNEL,
|
|
5
|
+
HELPDESK_DELIVERY_STATUS,
|
|
6
|
+
HELPDESK_FEATURE,
|
|
7
|
+
HELPDESK_FIELD_LIMITS,
|
|
8
|
+
HELPDESK_KIND,
|
|
9
|
+
HELPDESK_NOTIFICATION_TYPES,
|
|
10
|
+
HELPDESK_ORIGIN,
|
|
11
|
+
HELPDESK_REPLY_CHANNELS,
|
|
12
|
+
HELPDESK_SOURCE,
|
|
13
|
+
HELPDESK_STATUS,
|
|
14
|
+
HELPDESK_SUBJECT_MAX_CHARS,
|
|
15
|
+
HELPDESK_WEBSITE_KINDS,
|
|
16
|
+
HelpdeskConfigKeys,
|
|
17
|
+
type HelpdeskDeliveryChannel,
|
|
18
|
+
type HelpdeskDeliveryStatus,
|
|
19
|
+
HelpdeskErrors,
|
|
20
|
+
HelpdeskHandlers,
|
|
21
|
+
type HelpdeskKind,
|
|
22
|
+
type HelpdeskOrigin,
|
|
23
|
+
type HelpdeskPhoneMode,
|
|
24
|
+
HelpdeskQueries,
|
|
25
|
+
type HelpdeskReplyChannels,
|
|
26
|
+
HelpdeskScreens,
|
|
27
|
+
type HelpdeskSource,
|
|
28
|
+
type HelpdeskStatus,
|
|
29
|
+
} from "./constants.ts";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const HOST_ROUTING_BOOT_RULES = {
|
|
4
|
+
invalidRedirect: {
|
|
5
|
+
id: "host-routing/invalid-redirect",
|
|
6
|
+
summary:
|
|
7
|
+
"Redirect rules use a path as from, a same-origin path or https URL as to, and a lowercase hostname as host.",
|
|
8
|
+
fix: "Fix the redirect rule named in the error message.",
|
|
9
|
+
},
|
|
10
|
+
invalidApexAnonymousQueryAllowlist: {
|
|
11
|
+
id: "host-routing/invalid-apex-anonymous-query-allowlist",
|
|
12
|
+
summary:
|
|
13
|
+
"apexAnonymousQueryAllowlist keys are apex hostnames and the option is not combined with tenantBy path.",
|
|
14
|
+
fix: "Use apex or www.<apex> keys and drop the option in path mode.",
|
|
15
|
+
},
|
|
16
|
+
invalidDomainOrPrefix: {
|
|
17
|
+
id: "host-routing/invalid-domain-or-prefix",
|
|
18
|
+
summary:
|
|
19
|
+
"baseDomain and hosts keys are lowercase hostnames and tenantPathPrefix is a leading-slash path.",
|
|
20
|
+
fix: "Fix the domain or prefix named in the error message.",
|
|
21
|
+
},
|
|
22
|
+
invalidLocales: {
|
|
23
|
+
id: "host-routing/invalid-locales",
|
|
24
|
+
summary: "Locales look like de or de-at and the default locale is not in prefixed.",
|
|
25
|
+
fix: "Fix the locales option named in the error message.",
|
|
26
|
+
},
|
|
27
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { HOST_ROUTING_BOOT_RULES } from "./boot-rules.ts";
|
|
1
3
|
import { isApexHostname } from "./host.ts";
|
|
2
4
|
import type { HostRoutingOptions } from "./options.ts";
|
|
3
5
|
|
|
@@ -14,22 +16,24 @@ const REDIRECT_TARGET_PATTERN =
|
|
|
14
16
|
function validateRedirects(options: HostRoutingOptions): void {
|
|
15
17
|
for (const rule of options.redirects ?? []) {
|
|
16
18
|
if (!REDIRECT_PATH_PATTERN.test(rule.from)) {
|
|
17
|
-
throw
|
|
19
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidRedirect, {
|
|
20
|
+
message: `host-routing: redirect from must be a path like "/old", got "${rule.from}"`,
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
if (rule.from === "/api" || rule.from.startsWith("/api/")) {
|
|
20
|
-
throw
|
|
21
|
-
`host-routing: redirect from must not be an /api path, it would never fire, got "${rule.from}"`,
|
|
22
|
-
);
|
|
24
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidRedirect, {
|
|
25
|
+
message: `host-routing: redirect from must not be an /api path, it would never fire, got "${rule.from}"`,
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
if (!REDIRECT_TARGET_PATTERN.test(rule.to)) {
|
|
25
|
-
throw
|
|
26
|
-
`host-routing: redirect to must be a same-origin path or an https URL without query, got "${rule.to}"`,
|
|
27
|
-
);
|
|
29
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidRedirect, {
|
|
30
|
+
message: `host-routing: redirect to must be a same-origin path or an https URL without query, got "${rule.to}"`,
|
|
31
|
+
});
|
|
28
32
|
}
|
|
29
33
|
if (rule.host !== undefined && !DOMAIN_PATTERN.test(rule.host)) {
|
|
30
|
-
throw
|
|
31
|
-
`host-routing: redirect host must be a lowercase hostname, got "${rule.host}"`,
|
|
32
|
-
);
|
|
34
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidRedirect, {
|
|
35
|
+
message: `host-routing: redirect host must be a lowercase hostname, got "${rule.host}"`,
|
|
36
|
+
});
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -38,15 +42,16 @@ function validateAnonymousQueryAllowlist(options: HostRoutingOptions): void {
|
|
|
38
42
|
if (options.apexAnonymousQueryAllowlist !== undefined && options.tenantBy === "path") {
|
|
39
43
|
// Path mode resolves as fallback-only: a client-sent X-Tenant or cookie wins
|
|
40
44
|
// before the resolver runs, so the allowlist could never hold.
|
|
41
|
-
throw
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidApexAnonymousQueryAllowlist, {
|
|
46
|
+
message:
|
|
47
|
+
'host-routing: apexAnonymousQueryAllowlist cannot be used with tenantBy "path", because the client names its tenant there and bypasses the allowlist',
|
|
48
|
+
});
|
|
44
49
|
}
|
|
45
50
|
for (const host of Object.keys(options.apexAnonymousQueryAllowlist ?? {})) {
|
|
46
51
|
if (!isApexHostname(host, options.baseDomain)) {
|
|
47
|
-
throw
|
|
48
|
-
`host-routing: apexAnonymousQueryAllowlist key must be the apex or www.<apex> hostname, got "${host}"`,
|
|
49
|
-
);
|
|
52
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidApexAnonymousQueryAllowlist, {
|
|
53
|
+
message: `host-routing: apexAnonymousQueryAllowlist key must be the apex or www.<apex> hostname, got "${host}"`,
|
|
54
|
+
});
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
}
|
|
@@ -55,22 +60,24 @@ function validateAnonymousQueryAllowlist(options: HostRoutingOptions): void {
|
|
|
55
60
|
// the boot instead of routing every request to a 404.
|
|
56
61
|
export function validateHostRoutingOptions(options: HostRoutingOptions): void {
|
|
57
62
|
if (!DOMAIN_PATTERN.test(options.baseDomain)) {
|
|
58
|
-
throw
|
|
59
|
-
`host-routing: baseDomain must be a lowercase hostname without port, got "${options.baseDomain}"`,
|
|
60
|
-
);
|
|
63
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidDomainOrPrefix, {
|
|
64
|
+
message: `host-routing: baseDomain must be a lowercase hostname without port, got "${options.baseDomain}"`,
|
|
65
|
+
});
|
|
61
66
|
}
|
|
62
67
|
for (const host of Object.keys(options.hosts ?? {})) {
|
|
63
68
|
if (!DOMAIN_PATTERN.test(host)) {
|
|
64
|
-
throw
|
|
69
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidDomainOrPrefix, {
|
|
70
|
+
message: `host-routing: hosts key must be a lowercase hostname, got "${host}"`,
|
|
71
|
+
});
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
if (
|
|
68
75
|
options.tenantPathPrefix !== undefined &&
|
|
69
76
|
!PATH_PREFIX_PATTERN.test(options.tenantPathPrefix)
|
|
70
77
|
) {
|
|
71
|
-
throw
|
|
72
|
-
`host-routing: tenantPathPrefix must look like "/app" (leading slash, no trailing slash), got "${options.tenantPathPrefix}"`,
|
|
73
|
-
);
|
|
78
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidDomainOrPrefix, {
|
|
79
|
+
message: `host-routing: tenantPathPrefix must look like "/app" (leading slash, no trailing slash), got "${options.tenantPathPrefix}"`,
|
|
80
|
+
});
|
|
74
81
|
}
|
|
75
82
|
validateRedirects(options);
|
|
76
83
|
validateAnonymousQueryAllowlist(options);
|
|
@@ -78,13 +85,15 @@ export function validateHostRoutingOptions(options: HostRoutingOptions): void {
|
|
|
78
85
|
if (locales !== undefined) {
|
|
79
86
|
for (const locale of [locales.default, ...locales.prefixed]) {
|
|
80
87
|
if (!LOCALE_PATTERN.test(locale)) {
|
|
81
|
-
throw
|
|
88
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidLocales, {
|
|
89
|
+
message: `host-routing: locale must look like "de" or "de-at", got "${locale}"`,
|
|
90
|
+
});
|
|
82
91
|
}
|
|
83
92
|
}
|
|
84
93
|
if (locales.prefixed.includes(locales.default)) {
|
|
85
|
-
throw
|
|
86
|
-
`host-routing: default locale "${locales.default}" is served unprefixed and must not be in prefixed`,
|
|
87
|
-
);
|
|
94
|
+
throw bootRuleError(HOST_ROUTING_BOOT_RULES.invalidLocales, {
|
|
95
|
+
message: `host-routing: default locale "${locales.default}" is served unprefixed and must not be in prefixed`,
|
|
96
|
+
});
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const JOBS_BOOT_RULES = {
|
|
4
|
+
anonymousReadRole: {
|
|
5
|
+
id: "jobs/anonymous-read-role",
|
|
6
|
+
summary: "The jobs readRoles option does not contain anonymous.",
|
|
7
|
+
fix: "Remove anonymous from readRoles.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
bootRuleError,
|
|
3
|
+
defineFeature,
|
|
4
|
+
type FeatureDefinition,
|
|
5
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import { JOBS_BOOT_RULES } from "./boot-rules.ts";
|
|
2
7
|
import { catalogQuery } from "./handlers/catalog.query.ts";
|
|
3
8
|
import {
|
|
4
9
|
consumerDisableWrite,
|
|
@@ -60,9 +65,9 @@ export function createJobsFeature(options: JobsFeatureOptions = {}): FeatureDefi
|
|
|
60
65
|
const staleRunTimeoutHours = options.staleRunTimeoutHours ?? DEFAULT_JOB_RUN_STALE_TIMEOUT_HOURS;
|
|
61
66
|
const readRoles = options.readRoles ?? [];
|
|
62
67
|
if (readRoles.includes("anonymous")) {
|
|
63
|
-
throw
|
|
64
|
-
`createJobsFeature: readRoles must not contain "anonymous" — job status and failures are only readable by members of the tenant.`,
|
|
65
|
-
);
|
|
68
|
+
throw bootRuleError(JOBS_BOOT_RULES.anonymousReadRole, {
|
|
69
|
+
message: `createJobsFeature: readRoles must not contain "anonymous" — job status and failures are only readable by members of the tenant.`,
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
return defineFeature("jobs", (r) => {
|
|
68
73
|
r.adoptsBundledLists();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const LEGAL_PAGES_BOOT_RULES = {
|
|
4
|
+
invalidRoute: {
|
|
5
|
+
id: "legal-pages/invalid-route",
|
|
6
|
+
summary: "Legal page routes declare path, slug and lang, and the path starts with a slash.",
|
|
7
|
+
fix: "Fix the route named in the error message.",
|
|
8
|
+
},
|
|
9
|
+
duplicateRoutePath: {
|
|
10
|
+
id: "legal-pages/duplicate-route-path",
|
|
11
|
+
summary: "Legal page route paths are unique.",
|
|
12
|
+
fix: "Remove or rename the duplicate route.",
|
|
13
|
+
},
|
|
14
|
+
routesWithoutRequiredBlocks: {
|
|
15
|
+
id: "legal-pages/routes-without-required-blocks",
|
|
16
|
+
summary: "Custom routes that miss the default required blocks pass requiredBlocks explicitly.",
|
|
17
|
+
fix: "Pass requiredBlocks (or an empty array) alongside custom routes.",
|
|
18
|
+
},
|
|
19
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computeRevisionEtag, etagMatches } from "@cosmicdrift/kumiko-framework/api";
|
|
2
2
|
import {
|
|
3
|
+
bootRuleError,
|
|
3
4
|
defineFeature,
|
|
4
5
|
type FeatureDefinition,
|
|
5
6
|
SYSTEM_TENANT_ID,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
redirectToCanonicalPath,
|
|
12
13
|
slashVariantOf,
|
|
13
14
|
} from "../page-render/index.ts";
|
|
15
|
+
import { LEGAL_PAGES_BOOT_RULES } from "./boot-rules.ts";
|
|
14
16
|
import { runLegalPagesBootCheck } from "./lib/boot-check.ts";
|
|
15
17
|
import { validateRoutes } from "./lib/validate-routes.ts";
|
|
16
18
|
import { renderMarkdownToHtml, wrapInLayout } from "./markdown.ts";
|
|
@@ -113,9 +115,10 @@ export function createLegalPagesFeature(opts: LegalPagesOptions = {}): FeatureDe
|
|
|
113
115
|
opts.routes?.some((route) => route.slug === block.slug && route.lang === block.lang),
|
|
114
116
|
);
|
|
115
117
|
if (!coversDefaultBlock) {
|
|
116
|
-
throw
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.routesWithoutRequiredBlocks, {
|
|
119
|
+
message:
|
|
120
|
+
"legal-pages: custom `routes` without `requiredBlocks` — pass `requiredBlocks` explicitly (or `[]`)",
|
|
121
|
+
});
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
const alternatesBySlug = alternatesBySlugOf(routes);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { LEGAL_PAGES_BOOT_RULES } from "../boot-rules.ts";
|
|
1
3
|
import type { LegalPageRoute } from "../web/constants.ts";
|
|
2
4
|
|
|
3
5
|
// Validated once at feature-build time (not per-request) so a config typo
|
|
@@ -6,15 +8,19 @@ export function validateRoutes(routes: readonly LegalPageRoute[]): void {
|
|
|
6
8
|
const seenPaths = new Set<string>();
|
|
7
9
|
for (const route of routes) {
|
|
8
10
|
if (!route.path || !route.slug || !route.lang) {
|
|
9
|
-
throw
|
|
10
|
-
`legal-pages: route is missing a required field (path/slug/lang): ${JSON.stringify(route)}`,
|
|
11
|
-
);
|
|
11
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.invalidRoute, {
|
|
12
|
+
message: `legal-pages: route is missing a required field (path/slug/lang): ${JSON.stringify(route)}`,
|
|
13
|
+
});
|
|
12
14
|
}
|
|
13
15
|
if (!route.path.startsWith("/")) {
|
|
14
|
-
throw
|
|
16
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.invalidRoute, {
|
|
17
|
+
message: `legal-pages: route path must start with "/", got "${route.path}"`,
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
if (seenPaths.has(route.path)) {
|
|
17
|
-
throw
|
|
21
|
+
throw bootRuleError(LEGAL_PAGES_BOOT_RULES.duplicateRoutePath, {
|
|
22
|
+
message: `legal-pages: duplicate route path "${route.path}"`,
|
|
23
|
+
});
|
|
18
24
|
}
|
|
19
25
|
seenPaths.add(route.path);
|
|
20
26
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const METRICS_BOOT_RULES = {
|
|
4
|
+
duplicateMetricId: {
|
|
5
|
+
id: "metrics/duplicate-metric-id",
|
|
6
|
+
summary: "Metric ids passed to the metrics factory are unique.",
|
|
7
|
+
fix: "Rename one of the metrics.",
|
|
8
|
+
},
|
|
9
|
+
invalidMetric: {
|
|
10
|
+
id: "metrics/invalid-metric",
|
|
11
|
+
summary:
|
|
12
|
+
"Each metric passed to the metrics factory has a kebab-case id and a valid definition.",
|
|
13
|
+
fix: "Fix the metric named in the error message.",
|
|
14
|
+
},
|
|
15
|
+
} as const satisfies BootRuleTable;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { extractTableInfo, isTimestamptzType } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { METRICS_BOOT_RULES } from "./boot-rules.ts";
|
|
2
4
|
import { filterValueKindOf, metricFilterEntries, RESERVED_PAYLOAD_KEYS } from "./filters.ts";
|
|
3
5
|
import type { MetricDefinition } from "./types.ts";
|
|
4
6
|
import { METRIC_RANGES } from "./web/constants.ts";
|
|
@@ -15,7 +17,9 @@ export function validateMetrics(metrics: readonly MetricDefinition[]): void {
|
|
|
15
17
|
const seen = new Set<string>();
|
|
16
18
|
for (const metric of metrics) {
|
|
17
19
|
if (seen.has(metric.id)) {
|
|
18
|
-
throw
|
|
20
|
+
throw bootRuleError(METRICS_BOOT_RULES.duplicateMetricId, {
|
|
21
|
+
message: `metrics: duplicate metric id "${metric.id}"`,
|
|
22
|
+
});
|
|
19
23
|
}
|
|
20
24
|
seen.add(metric.id);
|
|
21
25
|
validateMetric(metric);
|
|
@@ -27,7 +31,9 @@ type TableInfo = ReturnType<typeof extractTableInfo>;
|
|
|
27
31
|
|
|
28
32
|
function validateMetric(metric: MetricDefinition): void {
|
|
29
33
|
const fail: Fail = (reason) => {
|
|
30
|
-
throw
|
|
34
|
+
throw bootRuleError(METRICS_BOOT_RULES.invalidMetric, {
|
|
35
|
+
message: `metrics: metric "${metric.id}" ${reason}`,
|
|
36
|
+
});
|
|
31
37
|
};
|
|
32
38
|
if (!KEBAB_ID.test(metric.id)) fail("has an id that is not kebab-case");
|
|
33
39
|
if (metric.scopes.length === 0) fail("declares no scopes");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const NOTES_HISTORY_BOOT_RULES = {
|
|
4
|
+
emptyParentsAllowlist: {
|
|
5
|
+
id: "notes-history/empty-parents-allowlist",
|
|
6
|
+
summary: "The parents allowlist is omitted or non-empty.",
|
|
7
|
+
fix: "Omit parents or list at least one entity.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
17
|
type AccessRule,
|
|
18
|
+
bootRuleError,
|
|
18
19
|
defineEntityListHandler,
|
|
19
20
|
defineFeature,
|
|
20
21
|
type EntityDefinition,
|
|
21
22
|
type FeatureRegistrar,
|
|
22
23
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
23
24
|
import { assertNoWhereRuleInOwnershipWrite, resolveFeatureAccess } from "../shared/index.ts";
|
|
25
|
+
import { NOTES_HISTORY_BOOT_RULES } from "./boot-rules.ts";
|
|
24
26
|
import { createNoteEntryEntity, noteMentionEntity } from "./entity.ts";
|
|
25
27
|
import { createNoteEntryExecutor } from "./executor.ts";
|
|
26
28
|
import { createAddNoteHandler } from "./handlers/add-note.write.ts";
|
|
@@ -122,11 +124,12 @@ export function createNotesHistoryFeature(
|
|
|
122
124
|
// that's a config mistake, not a valid allowlist. Omit `parents` instead
|
|
123
125
|
// of passing an empty array.
|
|
124
126
|
if (opts.parents !== undefined && opts.parents.length === 0) {
|
|
125
|
-
throw
|
|
126
|
-
|
|
127
|
+
throw bootRuleError(NOTES_HISTORY_BOOT_RULES.emptyParentsAllowlist, {
|
|
128
|
+
message:
|
|
129
|
+
"createNotesHistoryFeature({ parents }): parents must not be an empty array — " +
|
|
127
130
|
"an empty allowlist rejects every add-note call. Omit `parents` to allow " +
|
|
128
131
|
"any registered entity the caller can read as a note parent.",
|
|
129
|
-
);
|
|
132
|
+
});
|
|
130
133
|
}
|
|
131
134
|
return defineFeature(NOTES_HISTORY_FEATURE_NAME, (r) =>
|
|
132
135
|
registerNotesHistory(
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootRuleTable } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
|
|
3
|
+
export const PERSONAL_ACCESS_TOKENS_BOOT_RULES = {
|
|
4
|
+
scopeEventWithoutContract: {
|
|
5
|
+
id: "personal-access-tokens/scope-event-without-contract",
|
|
6
|
+
summary: "Events listed in PAT scopes have a public webhook contract.",
|
|
7
|
+
fix: "Declare the event with r.defineWebhookEvent or opt the entity into webhookEvents.",
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies BootRuleTable;
|