@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// API docs sample: a
|
|
1
|
+
// API docs sample: a ticketing app whose ticket handlers are reachable with a personal access token.
|
|
2
2
|
// Every handler a token scope reaches needs a description and, per locale, a title, description
|
|
3
3
|
// and field labels; `kumiko api-docs` turns them into the pages under api-docs/.
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ export const ticketEntity = createEntity({
|
|
|
28
28
|
|
|
29
29
|
const ticketAccess = { roles: ["Admin", "User"] } as const;
|
|
30
30
|
|
|
31
|
-
export const
|
|
31
|
+
export const ticketingFeature = defineFeature("ticketing", (r) => {
|
|
32
32
|
const { table: ticketTable, executor: ticketExecutor } = createEntityExecutor(
|
|
33
33
|
"ticket",
|
|
34
34
|
ticketEntity,
|
|
@@ -106,93 +106,93 @@ export const helpdeskFeature = defineFeature("helpdesk", (r) => {
|
|
|
106
106
|
id: "ticket-edit",
|
|
107
107
|
type: "entityEdit",
|
|
108
108
|
entity: "ticket",
|
|
109
|
-
layout: { sections: [{ title: "
|
|
109
|
+
layout: { sections: [{ title: "ticketing:section.ticket", fields: ["title", "priority"] }] },
|
|
110
110
|
});
|
|
111
111
|
r.screen({
|
|
112
112
|
id: "close-ticket",
|
|
113
113
|
type: "actionForm",
|
|
114
|
-
handler: "
|
|
114
|
+
handler: "ticketing:write:ticket:close",
|
|
115
115
|
fields: { resolution: createTextField({ personal: false, reason: "is_business_data" }) },
|
|
116
|
-
layout: { sections: [{ title: "
|
|
116
|
+
layout: { sections: [{ title: "ticketing:section.close", fields: ["resolution"] }] },
|
|
117
117
|
});
|
|
118
118
|
r.screen({
|
|
119
119
|
id: "purge-tickets",
|
|
120
120
|
type: "actionForm",
|
|
121
|
-
handler: "
|
|
121
|
+
handler: "ticketing:write:ticket:purge",
|
|
122
122
|
fields: {},
|
|
123
123
|
layout: { sections: [] },
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
r.nav({ id: "tickets", label: "
|
|
127
|
-
r.nav({ id: "settings", label: "
|
|
126
|
+
r.nav({ id: "tickets", label: "ticketing:nav:tickets", screen: "ticketing:screen:ticket-list" });
|
|
127
|
+
r.nav({ id: "settings", label: "ticketing:nav:settings" });
|
|
128
128
|
r.nav({
|
|
129
129
|
id: "api-tokens",
|
|
130
|
-
label: "
|
|
131
|
-
parent: "
|
|
130
|
+
label: "ticketing:nav:api-tokens",
|
|
131
|
+
parent: "ticketing:nav:settings",
|
|
132
132
|
screen: "personal-access-tokens:screen:api-tokens",
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
r.translations({
|
|
136
136
|
keys: {
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
137
|
+
"ticketing:nav:tickets": { en: "Tickets", de: "Tickets" },
|
|
138
|
+
"ticketing:nav:settings": { en: "Settings", de: "Einstellungen" },
|
|
139
|
+
"ticketing:nav:api-tokens": { en: "API tokens", de: "API-Tokens" },
|
|
140
|
+
"ticketing:section.ticket": { en: "Ticket", de: "Ticket" },
|
|
141
|
+
"ticketing:section.close": { en: "Close ticket", de: "Ticket schließen" },
|
|
142
|
+
"ticketing:entity:ticket:field:title": { en: "Title", de: "Titel" },
|
|
143
|
+
"ticketing:entity:ticket:field:status": { en: "Status", de: "Status" },
|
|
144
|
+
"ticketing:entity:ticket:field:priority": { en: "Priority", de: "Priorität" },
|
|
145
|
+
"ticketing:write:ticket:create:title": { en: "Create ticket", de: "Ticket anlegen" },
|
|
146
|
+
"ticketing:write:ticket:create:description": {
|
|
147
147
|
en: "Opens a new ticket.",
|
|
148
148
|
de: "Legt ein neues Ticket an.",
|
|
149
149
|
},
|
|
150
|
-
"
|
|
151
|
-
"
|
|
150
|
+
"ticketing:write:ticket:update:title": { en: "Update ticket", de: "Ticket ändern" },
|
|
151
|
+
"ticketing:write:ticket:update:description": {
|
|
152
152
|
en: "Changes the title or the priority of a ticket.",
|
|
153
153
|
de: "Ändert Titel oder Priorität eines Tickets.",
|
|
154
154
|
},
|
|
155
|
-
"
|
|
156
|
-
"
|
|
155
|
+
"ticketing:query:ticket:list:title": { en: "List tickets", de: "Tickets auflisten" },
|
|
156
|
+
"ticketing:query:ticket:list:description": {
|
|
157
157
|
en: "Lists tickets, newest first.",
|
|
158
158
|
de: "Listet Tickets, neueste zuerst.",
|
|
159
159
|
},
|
|
160
|
-
"
|
|
161
|
-
"
|
|
160
|
+
"ticketing:query:ticket:detail:title": { en: "Show ticket", de: "Ticket anzeigen" },
|
|
161
|
+
"ticketing:query:ticket:detail:description": {
|
|
162
162
|
en: "Returns one ticket.",
|
|
163
163
|
de: "Liefert ein Ticket.",
|
|
164
164
|
},
|
|
165
|
-
"
|
|
166
|
-
"
|
|
165
|
+
"ticketing:write:ticket:close:title": { en: "Close ticket", de: "Ticket schließen" },
|
|
166
|
+
"ticketing:write:ticket:close:description": {
|
|
167
167
|
en: "Closes a ticket and records how it was resolved.",
|
|
168
168
|
de: "Schließt ein Ticket und hält fest, wie es gelöst wurde.",
|
|
169
169
|
},
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
170
|
+
"ticketing:write:ticket:close:field:id": { en: "Ticket", de: "Ticket" },
|
|
171
|
+
"ticketing:write:ticket:close:field:resolution": { en: "Resolution", de: "Lösung" },
|
|
172
|
+
"ticketing:write:ticket:purge:title": { en: "Purge tickets", de: "Tickets bereinigen" },
|
|
173
|
+
"ticketing:write:ticket:purge:description": {
|
|
174
174
|
en: "Removes tickets that were closed long ago.",
|
|
175
175
|
de: "Entfernt Tickets, die lange geschlossen sind.",
|
|
176
176
|
},
|
|
177
|
-
"
|
|
177
|
+
"ticketing:write:ticket:purge:field:olderThanDays": {
|
|
178
178
|
en: "Closed longer than (days)",
|
|
179
179
|
de: "Länger geschlossen als (Tage)",
|
|
180
180
|
},
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
181
|
+
"ticketing:entity:ticket": { en: "ticket", de: "Ticket" },
|
|
182
|
+
"ticketing:entity:ticket:field:id": { en: "Ticket ID", de: "Ticket-ID" },
|
|
183
|
+
"ticketing:webhook:ticket-closed:description": {
|
|
184
184
|
en: "A ticket was closed and its resolution recorded.",
|
|
185
185
|
de: "Ein Ticket wurde geschlossen und seine Lösung festgehalten.",
|
|
186
186
|
},
|
|
187
|
-
"
|
|
187
|
+
"ticketing:webhook:ticket-closed:field:id": {
|
|
188
188
|
en: "ID of the closed ticket",
|
|
189
189
|
de: "ID des geschlossenen Tickets",
|
|
190
190
|
},
|
|
191
|
-
"
|
|
191
|
+
"ticketing:webhook:ticket-closed:field:resolution": {
|
|
192
192
|
en: "How the ticket was resolved",
|
|
193
193
|
de: "Wie das Ticket gelöst wurde",
|
|
194
194
|
},
|
|
195
|
-
"
|
|
195
|
+
"ticketing:entity:__action-form__:field:resolution": { en: "Resolution", de: "Lösung" },
|
|
196
196
|
},
|
|
197
197
|
});
|
|
198
198
|
});
|
|
@@ -204,12 +204,12 @@ export function patFeature() {
|
|
|
204
204
|
scopes: {
|
|
205
205
|
tickets: {
|
|
206
206
|
label: "Tickets",
|
|
207
|
-
events: ["ticket.created", "
|
|
208
|
-
read: ["
|
|
207
|
+
events: ["ticket.created", "ticketing:ticket-closed"],
|
|
208
|
+
read: ["ticketing:query:ticket:*"],
|
|
209
209
|
write: [
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"
|
|
210
|
+
"ticketing:write:ticket:create",
|
|
211
|
+
"ticketing:write:ticket:update",
|
|
212
|
+
"ticketing:write:ticket:close",
|
|
213
213
|
],
|
|
214
214
|
},
|
|
215
215
|
},
|
|
@@ -18,7 +18,7 @@ export const ticketEntity = createEntity({
|
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const ticketingFeature = defineFeature("ticketing", (r) => {
|
|
22
22
|
const { table: ticketTable, executor: ticketExecutor } = createEntityExecutor(
|
|
23
23
|
"ticket",
|
|
24
24
|
ticketEntity,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Recipe: helpdesk
|
|
2
|
+
|
|
3
|
+
Public contact form backend. The `helpdesk` bundled feature stores questions, contact
|
|
4
|
+
requests and problem reports from website visitors and notifies every SystemAdmin (mail,
|
|
5
|
+
Telegram only when the app turns it on). The notification names only the kind, the app and a link into the inbox:
|
|
6
|
+
no name, address, phone, subject or message. Telegram is a third party where nothing can be
|
|
7
|
+
shredded or recalled, so it gets the same minimal text. Website senders get a fixed
|
|
8
|
+
acknowledgement that repeats nothing they typed; signed-in admin reports get a copy.
|
|
9
|
+
SystemAdmins reply from the admin. Phone is off and Telegram is not mounted unless the app
|
|
10
|
+
turns them on (`fields.phone`, `telegram: true`).
|
|
11
|
+
|
|
12
|
+
**What the recipe demonstrates:**
|
|
13
|
+
- Mounting `createHelpdeskFeature` with its companions (config, delivery, user-data-rights,
|
|
14
|
+
files, notes-history)
|
|
15
|
+
- The anonymous flow: `helpdesk:query:challenge` hands out a proof-of-work challenge,
|
|
16
|
+
`helpdesk:write:submit` verifies it; spam gets the same 200 body and stores nothing
|
|
17
|
+
- The browser client at `GET /helpdesk/client.js` (`window.KumikoHelpdesk.load()` / `submit()`)
|
|
18
|
+
|
|
19
|
+
## Layout
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
samples/recipes/helpdesk/
|
|
23
|
+
├── package.json
|
|
24
|
+
├── README.md
|
|
25
|
+
└── src/
|
|
26
|
+
├── feature.ts # createHelpdeskFeature options
|
|
27
|
+
└── __tests__/
|
|
28
|
+
└── feature.integration.test.ts # challenge query + client route
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The behavior (submit, silent drops, replies, Telegram, GDPR export and erasure, retention) is
|
|
32
|
+
covered by the integration tests next to the feature in
|
|
33
|
+
`packages/bundled-features/src/helpdesk/__tests__/`.
|
|
34
|
+
|
|
35
|
+
## Run tests
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
bun test --config=bunfig.integration.toml samples/recipes/helpdesk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Integration into a real app
|
|
42
|
+
|
|
43
|
+
1. Mount `createHelpdeskFeature({ appName })` plus delivery, a mail channel, `user-data-rights`,
|
|
44
|
+
`files` with a file provider, `notes-history` and `config`.
|
|
45
|
+
2. Run `kumiko schema generate` (new tables, plus the delivery `idempotency_key` column).
|
|
46
|
+
3. SystemAdmins set `helpdesk:config:reply-to` in the admin.
|
|
47
|
+
4. Embed `/helpdesk/client.js` on the website; the form is yours. The client posts to the
|
|
48
|
+
relative paths `/api/query` and `/api/write` without cookies, so the page has to share the
|
|
49
|
+
app's origin. A website served by another server forwards `/api` to the app on its own
|
|
50
|
+
origin; it can then serve the same script from `HELPDESK_CLIENT_SOURCE` and type its calls
|
|
51
|
+
with `HelpdeskWebsiteClient`, both from `@cosmicdrift/kumiko-bundled-features/helpdesk/client`.
|
|
52
|
+
`samples/apps/use-all-bundled/public/helpdesk-contact.html` (with `helpdesk-contact.js`) is a complete same-origin page.
|
|
53
|
+
|
|
54
|
+
Telegram is optional and off by default: notifications go by mail to SystemAdmins only. An app
|
|
55
|
+
that turns it on (`telegram: true`) also mounts `channel-telegram` and `secrets` for the bot
|
|
56
|
+
token, and SystemAdmins set `helpdesk:config:telegram-chat`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@cosmicdrift/kumiko-sample-
|
|
3
|
-
"description": "Public contact form backend: the
|
|
2
|
+
"name": "@cosmicdrift/kumiko-sample-helpdesk",
|
|
3
|
+
"description": "Public contact form backend: the helpdesk bundled feature with its required companions (delivery, user-data-rights, files) and the anonymous browser client.",
|
|
4
4
|
"private": true,
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@cosmicdrift/kumiko-bundled-features": "workspace:*",
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Helpdesk sample
|
|
2
2
|
//
|
|
3
3
|
// A public website form (question, contact request, problem report) that lands with the
|
|
4
4
|
// SystemAdmins: mail, optional Telegram, a copy to the sender. Spam is handled without a
|
|
5
5
|
// captcha: honeypot field, single-use proof-of-work challenge, minimum submit time, per-IP
|
|
6
6
|
// and per-email rate limits. Rejected submits answer 200 with the normal body.
|
|
7
7
|
//
|
|
8
|
-
// The website embeds the anonymous client the feature serves itself
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// The website embeds the anonymous client the feature serves itself. The client posts to the
|
|
9
|
+
// relative paths /api/query and /api/write, so the page must share its origin with the app
|
|
10
|
+
// (or forward /api to it on its own origin):
|
|
11
|
+
// <script src="/helpdesk/client.js"></script>
|
|
12
|
+
// const { kinds, phone } = await window.KumikoHelpdesk.load();
|
|
13
|
+
// const result = await window.KumikoHelpdesk.submit({ kind, name, email, message, locale });
|
|
12
14
|
// // result.kind: "sent" | "rate-limited" (retryAfterSeconds) | "failed"
|
|
13
15
|
//
|
|
14
16
|
// Prerequisites the app wires itself:
|
|
15
17
|
// - `anonymousAccess` (defaultTenantId = SYSTEM_TENANT_ID) so the form needs no login
|
|
16
18
|
// - delivery with a mail channel (channel-telegram only with `telegram: true`, off by default)
|
|
17
|
-
// -
|
|
19
|
+
// - config, user-data-rights and notes-history (required features)
|
|
20
|
+
// - files with a file provider, because the entities carry file fields
|
|
18
21
|
// - `kumiko schema generate` for the new tables
|
|
19
22
|
|
|
20
|
-
import {
|
|
23
|
+
import { createHelpdeskFeature } from "@cosmicdrift/kumiko-bundled-features/helpdesk";
|
|
21
24
|
|
|
22
|
-
export const
|
|
25
|
+
export const helpdeskFeature = createHelpdeskFeature({
|
|
23
26
|
appName: "Sample App",
|
|
24
27
|
fields: { phone: "optional" },
|
|
25
28
|
// Lowered only to keep the sample test fast; the default (19 bits, 3 seconds) suits production.
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type * as z from "zod";
|
|
2
|
-
import type { ContactSubmitSchema } from "../payloads.ts";
|
|
3
|
-
import type { CONTACT_WEBSITE_KINDS, ContactPhoneMode } from "../web/constants.ts";
|
|
4
|
-
|
|
5
|
-
export type ContactWebsiteKind = (typeof CONTACT_WEBSITE_KINDS)[number];
|
|
6
|
-
|
|
7
|
-
export type ContactWebsiteFormOptions = {
|
|
8
|
-
readonly phone: ContactPhoneMode;
|
|
9
|
-
readonly kinds: readonly ContactWebsiteKind[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// The client adds challenge and nonce itself and falls back to the page language for locale.
|
|
13
|
-
export type ContactWebsiteSubmitFields = Omit<
|
|
14
|
-
z.input<typeof ContactSubmitSchema>,
|
|
15
|
-
"challenge" | "nonce" | "locale"
|
|
16
|
-
> & { readonly locale?: z.input<typeof ContactSubmitSchema>["locale"] };
|
|
17
|
-
|
|
18
|
-
export type ContactWebsiteSubmitResult =
|
|
19
|
-
| { readonly kind: "sent" }
|
|
20
|
-
| { readonly kind: "rate-limited"; readonly retryAfterSeconds?: number }
|
|
21
|
-
| { readonly kind: "failed" };
|
|
22
|
-
|
|
23
|
-
export type ContactWebsiteClient = {
|
|
24
|
-
load(): Promise<ContactWebsiteFormOptions>;
|
|
25
|
-
submit(fields: ContactWebsiteSubmitFields): Promise<ContactWebsiteSubmitResult>;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Registered by CONTACT_CLIENT_SOURCE as window.KumikoContact.
|
|
29
|
-
export type ContactWebsiteWindow = { readonly KumikoContact?: ContactWebsiteClient };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { CONTACT_CLIENT_SOURCE } from "./contact-client-source.ts";
|
|
2
|
-
export type {
|
|
3
|
-
ContactWebsiteClient,
|
|
4
|
-
ContactWebsiteFormOptions,
|
|
5
|
-
ContactWebsiteKind,
|
|
6
|
-
ContactWebsiteSubmitFields,
|
|
7
|
-
ContactWebsiteSubmitResult,
|
|
8
|
-
ContactWebsiteWindow,
|
|
9
|
-
} from "./contact-website-client.ts";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
contactReplyEntity,
|
|
3
|
-
contactReplyTable,
|
|
4
|
-
contactRequestEntity,
|
|
5
|
-
contactRequestTable,
|
|
6
|
-
} from "./entity.ts";
|
|
7
|
-
export { createContactFeature } from "./feature.ts";
|
|
8
|
-
export type { ContactOptions } from "./options.ts";
|
|
9
|
-
export { contactOpenRequestsPanels } from "./panels.ts";
|
|
10
|
-
export {
|
|
11
|
-
CONTACT_ADMIN_KINDS,
|
|
12
|
-
CONTACT_CLIENT_PATH,
|
|
13
|
-
CONTACT_DELIVERY_CHANNEL,
|
|
14
|
-
CONTACT_DELIVERY_STATUS,
|
|
15
|
-
CONTACT_FEATURE,
|
|
16
|
-
CONTACT_FIELD_LIMITS,
|
|
17
|
-
CONTACT_KIND,
|
|
18
|
-
CONTACT_NOTIFICATION_TYPES,
|
|
19
|
-
CONTACT_ORIGIN,
|
|
20
|
-
CONTACT_REPLY_CHANNELS,
|
|
21
|
-
CONTACT_SOURCE,
|
|
22
|
-
CONTACT_STATUS,
|
|
23
|
-
CONTACT_WEBSITE_KINDS,
|
|
24
|
-
ContactConfigKeys,
|
|
25
|
-
ContactErrors,
|
|
26
|
-
ContactHandlers,
|
|
27
|
-
ContactQueries,
|
|
28
|
-
ContactScreens,
|
|
29
|
-
} from "./web/constants.ts";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { DashboardStatPanel } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
-
import {
|
|
3
|
-
CONTACT_FEATURE,
|
|
4
|
-
CONTACT_STATUS,
|
|
5
|
-
ContactQueries,
|
|
6
|
-
ContactScreens,
|
|
7
|
-
} from "./web/constants.ts";
|
|
8
|
-
|
|
9
|
-
// Stat tile for a dashboard: how many contact requests still wait for a first answer.
|
|
10
|
-
export function contactOpenRequestsPanels(): readonly DashboardStatPanel[] {
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
kind: "stat",
|
|
14
|
-
id: `${CONTACT_FEATURE}-open-requests`,
|
|
15
|
-
label: "contact:overview.open",
|
|
16
|
-
query: ContactQueries.requestList,
|
|
17
|
-
params: {
|
|
18
|
-
filters: [{ field: "status", op: "eq", value: CONTACT_STATUS.Open }],
|
|
19
|
-
limit: 1,
|
|
20
|
-
totalCount: true,
|
|
21
|
-
},
|
|
22
|
-
ignoreScreenFilter: true,
|
|
23
|
-
valueField: "total",
|
|
24
|
-
tone: "warn",
|
|
25
|
-
navigate: { screen: ContactScreens.requestList },
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// Pure string constants, safe for browser code (see waitlist/web/constants.ts).
|
|
2
|
-
export const CONTACT_FEATURE = "contact" as const;
|
|
3
|
-
|
|
4
|
-
export const CONTACT_KIND = {
|
|
5
|
-
Question: "question",
|
|
6
|
-
Contact: "contact",
|
|
7
|
-
Bug: "bug",
|
|
8
|
-
Wish: "wish",
|
|
9
|
-
} as const;
|
|
10
|
-
export type ContactKind = (typeof CONTACT_KIND)[keyof typeof CONTACT_KIND];
|
|
11
|
-
|
|
12
|
-
export const CONTACT_WEBSITE_KINDS = [
|
|
13
|
-
CONTACT_KIND.Question,
|
|
14
|
-
CONTACT_KIND.Contact,
|
|
15
|
-
CONTACT_KIND.Bug,
|
|
16
|
-
] as const;
|
|
17
|
-
export const CONTACT_ADMIN_KINDS = [
|
|
18
|
-
CONTACT_KIND.Question,
|
|
19
|
-
CONTACT_KIND.Bug,
|
|
20
|
-
CONTACT_KIND.Wish,
|
|
21
|
-
] as const;
|
|
22
|
-
|
|
23
|
-
export const CONTACT_STATUS = {
|
|
24
|
-
Open: "open",
|
|
25
|
-
Answered: "answered",
|
|
26
|
-
Done: "done",
|
|
27
|
-
} as const;
|
|
28
|
-
export type ContactStatus = (typeof CONTACT_STATUS)[keyof typeof CONTACT_STATUS];
|
|
29
|
-
|
|
30
|
-
export const CONTACT_SOURCE = {
|
|
31
|
-
Website: "website",
|
|
32
|
-
Admin: "admin",
|
|
33
|
-
} as const;
|
|
34
|
-
export type ContactSource = (typeof CONTACT_SOURCE)[keyof typeof CONTACT_SOURCE];
|
|
35
|
-
|
|
36
|
-
export const CONTACT_REPLY_CHANNELS = {
|
|
37
|
-
Email: "email",
|
|
38
|
-
EmailAndInApp: "email+inApp",
|
|
39
|
-
} as const;
|
|
40
|
-
export type ContactReplyChannels =
|
|
41
|
-
(typeof CONTACT_REPLY_CHANNELS)[keyof typeof CONTACT_REPLY_CHANNELS];
|
|
42
|
-
|
|
43
|
-
export const CONTACT_ORIGIN = {
|
|
44
|
-
Website: "website",
|
|
45
|
-
AdminReport: "admin-report",
|
|
46
|
-
} as const;
|
|
47
|
-
export type ContactOrigin = (typeof CONTACT_ORIGIN)[keyof typeof CONTACT_ORIGIN];
|
|
48
|
-
|
|
49
|
-
export const CONTACT_DELIVERY_CHANNEL = {
|
|
50
|
-
Email: "email",
|
|
51
|
-
Telegram: "telegram",
|
|
52
|
-
ReplyEmail: "reply-email",
|
|
53
|
-
ReplyInApp: "reply-in-app",
|
|
54
|
-
} as const;
|
|
55
|
-
export type ContactDeliveryChannel =
|
|
56
|
-
(typeof CONTACT_DELIVERY_CHANNEL)[keyof typeof CONTACT_DELIVERY_CHANNEL];
|
|
57
|
-
|
|
58
|
-
export const CONTACT_DELIVERY_STATUS = {
|
|
59
|
-
Pending: "pending",
|
|
60
|
-
Delivered: "delivered",
|
|
61
|
-
Failed: "failed",
|
|
62
|
-
Skipped: "skipped",
|
|
63
|
-
Read: "read",
|
|
64
|
-
} as const;
|
|
65
|
-
export type ContactDeliveryStatus =
|
|
66
|
-
(typeof CONTACT_DELIVERY_STATUS)[keyof typeof CONTACT_DELIVERY_STATUS];
|
|
67
|
-
|
|
68
|
-
export type ContactPhoneMode = "off" | "optional" | "required";
|
|
69
|
-
|
|
70
|
-
export const ContactHandlers = {
|
|
71
|
-
submit: "contact:write:submit",
|
|
72
|
-
report: "contact:write:report",
|
|
73
|
-
reply: "contact:write:reply",
|
|
74
|
-
markDone: "contact:write:mark-done",
|
|
75
|
-
sendTest: "contact:write:send-test",
|
|
76
|
-
forwardRequest: "contact:write:forward-request",
|
|
77
|
-
sendReplyMail: "contact:write:send-reply-mail",
|
|
78
|
-
notifyReporterInApp: "contact:write:notify-reporter-in-app",
|
|
79
|
-
} as const;
|
|
80
|
-
|
|
81
|
-
export const ContactQueries = {
|
|
82
|
-
challenge: "contact:query:challenge",
|
|
83
|
-
openCount: "contact:query:open-count",
|
|
84
|
-
requestDetail: "contact:query:request-detail",
|
|
85
|
-
replies: "contact:query:replies",
|
|
86
|
-
requestDelivery: "contact:query:request-delivery",
|
|
87
|
-
// Entity-convention list QN: entityList screens resolve their query by this shape.
|
|
88
|
-
requestList: "contact:query:contact-request:list",
|
|
89
|
-
} as const;
|
|
90
|
-
|
|
91
|
-
export const ContactScreens = {
|
|
92
|
-
requestList: "contact:screen:request-list",
|
|
93
|
-
requestDetail: "contact:screen:request-detail",
|
|
94
|
-
report: "contact:screen:report",
|
|
95
|
-
reply: "contact:screen:reply",
|
|
96
|
-
replyMail: "contact:screen:reply-mail",
|
|
97
|
-
forwarding: "contact: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 CONTACT_UPLOAD_FIELD = "fileIds" as const;
|
|
102
|
-
|
|
103
|
-
export const ContactConfigKeys = {
|
|
104
|
-
replyTo: "contact:config:reply-to",
|
|
105
|
-
telegramChat: "contact:config:telegram-chat",
|
|
106
|
-
} as const;
|
|
107
|
-
|
|
108
|
-
export const ContactErrors = {
|
|
109
|
-
telegramChatMissing: "telegram_chat_missing",
|
|
110
|
-
telegramTestFailed: "telegram_test_failed",
|
|
111
|
-
notFound: "contact_request_not_found",
|
|
112
|
-
phoneNotAllowed: "contact_phone_not_allowed",
|
|
113
|
-
phoneRequired: "contact_phone_required",
|
|
114
|
-
reporterEmailMissing: "contact_reporter_email_missing",
|
|
115
|
-
attachmentNotFound: "contact_attachment_not_found",
|
|
116
|
-
} as const;
|
|
117
|
-
|
|
118
|
-
export const CONTACT_NOTIFICATION_TYPES = {
|
|
119
|
-
newRequest: "contact:notify:new-request",
|
|
120
|
-
confirmation: "contact:notify:confirmation",
|
|
121
|
-
acknowledgement: "contact:notify:acknowledgement",
|
|
122
|
-
reply: "contact:notify:reply",
|
|
123
|
-
replyInApp: "contact:notify:reply-in-app",
|
|
124
|
-
test: "contact:notify:test",
|
|
125
|
-
} as const;
|
|
126
|
-
|
|
127
|
-
export const CONTACT_CLIENT_PATH = "/contact/client.js" as const;
|
|
128
|
-
|
|
129
|
-
export const CONTACT_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 CONTACT_MAX_FILES = 5;
|
|
143
|
-
|
|
144
|
-
export const CONTACT_SUBJECT_MAX_CHARS = 80;
|
|
145
|
-
|
|
146
|
-
export const CONTACT_POW_BITS = { min: 8, max: 26, default: 19 } as const;
|
|
147
|
-
export const CONTACT_DEFAULT_MIN_SUBMIT_SECONDS = 3;
|
|
148
|
-
export const CONTACT_DEFAULT_CHALLENGE_TTL_MINUTES = 30;
|
|
149
|
-
export const CONTACT_CHALLENGE_REDIS_PREFIX = "contact:challenge:" as const;
|
|
150
|
-
|
|
151
|
-
export const CONTACT_REQUEST_ENTITY = "contact-request" as const;
|
|
152
|
-
export const CONTACT_REPLY_ENTITY = "contact-reply" as const;
|
|
153
|
-
|
|
154
|
-
export const contactIdempotencyKeys = {
|
|
155
|
-
admins: (requestId: string) => `contact:request:${requestId}:admins`,
|
|
156
|
-
telegram: (requestId: string) => `contact:request:${requestId}:telegram`,
|
|
157
|
-
confirmation: (requestId: string) => `contact:request:${requestId}:confirmation`,
|
|
158
|
-
reply: (replyId: string) => `contact:reply:${replyId}`,
|
|
159
|
-
replyInApp: (replyId: string) => `contact:reply:${replyId}:in-app`,
|
|
160
|
-
} as const;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
CONTACT_ADMIN_KINDS,
|
|
3
|
-
CONTACT_CLIENT_PATH,
|
|
4
|
-
CONTACT_DELIVERY_CHANNEL,
|
|
5
|
-
CONTACT_DELIVERY_STATUS,
|
|
6
|
-
CONTACT_FEATURE,
|
|
7
|
-
CONTACT_FIELD_LIMITS,
|
|
8
|
-
CONTACT_KIND,
|
|
9
|
-
CONTACT_NOTIFICATION_TYPES,
|
|
10
|
-
CONTACT_ORIGIN,
|
|
11
|
-
CONTACT_REPLY_CHANNELS,
|
|
12
|
-
CONTACT_SOURCE,
|
|
13
|
-
CONTACT_STATUS,
|
|
14
|
-
CONTACT_SUBJECT_MAX_CHARS,
|
|
15
|
-
CONTACT_WEBSITE_KINDS,
|
|
16
|
-
ContactConfigKeys,
|
|
17
|
-
type ContactDeliveryChannel,
|
|
18
|
-
type ContactDeliveryStatus,
|
|
19
|
-
ContactErrors,
|
|
20
|
-
ContactHandlers,
|
|
21
|
-
type ContactKind,
|
|
22
|
-
type ContactOrigin,
|
|
23
|
-
type ContactPhoneMode,
|
|
24
|
-
ContactQueries,
|
|
25
|
-
type ContactReplyChannels,
|
|
26
|
-
ContactScreens,
|
|
27
|
-
type ContactSource,
|
|
28
|
-
type ContactStatus,
|
|
29
|
-
} from "./constants.ts";
|