create-ailk 0.1.0 → 0.2.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 +124 -3
- package/component-catalog.md +456 -0
- package/dist/cli.js +92 -16
- package/dist/component-catalog.d.ts +11 -0
- package/dist/component-catalog.js +39 -0
- package/dist/copy.d.ts +7 -0
- package/dist/copy.js +24 -0
- package/dist/derive-architecture.d.ts +13 -0
- package/dist/derive-architecture.js +238 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +19 -2
- package/dist/lib/extract-module-bundle.d.ts +16 -0
- package/dist/lib/extract-module-bundle.js +184 -0
- package/dist/lib/fetch-module.d.ts +55 -0
- package/dist/lib/fetch-module.js +125 -0
- package/dist/lib/module-license-gate.d.ts +48 -0
- package/dist/lib/module-license-gate.js +67 -0
- package/dist/lib/module-tier.d.ts +35 -0
- package/dist/lib/module-tier.js +37 -0
- package/dist/module-architecture.d.ts +175 -0
- package/dist/module-architecture.js +663 -0
- package/dist/parse-args.d.ts +47 -1
- package/dist/parse-args.js +143 -2
- package/dist/programmatic.d.ts +160 -3
- package/dist/programmatic.js +196 -7
- package/dist/surfaces.d.ts +211 -0
- package/dist/surfaces.js +532 -0
- package/dist/sync-routes.d.ts +92 -0
- package/dist/sync-routes.js +350 -0
- package/package.json +12 -5
- package/templates/.claude/rules/architecture.md +6 -2
- package/templates/.claude/skills/README.md +9 -9
- package/templates/.claude/skills/add-schema/SKILL.md +14 -7
- package/templates/.claude/skills/add-schema/references/schema-types.md +109 -6
- package/templates/.claude/skills/provision-config/SKILL.md +1 -1
- package/templates/.claude/skills/scaffold-commerce/SKILL.md +498 -1
- package/templates/.claude/skills/scaffold-commerce/templates/checkout-route.template.ts +370 -0
- package/templates/.claude/skills/scaffold-commerce/templates/invoice-route.template.ts +376 -0
- package/templates/.claude/skills/scaffold-commerce/templates/payment-link-route.template.ts +471 -0
- package/templates/.claude/skills/scaffold-commerce/templates/portal-route.template.ts +365 -0
- package/templates/.claude/skills/scaffold-commerce/templates/stripe-config.template.ts +60 -0
- package/templates/.claude/skills/scaffold-commerce/templates/subscription-route.template.ts +446 -0
- package/templates/.claude/skills/suggest-site-pages/references/categories.md +4 -4
- package/templates/.env.example +126 -2
- package/templates/CLAUDE.md +11 -5
- package/templates/README.md +1 -1
- package/templates/apps/api/.env.example +38 -0
- package/templates/apps/api/CLAUDE.md +78 -1
- package/templates/apps/api/LICENSE +201 -0
- package/templates/apps/api/api/index.ts +6 -141
- package/templates/apps/api/jest.config.cjs +16 -0
- package/templates/apps/api/package.json +22 -6
- package/templates/apps/api/src/__tests__/module-exclusion.test.ts +141 -0
- package/templates/apps/api/src/__tests__/server.test.ts +46 -0
- package/templates/apps/api/src/__tests__/vercel-handler.test.ts +211 -0
- package/templates/apps/api/src/bin/abandon-sweep.ts +42 -0
- package/templates/apps/api/src/bin/deliverable-resend.ts +144 -0
- package/templates/apps/api/src/bin/deliverable-upload.ts +114 -0
- package/templates/apps/api/src/bin/followup-sweep.ts +44 -0
- package/templates/apps/api/src/bin/listing-csv-sweep.ts +46 -0
- package/templates/apps/api/src/bin/seed-presets.ts +58 -0
- package/templates/apps/api/src/bin/seed-waitlist-experiments.ts +104 -0
- package/templates/apps/api/src/bin/session-retention-sweep.ts +46 -0
- package/templates/apps/api/src/cli.ts +5 -11
- package/templates/apps/api/src/config/index.ts +35 -0
- package/templates/apps/api/src/config/modules.ts +43 -0
- package/templates/apps/api/src/lib/__mocks__/prisma-client.js +11 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +241 -0
- package/templates/apps/api/src/lib/__tests__/lead-capture-store.test.ts +2 -2
- package/templates/apps/api/src/lib/site.ts +16 -0
- package/templates/apps/api/src/lib/stripe.ts +22 -0
- package/templates/apps/api/src/lib/tenant-db.ts +225 -0
- package/templates/apps/api/src/lib/ws-token.ts +91 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/session-fixation.test.ts +7 -1
- package/templates/apps/api/src/middleware/__tests__/auth.cookie-path.test.ts +7 -1
- package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +91 -4
- package/templates/apps/api/src/middleware/auth.ts +43 -8
- package/templates/apps/api/src/middleware/rate-limit.ts +78 -3
- package/templates/apps/api/src/middleware/tenant.ts +99 -0
- package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +92 -0
- package/templates/apps/api/src/openapi/spec.ts +312 -3
- package/templates/apps/api/src/routes/aeo/__tests__/index.test.ts +175 -0
- package/templates/apps/api/src/routes/aeo/index.ts +107 -0
- package/templates/apps/api/src/routes/auth/__tests__/auth-tokens.functional.test.ts +5 -2
- package/templates/apps/api/src/routes/auth/__tests__/tokens.test.ts +22 -3
- package/templates/apps/api/src/routes/auth/tokens.ts +13 -1
- package/templates/apps/api/src/routes/billing/__tests__/portal.test.ts +450 -0
- package/templates/apps/api/src/routes/billing/__tests__/read.test.ts +262 -0
- package/templates/apps/api/src/routes/billing/__tests__/usage.test.ts +436 -0
- package/templates/apps/api/src/routes/billing/index.ts +36 -0
- package/templates/apps/api/src/routes/billing/portal.ts +182 -0
- package/templates/apps/api/src/routes/billing/read.ts +75 -0
- package/templates/apps/api/src/routes/billing/usage.ts +153 -0
- package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +99 -0
- package/templates/apps/api/src/routes/checkout/sessions.ts +20 -8
- package/templates/apps/api/src/routes/content/create.ts +1 -0
- package/templates/apps/api/src/routes/content/delete.ts +1 -0
- package/templates/apps/api/src/routes/content/index.ts +42 -6
- package/templates/apps/api/src/routes/content/update.ts +1 -0
- package/templates/apps/api/src/routes/deliverables/__tests__/index.test.ts +393 -0
- package/templates/apps/api/src/routes/deliverables/index.ts +200 -0
- package/templates/apps/api/src/routes/flow-checkouts/__tests__/index.test.ts +443 -0
- package/templates/apps/api/src/routes/flow-checkouts/index.ts +82 -0
- package/templates/apps/api/src/routes/flows/README.md +147 -0
- package/templates/apps/api/src/routes/flows/__tests__/index.test.ts +752 -0
- package/templates/apps/api/src/routes/flows/__tests__/recommender.test.ts +671 -0
- package/templates/apps/api/src/routes/flows/index.ts +202 -0
- package/templates/apps/api/src/routes/flows/recommender.ts +443 -0
- package/templates/apps/api/src/routes/leads/__tests__/index.test.ts +438 -31
- package/templates/apps/api/src/routes/leads/__tests__/track.test.ts +10 -10
- package/templates/apps/api/src/routes/leads/index.ts +43 -9
- package/templates/apps/api/src/routes/project-listings/__tests__/configured-application.test.ts +558 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/copy-edit.test.ts +815 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/drafts.test.ts +869 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/me-route-precedence.test.ts +221 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/me.test.ts +468 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/public.test.ts +424 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/site-answers.test.ts +707 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/site-key.test.ts +375 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/structured-address.test.ts +467 -0
- package/templates/apps/api/src/routes/project-listings/__tests__/tenant-isolation.test.ts +566 -0
- package/templates/apps/api/src/routes/project-listings/get.ts +70 -0
- package/templates/apps/api/src/routes/project-listings/index.ts +120 -0
- package/templates/apps/api/src/routes/project-listings/list.ts +47 -0
- package/templates/apps/api/src/routes/project-listings/me.ts +76 -0
- package/templates/apps/api/src/routes/project-listings/patch-copy.ts +222 -0
- package/templates/apps/api/src/routes/project-listings/patch-draft.ts +97 -0
- package/templates/apps/api/src/routes/project-listings/patch.ts +136 -0
- package/templates/apps/api/src/routes/project-listings/public.ts +52 -0
- package/templates/apps/api/src/routes/project-listings/respond.ts +37 -0
- package/templates/apps/api/src/routes/project-listings/resume-token.ts +22 -0
- package/templates/apps/api/src/routes/project-listings/start.ts +106 -0
- package/templates/apps/api/src/routes/project-listings/submit.ts +122 -0
- package/templates/apps/api/src/routes/schedule/__tests__/index.test.ts +490 -0
- package/templates/apps/api/src/routes/schedule/index.ts +249 -0
- package/templates/apps/api/src/routes/slack/__tests__/actions.test.ts +385 -0
- package/templates/apps/api/src/routes/slack/actions.ts +177 -0
- package/templates/apps/api/src/routes/slack/index.ts +38 -0
- package/templates/apps/api/src/routes/test/auth/__tests__/session.test.ts +16 -6
- package/templates/apps/api/src/routes/test/auth/session.ts +8 -6
- package/templates/apps/api/src/routes/waitlist-experiments/__tests__/tenant-isolation.test.ts +577 -0
- package/templates/apps/api/src/routes/waitlist-experiments/comparison.ts +78 -0
- package/templates/apps/api/src/routes/waitlist-experiments/index.ts +41 -0
- package/templates/apps/api/src/routes/waitlist-experiments/list.ts +64 -0
- package/templates/apps/api/src/routes/waitlist-experiments/respond.ts +42 -0
- package/templates/apps/api/src/routes/waitlist-experiments/signup.ts +84 -0
- package/templates/apps/api/src/routes/waitlist-experiments/signups.ts +119 -0
- package/templates/apps/api/src/routes/waitlist-signups/__tests__/index.test.ts +238 -0
- package/templates/apps/api/src/routes/waitlist-signups/index.ts +101 -0
- package/templates/apps/api/src/routes/webhooks/README.md +35 -12
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-flow-checkout.test.ts +315 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-org-billing.test.ts +270 -0
- package/templates/apps/api/src/routes/webhooks/stripe.ts +248 -20
- package/templates/apps/api/src/routes/workspaces/__tests__/config-tenant-isolation.test.ts +356 -0
- package/templates/apps/api/src/routes/workspaces/__tests__/tenant-isolation.test.ts +671 -0
- package/templates/apps/api/src/routes/workspaces/config.ts +125 -0
- package/templates/apps/api/src/routes/workspaces/index.ts +194 -0
- package/templates/apps/api/src/routes/workspaces/sessions.ts +218 -0
- package/templates/apps/api/src/server.ts +307 -7
- package/templates/apps/api/src/services/__tests__/abandon-email.test.ts +489 -0
- package/templates/apps/api/src/services/__tests__/aeo-score.test.ts +475 -0
- package/templates/apps/api/src/services/__tests__/answer-distributions.test.ts +132 -0
- package/templates/apps/api/src/services/__tests__/consent-migration.test.ts +65 -0
- package/templates/apps/api/src/services/__tests__/consent.test.ts +282 -0
- package/templates/apps/api/src/services/__tests__/deliverable-fulfillment.test.ts +523 -0
- package/templates/apps/api/src/services/__tests__/deliverable-resend.test.ts +359 -0
- package/templates/apps/api/src/services/__tests__/entitlements.test.ts +142 -0
- package/templates/apps/api/src/services/__tests__/flow-aggregate.test.ts +425 -0
- package/templates/apps/api/src/services/__tests__/flow-engine.test.ts +2840 -0
- package/templates/apps/api/src/services/__tests__/lead-promotion.test.ts +393 -0
- package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +8 -8
- package/templates/apps/api/src/services/__tests__/listing-csv-sweep.test.ts +560 -0
- package/templates/apps/api/src/services/__tests__/listing-promotion.test.ts +684 -0
- package/templates/apps/api/src/services/__tests__/playbook-compile.test.ts +406 -0
- package/templates/apps/api/src/services/__tests__/playbook-render.test.ts +290 -0
- package/templates/apps/api/src/services/__tests__/project-listing-decision.test.ts +736 -0
- package/templates/apps/api/src/services/__tests__/project-listing-flow.test.ts +475 -0
- package/templates/apps/api/src/services/__tests__/project-listing-issue.test.ts +340 -0
- package/templates/apps/api/src/services/__tests__/recommender-capture.test.ts +983 -0
- package/templates/apps/api/src/services/__tests__/slack-notify.test.ts +278 -0
- package/templates/apps/api/src/services/__tests__/tenant-context-cascade.test.ts +71 -0
- package/templates/apps/api/src/services/__tests__/tenant-context.test.ts +379 -0
- package/templates/apps/api/src/services/__tests__/usage-aggregation.test.ts +941 -0
- package/templates/apps/api/src/services/__tests__/usage-credits.test.ts +588 -0
- package/templates/apps/api/src/services/__tests__/usage-metering.test.ts +768 -0
- package/templates/apps/api/src/services/__tests__/waitlist-dashboard.test.ts +1314 -0
- package/templates/apps/api/src/services/__tests__/waitlist-experiments.test.ts +341 -0
- package/templates/apps/api/src/services/__tests__/waitlist-followup.test.ts +567 -0
- package/templates/apps/api/src/services/__tests__/waitlist-scoring.test.ts +474 -0
- package/templates/apps/api/src/services/__tests__/waitlist-signups.test.ts +354 -0
- package/templates/apps/api/src/services/abandon-email.ts +307 -0
- package/templates/apps/api/src/services/aeo-score.ts +288 -0
- package/templates/apps/api/src/services/answer-distributions.ts +138 -0
- package/templates/apps/api/src/services/consent.ts +236 -0
- package/templates/apps/api/src/services/deliverable-fulfillment.ts +523 -0
- package/templates/apps/api/src/services/entitlements.ts +102 -0
- package/templates/apps/api/src/services/flow-aggregate.ts +232 -0
- package/templates/apps/api/src/services/flow-checkouts.ts +123 -0
- package/templates/apps/api/src/services/flow-engine.ts +1296 -0
- package/templates/apps/api/src/services/lead-promotion.ts +176 -0
- package/templates/apps/api/src/services/lead-routing.ts +3 -3
- package/templates/apps/api/src/services/listing-config.ts +102 -0
- package/templates/apps/api/src/services/listing-csv-sweep.ts +455 -0
- package/templates/apps/api/src/services/listing-promotion.ts +342 -0
- package/templates/apps/api/src/services/playbook-compile.ts +398 -0
- package/templates/apps/api/src/services/playbook-render.ts +263 -0
- package/templates/apps/api/src/services/project-listing-decision.ts +510 -0
- package/templates/apps/api/src/services/project-listing-flow.ts +426 -0
- package/templates/apps/api/src/services/project-listing-issue.ts +251 -0
- package/templates/apps/api/src/services/project-listings.ts +1472 -0
- package/templates/apps/api/src/services/recommender-capture.ts +835 -0
- package/templates/apps/api/src/services/scheduling/cal-provider.ts +392 -0
- package/templates/apps/api/src/services/scheduling/index.ts +63 -0
- package/templates/apps/api/src/services/scheduling/types.ts +88 -0
- package/templates/apps/api/src/services/slack-notify.ts +240 -0
- package/templates/apps/api/src/services/tenant-context.ts +451 -0
- package/templates/apps/api/src/services/usage-aggregation.ts +516 -0
- package/templates/apps/api/src/services/usage-credits.ts +340 -0
- package/templates/apps/api/src/services/usage-metering.ts +699 -0
- package/templates/apps/api/src/services/waitlist-dashboard.ts +947 -0
- package/templates/apps/api/src/services/waitlist-experiments.ts +213 -0
- package/templates/apps/api/src/services/waitlist-followup.ts +486 -0
- package/templates/apps/api/src/services/waitlist-scoring.ts +166 -0
- package/templates/apps/api/src/services/waitlist-signups.ts +165 -0
- package/templates/apps/api/src/vercel-handler.ts +165 -0
- package/templates/apps/api/tsconfig.json +0 -12
- package/templates/apps/mcp/CLAUDE.md +19 -9
- package/templates/apps/mcp/LICENSE +201 -0
- package/templates/apps/mcp/__tests__/create_page.test.ts +1 -0
- package/templates/apps/mcp/__tests__/delete_page.test.ts +1 -0
- package/templates/apps/mcp/__tests__/module-exclusion.test.ts +105 -0
- package/templates/apps/mcp/__tests__/parity.test.ts +70 -6
- package/templates/apps/mcp/__tests__/request_callback.test.ts +4 -4
- package/templates/apps/mcp/__tests__/schedule_tools.test.ts +242 -0
- package/templates/apps/mcp/__tests__/submit_lead.test.ts +4 -4
- package/templates/apps/mcp/__tests__/subscribe_newsletter.test.ts +4 -4
- package/templates/apps/mcp/__tests__/tools/purchase.test.ts +47 -0
- package/templates/apps/mcp/__tests__/update_page.test.ts +1 -0
- package/templates/apps/mcp/package.json +6 -4
- package/templates/apps/mcp/src/config/modules.ts +37 -0
- package/templates/apps/mcp/src/server.ts +109 -18
- package/templates/apps/mcp/src/tools/capture_lead.ts +1 -1
- package/templates/apps/mcp/src/tools/create_booking.ts +58 -0
- package/templates/apps/mcp/src/tools/create_page.ts +1 -0
- package/templates/apps/mcp/src/tools/delete_page.ts +1 -0
- package/templates/apps/mcp/src/tools/get_event_meta.ts +55 -0
- package/templates/apps/mcp/src/tools/get_flow.ts +61 -0
- package/templates/apps/mcp/src/tools/index.ts +25 -0
- package/templates/apps/mcp/src/tools/list_availability.ts +67 -0
- package/templates/apps/mcp/src/tools/purchase.ts +3 -0
- package/templates/apps/mcp/src/tools/submit_flow_step.ts +83 -0
- package/templates/apps/mcp/src/tools/update_page.ts +1 -0
- package/templates/apps/mcp/tsconfig.json +1 -9
- package/templates/apps/web/.env.example +44 -0
- package/templates/apps/web/CLAUDE.md +28 -0
- package/templates/apps/web/LICENSE +201 -0
- package/templates/apps/web/__tests__/__mocks__/code-highlight.jest-stub.ts +24 -0
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +33 -0
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +18 -0
- package/templates/apps/web/__tests__/__mocks__/server-only.ts +13 -0
- package/templates/apps/web/__tests__/__mocks__/style-mock.js +4 -0
- package/templates/apps/web/__tests__/__mocks__/vercel-analytics-server.ts +9 -0
- package/templates/apps/web/__tests__/jest-support/import-meta-transformer.cjs +90 -0
- package/templates/apps/web/__tests__/setup.ts +22 -32
- package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +6 -3
- package/templates/apps/web/app/.well-known/mcp.json/build-manifest.ts +8 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +260 -0
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +263 -0
- package/templates/apps/web/app/[locale]/(authed)/account/sign-out-button.tsx +39 -0
- package/templates/apps/web/app/[locale]/(authed)/layout.tsx +54 -0
- package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +96 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/[experimentId]/page.tsx +309 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/[experimentId]/signups/[leadId]/page.tsx +149 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/comparison.test.tsx +273 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/gate.test.tsx +172 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/list.test.tsx +171 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/signup.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ExperimentsTable.tsx +116 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +24 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/OfferFunnelTable.tsx +66 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/RollupTicker.tsx +61 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ScoreTrace.tsx +114 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/SignupsTable.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/WaitlistComparisonTabs.tsx +85 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/status-badges.tsx +67 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +111 -0
- package/templates/apps/web/app/[locale]/(authed)/waitlist/page.tsx +179 -0
- package/templates/apps/web/app/[locale]/about/page.tsx +10 -1
- package/templates/apps/web/app/[locale]/blog/[[...slug]]/page.tsx +6 -1
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/careers/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +11 -1
- package/templates/apps/web/app/[locale]/clients/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/contact/ContactForm.tsx +21 -1
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +188 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +242 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +29 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +51 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +39 -15
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +21 -3
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +49 -0
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +66 -0
- package/templates/apps/web/app/[locale]/contact/page.tsx +14 -4
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/courses/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/docs/[[...slug]]/page.tsx +1 -0
- package/templates/apps/web/app/[locale]/downloads/__tests__/page-renderer-migration.test.tsx +11 -1
- package/templates/apps/web/app/[locale]/downloads/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +12 -2
- package/templates/apps/web/app/[locale]/events/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/faq/page.tsx +10 -1
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +265 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +445 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +341 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/checkout.actions.test.ts +287 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +302 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +128 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/checkout.actions.ts +254 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +144 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +108 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +532 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +121 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.checkout.test.tsx +457 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +396 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +114 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +52 -0
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/integrations/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +14 -1
- package/templates/apps/web/app/[locale]/layout.tsx +127 -16
- package/templates/apps/web/app/[locale]/page.tsx +10 -1
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/partners/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/products/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +10 -0
- package/templates/apps/web/app/[locale]/projects/apply/ListingApplicationClient.tsx +110 -0
- package/templates/apps/web/app/[locale]/projects/apply/__tests__/ListingApplicationClient.test.tsx +96 -0
- package/templates/apps/web/app/[locale]/projects/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +12 -2
- package/templates/apps/web/app/[locale]/resources/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/schedule/__tests__/page.test.tsx +117 -0
- package/templates/apps/web/app/[locale]/schedule/confirmed/__tests__/page.test.tsx +96 -0
- package/templates/apps/web/app/[locale]/schedule/confirmed/page.tsx +92 -0
- package/templates/apps/web/app/[locale]/schedule/page.tsx +82 -0
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/services/page.tsx +9 -1
- package/templates/apps/web/app/[locale]/sign-in/__tests__/next-path.test.ts +31 -0
- package/templates/apps/web/app/[locale]/sign-in/__tests__/page.test.tsx +152 -0
- package/templates/apps/web/app/[locale]/sign-in/next-path.ts +0 -0
- package/templates/apps/web/app/[locale]/sign-in/page.tsx +83 -0
- package/templates/apps/web/app/[locale]/sign-in/sign-in-card.tsx +123 -0
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +11 -1
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +93 -0
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +48 -0
- package/templates/apps/web/app/[locale]/use-cases/__tests__/page-renderer-migration.test.tsx +11 -1
- package/templates/apps/web/app/[locale]/use-cases/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/globals.css +35 -0
- package/templates/apps/web/app/llms.txt/route.ts +2 -1
- package/templates/apps/web/app/og/route.tsx +10 -2
- package/templates/apps/web/auth.ts +8 -0
- package/templates/apps/web/components/sign-out-trigger.tsx +42 -0
- package/templates/apps/web/content/en/blog/README.txt +25 -0
- package/templates/apps/web/content/en/docs/index.mdx +28 -0
- package/templates/apps/web/jest.config.cjs +90 -27
- package/templates/apps/web/lib/__tests__/site-brand.test.ts +119 -0
- package/templates/apps/web/lib/__tests__/site-theme.test.ts +112 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +499 -0
- package/templates/apps/web/lib/account-config.ts +13 -0
- package/templates/apps/web/lib/server-api.ts +85 -0
- package/templates/apps/web/lib/site-brand.tsx +121 -0
- package/templates/apps/web/lib/site-theme.ts +74 -0
- package/templates/apps/web/messages/en.json +275 -7
- package/templates/apps/web/middleware.ts +11 -3
- package/templates/apps/web/next.config.mjs +8 -2
- package/templates/apps/web/package.json +17 -7
- package/templates/apps/web/postcss.config.mjs +23 -0
- package/templates/apps/web/public/.well-known/security.txt +3 -3
- package/templates/apps/web/src/lib/routes.ts +15 -2
- package/templates/apps/web/tsconfig.json +1 -16
- package/templates/content/_site.mdx +36 -25
- package/templates/content/en/AboutPage/about.mdx +24 -14
- package/templates/content/en/ContactPage/contact.mdx +23 -14
- package/templates/content/en/FAQPage/faq.mdx +10 -392
- package/templates/content/en/HomePage/home.mdx +14 -285
- package/templates/database/CHANGELOG.md +443 -0
- package/templates/database/LICENSE +201 -0
- package/templates/database/README.md +3 -1
- package/templates/database/__tests__/flows-listing-diagnostic.test.ts +392 -0
- package/templates/database/__tests__/flows-presets.test.ts +173 -0
- package/templates/database/__tests__/prefixed-ids.db.test.ts +146 -0
- package/templates/database/__tests__/seed.test.ts +88 -0
- package/templates/database/__tests__/user-cascade.test.ts +19 -4
- package/templates/database/auth/schema.prisma +521 -0
- package/templates/database/config/schema.prisma +234 -0
- package/templates/database/content/schema.prisma +263 -0
- package/templates/database/flows/listing-diagnostic.ts +182 -0
- package/templates/database/flows/presets.ts +315 -0
- package/templates/database/inbox/__tests__/schema.test.ts +4 -0
- package/templates/database/inbox/schema.prisma +574 -3
- package/templates/database/jest.config.cjs +8 -0
- package/templates/database/migrations/20260712215647_add_multi_tenant_tenancy/migration.sql +201 -0
- package/templates/database/migrations/20260713143320_reanchor_site_config_to_workspace/migration.sql +67 -0
- package/templates/database/migrations/20260713174000_add_audit_logs/migration.sql +46 -0
- package/templates/database/migrations/20260713190000_drop_telemetry_records/migration.sql +25 -0
- package/templates/database/migrations/20260713192000_add_uuidv7_function/migration.sql +49 -0
- package/templates/database/migrations/20260713192429_prefixed_uuid_entity_ids/migration.sql +197 -0
- package/templates/database/migrations/20260713200000_add_org_billing/migration.sql +32 -0
- package/templates/database/migrations/20260714000000_add_lead_promotion_fields/migration.sql +22 -0
- package/templates/database/migrations/20260714010000_add_usage_billing_content_models/migration.sql +151 -0
- package/templates/database/migrations/20260714020000_add_usage_billing_auth_config_models/migration.sql +223 -0
- package/templates/database/migrations/20260714030000_credit_balance_non_negative/migration.sql +22 -0
- package/templates/database/migrations/20260714030000_widen_usage_billing_report_aggregates/migration.sql +32 -0
- package/templates/database/migrations/20260810233516_add_flow_engine_models/migration.sql +40 -0
- package/templates/database/migrations/20260811020000_add_flow_session_abandon_email_columns/migration.sql +4 -0
- package/templates/database/migrations/20260811030000_add_flow_session_abandon_email_index/migration.sql +2 -0
- package/templates/database/migrations/20260811040000_add_flow_session_segment/migration.sql +2 -0
- package/templates/database/migrations/20260811050000_add_deliverable_models/migration.sql +29 -0
- package/templates/database/migrations/20260812000000_add_deliverable_grant_send_columns/migration.sql +6 -0
- package/templates/database/migrations/20260902222948_add_waitlist_experiment_models/migration.sql +39 -0
- package/templates/database/migrations/20260902224500_add_waitlist_id_format_checks/migration.sql +24 -0
- package/templates/database/migrations/20260903004112_add_flow_session_flags_aeo_score/migration.sql +3 -0
- package/templates/database/migrations/20260903010000_add_playbook_instance/migration.sql +33 -0
- package/templates/database/migrations/20260904000000_add_waitlist_followup_send/migration.sql +30 -0
- package/templates/database/migrations/20260905230000_add_flow_checkout/migration.sql +47 -0
- package/templates/database/migrations/20260906000000_add_flow_checkout_idempotency/migration.sql +16 -0
- package/templates/database/migrations/20260907120000_add_project_listing/migration.sql +47 -0
- package/templates/database/migrations/20260907130000_add_project_listing_slack_columns/migration.sql +10 -0
- package/templates/database/migrations/20260907180000_add_listing_csv_send/migration.sql +26 -0
- package/templates/database/migrations/20260909120000_project_listings_platform/migration.sql +90 -0
- package/templates/database/migrations/20260909180000_listing_draft_and_fields/migration.sql +174 -0
- package/templates/database/migrations/20260910120000_listing_public_site_key/migration.sql +14 -0
- package/templates/database/migrations/20260911120000_listing_copy_edit_audit/migration.sql +25 -0
- package/templates/database/migrations/20260911140000_listing_structured_address/migration.sql +32 -0
- package/templates/database/migrations/20260911180000_consent_grants/migration.sql +71 -0
- package/templates/database/migrations/20260911200000_listing_site_answers/migration.sql +30 -0
- package/templates/database/migrations/20260912120000_listing_owner_link/migration.sql +49 -0
- package/templates/database/ops/schema.prisma +27 -0
- package/templates/database/package.json +42 -4
- package/templates/database/prisma.config.ts +1 -1
- package/templates/database/schema.prisma +19 -435
- package/templates/database/seed-test.ts +14 -4
- package/templates/database/seed.ts +148 -0
- package/templates/database/tenancy.ts +45 -0
- package/templates/database/tsconfig.flows.json +15 -0
- package/templates/database/tsconfig.json +7 -1
- package/templates/database/tsconfig.tenancy.json +14 -0
- package/templates/package.json +30 -55
- package/templates/pnpm-workspace.yaml +0 -3
- package/templates/project.yaml +1 -1
- package/templates/tsconfig.json +1 -37
- package/templates/apps/web/__tests__/auth/adversarial/cookie-attributes.test.ts +0 -94
- package/templates/apps/web/__tests__/auth/adversarial/oauth-state-parameter.test.ts +0 -75
- package/templates/apps/web/__tests__/auth/adversarial/redirect-uri-allowlist.test.ts +0 -82
- package/templates/apps/web/__tests__/auth/env-helpers.test.ts +0 -168
- package/templates/apps/web/__tests__/authority-list-routes.test.tsx +0 -208
- package/templates/apps/web/__tests__/better-stack.test.ts +0 -66
- package/templates/apps/web/__tests__/blog-dir-resolution.test.ts +0 -87
- package/templates/apps/web/__tests__/blog-source-populated.test.ts +0 -130
- package/templates/apps/web/__tests__/data-testid-coverage.test.tsx +0 -60
- package/templates/apps/web/__tests__/google-analytics.test.tsx +0 -104
- package/templates/apps/web/__tests__/i18n/middleware.test.ts +0 -119
- package/templates/apps/web/__tests__/i18n/routing.test.ts +0 -114
- package/templates/apps/web/__tests__/i18n/translations.test.ts +0 -191
- package/templates/apps/web/__tests__/json-ld.test.ts +0 -98
- package/templates/apps/web/__tests__/knowledge-events-routes.test.tsx +0 -580
- package/templates/apps/web/__tests__/layout-stealth.test.ts +0 -39
- package/templates/apps/web/__tests__/lighthouse-fixtures/improvement-image-shrink.tsx +0 -103
- package/templates/apps/web/__tests__/lighthouse-fixtures/override-fixture.md +0 -114
- package/templates/apps/web/__tests__/lighthouse-fixtures/regression-bloat.tsx +0 -94
- package/templates/apps/web/__tests__/page.test.tsx +0 -230
- package/templates/apps/web/__tests__/products-services-phase1.test.tsx +0 -321
- package/templates/apps/web/__tests__/projects-routes.test.tsx +0 -392
- package/templates/apps/web/__tests__/resources-downloads-integrations-phase2.test.tsx +0 -475
- package/templates/apps/web/__tests__/routes/ai-plugin-json.test.ts +0 -53
- package/templates/apps/web/__tests__/routes/blog-route.test.tsx +0 -191
- package/templates/apps/web/__tests__/routes/llms-txt.test.ts +0 -123
- package/templates/apps/web/__tests__/routes/robots-txt.test.ts +0 -52
- package/templates/apps/web/__tests__/routes/sitemap-xml.test.ts +0 -78
- package/templates/apps/web/__tests__/routes/well-known-mcp.test.ts +0 -203
- package/templates/apps/web/__tests__/section-routes.test.tsx +0 -693
- package/templates/apps/web/__tests__/security-headers.test.ts +0 -201
- package/templates/apps/web/__tests__/sentry-config.test.ts +0 -116
- package/templates/apps/web/__tests__/sitemap-locales.test.ts +0 -415
- package/templates/apps/web/__tests__/standalone-informational-routes.test.tsx +0 -844
- package/templates/apps/web/app/[locale]/__tests__/layout.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/__tests__/page-renderer-migration.test.tsx +0 -202
- package/templates/apps/web/app/__tests__/error-boundaries.test.tsx +0 -152
- package/templates/apps/web/content/en/blog/index.mdx +0 -15
- package/templates/apps/web/content/en/blog/launching-ailk.mdx +0 -20
- package/templates/apps/web/content/en/docs/getting-started.mdx +0 -30
- package/templates/content/.gitkeep +0 -0
- package/templates/content/CLAUDE.md +0 -85
- package/templates/content/ar/HomePage/home.mdx +0 -123
- package/templates/content/ar/_site.mdx +0 -35
- package/templates/content/de/_site.mdx +0 -29
- package/templates/content/en/.gitkeep +0 -0
- package/templates/content/en/AboutPage/about.schema.json +0 -82
- package/templates/content/en/BookCall/book-call.mdx +0 -19
- package/templates/content/en/BookCall/book-call.schema.json +0 -121
- package/templates/content/en/BreadcrumbList/site-breadcrumbs.mdx +0 -20
- package/templates/content/en/CareersList/careers.mdx +0 -24
- package/templates/content/en/CaseStudiesList/case-studies.mdx +0 -22
- package/templates/content/en/CaseStudiesList/showcase.mdx +0 -8
- package/templates/content/en/CaseStudy/ailk-aeo-rollout.mdx +0 -32
- package/templates/content/en/CaseStudy/schema-builder-migration.mdx +0 -41
- package/templates/content/en/ClientsList/clients.mdx +0 -38
- package/templates/content/en/ContactPage/contact.schema.json +0 -100
- package/templates/content/en/ContactPoint/primary.mdx +0 -14
- package/templates/content/en/Course/aeo-fundamentals.mdx +0 -37
- package/templates/content/en/Course/schema-builder-workshop.mdx +0 -62
- package/templates/content/en/CoursesList/courses.mdx +0 -22
- package/templates/content/en/DownloadsList/downloads.mdx +0 -22
- package/templates/content/en/Event/aeo-office-hours-may-2026.mdx +0 -39
- package/templates/content/en/Event/ailk-launch-day-2026.mdx +0 -35
- package/templates/content/en/EventsList/events.mdx +0 -26
- package/templates/content/en/FAQPage/faq.schema.json +0 -231
- package/templates/content/en/GlossaryList/glossary.mdx +0 -19
- package/templates/content/en/GlossaryList/glossary.schema.json +0 -300
- package/templates/content/en/HomePage/home.schema.json +0 -88
- package/templates/content/en/HomePage/launch-service.mdx +0 -475
- package/templates/content/en/HomePage/launch-service.schema.json +0 -138
- package/templates/content/en/HowTo/add-mdx-content.mdx +0 -38
- package/templates/content/en/HowTo/configure-aeo-scoring.mdx +0 -35
- package/templates/content/en/HowTo/set-up-json-ld.mdx +0 -36
- package/templates/content/en/Integration/github-actions.mdx +0 -31
- package/templates/content/en/Integration/openai-api.mdx +0 -26
- package/templates/content/en/Integration/vercel.mdx +0 -32
- package/templates/content/en/IntegrationsList/integrations.mdx +0 -22
- package/templates/content/en/JobPosting/content-strategist.mdx +0 -46
- package/templates/content/en/JobPosting/developer-advocate.mdx +0 -47
- package/templates/content/en/JobPosting/senior-fullstack-engineer.mdx +0 -57
- package/templates/content/en/LandingPage/aeo-audit.mdx +0 -19
- package/templates/content/en/LandingPage/aeo-audit.schema.json +0 -92
- package/templates/content/en/LandingPage/agency-waitlist.mdx +0 -340
- package/templates/content/en/LandingPage/agency-waitlist.schema.json +0 -152
- package/templates/content/en/LandingPage/developers.mdx +0 -19
- package/templates/content/en/LandingPage/developers.schema.json +0 -109
- package/templates/content/en/LandingPage/for-agencies.mdx +0 -390
- package/templates/content/en/LandingPage/for-agencies.schema.json +0 -107
- package/templates/content/en/LandingPage/for-ai-search-agencies.mdx +0 -417
- package/templates/content/en/LandingPage/for-ai-search-agencies.schema.json +0 -105
- package/templates/content/en/LandingPage/for-businesses.mdx +0 -19
- package/templates/content/en/LandingPage/for-businesses.schema.json +0 -96
- package/templates/content/en/LandingPage/platform.mdx +0 -369
- package/templates/content/en/LandingPage/platform.schema.json +0 -166
- package/templates/content/en/LandingPage/vs-ai-website-builders.mdx +0 -19
- package/templates/content/en/LandingPage/vs-ai-website-builders.schema.json +0 -102
- package/templates/content/en/LandingPage/vs-wordpress.mdx +0 -19
- package/templates/content/en/LandingPage/vs-wordpress.schema.json +0 -53
- package/templates/content/en/NewsletterSignup/newsletter.mdx +0 -236
- package/templates/content/en/NewsletterSignup/newsletter.schema.json +0 -91
- package/templates/content/en/Organization/site-owner.mdx +0 -16
- package/templates/content/en/Partner/prisma.mdx +0 -31
- package/templates/content/en/Partner/supabase.mdx +0 -30
- package/templates/content/en/Partner/vercel.mdx +0 -28
- package/templates/content/en/PartnersList/partners.mdx +0 -22
- package/templates/content/en/Person/founder.mdx +0 -18
- package/templates/content/en/Pricing/pricing.mdx +0 -538
- package/templates/content/en/Pricing/pricing.schema.json +0 -209
- package/templates/content/en/PrivacyPage/privacy.mdx +0 -165
- package/templates/content/en/PrivacyPage/privacy.schema.json +0 -64
- package/templates/content/en/Product/ailk.mdx +0 -19
- package/templates/content/en/Product/ailk.schema.json +0 -94
- package/templates/content/en/Product/api-launch-kit.mdx +0 -26
- package/templates/content/en/Product/launch-kit.mdx +0 -28
- package/templates/content/en/ProductsList/products.mdx +0 -26
- package/templates/content/en/Project/ailk-phase-2.mdx +0 -54
- package/templates/content/en/ProjectsList/projects.mdx +0 -25
- package/templates/content/en/ResourceDetail/aeo-scoring-guide.mdx +0 -27
- package/templates/content/en/ResourceDetail/content-model-whitepaper.mdx +0 -28
- package/templates/content/en/ResourceDetail/schema-org-quick-reference.mdx +0 -39
- package/templates/content/en/ResourcesHub/resources.mdx +0 -22
- package/templates/content/en/Service/consulting.mdx +0 -22
- package/templates/content/en/Service/implementation.mdx +0 -30
- package/templates/content/en/Service/launch-service.mdx +0 -232
- package/templates/content/en/Service/launch.mdx +0 -228
- package/templates/content/en/ServicesList/services.mdx +0 -84
- package/templates/content/en/SoftwareProduct/ailk-aeo.mdx +0 -44
- package/templates/content/en/SoftwareProduct/ailk-content-adapters.mdx +0 -47
- package/templates/content/en/SoftwareProduct/ailk-schema.mdx +0 -49
- package/templates/content/en/TeamList/team.mdx +0 -63
- package/templates/content/en/TeamMember/founder.mdx +0 -72
- package/templates/content/en/TermsPage/terms.mdx +0 -19
- package/templates/content/en/TermsPage/terms.schema.json +0 -99
- package/templates/content/en/TestimonialsList/testimonials.mdx +0 -44
- package/templates/content/en/UseCasesList/use-cases.mdx +0 -30
- package/templates/content/en/Whitepaper/ax-first-product-development.mdx +0 -27
- package/templates/content/en/Whitepaper/open-core-commercial-strategy.mdx +0 -27
- package/templates/content/en/Whitepaper/structured-data-for-answer-engines.mdx +0 -31
- package/templates/content/en-XA/AboutPage/about.mdx +0 -8
- package/templates/content/en-XA/FAQPage/faq.mdx +0 -8
- package/templates/content/en-XA/HomePage/home.mdx +0 -8
- package/templates/content/es/_site.mdx +0 -30
- package/templates/content/fr/_site.mdx +0 -30
- package/templates/content/ja/_site.mdx +0 -30
- package/templates/content/pt-BR/AboutPage/about.mdx +0 -8
- package/templates/content/pt-BR/FAQPage/faq.mdx +0 -8
- package/templates/content/pt-BR/HomePage/home.mdx +0 -23
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
// oss: false
|
|
2
|
+
/**
|
|
3
|
+
* @file playbook-compile.test.ts
|
|
4
|
+
* @description Golden tests for FEAT-074 U4a's compile (#4715).
|
|
5
|
+
*
|
|
6
|
+
* Every golden's `source` is run through the VENDORED
|
|
7
|
+
* `check-playbook.py --self-test`-verified checker (`vendor/playbook-method/`)
|
|
8
|
+
* against the REAL vendored play library — AC-1/AC-6. `check-playbook.py`
|
|
9
|
+
* takes `--playbook PATH` (a markdown FILE carrying the
|
|
10
|
+
* `<!-- playbook-source: {...} -->` block), not a bare object, so each
|
|
11
|
+
* assertion writes `result.markdown` (which already contains that exact
|
|
12
|
+
* block — `compilePlaybook` renders it) to a temp file and runs the checker
|
|
13
|
+
* against it.
|
|
14
|
+
*
|
|
15
|
+
* `compileAndStorePlaybook`'s own suite mocks `@working-theory/database`
|
|
16
|
+
* (via `__mocks__/prisma.ts`, mirroring waitlist-scoring.test.ts) and
|
|
17
|
+
* `@working-theory/observability`'s logger, so its Prisma write shape,
|
|
18
|
+
* append-only behavior, and fail-soft catch are directly assertable without
|
|
19
|
+
* a live database.
|
|
20
|
+
*/
|
|
21
|
+
// eslint-disable-next-line no-restricted-syntax -- prisma is a DB boundary; __mocks__/prisma.ts activates the auto-mock (Jest requires explicit call for local files)
|
|
22
|
+
jest.mock("../../lib/prisma.js");
|
|
23
|
+
|
|
24
|
+
const mockLoggerError = jest.fn();
|
|
25
|
+
jest.mock("@working-theory/observability", () => ({
|
|
26
|
+
logger: {
|
|
27
|
+
info: jest.fn(),
|
|
28
|
+
warn: jest.fn(),
|
|
29
|
+
error: (...args: unknown[]) => mockLoggerError(...args),
|
|
30
|
+
debug: jest.fn(),
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
import { createHash } from "node:crypto";
|
|
35
|
+
import { execFileSync } from "node:child_process";
|
|
36
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
37
|
+
import { tmpdir } from "node:os";
|
|
38
|
+
import { dirname, join } from "node:path";
|
|
39
|
+
|
|
40
|
+
import { prisma } from "../../lib/prisma.js";
|
|
41
|
+
import {
|
|
42
|
+
compileAndStorePlaybook,
|
|
43
|
+
compilePlaybook,
|
|
44
|
+
loadVendoredPlayLibrary,
|
|
45
|
+
PlaybookCompileError,
|
|
46
|
+
resolveVendoredLibraryPath,
|
|
47
|
+
type PlayLibrary,
|
|
48
|
+
} from "../playbook-compile.js";
|
|
49
|
+
|
|
50
|
+
// Never `import.meta.url` here (see playbook-compile.ts's header — ts-jest
|
|
51
|
+
// compiles this file to CommonJS, which cannot execute `import.meta`).
|
|
52
|
+
// `resolveVendoredLibraryPath` already does the cwd-relative probing this
|
|
53
|
+
// test needs; the vendor directory is that resolved file's own dirname.
|
|
54
|
+
const VENDOR_DIR = dirname(resolveVendoredLibraryPath());
|
|
55
|
+
const CHECKER_PATH = join(VENDOR_DIR, "check-playbook.py");
|
|
56
|
+
const SCHEMA_PATH = join(VENDOR_DIR, "playbook-source.schema.json");
|
|
57
|
+
const PLAYS_PATH = join(VENDOR_DIR, "targeting-maturity.plays.json");
|
|
58
|
+
|
|
59
|
+
const LIBRARY: PlayLibrary = loadVendoredPlayLibrary();
|
|
60
|
+
|
|
61
|
+
/** Runs the vendored checker against one golden's rendered markdown. Throws
|
|
62
|
+
* (failing the test) on a non-zero exit — `execFileSync` throws on exit != 0. */
|
|
63
|
+
function runCheckerOnMarkdown(markdown: string): void {
|
|
64
|
+
const dir = mkdtempSync(join(tmpdir(), "playbook-checker-"));
|
|
65
|
+
const playbookPath = join(dir, "PLAYBOOK-golden.md");
|
|
66
|
+
try {
|
|
67
|
+
writeFileSync(playbookPath, markdown, "utf8");
|
|
68
|
+
execFileSync(
|
|
69
|
+
"python3",
|
|
70
|
+
[CHECKER_PATH, "--playbook", playbookPath, "--plays", PLAYS_PATH, "--schema", SCHEMA_PATH],
|
|
71
|
+
{ stdio: "pipe" },
|
|
72
|
+
);
|
|
73
|
+
} finally {
|
|
74
|
+
rmSync(dir, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A `predicate`-kind ruleTrace entry, the shape `evaluateWaitlistScoring`
|
|
79
|
+
* produces (`RuleTraceEntry`, `@working-theory/validation`) — hand-built
|
|
80
|
+
* here (not run through the real evaluator) since only the `tier`/`path`/
|
|
81
|
+
* `result` fields matter to `compilePlaybook`'s loop-back detection. */
|
|
82
|
+
function predicateEntry(tier: string, refName: string, result: boolean) {
|
|
83
|
+
return {
|
|
84
|
+
kind: "predicate" as const,
|
|
85
|
+
tier,
|
|
86
|
+
path: `allOf[0].ref(level1_only).allOf[0].ref(level1_signal).anyOf[0].ref(${refName}).eq`,
|
|
87
|
+
node: {},
|
|
88
|
+
result,
|
|
89
|
+
detail: `${refName} = ${result}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
describe("compilePlaybook (D1) — goldens", () => {
|
|
94
|
+
it("Level 0 (the Gate) compiles, unlocks_next = Level 1's ids, passes the vendored checker (AC-1, AC-6)", () => {
|
|
95
|
+
const { source, markdown } = compilePlaybook({
|
|
96
|
+
score: { id: "wlscore_gate", tier: "level_0", ruleTrace: [] },
|
|
97
|
+
plays: LIBRARY,
|
|
98
|
+
leadId: "lead_gate",
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(source).toMatchObject({
|
|
102
|
+
artifact_type: "playbook",
|
|
103
|
+
scope: "person",
|
|
104
|
+
scope_ref: "lead_gate",
|
|
105
|
+
method: "targeting-maturity",
|
|
106
|
+
level: 0,
|
|
107
|
+
compiled_from: "wlscore_gate",
|
|
108
|
+
});
|
|
109
|
+
expect(source.plays).toEqual(["tm-0.1", "tm-0.2"]);
|
|
110
|
+
expect(source.unlocks_next).toEqual(["tm-1.1", "tm-1.2", "tm-1.3", "tm-1.4", "tm-1.5", "tm-1.6"]);
|
|
111
|
+
expect(markdown).toContain('"level":0');
|
|
112
|
+
|
|
113
|
+
runCheckerOnMarkdown(markdown);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("Level 1 via paying customers compiles, unlocks_next = Level 2's ids, no loop-back framing, passes the checker (AC-1)", () => {
|
|
117
|
+
const { source, markdown } = compilePlaybook({
|
|
118
|
+
score: {
|
|
119
|
+
id: "wlscore_l1_customers",
|
|
120
|
+
tier: "level_1",
|
|
121
|
+
ruleTrace: [predicateEntry("level_1", "has_customers", true)],
|
|
122
|
+
},
|
|
123
|
+
plays: LIBRARY,
|
|
124
|
+
leadId: "lead_l1_customers",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expect(source.level).toBe(1);
|
|
128
|
+
expect(source.plays).toEqual(["tm-1.1", "tm-1.2", "tm-1.3", "tm-1.4", "tm-1.5", "tm-1.6"]);
|
|
129
|
+
expect(source.unlocks_next).toEqual(["tm-2.1", "tm-2.2", "tm-2.3"]);
|
|
130
|
+
expect(markdown).not.toContain("loop-back");
|
|
131
|
+
|
|
132
|
+
runCheckerOnMarkdown(markdown);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("Level 1 via a confirmed-Fit cohort renders the Level-6 loop-back framing, source otherwise identical (AC-1)", () => {
|
|
136
|
+
const { source, markdown } = compilePlaybook({
|
|
137
|
+
score: {
|
|
138
|
+
id: "wlscore_l1_cohort",
|
|
139
|
+
tier: "level_1",
|
|
140
|
+
ruleTrace: [predicateEntry("level_1", "has_confirmed_fit_cohort", true)],
|
|
141
|
+
},
|
|
142
|
+
plays: LIBRARY,
|
|
143
|
+
leadId: "lead_l1_cohort",
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
expect(source.level).toBe(1);
|
|
147
|
+
expect(source.plays).toEqual(["tm-1.1", "tm-1.2", "tm-1.3", "tm-1.4", "tm-1.5", "tm-1.6"]);
|
|
148
|
+
expect(source.unlocks_next).toEqual(["tm-2.1", "tm-2.2", "tm-2.3"]);
|
|
149
|
+
expect(markdown).toContain("loop-back");
|
|
150
|
+
|
|
151
|
+
runCheckerOnMarkdown(markdown);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("Level 5 compiles, unlocks_next = Level 7's ids (never 6, which the method has no such Level for) (AC-1)", () => {
|
|
155
|
+
const { source, markdown } = compilePlaybook({
|
|
156
|
+
score: { id: "wlscore_l5", tier: "level_5", ruleTrace: [] },
|
|
157
|
+
plays: LIBRARY,
|
|
158
|
+
leadId: "lead_l5",
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(source.level).toBe(5);
|
|
162
|
+
expect(source.plays).toEqual(["tm-5.1", "tm-5.2", "tm-5.3", "tm-5.4", "tm-5.5", "tm-5.6"]);
|
|
163
|
+
expect(source.unlocks_next).toEqual([
|
|
164
|
+
"tm-7.1",
|
|
165
|
+
"tm-7.2",
|
|
166
|
+
"tm-7.3",
|
|
167
|
+
"tm-7.4",
|
|
168
|
+
"tm-7.5",
|
|
169
|
+
"tm-7.6",
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
runCheckerOnMarkdown(markdown);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("Level 8 compiles, unlocks_next = Level 7's ids — library-declared, never level + 1 = 9 (AC-1)", () => {
|
|
176
|
+
const { source, markdown } = compilePlaybook({
|
|
177
|
+
score: { id: "wlscore_l8", tier: "level_8", ruleTrace: [] },
|
|
178
|
+
plays: LIBRARY,
|
|
179
|
+
leadId: "lead_l8",
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
expect(source.level).toBe(8);
|
|
183
|
+
expect(source.plays).toEqual(["tm-8.1", "tm-8.2", "tm-8.3", "tm-8.4"]);
|
|
184
|
+
expect(source.unlocks_next).toEqual([
|
|
185
|
+
"tm-7.1",
|
|
186
|
+
"tm-7.2",
|
|
187
|
+
"tm-7.3",
|
|
188
|
+
"tm-7.4",
|
|
189
|
+
"tm-7.5",
|
|
190
|
+
"tm-7.6",
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
runCheckerOnMarkdown(markdown);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("compilePlaybook — determinism (AC-2)", () => {
|
|
198
|
+
it("compiling the same score twice yields byte-identical markdown and deep-equal source", () => {
|
|
199
|
+
const input = {
|
|
200
|
+
score: {
|
|
201
|
+
id: "wlscore_det",
|
|
202
|
+
tier: "level_7",
|
|
203
|
+
ruleTrace: [predicateEntry("level_7", "validated_icp", true)],
|
|
204
|
+
},
|
|
205
|
+
plays: LIBRARY,
|
|
206
|
+
leadId: "lead_det",
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const first = compilePlaybook(input);
|
|
210
|
+
const second = compilePlaybook(input);
|
|
211
|
+
|
|
212
|
+
expect(second.markdown).toBe(first.markdown);
|
|
213
|
+
expect(second.source).toEqual(first.source);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe("compilePlaybook — fail-soft compile errors (AC-4, spec §5.3)", () => {
|
|
218
|
+
it("throws PlaybookCompileError for an unrecognized tier", () => {
|
|
219
|
+
expect(() =>
|
|
220
|
+
compilePlaybook({
|
|
221
|
+
score: { id: "wlscore_bad", tier: "level_unresolved", ruleTrace: [] },
|
|
222
|
+
plays: LIBRARY,
|
|
223
|
+
leadId: "lead_bad",
|
|
224
|
+
}),
|
|
225
|
+
).toThrow(PlaybookCompileError);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("throws PlaybookCompileError when the library declares no plays for the tier's Level", () => {
|
|
229
|
+
const emptyLibrary: PlayLibrary = { version: "1.0.0", method: "targeting-maturity", levels: [] };
|
|
230
|
+
expect(() =>
|
|
231
|
+
compilePlaybook({
|
|
232
|
+
score: { id: "wlscore_empty", tier: "level_3", ruleTrace: [] },
|
|
233
|
+
plays: emptyLibrary,
|
|
234
|
+
leadId: "lead_empty",
|
|
235
|
+
}),
|
|
236
|
+
).toThrow(PlaybookCompileError);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe("compileAndStorePlaybook (D4) — the Prisma-touching wrapper", () => {
|
|
241
|
+
beforeEach(() => {
|
|
242
|
+
jest.clearAllMocks();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("creates exactly one PlaybookInstance row carrying the compiled source + markdown (AC-3)", async () => {
|
|
246
|
+
(prisma.playbookInstance.create as jest.Mock).mockResolvedValue({ id: "pbk_1" });
|
|
247
|
+
|
|
248
|
+
await compileAndStorePlaybook({
|
|
249
|
+
siteId: "site-abc",
|
|
250
|
+
leadId: "lead-1",
|
|
251
|
+
experimentKey: "targeting-maturity",
|
|
252
|
+
scoreId: "wlscore_1",
|
|
253
|
+
tier: "level_1",
|
|
254
|
+
ruleTrace: [],
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
expect(prisma.playbookInstance.create).toHaveBeenCalledTimes(1);
|
|
258
|
+
const [call] = (prisma.playbookInstance.create as jest.Mock).mock.calls[0]!;
|
|
259
|
+
expect(call.data).toMatchObject({
|
|
260
|
+
siteId: "site-abc",
|
|
261
|
+
leadId: "lead-1",
|
|
262
|
+
experimentKey: "targeting-maturity",
|
|
263
|
+
scoreId: "wlscore_1",
|
|
264
|
+
tier: "level_1",
|
|
265
|
+
level: 1,
|
|
266
|
+
});
|
|
267
|
+
expect(call.data.source).toMatchObject({ level: 1, compiled_from: "wlscore_1", scope_ref: "lead-1" });
|
|
268
|
+
expect(typeof call.data.markdown).toBe("string");
|
|
269
|
+
expect(call.data.markdown).toContain("playbook-source");
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("append-only: a second call for the same lead creates a SECOND row, never an update/upsert (AC-3)", async () => {
|
|
273
|
+
(prisma.playbookInstance.create as jest.Mock)
|
|
274
|
+
.mockResolvedValueOnce({ id: "pbk_1" })
|
|
275
|
+
.mockResolvedValueOnce({ id: "pbk_2" });
|
|
276
|
+
|
|
277
|
+
await compileAndStorePlaybook({
|
|
278
|
+
siteId: "site-abc",
|
|
279
|
+
leadId: "lead-1",
|
|
280
|
+
experimentKey: "targeting-maturity",
|
|
281
|
+
scoreId: "wlscore_1",
|
|
282
|
+
tier: "level_1",
|
|
283
|
+
ruleTrace: [],
|
|
284
|
+
});
|
|
285
|
+
await compileAndStorePlaybook({
|
|
286
|
+
siteId: "site-abc",
|
|
287
|
+
leadId: "lead-1",
|
|
288
|
+
experimentKey: "targeting-maturity",
|
|
289
|
+
scoreId: "wlscore_2",
|
|
290
|
+
tier: "level_2",
|
|
291
|
+
ruleTrace: [],
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Two calls -> two creates, distinct rows (the second scoreId), never a
|
|
295
|
+
// single row mutated in place — the append-only contract (D2).
|
|
296
|
+
expect(prisma.playbookInstance.create).toHaveBeenCalledTimes(2);
|
|
297
|
+
const [firstCall] = (prisma.playbookInstance.create as jest.Mock).mock.calls[0]!;
|
|
298
|
+
const [secondCall] = (prisma.playbookInstance.create as jest.Mock).mock.calls[1]!;
|
|
299
|
+
expect(firstCall.data.scoreId).toBe("wlscore_1");
|
|
300
|
+
expect(secondCall.data.scoreId).toBe("wlscore_2");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("a compile failure (an unrecognized tier) is logged and never throws — the score is unaffected (AC-4)", async () => {
|
|
304
|
+
await expect(
|
|
305
|
+
compileAndStorePlaybook({
|
|
306
|
+
siteId: "site-abc",
|
|
307
|
+
leadId: "lead-1",
|
|
308
|
+
experimentKey: "targeting-maturity",
|
|
309
|
+
scoreId: "wlscore_1",
|
|
310
|
+
tier: "level_unresolved",
|
|
311
|
+
ruleTrace: [],
|
|
312
|
+
}),
|
|
313
|
+
).resolves.toBeUndefined();
|
|
314
|
+
|
|
315
|
+
expect(prisma.playbookInstance.create).not.toHaveBeenCalled();
|
|
316
|
+
expect(mockLoggerError).toHaveBeenCalledWith(
|
|
317
|
+
expect.objectContaining({
|
|
318
|
+
siteId: "site-abc",
|
|
319
|
+
experimentKey: "targeting-maturity",
|
|
320
|
+
leadId: "lead-1",
|
|
321
|
+
kind: "playbook_compile_failed",
|
|
322
|
+
}),
|
|
323
|
+
expect.any(String),
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("a Prisma write failure is logged and never throws (AC-4)", async () => {
|
|
328
|
+
(prisma.playbookInstance.create as jest.Mock).mockRejectedValue(new Error("db down"));
|
|
329
|
+
|
|
330
|
+
await expect(
|
|
331
|
+
compileAndStorePlaybook({
|
|
332
|
+
siteId: "site-abc",
|
|
333
|
+
leadId: "lead-1",
|
|
334
|
+
experimentKey: "targeting-maturity",
|
|
335
|
+
scoreId: "wlscore_1",
|
|
336
|
+
tier: "level_1",
|
|
337
|
+
ruleTrace: [],
|
|
338
|
+
}),
|
|
339
|
+
).resolves.toBeUndefined();
|
|
340
|
+
|
|
341
|
+
expect(mockLoggerError).toHaveBeenCalledWith(
|
|
342
|
+
expect.objectContaining({ kind: "playbook_compile_failed" }),
|
|
343
|
+
expect.any(String),
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("a missing vendored library file degrades like any other compile failure — never throws at import or at call time (security review M1, AC-4)", async () => {
|
|
348
|
+
// A fresh module instance (its own memoization cache) with process.cwd()
|
|
349
|
+
// pointed at a path with no vendor/ tree above it, so every candidate in
|
|
350
|
+
// resolveVendoredLibraryPath's probe misses and the fallback readFileSync
|
|
351
|
+
// throws ENOENT — exactly M1's failure mode, exercised WITHOUT mocking
|
|
352
|
+
// node:fs (a real missing-file read, not a simulated one).
|
|
353
|
+
let freshCompileAndStorePlaybook!: typeof compileAndStorePlaybook;
|
|
354
|
+
jest.isolateModules(() => {
|
|
355
|
+
freshCompileAndStorePlaybook = require("../playbook-compile.js").compileAndStorePlaybook;
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// The load is LAZY (M1) — it happens on the CALL below, not at the
|
|
359
|
+
// require() above — so the cwd mock must still be active here, and is
|
|
360
|
+
// restored only after the call that exercises it.
|
|
361
|
+
const cwdSpy = jest.spyOn(process, "cwd").mockReturnValue("/nonexistent-root-for-m1-test");
|
|
362
|
+
let result: unknown;
|
|
363
|
+
try {
|
|
364
|
+
result = await freshCompileAndStorePlaybook({
|
|
365
|
+
siteId: "site-abc",
|
|
366
|
+
leadId: "lead-1",
|
|
367
|
+
experimentKey: "targeting-maturity",
|
|
368
|
+
scoreId: "wlscore_missing_lib",
|
|
369
|
+
tier: "level_1",
|
|
370
|
+
ruleTrace: [],
|
|
371
|
+
});
|
|
372
|
+
} finally {
|
|
373
|
+
cwdSpy.mockRestore();
|
|
374
|
+
}
|
|
375
|
+
expect(result).toBeUndefined();
|
|
376
|
+
|
|
377
|
+
expect(prisma.playbookInstance.create).not.toHaveBeenCalled();
|
|
378
|
+
expect(mockLoggerError).toHaveBeenCalledWith(
|
|
379
|
+
expect.objectContaining({
|
|
380
|
+
siteId: "site-abc",
|
|
381
|
+
experimentKey: "targeting-maturity",
|
|
382
|
+
leadId: "lead-1",
|
|
383
|
+
kind: "playbook_compile_failed",
|
|
384
|
+
}),
|
|
385
|
+
expect.any(String),
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
describe("vendored checker self-test + provenance (AC-6)", () => {
|
|
391
|
+
it("check-playbook.py --self-test exits 0", () => {
|
|
392
|
+
expect(() => execFileSync("python3", [CHECKER_PATH, "--self-test"], { stdio: "pipe" })).not.toThrow();
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it("each vendored file's sha256 equals the hash recorded in PROVENANCE.md", () => {
|
|
396
|
+
const provenance = readFileSync(join(VENDOR_DIR, "PROVENANCE.md"), "utf8");
|
|
397
|
+
for (const file of [
|
|
398
|
+
"check-playbook.py",
|
|
399
|
+
"playbook-source.schema.json",
|
|
400
|
+
"targeting-maturity.plays.json",
|
|
401
|
+
]) {
|
|
402
|
+
const actual = createHash("sha256").update(readFileSync(join(VENDOR_DIR, file))).digest("hex");
|
|
403
|
+
expect(provenance).toContain(actual);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
});
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file playbook-render.test.ts
|
|
3
|
+
* @description Golden tests for FEAT-074 U4b's renderer (#4718, AC-1/AC-2/AC-6).
|
|
4
|
+
*
|
|
5
|
+
* Reuses `compilePlaybook` (U4a) to produce a real `{source, markdown}` pair
|
|
6
|
+
* from the vendored play library for each golden — the SAME goldens
|
|
7
|
+
* `playbook-compile.test.ts` exercises (Level 0, Level 1 via paying
|
|
8
|
+
* customers, Level 1 via the confirmed-Fit cohort loop-back, Level 5, Level
|
|
9
|
+
* 8), so the render is proven against the real compile output, not a
|
|
10
|
+
* hand-rolled `source`/`markdown` pair.
|
|
11
|
+
*
|
|
12
|
+
* PDF page count is read via `pdf-lib` itself (`PDFDocument.load`, already a
|
|
13
|
+
* production dependency — no ESM friction under Jest). PDF TEXT is read by
|
|
14
|
+
* shelling out to a standalone Node ESM script that drives `pdfjs-dist`'s
|
|
15
|
+
* legacy Node build: `pdfjs-dist/legacy/build/pdf.mjs` uses `import.meta.url`
|
|
16
|
+
* internally, which Jest's CommonJS-compiled test runner cannot load via a
|
|
17
|
+
* dynamic `import()` (verified: `SyntaxError: Cannot use 'import.meta'
|
|
18
|
+
* outside a module`) — mirrors `playbook-compile.test.ts`'s own
|
|
19
|
+
* `execFileSync`-a-real-separate-process pattern (there, `check-playbook.py`;
|
|
20
|
+
* here, a small Node ESM extractor script written to a temp file per call).
|
|
21
|
+
*/
|
|
22
|
+
import { execFileSync } from "node:child_process";
|
|
23
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
|
|
27
|
+
import { PDFDocument } from "pdf-lib";
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
compilePlaybook,
|
|
31
|
+
loadVendoredPlayLibrary,
|
|
32
|
+
type PlayLibrary,
|
|
33
|
+
} from "../playbook-compile.js";
|
|
34
|
+
import { PlaybookRenderError, renderPlaybookPdf } from "../playbook-render.js";
|
|
35
|
+
|
|
36
|
+
const LIBRARY: PlayLibrary = loadVendoredPlayLibrary();
|
|
37
|
+
|
|
38
|
+
/** A `predicate`-kind ruleTrace entry (mirrors playbook-compile.test.ts's
|
|
39
|
+
* own `predicateEntry` helper — only `tier`/`path`/`result` matter to
|
|
40
|
+
* `compilePlaybook`'s loop-back detection). */
|
|
41
|
+
function predicateEntry(tier: string, refName: string, result: boolean) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "predicate" as const,
|
|
44
|
+
tier,
|
|
45
|
+
path: `allOf[0].ref(level1_only).allOf[0].ref(level1_signal).anyOf[0].ref(${refName}).eq`,
|
|
46
|
+
node: {},
|
|
47
|
+
result,
|
|
48
|
+
detail: `${refName} = ${result}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ─── Extraction helper — a standalone Node ESM child process ──────────────
|
|
53
|
+
|
|
54
|
+
const EXTRACT_SCRIPT = `
|
|
55
|
+
import { readFileSync } from "node:fs";
|
|
56
|
+
import { pathToFileURL } from "node:url";
|
|
57
|
+
// pdfjs-dist's legacy Node build (getDocument) calls Promise.withResolvers(),
|
|
58
|
+
// a Node 22 API. CI pins Node 20.19 (no Promise.withResolvers), so guard it
|
|
59
|
+
// here -- before the pdfjs dynamic import below -- with a spec-compliant
|
|
60
|
+
// polyfill (https://tc39.es/proposal-promise-with-resolvers/).
|
|
61
|
+
if (typeof Promise.withResolvers !== "function") {
|
|
62
|
+
Promise.withResolvers = function () {
|
|
63
|
+
let resolve, reject;
|
|
64
|
+
const promise = new Promise((res, rej) => {
|
|
65
|
+
resolve = res;
|
|
66
|
+
reject = rej;
|
|
67
|
+
});
|
|
68
|
+
return { promise, resolve, reject };
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const bytes = new Uint8Array(readFileSync(process.argv[2]));
|
|
72
|
+
const pdfjs = await import(pathToFileURL(process.argv[3]).href);
|
|
73
|
+
const doc = await pdfjs.getDocument({
|
|
74
|
+
data: bytes,
|
|
75
|
+
useWorkerFetch: false,
|
|
76
|
+
isEvalSupported: false,
|
|
77
|
+
useSystemFonts: true,
|
|
78
|
+
}).promise;
|
|
79
|
+
const pageTexts = [];
|
|
80
|
+
for (let i = 1; i <= doc.numPages; i++) {
|
|
81
|
+
const page = await doc.getPage(i);
|
|
82
|
+
const textContent = await page.getTextContent();
|
|
83
|
+
pageTexts.push(textContent.items.map((it) => it.str).join(" "));
|
|
84
|
+
}
|
|
85
|
+
process.stdout.write(JSON.stringify({ text: pageTexts.join("\\n") }));
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Absolute path to pdfjs-dist's legacy Node entry, resolved from THIS
|
|
90
|
+
* (CommonJS-compiled, per ts-jest's `module: 'commonjs'` preset — see the
|
|
91
|
+
* file header) test module's own `require`. Passed to the child process by
|
|
92
|
+
* absolute path — never a bare `"pdfjs-dist/..."` specifier — because the
|
|
93
|
+
* extractor script is written to a temp directory outside this workspace's
|
|
94
|
+
* `node_modules` resolution chain, where a bare specifier cannot resolve.
|
|
95
|
+
*/
|
|
96
|
+
const PDFJS_LEGACY_ENTRY = require.resolve("pdfjs-dist/legacy/build/pdf.mjs");
|
|
97
|
+
|
|
98
|
+
/** Extracts the concatenated text of every page of a PDF's bytes. */
|
|
99
|
+
function extractPdfText(bytes: Uint8Array): string {
|
|
100
|
+
const dir = mkdtempSync(join(tmpdir(), "playbook-pdf-extract-"));
|
|
101
|
+
try {
|
|
102
|
+
const scriptPath = join(dir, "extract.mjs");
|
|
103
|
+
const pdfPath = join(dir, "playbook.pdf");
|
|
104
|
+
writeFileSync(scriptPath, EXTRACT_SCRIPT, "utf8");
|
|
105
|
+
writeFileSync(pdfPath, bytes);
|
|
106
|
+
const out = execFileSync(
|
|
107
|
+
"node",
|
|
108
|
+
[scriptPath, pdfPath, PDFJS_LEGACY_ENTRY],
|
|
109
|
+
{ encoding: "utf8" },
|
|
110
|
+
);
|
|
111
|
+
return (JSON.parse(out) as { text: string }).text;
|
|
112
|
+
} finally {
|
|
113
|
+
rmSync(dir, { recursive: true, force: true });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function pageCount(bytes: Uint8Array): Promise<number> {
|
|
118
|
+
const doc = await PDFDocument.load(bytes);
|
|
119
|
+
return doc.getPageCount();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Renders and asserts the AC-6 <= 2s bound on EVERY golden call site, not
|
|
123
|
+
* only one -- a per-golden bound, since the PDF renders per-request inside
|
|
124
|
+
* the download route and the largest golden (Level 5, 6 own plays + 6
|
|
125
|
+
* unlock plays) is exactly the case the bound exists to guard. */
|
|
126
|
+
async function renderTimed(
|
|
127
|
+
input: Parameters<typeof renderPlaybookPdf>[0],
|
|
128
|
+
): Promise<Uint8Array> {
|
|
129
|
+
const start = Date.now();
|
|
130
|
+
const bytes = await renderPlaybookPdf(input);
|
|
131
|
+
expect(Date.now() - start).toBeLessThanOrEqual(2000);
|
|
132
|
+
return bytes;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Every play title the library declares for `level` — used to assert the
|
|
136
|
+
* rendered PDF's extracted text contains all of them (never hand-duplicated
|
|
137
|
+
* as a literal string list, so this test can't drift from the library). */
|
|
138
|
+
function titlesForLevel(level: number): string[] {
|
|
139
|
+
const entry = LIBRARY.levels.find((l) => l.level === level);
|
|
140
|
+
if (!entry) throw new Error(`no fixture level ${level} in the vendored library`);
|
|
141
|
+
return entry.plays.map((p) => p.title);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** The play ids the library declares for `level` — used to assert
|
|
145
|
+
* `compilePlaybook`'s `source.unlocks_next` matches the library exactly
|
|
146
|
+
* (mirrors playbook-compile.test.ts's own equivalent assertions). */
|
|
147
|
+
function idsForLevel(level: number): string[] {
|
|
148
|
+
const entry = LIBRARY.levels.find((l) => l.level === level);
|
|
149
|
+
if (!entry) throw new Error(`no fixture level ${level} in the vendored library`);
|
|
150
|
+
return entry.plays.map((p) => p.id);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ─── The forbidden-token matcher (spec §2.1/AC-2) ──────────────────────────
|
|
154
|
+
|
|
155
|
+
const WHOLE_WORD_FORBIDDEN = /\b(tier|cell|coefficient|stage)\b/;
|
|
156
|
+
const SUBSTRING_FORBIDDEN = "level_";
|
|
157
|
+
|
|
158
|
+
function assertNoForbiddenTokens(text: string): void {
|
|
159
|
+
const lower = text.toLowerCase();
|
|
160
|
+
expect(WHOLE_WORD_FORBIDDEN.test(lower)).toBe(false);
|
|
161
|
+
expect(lower).not.toContain(SUBSTRING_FORBIDDEN);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ─── Goldens — Level 0, 1 (both routes), 5, 8 — mirrors playbook-compile.test.ts ──
|
|
165
|
+
|
|
166
|
+
describe("renderPlaybookPdf — goldens (AC-1, AC-2, AC-6)", () => {
|
|
167
|
+
it("Level 0 (the Gate): labelled 'Gate', never 'Level 0'; every Level-0 play title present; no forbidden tokens; <= 6 pages; <= 2s", async () => {
|
|
168
|
+
const { source, markdown } = compilePlaybook({
|
|
169
|
+
score: { id: "wlscore_gate", tier: "level_0", ruleTrace: [] },
|
|
170
|
+
plays: LIBRARY,
|
|
171
|
+
leadId: "lead_gate",
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const bytes = await renderTimed({ source, markdown, locale: "en" });
|
|
175
|
+
|
|
176
|
+
expect(await pageCount(bytes)).toBeLessThanOrEqual(6);
|
|
177
|
+
|
|
178
|
+
const text = extractPdfText(bytes);
|
|
179
|
+
expect(text).toContain("Gate");
|
|
180
|
+
expect(text).not.toContain("Level 0");
|
|
181
|
+
for (const title of titlesForLevel(0)) {
|
|
182
|
+
expect(text).toContain(title);
|
|
183
|
+
}
|
|
184
|
+
assertNoForbiddenTokens(text);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("Level 1 via paying customers: labelled 'Level 1'; every Level-1 play title present; no forbidden tokens; <= 2s", async () => {
|
|
188
|
+
const { source, markdown } = compilePlaybook({
|
|
189
|
+
score: {
|
|
190
|
+
id: "wlscore_l1_customers",
|
|
191
|
+
tier: "level_1",
|
|
192
|
+
ruleTrace: [predicateEntry("level_1", "has_customers", true)],
|
|
193
|
+
},
|
|
194
|
+
plays: LIBRARY,
|
|
195
|
+
leadId: "lead_l1_customers",
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const bytes = await renderTimed({ source, markdown, locale: "en" });
|
|
199
|
+
expect(await pageCount(bytes)).toBeLessThanOrEqual(6);
|
|
200
|
+
|
|
201
|
+
const text = extractPdfText(bytes);
|
|
202
|
+
expect(text).toContain("Level 1");
|
|
203
|
+
for (const title of titlesForLevel(1)) {
|
|
204
|
+
expect(text).toContain(title);
|
|
205
|
+
}
|
|
206
|
+
assertNoForbiddenTokens(text);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("Level 1 via the confirmed-Fit cohort loop-back: same Level-1 render contract as the paying-customers golden; <= 2s", async () => {
|
|
210
|
+
const { source, markdown } = compilePlaybook({
|
|
211
|
+
score: {
|
|
212
|
+
id: "wlscore_l1_cohort",
|
|
213
|
+
tier: "level_1",
|
|
214
|
+
ruleTrace: [predicateEntry("level_1", "has_confirmed_fit_cohort", true)],
|
|
215
|
+
},
|
|
216
|
+
plays: LIBRARY,
|
|
217
|
+
leadId: "lead_l1_cohort",
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const bytes = await renderTimed({ source, markdown, locale: "en" });
|
|
221
|
+
expect(await pageCount(bytes)).toBeLessThanOrEqual(6);
|
|
222
|
+
|
|
223
|
+
const text = extractPdfText(bytes);
|
|
224
|
+
expect(text).toContain("Level 1");
|
|
225
|
+
for (const title of titlesForLevel(1)) {
|
|
226
|
+
expect(text).toContain(title);
|
|
227
|
+
}
|
|
228
|
+
assertNoForbiddenTokens(text);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("Level 5 (unlocks Level 7 -- never 6, the largest golden: 6 own plays + 6 unlock plays): every title present in both sections, no forbidden tokens, <= 6 pages, <= 2s", async () => {
|
|
232
|
+
const { source, markdown } = compilePlaybook({
|
|
233
|
+
score: { id: "wlscore_l5", tier: "level_5", ruleTrace: [] },
|
|
234
|
+
plays: LIBRARY,
|
|
235
|
+
leadId: "lead_l5",
|
|
236
|
+
});
|
|
237
|
+
expect(source.unlocks_next).toEqual(idsForLevel(7));
|
|
238
|
+
|
|
239
|
+
const bytes = await renderTimed({ source, markdown, locale: "en" });
|
|
240
|
+
expect(await pageCount(bytes)).toBeLessThanOrEqual(6);
|
|
241
|
+
|
|
242
|
+
const text = extractPdfText(bytes);
|
|
243
|
+
expect(text).toContain("Level 5");
|
|
244
|
+
expect(text).toContain("Level 7");
|
|
245
|
+
for (const title of [...titlesForLevel(5), ...titlesForLevel(7)]) {
|
|
246
|
+
expect(text).toContain(title);
|
|
247
|
+
}
|
|
248
|
+
assertNoForbiddenTokens(text);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("Level 8 (unlocks Level 7, never 9 -- library-declared, non-monotonic): every title present, no forbidden tokens; <= 2s", async () => {
|
|
252
|
+
const { source, markdown } = compilePlaybook({
|
|
253
|
+
score: { id: "wlscore_l8", tier: "level_8", ruleTrace: [] },
|
|
254
|
+
plays: LIBRARY,
|
|
255
|
+
leadId: "lead_l8",
|
|
256
|
+
});
|
|
257
|
+
expect(source.unlocks_next).toEqual(idsForLevel(7));
|
|
258
|
+
|
|
259
|
+
const bytes = await renderTimed({ source, markdown, locale: "en" });
|
|
260
|
+
expect(await pageCount(bytes)).toBeLessThanOrEqual(6);
|
|
261
|
+
|
|
262
|
+
const text = extractPdfText(bytes);
|
|
263
|
+
expect(text).toContain("Level 8");
|
|
264
|
+
expect(text).toContain("Level 7");
|
|
265
|
+
for (const title of [...titlesForLevel(8), ...titlesForLevel(7)]) {
|
|
266
|
+
expect(text).toContain(title);
|
|
267
|
+
}
|
|
268
|
+
assertNoForbiddenTokens(text);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// ─── A play id the current library no longer declares — a library defect ──
|
|
273
|
+
|
|
274
|
+
describe("renderPlaybookPdf — library-defect posture (mirrors PlaybookCompileError)", () => {
|
|
275
|
+
it("throws PlaybookRenderError when source names a play id the current library does not declare", async () => {
|
|
276
|
+
const source = {
|
|
277
|
+
artifact_type: "playbook" as const,
|
|
278
|
+
scope: "person" as const,
|
|
279
|
+
scope_ref: "lead_defect",
|
|
280
|
+
method: "targeting-maturity",
|
|
281
|
+
level: 0,
|
|
282
|
+
plays: ["tm-0.1", "tm-999.999"],
|
|
283
|
+
compiled_from: "wlscore_defect",
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
await expect(
|
|
287
|
+
renderPlaybookPdf({ source, markdown: "", locale: "en" }),
|
|
288
|
+
).rejects.toThrow(PlaybookRenderError);
|
|
289
|
+
});
|
|
290
|
+
});
|