@blogmcp/sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consultations/channel-text.d.ts +118 -0
- package/dist/consultations/channel-text.js +40 -0
- package/dist/consultations/index.d.ts +28 -0
- package/dist/consultations/index.js +60 -0
- package/dist/consultations/messages.cs.d.ts +149 -0
- package/dist/consultations/messages.cs.js +143 -0
- package/dist/consultations/messages.d.ts +34 -0
- package/dist/consultations/messages.en.d.ts +143 -0
- package/dist/consultations/messages.en.js +141 -0
- package/dist/consultations/messages.js +48 -0
- package/dist/consultations/outcome.d.ts +121 -0
- package/dist/consultations/outcome.js +161 -0
- package/dist/consultations/public-config.d.ts +71 -0
- package/dist/consultations/public-config.js +104 -0
- package/dist/consultations/reader.d.ts +83 -0
- package/dist/consultations/reader.js +128 -0
- package/dist/consultations/routes.d.ts +214 -0
- package/dist/consultations/routes.js +149 -0
- package/dist/consultations/server/client-ip.d.ts +50 -0
- package/dist/consultations/server/client-ip.js +44 -0
- package/dist/consultations/server/contact.d.ts +23 -0
- package/dist/consultations/server/contact.js +138 -0
- package/dist/consultations/server/context.d.ts +246 -0
- package/dist/consultations/server/context.js +152 -0
- package/dist/consultations/server/cookie.d.ts +60 -0
- package/dist/consultations/server/cookie.js +57 -0
- package/dist/consultations/server/env.d.ts +20 -0
- package/dist/consultations/server/env.js +35 -0
- package/dist/consultations/server/http.d.ts +59 -0
- package/dist/consultations/server/http.js +64 -0
- package/dist/consultations/server/index.d.ts +37 -0
- package/dist/consultations/server/index.js +19 -0
- package/dist/consultations/server/origin.d.ts +39 -0
- package/dist/consultations/server/origin.js +31 -0
- package/dist/consultations/server/server.d.ts +106 -0
- package/dist/consultations/server/server.js +122 -0
- package/dist/consultations/server/session.d.ts +38 -0
- package/dist/consultations/server/session.js +210 -0
- package/dist/consultations/server/transport.d.ts +69 -0
- package/dist/consultations/server/transport.js +117 -0
- package/dist/consultations/server/turnstile.d.ts +44 -0
- package/dist/consultations/server/turnstile.js +31 -0
- package/dist/consultations/site.d.ts +100 -0
- package/dist/consultations/site.js +60 -0
- package/dist/consultations/submit-new.d.ts +103 -0
- package/dist/consultations/submit-new.js +72 -0
- package/dist/core/auth.d.ts +2 -2
- package/dist/core/client.d.ts +25 -4
- package/dist/core/client.js +35 -30
- package/dist/core/consultation-adapter.d.ts +2 -2
- package/dist/core/consultations.d.ts +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.js +16 -15
- package/dist/core/index.d.ts +31 -31
- package/dist/core/index.js +35 -34
- package/dist/core/markdown.d.ts +1 -1
- package/dist/core/queries.d.ts +4 -1
- package/dist/core/queries.js +131 -86
- package/dist/core/review/format.d.ts +1 -1
- package/dist/core/review/index.d.ts +2 -2
- package/dist/core/seo.d.ts +1 -1
- package/dist/core/translations/cs.json.js +1 -1
- package/dist/core/translations/en.json.js +1 -1
- package/dist/core/types.d.ts +50 -1
- package/dist/core/view-model.d.ts +12 -2
- package/dist/core/view-model.js +40 -34
- package/dist/{packages/tripmap-core/node_modules → node_modules}/pmtiles/dist/esm/index.js +1 -1
- package/dist/nuxt/composables/useAsyncKb.d.ts +4 -4
- package/dist/nuxt/index.d.ts +1 -1
- package/dist/packages/mdx-render-vue/dist/composables/useGallery.js +12 -11
- package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +16 -16
- package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +1 -1
- package/dist/packages/mdx-render-vue/dist/registry.js +21 -22
- package/dist/packages/mdx-render-vue/dist/render/alert/Alert.vue2.js +1 -1
- package/dist/packages/mdx-render-vue/dist/render/badge/Badge.vue2.js +1 -1
- package/dist/packages/mdx-render-vue/dist/render/button/Button.vue2.js +1 -1
- package/dist/packages/mdx-render-vue/dist/render/callout/CalloutDefault.vue.js +1 -1
- package/dist/packages/mdx-render-vue/dist/render/callout/CalloutMinimal.vue.js +1 -1
- package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +2 -2
- package/dist/packages/tripmap-core/dist/engine.js +3 -3
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
- package/dist/react/KbMdxContent.d.ts +1 -1
- package/dist/react/KbMdxContent.js +7 -8
- package/dist/react/context.d.ts +4 -4
- package/dist/react/hooks/useImageRenderer.d.ts +1 -1
- package/dist/react/hooks/useKbClient.d.ts +1 -1
- package/dist/react/hooks/useKbContext.d.ts +1 -1
- package/dist/react/hooks/useKbI18n.d.ts +1 -1
- package/dist/react/hooks/useKbLanguage.d.ts +1 -1
- package/dist/react/hooks/useKbSearch.d.ts +1 -1
- package/dist/react/hooks/useMdxContent.d.ts +1 -1
- package/dist/react/index.d.ts +15 -15
- package/dist/react/provider.d.ts +2 -2
- package/dist/react/server/index.d.ts +2 -2
- package/dist/vue/components/KbAccessGate.vue.d.ts +4 -1
- package/dist/vue/components/KbAccessGate.vue.js +42 -32
- package/dist/vue/components/KbArticleCard.vue.d.ts +3 -1
- package/dist/vue/components/KbArticleCard.vue.js +67 -39
- package/dist/vue/components/KbMdxContent.vue2.js +6 -7
- package/dist/vue/composables/useArticles.d.ts +1 -1
- package/dist/vue/composables/useImageRenderer.d.ts +1 -1
- package/dist/vue/composables/useKbAuth.d.ts +1 -1
- package/dist/vue/composables/useKbClient.d.ts +1 -1
- package/dist/vue/composables/useKbComments.d.ts +1 -1
- package/dist/vue/composables/useKbI18n.d.ts +1 -1
- package/dist/vue/composables/useKbLanguage.d.ts +1 -1
- package/dist/vue/composables/useNavigation.d.ts +1 -1
- package/dist/vue/composables/useSearch.d.ts +1 -1
- package/dist/vue/composables/useTags.d.ts +1 -1
- package/dist/vue/index.d.ts +19 -19
- package/dist/vue/plugin.d.ts +4 -4
- package/package.json +15 -5
- package/src/consultations/channel-text.ts +168 -0
- package/src/consultations/index.ts +87 -0
- package/src/consultations/messages.cs.ts +175 -0
- package/src/consultations/messages.en.ts +171 -0
- package/src/consultations/messages.ts +91 -0
- package/src/consultations/outcome.ts +278 -0
- package/src/consultations/public-config.ts +246 -0
- package/src/consultations/reader.ts +281 -0
- package/src/consultations/routes.ts +341 -0
- package/src/consultations/server/client-ip.ts +106 -0
- package/src/consultations/server/contact.ts +267 -0
- package/src/consultations/server/context.ts +403 -0
- package/src/consultations/server/cookie.ts +129 -0
- package/src/consultations/server/env.ts +66 -0
- package/src/consultations/server/http.ts +148 -0
- package/src/consultations/server/index.ts +55 -0
- package/src/consultations/server/origin.ts +71 -0
- package/src/consultations/server/server.ts +322 -0
- package/src/consultations/server/session.ts +414 -0
- package/src/consultations/server/transport.ts +196 -0
- package/src/consultations/server/turnstile.ts +98 -0
- package/src/consultations/site.ts +183 -0
- package/src/consultations/submit-new.ts +266 -0
- package/src/core/auth.ts +1 -1
- package/src/core/client.ts +32 -1
- package/src/core/errors.ts +5 -2
- package/src/core/index.ts +3 -0
- package/src/core/queries.ts +56 -0
- package/src/core/translations/cs.json +2 -1
- package/src/core/translations/en.json +2 -1
- package/src/core/types.ts +51 -0
- package/src/core/view-model.ts +18 -0
- package/src/vue/components/KbAccessGate.vue +14 -1
- package/src/vue/components/KbArticleCard.vue +25 -0
- package/dist/_virtual/constants.js +0 -4
- package/dist/_virtual/index.js +0 -2
- package/dist/_virtual/index2.js +0 -4
- package/dist/_virtual/index3.js +0 -2
- package/dist/_virtual/re.js +0 -4
- package/dist/node_modules/@braintree/sanitize-url/dist/constants.js +0 -8
- package/dist/node_modules/@braintree/sanitize-url/dist/index.js +0 -60
- package/dist/node_modules/dompurify/dist/purify.es.js +0 -662
- package/dist/node_modules/semver/classes/comparator.js +0 -56
- package/dist/node_modules/semver/classes/range.js +0 -148
- package/dist/node_modules/semver/classes/semver.js +0 -169
- package/dist/node_modules/semver/functions/clean.js +0 -14
- package/dist/node_modules/semver/functions/cmp.js +0 -39
- package/dist/node_modules/semver/functions/coerce.js +0 -33
- package/dist/node_modules/semver/functions/compare-build.js +0 -14
- package/dist/node_modules/semver/functions/compare-loose.js +0 -11
- package/dist/node_modules/semver/functions/compare.js +0 -11
- package/dist/node_modules/semver/functions/diff.js +0 -24
- package/dist/node_modules/semver/functions/eq.js +0 -11
- package/dist/node_modules/semver/functions/gt.js +0 -11
- package/dist/node_modules/semver/functions/gte.js +0 -11
- package/dist/node_modules/semver/functions/inc.js +0 -21
- package/dist/node_modules/semver/functions/lt.js +0 -11
- package/dist/node_modules/semver/functions/lte.js +0 -11
- package/dist/node_modules/semver/functions/major.js +0 -11
- package/dist/node_modules/semver/functions/minor.js +0 -11
- package/dist/node_modules/semver/functions/neq.js +0 -11
- package/dist/node_modules/semver/functions/parse.js +0 -21
- package/dist/node_modules/semver/functions/patch.js +0 -11
- package/dist/node_modules/semver/functions/prerelease.js +0 -14
- package/dist/node_modules/semver/functions/rcompare.js +0 -11
- package/dist/node_modules/semver/functions/rsort.js +0 -11
- package/dist/node_modules/semver/functions/satisfies.js +0 -18
- package/dist/node_modules/semver/functions/sort.js +0 -11
- package/dist/node_modules/semver/functions/valid.js +0 -14
- package/dist/node_modules/semver/index.js +0 -97
- package/dist/node_modules/semver/internal/constants.js +0 -28
- package/dist/node_modules/semver/internal/debug.js +0 -8
- package/dist/node_modules/semver/internal/identifiers.js +0 -18
- package/dist/node_modules/semver/internal/lrucache.js +0 -32
- package/dist/node_modules/semver/internal/parse-options.js +0 -10
- package/dist/node_modules/semver/internal/re.js +0 -32
- package/dist/node_modules/semver/ranges/gtr.js +0 -11
- package/dist/node_modules/semver/ranges/intersects.js +0 -11
- package/dist/node_modules/semver/ranges/ltr.js +0 -11
- package/dist/node_modules/semver/ranges/max-satisfying.js +0 -22
- package/dist/node_modules/semver/ranges/min-satisfying.js +0 -22
- package/dist/node_modules/semver/ranges/min-version.js +0 -42
- package/dist/node_modules/semver/ranges/outside.js +0 -44
- package/dist/node_modules/semver/ranges/simplify.js +0 -24
- package/dist/node_modules/semver/ranges/subset.js +0 -94
- package/dist/node_modules/semver/ranges/to-comparators.js +0 -11
- package/dist/node_modules/semver/ranges/valid.js +0 -17
- package/dist/packages/mdx-schema/dist/composables/useMdxParsing.js +0 -389
- package/dist/packages/mdx-schema/dist/metadata/index.js +0 -526
- package/dist/packages/mdx-schema/dist/prepareProps.js +0 -46
- package/dist/packages/mdx-schema/dist/styles/index.js +0 -147
- package/dist/packages/mdx-schema/dist/tripmap.js +0 -101
- package/dist/packages/mdx-schema/dist/types/index.js +0 -26
- package/dist/packages/sanitize/dist/html.js +0 -89
- /package/dist/{packages/tripmap-core/node_modules → node_modules}/maplibre-gl/dist/maplibre-gl-shared.js +0 -0
- /package/dist/{packages/tripmap-core/node_modules → node_modules}/maplibre-gl/dist/maplibre-gl.js +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { CONSULTATION_MESSAGES_CS } from './messages.cs'
|
|
2
|
+
|
|
3
|
+
/** English has only the `_one` / `_other` plural forms; every other key is the Czech catalogue's. */
|
|
4
|
+
type EnglishKey = Exclude<keyof typeof CONSULTATION_MESSAGES_CS, `${string}_few` | `${string}_many`>
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* English texts of the reader consultation pages — the same keys and the
|
|
8
|
+
* same rules as the Czech ones (messages.cs.ts). Plurals follow
|
|
9
|
+
* `Intl.PluralRules('en')`: `_one`, `_other`.
|
|
10
|
+
*/
|
|
11
|
+
export const CONSULTATION_MESSAGES_EN = {
|
|
12
|
+
'error.method': "This can't be started this way. Please go back to your question.",
|
|
13
|
+
'error.origin': "This request didn't come from this page. Please reload it and try again.",
|
|
14
|
+
'error.disabled': "Questions aren't available here right now.",
|
|
15
|
+
'error.auth': 'Please sign in and try again.',
|
|
16
|
+
'error.unavailable': "We couldn't load or save that just now. Please try again in a little while.",
|
|
17
|
+
'error.invalid': "Something in the form isn't right. Please check it and try again.",
|
|
18
|
+
'error.consent': 'To send your question, please tick the consent box under the text.',
|
|
19
|
+
'error.tooLong': 'That message is too long. Please shorten it.',
|
|
20
|
+
'error.quota': "That's a lot in a short time — please try again in a little while.",
|
|
21
|
+
'error.captcha': "We couldn't check that you're not a robot. Please wait for a new check and send it again.",
|
|
22
|
+
'error.notFound': "We couldn't find this question.",
|
|
23
|
+
'error.expired': 'This link or your access to the question has expired.',
|
|
24
|
+
'error.closed': "This question is closed; it can't be answered any more.",
|
|
25
|
+
'error.mismatch': 'A question can only be moved to an account with the same e-mail address it came from.',
|
|
26
|
+
'error.conflict':
|
|
27
|
+
"We've most likely got this already — only the confirmation didn't reach you. Please reload the page and check before sending it again.",
|
|
28
|
+
'error.submit': "That didn't work. Please reload the page and try again.",
|
|
29
|
+
|
|
30
|
+
'status.OPEN': 'Waiting for a reply',
|
|
31
|
+
'status.ANSWERED': 'Answered',
|
|
32
|
+
'status.CLOSED': 'Closed',
|
|
33
|
+
'status.ERASURE_REQUESTED': 'Waiting to be deleted',
|
|
34
|
+
|
|
35
|
+
'thread.you': 'You',
|
|
36
|
+
'thread.team': 'Our team',
|
|
37
|
+
'thread.created': 'Asked on {date}',
|
|
38
|
+
'thread.replyLabel': 'Your reply',
|
|
39
|
+
'thread.replySubmit': 'Send reply',
|
|
40
|
+
'thread.replySending': 'Sending…',
|
|
41
|
+
'thread.counter': '{length} / {max} characters',
|
|
42
|
+
'thread.posted': "We've got your reply.",
|
|
43
|
+
'thread.cannotReply': "This question can't be answered any more.",
|
|
44
|
+
'thread.erase': 'Delete question',
|
|
45
|
+
'thread.eraseTitle': 'Delete this question?',
|
|
46
|
+
'thread.eraseExplain':
|
|
47
|
+
"The question closes right away and can't be answered any more. After a grace period we delete it along with the replies, unless the law requires us to keep it.",
|
|
48
|
+
'thread.eraseKeepsConsent': "This doesn't withdraw your consent — you can do that in My questions.",
|
|
49
|
+
'thread.eraseConfirm': 'Yes, delete it',
|
|
50
|
+
'thread.eraseCancel': 'Keep it',
|
|
51
|
+
'thread.erasureRequestedTitle': 'Waiting to be deleted',
|
|
52
|
+
'thread.erasureRequestedBody':
|
|
53
|
+
'The question is closed. After a grace period we delete it along with the replies, unless the law requires us to keep it.',
|
|
54
|
+
|
|
55
|
+
'open.title': 'Your question',
|
|
56
|
+
'open.reading': 'Loading…',
|
|
57
|
+
'open.lede': 'Use the button below to see your question and our reply.',
|
|
58
|
+
'open.show': 'Show my question',
|
|
59
|
+
'open.opening': 'Opening…',
|
|
60
|
+
'open.invalidTitle': 'This link no longer works',
|
|
61
|
+
'open.invalidBody': "It may have expired or already been used. We'll send you a new one.",
|
|
62
|
+
'open.missingBody': 'The link is missing its access code. Please open the whole link from the e-mail, or ask for a new one.',
|
|
63
|
+
|
|
64
|
+
'session.title': 'Your question',
|
|
65
|
+
'session.lede': 'Here are your question and our reply. This page is just for you and signs you out after a while.',
|
|
66
|
+
'session.noneBody':
|
|
67
|
+
"You open a question with the link from the e-mail that came with our reply. If you don't have it or it has expired, we'll send you a new one.",
|
|
68
|
+
'session.expiredTitle': 'Your access has expired',
|
|
69
|
+
'session.expiredBody': "The link or your access is no longer valid. We'll send you a new link.",
|
|
70
|
+
'session.requestLink': 'Send me a new link',
|
|
71
|
+
'session.logout': 'Sign out',
|
|
72
|
+
'session.loggedOut': "You're signed out. Open the question again with the link from the e-mail.",
|
|
73
|
+
'session.attachTitle': 'Move to your account',
|
|
74
|
+
'session.attachExplain':
|
|
75
|
+
"You're signed in, so you can move this question to My questions. This only works for an account with the same e-mail address you wrote from. The link from the e-mail then stops working.",
|
|
76
|
+
'session.attach': 'Move to my account',
|
|
77
|
+
'session.attachedTitle': 'The question is in your account',
|
|
78
|
+
'session.attachedBody': "You'll find it in My questions. The link from the e-mail no longer works.",
|
|
79
|
+
'session.attachedLink': 'Open My questions',
|
|
80
|
+
'session.erasedTitle': "We've closed your question",
|
|
81
|
+
'session.erasedBody':
|
|
82
|
+
"It can't be answered any more. After a grace period we delete it along with the replies, unless the law requires us to keep it.",
|
|
83
|
+
|
|
84
|
+
'newLink.title': 'A new link to your question',
|
|
85
|
+
'newLink.lede':
|
|
86
|
+
"Enter the e-mail address you wrote to us from. If we have an answered question for it, we'll send a new link there.",
|
|
87
|
+
'newLink.email': 'E-mail',
|
|
88
|
+
'newLink.emailInvalid': "That doesn't look like an e-mail address.",
|
|
89
|
+
'newLink.honeypot': 'Leave this field empty',
|
|
90
|
+
'newLink.submit': 'Send link',
|
|
91
|
+
'newLink.sending': 'Sending…',
|
|
92
|
+
'newLink.done': "If we have an answered question for that address, we've sent a new link to it.",
|
|
93
|
+
|
|
94
|
+
'account.title': 'My questions',
|
|
95
|
+
'account.empty': 'No questions yet',
|
|
96
|
+
'account.emptyBody': 'Questions you send us show up here, together with our reply.',
|
|
97
|
+
'account.emptyBodyAsk': "Ask us here — you'll find our reply on this page.",
|
|
98
|
+
'account.created': 'Question from {date}',
|
|
99
|
+
'account.summary': 'Messages: {count} · last {date}',
|
|
100
|
+
'account.back': '← My questions',
|
|
101
|
+
'account.ask': 'Ask a new question',
|
|
102
|
+
'account.consentGiven': 'Consent given on {date}',
|
|
103
|
+
'account.consentGivenNoDate': 'Consent given',
|
|
104
|
+
'account.consentWithdraw': 'Withdraw consent',
|
|
105
|
+
'account.consentWithdrawTitle': 'Withdraw your consent?',
|
|
106
|
+
'account.consentWithdrawExplain':
|
|
107
|
+
"We close the questions you asked with your consent right away, and they can't be answered any more. After a grace period we delete them along with the replies, unless the law requires us to keep them. Questions without consent (for example from the contact form) stay — you can delete each of them yourself. If you ask us here again, we'll ask for your consent again.",
|
|
108
|
+
'account.consentWithdrawConfirm': 'Yes, withdraw it',
|
|
109
|
+
'account.consentWithdrawCancel': 'Keep my consent',
|
|
110
|
+
'account.consentWithdrawing': 'Withdrawing…',
|
|
111
|
+
'account.consentWithdrawFailed': "We couldn't withdraw your consent just now. Please try again in a little while.",
|
|
112
|
+
'account.consentWithdrawnTitle': "You've withdrawn your consent",
|
|
113
|
+
'account.consentWithdrawnClosed_one':
|
|
114
|
+
"We've closed {count} question you asked with your consent. After a grace period we delete it along with the replies, unless the law requires us to keep it.",
|
|
115
|
+
'account.consentWithdrawnClosed_other':
|
|
116
|
+
"We've closed {count} questions you asked with your consent. After a grace period we delete them along with the replies, unless the law requires us to keep them.",
|
|
117
|
+
'account.consentWithdrawnNone': 'You had no open question asked with your consent, so nothing was closed.',
|
|
118
|
+
'account.consentWithdrawnNext': "If you ask us here again, we'll ask for your consent again.",
|
|
119
|
+
'account.consentAlreadyWithdrawn': "You no longer have a valid consent — you've probably withdrawn it in another window.",
|
|
120
|
+
|
|
121
|
+
'ask.title': 'New question',
|
|
122
|
+
'ask.lede': "Tell us what you'd like to ask. You'll find our reply here in My questions.",
|
|
123
|
+
'ask.bodyLabel': 'Your question',
|
|
124
|
+
'ask.counter': '{length} / {max} characters',
|
|
125
|
+
'ask.tooLong': 'Your question is too long. Please shorten it to {max} characters at most.',
|
|
126
|
+
'ask.quota': "That's a lot of new questions at once. You can ask another one later, or add it to one of your questions in My questions.",
|
|
127
|
+
'ask.conflict':
|
|
128
|
+
"We've most likely got this question already — only the confirmation didn't reach you. Please check My questions. If it isn't there, send it again.",
|
|
129
|
+
'ask.openList': 'Open My questions',
|
|
130
|
+
'ask.consentLabel': 'I agree to the processing described above.',
|
|
131
|
+
'ask.consentOnce':
|
|
132
|
+
'You give your consent once: it covers your further questions too, until you withdraw it in My questions or we ask you for a new one.',
|
|
133
|
+
'ask.consentRenew':
|
|
134
|
+
'The consent text has changed, so we are asking for your consent again. It will cover your further questions too, until you withdraw it or we ask you for a new one.',
|
|
135
|
+
'ask.consentGiven': 'You gave your consent on {date}; it holds until you withdraw it or we ask you for a new one.',
|
|
136
|
+
'ask.consentGivenNoDate': "You've already given your consent; it holds until you withdraw it or we ask you for a new one.",
|
|
137
|
+
'ask.consentUnknown': "We can't check right now whether your consent still holds.",
|
|
138
|
+
'ask.textChanged': "We've updated the text about processing in the meantime. Please read the new version and send your question again.",
|
|
139
|
+
'ask.consentNeeded': 'Your earlier consent is no longer valid. Please read the text above and give it again to send your question.',
|
|
140
|
+
'ask.answerHint': "You'll find our reply here in My questions.",
|
|
141
|
+
'ask.answerHintEmail': "When we reply, we'll e-mail you a link.",
|
|
142
|
+
'ask.submit': 'Send question',
|
|
143
|
+
'ask.sending': 'Sending…',
|
|
144
|
+
'ask.unavailableTitle': "You can't ask a new question right now",
|
|
145
|
+
'ask.unavailableBody': 'Please try again in a little while.',
|
|
146
|
+
'ask.draftLabel': 'Your unsent question',
|
|
147
|
+
'ask.draftHint': "It can't be saved right now. Copy it so you don't lose it, and send it once this works again.",
|
|
148
|
+
'ask.privacyLink': 'How we handle personal data',
|
|
149
|
+
|
|
150
|
+
'contact.title': 'Write to us',
|
|
151
|
+
'contact.lede': "Tell us what you'd like to ask.",
|
|
152
|
+
'contact.name': 'Name (optional)',
|
|
153
|
+
'contact.email': 'E-mail',
|
|
154
|
+
'contact.emailHint': "We'll send the link to our reply here.",
|
|
155
|
+
'contact.message': 'Message',
|
|
156
|
+
'contact.counter': '{length} / {max} characters',
|
|
157
|
+
'contact.consentLabel': 'I agree to the processing described above.',
|
|
158
|
+
'contact.submit': 'Send',
|
|
159
|
+
'contact.sending': 'Sending…',
|
|
160
|
+
'contact.done': "Thanks, we've got your question. We'll email you a link when we reply.",
|
|
161
|
+
'contact.honeypot': 'Leave this field empty',
|
|
162
|
+
'contact.captchaUnavailable':
|
|
163
|
+
"The anti-robot check didn't load (a browser extension may be blocking it), so the form can't be sent right now. Please try reloading the page.",
|
|
164
|
+
'contact.textChanged': "We've updated the text about processing in the meantime. Please read the new version and send your message again.",
|
|
165
|
+
'contact.emailInvalid': "That doesn't look like an e-mail address.",
|
|
166
|
+
'contact.nameTooLong': 'That name is too long ({max} characters at most).',
|
|
167
|
+
'contact.messageTooLong': 'That message is too long ({max} characters at most).',
|
|
168
|
+
|
|
169
|
+
'common.signIn': 'Sign in',
|
|
170
|
+
'common.needsJs': 'This page needs JavaScript. Please turn it on and reload the page.',
|
|
171
|
+
} as const satisfies Record<EnglishKey, string>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reader consultation pages' texts in Czech and English, and one function
|
|
3
|
+
* to get one.
|
|
4
|
+
*
|
|
5
|
+
* `consultationMessage(locale, key, params)`: `{name}` placeholders are filled
|
|
6
|
+
* from `params` (as in the SDK's `createKbI18n`); a plural key picks its form
|
|
7
|
+
* with `Intl.PluralRules` from `params.count` (`account.consentWithdrawnClosed`
|
|
8
|
+
* → `…_one`, `…_few`, `…_other`); a locale other than Czech gets English.
|
|
9
|
+
*
|
|
10
|
+
* The flat catalogues (`CONSULTATION_MESSAGES`) use i18next's plural suffixes,
|
|
11
|
+
* so a blog can also merge them into its own i18n. The error texts are keyed
|
|
12
|
+
* by the reader code: `error.<ConsultationUiCode>`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { CONSULTATION_MESSAGES_CS } from './messages.cs'
|
|
16
|
+
import { CONSULTATION_MESSAGES_EN } from './messages.en'
|
|
17
|
+
|
|
18
|
+
type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'
|
|
19
|
+
type BaseKey<K extends string> = K extends `${infer Base}_${PluralCategory}` ? Base : K
|
|
20
|
+
|
|
21
|
+
/** A message key; a plural message is named without its suffix (`account.consentWithdrawnClosed`). */
|
|
22
|
+
export type ConsultationMessageKey = BaseKey<keyof typeof CONSULTATION_MESSAGES_CS & string>
|
|
23
|
+
|
|
24
|
+
/** The languages with a catalogue. */
|
|
25
|
+
export type ConsultationMessageLanguage = 'cs' | 'en'
|
|
26
|
+
|
|
27
|
+
/** Both catalogues, flat (`'thread.team'`, `'account.consentWithdrawnClosed_few'`, …). */
|
|
28
|
+
export const CONSULTATION_MESSAGES: Readonly<{
|
|
29
|
+
cs: typeof CONSULTATION_MESSAGES_CS
|
|
30
|
+
en: typeof CONSULTATION_MESSAGES_EN
|
|
31
|
+
}> = Object.freeze({
|
|
32
|
+
cs: Object.freeze(CONSULTATION_MESSAGES_CS),
|
|
33
|
+
en: Object.freeze(CONSULTATION_MESSAGES_EN),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
/** The catalogue a locale reads: Czech for `cs` / `cs-CZ`, English for everything else. */
|
|
37
|
+
export function consultationMessageLanguage(locale: string): ConsultationMessageLanguage {
|
|
38
|
+
const language = typeof locale === 'string' ? locale.toLowerCase().split('-')[0] : ''
|
|
39
|
+
return language === 'cs' ? 'cs' : 'en'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const pluralRules = new Map<ConsultationMessageLanguage, Intl.PluralRules | null>()
|
|
43
|
+
|
|
44
|
+
function pluralCategory(language: ConsultationMessageLanguage, count: number): string {
|
|
45
|
+
if (!pluralRules.has(language)) {
|
|
46
|
+
let rules: Intl.PluralRules | null = null
|
|
47
|
+
try {
|
|
48
|
+
rules = new Intl.PluralRules(language)
|
|
49
|
+
} catch {
|
|
50
|
+
// A runtime without Intl.PluralRules: every count takes the `_other` form.
|
|
51
|
+
}
|
|
52
|
+
pluralRules.set(language, rules)
|
|
53
|
+
}
|
|
54
|
+
return pluralRules.get(language)?.select(count) ?? 'other'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function countOf(value: unknown): number | null {
|
|
58
|
+
const n = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : Number.NaN
|
|
59
|
+
return Number.isFinite(n) ? n : null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function lookup(catalog: Readonly<Record<string, string>>, key: string): string | undefined {
|
|
63
|
+
return Object.prototype.hasOwnProperty.call(catalog, key) ? catalog[key] : undefined
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function interpolate(template: string, params?: Record<string, string | number>): string {
|
|
67
|
+
if (!params) return template
|
|
68
|
+
return template.replace(/\{(\w+)\}/g, (placeholder, name: string) =>
|
|
69
|
+
Object.prototype.hasOwnProperty.call(params, name) && params[name] != null ? String(params[name]) : placeholder,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* One text in the page's language. `params` fill `{name}` placeholders; a
|
|
75
|
+
* plural message needs `count`. An unknown key comes back as itself.
|
|
76
|
+
*/
|
|
77
|
+
export function consultationMessage(
|
|
78
|
+
locale: string,
|
|
79
|
+
key: ConsultationMessageKey,
|
|
80
|
+
params?: Record<string, string | number>,
|
|
81
|
+
): string {
|
|
82
|
+
const language = consultationMessageLanguage(locale)
|
|
83
|
+
const catalog: Readonly<Record<string, string>> = CONSULTATION_MESSAGES[language]
|
|
84
|
+
let template = lookup(catalog, key)
|
|
85
|
+
if (template === undefined) {
|
|
86
|
+
const count = countOf(params?.count)
|
|
87
|
+
const category = count === null ? 'other' : pluralCategory(language, count)
|
|
88
|
+
template = lookup(catalog, `${key}_${category}`) ?? lookup(catalog, `${key}_other`)
|
|
89
|
+
}
|
|
90
|
+
return template === undefined ? String(key) : interpolate(template, params)
|
|
91
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The envelope every consultation helper answers with, and the one mapping
|
|
3
|
+
* from the KB's error codes to the codes a reader page shows.
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ A reader never sees the KB's own text. The KB answers with a code
|
|
6
|
+
* (`INVALID_LINK`, `QUOTA_EXCEEDED`, …; `CONSULTATION_ERROR_CODES`) and a
|
|
7
|
+
* constant English sentence; the helpers turn the code into one of
|
|
8
|
+
* `CONSULTATION_UI_CODES`, and the page turns that into its own message
|
|
9
|
+
* (`consultationMessage(locale, 'error.<code>')`).
|
|
10
|
+
*
|
|
11
|
+
* The UI codes keep the drhoubicka storefront's names (plus `captcha`), so the
|
|
12
|
+
* storefront can adopt this mapping later by swapping one function and keep
|
|
13
|
+
* its `consultation.error.*` translation keys.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { isKbGraphQLError, type ConsultationErrorCode } from '../core/errors'
|
|
17
|
+
|
|
18
|
+
/** The codes a reader page can be told, in no particular order. */
|
|
19
|
+
export const CONSULTATION_UI_CODES = [
|
|
20
|
+
/** Not a POST (an action URL opened by hand). */
|
|
21
|
+
'method',
|
|
22
|
+
/** The request did not come from this site (`Origin` / `Sec-Fetch-Site`) — CSRF protection. */
|
|
23
|
+
'origin',
|
|
24
|
+
/** Not offered here: the module or the channel is off, or the site is not the reader site. */
|
|
25
|
+
'disabled',
|
|
26
|
+
/** A signed-in reader is needed (or the KB refused the reader's identity). */
|
|
27
|
+
'auth',
|
|
28
|
+
/** The KB could not be reached or asked to retry later. The reader can try again soon. */
|
|
29
|
+
'unavailable',
|
|
30
|
+
/** The form did not validate (an empty message, a malformed link, a bad address). */
|
|
31
|
+
'invalid',
|
|
32
|
+
/**
|
|
33
|
+
* The KB wants a different legal text with the question than the one that
|
|
34
|
+
* went with it (a consent not ticked, a text changed meanwhile, a consent
|
|
35
|
+
* that stopped covering new questions, a channel switched to notice mode).
|
|
36
|
+
* The page fetches what applies now and shows it.
|
|
37
|
+
*/
|
|
38
|
+
'consent',
|
|
39
|
+
/** The message is longer than the page (or the KB) allows. */
|
|
40
|
+
'tooLong',
|
|
41
|
+
/** A KB quota (per address, per thread, per day). */
|
|
42
|
+
'quota',
|
|
43
|
+
/** The Turnstile check failed. */
|
|
44
|
+
'captcha',
|
|
45
|
+
/** No such consultation — or not the reader's; the KB does not tell the two apart. */
|
|
46
|
+
'notFound',
|
|
47
|
+
/** The link or the session is no longer valid (`INVALID_LINK`). */
|
|
48
|
+
'expired',
|
|
49
|
+
/** The thread is closed; nothing can be written into it. */
|
|
50
|
+
'closed',
|
|
51
|
+
/** Attaching to an account: the account's address is not the thread's. */
|
|
52
|
+
'mismatch',
|
|
53
|
+
/**
|
|
54
|
+
* The same idempotency key with different content (`IDEMPOTENCY_CONFLICT`):
|
|
55
|
+
* an earlier attempt most likely went through and only its answer was lost.
|
|
56
|
+
* Tell the reader to look before sending again, and issue a NEW key.
|
|
57
|
+
*/
|
|
58
|
+
'conflict',
|
|
59
|
+
/** Anything else: "that did not work, try again". */
|
|
60
|
+
'submit',
|
|
61
|
+
] as const
|
|
62
|
+
|
|
63
|
+
export type ConsultationUiCode = (typeof CONSULTATION_UI_CODES)[number]
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* What every consultation helper resolves to; none of them throws.
|
|
67
|
+
* `retryAfterS` is set when the KB (or its rate limiter) said when to retry.
|
|
68
|
+
*/
|
|
69
|
+
export type ConsultationOutcome<T> =
|
|
70
|
+
| { ok: true; value: T }
|
|
71
|
+
| { ok: false; code: ConsultationUiCode; retryAfterS?: number }
|
|
72
|
+
|
|
73
|
+
const UI_CODES: ReadonlySet<string> = new Set(CONSULTATION_UI_CODES)
|
|
74
|
+
|
|
75
|
+
/** True for one of `CONSULTATION_UI_CODES` (e.g. a code read back from an action's result). */
|
|
76
|
+
export function isConsultationUiCode(code: unknown): code is ConsultationUiCode {
|
|
77
|
+
return typeof code === 'string' && UI_CODES.has(code)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Every KB consultation code → the reader's code. `satisfies Record` over the
|
|
82
|
+
* whole union: a code added to the KB (and to `CONSULTATION_ERROR_CODES`,
|
|
83
|
+
* which a drift test keeps in step) fails the type check here instead of
|
|
84
|
+
* reaching a reader as an unknown string, and so does a misspelled extra key.
|
|
85
|
+
*
|
|
86
|
+
* Codes a reader path cannot produce (operator, adapter, AI draft and card
|
|
87
|
+
* codes) map to `submit`: should one arrive anyway, the reader gets the
|
|
88
|
+
* generic message and the log shows the KB code.
|
|
89
|
+
*/
|
|
90
|
+
export const CONSULTATION_OUTCOME_OF_KB: Readonly<Record<ConsultationErrorCode, ConsultationUiCode>> =
|
|
91
|
+
Object.freeze({
|
|
92
|
+
UNAUTHENTICATED: 'auth',
|
|
93
|
+
FORBIDDEN: 'auth',
|
|
94
|
+
NOT_FOUND: 'notFound',
|
|
95
|
+
FEATURE_DISABLED: 'disabled',
|
|
96
|
+
// The channel is not enabled in the KB: for the reader the same as the module being off.
|
|
97
|
+
CHANNEL_NOT_ALLOWED: 'disabled',
|
|
98
|
+
INVALID_INPUT: 'invalid',
|
|
99
|
+
BODY_TOO_LONG: 'tooLong',
|
|
100
|
+
// A new question went with another legal text than the KB wants now. `consent` makes the page
|
|
101
|
+
// fetch what applies and show it; as `invalid` it would repeat "check the form" forever.
|
|
102
|
+
NOTICE_REQUIRED: 'consent',
|
|
103
|
+
NOTICE_VERSION_UNKNOWN: 'consent',
|
|
104
|
+
CONSENT_REQUIRED: 'consent',
|
|
105
|
+
CONSENT_VERSION_UNKNOWN: 'consent',
|
|
106
|
+
QUOTA_EXCEEDED: 'quota',
|
|
107
|
+
INVALID_LINK: 'expired',
|
|
108
|
+
THREAD_CLOSED: 'closed',
|
|
109
|
+
ATTACH_EMAIL_MISMATCH: 'mismatch',
|
|
110
|
+
// Same key, different content: the first attempt was stored and its answer lost.
|
|
111
|
+
IDEMPOTENCY_CONFLICT: 'conflict',
|
|
112
|
+
RETRY_LATER: 'unavailable',
|
|
113
|
+
INTERNAL_ERROR: 'unavailable',
|
|
114
|
+
THREAD_REQUIRED: 'submit',
|
|
115
|
+
SENDER_MISMATCH: 'submit',
|
|
116
|
+
STALE_THREAD: 'submit',
|
|
117
|
+
STALE_LEASE: 'submit',
|
|
118
|
+
// A reader gets it only from withdrawing a consent that is already gone; `withdrawConsent`
|
|
119
|
+
// answers that as done (withdrawing is idempotent) before this table is asked.
|
|
120
|
+
NOTHING_TO_DO: 'submit',
|
|
121
|
+
LEGAL_HOLD: 'submit',
|
|
122
|
+
CONTENT_ACCESS_REQUIRED: 'submit',
|
|
123
|
+
READER_URL_MISSING: 'submit',
|
|
124
|
+
READER_PATH_MISSING: 'submit',
|
|
125
|
+
TEXT_MISSING: 'submit',
|
|
126
|
+
OPERATOR_MISSING: 'submit',
|
|
127
|
+
MAIL_TRANSPORT_MISSING: 'submit',
|
|
128
|
+
TEXT_VERSION_EXISTS: 'submit',
|
|
129
|
+
CONTENT_ACCESS_ATTESTATION_REQUIRED: 'submit',
|
|
130
|
+
// AI reply drafts (phase 2a) and answer cards (phase 2b) are operator-only.
|
|
131
|
+
AI_DRAFTS_DISABLED: 'submit',
|
|
132
|
+
AI_LOCAL_UNAVAILABLE: 'submit',
|
|
133
|
+
PROCESSING_RESTRICTED: 'submit',
|
|
134
|
+
DRAFT_FLAGS_UNACKNOWLEDGED: 'submit',
|
|
135
|
+
REPLY_POLICY_MISSING: 'submit',
|
|
136
|
+
DRAFT_ID_REQUIRED: 'submit',
|
|
137
|
+
CARD_GUARD_FAILED: 'submit',
|
|
138
|
+
CARD_CONFIRMATION_REQUIRED: 'submit',
|
|
139
|
+
STALE_CARD: 'submit',
|
|
140
|
+
} satisfies Record<ConsultationErrorCode, ConsultationUiCode>)
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* A KB code (a mutation result's `code`, or `KbGraphQLError.code`) → the
|
|
144
|
+
* reader's code. Unknown, absent and GraphQL-level codes
|
|
145
|
+
* (`GRAPHQL_VALIDATION_FAILED`, …) are `submit`.
|
|
146
|
+
*/
|
|
147
|
+
export function consultationOutcomeOf(kbCode: string | null | undefined): ConsultationUiCode {
|
|
148
|
+
if (typeof kbCode !== 'string' || kbCode === '') return 'submit'
|
|
149
|
+
return Object.prototype.hasOwnProperty.call(CONSULTATION_OUTCOME_OF_KB, kbCode)
|
|
150
|
+
? CONSULTATION_OUTCOME_OF_KB[kbCode as ConsultationErrorCode]
|
|
151
|
+
: 'submit'
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Brand shared by every copy of the SDK loaded in one process (a bundler can
|
|
156
|
+
* load the src and the dist build side by side), so the check works where
|
|
157
|
+
* `instanceof` would not.
|
|
158
|
+
*/
|
|
159
|
+
const TRANSPORT_ERROR_BRAND = Symbol.for('@blogmcp/sdk/ConsultationTransportError')
|
|
160
|
+
|
|
161
|
+
function httpStatusOrNull(value: unknown): number | null {
|
|
162
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 100 && value <= 599 ? value : null
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function secondsOrNull(value: unknown): number | null {
|
|
166
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.ceil(value) : null
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The KB could not be asked, or did not answer as the API does: the network
|
|
171
|
+
* failed, the request timed out, an HTTP 5xx or a 429 without a code came
|
|
172
|
+
* back, the body was not JSON or lacked the expected field.
|
|
173
|
+
*
|
|
174
|
+
* Its message must stay free of anything a reader sent (bodies, addresses,
|
|
175
|
+
* tokens) — it names what failed, e.g. "KB answered HTTP 503".
|
|
176
|
+
*/
|
|
177
|
+
export class ConsultationTransportError extends Error {
|
|
178
|
+
/** The KB's HTTP status, or null when there was no response (network, timeout). */
|
|
179
|
+
readonly status: number | null
|
|
180
|
+
/** Seconds to wait before retrying (the KB's `Retry-After`), or null. */
|
|
181
|
+
readonly retryAfterS: number | null
|
|
182
|
+
|
|
183
|
+
constructor(message: string, init: { status?: number | null; retryAfterS?: number | null } = {}) {
|
|
184
|
+
super(message)
|
|
185
|
+
this.name = 'ConsultationTransportError'
|
|
186
|
+
this.status = httpStatusOrNull(init.status)
|
|
187
|
+
this.retryAfterS = secondsOrNull(init.retryAfterS)
|
|
188
|
+
// Non-enumerable, so it stays out of serialised errors and of the .d.ts.
|
|
189
|
+
Object.defineProperty(this, TRANSPORT_ERROR_BRAND, { value: true })
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** True for a ConsultationTransportError, also one thrown by another copy of the SDK. */
|
|
194
|
+
export function isConsultationTransportError(err: unknown): err is ConsultationTransportError {
|
|
195
|
+
if (err instanceof ConsultationTransportError) return true
|
|
196
|
+
return err instanceof Error && (err as unknown as Record<symbol, unknown>)[TRANSPORT_ERROR_BRAND] === true
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Anything a KB call threw → the reader's code.
|
|
201
|
+
*
|
|
202
|
+
* - `KbGraphQLError` with a code: the table above (`NOT_FOUND` → `notFound`, …).
|
|
203
|
+
* - `KbGraphQLError` without one: the SDK's "malformed response" (a missing
|
|
204
|
+
* field) — for the reader "the KB did not answer", so `unavailable`.
|
|
205
|
+
* - `ConsultationTransportError`: `unavailable`, with its `retryAfterS`.
|
|
206
|
+
* - anything else (a network error of a custom fetcher, a bug): `unavailable`.
|
|
207
|
+
*/
|
|
208
|
+
export function consultationFailureOf(err: unknown): { code: ConsultationUiCode; retryAfterS?: number } {
|
|
209
|
+
if (isKbGraphQLError(err)) {
|
|
210
|
+
return { code: err.code ? consultationOutcomeOf(err.code) : 'unavailable' }
|
|
211
|
+
}
|
|
212
|
+
if (isConsultationTransportError(err)) {
|
|
213
|
+
return err.retryAfterS === null ? { code: 'unavailable' } : { code: 'unavailable', retryAfterS: err.retryAfterS }
|
|
214
|
+
}
|
|
215
|
+
return { code: 'unavailable' }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** The HTTP status of a response that carries a reader code. */
|
|
219
|
+
export const CONSULTATION_UI_HTTP_STATUS: Readonly<Record<ConsultationUiCode, number>> = Object.freeze({
|
|
220
|
+
method: 405,
|
|
221
|
+
origin: 403,
|
|
222
|
+
disabled: 404,
|
|
223
|
+
auth: 401,
|
|
224
|
+
unavailable: 503,
|
|
225
|
+
invalid: 400,
|
|
226
|
+
consent: 400,
|
|
227
|
+
tooLong: 400,
|
|
228
|
+
quota: 429,
|
|
229
|
+
captcha: 400,
|
|
230
|
+
notFound: 404,
|
|
231
|
+
expired: 410,
|
|
232
|
+
closed: 409,
|
|
233
|
+
mismatch: 409,
|
|
234
|
+
conflict: 409,
|
|
235
|
+
submit: 502,
|
|
236
|
+
} satisfies Record<ConsultationUiCode, number>)
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Headers of EVERY consultation page and endpoint response, errors included.
|
|
240
|
+
*
|
|
241
|
+
* - `Cache-Control: private, no-store` — the page carries a question and its
|
|
242
|
+
* answer; no shared cache and no browser disk may keep it (a shared
|
|
243
|
+
* computer, "back" after signing out).
|
|
244
|
+
* - `Referrer-Policy: same-origin`, NOT `no-referrer`: under `no-referrer` a
|
|
245
|
+
* plain form POST (before hydration, without JavaScript) carries
|
|
246
|
+
* `Origin: null`, and the Origin check would refuse every reply, erase and
|
|
247
|
+
* sign-out. `same-origin` sends nothing to third parties either. The
|
|
248
|
+
* fragment (`#t=…`) never goes into a `Referer` at all.
|
|
249
|
+
* - `X-Robots-Tag: noindex, nofollow` — a header (not a robots.txt
|
|
250
|
+
* `Disallow`), so a crawler can read it and drop the URL.
|
|
251
|
+
* - `X-Frame-Options` + `frame-ancestors 'none'` — no other site may frame a
|
|
252
|
+
* page whose buttons erase a thread.
|
|
253
|
+
*/
|
|
254
|
+
export const CONSULTATION_RESPONSE_HEADERS = Object.freeze({
|
|
255
|
+
'Cache-Control': 'private, no-store',
|
|
256
|
+
'Referrer-Policy': 'same-origin',
|
|
257
|
+
'X-Robots-Tag': 'noindex, nofollow',
|
|
258
|
+
'X-Frame-Options': 'DENY',
|
|
259
|
+
'Content-Security-Policy': "frame-ancestors 'none'",
|
|
260
|
+
} as const)
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Where a helper reports what operators should see: an outage (`unavailable`)
|
|
264
|
+
* or something unexpected (`submit`). It gets the operation, the outcome, the
|
|
265
|
+
* KB code and the HTTP status — never a body, an address, a name, a token, a
|
|
266
|
+
* session, a JWT, a key or an IP.
|
|
267
|
+
*/
|
|
268
|
+
export type ConsultationLogger = (e: {
|
|
269
|
+
op: string
|
|
270
|
+
outcome: ConsultationUiCode
|
|
271
|
+
kbCode?: string | null
|
|
272
|
+
status?: number | null
|
|
273
|
+
}) => void
|
|
274
|
+
|
|
275
|
+
/** The codes a helper logs; everything else is an ordinary reader state (an expired link, a quota). */
|
|
276
|
+
export function isLoggedConsultationOutcome(code: ConsultationUiCode): boolean {
|
|
277
|
+
return code === 'unavailable' || code === 'submit'
|
|
278
|
+
}
|