create-ailk 0.22.0 → 0.24.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 +27 -14
- package/component-catalog.json +149 -5
- package/component-catalog.md +7 -6
- package/dist/add-module.js +17 -10
- package/dist/add-route.d.ts +55 -1
- package/dist/add-route.js +301 -13
- package/dist/cli.js +27 -10
- package/dist/derive-architecture.d.ts +7 -5
- package/dist/derive-architecture.js +26 -32
- package/dist/lib/design-checks.js +4 -2
- package/dist/lib/env-catalog.js +0 -4
- package/dist/lib/npm-auth.d.ts +9 -0
- package/dist/lib/npm-auth.js +48 -0
- package/dist/lib/scaffold-render-sweep.d.ts +36 -2
- package/dist/lib/scaffold-render-sweep.js +50 -8
- package/dist/module-architecture.js +115 -10
- package/dist/paid-sections.d.ts +21 -2
- package/dist/paid-sections.js +69 -7
- package/dist/seed-flows.d.ts +4 -1
- package/dist/seed-flows.js +50 -4
- package/dist/spoke-checkout.d.ts +38 -35
- package/dist/spoke-checkout.js +66 -229
- package/dist/starter-grid.d.ts +0 -3
- package/dist/starter-grid.js +24 -14
- package/dist/surfaces.js +33 -12
- package/dist/sync-routes.d.ts +68 -5
- package/dist/sync-routes.js +455 -29
- package/dist/template-record.d.ts +1 -1
- package/dist/template-record.js +3 -2
- package/dist/update.js +10 -0
- package/package.json +3 -3
- package/site-templates/_base/content/en/NewsletterSignup/newsletter.mdx +4 -49
- package/site-templates/_base/content/en/Pricing/pricing.mdx +3 -21
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +23 -20
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +28 -14
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +15 -39
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +38 -34
- package/site-templates/marketing-site-free/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/local-business-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/organization-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/person-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/templates/.env.example +13 -7
- package/templates/.github/workflows/ci.yml +13 -0
- package/templates/CLAUDE.md +4 -2
- package/templates/README.md +1 -0
- package/templates/_gitignore +4 -0
- package/templates/apps/api/.env.example +34 -0
- package/templates/apps/api/CLAUDE.md +94 -19
- package/templates/apps/api/package.json +1 -0
- package/templates/apps/api/src/__tests__/factories/in-memory-prisma.ts +2 -0
- package/templates/apps/api/src/bin/stripe-connections-rekey.ts +45 -0
- package/templates/apps/api/src/config/__tests__/stripe-connection-key.test.ts +185 -0
- package/templates/apps/api/src/config/index.ts +109 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -1
- package/templates/apps/api/src/lib/__tests__/flow-rename-race.db.test.ts +116 -0
- package/templates/apps/api/src/lib/__tests__/site.test.ts +16 -0
- package/templates/apps/api/src/lib/error-serializer.ts +74 -7
- package/templates/apps/api/src/lib/site.ts +4 -1
- package/templates/apps/api/src/lib/stripe.ts +77 -4
- package/templates/apps/api/src/lib/webhook-idempotency.ts +66 -2
- package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +218 -0
- package/templates/apps/api/src/middleware/__tests__/write-budget.test.ts +174 -0
- package/templates/apps/api/src/middleware/rate-limit.ts +226 -4
- package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +127 -0
- package/templates/apps/api/src/openapi/spec.ts +343 -7
- package/templates/apps/api/src/routes/billing/plan-checkout.ts +332 -0
- package/templates/apps/api/src/routes/checkout/__tests__/live-key.test.ts +11 -0
- package/templates/apps/api/src/routes/checkout/__tests__/offerings-authorization.test.ts +1426 -0
- package/templates/apps/api/src/routes/checkout/__tests__/session.test.ts +11 -0
- package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +49 -0
- package/templates/apps/api/src/routes/checkout/session.ts +57 -25
- package/templates/apps/api/src/routes/checkout/sessions.ts +232 -82
- package/templates/apps/api/src/routes/consent/__tests__/account.test.ts +5 -5
- package/templates/apps/api/src/routes/consent/__tests__/sign-up-rate-limit.test.ts +160 -0
- package/templates/apps/api/src/routes/consent/account.ts +4 -2
- package/templates/apps/api/src/routes/content/__tests__/get-page.test.ts +2 -2
- package/templates/apps/api/src/routes/content/__tests__/offerings.test.ts +731 -0
- package/templates/apps/api/src/routes/content/__tests__/pricing.test.ts +753 -0
- package/templates/apps/api/src/routes/content/__tests__/shown-offerings.test.ts +762 -0
- package/templates/apps/api/src/routes/content/get-page.ts +34 -119
- package/templates/apps/api/src/routes/content/index.ts +16 -2
- package/templates/apps/api/src/routes/content/list-pages.ts +15 -36
- package/templates/apps/api/src/routes/content/offerings.ts +184 -0
- package/templates/apps/api/src/routes/content/pricing.ts +176 -0
- package/templates/apps/api/src/routes/content/search.ts +16 -45
- package/templates/apps/api/src/routes/content/shown-offerings.ts +229 -0
- package/templates/apps/api/src/routes/leads/index.ts +377 -308
- package/templates/apps/api/src/routes/project-listings/__tests__/me.test.ts +20 -9
- package/templates/apps/api/src/routes/project-listings/__tests__/public.test.ts +17 -6
- package/templates/apps/api/src/routes/project-listings/__tests__/site-answers.test.ts +1 -1
- package/templates/apps/api/src/routes/webhooks/README.md +66 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-flow-checkout.test.ts +1 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-offerings.test.ts +814 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-org-billing.test.ts +80 -68
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-site-filter.test.ts +6 -5
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +8 -2
- package/templates/apps/api/src/routes/webhooks/index.ts +23 -0
- package/templates/apps/api/src/routes/webhooks/stripe-offerings.ts +384 -0
- package/templates/apps/api/src/routes/webhooks/stripe.ts +93 -17
- package/templates/apps/api/src/server.ts +165 -51
- package/templates/apps/api/src/services/__tests__/abandon-email.test.ts +121 -4
- package/templates/apps/api/src/services/__tests__/checkout-plan.test.ts +313 -0
- package/templates/apps/api/src/services/__tests__/deliverable-fulfillment.test.ts +61 -2
- package/templates/apps/api/src/services/__tests__/keyless-workspace-predicate.test.ts +234 -0
- package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +374 -44
- package/templates/apps/api/src/services/__tests__/person.test.ts +260 -1
- package/templates/apps/api/src/services/__tests__/plan-offerings.test.ts +450 -0
- package/templates/apps/api/src/services/__tests__/project-listings.counts.test.ts +202 -0
- package/templates/apps/api/src/services/__tests__/project-listings.fence.test.ts +15 -18
- package/templates/apps/api/src/services/abandon-email.ts +28 -5
- package/templates/apps/api/src/services/deliverable-fulfillment.ts +15 -12
- package/templates/apps/api/src/services/entitlements.ts +157 -1
- package/templates/apps/api/src/services/lead-routing.ts +113 -58
- package/templates/apps/api/src/services/offerings/__tests__/catalog.test.ts +348 -0
- package/templates/apps/api/src/services/offerings/__tests__/checkout-session-record.test.ts +268 -0
- package/templates/apps/api/src/services/offerings/__tests__/connection.test.ts +975 -0
- package/templates/apps/api/src/services/offerings/__tests__/fixtures.ts +416 -0
- package/templates/apps/api/src/services/offerings/__tests__/org-products.test.ts +400 -0
- package/templates/apps/api/src/services/offerings/__tests__/readers.test.ts +685 -0
- package/templates/apps/api/src/services/offerings/__tests__/source.test.ts +231 -0
- package/templates/apps/api/src/services/offerings/catalog.ts +318 -0
- package/templates/apps/api/src/services/offerings/checkout-authorization.ts +403 -0
- package/templates/apps/api/src/services/offerings/checkout-session-record.ts +192 -0
- package/templates/apps/api/src/services/offerings/connection.ts +1083 -0
- package/templates/apps/api/src/services/offerings/index.ts +614 -0
- package/templates/apps/api/src/services/offerings/source.ts +140 -0
- package/templates/apps/api/src/services/offerings/store.ts +150 -0
- package/templates/apps/api/src/services/person.ts +147 -9
- package/templates/apps/api/src/services/plan-offerings.ts +96 -30
- package/templates/apps/api/src/services/project-listings.ts +43 -31
- package/templates/apps/api/src/services/public-site-resolver.ts +19 -14
- package/templates/apps/mcp/CLAUDE.md +32 -18
- package/templates/apps/mcp/__tests__/app-entry.test.ts +2 -2
- package/templates/apps/mcp/__tests__/catalog-drift.test.ts +9 -4
- package/templates/apps/mcp/__tests__/get_offerings.test.ts +358 -0
- package/templates/apps/mcp/__tests__/get_pricing.test.ts +364 -0
- package/templates/apps/mcp/__tests__/http-transport.test.ts +95 -14
- package/templates/apps/mcp/__tests__/lib/content-adapter-parity.test.ts +8 -3
- package/templates/apps/mcp/__tests__/lib/content-adapter.test.ts +0 -25
- package/templates/apps/mcp/__tests__/lib/fail-closed-tools.test.ts +22 -7
- package/templates/apps/mcp/__tests__/list_pages.test.ts +84 -44
- package/templates/apps/mcp/__tests__/locale.test.ts +41 -56
- package/templates/apps/mcp/__tests__/module-exclusion.test.ts +2 -2
- package/templates/apps/mcp/__tests__/rate-limit-write.test.ts +189 -0
- package/templates/apps/mcp/__tests__/read_content.test.ts +115 -78
- package/templates/apps/mcp/__tests__/request_callback.test.ts +63 -128
- package/templates/apps/mcp/__tests__/search_content.test.ts +76 -61
- package/templates/apps/mcp/__tests__/server.test.ts +13 -11
- package/templates/apps/mcp/__tests__/start_purchase.test.ts +208 -12
- package/templates/apps/mcp/__tests__/submit_lead.test.ts +82 -167
- package/templates/apps/mcp/__tests__/subscribe_newsletter.test.ts +59 -130
- package/templates/apps/mcp/__tests__/tools/purchase.test.ts +11 -11
- package/templates/apps/mcp/package.json +1 -0
- package/templates/apps/mcp/src/abuse/index.ts +18 -11
- package/templates/apps/mcp/src/http-transport.ts +47 -9
- package/templates/apps/mcp/src/lib/content-adapter.ts +0 -26
- package/templates/apps/mcp/src/lib/empty-content-adapter.ts +5 -4
- package/templates/apps/mcp/src/lib/shown-offerings.ts +105 -0
- package/templates/apps/mcp/src/lib/site-config.ts +53 -0
- package/templates/apps/mcp/src/server.ts +5 -0
- package/templates/apps/mcp/src/tools/capture_lead.ts +30 -28
- package/templates/apps/mcp/src/tools/get_offerings.ts +47 -30
- package/templates/apps/mcp/src/tools/get_pricing.ts +40 -40
- package/templates/apps/mcp/src/tools/index.ts +22 -21
- package/templates/apps/mcp/src/tools/list_pages.ts +27 -33
- package/templates/apps/mcp/src/tools/purchase.ts +30 -2
- package/templates/apps/mcp/src/tools/read_content.ts +46 -40
- package/templates/apps/mcp/src/tools/request_callback.ts +21 -28
- package/templates/apps/mcp/src/tools/search_content.ts +20 -24
- package/templates/apps/mcp/src/tools/subscribe_newsletter.ts +23 -26
- package/templates/apps/mcp/src/workspace-server.ts +15 -0
- package/templates/apps/web/.env.example +10 -31
- package/templates/apps/web/CLAUDE.md +324 -42
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +189 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +4 -2
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +8 -3
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +22 -144
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +9 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +172 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +149 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +22 -24
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +140 -66
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +57 -22
- package/templates/apps/web/app/[locale]/careers/page.tsx +129 -5
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +119 -11
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +28 -5
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +20 -6
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +1 -1
- package/templates/apps/web/app/[locale]/contact/page.tsx +99 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +237 -5
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +200 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +197 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +430 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +21 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +369 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +12 -73
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +10 -31
- package/templates/apps/web/app/[locale]/layout.tsx +55 -4
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +174 -104
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +95 -58
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +7 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +599 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +216 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +236 -0
- package/templates/apps/web/app/[locale]/pricing/page.tsx +367 -6
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +4 -1
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +17 -0
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +62 -3
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +70 -18
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +30 -9
- package/templates/apps/web/app/api/offerings/checkout/[lookupKey]/route.ts +316 -0
- package/templates/apps/web/app/api/offerings/checkout/__tests__/route.test.ts +810 -0
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +27 -1
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +2 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +265 -0
- package/templates/apps/web/lib/__tests__/magnet-routes.test.ts +64 -0
- package/templates/apps/web/lib/__tests__/newsletter.actions.test.ts +293 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +601 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +67 -8
- package/templates/apps/web/lib/auth-routes.ts +36 -2
- package/templates/apps/web/lib/checkout-config.ts +9 -20
- package/templates/apps/web/lib/deck-page.ts +1 -0
- package/templates/apps/web/lib/deliverable-grant.ts +18 -0
- package/templates/apps/web/lib/in-page-magnet.ts +416 -0
- package/templates/apps/web/lib/magnet-routes.ts +44 -0
- package/templates/apps/web/lib/modules.generated.ts +9 -0
- package/templates/apps/web/lib/newsletter.actions.ts +205 -0
- package/templates/apps/web/lib/offerings-pricing.ts +326 -0
- package/templates/apps/web/lib/posting-title.ts +17 -0
- package/templates/apps/web/lib/sign-up-agreements.ts +4 -2
- package/templates/apps/web/messages/en.json +49 -15
- package/templates/apps/web/middleware.ts +12 -2
- package/templates/apps/web/security-headers.config.ts +17 -0
- package/templates/content/en/BlogList/blog.mdx +4 -71
- package/templates/content/en/BookCall/book-a-call.mdx +1 -41
- package/templates/content/en/BookCall/onsite-estimate.mdx +1 -17
- package/templates/content/en/BookCall/onsite-service.mdx +1 -17
- package/templates/content/en/BookCall/start-project.mdx +1 -17
- package/templates/content/en/ContactPage/contact.mdx +6 -63
- package/templates/content/en/HomePage/home.mdx +3 -21
- package/templates/database/CHANGELOG.md +51 -0
- package/templates/database/__tests__/in-page-magnets-migration.test.ts +161 -0
- package/templates/database/__tests__/offerings-checkout-session.db.test.ts +270 -0
- package/templates/database/__tests__/offerings-migration.test.ts +197 -0
- package/templates/database/__tests__/offerings-shown-price-ids-migration.test.ts +86 -0
- package/templates/database/__tests__/offerings.db.test.ts +303 -0
- package/templates/database/__tests__/seed.test.ts +63 -1
- package/templates/database/__tests__/trial-magnet-migration.test.ts +186 -0
- package/templates/database/auth/schema.prisma +4 -0
- package/templates/database/config/schema.prisma +91 -0
- package/templates/database/migrations/20261020120000_offerings_data_model/migration.sql +146 -0
- package/templates/database/migrations/20261021120000_offerings_checkout_session/migration.sql +77 -0
- package/templates/database/migrations/20261022120000_in_page_magnets/migration.sql +45 -0
- package/templates/database/migrations/20261023120000_offerings_shown_price_ids/migration.sql +47 -0
- package/templates/database/migrations/20261024120000_organization_plan_checkout_session/migration.sql +16 -0
- package/templates/database/migrations/20261025120000_trial_magnet/migration.sql +28 -0
- package/templates/database/migrations/20261026120000_trial_magnet_proof_line/migration.sql +23 -0
- package/templates/database/package.json +1 -1
- package/templates/database/seed.ts +57 -2
- package/templates/tools/lint-architecture.ts +205 -1
- package/versions.json +35 -35
- package/site-templates/marketing-site-free/content/en/Pricing/pricing.mdx +0 -199
- package/templates/apps/api/src/routes/content/slug.ts +0 -9
- package/templates/apps/web/app/[locale]/downloads/__tests__/page-renderer-migration.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/downloads/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/newsletter/__tests__/newsletter.actions.test.ts +0 -139
- package/templates/apps/web/app/[locale]/newsletter/newsletter.actions.ts +0 -93
- package/templates/apps/web/app/api/checkout/[offering]/route.ts +0 -48
- package/templates/apps/web/app/api/checkout/__tests__/route.test.ts +0 -120
- package/templates/apps/web/app/api/checkout/__tests__/success-path.test.ts +0 -86
- package/templates/apps/web/app/api/webhooks/stripe/__tests__/route.test.ts +0 -92
- package/templates/apps/web/app/api/webhooks/stripe/route.ts +0 -31
- package/templates/apps/web/lib/__tests__/checkout.test.ts +0 -243
- package/templates/apps/web/lib/__tests__/meeting-slugs.test.ts +0 -120
- package/templates/apps/web/lib/checkout.ts +0 -93
- package/templates/apps/web/lib/meeting-slugs.ts +0 -63
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
-- #8876 — the Offerings data model (spec
|
|
2
|
+
-- docs/specs/8876-the-offerings-data-model-typed-spec.md D1, D2; contract
|
|
3
|
+
-- docs/specs/8879-the-offerings-security-contract-key-spec.md C1):
|
|
4
|
+
--
|
|
5
|
+
-- stripe_connections (config) — an Organization's own Stripe account by a
|
|
6
|
+
-- restricted key: the mode, the key's last four, the key and webhook
|
|
7
|
+
-- secret as AES-256-GCM ciphertext written only by apps/api's
|
|
8
|
+
-- services/offerings/connection.ts, and a per-connection webhook token.
|
|
9
|
+
-- organization_offerings (config) — the Products an Organization has
|
|
10
|
+
-- switched on (the org-enabled set). Kept when a connection is deleted.
|
|
11
|
+
-- workspace_offerings (config) — the Products one workspace shows, its
|
|
12
|
+
-- Recommended plan and add-on, and the last-good Stripe snapshot.
|
|
13
|
+
--
|
|
14
|
+
-- Three new tables in the house style of 20261003130000_scheduling_connection
|
|
15
|
+
-- (CreateTable + CreateIndex as `prisma migrate diff` emits them, then the
|
|
16
|
+
-- ADR-0031 rule-3 id-format completion, in ONE migration since the tables are
|
|
17
|
+
-- new), plus a format CHECK on each reference column (the
|
|
18
|
+
-- workspace_piece_stages style) and the integrity CHECKs spec D1 names. Plain
|
|
19
|
+
-- scalar keys, no foreign key (ADR 0009 invariant 1).
|
|
20
|
+
--
|
|
21
|
+
-- The two ciphertext envelope CHECKs are the `v1.<iv>.<tag>.<ciphertext>`
|
|
22
|
+
-- base64url shape the cipher writes — a 12-byte IV (16 characters) and a
|
|
23
|
+
-- 16-byte tag (22) — and refuse a Stripe key or signing-secret prefix
|
|
24
|
+
-- anywhere in the value, so a writer bug that stored a key or a secret in
|
|
25
|
+
-- clear, bare or wrapped in the envelope's dots, is refused here
|
|
26
|
+
-- (SEC-8876-3, SEC-PR8955-2).
|
|
27
|
+
--
|
|
28
|
+
-- No backfill, no constraint relaxed, no existing table touched.
|
|
29
|
+
--
|
|
30
|
+
-- Rollback: DROP TABLE "stripe_connections", "organization_offerings",
|
|
31
|
+
-- "workspace_offerings". Every stored connection and selection is lost and
|
|
32
|
+
-- every site returns to its page content.
|
|
33
|
+
|
|
34
|
+
-- CreateTable
|
|
35
|
+
CREATE TABLE "stripe_connections" (
|
|
36
|
+
"id" TEXT NOT NULL DEFAULT ('stripecon_'::text || (uuidv7())::text),
|
|
37
|
+
"organization_id" TEXT NOT NULL,
|
|
38
|
+
"mode" VARCHAR(8) NOT NULL,
|
|
39
|
+
"key_last4" VARCHAR(4) NOT NULL,
|
|
40
|
+
"credential_ciphertext" TEXT NOT NULL,
|
|
41
|
+
"webhook_token" VARCHAR(64) NOT NULL,
|
|
42
|
+
"webhook_secret_ciphertext" TEXT,
|
|
43
|
+
"live_at" TIMESTAMPTZ,
|
|
44
|
+
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
45
|
+
"updated_at" TIMESTAMPTZ NOT NULL,
|
|
46
|
+
|
|
47
|
+
CONSTRAINT "stripe_connections_pkey" PRIMARY KEY ("id")
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- CreateTable
|
|
51
|
+
CREATE TABLE "organization_offerings" (
|
|
52
|
+
"id" TEXT NOT NULL DEFAULT ('orgoffer_'::text || (uuidv7())::text),
|
|
53
|
+
"organization_id" TEXT NOT NULL,
|
|
54
|
+
"enabled_product_ids" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
|
55
|
+
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
56
|
+
"updated_at" TIMESTAMPTZ NOT NULL,
|
|
57
|
+
|
|
58
|
+
CONSTRAINT "organization_offerings_pkey" PRIMARY KEY ("id")
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
-- CreateTable
|
|
62
|
+
CREATE TABLE "workspace_offerings" (
|
|
63
|
+
"id" TEXT NOT NULL DEFAULT ('wsoffer_'::text || (uuidv7())::text),
|
|
64
|
+
"workspace_id" TEXT NOT NULL,
|
|
65
|
+
"shown_product_ids" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
|
66
|
+
"recommended_plan_product_id" TEXT,
|
|
67
|
+
"recommended_addon_product_id" TEXT,
|
|
68
|
+
"snapshot" JSONB,
|
|
69
|
+
"snapshot_at" TIMESTAMPTZ,
|
|
70
|
+
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
71
|
+
"updated_at" TIMESTAMPTZ NOT NULL,
|
|
72
|
+
|
|
73
|
+
CONSTRAINT "workspace_offerings_pkey" PRIMARY KEY ("id")
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
-- CreateIndex
|
|
77
|
+
CREATE UNIQUE INDEX "stripe_connections_organization_id_key" ON "stripe_connections"("organization_id");
|
|
78
|
+
|
|
79
|
+
-- CreateIndex
|
|
80
|
+
CREATE UNIQUE INDEX "stripe_connections_webhook_token_key" ON "stripe_connections"("webhook_token");
|
|
81
|
+
|
|
82
|
+
-- CreateIndex
|
|
83
|
+
CREATE UNIQUE INDEX "organization_offerings_organization_id_key" ON "organization_offerings"("organization_id");
|
|
84
|
+
|
|
85
|
+
-- CreateIndex
|
|
86
|
+
CREATE UNIQUE INDEX "workspace_offerings_workspace_id_key" ON "workspace_offerings"("workspace_id");
|
|
87
|
+
|
|
88
|
+
-- ADR-0031 rule 3 — stripe_connections: stripecon_, organization_offerings:
|
|
89
|
+
-- orgoffer_, workspace_offerings: wsoffer_ (registered in
|
|
90
|
+
-- packages/ids/src/registry.ts ENTITY_PREFIX; this migration's path is added
|
|
91
|
+
-- to migration-sync.test.ts's PK_CHECK_MIGRATIONS).
|
|
92
|
+
ALTER TABLE "stripe_connections" ALTER COLUMN "id" TYPE text COLLATE "C";
|
|
93
|
+
ALTER TABLE "stripe_connections" ALTER COLUMN "id" SET DEFAULT ('stripecon_'::text || (uuidv7())::text);
|
|
94
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_id_format" CHECK ("id" ~ '^stripecon_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
95
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_organization_id_format" CHECK ("organization_id" ~ '^org_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
96
|
+
ALTER TABLE "organization_offerings" ALTER COLUMN "id" TYPE text COLLATE "C";
|
|
97
|
+
ALTER TABLE "organization_offerings" ALTER COLUMN "id" SET DEFAULT ('orgoffer_'::text || (uuidv7())::text);
|
|
98
|
+
ALTER TABLE "organization_offerings" ADD CONSTRAINT "organization_offerings_id_format" CHECK ("id" ~ '^orgoffer_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
99
|
+
ALTER TABLE "organization_offerings" ADD CONSTRAINT "organization_offerings_organization_id_format" CHECK ("organization_id" ~ '^org_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
100
|
+
ALTER TABLE "workspace_offerings" ALTER COLUMN "id" TYPE text COLLATE "C";
|
|
101
|
+
ALTER TABLE "workspace_offerings" ALTER COLUMN "id" SET DEFAULT ('wsoffer_'::text || (uuidv7())::text);
|
|
102
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_id_format" CHECK ("id" ~ '^wsoffer_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
103
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_workspace_id_format" CHECK ("workspace_id" ~ '^wksp_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
104
|
+
|
|
105
|
+
-- A connection is in test or live mode, and only a live one has a go-live
|
|
106
|
+
-- time (a replace that returns a row to test clears it, contract C9).
|
|
107
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_mode_domain"
|
|
108
|
+
CHECK ("mode" IN ('test', 'live'));
|
|
109
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_live_at_pair"
|
|
110
|
+
CHECK (("mode" = 'live') = ("live_at" IS NOT NULL));
|
|
111
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_key_last4_shape"
|
|
112
|
+
CHECK ("key_last4" ~ '^[A-Za-z0-9]{4}$');
|
|
113
|
+
-- 32 random bytes, base64url.
|
|
114
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_webhook_token_shape"
|
|
115
|
+
CHECK ("webhook_token" ~ '^[A-Za-z0-9_-]{43}$');
|
|
116
|
+
-- Ciphertext only: never a key or a signing secret in clear.
|
|
117
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_credential_envelope"
|
|
118
|
+
CHECK ("credential_ciphertext" ~ '^v1\.[A-Za-z0-9_-]{16}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]+$'
|
|
119
|
+
AND "credential_ciphertext" !~ '(rk|sk|pk)_(test|live)_|whsec_');
|
|
120
|
+
ALTER TABLE "stripe_connections" ADD CONSTRAINT "stripe_connections_webhook_secret_envelope"
|
|
121
|
+
CHECK ("webhook_secret_ciphertext" IS NULL
|
|
122
|
+
OR ("webhook_secret_ciphertext" ~ '^v1\.[A-Za-z0-9_-]{16}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]+$'
|
|
123
|
+
AND "webhook_secret_ciphertext" !~ '(rk|sk|pk)_(test|live)_|whsec_'));
|
|
124
|
+
|
|
125
|
+
-- Each id set is never NULL, holds no NULL element, and has at most 100 ids.
|
|
126
|
+
-- Duplicates and the id shape are refused by the writers' schema parse.
|
|
127
|
+
ALTER TABLE "organization_offerings" ADD CONSTRAINT "organization_offerings_enabled_product_ids_bound"
|
|
128
|
+
CHECK ("enabled_product_ids" IS NOT NULL
|
|
129
|
+
AND cardinality("enabled_product_ids") <= 100
|
|
130
|
+
AND array_position("enabled_product_ids", NULL) IS NULL);
|
|
131
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_shown_product_ids_bound"
|
|
132
|
+
CHECK ("shown_product_ids" IS NOT NULL
|
|
133
|
+
AND cardinality("shown_product_ids") <= 100
|
|
134
|
+
AND array_position("shown_product_ids", NULL) IS NULL);
|
|
135
|
+
|
|
136
|
+
-- A Recommended product is one the workspace shows.
|
|
137
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_recommended_plan_shown"
|
|
138
|
+
CHECK ("recommended_plan_product_id" IS NULL
|
|
139
|
+
OR "recommended_plan_product_id" = ANY ("shown_product_ids"));
|
|
140
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_recommended_addon_shown"
|
|
141
|
+
CHECK ("recommended_addon_product_id" IS NULL
|
|
142
|
+
OR "recommended_addon_product_id" = ANY ("shown_product_ids"));
|
|
143
|
+
|
|
144
|
+
-- The snapshot and its time are set together.
|
|
145
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_snapshot_pair"
|
|
146
|
+
CHECK (("snapshot" IS NULL) = ("snapshot_at" IS NULL));
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
-- #8930 — the Offerings Checkout session record (spec
|
|
2
|
+
-- docs/specs/8930-the-offerings-checkout-session-record-spec.md D1, D2;
|
|
3
|
+
-- contract docs/specs/8879-the-offerings-security-contract-key-spec.md A11,
|
|
4
|
+
-- W5, A13):
|
|
5
|
+
--
|
|
6
|
+
-- offerings_checkout_sessions (config) — one row per Checkout Session the
|
|
7
|
+
-- hub created: its id, the workspace and Organization it was created for,
|
|
8
|
+
-- the Price and lookup key it sells, and the key's mode. Written once by
|
|
9
|
+
-- apps/api's services/offerings/checkout-session-record.ts before the
|
|
10
|
+
-- checkout route answers; the per-Organization webhook fulfils, and the
|
|
11
|
+
-- session read answers, only a session recorded here.
|
|
12
|
+
--
|
|
13
|
+
-- One new table in the house style of 20261003130000_scheduling_connection
|
|
14
|
+
-- (CreateTable + CreateIndex as `prisma migrate diff` emits them, then the
|
|
15
|
+
-- ADR-0031 rule-3 id-format completion), plus a CHECK on every column. Plain
|
|
16
|
+
-- scalar keys, no foreign key (ADR 0009 invariant 1). The table is new, so no
|
|
17
|
+
-- CHECK needs NOT VALID.
|
|
18
|
+
--
|
|
19
|
+
-- One new table, no backfill, no existing table touched.
|
|
20
|
+
--
|
|
21
|
+
-- Rollout: deploy the migration before the API code that writes the record,
|
|
22
|
+
-- so the checkout route never runs on a database without the table.
|
|
23
|
+
--
|
|
24
|
+
-- Rollback: DROP TABLE "offerings_checkout_sessions". While the table is
|
|
25
|
+
-- absent every read rejects, so the webhook answers non-2xx and Stripe keeps
|
|
26
|
+
-- retrying. Re-creating it empty loses every earlier record: each such session
|
|
27
|
+
-- then reads as unrecorded and a purchase completed after that is never
|
|
28
|
+
-- fulfilled. So roll back only before the checkout route that writes it is
|
|
29
|
+
-- live, and never re-create the table without its old rows unless the seller
|
|
30
|
+
-- is told.
|
|
31
|
+
|
|
32
|
+
-- CreateTable
|
|
33
|
+
CREATE TABLE "offerings_checkout_sessions" (
|
|
34
|
+
"id" TEXT NOT NULL DEFAULT ('ocsess_'::text || (uuidv7())::text),
|
|
35
|
+
"session_id" TEXT NOT NULL,
|
|
36
|
+
"workspace_id" TEXT NOT NULL,
|
|
37
|
+
"organization_id" TEXT NOT NULL,
|
|
38
|
+
"price_id" VARCHAR(255) NOT NULL,
|
|
39
|
+
"lookup_key" VARCHAR(48) NOT NULL,
|
|
40
|
+
"mode" VARCHAR(8) NOT NULL,
|
|
41
|
+
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
+
|
|
43
|
+
CONSTRAINT "offerings_checkout_sessions_pkey" PRIMARY KEY ("id")
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
-- CreateIndex
|
|
47
|
+
CREATE UNIQUE INDEX "offerings_checkout_sessions_session_id_key" ON "offerings_checkout_sessions"("session_id");
|
|
48
|
+
|
|
49
|
+
-- ADR-0031 rule 3 — offerings_checkout_sessions: ocsess_ (registered in
|
|
50
|
+
-- packages/ids/src/registry.ts ENTITY_PREFIX; this migration's path is added
|
|
51
|
+
-- to migration-sync.test.ts's PK_CHECK_MIGRATIONS).
|
|
52
|
+
ALTER TABLE "offerings_checkout_sessions" ALTER COLUMN "id" TYPE text COLLATE "C";
|
|
53
|
+
ALTER TABLE "offerings_checkout_sessions" ALTER COLUMN "id" SET DEFAULT ('ocsess_'::text || (uuidv7())::text);
|
|
54
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_id_format" CHECK ("id" ~ '^ocsess_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
55
|
+
|
|
56
|
+
-- A Checkout Session id: the pieces_checkout_session_format body.
|
|
57
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_session_id_format"
|
|
58
|
+
CHECK ("session_id" ~ '^cs_(test|live)_[A-Za-z0-9]{1,250}$');
|
|
59
|
+
-- The workspace the session was created for.
|
|
60
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_workspace_id_format"
|
|
61
|
+
CHECK ("workspace_id" ~ '^wksp_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
62
|
+
-- That workspace's own Organization.
|
|
63
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_organization_id_format"
|
|
64
|
+
CHECK ("organization_id" ~ '^org_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');
|
|
65
|
+
-- A Stripe id: the one bound #8876 D4 puts on every Stripe id.
|
|
66
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_price_id_format"
|
|
67
|
+
CHECK ("price_id" ~ '^[A-Za-z0-9_-]{1,255}$');
|
|
68
|
+
-- The contract §3.7 whole-key grammar, <plan>_<period>. A backstop, never a
|
|
69
|
+
-- parser: the store calls parseLookupKey, and the db test proves the two agree.
|
|
70
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_lookup_key_format"
|
|
71
|
+
CHECK ("lookup_key" ~ '^[a-z0-9][a-z0-9-]{0,39}_(monthly|yearly|once)$');
|
|
72
|
+
-- The key's mode.
|
|
73
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_mode_domain"
|
|
74
|
+
CHECK ("mode" IN ('test', 'live'));
|
|
75
|
+
-- A test key makes a cs_test_ session and a live key a cs_live_ one.
|
|
76
|
+
ALTER TABLE "offerings_checkout_sessions" ADD CONSTRAINT "offerings_checkout_sessions_session_mode_agree"
|
|
77
|
+
CHECK (("mode" = 'live') = ("session_id" ~ '^cs_live_'));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- #8847 — the in-page form shape (spec
|
|
2
|
+
-- docs/specs/8847-the-in-page-form-shape-spec.md D5, C5).
|
|
3
|
+
--
|
|
4
|
+
-- Two marked blocks, each re-runnable and each held to its TypeScript
|
|
5
|
+
-- constant by database/__tests__/in-page-magnets-migration.test.ts, on the
|
|
6
|
+
-- request-quote backfill's footing (20261012120000_member_contract):
|
|
7
|
+
--
|
|
8
|
+
-- newsletter backfill — every existing workspace gets the standard
|
|
9
|
+
-- newsletter magnet (`newsletterFlowConfig`,
|
|
10
|
+
-- `live`, landing page /newsletter, completion
|
|
11
|
+
-- `lead`). Insert-only on `(site_id, slug)`: a row
|
|
12
|
+
-- already at `newsletter` (an owner's own
|
|
13
|
+
-- wizard-built newsletter included) is never
|
|
14
|
+
-- changed. A workspace created after this runs is
|
|
15
|
+
-- seeded by `POST /v1/workspaces`, and the
|
|
16
|
+
-- seed-presets CLI covers one created between this
|
|
17
|
+
-- migration and the route code's deploy.
|
|
18
|
+
--
|
|
19
|
+
-- contact-form upgrade — a stored Contact form whose config is EXACTLY
|
|
20
|
+
-- #8661's shipped default moves to the new default
|
|
21
|
+
-- (`contactFormFlowConfig`). `config` is jsonb, so
|
|
22
|
+
-- `=` compares values, not key order or whitespace:
|
|
23
|
+
-- a row an owner edited in any way, or a
|
|
24
|
+
-- wizard-built Contact form, is not equal and is
|
|
25
|
+
-- left as is. Only `config` and `updated_at` are
|
|
26
|
+
-- written — never title, status, landing page or
|
|
27
|
+
-- completion. A re-run matches nothing.
|
|
28
|
+
--
|
|
29
|
+
-- Rollback: DELETE FROM "flow_definitions" WHERE "slug" = 'newsletter' AND
|
|
30
|
+
-- "config" = <the backfill literal>::jsonb; and the upgrade's UPDATE with its
|
|
31
|
+
-- two literals swapped.
|
|
32
|
+
|
|
33
|
+
-- BEGIN newsletter backfill
|
|
34
|
+
INSERT INTO "flow_definitions" ("site_id", "workspace_id", "slug", "config", "kind", "title", "status", "customers_enabled", "completion", "landing_page", "updated_at")
|
|
35
|
+
SELECT w."id", w."id", 'newsletter',
|
|
36
|
+
'{"slug":"newsletter","defaultLocale":"en","steps":[{"key":"subscribe","type":"field","copy":{"title":{"en":"Get the newsletter"},"body":{"en":"One email when there is something new."},"cta":{"en":"Subscribe"}},"fields":[{"name":"email","inputType":"email","required":true,"mapsTo":"email","copy":{"label":{"en":"Email"},"placeholder":{"en":"you@example.com"}}},{"name":"terms","inputType":"consent","required":true,"purposes":["newsletter"],"copy":{"label":{"en":"I accept the [Terms](terms) and [Privacy Policy](privacy)."},"help":{"en":"No spam. Unsubscribe any time."}}}]}],"ending":{"default":{"kind":"screen","headline":{"en":"Check your inbox"},"body":{"en":"Your welcome email is on its way."}}},"completionEmail":{"subject":{"en":"You''re subscribed"},"body":{"en":"Thanks for subscribing. You''ll get one email when there is something new."}},"unsubscribe":{"title":{"en":"Unsubscribe"},"body":{"en":"Stop getting the newsletter by email?"},"cta":{"en":"Unsubscribe"},"done":{"headline":{"en":"You''re unsubscribed."},"body":{"en":"You won''t get the newsletter any more."}}}}'::jsonb,
|
|
37
|
+
'newsletter', 'Newsletter', 'live', false, 'lead', '/newsletter', CURRENT_TIMESTAMP
|
|
38
|
+
FROM "workspaces" w
|
|
39
|
+
ON CONFLICT ("site_id", "slug") DO NOTHING;
|
|
40
|
+
-- END newsletter backfill
|
|
41
|
+
|
|
42
|
+
-- BEGIN contact-form upgrade
|
|
43
|
+
UPDATE "flow_definitions" SET "config" = '{"slug":"contact","defaultLocale":"en","steps":[{"key":"contact","type":"field","copy":{"title":{"en":"Get in touch"},"body":{"en":"I reply within one business day."},"cta":{"en":"Send message"}},"fields":[{"name":"name","inputType":"text","required":true,"mapsTo":"name","copy":{"label":{"en":"Name"}}},{"name":"email","inputType":"email","required":true,"mapsTo":"email","copy":{"label":{"en":"Email"}}},{"name":"subject","inputType":"select","required":false,"options":[{"value":"General question","label":{"en":"General question"}},{"value":"Working together","label":{"en":"Working together"}},{"value":"Support","label":{"en":"Support"}},{"value":"Press and partnerships","label":{"en":"Press and partnerships"}},{"value":"Other","label":{"en":"Other"}}],"copy":{"label":{"en":"Subject"},"placeholder":{"en":"Choose a subject"}}},{"name":"message","inputType":"textarea","required":false,"copy":{"label":{"en":"Message"}}},{"name":"terms","inputType":"consent","required":true,"purposes":["service_terms"],"copy":{"label":{"en":"I accept the [Terms](terms) and [Privacy Policy](privacy)."}}}]}],"ending":{"default":{"kind":"screen","headline":{"en":"Message sent."},"body":{"en":"Thanks for getting in touch. I reply within one business day."}}}}'::jsonb, "updated_at" = CURRENT_TIMESTAMP
|
|
44
|
+
WHERE "slug" = 'contact' AND "config" = '{"slug":"contact","defaultLocale":"en","steps":[{"key":"contact","type":"field","copy":{"title":{"en":"Contact form"},"cta":{"en":"Send message"}},"fields":[{"name":"name","inputType":"text","required":true,"mapsTo":"name","copy":{"label":{"en":"Name"}}},{"name":"email","inputType":"email","required":true,"mapsTo":"email","copy":{"label":{"en":"Email"}}},{"name":"subject","inputType":"select","required":false,"options":[{"value":"General question","label":{"en":"General question"}},{"value":"Working together","label":{"en":"Working together"}},{"value":"Support","label":{"en":"Support"}},{"value":"Press and partnerships","label":{"en":"Press and partnerships"}},{"value":"Other","label":{"en":"Other"}}],"copy":{"label":{"en":"Subject"},"placeholder":{"en":"Choose a subject"}}},{"name":"message","inputType":"textarea","required":false,"copy":{"label":{"en":"Message"}}},{"name":"terms","inputType":"consent","required":true,"purposes":["service_terms"],"copy":{"label":{"en":"I accept the [Terms](terms), [Privacy Policy](privacy), and [Working Agreement](working_agreement)."}}}]}]}'::jsonb;
|
|
45
|
+
-- END contact-form upgrade
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- #9070 — the workspace shown set becomes per Stripe Price (spec
|
|
2
|
+
-- docs/specs/9070-the-workspace-offerings-page-becomes-spec.md D1, AC-6).
|
|
3
|
+
--
|
|
4
|
+
-- workspace_offerings.shown_price_ids (config) — the Stripe Price ids one
|
|
5
|
+
-- workspace shows on its pricing page. Written only by
|
|
6
|
+
-- apps/api's services/offerings/store.ts
|
|
7
|
+
-- (writeWorkspaceSelection, the PUT
|
|
8
|
+
-- /v1/workspaces/:workspaceId/offerings route), beside
|
|
9
|
+
-- shown_product_ids, which every write sets to the Products
|
|
10
|
+
-- with at least one shown Price. Read through
|
|
11
|
+
-- shownPriceIdsFor (services/offerings/index.ts) by
|
|
12
|
+
-- /pricing, the agent pricing tools, the plan picker and
|
|
13
|
+
-- checkout.
|
|
14
|
+
--
|
|
15
|
+
-- An EMPTY array means "every Price of each shown Product" — the grain every
|
|
16
|
+
-- row had before this migration — so every existing row reads `{}` from the
|
|
17
|
+
-- constant default and shows exactly what it showed before. Postgres stores
|
|
18
|
+
-- the default in the catalog and rewrites no row for it. The store's parse
|
|
19
|
+
-- refuses a new write of Products without Prices, so a row saved after this
|
|
20
|
+
-- migration always carries its Price ids. Each CHECK is added NOT VALID and
|
|
21
|
+
-- then VALIDATEd; every existing row passes both (an empty array).
|
|
22
|
+
--
|
|
23
|
+
-- The migration timestamp follows 20261022120000_in_page_magnets, which took
|
|
24
|
+
-- the spec's named slot first (spec §5.3).
|
|
25
|
+
--
|
|
26
|
+
-- Rollout: deploy this migration BEFORE the API code that reads and writes the
|
|
27
|
+
-- column, and the API before the Admin.
|
|
28
|
+
--
|
|
29
|
+
-- Rollback: roll the API back, then
|
|
30
|
+
-- UPDATE "workspace_offerings" SET "shown_price_ids" = '{}';
|
|
31
|
+
-- so every row reads at the Product grain again and the old route's saves
|
|
32
|
+
-- pass workspace_offerings_shown_prices_need_products, and tell each owner who
|
|
33
|
+
-- saved per Price that every Price of their shown Products is on sale again.
|
|
34
|
+
-- Never drop the column while a per-Price row exists without that notice.
|
|
35
|
+
|
|
36
|
+
-- AlterTable
|
|
37
|
+
ALTER TABLE "workspace_offerings" ADD COLUMN "shown_price_ids" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[];
|
|
38
|
+
|
|
39
|
+
-- At most 100 Products × three periods, and no NULL element.
|
|
40
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_shown_price_ids_bound"
|
|
41
|
+
CHECK (cardinality("shown_price_ids") <= 300 AND array_position("shown_price_ids", NULL) IS NULL) NOT VALID;
|
|
42
|
+
ALTER TABLE "workspace_offerings" VALIDATE CONSTRAINT "workspace_offerings_shown_price_ids_bound";
|
|
43
|
+
|
|
44
|
+
-- A shown Price needs a shown Product.
|
|
45
|
+
ALTER TABLE "workspace_offerings" ADD CONSTRAINT "workspace_offerings_shown_prices_need_products"
|
|
46
|
+
CHECK (cardinality("shown_price_ids") = 0 OR cardinality("shown_product_ids") > 0) NOT VALID;
|
|
47
|
+
ALTER TABLE "workspace_offerings" VALIDATE CONSTRAINT "workspace_offerings_shown_prices_need_products";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- #9067 D13 — the Organization binds only the plan Checkout it recorded (spec
|
|
2
|
+
-- docs/specs/9067-the-billing-tab-s-plan-spec.md D13, SEC-9067-1 to -3).
|
|
3
|
+
--
|
|
4
|
+
-- `plan_checkout_session_id` is the one plan Checkout this Organization has
|
|
5
|
+
-- open, written by POST /v1/billing/plan-checkout through a compare-and-set
|
|
6
|
+
-- and cleared by the Stripe webhook when it binds that session's customer.
|
|
7
|
+
-- Nullable, no default and no backfill: every existing row reads "no open
|
|
8
|
+
-- plan session". Unique, so one session id can name at most one
|
|
9
|
+
-- Organization.
|
|
10
|
+
--
|
|
11
|
+
-- Rollback: DROP INDEX "organizations_plan_checkout_session_id_key";
|
|
12
|
+
-- ALTER TABLE "organizations" DROP COLUMN "plan_checkout_session_id";
|
|
13
|
+
|
|
14
|
+
ALTER TABLE "organizations" ADD COLUMN "plan_checkout_session_id" TEXT;
|
|
15
|
+
|
|
16
|
+
CREATE UNIQUE INDEX "organizations_plan_checkout_session_id_key" ON "organizations"("plan_checkout_session_id");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- #9301 — the standard trial magnet (spec
|
|
2
|
+
-- docs/specs/9287-operator-started-trials-spec.md D11, C1).
|
|
3
|
+
--
|
|
4
|
+
-- One marked block, re-runnable and held to its TypeScript constant by
|
|
5
|
+
-- database/__tests__/trial-magnet-migration.test.ts, on the newsletter
|
|
6
|
+
-- backfill's footing (20261022120000_in_page_magnets):
|
|
7
|
+
--
|
|
8
|
+
-- trial backfill — every existing workspace gets the standard trial
|
|
9
|
+
-- magnet (`trialFlowConfig`, `diagnostic`, `live`,
|
|
10
|
+
-- landing page /trial, completion `lead`). Insert-only
|
|
11
|
+
-- on `(site_id, slug)`: a row already at `trial` (an
|
|
12
|
+
-- owner's own magnet included) is never changed. A
|
|
13
|
+
-- workspace created after this runs is seeded by
|
|
14
|
+
-- `POST /v1/workspaces`, and the seed-presets CLI covers
|
|
15
|
+
-- one created between this migration and the route
|
|
16
|
+
-- code's deploy.
|
|
17
|
+
--
|
|
18
|
+
-- Rollback: DELETE FROM "flow_definitions" WHERE "slug" = 'trial' AND
|
|
19
|
+
-- "config" = <the backfill literal>::jsonb;
|
|
20
|
+
|
|
21
|
+
-- BEGIN trial backfill
|
|
22
|
+
INSERT INTO "flow_definitions" ("site_id", "workspace_id", "slug", "config", "kind", "title", "status", "customers_enabled", "completion", "landing_page", "updated_at")
|
|
23
|
+
SELECT w."id", w."id", 'trial',
|
|
24
|
+
'{"slug":"trial","defaultLocale":"en","steps":[{"key":"about","type":"field","copy":{"title":{"en":"Free trial"},"cta":{"en":"Request my trial"}},"fields":[{"name":"first_name","inputType":"text","required":true,"mapsTo":"givenName","copy":{"label":{"en":"First name"}}},{"name":"last_name","inputType":"text","required":true,"mapsTo":"familyName","copy":{"label":{"en":"Last name"}}},{"name":"email","inputType":"email","required":true,"mapsTo":"email","copy":{"label":{"en":"Work email"}}},{"name":"terms","inputType":"consent","required":true,"purposes":["service_terms"],"copy":{"label":{"en":"I accept the [Terms](terms) and [Privacy Policy](privacy)."}}}]}],"ending":{"default":{"kind":"screen","headline":{"en":"Thanks, {name}."},"body":{"en":"We have your request and will be in touch about your trial."}}},"landing":{"title":{"en":"Free trial"},"description":{"en":"Try it free for 14 days. No card needed."},"cta":{"en":"Request a free trial"}}}'::jsonb,
|
|
25
|
+
'diagnostic', 'Free trial', 'live', false, 'lead', '/trial', CURRENT_TIMESTAMP
|
|
26
|
+
FROM "workspaces" w
|
|
27
|
+
ON CONFLICT ("site_id", "slug") DO NOTHING;
|
|
28
|
+
-- END trial backfill
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- #9302 — the trial magnet's landing gains its proof line (spec
|
|
2
|
+
-- docs/specs/9287-operator-started-trials-spec.md C2; operator decision on
|
|
3
|
+
-- #9302, option (a)).
|
|
4
|
+
--
|
|
5
|
+
-- One marked block, held to its TypeScript constant by
|
|
6
|
+
-- database/__tests__/trial-magnet-migration.test.ts, on the contact-form
|
|
7
|
+
-- upgrade's footing (20261022120000_in_page_magnets):
|
|
8
|
+
--
|
|
9
|
+
-- trial proof-line upgrade — a trial magnet whose config is still exactly
|
|
10
|
+
-- #9301's shipped default (the backfill literal
|
|
11
|
+
-- in 20261025120000_trial_magnet) becomes
|
|
12
|
+
-- `trialFlowConfig`, which adds
|
|
13
|
+
-- `landing.meta`. An owner's edited trial magnet
|
|
14
|
+
-- is never touched. Sets nothing but `config`
|
|
15
|
+
-- and `updated_at`.
|
|
16
|
+
--
|
|
17
|
+
-- Rollback: UPDATE "flow_definitions" SET "config" = <the WHERE literal>::jsonb
|
|
18
|
+
-- WHERE "slug" = 'trial' AND "config" = <the SET literal>::jsonb;
|
|
19
|
+
|
|
20
|
+
-- BEGIN trial proof-line upgrade
|
|
21
|
+
UPDATE "flow_definitions" SET "config" = '{"slug":"trial","defaultLocale":"en","steps":[{"key":"about","type":"field","copy":{"title":{"en":"Free trial"},"cta":{"en":"Request my trial"}},"fields":[{"name":"first_name","inputType":"text","required":true,"mapsTo":"givenName","copy":{"label":{"en":"First name"}}},{"name":"last_name","inputType":"text","required":true,"mapsTo":"familyName","copy":{"label":{"en":"Last name"}}},{"name":"email","inputType":"email","required":true,"mapsTo":"email","copy":{"label":{"en":"Work email"}}},{"name":"terms","inputType":"consent","required":true,"purposes":["service_terms"],"copy":{"label":{"en":"I accept the [Terms](terms) and [Privacy Policy](privacy)."}}}]}],"ending":{"default":{"kind":"screen","headline":{"en":"Thanks, {name}."},"body":{"en":"We have your request and will be in touch about your trial."}}},"landing":{"title":{"en":"Free trial"},"description":{"en":"Try it free for 14 days. No card needed."},"meta":{"en":"A person on our team reviews every request."},"cta":{"en":"Request a free trial"}}}'::jsonb, "updated_at" = CURRENT_TIMESTAMP
|
|
22
|
+
WHERE "slug" = 'trial' AND "config" = '{"slug":"trial","defaultLocale":"en","steps":[{"key":"about","type":"field","copy":{"title":{"en":"Free trial"},"cta":{"en":"Request my trial"}},"fields":[{"name":"first_name","inputType":"text","required":true,"mapsTo":"givenName","copy":{"label":{"en":"First name"}}},{"name":"last_name","inputType":"text","required":true,"mapsTo":"familyName","copy":{"label":{"en":"Last name"}}},{"name":"email","inputType":"email","required":true,"mapsTo":"email","copy":{"label":{"en":"Work email"}}},{"name":"terms","inputType":"consent","required":true,"purposes":["service_terms"],"copy":{"label":{"en":"I accept the [Terms](terms) and [Privacy Policy](privacy)."}}}]}],"ending":{"default":{"kind":"screen","headline":{"en":"Thanks, {name}."},"body":{"en":"We have your request and will be in touch about your trial."}}},"landing":{"title":{"en":"Free trial"},"description":{"en":"Try it free for 14 days. No card needed."},"cta":{"en":"Request a free trial"}}}'::jsonb;
|
|
23
|
+
-- END trial proof-line upgrade
|
|
@@ -34,9 +34,17 @@ import {
|
|
|
34
34
|
JOB_APPLICATION_FLOW_TITLE,
|
|
35
35
|
JOB_APPLICATION_LANDING_PAGE,
|
|
36
36
|
jobApplicationFlowConfig,
|
|
37
|
+
NEWSLETTER_FLOW_SLUG,
|
|
38
|
+
NEWSLETTER_FLOW_TITLE,
|
|
39
|
+
NEWSLETTER_LANDING_PAGE,
|
|
40
|
+
newsletterFlowConfig,
|
|
37
41
|
REQUEST_QUOTE_FLOW_SLUG,
|
|
38
42
|
REQUEST_QUOTE_FLOW_TITLE,
|
|
39
43
|
requestQuoteFlowConfig,
|
|
44
|
+
TRIAL_FLOW_LANDING_PAGE,
|
|
45
|
+
TRIAL_FLOW_SLUG,
|
|
46
|
+
TRIAL_FLOW_TITLE,
|
|
47
|
+
trialFlowConfig,
|
|
40
48
|
} from "@working-theory/validation";
|
|
41
49
|
|
|
42
50
|
import type { PrismaClient } from "./generated/client/client.js";
|
|
@@ -84,8 +92,9 @@ export type DefaultWorkspacePrismaClient = Pick<
|
|
|
84
92
|
* `update`, so an existing `(site_id, slug)` row is never overwritten.
|
|
85
93
|
*
|
|
86
94
|
* #8661 D3 — and its live Contact form magnet, the same way, and (#8746 D3)
|
|
87
|
-
* its live Job application magnet
|
|
88
|
-
* already present) gets its rows from the
|
|
95
|
+
* its live Job application magnet, and (#8847 D4) its live newsletter magnet.
|
|
96
|
+
* An existing deployment (a workspace already present) gets its rows from the
|
|
97
|
+
* seed-presets CLI instead.
|
|
89
98
|
*
|
|
90
99
|
* #8759 — each names its #8757 D2 completion: the migration's backfill ran
|
|
91
100
|
* before this seed and found no rows, so the seed writes the value itself.
|
|
@@ -189,6 +198,52 @@ export async function provisionDefaultWorkspace(
|
|
|
189
198
|
update: {},
|
|
190
199
|
});
|
|
191
200
|
|
|
201
|
+
// #8847 D4 — the standard newsletter magnet, the same way.
|
|
202
|
+
await prisma.flowDefinition.upsert({
|
|
203
|
+
where: {
|
|
204
|
+
siteId_slug: {
|
|
205
|
+
siteId: DEFAULT_WORKSPACE_ID,
|
|
206
|
+
slug: NEWSLETTER_FLOW_SLUG,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
create: {
|
|
210
|
+
siteId: DEFAULT_WORKSPACE_ID,
|
|
211
|
+
workspaceId: DEFAULT_WORKSPACE_ID,
|
|
212
|
+
slug: NEWSLETTER_FLOW_SLUG,
|
|
213
|
+
config: newsletterFlowConfig,
|
|
214
|
+
kind: "newsletter",
|
|
215
|
+
title: NEWSLETTER_FLOW_TITLE,
|
|
216
|
+
status: "live",
|
|
217
|
+
customersEnabled: false,
|
|
218
|
+
completion: "lead",
|
|
219
|
+
landingPage: NEWSLETTER_LANDING_PAGE,
|
|
220
|
+
},
|
|
221
|
+
update: {},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// #9287 D11 — the standard trial magnet, the same way.
|
|
225
|
+
await prisma.flowDefinition.upsert({
|
|
226
|
+
where: {
|
|
227
|
+
siteId_slug: {
|
|
228
|
+
siteId: DEFAULT_WORKSPACE_ID,
|
|
229
|
+
slug: TRIAL_FLOW_SLUG,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
create: {
|
|
233
|
+
siteId: DEFAULT_WORKSPACE_ID,
|
|
234
|
+
workspaceId: DEFAULT_WORKSPACE_ID,
|
|
235
|
+
slug: TRIAL_FLOW_SLUG,
|
|
236
|
+
config: trialFlowConfig,
|
|
237
|
+
kind: "diagnostic",
|
|
238
|
+
title: TRIAL_FLOW_TITLE,
|
|
239
|
+
status: "live",
|
|
240
|
+
customersEnabled: false,
|
|
241
|
+
completion: "lead",
|
|
242
|
+
landingPage: TRIAL_FLOW_LANDING_PAGE,
|
|
243
|
+
},
|
|
244
|
+
update: {},
|
|
245
|
+
});
|
|
246
|
+
|
|
192
247
|
return { created: true };
|
|
193
248
|
}
|
|
194
249
|
|