@luhtech/site-template 0.16.0 → 0.18.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/README.md +4 -13
- package/bin/luhtech-tokens.mjs +5 -38
- package/package.json +3 -13
- package/src/components/PaperLanding.astro +242 -0
- package/src/content/loadBrand.ts +3 -46
- package/src/content/loadPage.ts +3 -53
- package/src/content/loadSite.ts +3 -41
- package/src/content/loadTool.ts +3 -53
- package/src/lib/assetRequest.ts +13 -0
- package/src/lib/paperLanding.ts +182 -0
- package/src/content/_vendored-schema-fallback/capability-claim.schema.json +0 -91
- package/src/content/schemaFetch.ts +0 -70
package/README.md
CHANGED
|
@@ -20,9 +20,10 @@ site with no way to supply one (GTM-L3 G1.4-R, 2026-09-08).
|
|
|
20
20
|
## The contract
|
|
21
21
|
|
|
22
22
|
- **`loadSite(path)`** / **`loadPage(path)`** (`@luhtech/site-template/content`)
|
|
23
|
-
read a JSON
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
read a JSON content instance. They do not validate: since 0.18.0 each site
|
|
24
|
+
repo validates its content in CI against schema-registry with the reusable
|
|
25
|
+
`content-validate.yml` workflow, so this public package fetches and carries
|
|
26
|
+
no schema. `loadTool`, `loadBrand` and `luhtech-tokens` work the same way.
|
|
26
27
|
- **`<SiteLayout site={site} page={page}>`** (`@luhtech/site-template/layouts/SiteLayout.astro`)
|
|
27
28
|
renders nav from `site.nav`, footer from `site.footer.legalLine` +
|
|
28
29
|
`parentHref`, and `<head>` from `page.seo` (title, description, og:\*,
|
|
@@ -106,16 +107,6 @@ site with no way to supply one (GTM-L3 G1.4-R, 2026-09-08).
|
|
|
106
107
|
no MCP access. `kind=method` claims describe design intent regardless of
|
|
107
108
|
status and are reported, never failed.
|
|
108
109
|
|
|
109
|
-
## A known, out-of-scope gap
|
|
110
|
-
|
|
111
|
-
`content/capability-claim.schema.json` 404s at both its bare and
|
|
112
|
-
version-pinned live URLs (a schema-registry publish-pipeline issue, not
|
|
113
|
-
something this package can fix). `loadPage`'s validator falls back to a
|
|
114
|
-
vendored local copy (`src/content/_vendored-schema-fallback/`, fetched from
|
|
115
|
-
the real schema-registry source, not fabricated) only for this one schema,
|
|
116
|
-
and logs a warning when it does. Every other schema fetch failure is a hard
|
|
117
|
-
error.
|
|
118
|
-
|
|
119
110
|
## Article sections, table of contents, linkable blocks
|
|
120
111
|
|
|
121
112
|
Added in 0.4.0 (d-2026-09-08-sr-article-venture-site-bridge), the schema-first
|
package/bin/luhtech-tokens.mjs
CHANGED
|
@@ -6,23 +6,15 @@
|
|
|
6
6
|
* same real logic, generalized to take instance/output paths as CLI args
|
|
7
7
|
* instead of assuming one repo's directory layout.
|
|
8
8
|
*
|
|
9
|
+
* The instance is validated in the site repo's CI (schema-registry
|
|
10
|
+
* content-validate.yml), not here.
|
|
11
|
+
*
|
|
9
12
|
* Usage:
|
|
10
13
|
* luhtech-tokens <path-to-brand-identity.json> <output-css-path>
|
|
11
14
|
* luhtech-tokens content/brand/ectropy.json src/styles/tokens.generated.css
|
|
12
15
|
*/
|
|
13
16
|
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
14
17
|
import { dirname, resolve } from 'node:path';
|
|
15
|
-
import Ajv from 'ajv';
|
|
16
|
-
import addFormats from 'ajv-formats';
|
|
17
|
-
|
|
18
|
-
const SCHEMA_BASE = 'https://schemas.luh.tech';
|
|
19
|
-
const SCHEMA_REFS = [
|
|
20
|
-
'portfolio/brand-identity.schema.json',
|
|
21
|
-
'_enums/luhtech-enums.schema.v2.json',
|
|
22
|
-
'_enums/venture.enum.json',
|
|
23
|
-
'_definitions/definitions.schema.json',
|
|
24
|
-
'_definitions/graph.schema.json',
|
|
25
|
-
];
|
|
26
18
|
|
|
27
19
|
const [, , instanceArg, outputArg] = process.argv;
|
|
28
20
|
if (!instanceArg || !outputArg) {
|
|
@@ -32,15 +24,6 @@ if (!instanceArg || !outputArg) {
|
|
|
32
24
|
const instancePath = resolve(process.cwd(), instanceArg);
|
|
33
25
|
const outputPath = resolve(process.cwd(), outputArg);
|
|
34
26
|
|
|
35
|
-
async function fetchSchema(rel) {
|
|
36
|
-
const url = `${SCHEMA_BASE}/${rel}`;
|
|
37
|
-
const res = await fetch(url);
|
|
38
|
-
if (!res.ok) {
|
|
39
|
-
throw new Error(`Failed to fetch canonical schema ${url}: HTTP ${res.status}.`);
|
|
40
|
-
}
|
|
41
|
-
return res.json();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
27
|
function readInstance(path) {
|
|
45
28
|
let raw;
|
|
46
29
|
try {
|
|
@@ -78,26 +61,10 @@ ${color.accent.secondary ? ` --color-accent-secondary: ${cssColor(color.accent.
|
|
|
78
61
|
}
|
|
79
62
|
|
|
80
63
|
async function main() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const [brandIdentitySchema, ...refs] = await Promise.all(SCHEMA_REFS.map(fetchSchema));
|
|
85
|
-
for (const ref of refs) {
|
|
86
|
-
ajv.addSchema(ref);
|
|
87
|
-
}
|
|
88
|
-
const validate = ajv.compile(brandIdentitySchema);
|
|
89
|
-
|
|
64
|
+
// The brand instance is validated in the site repo's CI against
|
|
65
|
+
// schema-registry (content-validate.yml); this public package fetches no schema.
|
|
90
66
|
const brand = readInstance(instancePath);
|
|
91
67
|
|
|
92
|
-
if (!validate(brand)) {
|
|
93
|
-
const detail = (validate.errors ?? [])
|
|
94
|
-
.map((e) => `${e.instancePath || '(root)'}: ${e.message}`)
|
|
95
|
-
.join('; ');
|
|
96
|
-
throw new Error(
|
|
97
|
-
`${instancePath} failed validation against portfolio/brand-identity.schema.json: ${detail}`
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
68
|
const css = generateCss(brand);
|
|
102
69
|
mkdirSync(dirname(outputPath), { recursive: true });
|
|
103
70
|
writeFileSync(outputPath, css, 'utf-8');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luhtech/site-template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Shared Astro component library + content-instance contract for LuhTech venture marketing sites -- one template renders every site from content/page.schema.json + content/site.schema.json instances.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"exports": {
|
|
24
24
|
"./content": "./src/content/index.ts",
|
|
25
|
+
"./lib/paperLanding": "./src/lib/paperLanding.ts",
|
|
25
26
|
"./layouts/SiteLayout.astro": "./src/layouts/SiteLayout.astro",
|
|
26
27
|
"./components/*": "./src/components/*",
|
|
27
28
|
"./components/sections/*": "./src/components/sections/*"
|
|
@@ -45,17 +46,6 @@
|
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"@lucide/astro": "^1.42.0",
|
|
48
|
-
"@resvg/resvg-js": "^2.6.2"
|
|
49
|
-
"ajv": "^8.17.1",
|
|
50
|
-
"ajv-formats": "^3.0.1"
|
|
51
|
-
},
|
|
52
|
-
"luhtech": {
|
|
53
|
-
"schemaPins": {
|
|
54
|
-
"content/page.schema.json": "2.5.0",
|
|
55
|
-
"content/site.schema.json": "1.3.0",
|
|
56
|
-
"content/capability-claim.schema.json": "0.2.0",
|
|
57
|
-
"content/tool.schema.json": "1.2.0",
|
|
58
|
-
"portfolio/brand-identity.schema.json": "1.5.0"
|
|
59
|
-
}
|
|
49
|
+
"@resvg/resvg-js": "^2.6.2"
|
|
60
50
|
}
|
|
61
51
|
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
---
|
|
2
|
+
// d-2026-10-02-st-paper-landing-three-actions. The paper's one page
|
|
3
|
+
// (/papers/<slug>/): its open summary and figures (rendered through the same
|
|
4
|
+
// section components as the landing page it replaces,
|
|
5
|
+
// d-2026-10-01-eb-whitepaper-hybrid-gate), then three actions.
|
|
6
|
+
//
|
|
7
|
+
// - Download: arriving with ?t=<token> (the delivery email's link) it links
|
|
8
|
+
// to the gateway's download route, ${assetRequestEndpoint}/<token>, which
|
|
9
|
+
// records the open and stamps through business-tools. Otherwise it shows
|
|
10
|
+
// the asset request form; arriving with ?c=<code> the request names that
|
|
11
|
+
// code as referredByCode (AssetRequestForm / assetRequest.ts).
|
|
12
|
+
// - Feedback (#feedback): the record's feedbackForm, behind a Cloudflare
|
|
13
|
+
// Turnstile challenge, posted to site.leadCapture.feedbackEndpoint. Name and
|
|
14
|
+
// email are asked on both arrivals. Without a feedbackEndpoint and a
|
|
15
|
+
// turnstileSiteKey in site config (site.schema.json 1.4.0) it says plainly
|
|
16
|
+
// that feedback is not open yet. The fragment is an anchor only; the token
|
|
17
|
+
// stays in the query.
|
|
18
|
+
// - Share: the page URL with no query or fragment -- never a token or code.
|
|
19
|
+
//
|
|
20
|
+
// Turnstile, implicit rendering (developers.cloudflare.com/turnstile/get-started/
|
|
21
|
+
// client-side-rendering/, read 2026-10-02): the api.js script from
|
|
22
|
+
// challenges.cloudflare.com, a <div class="cf-turnstile" data-sitekey> inside
|
|
23
|
+
// the form, and the token in the hidden input cf-turnstile-response it adds.
|
|
24
|
+
// Tokens are single-use, so the widget is reset after every attempt.
|
|
25
|
+
import Section from './Section.astro';
|
|
26
|
+
import AssetRequestForm from './AssetRequestForm.astro';
|
|
27
|
+
import {
|
|
28
|
+
feedbackOpen,
|
|
29
|
+
linkedInShareUrl,
|
|
30
|
+
mailtoShareUrl,
|
|
31
|
+
paperSections,
|
|
32
|
+
shareUrlFor,
|
|
33
|
+
type PaperRecord,
|
|
34
|
+
} from '../lib/paperLanding.ts';
|
|
35
|
+
|
|
36
|
+
export interface Props {
|
|
37
|
+
paper: PaperRecord;
|
|
38
|
+
slug: string;
|
|
39
|
+
site: { leadCapture: { assetRequestEndpoint?: string; feedbackEndpoint?: string; turnstileSiteKey?: string; honeypotField: string; minSubmitMs?: number; ventureField?: string; [k: string]: unknown } };
|
|
40
|
+
route?: string;
|
|
41
|
+
}
|
|
42
|
+
const { paper, slug, site } = Astro.props;
|
|
43
|
+
const route = Astro.props.route ?? `/papers/${slug}/`;
|
|
44
|
+
const leadCapture = site.leadCapture;
|
|
45
|
+
if (!paper.pdfAssetRef) throw new Error(`PaperLanding: paper ${slug} has no pdfAssetRef`);
|
|
46
|
+
if (!leadCapture?.assetRequestEndpoint) throw new Error(`PaperLanding: site.leadCapture has no assetRequestEndpoint for paper ${slug}`);
|
|
47
|
+
|
|
48
|
+
const sections = paperSections(paper, slug);
|
|
49
|
+
const shareUrl = shareUrlFor(new URL(route, Astro.site ?? Astro.url).href);
|
|
50
|
+
const form = paper.feedbackForm;
|
|
51
|
+
const open = feedbackOpen(leadCapture) && Boolean(form);
|
|
52
|
+
const field = 'w-full px-3 py-2 rounded-md border border-ink/20 bg-canvas text-ink';
|
|
53
|
+
const button = 'px-5 py-2.5 rounded-md bg-accent-primary text-canvas font-medium transition-all duration-200 hover:opacity-90 disabled:opacity-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-secondary focus-visible:rounded';
|
|
54
|
+
const secondary = 'px-4 py-2 rounded-md border border-ink/20 text-ink font-medium hover:border-accent-primary';
|
|
55
|
+
---
|
|
56
|
+
<div class="paper-landing" data-asset-request-endpoint={leadCapture.assetRequestEndpoint}>
|
|
57
|
+
{sections.map((s) => <Section section={s} site={site} />)}
|
|
58
|
+
|
|
59
|
+
<section id="download" class="py-12 border-t border-ink/10" data-reveal>
|
|
60
|
+
<h2 class="font-display text-2xl font-bold mb-4">Download</h2>
|
|
61
|
+
<div class="paper-download-link" hidden>
|
|
62
|
+
<a class={`${button} inline-block`} href="#download" rel="nofollow">Download the paper</a>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="paper-download-request max-w-md">
|
|
65
|
+
<AssetRequestForm assetRequest={{ assetRef: paper.pdfAssetRef }} leadCapture={leadCapture as any} />
|
|
66
|
+
</div>
|
|
67
|
+
</section>
|
|
68
|
+
|
|
69
|
+
<section id="feedback" class="py-12 border-t border-ink/10" data-reveal>
|
|
70
|
+
<h2 class="font-display text-2xl font-bold mb-4">Feedback</h2>
|
|
71
|
+
{open && form ? (
|
|
72
|
+
<>
|
|
73
|
+
<p class="paper-feedback-needs-arrival text-sm opacity-80">Feedback opens from the link in your email or the code on your copy of the paper.</p>
|
|
74
|
+
<form
|
|
75
|
+
class="paper-feedback-form max-w-xl space-y-4"
|
|
76
|
+
hidden
|
|
77
|
+
data-endpoint={leadCapture.feedbackEndpoint}
|
|
78
|
+
data-asset-ref={paper.pdfAssetRef}
|
|
79
|
+
>
|
|
80
|
+
<div>
|
|
81
|
+
<label class="block text-sm font-medium mb-1" for="pf-role">Your role</label>
|
|
82
|
+
<select id="pf-role" name="roleId" required class={field}>
|
|
83
|
+
{form.roles.map((r, i) => <option value={r.roleId} selected={i === 0}>{r.label}</option>)}
|
|
84
|
+
</select>
|
|
85
|
+
</div>
|
|
86
|
+
{form.questions.map((q) => (
|
|
87
|
+
<div data-question-id={q.questionId}>
|
|
88
|
+
<label class="block text-sm font-medium mb-1" for={`pf-q-${q.questionId}`}>{q.prompt}</label>
|
|
89
|
+
{q.answerType === 'choice' ? (
|
|
90
|
+
<>
|
|
91
|
+
<select id={`pf-q-${q.questionId}`} name={`answer:${q.questionId}`} class={field}>
|
|
92
|
+
<option value="" selected></option>
|
|
93
|
+
{(q.choices ?? []).map((c) => <option value={c.choiceId}>{c.label}</option>)}
|
|
94
|
+
</select>
|
|
95
|
+
{q.allowOther && (
|
|
96
|
+
<input name={`other:${q.questionId}`} type="text" maxlength="4000" aria-label={`${q.prompt} (other)`} class={`${field} mt-2`} />
|
|
97
|
+
)}
|
|
98
|
+
</>
|
|
99
|
+
) : (
|
|
100
|
+
<textarea id={`pf-q-${q.questionId}`} name={`answer:${q.questionId}`} rows="3" maxlength="4000" class={field}></textarea>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
))}
|
|
104
|
+
<div class="grid grid-cols-2 gap-3">
|
|
105
|
+
<div>
|
|
106
|
+
<label class="block text-sm font-medium mb-1" for="pf-first">First name</label>
|
|
107
|
+
<input id="pf-first" name="firstName" type="text" required maxlength="100" autocomplete="given-name" class={field} />
|
|
108
|
+
</div>
|
|
109
|
+
<div>
|
|
110
|
+
<label class="block text-sm font-medium mb-1" for="pf-last">Last name</label>
|
|
111
|
+
<input id="pf-last" name="lastName" type="text" required maxlength="100" autocomplete="family-name" class={field} />
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
<div>
|
|
115
|
+
<label class="block text-sm font-medium mb-1" for="pf-email">Email</label>
|
|
116
|
+
<input id="pf-email" name="email" type="email" required maxlength="255" autocomplete="email" class={field} />
|
|
117
|
+
</div>
|
|
118
|
+
<div>
|
|
119
|
+
<label class="block text-sm font-medium mb-1" for="pf-company">Company</label>
|
|
120
|
+
<input id="pf-company" name="company" type="text" maxlength="255" autocomplete="organization" class={field} />
|
|
121
|
+
</div>
|
|
122
|
+
<label class="flex gap-2 items-start text-sm">
|
|
123
|
+
<input name="publishConsent" type="checkbox" class="mt-1" />
|
|
124
|
+
<span>LuhTech may publish my answers.</span>
|
|
125
|
+
</label>
|
|
126
|
+
<div class="cf-turnstile" data-sitekey={leadCapture.turnstileSiteKey}></div>
|
|
127
|
+
<button type="submit" class={button}>Send my answers</button>
|
|
128
|
+
<p class="paper-feedback-status text-sm" role="status" aria-live="polite"></p>
|
|
129
|
+
</form>
|
|
130
|
+
<script is:inline src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
|
131
|
+
</>
|
|
132
|
+
) : (
|
|
133
|
+
<p class="text-sm opacity-80">Feedback is not open yet.</p>
|
|
134
|
+
)}
|
|
135
|
+
</section>
|
|
136
|
+
|
|
137
|
+
<section id="share" class="py-12 border-t border-ink/10" data-reveal>
|
|
138
|
+
<h2 class="font-display text-2xl font-bold mb-4">Share</h2>
|
|
139
|
+
<div class="flex gap-3 flex-wrap items-center">
|
|
140
|
+
<button type="button" class={`paper-share-copy ${secondary}`} data-share-url={shareUrl}>Copy link</button>
|
|
141
|
+
<a class={secondary} href={linkedInShareUrl(shareUrl)} target="_blank" rel="noopener noreferrer">LinkedIn</a>
|
|
142
|
+
<a class={secondary} href={mailtoShareUrl(shareUrl, paper.title)}>Email</a>
|
|
143
|
+
<span class="paper-share-status text-sm" role="status" aria-live="polite"></span>
|
|
144
|
+
</div>
|
|
145
|
+
</section>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<script>
|
|
149
|
+
import { arrivalFrom, downloadUrlFor, feedbackBody, feedbackMessage } from '../lib/paperLanding.ts';
|
|
150
|
+
import { sourceRefFor } from '../lib/assetRequest.ts';
|
|
151
|
+
|
|
152
|
+
for (const root of document.querySelectorAll<HTMLElement>('.paper-landing')) {
|
|
153
|
+
const arrival = arrivalFrom(window.location.search);
|
|
154
|
+
|
|
155
|
+
// Download: a token links straight to the gateway's download route.
|
|
156
|
+
if (arrival.by === 'token') {
|
|
157
|
+
const link = root.querySelector<HTMLElement>('.paper-download-link');
|
|
158
|
+
const anchor = link?.querySelector('a');
|
|
159
|
+
if (link && anchor) {
|
|
160
|
+
anchor.href = downloadUrlFor(root.dataset.assetRequestEndpoint!, arrival.token);
|
|
161
|
+
link.hidden = false;
|
|
162
|
+
root.querySelector<HTMLElement>('.paper-download-request')!.hidden = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Feedback: open to a reader who arrived by token or code.
|
|
167
|
+
const form = root.querySelector<HTMLFormElement>('form.paper-feedback-form');
|
|
168
|
+
if (form && arrival.by !== 'none') {
|
|
169
|
+
form.hidden = false;
|
|
170
|
+
root.querySelector<HTMLElement>('.paper-feedback-needs-arrival')!.hidden = true;
|
|
171
|
+
const status = form.querySelector('.paper-feedback-status') as HTMLParagraphElement;
|
|
172
|
+
form.addEventListener('submit', async (e) => {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
const data = new FormData(form);
|
|
175
|
+
const turnstileToken = String(data.get('cf-turnstile-response') ?? '');
|
|
176
|
+
if (!turnstileToken) {
|
|
177
|
+
status.textContent = 'Complete the challenge first.';
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const answers: Record<string, string> = {};
|
|
181
|
+
for (const [k, v] of data.entries()) {
|
|
182
|
+
if (k.startsWith('answer:')) answers[k.slice(7)] = String(v);
|
|
183
|
+
}
|
|
184
|
+
for (const [k, v] of data.entries()) {
|
|
185
|
+
if (k.startsWith('other:') && String(v).trim()) answers[k.slice(6)] = String(v);
|
|
186
|
+
}
|
|
187
|
+
const body = feedbackBody(
|
|
188
|
+
{
|
|
189
|
+
roleId: String(data.get('roleId') ?? ''),
|
|
190
|
+
answers,
|
|
191
|
+
publishConsent: data.get('publishConsent') === 'on',
|
|
192
|
+
firstName: String(data.get('firstName') ?? ''),
|
|
193
|
+
lastName: String(data.get('lastName') ?? ''),
|
|
194
|
+
email: String(data.get('email') ?? ''),
|
|
195
|
+
company: String(data.get('company') ?? ''),
|
|
196
|
+
turnstileToken,
|
|
197
|
+
},
|
|
198
|
+
{ assetRef: form.dataset.assetRef!, arrival, sourceRef: sourceRefFor('', window.location.pathname) }
|
|
199
|
+
);
|
|
200
|
+
if (!body) return;
|
|
201
|
+
if (Object.keys(body.answers).length === 0) {
|
|
202
|
+
status.textContent = 'Answer at least one question.';
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const button = form.querySelector('button[type="submit"]') as HTMLButtonElement;
|
|
206
|
+
button.disabled = true;
|
|
207
|
+
status.textContent = 'Sending...';
|
|
208
|
+
try {
|
|
209
|
+
const res = await fetch(form.dataset.endpoint!, {
|
|
210
|
+
method: 'POST',
|
|
211
|
+
headers: { 'Content-Type': 'application/json' },
|
|
212
|
+
body: JSON.stringify(body),
|
|
213
|
+
});
|
|
214
|
+
const json = (await res.json().catch(() => ({}))) as { error?: string };
|
|
215
|
+
status.textContent = feedbackMessage(res.status, json.error);
|
|
216
|
+
if (res.status === 201) form.reset();
|
|
217
|
+
} catch {
|
|
218
|
+
status.textContent = feedbackMessage(0);
|
|
219
|
+
}
|
|
220
|
+
button.disabled = false;
|
|
221
|
+
(window as unknown as { turnstile?: { reset: () => void } }).turnstile?.reset();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Share: copy the non-personal link the button carries.
|
|
226
|
+
const copy = root.querySelector<HTMLButtonElement>('.paper-share-copy');
|
|
227
|
+
const shareStatus = root.querySelector('.paper-share-status') as HTMLSpanElement;
|
|
228
|
+
copy?.addEventListener('click', async () => {
|
|
229
|
+
try {
|
|
230
|
+
await navigator.clipboard.writeText(copy.dataset.shareUrl!);
|
|
231
|
+
shareStatus.textContent = 'Link copied.';
|
|
232
|
+
} catch {
|
|
233
|
+
shareStatus.textContent = copy.dataset.shareUrl!;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// #feedback lands on the Feedback action once the arrival has shown or hidden its parts.
|
|
238
|
+
if (window.location.hash === '#feedback') {
|
|
239
|
+
root.querySelector('#feedback')?.scrollIntoView();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
</script>
|
package/src/content/loadBrand.ts
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
import addFormats from 'ajv-formats';
|
|
4
|
-
import { fetchSchema, fetchSupportSchema } from './schemaFetch.js';
|
|
5
|
-
|
|
6
|
-
// 1.5.0: voice.lexicon spellings/glosses/prohibitedPatterns and surface-scoped
|
|
7
|
-
// prohibited items (additive -- every 1.3.0 instance validates unchanged).
|
|
8
|
-
const BRAND_PIN = '1.5.0';
|
|
9
|
-
|
|
10
|
-
let validatorPromise: ReturnType<typeof buildValidator> | null = null;
|
|
11
|
-
|
|
12
|
-
async function buildValidator() {
|
|
13
|
-
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
14
|
-
addFormats(ajv);
|
|
15
|
-
|
|
16
|
-
const [brandSchema, definitionsSchema, graphSchema, ventureEnum, luhtechEnums] =
|
|
17
|
-
await Promise.all([
|
|
18
|
-
fetchSchema('portfolio/brand-identity.schema.json', BRAND_PIN),
|
|
19
|
-
fetchSupportSchema('_definitions/definitions.schema.json'),
|
|
20
|
-
fetchSupportSchema('_definitions/graph.schema.json'),
|
|
21
|
-
fetchSupportSchema('_enums/venture.enum.json'),
|
|
22
|
-
fetchSupportSchema('_enums/luhtech-enums.schema.v2.json'),
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
ajv.addSchema(definitionsSchema as object);
|
|
26
|
-
ajv.addSchema(graphSchema as object);
|
|
27
|
-
ajv.addSchema(ventureEnum as object);
|
|
28
|
-
ajv.addSchema(luhtechEnums as object);
|
|
29
|
-
|
|
30
|
-
return ajv.compile(brandSchema as object);
|
|
31
|
-
}
|
|
32
2
|
|
|
33
3
|
export interface LoadedBrand {
|
|
34
4
|
brandId: string;
|
|
@@ -37,26 +7,13 @@ export interface LoadedBrand {
|
|
|
37
7
|
}
|
|
38
8
|
|
|
39
9
|
/**
|
|
40
|
-
* Reads a portfolio/brand-identity.schema.json instance from disk
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* returning an unvalidated instance.
|
|
10
|
+
* Reads a portfolio/brand-identity.schema.json instance from disk. The instance is validated in the
|
|
11
|
+
* site repo's CI against schema-registry (schema-registry content-validate.yml),
|
|
12
|
+
* not here: this public package fetches and carries no schema.
|
|
44
13
|
*/
|
|
45
14
|
export async function loadBrand(path: string): Promise<LoadedBrand> {
|
|
46
15
|
const raw = readFileSync(path, 'utf-8');
|
|
47
16
|
const instance = JSON.parse(raw);
|
|
48
17
|
|
|
49
|
-
if (!validatorPromise) validatorPromise = buildValidator();
|
|
50
|
-
const validate = await validatorPromise;
|
|
51
|
-
|
|
52
|
-
if (!validate(instance)) {
|
|
53
|
-
const errors = (validate.errors ?? [])
|
|
54
|
-
.map((e) => ` ${e.instancePath || '/'} ${e.message}`)
|
|
55
|
-
.join('\n');
|
|
56
|
-
throw new Error(
|
|
57
|
-
`${path} failed portfolio/brand-identity.schema.json@${BRAND_PIN} validation:\n${errors}`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
18
|
return instance as LoadedBrand;
|
|
62
19
|
}
|
package/src/content/loadPage.ts
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
import addFormats from 'ajv-formats';
|
|
4
|
-
import { fetchSchema, fetchSupportSchema } from './schemaFetch.js';
|
|
5
|
-
|
|
6
|
-
const PAGE_PIN = '2.5.0';
|
|
7
|
-
const CAPABILITY_CLAIM_PIN = '0.2.0';
|
|
8
|
-
|
|
9
|
-
let validatorPromise: ReturnType<typeof buildValidator> | null = null;
|
|
10
|
-
|
|
11
|
-
async function buildValidator() {
|
|
12
|
-
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
13
|
-
addFormats(ajv);
|
|
14
|
-
|
|
15
|
-
const [pageSchema, capabilityClaimSchema, cellSchema, definitionsSchema, graphSchema, ventureEnum, contentSpineSchema] =
|
|
16
|
-
await Promise.all([
|
|
17
|
-
fetchSchema('content/page.schema.json', PAGE_PIN),
|
|
18
|
-
fetchSchema('content/capability-claim.schema.json', CAPABILITY_CLAIM_PIN),
|
|
19
|
-
fetchSupportSchema('_definitions/cell.schema.json'),
|
|
20
|
-
fetchSupportSchema('_definitions/definitions.schema.json'),
|
|
21
|
-
fetchSupportSchema('_definitions/graph.schema.json'),
|
|
22
|
-
fetchSupportSchema('_enums/venture.enum.json'),
|
|
23
|
-
// page.schema.json v2.0.0 (content-spine adoption) $refs this for
|
|
24
|
-
// publishRecordRefs/themeRefs/strategyRef/producedBy -- missing here
|
|
25
|
-
// until now because PAGE_PIN itself couldn't move past v1.4.0 (see
|
|
26
|
-
// this same PR's own PAGE_PIN fix) to ever need it.
|
|
27
|
-
fetchSupportSchema('_definitions/content-spine.schema.json'),
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
ajv.addSchema(capabilityClaimSchema as object);
|
|
31
|
-
ajv.addSchema(cellSchema as object);
|
|
32
|
-
ajv.addSchema(definitionsSchema as object);
|
|
33
|
-
ajv.addSchema(graphSchema as object);
|
|
34
|
-
ajv.addSchema(ventureEnum as object);
|
|
35
|
-
ajv.addSchema(contentSpineSchema as object);
|
|
36
|
-
|
|
37
|
-
return ajv.compile(pageSchema as object);
|
|
38
|
-
}
|
|
39
2
|
|
|
40
3
|
export interface PageBlock {
|
|
41
4
|
blockType: string;
|
|
@@ -111,26 +74,13 @@ export interface LoadedPage {
|
|
|
111
74
|
}
|
|
112
75
|
|
|
113
76
|
/**
|
|
114
|
-
* Reads a content/page.schema.json instance from disk
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* and continue with an unvalidated instance.
|
|
77
|
+
* Reads a content/page.schema.json instance from disk. The instance is validated in the
|
|
78
|
+
* site repo's CI against schema-registry (schema-registry content-validate.yml),
|
|
79
|
+
* not here: this public package fetches and carries no schema.
|
|
118
80
|
*/
|
|
119
81
|
export async function loadPage(path: string): Promise<LoadedPage> {
|
|
120
82
|
const raw = readFileSync(path, 'utf-8');
|
|
121
83
|
const instance = JSON.parse(raw);
|
|
122
84
|
|
|
123
|
-
if (!validatorPromise) validatorPromise = buildValidator();
|
|
124
|
-
const validate = await validatorPromise;
|
|
125
|
-
|
|
126
|
-
if (!validate(instance)) {
|
|
127
|
-
const errors = (validate.errors ?? [])
|
|
128
|
-
.map((e) => ` ${e.instancePath || '/'} ${e.message}`)
|
|
129
|
-
.join('\n');
|
|
130
|
-
throw new Error(
|
|
131
|
-
`${path} failed content/page.schema.json@${PAGE_PIN} validation:\n${errors}`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
85
|
return instance as LoadedPage;
|
|
136
86
|
}
|
package/src/content/loadSite.ts
CHANGED
|
@@ -1,55 +1,17 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
import addFormats from 'ajv-formats';
|
|
4
|
-
import { fetchSchema, fetchSupportSchema } from './schemaFetch.js';
|
|
5
|
-
|
|
6
|
-
const SITE_PIN = '1.3.0';
|
|
7
|
-
|
|
8
|
-
let validatorPromise: ReturnType<typeof buildValidator> | null = null;
|
|
9
|
-
|
|
10
|
-
async function buildValidator() {
|
|
11
|
-
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
12
|
-
addFormats(ajv);
|
|
13
|
-
|
|
14
|
-
const [siteSchema, definitionsSchema, graphSchema, ventureEnum] = await Promise.all([
|
|
15
|
-
fetchSchema('content/site.schema.json', SITE_PIN),
|
|
16
|
-
fetchSupportSchema('_definitions/definitions.schema.json'),
|
|
17
|
-
fetchSupportSchema('_definitions/graph.schema.json'),
|
|
18
|
-
fetchSupportSchema('_enums/venture.enum.json'),
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
ajv.addSchema(definitionsSchema as object);
|
|
22
|
-
ajv.addSchema(graphSchema as object);
|
|
23
|
-
ajv.addSchema(ventureEnum as object);
|
|
24
|
-
|
|
25
|
-
return ajv.compile(siteSchema as object);
|
|
26
|
-
}
|
|
27
2
|
|
|
28
3
|
export interface LoadedSite {
|
|
29
4
|
[key: string]: unknown;
|
|
30
5
|
}
|
|
31
6
|
|
|
32
7
|
/**
|
|
33
|
-
* Reads a content/site.schema.json instance from disk
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* and continue with an unvalidated instance.
|
|
8
|
+
* Reads a content/site.schema.json instance from disk. The instance is validated in the
|
|
9
|
+
* site repo's CI against schema-registry (schema-registry content-validate.yml),
|
|
10
|
+
* not here: this public package fetches and carries no schema.
|
|
37
11
|
*/
|
|
38
12
|
export async function loadSite(path: string): Promise<LoadedSite> {
|
|
39
13
|
const raw = readFileSync(path, 'utf-8');
|
|
40
14
|
const instance = JSON.parse(raw);
|
|
41
15
|
|
|
42
|
-
if (!validatorPromise) validatorPromise = buildValidator();
|
|
43
|
-
const validate = await validatorPromise;
|
|
44
|
-
|
|
45
|
-
if (!validate(instance)) {
|
|
46
|
-
const errors = (validate.errors ?? [])
|
|
47
|
-
.map((e) => ` ${e.instancePath || '/'} ${e.message}`)
|
|
48
|
-
.join('\n');
|
|
49
|
-
throw new Error(
|
|
50
|
-
`${path} failed content/site.schema.json@${SITE_PIN} validation:\n${errors}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
16
|
return instance as LoadedSite;
|
|
55
17
|
}
|
package/src/content/loadTool.ts
CHANGED
|
@@ -1,42 +1,4 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
import addFormats from 'ajv-formats';
|
|
4
|
-
import { fetchSchema, fetchSupportSchema } from './schemaFetch.js';
|
|
5
|
-
|
|
6
|
-
const TOOL_PIN = '1.2.0';
|
|
7
|
-
const CAPABILITY_CLAIM_PIN = '0.2.0';
|
|
8
|
-
|
|
9
|
-
let validatorPromise: ReturnType<typeof buildValidator> | null = null;
|
|
10
|
-
|
|
11
|
-
async function buildValidator() {
|
|
12
|
-
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
13
|
-
addFormats(ajv);
|
|
14
|
-
|
|
15
|
-
// tool.schema.json 1.2.0 adopts the content spine (cell refs, themes,
|
|
16
|
-
// strategy) and forbids audit-paint field names, so its $ref chain now
|
|
17
|
-
// reaches cell, content-spine (which itself $refs capability-claim) and
|
|
18
|
-
// forbidden-audit-paint-names -- found building LuhTech-Business's /tools/
|
|
19
|
-
// route against the 1.2.0 pin, which failed "can't resolve reference".
|
|
20
|
-
const [toolSchema, capabilityClaimSchema, definitionsSchema, graphSchema, cellSchema, contentSpineSchema, forbiddenNamesSchema] =
|
|
21
|
-
await Promise.all([
|
|
22
|
-
fetchSchema('content/tool.schema.json', TOOL_PIN),
|
|
23
|
-
fetchSchema('content/capability-claim.schema.json', CAPABILITY_CLAIM_PIN),
|
|
24
|
-
fetchSupportSchema('_definitions/definitions.schema.json'),
|
|
25
|
-
fetchSupportSchema('_definitions/graph.schema.json'),
|
|
26
|
-
fetchSupportSchema('_definitions/cell.schema.json'),
|
|
27
|
-
fetchSupportSchema('_definitions/content-spine.schema.json'),
|
|
28
|
-
fetchSupportSchema('_definitions/forbidden-audit-paint-names.schema.json'),
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
ajv.addSchema(capabilityClaimSchema as object);
|
|
32
|
-
ajv.addSchema(definitionsSchema as object);
|
|
33
|
-
ajv.addSchema(graphSchema as object);
|
|
34
|
-
ajv.addSchema(cellSchema as object);
|
|
35
|
-
ajv.addSchema(contentSpineSchema as object);
|
|
36
|
-
ajv.addSchema(forbiddenNamesSchema as object);
|
|
37
|
-
|
|
38
|
-
return ajv.compile(toolSchema as object);
|
|
39
|
-
}
|
|
40
2
|
|
|
41
3
|
export interface ToolFieldSpec {
|
|
42
4
|
id: string;
|
|
@@ -80,25 +42,13 @@ export interface LoadedTool {
|
|
|
80
42
|
}
|
|
81
43
|
|
|
82
44
|
/**
|
|
83
|
-
* Reads a content/tool.schema.json instance from disk
|
|
84
|
-
*
|
|
85
|
-
*
|
|
45
|
+
* Reads a content/tool.schema.json instance from disk. The instance is validated in the
|
|
46
|
+
* site repo's CI against schema-registry (schema-registry content-validate.yml),
|
|
47
|
+
* not here: this public package fetches and carries no schema.
|
|
86
48
|
*/
|
|
87
49
|
export async function loadTool(path: string): Promise<LoadedTool> {
|
|
88
50
|
const raw = readFileSync(path, 'utf-8');
|
|
89
51
|
const instance = JSON.parse(raw);
|
|
90
52
|
|
|
91
|
-
if (!validatorPromise) validatorPromise = buildValidator();
|
|
92
|
-
const validate = await validatorPromise;
|
|
93
|
-
|
|
94
|
-
if (!validate(instance)) {
|
|
95
|
-
const errors = (validate.errors ?? [])
|
|
96
|
-
.map((e) => ` ${e.instancePath || '/'} ${e.message}`)
|
|
97
|
-
.join('\n');
|
|
98
|
-
throw new Error(
|
|
99
|
-
`${path} failed content/tool.schema.json@${TOOL_PIN} validation:\n${errors}`
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
53
|
return instance as LoadedTool;
|
|
104
54
|
}
|
package/src/lib/assetRequest.ts
CHANGED
|
@@ -40,6 +40,17 @@ export function sourceRefFor(search: string, pathname: string): string {
|
|
|
40
40
|
return SOURCE_REF.test(pageRef) ? pageRef : 'page:home';
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The code a scanned or forwarded copy carried (?c=<code>), sent as
|
|
45
|
+
* referredByCode so the request is attributed to it
|
|
46
|
+
* (d-2026-10-02-eb-asset-request-referred-by-code). Undefined when absent or
|
|
47
|
+
* malformed (gateway pattern ^[A-Za-z0-9_-]{4,64}$).
|
|
48
|
+
*/
|
|
49
|
+
export function referredByCodeFrom(search: string): string | undefined {
|
|
50
|
+
const c = new URLSearchParams(search).get('c');
|
|
51
|
+
return c && /^[A-Za-z0-9_-]{4,64}$/.test(c) ? c : undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
/** The /requests endpoint beside the /assets endpoint the site config names. */
|
|
44
55
|
export function requestEndpointFor(assetRequestEndpoint: string): string {
|
|
45
56
|
return assetRequestEndpoint.replace(/\/assets\/?$/, '/requests');
|
|
@@ -66,6 +77,7 @@ export interface AssetContext {
|
|
|
66
77
|
/** The asset request body. */
|
|
67
78
|
export function assetRequestBody(input: AssetFormInput, ctx: AssetContext) {
|
|
68
79
|
const utm = utmFromSearch(ctx.search);
|
|
80
|
+
const referredByCode = referredByCodeFrom(ctx.search);
|
|
69
81
|
return {
|
|
70
82
|
assetRef: ctx.assetRef,
|
|
71
83
|
sourceRef: sourceRefFor(ctx.search, ctx.pathname),
|
|
@@ -74,6 +86,7 @@ export function assetRequestBody(input: AssetFormInput, ctx: AssetContext) {
|
|
|
74
86
|
persona: PERSONAS.some((p) => p.value === input.persona) ? input.persona : 'unclassified',
|
|
75
87
|
seriesOptIn: input.seriesOptIn === true,
|
|
76
88
|
...(utm ? { utm } : {}),
|
|
89
|
+
...(referredByCode ? { referredByCode } : {}),
|
|
77
90
|
contact: {
|
|
78
91
|
firstName: input.firstName.trim(),
|
|
79
92
|
lastName: input.lastName.trim(),
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// d-2026-10-02-st-paper-landing-three-actions: the paper's one page
|
|
2
|
+
// (/papers/<slug>/) -- its open summary and figures, then Download, Feedback
|
|
3
|
+
// and Share. It reads the whitepaper record (schema-registry
|
|
4
|
+
// content/whitepaper.schema.json 1.3.0). Pure, so the page's script and the
|
|
5
|
+
// tests share one implementation.
|
|
6
|
+
|
|
7
|
+
/** Whitepaper statuses that put a paper's page on the site (L4 approves the final paper first). */
|
|
8
|
+
export const PAPER_LIVE_STATUSES = ['APPROVED', 'COMPLETE'] as const;
|
|
9
|
+
|
|
10
|
+
export function isPaperLive(status: unknown): boolean {
|
|
11
|
+
return (PAPER_LIVE_STATUSES as readonly unknown[]).includes(status);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The gateway's delivery token (tool-submission.routes.ts GET /assets/:token). */
|
|
15
|
+
export const TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
16
|
+
/** A printed or forwarded copy's code (business-tools link-codes.ts CODE_PATTERN). */
|
|
17
|
+
export const CODE_PATTERN = /^[A-Za-z0-9_-]{4,64}$/;
|
|
18
|
+
|
|
19
|
+
export type Arrival = { by: 'token'; token: string } | { by: 'code'; code: string } | { by: 'none' };
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How the visitor arrived: ?t=<token> from the delivery email, ?c=<code> from
|
|
23
|
+
* a scanned or forwarded copy, else neither. A malformed value counts as none.
|
|
24
|
+
*/
|
|
25
|
+
export function arrivalFrom(search: string): Arrival {
|
|
26
|
+
const params = new URLSearchParams(search);
|
|
27
|
+
const t = params.get('t');
|
|
28
|
+
if (t && TOKEN_PATTERN.test(t)) return { by: 'token', token: t };
|
|
29
|
+
const c = params.get('c');
|
|
30
|
+
if (c && CODE_PATTERN.test(c)) return { by: 'code', code: c };
|
|
31
|
+
return { by: 'none' };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The gateway's download route beside the asset request endpoint the site config names. */
|
|
35
|
+
export function downloadUrlFor(assetRequestEndpoint: string, token: string): string {
|
|
36
|
+
return `${assetRequestEndpoint.replace(/\/+$/, '')}/${encodeURIComponent(token)}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The non-personal link to share: the page URL with no query and no fragment, so never a token or code. */
|
|
40
|
+
export function shareUrlFor(pageUrl: string): string {
|
|
41
|
+
const u = new URL(pageUrl);
|
|
42
|
+
return `${u.origin}${u.pathname}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function linkedInShareUrl(shareUrl: string): string {
|
|
46
|
+
return `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function mailtoShareUrl(shareUrl: string, title: string): string {
|
|
50
|
+
return `mailto:?subject=${encodeURIComponent(title)}&body=${encodeURIComponent(shareUrl)}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The Feedback form is open only when the site config names both its endpoint and its Turnstile site key. */
|
|
54
|
+
export function feedbackOpen(leadCapture: { feedbackEndpoint?: string; turnstileSiteKey?: string } | undefined): boolean {
|
|
55
|
+
return Boolean(leadCapture?.feedbackEndpoint && leadCapture?.turnstileSiteKey);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface FeedbackInput {
|
|
59
|
+
roleId: string;
|
|
60
|
+
answers: Record<string, string>;
|
|
61
|
+
publishConsent: boolean;
|
|
62
|
+
firstName: string;
|
|
63
|
+
lastName: string;
|
|
64
|
+
email: string;
|
|
65
|
+
company?: string;
|
|
66
|
+
turnstileToken: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The body business-tools POST /api/public/papers/feedback takes
|
|
71
|
+
* (apps/dashboard/src/lib/paper-feedback.ts parseSubmission): answers keyed by
|
|
72
|
+
* questionId (blank ones left out), the role, the consent box, how the reader
|
|
73
|
+
* arrived (a code arrival names its code), name and email on both arrivals,
|
|
74
|
+
* and the Turnstile token. Null when the reader arrived by neither.
|
|
75
|
+
*/
|
|
76
|
+
export function feedbackBody(input: FeedbackInput, ctx: { assetRef: string; arrival: Arrival; sourceRef?: string }) {
|
|
77
|
+
if (ctx.arrival.by === 'none') return null;
|
|
78
|
+
const answers: Record<string, string> = {};
|
|
79
|
+
for (const [questionId, value] of Object.entries(input.answers)) {
|
|
80
|
+
const v = String(value ?? '').trim();
|
|
81
|
+
if (v) answers[questionId] = v.slice(0, 4000);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
assetRef: ctx.assetRef,
|
|
85
|
+
roleId: input.roleId,
|
|
86
|
+
answers,
|
|
87
|
+
publishConsent: input.publishConsent === true,
|
|
88
|
+
arrivedBy: ctx.arrival.by,
|
|
89
|
+
...(ctx.arrival.by === 'code' ? { code: ctx.arrival.code } : {}),
|
|
90
|
+
...(ctx.sourceRef ? { sourceRef: ctx.sourceRef } : {}),
|
|
91
|
+
contact: {
|
|
92
|
+
firstName: input.firstName.trim(),
|
|
93
|
+
lastName: input.lastName.trim(),
|
|
94
|
+
email: input.email.trim(),
|
|
95
|
+
...(input.company?.trim() ? { company: input.company.trim() } : {}),
|
|
96
|
+
},
|
|
97
|
+
turnstileToken: input.turnstileToken,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** What the reader is told for each answer the feedback endpoint can give. */
|
|
102
|
+
export function feedbackMessage(status: number, error?: string): string {
|
|
103
|
+
if (status === 201) return 'Thank you -- your answers reached us.';
|
|
104
|
+
if (status === 503) return 'Feedback is not open yet.';
|
|
105
|
+
if (status === 429) return 'Too many submissions from here; try again in an hour.';
|
|
106
|
+
if (status === 403) return 'The challenge did not pass; reload the page and try again.';
|
|
107
|
+
if (status === 400 && error) return error;
|
|
108
|
+
return 'Something went wrong. Try again in a moment.';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface PaperFigure {
|
|
112
|
+
figureId: string;
|
|
113
|
+
value: string;
|
|
114
|
+
unit?: string;
|
|
115
|
+
caption?: string;
|
|
116
|
+
estimate?: boolean;
|
|
117
|
+
provenance: { sourceRef: string; public: boolean; observedAt?: string };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface PaperRecord {
|
|
121
|
+
title: string;
|
|
122
|
+
subtitle?: string;
|
|
123
|
+
summary: string;
|
|
124
|
+
status: string;
|
|
125
|
+
figures?: PaperFigure[];
|
|
126
|
+
openFigureIds?: string[];
|
|
127
|
+
pdfAssetRef?: string;
|
|
128
|
+
feedbackForm?: {
|
|
129
|
+
roles: { roleId: string; label: string; persona?: string }[];
|
|
130
|
+
questions: { questionId: string; prompt: string; answerType: 'text' | 'choice'; choices?: { choiceId: string; label: string }[]; allowOther?: boolean }[];
|
|
131
|
+
};
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The paper's open summary and figures as page sections, so the page renders
|
|
137
|
+
* them through the same section components as the landing page it replaces
|
|
138
|
+
* (d-2026-10-01-eb-whitepaper-hybrid-gate): a hero with the summary's first
|
|
139
|
+
* paragraph, a summary section with the rest, and the open figures with
|
|
140
|
+
* their captions.
|
|
141
|
+
*/
|
|
142
|
+
export function paperSections(paper: PaperRecord, slug: string) {
|
|
143
|
+
const paragraphs = paper.summary.split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean);
|
|
144
|
+
const [lede, ...rest] = paragraphs;
|
|
145
|
+
const open = (paper.openFigureIds ?? []).map((id) => {
|
|
146
|
+
const f = (paper.figures ?? []).find((x) => x.figureId === id);
|
|
147
|
+
if (!f) throw new Error(`paper ${slug}: openFigureIds names ${id}, which is not in figures[]`);
|
|
148
|
+
return f;
|
|
149
|
+
});
|
|
150
|
+
const sections: Record<string, unknown>[] = [
|
|
151
|
+
{
|
|
152
|
+
sectionId: slug,
|
|
153
|
+
sectionKind: 'hero',
|
|
154
|
+
heading: paper.title,
|
|
155
|
+
...(paper.subtitle ? { subheading: paper.subtitle } : {}),
|
|
156
|
+
...(lede ? { blocks: [{ blockType: 'lede', text: lede }] } : {}),
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
if (rest.length) {
|
|
160
|
+
sections.push({
|
|
161
|
+
sectionId: `${slug}-summary`,
|
|
162
|
+
sectionKind: 'approach',
|
|
163
|
+
heading: 'Summary',
|
|
164
|
+
blocks: rest.map((text) => ({ blockType: 'paragraph', text })),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (open.length) {
|
|
168
|
+
sections.push({
|
|
169
|
+
sectionId: `${slug}-figures`,
|
|
170
|
+
sectionKind: 'proof',
|
|
171
|
+
heading: 'What the paper finds',
|
|
172
|
+
blocks: open.filter((f) => f.caption).map((f) => ({ blockType: 'paragraph', text: f.caption })),
|
|
173
|
+
figures: open.map((f) => ({
|
|
174
|
+
figureId: f.figureId,
|
|
175
|
+
value: f.estimate && !/estimate/i.test(f.value) ? `${f.value} (estimate)` : f.value,
|
|
176
|
+
...(f.unit ? { unit: f.unit } : {}),
|
|
177
|
+
provenance: f.provenance,
|
|
178
|
+
})),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return sections;
|
|
182
|
+
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://schemas.luh.tech/content/capability-claim.schema.json",
|
|
4
|
-
"title": "Capability Claim",
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"description": "A statement about what the platform does, carried by any rendered surface. Marked method or built. A claim marked built must resolve to a register entry; one that does not fails CI. Reconciled with content/article.schema.json's older, distinct claim shape (v2.0.0): article's own claims now $ref this schema rather than an embedded, incompatible definition. kind and sourcedStatus are different axes, not restated forms of each other -- kind names WHAT TYPE of statement this is (method: how the system works; built: this exists and runs), sourcedStatus names WHAT MATURITY the referenced feature has reached, per its real register entry. Widening kind's two values down into sourcedStatus's four (or vice versa) would lose a real distinction either schema already depends on, so both fields coexist.",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"additionalProperties": false,
|
|
9
|
-
"required": [
|
|
10
|
-
"claimId",
|
|
11
|
-
"kind",
|
|
12
|
-
"text"
|
|
13
|
-
],
|
|
14
|
-
"properties": {
|
|
15
|
-
"claimId": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"pattern": "^[a-z][a-z0-9-]*$"
|
|
18
|
-
},
|
|
19
|
-
"kind": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"enum": [
|
|
22
|
-
"method",
|
|
23
|
-
"built"
|
|
24
|
-
],
|
|
25
|
-
"description": "method: this is how the model works. built: this exists and runs today."
|
|
26
|
-
},
|
|
27
|
-
"text": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"minLength": 1
|
|
30
|
-
},
|
|
31
|
-
"featureRef": {
|
|
32
|
-
"type": [
|
|
33
|
-
"string",
|
|
34
|
-
"null"
|
|
35
|
-
],
|
|
36
|
-
"pattern": "^urn:luhtech:[a-z][a-z0-9-]*:feature:[a-z0-9-]+$",
|
|
37
|
-
"description": "Required when kind is built. The register entry the claim resolves to."
|
|
38
|
-
},
|
|
39
|
-
"sourcedStatus": {
|
|
40
|
-
"type": [
|
|
41
|
-
"string",
|
|
42
|
-
"null"
|
|
43
|
-
],
|
|
44
|
-
"enum": [
|
|
45
|
-
"operational",
|
|
46
|
-
"partial",
|
|
47
|
-
"planned",
|
|
48
|
-
"concept",
|
|
49
|
-
null
|
|
50
|
-
],
|
|
51
|
-
"description": "Optional graduated maturity, matching content/article.schema.json's original claim vocabulary. Independent of kind -- a method claim can be sourcedStatus:concept (describes an approach not yet built at all) just as easily as a built claim can be sourcedStatus:partial (exists, not complete). Absent when the claim doesn't need finer graduation than kind alone provides (e.g. a claim mechanically derived from a single roadmap feature's status field, per the pipeline that emits content/deck-record.schema.json instances)."
|
|
52
|
-
},
|
|
53
|
-
"observedAt": {
|
|
54
|
-
"type": [
|
|
55
|
-
"string",
|
|
56
|
-
"null"
|
|
57
|
-
],
|
|
58
|
-
"format": "date"
|
|
59
|
-
},
|
|
60
|
-
"note": {
|
|
61
|
-
"type": [
|
|
62
|
-
"string",
|
|
63
|
-
"null"
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"allOf": [
|
|
68
|
-
{
|
|
69
|
-
"if": {
|
|
70
|
-
"properties": {
|
|
71
|
-
"kind": {
|
|
72
|
-
"const": "built"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"required": [
|
|
76
|
-
"kind"
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
"then": {
|
|
80
|
-
"required": [
|
|
81
|
-
"featureRef"
|
|
82
|
-
],
|
|
83
|
-
"properties": {
|
|
84
|
-
"featureRef": {
|
|
85
|
-
"type": "string"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Fetches the live, version-pinned schemas this package validates against.
|
|
2
|
-
// Pins live in package.json's luhtech.schemaPins -- the immutable
|
|
3
|
-
// https://schemas.luh.tech/v/{version}/{path} convention (d-2026-08-28-eb-
|
|
4
|
-
// versioned-schema-serving), not the floating "latest" alias, so a schema
|
|
5
|
-
// change upstream never silently changes what an already-shipped site
|
|
6
|
-
// build validates against.
|
|
7
|
-
//
|
|
8
|
-
// content/capability-claim.schema.json is a known, flagged gap: it 404s at
|
|
9
|
-
// both its bare and versioned live URLs (a schema-registry publish-pipeline
|
|
10
|
-
// issue, out of scope for this package -- see the site-template README).
|
|
11
|
-
// This loader falls back to a vendored local copy for that one schema only,
|
|
12
|
-
// fetched from the real schema-registry source (not fabricated), and never
|
|
13
|
-
// silently swallows a 404 for any other schema.
|
|
14
|
-
//
|
|
15
|
-
// The fallback is a static JSON import, not a runtime readFileSync -- a
|
|
16
|
-
// bundled build (Vite/Rollup, which Astro uses) relocates compiled chunks
|
|
17
|
-
// without knowing to also copy an fs-read sidecar file, producing an ENOENT
|
|
18
|
-
// at build time (found live during the first real consumer build, GTM-L2
|
|
19
|
-
// C3). A static import lets the bundler inline the JSON content itself,
|
|
20
|
-
// sidestepping the asset-copy problem entirely.
|
|
21
|
-
|
|
22
|
-
import capabilityClaimFallback from './_vendored-schema-fallback/capability-claim.schema.json';
|
|
23
|
-
|
|
24
|
-
const VENDORED_FALLBACK: Record<string, unknown> = {
|
|
25
|
-
'content/capability-claim.schema.json': capabilityClaimFallback,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const cache = new Map<string, unknown>();
|
|
29
|
-
|
|
30
|
-
export async function fetchSchema(pinnedPath: string, version: string): Promise<unknown> {
|
|
31
|
-
const cacheKey = `${pinnedPath}@${version}`;
|
|
32
|
-
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
|
33
|
-
|
|
34
|
-
const url = `https://schemas.luh.tech/v/${version}/${pinnedPath}`;
|
|
35
|
-
let schema: unknown;
|
|
36
|
-
try {
|
|
37
|
-
const res = await fetch(url);
|
|
38
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
39
|
-
schema = await res.json();
|
|
40
|
-
} catch (err) {
|
|
41
|
-
const fallback = VENDORED_FALLBACK[pinnedPath];
|
|
42
|
-
if (!fallback) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Failed to fetch pinned schema ${pinnedPath}@${version} from ${url}: ${(err as Error).message}. ` +
|
|
45
|
-
`No vendored fallback exists for this schema -- this is a real failure, not a known gap.`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
console.warn(
|
|
49
|
-
`[site-template] ${pinnedPath}@${version} unreachable at ${url} (known publish-pipeline gap) -- using vendored fallback.`
|
|
50
|
-
);
|
|
51
|
-
schema = fallback;
|
|
52
|
-
}
|
|
53
|
-
cache.set(cacheKey, schema);
|
|
54
|
-
return schema;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Unversioned support schemas (definitions, enums) the pinned schemas $ref -- these
|
|
58
|
-
* are stable, shared vocabulary, not independently versioned/pinned. */
|
|
59
|
-
export async function fetchSupportSchema(path: string): Promise<unknown> {
|
|
60
|
-
const cacheKey = `support:${path}`;
|
|
61
|
-
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
|
62
|
-
const url = `https://schemas.luh.tech/${path}`;
|
|
63
|
-
const res = await fetch(url);
|
|
64
|
-
if (!res.ok) {
|
|
65
|
-
throw new Error(`Failed to fetch support schema ${path} from ${url}: HTTP ${res.status}`);
|
|
66
|
-
}
|
|
67
|
-
const schema = await res.json();
|
|
68
|
-
cache.set(cacheKey, schema);
|
|
69
|
-
return schema;
|
|
70
|
-
}
|