create-ailk 0.37.0 → 0.38.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 +149 -2
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +7 -2
- package/dist/add-route.js +28 -13
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +9 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +67 -0
- package/dist/routes.d.ts +103 -0
- package/dist/routes.js +708 -0
- package/dist/site-manifest.js +1 -1
- package/dist/site-roster.d.ts +2 -1
- package/dist/site-roster.js +30 -8
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +18 -0
- package/dist/surfaces.js +47 -282
- package/dist/sync-routes.d.ts +28 -1
- package/dist/sync-routes.js +144 -11
- package/dist/template-record.d.ts +11 -0
- package/dist/template-record.js +18 -0
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +31 -2
- package/dist/update.js +627 -99
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +62 -20
- package/templates/apps/web/account.config.tsx +101 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
- package/templates/apps/web/app/[locale]/layout.tsx +45 -28
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/i18n/request.ts +44 -1
- package/templates/apps/web/jest.config.cjs +13 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/messages/en.json +8 -684
- package/templates/apps/web/middleware.ts +3 -1
- package/templates/apps/web/next.config.mjs +27 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +48 -47
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The template routes a site has declined (#11260) — `customizations.yaml`'s
|
|
3
|
+
* optional top-level `declined_routes` list.
|
|
4
|
+
*
|
|
5
|
+
* A site may drop one template route on purpose (wendihenry sells from
|
|
6
|
+
* `/pricing` alone, so it carries no `pricing/[slug]`). Without a record the
|
|
7
|
+
* tooling reads, every `sync-routes` check reports the route missing and the
|
|
8
|
+
* next `--apply` copies it back. An entry here is that record:
|
|
9
|
+
*
|
|
10
|
+
* declined_routes:
|
|
11
|
+
* - route: "pricing/[slug]" # a template route, under apps/web/app/[locale]/
|
|
12
|
+
* reason: "this site sells from /pricing alone"
|
|
13
|
+
* decided: "Site Owner, 2026-11-02" # <decider>, <YYYY-MM-DD>
|
|
14
|
+
*
|
|
15
|
+
* A declined route covers its whole directory, sub-routes included:
|
|
16
|
+
* `sync-routes` names it under "Declined by this site" (never missing) and
|
|
17
|
+
* never copies it, and `create-ailk update` never writes a file under it.
|
|
18
|
+
*
|
|
19
|
+
* Read by line, like `routes.ts`'s `readRecorded` — create-ailk carries no
|
|
20
|
+
* YAML parser. Only each entry's `route` is read here; the scaffold's
|
|
21
|
+
* `tools/lint-architecture.ts` owns the file's full validation (a reason, a
|
|
22
|
+
* decider/date line, a known template route) and refuses any layout this
|
|
23
|
+
* reader cannot read: a flow list or map, or a block scalar.
|
|
24
|
+
*
|
|
25
|
+
* Pure module: no `import.meta.url`, so jest imports it directly.
|
|
26
|
+
*/
|
|
27
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
28
|
+
import { join } from "node:path";
|
|
29
|
+
import { ROUTE_ROOT } from "./surfaces.js";
|
|
30
|
+
/** The site file the list lives in. */
|
|
31
|
+
export const DECLINED_ROUTES_FILE = "customizations.yaml";
|
|
32
|
+
/**
|
|
33
|
+
* The `route` of every `declined_routes` entry in `<siteDir>/customizations.yaml`,
|
|
34
|
+
* sorted and deduplicated, each without a leading or trailing `/`. Empty when
|
|
35
|
+
* the file or the key is absent. Block (`- route: …`) and flow
|
|
36
|
+
* (`declined_routes: []`) forms; quoted or bare values.
|
|
37
|
+
*/
|
|
38
|
+
export function readDeclinedRoutes(siteDir) {
|
|
39
|
+
const path = join(siteDir, DECLINED_ROUTES_FILE);
|
|
40
|
+
if (!existsSync(path))
|
|
41
|
+
return [];
|
|
42
|
+
const out = new Set();
|
|
43
|
+
let inList = false;
|
|
44
|
+
for (const raw of readFileSync(path, "utf8").split(/\r?\n/)) {
|
|
45
|
+
const line = raw.replace(/\s+#.*$/, "");
|
|
46
|
+
if (line.trim() === "" || line.trimStart().startsWith("#"))
|
|
47
|
+
continue;
|
|
48
|
+
// A top-level key ends the list; a column-0 `- ` item is still inside it.
|
|
49
|
+
if (/^\S/.test(line) && !/^-\s/.test(line)) {
|
|
50
|
+
inList = /^declined_routes:/.test(line);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (!inList)
|
|
54
|
+
continue;
|
|
55
|
+
const route = /^\s*(?:-\s+)?route:\s*(.+)$/.exec(line)?.[1];
|
|
56
|
+
if (route === undefined)
|
|
57
|
+
continue;
|
|
58
|
+
const value = route.trim().replace(/^["']|["']$/g, "").replace(/^\/+|\/+$/g, "");
|
|
59
|
+
if (value !== "")
|
|
60
|
+
out.add(value);
|
|
61
|
+
}
|
|
62
|
+
return [...out].sort();
|
|
63
|
+
}
|
|
64
|
+
/** The declined entry covering `route` (ROUTE_ROOT-relative) — itself or an ancestor — or undefined. */
|
|
65
|
+
export function declinedRouteFor(route, declined) {
|
|
66
|
+
return declined.find((d) => route === d || route.startsWith(`${d}/`));
|
|
67
|
+
}
|
|
68
|
+
/** The declined entry whose directory holds site-relative `path`, or undefined. */
|
|
69
|
+
export function declinedRouteOfPath(path, declined) {
|
|
70
|
+
if (!path.startsWith(`${ROUTE_ROOT}/`))
|
|
71
|
+
return undefined;
|
|
72
|
+
const rel = path.slice(ROUTE_ROOT.length + 1);
|
|
73
|
+
return declined.find((d) => rel.startsWith(`${d}/`));
|
|
74
|
+
}
|
|
@@ -31,12 +31,6 @@ export declare const SPOKE_BILLING_ACTION_PATH = "apps/web/app/[locale]/(authed)
|
|
|
31
31
|
* (#9142): a spoke sells through its hub's Offerings buy route.
|
|
32
32
|
*/
|
|
33
33
|
export declare const SPOKE_CHECKOUT_ROUTE_FILES: readonly string[];
|
|
34
|
-
/**
|
|
35
|
-
* The spoke files that may import @working-theory/spoke-checkout to READ a
|
|
36
|
-
* paid session, and nothing else: the thank-you page's `readPaidCheckoutEmail`
|
|
37
|
-
* (#8757 D13).
|
|
38
|
-
*/
|
|
39
|
-
export declare const SPOKE_CHECKOUT_READER_FILES: readonly string[];
|
|
40
34
|
/** The forbidden patterns a spoke's apps/web carries (#7873, brief Part 2 §2; #8748). The fulfilment pattern that guarded `lib/checkout.ts` retired with it (#9142). */
|
|
41
35
|
export declare const SPOKE_WEB_FORBIDDEN_PATTERNS: readonly ForbiddenPattern[];
|
|
42
36
|
/** The same three for a spoke's kept apps/mcp — no MCP file may import the package (#7873). */
|
|
@@ -18,7 +18,7 @@ import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH } from "./pa
|
|
|
18
18
|
import { SITE_CHROME_PATH } from "./site-chrome.js";
|
|
19
19
|
import { SITE_FONTS_PATH } from "./site-fonts.js";
|
|
20
20
|
import { SITE_LISTING_PATH } from "./site-listing-path.js";
|
|
21
|
-
import { SPOKE_CHECKOUT_CONFIG_PATH
|
|
21
|
+
import { SPOKE_CHECKOUT_CONFIG_PATH } from "./spoke-checkout.js";
|
|
22
22
|
import { CORE_SURFACE_PATHS, NAV_CONFIG_PATH, RECOGNIZED_SURFACES, resolveSurfaces, } from "./surfaces.js";
|
|
23
23
|
import { SPOKE_SEAM_FILES } from "./topology.js";
|
|
24
24
|
/** The npm scope a site consumes and never forks (#9191). */
|
|
@@ -51,14 +51,6 @@ export const SPOKE_BILLING_ACTION_PATH = "apps/web/app/[locale]/(authed)/account
|
|
|
51
51
|
export const SPOKE_CHECKOUT_ROUTE_FILES = Object.freeze([
|
|
52
52
|
SPOKE_BILLING_ACTION_PATH,
|
|
53
53
|
]);
|
|
54
|
-
/**
|
|
55
|
-
* The spoke files that may import @working-theory/spoke-checkout to READ a
|
|
56
|
-
* paid session, and nothing else: the thank-you page's `readPaidCheckoutEmail`
|
|
57
|
-
* (#8757 D13).
|
|
58
|
-
*/
|
|
59
|
-
export const SPOKE_CHECKOUT_READER_FILES = Object.freeze([
|
|
60
|
-
"apps/web/app/[locale]/checkout/thank-you/page.tsx",
|
|
61
|
-
]);
|
|
62
54
|
/**
|
|
63
55
|
* A line-level regex for an import of `specifier` or one of its subpaths, in
|
|
64
56
|
* every form the line can take: `from "…"` (a static or re-export, including
|
|
@@ -75,7 +67,7 @@ function specifierForm(specifier) {
|
|
|
75
67
|
/** P1 with no exclusions — a kept apps/mcp's form; apps/web adds the route files. */
|
|
76
68
|
const SPOKE_CHECKOUT_PATTERN = Object.freeze({
|
|
77
69
|
pattern: specifierForm("@working-theory/spoke-checkout"),
|
|
78
|
-
reason: "Spoke checkout: only the billing action
|
|
70
|
+
reason: "Spoke checkout: only the billing action may import @working-theory/spoke-checkout (brief Part 2 §2, #7873, #8217, #8757, #9142, #11253)",
|
|
79
71
|
});
|
|
80
72
|
const STRIPE_CLIENT_PATTERN = Object.freeze({
|
|
81
73
|
pattern: specifierForm("@working-theory/stripe-client"),
|
|
@@ -89,7 +81,9 @@ const STRIPE_SDK_PATTERN = Object.freeze({
|
|
|
89
81
|
export const SPOKE_WEB_FORBIDDEN_PATTERNS = Object.freeze([
|
|
90
82
|
Object.freeze({
|
|
91
83
|
...SPOKE_CHECKOUT_PATTERN,
|
|
92
|
-
|
|
84
|
+
// #11253 D8 — the thank-you page's paid-session read now ships in
|
|
85
|
+
// @working-theory/ui-commerce; no file in a spoke's apps/web reads one.
|
|
86
|
+
paths_excluded: [...SPOKE_CHECKOUT_ROUTE_FILES],
|
|
93
87
|
}),
|
|
94
88
|
STRIPE_CLIENT_PATTERN,
|
|
95
89
|
STRIPE_SDK_PATTERN,
|
|
@@ -365,12 +359,12 @@ export function deriveArchitecture(modules = ["marketing"], surfaces, options =
|
|
|
365
359
|
modulePaths.push(`${s.installRoot.replace(/\/$/, "")}/**`);
|
|
366
360
|
modulePaths.push(...(s.patches ?? []).map((p) => p.target));
|
|
367
361
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
362
|
+
// #11253 — the checkout and purchase route files are generated, which the
|
|
363
|
+
// site's lint admits by their header (`isGeneratedRoute`, #11252); the
|
|
364
|
+
// config and the stamp are commerce `ownedFiles`, so neither needs a glob.
|
|
371
365
|
const customizations = {
|
|
372
366
|
manifest: "customizations.yaml",
|
|
373
|
-
scaffold_paths: sortedUnion(generatorPaths,
|
|
367
|
+
scaffold_paths: sortedUnion(generatorPaths, modulePaths.filter((p) => p.startsWith("apps/") && inScaffold(p))),
|
|
374
368
|
};
|
|
375
369
|
const doc = {
|
|
376
370
|
version: ARCHITECTURE_BASE.version,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { APPLY_DESIGN_HELP, UnreadChromeError, applyDesign, formatApplyDesignRep
|
|
|
14
14
|
export type { HomeSeedOutcome } from "./design-home.js";
|
|
15
15
|
export { SITE_ROSTER_PATH, readSiteRoster, siteRosterProblems, } from "./site-roster.js";
|
|
16
16
|
export { SYNC_ROUTES_HELP, formatSyncRoutesReport, listTemplateRouteDirs, parseSyncRoutesArgs, syncRoutes, type RouteReport, type SyncRoutesOptions, type SyncRoutesResult, } from "./sync-routes.js";
|
|
17
|
+
export { ROUTES_APP_DIR, ROUTES_HELP, RoutesRefusedError, checkRoutes, formatRoutesReport, parseRouteManifest, parseRoutesArgs, readRouteManifests, renderRouteFile, routesFailing, writeRoutes, type ManifestMessages, type RecordedRoute, type RouteEntry, type RouteKind, type RouteManifest, type RoutesArgs, type RoutesDrift, type WriteRoutesResult, } from "./routes.js";
|
|
17
18
|
export { deriveArchitecture } from "./derive-architecture.js";
|
|
18
19
|
export { CORE_ROUTE_DIRS, CORE_SURFACE_PATHS, NAV_CONFIG_PATH, GATEABLE_SURFACES, MODULE_SURFACES, RECOGNIZED_SURFACES, ROUTE_SINCE, SurfaceError, excludedContentPaths, excludedRoutePaths, isUnservedSurfaceContent, isUnservedSurfaceRoute, parseSurfaces, renderNavConfig, resolveSurfaces, surfaceForRouteDir, type Surface, } from "./surfaces.js";
|
|
19
20
|
export { substituteMarkers, substituteWorkspaceVersions, type MarkerMap, type WorkspaceVersionMap, } from "./substitute.js";
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,9 @@ export { SITE_ROSTER_PATH, readSiteRoster, siteRosterProblems, } from "./site-ro
|
|
|
25
25
|
// `create-ailk sync-routes` (#4986) — the template-route drift check + copy.
|
|
26
26
|
// The pure module is exported so tooling can run it against any template dir.
|
|
27
27
|
export { SYNC_ROUTES_HELP, formatSyncRoutesReport, listTemplateRouteDirs, parseSyncRoutesArgs, syncRoutes, } from "./sync-routes.js";
|
|
28
|
+
// `create-ailk routes --write | --check` (#11219, ADR 0040) — the one
|
|
29
|
+
// route-file generator over the installed page packages' manifests.
|
|
30
|
+
export { ROUTES_APP_DIR, ROUTES_HELP, RoutesRefusedError, checkRoutes, formatRoutesReport, parseRouteManifest, parseRoutesArgs, readRouteManifests, renderRouteFile, routesFailing, writeRoutes, } from "./routes.js";
|
|
28
31
|
// The module-set → architecture.yaml derivation. Exported so the sync path
|
|
29
32
|
// (re-derive after a module is added) can re-run it (spec #3787 §2.1). The
|
|
30
33
|
// module→slice registry it composes is an internal detail, deliberately not
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* the collection (D6), and an API without it (`402`, `403`, `404`) turns the
|
|
20
20
|
* pass off for the run, so pages import inline as they did before.
|
|
21
21
|
*
|
|
22
|
+
* `seedTopics` (below) is the seed file's other half: each of its `topics[]`
|
|
23
|
+
* becomes one Topic holding all its keywords (lang-topic-fields).
|
|
24
|
+
*
|
|
22
25
|
* The key travels only as `authorization: Bearer <key>`, never across a
|
|
23
26
|
* redirect; of an API answer only a status and a `[a-z0-9_]` code reach a
|
|
24
27
|
* line, and no line carries an answer's words (SEC-7876-S1).
|
|
@@ -124,4 +127,94 @@ export declare function renderChangeLine(c: LanguageImportResult["renderChanges"
|
|
|
124
127
|
export declare function languageCountsLine(result: LanguageImportResult, apply: boolean): string;
|
|
125
128
|
/** Every line D7 prints, in order: items, counts, render changes, collisions, top-ups, dropped kickers, displacements. */
|
|
126
129
|
export declare function languageLines(result: LanguageImportResult, apply: boolean): string[];
|
|
130
|
+
/** One keyword of a seed topic, as the seed file carries it. */
|
|
131
|
+
export interface SeedTopicKeyword {
|
|
132
|
+
phrase: string;
|
|
133
|
+
monthlySearches?: number;
|
|
134
|
+
/** `YYYY-MM` or `YYYY-MM-DD`: when the number was read. */
|
|
135
|
+
asOf?: string;
|
|
136
|
+
primary?: boolean;
|
|
137
|
+
}
|
|
138
|
+
/** One seed topic, as the seed file carries it. */
|
|
139
|
+
export interface SeedTopic {
|
|
140
|
+
slug: string;
|
|
141
|
+
name: string;
|
|
142
|
+
/** The site path of the topic's pillar page. */
|
|
143
|
+
pillar?: string;
|
|
144
|
+
keywords: SeedTopicKeyword[];
|
|
145
|
+
}
|
|
146
|
+
/** One stored keyword row (`languageTopicKeywordSchema`, restated: no runtime dep). */
|
|
147
|
+
export interface TopicRow {
|
|
148
|
+
phrase: string;
|
|
149
|
+
searches: number | null;
|
|
150
|
+
competition: "low" | "medium" | "high" | null;
|
|
151
|
+
competitionIndex: number | null;
|
|
152
|
+
topBid: number | null;
|
|
153
|
+
yoyChange: number | "∞" | null;
|
|
154
|
+
threeMonthChange: number | "∞" | null;
|
|
155
|
+
pulledAt: string | null;
|
|
156
|
+
note?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface TopicKeyword extends TopicRow {
|
|
159
|
+
primary?: true;
|
|
160
|
+
variants: (TopicRow & {
|
|
161
|
+
keep: boolean;
|
|
162
|
+
})[];
|
|
163
|
+
}
|
|
164
|
+
/** A Topic's words (`languageTopicWordsSchema`, restated); other stored keys pass through untouched. */
|
|
165
|
+
export interface TopicWords {
|
|
166
|
+
title: string;
|
|
167
|
+
pillar?: string;
|
|
168
|
+
keywords: TopicKeyword[];
|
|
169
|
+
[key: string]: unknown;
|
|
170
|
+
}
|
|
171
|
+
export type TopicSeedResult = "created" | "updated" | "unchanged" | "failed";
|
|
172
|
+
export interface TopicSeedReport {
|
|
173
|
+
topics: {
|
|
174
|
+
slug: string;
|
|
175
|
+
result: TopicSeedResult;
|
|
176
|
+
added: number;
|
|
177
|
+
updated: number;
|
|
178
|
+
reason?: string;
|
|
179
|
+
}[];
|
|
180
|
+
counts: Record<TopicSeedResult, number>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A seed keyword's `asOf` as the pull datetime it stands for (midnight UTC on
|
|
184
|
+
* its day, or on the 1st of its month), or `null` for none or a date that is
|
|
185
|
+
* not a real one.
|
|
186
|
+
*/
|
|
187
|
+
export declare function asOfDatetime(asOf: string | undefined): string | null;
|
|
188
|
+
/**
|
|
189
|
+
* A seed file's `topics[]`, checked: `[]` when the file has none. Throws,
|
|
190
|
+
* naming the topic, on a shape the hub would refuse, so nothing is sent from
|
|
191
|
+
* a bad file.
|
|
192
|
+
*/
|
|
193
|
+
export declare function seedTopicsOf(seed: unknown): SeedTopic[];
|
|
194
|
+
/**
|
|
195
|
+
* A seed topic applied to a Topic's words (`null` for none yet). Each seed
|
|
196
|
+
* keyword matching a stored row (trimmed, case- and space-insensitive) keeps
|
|
197
|
+
* the stored spelling, place, variants and note, and takes the seed's number
|
|
198
|
+
* only when the seed's `asOf` is newer than the row's last pull, so a later
|
|
199
|
+
* Keyword Planner import is never overwritten by an older seed. Every other
|
|
200
|
+
* seed keyword becomes a keyword of its own, in the seed's spelling — the
|
|
201
|
+
* primary first. The seed's primary is marked only when the Topic has none
|
|
202
|
+
* and the phrase is a keyword rather than a variant; its pillar is set only
|
|
203
|
+
* when the Topic has none; its name titles only a new Topic. Pure; applying
|
|
204
|
+
* the same seed twice changes nothing the second time.
|
|
205
|
+
*/
|
|
206
|
+
export declare function applySeedTopic(stored: TopicWords | null, seed: SeedTopic): {
|
|
207
|
+
words: TopicWords;
|
|
208
|
+
added: number;
|
|
209
|
+
updated: number;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Write each seed topic to the workspace as one Topic (`PUT …/language/topic/<slug>`):
|
|
213
|
+
* created when the workspace has none, saved over its draft tip when the seed
|
|
214
|
+
* changes it, untouched when it does not. A topic that fails is reported and
|
|
215
|
+
* the rest still run.
|
|
216
|
+
*/
|
|
217
|
+
export declare function seedTopics(topics: readonly SeedTopic[], options: LanguageImportOptions): Promise<TopicSeedReport>;
|
|
218
|
+
/** One line per seed topic, then the counts, in the dry run's verbs or `--apply`'s. */
|
|
219
|
+
export declare function topicSeedLines(report: TopicSeedReport, apply: boolean): string[];
|
|
127
220
|
export {};
|
package/dist/language-import.js
CHANGED
|
@@ -106,6 +106,50 @@ function entriesOf(section) {
|
|
|
106
106
|
function reasonOf(answer) {
|
|
107
107
|
return "network" in answer ? answer.network : `${answer.status} ${answer.code}`;
|
|
108
108
|
}
|
|
109
|
+
/** One API call: the key as a bearer, no redirect, a timeout, and up to three rate-limited retries. */
|
|
110
|
+
async function callApi(options, sleep, method, url, body) {
|
|
111
|
+
for (let retry = 0;; retry++) {
|
|
112
|
+
let response;
|
|
113
|
+
try {
|
|
114
|
+
response = await options.fetch(url, {
|
|
115
|
+
method,
|
|
116
|
+
headers: {
|
|
117
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
118
|
+
...(body !== undefined && { "content-type": "application/json" }),
|
|
119
|
+
},
|
|
120
|
+
...(body !== undefined && { body: JSON.stringify(body) }),
|
|
121
|
+
redirect: "error",
|
|
122
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
const name = err instanceof Error ? err.name.toLowerCase() : "";
|
|
127
|
+
return { network: `network ${SAFE_CODE.test(name) ? name : "unknown"}` };
|
|
128
|
+
}
|
|
129
|
+
if (response.status === 429 && retry < RATE_LIMIT_RETRIES) {
|
|
130
|
+
const header = response.headers.get("retry-after");
|
|
131
|
+
const asked = header !== null && /^\d+$/.test(header) ? Number(header) : 0;
|
|
132
|
+
const seconds = asked >= 1 && asked <= RATE_LIMIT_WAIT_MAX_S ? asked : RATE_LIMIT_WAIT_MAX_S;
|
|
133
|
+
options.onLine?.(`rate limited — waiting ${seconds}s`);
|
|
134
|
+
await sleep(seconds * 1000);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
let envelope = {};
|
|
138
|
+
try {
|
|
139
|
+
envelope = ((await response.json()) ?? {});
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// No JSON body: the status alone is reported.
|
|
143
|
+
}
|
|
144
|
+
const code = envelope.error?.code;
|
|
145
|
+
const data = envelope.data;
|
|
146
|
+
return {
|
|
147
|
+
status: response.status,
|
|
148
|
+
code: typeof code === "string" && SAFE_CODE.test(code) ? code : "unknown",
|
|
149
|
+
data: data !== null && typeof data === "object" ? data : {},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
109
153
|
export function withLanguage(adapters, options) {
|
|
110
154
|
const base = `${options.apiOrigin}/v1/workspaces/${encodeURIComponent(options.workspaceId)}/language`;
|
|
111
155
|
const query = `?locale=${encodeURIComponent(options.locale)}`;
|
|
@@ -120,49 +164,7 @@ export function withLanguage(adapters, options) {
|
|
|
120
164
|
const kickers = [];
|
|
121
165
|
const displaced = [];
|
|
122
166
|
const collisions = [];
|
|
123
|
-
|
|
124
|
-
for (let retry = 0;; retry++) {
|
|
125
|
-
let response;
|
|
126
|
-
try {
|
|
127
|
-
response = await options.fetch(url, {
|
|
128
|
-
method,
|
|
129
|
-
headers: {
|
|
130
|
-
authorization: `Bearer ${options.apiKey}`,
|
|
131
|
-
...(body !== undefined && { "content-type": "application/json" }),
|
|
132
|
-
},
|
|
133
|
-
...(body !== undefined && { body: JSON.stringify(body) }),
|
|
134
|
-
redirect: "error",
|
|
135
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
const name = err instanceof Error ? err.name.toLowerCase() : "";
|
|
140
|
-
return { network: `network ${SAFE_CODE.test(name) ? name : "unknown"}` };
|
|
141
|
-
}
|
|
142
|
-
if (response.status === 429 && retry < RATE_LIMIT_RETRIES) {
|
|
143
|
-
const header = response.headers.get("retry-after");
|
|
144
|
-
const asked = header !== null && /^\d+$/.test(header) ? Number(header) : 0;
|
|
145
|
-
const seconds = asked >= 1 && asked <= RATE_LIMIT_WAIT_MAX_S ? asked : RATE_LIMIT_WAIT_MAX_S;
|
|
146
|
-
options.onLine?.(`rate limited — waiting ${seconds}s`);
|
|
147
|
-
await sleep(seconds * 1000);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
let envelope = {};
|
|
151
|
-
try {
|
|
152
|
-
envelope = ((await response.json()) ?? {});
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
// No JSON body: the status alone is reported.
|
|
156
|
-
}
|
|
157
|
-
const code = envelope.error?.code;
|
|
158
|
-
const data = envelope.data;
|
|
159
|
-
return {
|
|
160
|
-
status: response.status,
|
|
161
|
-
code: typeof code === "string" && SAFE_CODE.test(code) ? code : "unknown",
|
|
162
|
-
data: data !== null && typeof data === "object" ? data : {},
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
167
|
+
const call = (method, url, body) => callApi(options, sleep, method, url, body);
|
|
166
168
|
const itemUrl = (kind, slug) => `${base}/${kind}/${encodeURIComponent(slug)}`;
|
|
167
169
|
/** The stored item at a slug, `null` for none; throws on any other answer. */
|
|
168
170
|
async function read(kind, slug) {
|
|
@@ -449,3 +451,228 @@ export function languageLines(result, apply) {
|
|
|
449
451
|
...result.displaced.map((d) => `language: faq/${d.slug}: the workspace holds a different question here; the file's is ${d.next}`),
|
|
450
452
|
];
|
|
451
453
|
}
|
|
454
|
+
/** `normalizeTopicPhrase` (`@working-theory/validation`), restated. */
|
|
455
|
+
function topicPhraseKey(phrase) {
|
|
456
|
+
return phrase.trim().toLowerCase().replace(/\s+/g, " ");
|
|
457
|
+
}
|
|
458
|
+
const SEED_PHRASE_MAX = 200;
|
|
459
|
+
const SEED_NAME_MAX = 200;
|
|
460
|
+
const SEED_TOPICS_MAX = 500;
|
|
461
|
+
const SEED_KEYWORDS_MAX = 1000;
|
|
462
|
+
/** `TOPIC_PILLAR_PATTERN` plus the pillar's 200-character cap, restated; control characters are refused separately. */
|
|
463
|
+
const PILLAR = /^\/(?![/\\])[^\s\\]{0,199}$/;
|
|
464
|
+
const AS_OF = /^([0-9]{4})-([0-9]{2})(?:-([0-9]{2}))?$/;
|
|
465
|
+
// eslint-disable-next-line no-control-regex -- matching control characters is the point
|
|
466
|
+
const SEED_CONTROL = /[\u0000-\u001F\u007F-\u009F]/;
|
|
467
|
+
/**
|
|
468
|
+
* A seed keyword's `asOf` as the pull datetime it stands for (midnight UTC on
|
|
469
|
+
* its day, or on the 1st of its month), or `null` for none or a date that is
|
|
470
|
+
* not a real one.
|
|
471
|
+
*/
|
|
472
|
+
export function asOfDatetime(asOf) {
|
|
473
|
+
const match = asOf === undefined ? null : AS_OF.exec(asOf);
|
|
474
|
+
if (match === null)
|
|
475
|
+
return null;
|
|
476
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3] ?? "1")];
|
|
477
|
+
const at = new Date(Date.UTC(year, month - 1, day));
|
|
478
|
+
const real = at.getUTCFullYear() === year && at.getUTCMonth() === month - 1 && at.getUTCDate() === day;
|
|
479
|
+
return real ? at.toISOString() : null;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* A seed file's `topics[]`, checked: `[]` when the file has none. Throws,
|
|
483
|
+
* naming the topic, on a shape the hub would refuse, so nothing is sent from
|
|
484
|
+
* a bad file.
|
|
485
|
+
*/
|
|
486
|
+
export function seedTopicsOf(seed) {
|
|
487
|
+
const raw = seed?.topics;
|
|
488
|
+
if (raw === undefined)
|
|
489
|
+
return [];
|
|
490
|
+
if (!Array.isArray(raw) || raw.length > SEED_TOPICS_MAX) {
|
|
491
|
+
throw new Error(`language seed: "topics" is not a list of at most ${SEED_TOPICS_MAX} topics`);
|
|
492
|
+
}
|
|
493
|
+
const text = (v, max) => typeof v === "string" && v.trim() !== "" && v.length <= max && !SEED_CONTROL.test(v);
|
|
494
|
+
const slugs = new Set();
|
|
495
|
+
return raw.map((topic, index) => {
|
|
496
|
+
const t = (topic ?? {});
|
|
497
|
+
const label = typeof t["slug"] === "string" && ITEM_SLUG.test(t["slug"]) ? t["slug"] : `#${index + 1}`;
|
|
498
|
+
const bad = (why) => new Error(`language seed: topic ${label}: ${why}`);
|
|
499
|
+
const slug = t["slug"];
|
|
500
|
+
if (typeof slug !== "string" || !ITEM_SLUG.test(slug))
|
|
501
|
+
throw bad("no valid slug");
|
|
502
|
+
if (slugs.has(slug))
|
|
503
|
+
throw bad("the slug appears twice");
|
|
504
|
+
slugs.add(slug);
|
|
505
|
+
const name = t["name"];
|
|
506
|
+
if (!text(name, SEED_NAME_MAX))
|
|
507
|
+
throw bad("no name");
|
|
508
|
+
const pillar = t["pillar"];
|
|
509
|
+
if (pillar !== undefined && (typeof pillar !== "string" || !PILLAR.test(pillar) || SEED_CONTROL.test(pillar))) {
|
|
510
|
+
throw bad("the pillar is not a site path");
|
|
511
|
+
}
|
|
512
|
+
const keywords = t["keywords"];
|
|
513
|
+
if (!Array.isArray(keywords) || keywords.length > SEED_KEYWORDS_MAX)
|
|
514
|
+
throw bad("no keyword list");
|
|
515
|
+
const phrases = new Set();
|
|
516
|
+
let primaries = 0;
|
|
517
|
+
const parsed = keywords.map((k, at) => {
|
|
518
|
+
const kw = (k ?? {});
|
|
519
|
+
const phrase = kw["phrase"];
|
|
520
|
+
if (!text(phrase, SEED_PHRASE_MAX))
|
|
521
|
+
throw bad(`keyword ${at + 1} has no phrase`);
|
|
522
|
+
if (phrases.has(topicPhraseKey(phrase)))
|
|
523
|
+
throw bad(`keyword ${at + 1} repeats a phrase`);
|
|
524
|
+
phrases.add(topicPhraseKey(phrase));
|
|
525
|
+
const searches = kw["monthlySearches"];
|
|
526
|
+
if (searches !== undefined && (typeof searches !== "number" || !Number.isFinite(searches) || searches < 0)) {
|
|
527
|
+
throw bad(`keyword ${at + 1} has no valid monthlySearches`);
|
|
528
|
+
}
|
|
529
|
+
const asOf = kw["asOf"];
|
|
530
|
+
if (asOf !== undefined && (typeof asOf !== "string" || asOfDatetime(asOf) === null)) {
|
|
531
|
+
throw bad(`keyword ${at + 1} has no valid asOf`);
|
|
532
|
+
}
|
|
533
|
+
if (kw["primary"] === true)
|
|
534
|
+
primaries += 1;
|
|
535
|
+
return {
|
|
536
|
+
phrase: phrase.trim(),
|
|
537
|
+
...(searches !== undefined && { monthlySearches: searches }),
|
|
538
|
+
...(asOf !== undefined && { asOf }),
|
|
539
|
+
...(kw["primary"] === true && { primary: true }),
|
|
540
|
+
};
|
|
541
|
+
});
|
|
542
|
+
if (primaries > 1)
|
|
543
|
+
throw bad("more than one keyword is primary");
|
|
544
|
+
return { slug, name: name.trim(), ...(pillar !== undefined && { pillar }), keywords: parsed };
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* A seed topic applied to a Topic's words (`null` for none yet). Each seed
|
|
549
|
+
* keyword matching a stored row (trimmed, case- and space-insensitive) keeps
|
|
550
|
+
* the stored spelling, place, variants and note, and takes the seed's number
|
|
551
|
+
* only when the seed's `asOf` is newer than the row's last pull, so a later
|
|
552
|
+
* Keyword Planner import is never overwritten by an older seed. Every other
|
|
553
|
+
* seed keyword becomes a keyword of its own, in the seed's spelling — the
|
|
554
|
+
* primary first. The seed's primary is marked only when the Topic has none
|
|
555
|
+
* and the phrase is a keyword rather than a variant; its pillar is set only
|
|
556
|
+
* when the Topic has none; its name titles only a new Topic. Pure; applying
|
|
557
|
+
* the same seed twice changes nothing the second time.
|
|
558
|
+
*/
|
|
559
|
+
export function applySeedTopic(stored, seed) {
|
|
560
|
+
const words = stored === null
|
|
561
|
+
? { title: seed.name, keywords: [] }
|
|
562
|
+
: {
|
|
563
|
+
...stored,
|
|
564
|
+
keywords: stored.keywords.map((k) => ({ ...k, variants: k.variants.map((v) => ({ ...v })) })),
|
|
565
|
+
};
|
|
566
|
+
if (seed.pillar !== undefined && words.pillar === undefined)
|
|
567
|
+
words.pillar = seed.pillar;
|
|
568
|
+
const rows = new Map();
|
|
569
|
+
for (const keyword of words.keywords) {
|
|
570
|
+
rows.set(topicPhraseKey(keyword.phrase), { row: keyword, keyword });
|
|
571
|
+
for (const variant of keyword.variants) {
|
|
572
|
+
if (!rows.has(topicPhraseKey(variant.phrase)))
|
|
573
|
+
rows.set(topicPhraseKey(variant.phrase), { row: variant });
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
const hasPrimary = words.keywords.some((k) => k.primary === true);
|
|
577
|
+
const fresh = [];
|
|
578
|
+
let updated = 0;
|
|
579
|
+
for (const kw of seed.keywords) {
|
|
580
|
+
const pulledAt = asOfDatetime(kw.asOf);
|
|
581
|
+
const found = rows.get(topicPhraseKey(kw.phrase));
|
|
582
|
+
if (found === undefined) {
|
|
583
|
+
fresh.push({
|
|
584
|
+
phrase: kw.phrase,
|
|
585
|
+
searches: kw.monthlySearches ?? null,
|
|
586
|
+
competition: null,
|
|
587
|
+
competitionIndex: null,
|
|
588
|
+
topBid: null,
|
|
589
|
+
yoyChange: null,
|
|
590
|
+
threeMonthChange: null,
|
|
591
|
+
pulledAt,
|
|
592
|
+
...(kw.primary === true && !hasPrimary && { primary: true }),
|
|
593
|
+
variants: [],
|
|
594
|
+
});
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
let changed = false;
|
|
598
|
+
if (kw.monthlySearches !== undefined &&
|
|
599
|
+
pulledAt !== null &&
|
|
600
|
+
(found.row.pulledAt === null || Date.parse(pulledAt) > Date.parse(found.row.pulledAt))) {
|
|
601
|
+
found.row.searches = kw.monthlySearches;
|
|
602
|
+
found.row.pulledAt = pulledAt;
|
|
603
|
+
changed = true;
|
|
604
|
+
}
|
|
605
|
+
if (kw.primary === true && !hasPrimary && found.keyword !== undefined) {
|
|
606
|
+
found.keyword.primary = true;
|
|
607
|
+
changed = true;
|
|
608
|
+
}
|
|
609
|
+
if (changed)
|
|
610
|
+
updated += 1;
|
|
611
|
+
}
|
|
612
|
+
words.keywords = [
|
|
613
|
+
...fresh.filter((k) => k.primary === true),
|
|
614
|
+
...words.keywords,
|
|
615
|
+
...fresh.filter((k) => k.primary !== true),
|
|
616
|
+
];
|
|
617
|
+
return { words, added: fresh.length, updated };
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Write each seed topic to the workspace as one Topic (`PUT …/language/topic/<slug>`):
|
|
621
|
+
* created when the workspace has none, saved over its draft tip when the seed
|
|
622
|
+
* changes it, untouched when it does not. A topic that fails is reported and
|
|
623
|
+
* the rest still run.
|
|
624
|
+
*/
|
|
625
|
+
export async function seedTopics(topics, options) {
|
|
626
|
+
const base = `${options.apiOrigin}/v1/workspaces/${encodeURIComponent(options.workspaceId)}/language/topic`;
|
|
627
|
+
const query = `?locale=${encodeURIComponent(options.locale)}`;
|
|
628
|
+
const sleep = options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
629
|
+
const report = { topics: [], counts: { created: 0, updated: 0, unchanged: 0, failed: 0 } };
|
|
630
|
+
const ok = (a) => !("network" in a) && (a.status === 200 || a.status === 201);
|
|
631
|
+
for (const topic of topics) {
|
|
632
|
+
const url = `${base}/${encodeURIComponent(topic.slug)}${query}`;
|
|
633
|
+
const done = (result, added = 0, updated = 0, reason) => {
|
|
634
|
+
report.topics.push({ slug: topic.slug, result, added, updated, ...(reason !== undefined && { reason }) });
|
|
635
|
+
report.counts[result] += 1;
|
|
636
|
+
};
|
|
637
|
+
const read = await callApi(options, sleep, "GET", url);
|
|
638
|
+
const item = "network" in read ? undefined : read.data["item"];
|
|
639
|
+
let stored;
|
|
640
|
+
let version;
|
|
641
|
+
if (!("network" in read) && read.status === 404) {
|
|
642
|
+
stored = null;
|
|
643
|
+
version = null;
|
|
644
|
+
}
|
|
645
|
+
else if (ok(read) &&
|
|
646
|
+
item !== undefined &&
|
|
647
|
+
typeof item.version === "string" &&
|
|
648
|
+
Array.isArray(item.words?.keywords)) {
|
|
649
|
+
stored = item.words;
|
|
650
|
+
version = item.version;
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
done("failed", 0, 0, reasonOf(read));
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
const next = applySeedTopic(stored, topic);
|
|
657
|
+
if (stored !== null && next.added === 0 && next.updated === 0 && stored.pillar === next.words.pillar) {
|
|
658
|
+
done("unchanged");
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
const saved = await callApi(options, sleep, "PUT", url, { words: next.words, version });
|
|
662
|
+
if (!ok(saved)) {
|
|
663
|
+
done("failed", 0, 0, reasonOf(saved));
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
done(stored === null ? "created" : "updated", next.added, next.updated);
|
|
667
|
+
}
|
|
668
|
+
return report;
|
|
669
|
+
}
|
|
670
|
+
/** One line per seed topic, then the counts, in the dry run's verbs or `--apply`'s. */
|
|
671
|
+
export function topicSeedLines(report, apply) {
|
|
672
|
+
const verb = (r) => (apply ? r : r === "created" ? "create" : r === "updated" ? "update" : r);
|
|
673
|
+
const { created, updated, unchanged, failed } = report.counts;
|
|
674
|
+
return [
|
|
675
|
+
...report.topics.map((t) => `language: topic/${t.slug}: ${verb(t.result)}${t.result === "created" || t.result === "updated" ? ` (${t.added} added, ${t.updated} updated)` : ""}${t.reason === undefined ? "" : ` — ${t.reason}`}`),
|
|
676
|
+
`language: topics ${apply ? "created" : "create"} ${created} · ${apply ? "updated" : "update"} ${updated} · unchanged ${unchanged} · failed ${failed}`,
|
|
677
|
+
];
|
|
678
|
+
}
|
package/dist/lib/import-mdx.js
CHANGED
|
@@ -100,7 +100,7 @@ const INDEX_OWN_SLUG = new Map(Object.entries(EDITORIAL_TYPES).map(([dir, k]) =>
|
|
|
100
100
|
/** `PAGE_TAG_TYPES` (the validation package's `site-fields.ts`), restated: the blog collection keeps a sent `tags`. */
|
|
101
101
|
const PAGE_TAG_TYPES = new Set(["BlogPosting", "BlogList"]);
|
|
102
102
|
/**
|
|
103
|
-
* `fumadocsToArtifactFrontmatter` (`
|
|
103
|
+
* `fumadocsToArtifactFrontmatter` (`@working-theory/ui-docs-blog`'s `src/runtime-source.ts`, #11254) restated —
|
|
104
104
|
* fumadocs key to stored key — less `tags`, which only a blog page sends, plus
|
|
105
105
|
* `sections`, which `convert` moves. Any other key rides in `siteFields`
|
|
106
106
|
* (#10806 D4).
|
|
@@ -31,7 +31,7 @@ export declare const CLAIM_GATED_ROUTES: Readonly<Record<string, string>>;
|
|
|
31
31
|
export declare const HUB_GATED_ROUTES: Readonly<Record<string, string>>;
|
|
32
32
|
/**
|
|
33
33
|
* The API origin names `apps/web` reads, in step with `apiOriginConfigured()`
|
|
34
|
-
* in `
|
|
34
|
+
* in `packages-paid/ui-signal-collectors/src/pages/flows/[slug]/served-flow.ts`.
|
|
35
35
|
*/
|
|
36
36
|
export declare const HUB_ORIGIN_ENV_NAMES: readonly ["AILK_API_URL", "NEXT_PUBLIC_AILK_API_URL", "NEXT_PUBLIC_API_URL"];
|
|
37
37
|
/**
|
|
@@ -78,12 +78,15 @@ export declare function assessRouteStatus(input: {
|
|
|
78
78
|
status: number | null;
|
|
79
79
|
}): SweepVerdict;
|
|
80
80
|
/**
|
|
81
|
-
* A `CLAIM_GATED_ROUTES` entry: it must
|
|
82
|
-
*
|
|
81
|
+
* A `CLAIM_GATED_ROUTES` entry: it must answer exactly 404. Its page ships in
|
|
82
|
+
* a page package (`@working-theory/ui-commerce`, #11253), so a leg that does
|
|
83
|
+
* not carry that package (`carried: false`) has no such route and passes;
|
|
84
|
+
* one that does must list it in the route table (a missing one is stale).
|
|
83
85
|
*/
|
|
84
86
|
export declare function assessClaimGatedRoute(input: {
|
|
85
87
|
route: string;
|
|
86
88
|
routeTable: string[];
|
|
89
|
+
carried: boolean;
|
|
87
90
|
hops: RedirectHop[];
|
|
88
91
|
status: number | null;
|
|
89
92
|
}): SweepVerdict;
|