create-freeholder 0.0.0-bootstrap.0 → 0.2.0-beta.2

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.
Files changed (2553) hide show
  1. package/README.md +30 -2
  2. package/dist/index.d.ts +72 -0
  3. package/dist/index.js +672 -0
  4. package/dist/template/.changeset/README.md +8 -0
  5. package/dist/template/.changeset/access-from-grants.md +14 -0
  6. package/dist/template/.changeset/accounting-exports.md +32 -0
  7. package/dist/template/.changeset/ad-creatives.md +33 -0
  8. package/dist/template/.changeset/ad-inventory.md +19 -0
  9. package/dist/template/.changeset/ad-measurement.md +10 -0
  10. package/dist/template/.changeset/ad-third-party.md +9 -0
  11. package/dist/template/.changeset/admin-ads.md +9 -0
  12. package/dist/template/.changeset/admin-documents.md +7 -0
  13. package/dist/template/.changeset/admin-loyalty.md +9 -0
  14. package/dist/template/.changeset/admin-referrals.md +9 -0
  15. package/dist/template/.changeset/admin-shell.md +16 -0
  16. package/dist/template/.changeset/adversarial-cms-boundaries.md +8 -0
  17. package/dist/template/.changeset/adversarial-customer-invariants.md +7 -0
  18. package/dist/template/.changeset/adversarial-customer-privacy.md +13 -0
  19. package/dist/template/.changeset/adversarial-platform-safety.md +15 -0
  20. package/dist/template/.changeset/agent-approval-inbox.md +5 -0
  21. package/dist/template/.changeset/agent-autonomy-writes.md +5 -0
  22. package/dist/template/.changeset/agent-budgets.md +5 -0
  23. package/dist/template/.changeset/agent-catalogue.md +22 -0
  24. package/dist/template/.changeset/agent-f04.md +6 -0
  25. package/dist/template/.changeset/agent-injection-hardening.md +5 -0
  26. package/dist/template/.changeset/agent-pause-kill-switch.md +5 -0
  27. package/dist/template/.changeset/agent-playbooks.md +5 -0
  28. package/dist/template/.changeset/agent-run-live.md +5 -0
  29. package/dist/template/.changeset/agent-work-board.md +5 -0
  30. package/dist/template/.changeset/agents-inbound.md +31 -0
  31. package/dist/template/.changeset/agents-model.md +27 -0
  32. package/dist/template/.changeset/alt-text-suggestions.md +8 -0
  33. package/dist/template/.changeset/analytics-governance.md +7 -0
  34. package/dist/template/.changeset/analytics-proxy-origin.md +8 -0
  35. package/dist/template/.changeset/analytics.md +10 -0
  36. package/dist/template/.changeset/apache-license.md +15 -0
  37. package/dist/template/.changeset/api-keys.md +19 -0
  38. package/dist/template/.changeset/arabic-rtl-catalog.md +23 -0
  39. package/dist/template/.changeset/assistant-grounding.md +10 -0
  40. package/dist/template/.changeset/assistant-guardrails.md +11 -0
  41. package/dist/template/.changeset/attested-facts-and-corrections.md +11 -0
  42. package/dist/template/.changeset/audit-search-and-proof.md +34 -0
  43. package/dist/template/.changeset/autofill-safety.md +22 -0
  44. package/dist/template/.changeset/automation-guardrails.md +9 -0
  45. package/dist/template/.changeset/automation-runtime.md +9 -0
  46. package/dist/template/.changeset/automations-builder.md +9 -0
  47. package/dist/template/.changeset/availability-resolver.md +29 -0
  48. package/dist/template/.changeset/availability.md +23 -0
  49. package/dist/template/.changeset/booking-audiences.md +24 -0
  50. package/dist/template/.changeset/booking-race-message.md +15 -0
  51. package/dist/template/.changeset/bookings.md +28 -0
  52. package/dist/template/.changeset/boot-in-request-graph.md +7 -0
  53. package/dist/template/.changeset/bot-detection.md +9 -0
  54. package/dist/template/.changeset/briefing-delivery.md +21 -0
  55. package/dist/template/.changeset/briefing-sections.md +22 -0
  56. package/dist/template/.changeset/browser-journeys.md +8 -0
  57. package/dist/template/.changeset/builder-code-lane.md +25 -0
  58. package/dist/template/.changeset/business-presets.md +8 -0
  59. package/dist/template/.changeset/business-settings-and-csrf.md +17 -0
  60. package/dist/template/.changeset/c11-08-restore-drill.md +20 -0
  61. package/dist/template/.changeset/c11-12-f04-axe.md +8 -0
  62. package/dist/template/.changeset/c11-14-retention.md +8 -0
  63. package/dist/template/.changeset/c11-14-search.md +11 -0
  64. package/dist/template/.changeset/c11-journeys.md +7 -0
  65. package/dist/template/.changeset/c11-ops.md +8 -0
  66. package/dist/template/.changeset/c11-quality.md +8 -0
  67. package/dist/template/.changeset/c1111-reference-acceptance.md +8 -0
  68. package/dist/template/.changeset/c1111-reference-target-closure.md +8 -0
  69. package/dist/template/.changeset/c224-inline-canvas.md +13 -0
  70. package/dist/template/.changeset/c224-merchandising-blocks.md +19 -0
  71. package/dist/template/.changeset/c225-canvas-caret-swap.md +5 -0
  72. package/dist/template/.changeset/c225-canvas-drag-drop.md +5 -0
  73. package/dist/template/.changeset/c225-canvas-media-tools.md +5 -0
  74. package/dist/template/.changeset/c225-store-sections.md +5 -0
  75. package/dist/template/.changeset/c313-live-paradise-acceptance.md +8 -0
  76. package/dist/template/.changeset/c324-storefront-parity.md +5 -0
  77. package/dist/template/.changeset/c6-11-events-evidence.md +14 -0
  78. package/dist/template/.changeset/caddy-domain-env.md +7 -0
  79. package/dist/template/.changeset/calculators-and-coverage.md +13 -0
  80. package/dist/template/.changeset/calculators-localized-evidence.md +11 -0
  81. package/dist/template/.changeset/calendar-oauth.md +5 -0
  82. package/dist/template/.changeset/calendars.md +26 -0
  83. package/dist/template/.changeset/campaign-broadcasts.md +34 -0
  84. package/dist/template/.changeset/canonical-two-factor-envelope.md +7 -0
  85. package/dist/template/.changeset/capture-chunk-integrity.md +5 -0
  86. package/dist/template/.changeset/cart-capability-authorization.md +10 -0
  87. package/dist/template/.changeset/cart-contact-authority.md +5 -0
  88. package/dist/template/.changeset/catalog-checkout-milestones.md +8 -0
  89. package/dist/template/.changeset/catalog-quality-rtl.md +12 -0
  90. package/dist/template/.changeset/change-password.md +8 -0
  91. package/dist/template/.changeset/ci-minio-quay.md +6 -0
  92. package/dist/template/.changeset/client-documents.md +11 -0
  93. package/dist/template/.changeset/client-galleries.md +7 -0
  94. package/dist/template/.changeset/client-gallery-delivery-audit.md +9 -0
  95. package/dist/template/.changeset/client-readiness-security.md +7 -0
  96. package/dist/template/.changeset/close-world-class-storefront.md +27 -0
  97. package/dist/template/.changeset/cms-a11y-hints.md +5 -0
  98. package/dist/template/.changeset/cms-author-history.md +8 -0
  99. package/dist/template/.changeset/cms-blocks.md +8 -0
  100. package/dist/template/.changeset/cms-cache-budgets.md +5 -0
  101. package/dist/template/.changeset/cms-chrome-sections.md +8 -0
  102. package/dist/template/.changeset/cms-collab-presence-comments.md +7 -0
  103. package/dist/template/.changeset/cms-content-lifecycle.md +9 -0
  104. package/dist/template/.changeset/cms-design-tokens.md +5 -0
  105. package/dist/template/.changeset/cms-editor.md +8 -0
  106. package/dist/template/.changeset/cms-email-editor.md +5 -0
  107. package/dist/template/.changeset/cms-entity-layouts.md +5 -0
  108. package/dist/template/.changeset/cms-experiment-reporting.md +5 -0
  109. package/dist/template/.changeset/cms-experiments.md +5 -0
  110. package/dist/template/.changeset/cms-locale-workflow.md +5 -0
  111. package/dist/template/.changeset/cms-plugin-proof.md +5 -0
  112. package/dist/template/.changeset/cms-rich-editor-foundations.md +8 -0
  113. package/dist/template/.changeset/cms-section-instances.md +5 -0
  114. package/dist/template/.changeset/cms-surface-blocks.md +9 -0
  115. package/dist/template/.changeset/cms-templates.md +5 -0
  116. package/dist/template/.changeset/collections-taxonomy.md +5 -0
  117. package/dist/template/.changeset/commerce-advanced-money.md +16 -0
  118. package/dist/template/.changeset/commerce-carts-orders.md +9 -0
  119. package/dist/template/.changeset/commerce-catalog-merchandising.md +5 -0
  120. package/dist/template/.changeset/commerce-edge-contracts.md +5 -0
  121. package/dist/template/.changeset/commerce-fulfillment.md +9 -0
  122. package/dist/template/.changeset/commerce-inventory-ledger.md +9 -0
  123. package/dist/template/.changeset/commerce-invoice-admin.md +5 -0
  124. package/dist/template/.changeset/commerce-money-foundation.md +5 -0
  125. package/dist/template/.changeset/commerce-payment-providers.md +8 -0
  126. package/dist/template/.changeset/commerce-pos.md +8 -0
  127. package/dist/template/.changeset/commerce-procurement.md +9 -0
  128. package/dist/template/.changeset/commerce-product-lifecycle.md +16 -0
  129. package/dist/template/.changeset/commerce-promotions.md +8 -0
  130. package/dist/template/.changeset/commerce-provider-parity.md +10 -0
  131. package/dist/template/.changeset/commerce-relations-breaks.md +5 -0
  132. package/dist/template/.changeset/commerce-service-offerings.md +11 -0
  133. package/dist/template/.changeset/commerce-shipping-rates.md +9 -0
  134. package/dist/template/.changeset/commerce-tax-templates.md +5 -0
  135. package/dist/template/.changeset/commerce-variant-matrices.md +5 -0
  136. package/dist/template/.changeset/community-rooms.md +7 -0
  137. package/dist/template/.changeset/complete-demo-scenarios.md +10 -0
  138. package/dist/template/.changeset/completion-honesty.md +10 -0
  139. package/dist/template/.changeset/config.json +11 -0
  140. package/dist/template/.changeset/connection-grants.md +5 -0
  141. package/dist/template/.changeset/consent-gated-media.md +13 -0
  142. package/dist/template/.changeset/consent-is-evidence.md +13 -0
  143. package/dist/template/.changeset/contact-data-depth.md +16 -0
  144. package/dist/template/.changeset/contact-duplicate-review.md +17 -0
  145. package/dist/template/.changeset/contact-import.md +26 -0
  146. package/dist/template/.changeset/contact-merge-ui.md +8 -0
  147. package/dist/template/.changeset/contact-privacy-rights.md +18 -0
  148. package/dist/template/.changeset/contacts-admin.md +15 -0
  149. package/dist/template/.changeset/contacts-create-human-only.md +5 -0
  150. package/dist/template/.changeset/content-security-policy.md +8 -0
  151. package/dist/template/.changeset/contract-templates.md +22 -0
  152. package/dist/template/.changeset/contribute-channel.md +5 -0
  153. package/dist/template/.changeset/contribute-status-replies.md +5 -0
  154. package/dist/template/.changeset/conversations.md +20 -0
  155. package/dist/template/.changeset/core-jobs.md +9 -0
  156. package/dist/template/.changeset/core-runs.md +7 -0
  157. package/dist/template/.changeset/core-seo.md +10 -0
  158. package/dist/template/.changeset/create-freeholder-setup.md +8 -0
  159. package/dist/template/.changeset/credential-encryption.md +26 -0
  160. package/dist/template/.changeset/custom-field-options-default.md +8 -0
  161. package/dist/template/.changeset/customer-booking-screens.md +9 -0
  162. package/dist/template/.changeset/customer-dependency-security.md +5 -0
  163. package/dist/template/.changeset/customer-gallery-foundation.md +8 -0
  164. package/dist/template/.changeset/customer-invoice-payments.md +5 -0
  165. package/dist/template/.changeset/customer-magic-links.md +12 -0
  166. package/dist/template/.changeset/customer-mobile-contracts.md +6 -0
  167. package/dist/template/.changeset/customer-reply-and-account.md +7 -0
  168. package/dist/template/.changeset/customer-self-service.md +12 -0
  169. package/dist/template/.changeset/customization-seams.md +7 -0
  170. package/dist/template/.changeset/daily-briefing.md +27 -0
  171. package/dist/template/.changeset/daily-private-rooms.md +8 -0
  172. package/dist/template/.changeset/daily-update-check.md +6 -0
  173. package/dist/template/.changeset/danger-token-integrity.md +5 -0
  174. package/dist/template/.changeset/demo-same-droplet.md +12 -0
  175. package/dist/template/.changeset/dependency-security-policy.md +7 -0
  176. package/dist/template/.changeset/deploy-script-stdin.md +5 -0
  177. package/dist/template/.changeset/design-system-and-setup.md +17 -0
  178. package/dist/template/.changeset/deterministic-demo-scenarios.md +5 -0
  179. package/dist/template/.changeset/digitalocean-droplet-recipe.md +15 -0
  180. package/dist/template/.changeset/doc-claim-mapping.md +5 -0
  181. package/dist/template/.changeset/docs-availability.md +7 -0
  182. package/dist/template/.changeset/doctor.md +9 -0
  183. package/dist/template/.changeset/done.md +8 -0
  184. package/dist/template/.changeset/droplet-backup-cron-env.md +10 -0
  185. package/dist/template/.changeset/dunning.md +10 -0
  186. package/dist/template/.changeset/durable-provider-work.md +10 -0
  187. package/dist/template/.changeset/editor-preview-local-draft.md +5 -0
  188. package/dist/template/.changeset/editor-publish-autosave-race.md +5 -0
  189. package/dist/template/.changeset/embeds-with-backlinks.md +7 -0
  190. package/dist/template/.changeset/enforced-service-area-coverage.md +5 -0
  191. package/dist/template/.changeset/events-newsletters-seo.md +5 -0
  192. package/dist/template/.changeset/executable-tier-one-portability.md +5 -0
  193. package/dist/template/.changeset/expo-customer-app.md +10 -0
  194. package/dist/template/.changeset/external-calendar-sync.md +20 -0
  195. package/dist/template/.changeset/f-matrix-2026-09-16.md +17 -0
  196. package/dist/template/.changeset/f-matrix.md +9 -0
  197. package/dist/template/.changeset/f04-journey-screens.md +11 -0
  198. package/dist/template/.changeset/faceted-browse-storefront-search.md +5 -0
  199. package/dist/template/.changeset/first-party-plugin-surfaces.md +8 -0
  200. package/dist/template/.changeset/fork-lane.md +11 -0
  201. package/dist/template/.changeset/form-builder.md +26 -0
  202. package/dist/template/.changeset/forms-get-public-projection.md +13 -0
  203. package/dist/template/.changeset/forms-module.md +10 -0
  204. package/dist/template/.changeset/freeholder-app-init.md +10 -0
  205. package/dist/template/.changeset/front-site-assistant.md +29 -0
  206. package/dist/template/.changeset/gallery-approval-rounds.md +8 -0
  207. package/dist/template/.changeset/gallery-archive-delivery.md +13 -0
  208. package/dist/template/.changeset/gallery-download-policy.md +8 -0
  209. package/dist/template/.changeset/gallery-partner-share.md +8 -0
  210. package/dist/template/.changeset/gallery-proofing.md +9 -0
  211. package/dist/template/.changeset/gallery-sales.md +11 -0
  212. package/dist/template/.changeset/gate-hardening.md +5 -0
  213. package/dist/template/.changeset/generate-alt-text-without-open-transactions.md +9 -0
  214. package/dist/template/.changeset/graceful-job-shutdown.md +8 -0
  215. package/dist/template/.changeset/help-centre.md +16 -0
  216. package/dist/template/.changeset/honest-error-states.md +5 -0
  217. package/dist/template/.changeset/host-executor-drills.md +5 -0
  218. package/dist/template/.changeset/host-image-identity.md +5 -0
  219. package/dist/template/.changeset/host-updater-migration-lane.md +5 -0
  220. package/dist/template/.changeset/http-api.md +23 -0
  221. package/dist/template/.changeset/http-edge-auth-routes.md +14 -0
  222. package/dist/template/.changeset/ics-and-calendar-writeback.md +19 -0
  223. package/dist/template/.changeset/ics-feed-500.md +7 -0
  224. package/dist/template/.changeset/import-replace-rollback.md +5 -0
  225. package/dist/template/.changeset/inbox.md +24 -0
  226. package/dist/template/.changeset/intake-waivers-and-reminders.md +26 -0
  227. package/dist/template/.changeset/internal-service-boundary.md +9 -0
  228. package/dist/template/.changeset/job-operations.md +14 -0
  229. package/dist/template/.changeset/job-runtime-health.md +9 -0
  230. package/dist/template/.changeset/leftover-f04.md +8 -0
  231. package/dist/template/.changeset/light-and-dark.md +12 -0
  232. package/dist/template/.changeset/living-contract.md +5 -0
  233. package/dist/template/.changeset/locale-driven-customer-surfaces.md +14 -0
  234. package/dist/template/.changeset/locale-routing.md +10 -0
  235. package/dist/template/.changeset/locations-and-nap.md +29 -0
  236. package/dist/template/.changeset/loyalty-points.md +17 -0
  237. package/dist/template/.changeset/loyalty-tiers-rewards.md +20 -0
  238. package/dist/template/.changeset/mail-adapter-completion.md +20 -0
  239. package/dist/template/.changeset/mail-and-reset.md +10 -0
  240. package/dist/template/.changeset/mail-contacts.md +28 -0
  241. package/dist/template/.changeset/mail-delivery-boundary.md +10 -0
  242. package/dist/template/.changeset/managed-agent-loop.md +5 -0
  243. package/dist/template/.changeset/marketplace-channel-sync.md +7 -0
  244. package/dist/template/.changeset/mcp-server.md +20 -0
  245. package/dist/template/.changeset/media-and-canvas.md +8 -0
  246. package/dist/template/.changeset/media-capture-review.md +8 -0
  247. package/dist/template/.changeset/media-capture-sessions.md +5 -0
  248. package/dist/template/.changeset/media-delete-and-inline-editing.md +7 -0
  249. package/dist/template/.changeset/media-lifecycle.md +9 -0
  250. package/dist/template/.changeset/media-phone-ingest.md +8 -0
  251. package/dist/template/.changeset/memberships.md +37 -0
  252. package/dist/template/.changeset/message-templates.md +9 -0
  253. package/dist/template/.changeset/mobile-app-package.md +10 -0
  254. package/dist/template/.changeset/mobile-capture-batches.md +9 -0
  255. package/dist/template/.changeset/mobile-dependency-security.md +5 -0
  256. package/dist/template/.changeset/mobile-screens.md +10 -0
  257. package/dist/template/.changeset/mobile-store-ci.md +11 -0
  258. package/dist/template/.changeset/mobile-v2-deferral.md +12 -0
  259. package/dist/template/.changeset/n1-schema.md +6 -0
  260. package/dist/template/.changeset/named-roles-grants.md +10 -0
  261. package/dist/template/.changeset/native-customer-invoices.md +9 -0
  262. package/dist/template/.changeset/native-gallery-proofing.md +6 -0
  263. package/dist/template/.changeset/next-critical-advisories.md +6 -0
  264. package/dist/template/.changeset/no-double-booking.md +13 -0
  265. package/dist/template/.changeset/no-live-phone-example.md +5 -0
  266. package/dist/template/.changeset/note-task-recovery.md +9 -0
  267. package/dist/template/.changeset/notes.md +22 -0
  268. package/dist/template/.changeset/notification-fanout-inbox.md +17 -0
  269. package/dist/template/.changeset/on-danger-token.md +9 -0
  270. package/dist/template/.changeset/one-answer-to-who.md +24 -0
  271. package/dist/template/.changeset/open-source-demo-only.md +7 -0
  272. package/dist/template/.changeset/order-read-authorization.md +10 -0
  273. package/dist/template/.changeset/outbox-dead-letters.md +13 -0
  274. package/dist/template/.changeset/owner-agent-launch.md +4 -0
  275. package/dist/template/.changeset/owner-authored-assessments.md +15 -0
  276. package/dist/template/.changeset/owner-companion.md +10 -0
  277. package/dist/template/.changeset/owner-content-builder.md +21 -0
  278. package/dist/template/.changeset/owner-facing-helper.md +5 -0
  279. package/dist/template/.changeset/owner-storage-recording-import.md +8 -0
  280. package/dist/template/.changeset/ownership-recovery.md +5 -0
  281. package/dist/template/.changeset/ownership.md +8 -0
  282. package/dist/template/.changeset/package-artifact-integrity.md +9 -0
  283. package/dist/template/.changeset/paradise-comms-adapter.md +5 -0
  284. package/dist/template/.changeset/patch-uuid-buffer-advisory.md +7 -0
  285. package/dist/template/.changeset/paywalls.md +10 -0
  286. package/dist/template/.changeset/perf-harness-windows.md +11 -0
  287. package/dist/template/.changeset/perf-measurement-families.md +8 -0
  288. package/dist/template/.changeset/phase-0-foundations.md +7 -0
  289. package/dist/template/.changeset/pipelines.md +21 -0
  290. package/dist/template/.changeset/plan-evidence-gate.md +7 -0
  291. package/dist/template/.changeset/plan-proof-clause.md +9 -0
  292. package/dist/template/.changeset/plan-provider-pivot-2026-09-27.md +20 -0
  293. package/dist/template/.changeset/plan-world-class-commerce-editor-2026-09-29.md +21 -0
  294. package/dist/template/.changeset/playbook-schedules.md +21 -0
  295. package/dist/template/.changeset/playground-hardening.md +5 -0
  296. package/dist/template/.changeset/plugin-contract.md +5 -0
  297. package/dist/template/.changeset/popups.md +37 -0
  298. package/dist/template/.changeset/portable-plugins.md +5 -0
  299. package/dist/template/.changeset/portal-rooms.md +16 -0
  300. package/dist/template/.changeset/portal-shell.md +11 -0
  301. package/dist/template/.changeset/print-on-demand-fulfillment.md +7 -0
  302. package/dist/template/.changeset/printify-live-fulfillment.md +11 -0
  303. package/dist/template/.changeset/private-location-access.md +10 -0
  304. package/dist/template/.changeset/private-mobile-cache.md +6 -0
  305. package/dist/template/.changeset/private-note-access.md +8 -0
  306. package/dist/template/.changeset/privileged-two-factor.md +11 -0
  307. package/dist/template/.changeset/product-completion-plan.md +10 -0
  308. package/dist/template/.changeset/product-gift-share.md +7 -0
  309. package/dist/template/.changeset/project-case-studies.md +7 -0
  310. package/dist/template/.changeset/projects.md +24 -0
  311. package/dist/template/.changeset/provider-recording-erasure.md +8 -0
  312. package/dist/template/.changeset/provider-workflows-without-open-transactions.md +15 -0
  313. package/dist/template/.changeset/public-beta-2.md +4 -0
  314. package/dist/template/.changeset/public-beta-preparation.md +4 -0
  315. package/dist/template/.changeset/public-cart-checkout-confirmation.md +5 -0
  316. package/dist/template/.changeset/public-entity-drafts.md +6 -0
  317. package/dist/template/.changeset/public-gates.md +9 -0
  318. package/dist/template/.changeset/public-playground-host-updates.md +10 -0
  319. package/dist/template/.changeset/public-project-portfolios.md +7 -0
  320. package/dist/template/.changeset/publish-image.md +7 -0
  321. package/dist/template/.changeset/purge-without-open-transactions.md +9 -0
  322. package/dist/template/.changeset/push-notifications.md +11 -0
  323. package/dist/template/.changeset/queue-performance-clock.md +8 -0
  324. package/dist/template/.changeset/quote-conversion.md +22 -0
  325. package/dist/template/.changeset/quote-partner-share.md +7 -0
  326. package/dist/template/.changeset/quotes.md +22 -0
  327. package/dist/template/.changeset/real-browser-accessibility.md +7 -0
  328. package/dist/template/.changeset/recipe-bootstrap-fixes.md +9 -0
  329. package/dist/template/.changeset/recipe-update-backup-gate.md +5 -0
  330. package/dist/template/.changeset/recipient-messaging-policy.md +8 -0
  331. package/dist/template/.changeset/record-search-orders-subscriptions-gifts.md +8 -0
  332. package/dist/template/.changeset/record-studio-permissions.md +7 -0
  333. package/dist/template/.changeset/record-trash-every-row.md +9 -0
  334. package/dist/template/.changeset/recurring-invoices.md +24 -0
  335. package/dist/template/.changeset/referral-attribution.md +20 -0
  336. package/dist/template/.changeset/referral-commissions.md +11 -0
  337. package/dist/template/.changeset/register-stored-original-without-open-transactions.md +7 -0
  338. package/dist/template/.changeset/release-channels.md +7 -0
  339. package/dist/template/.changeset/remove-forced-builder-credit.md +5 -0
  340. package/dist/template/.changeset/rentals.md +22 -0
  341. package/dist/template/.changeset/reports-you-will-read.md +31 -0
  342. package/dist/template/.changeset/rescan-without-open-transactions.md +9 -0
  343. package/dist/template/.changeset/retire-stale-handoffs.md +7 -0
  344. package/dist/template/.changeset/reviews.md +11 -0
  345. package/dist/template/.changeset/rich-link-url-allowlist.md +5 -0
  346. package/dist/template/.changeset/role-guidance.md +5 -0
  347. package/dist/template/.changeset/rule-strong-token.md +13 -0
  348. package/dist/template/.changeset/saved-views.md +19 -0
  349. package/dist/template/.changeset/schema-baseline.md +12 -0
  350. package/dist/template/.changeset/scoring.md +23 -0
  351. package/dist/template/.changeset/security-parsing-and-recovery.md +8 -0
  352. package/dist/template/.changeset/seed-demo.md +8 -0
  353. package/dist/template/.changeset/seeded-development-home.md +5 -0
  354. package/dist/template/.changeset/segments.md +21 -0
  355. package/dist/template/.changeset/self-building-scope.md +12 -0
  356. package/dist/template/.changeset/seo-riba-surface.md +11 -0
  357. package/dist/template/.changeset/service-output-schemas.md +5 -0
  358. package/dist/template/.changeset/session-device-management.md +11 -0
  359. package/dist/template/.changeset/sharing-in-the-dna.md +32 -0
  360. package/dist/template/.changeset/ship-replit-storage-sdk.md +5 -0
  361. package/dist/template/.changeset/shopify-live-channel.md +12 -0
  362. package/dist/template/.changeset/shopify-refund-reconciliation.md +8 -0
  363. package/dist/template/.changeset/signed-candidate-history.md +4 -0
  364. package/dist/template/.changeset/signed-release-feed.md +6 -0
  365. package/dist/template/.changeset/signup-contact-import.md +5 -0
  366. package/dist/template/.changeset/site-live-chat.md +5 -0
  367. package/dist/template/.changeset/sms-consent-boundary.md +8 -0
  368. package/dist/template/.changeset/sms-registration.md +25 -0
  369. package/dist/template/.changeset/sms-templates-keywords-mms.md +5 -0
  370. package/dist/template/.changeset/sms.md +27 -0
  371. package/dist/template/.changeset/social-composer.md +9 -0
  372. package/dist/template/.changeset/social-connections.md +10 -0
  373. package/dist/template/.changeset/social-gbp.md +7 -0
  374. package/dist/template/.changeset/social-ingest.md +8 -0
  375. package/dist/template/.changeset/social-onboarding.md +8 -0
  376. package/dist/template/.changeset/source-first-start.md +5 -0
  377. package/dist/template/.changeset/source-map-security-floor.md +4 -0
  378. package/dist/template/.changeset/source-provenance.md +16 -0
  379. package/dist/template/.changeset/spine-and-service-registry.md +21 -0
  380. package/dist/template/.changeset/stable-release-publication.md +10 -0
  381. package/dist/template/.changeset/staff-invitations.md +13 -0
  382. package/dist/template/.changeset/standalone-artifact-boundary.md +5 -0
  383. package/dist/template/.changeset/standing-debts-1.md +10 -0
  384. package/dist/template/.changeset/storage-adapters.md +12 -0
  385. package/dist/template/.changeset/subscription-billing.md +12 -0
  386. package/dist/template/.changeset/supplier-agreement-search.md +8 -0
  387. package/dist/template/.changeset/supply-chain-release-gate.md +11 -0
  388. package/dist/template/.changeset/tasks.md +20 -0
  389. package/dist/template/.changeset/tax-adapter-seam.md +5 -0
  390. package/dist/template/.changeset/third-party-batch-2.md +28 -0
  391. package/dist/template/.changeset/third-party-findings-batch-1.md +27 -0
  392. package/dist/template/.changeset/tidy-sites-drop.md +9 -0
  393. package/dist/template/.changeset/time-entries.md +24 -0
  394. package/dist/template/.changeset/transaction-composition-integrity.md +22 -0
  395. package/dist/template/.changeset/transactional-jobs.md +15 -0
  396. package/dist/template/.changeset/translation-admin.md +26 -0
  397. package/dist/template/.changeset/translation-draft-honesty.md +5 -0
  398. package/dist/template/.changeset/typed-sdk.md +7 -0
  399. package/dist/template/.changeset/unified-calendar.md +23 -0
  400. package/dist/template/.changeset/update-admin.md +12 -0
  401. package/dist/template/.changeset/update-apply.md +6 -0
  402. package/dist/template/.changeset/update-cli.md +10 -0
  403. package/dist/template/.changeset/update-escalation.md +11 -0
  404. package/dist/template/.changeset/update-policy.md +6 -0
  405. package/dist/template/.changeset/update-preflight.md +6 -0
  406. package/dist/template/.changeset/update-status.md +10 -0
  407. package/dist/template/.changeset/update-targets.md +10 -0
  408. package/dist/template/.changeset/upgrade-gates.md +9 -0
  409. package/dist/template/.changeset/uploads-without-open-transactions.md +9 -0
  410. package/dist/template/.changeset/versioned-release.md +10 -0
  411. package/dist/template/.changeset/visit-to-paid-funnel.md +27 -0
  412. package/dist/template/.changeset/visual-drag.md +6 -0
  413. package/dist/template/.changeset/voice-video-rooms.md +8 -0
  414. package/dist/template/.changeset/voicevideo-credential-expiry.md +8 -0
  415. package/dist/template/.changeset/waitlists-groups-and-policy.md +27 -0
  416. package/dist/template/.changeset/watermark-backfill-without-open-transactions.md +9 -0
  417. package/dist/template/.changeset/watermarked-proof-renditions.md +8 -0
  418. package/dist/template/.changeset/webauthn-14.md +7 -0
  419. package/dist/template/.changeset/webhook-pinned-transport.md +5 -0
  420. package/dist/template/.changeset/webhooks.md +22 -0
  421. package/dist/template/.changeset/wevibesites-colophon.md +7 -0
  422. package/dist/template/.changeset/workflow-record-search.md +8 -0
  423. package/dist/template/.changeset/workforce-adapter-family.md +5 -0
  424. package/dist/template/.changeset/www-canonical-redirect.md +7 -0
  425. package/dist/template/.dockerignore +16 -0
  426. package/dist/template/.env.example +215 -0
  427. package/dist/template/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  428. package/dist/template/.github/actions/setup-project/action.yml +15 -0
  429. package/dist/template/.github/dependabot.yml +27 -0
  430. package/dist/template/.github/workflows/ci.yml +501 -0
  431. package/dist/template/.github/workflows/eas.yml +51 -0
  432. package/dist/template/.github/workflows/mirror-ci-images.yml +62 -0
  433. package/dist/template/.github/workflows/publish-image.yml +214 -0
  434. package/dist/template/.github/workflows/publish-packages.yml +75 -0
  435. package/dist/template/.github/workflows/security-scheduled.yml +47 -0
  436. package/dist/template/.node-version +1 -0
  437. package/dist/template/.railway/railway.ts +43 -0
  438. package/dist/template/.replit +15 -0
  439. package/dist/template/AGENTS.md +34 -0
  440. package/dist/template/CLAUDE.md +62 -0
  441. package/dist/template/CODE_OF_CONDUCT.md +134 -0
  442. package/dist/template/CONTRIBUTING.md +100 -0
  443. package/dist/template/DCO.md +42 -0
  444. package/dist/template/Dockerfile +48 -0
  445. package/dist/template/LICENSE +202 -0
  446. package/dist/template/LICENSING.md +61 -0
  447. package/dist/template/MASTER.md +10261 -0
  448. package/dist/template/README.md +122 -0
  449. package/dist/template/SECURITY.md +152 -0
  450. package/dist/template/app/(admin)/action-helpers.ts +21 -0
  451. package/dist/template/app/(admin)/actions.ts +1529 -0
  452. package/dist/template/app/(admin)/admin/AdminGuidanceHelp.tsx +38 -0
  453. package/dist/template/app/(admin)/admin/AdminNav.tsx +303 -0
  454. package/dist/template/app/(admin)/admin/BlockEditor.tsx +2993 -0
  455. package/dist/template/app/(admin)/admin/ConversationsPanel.tsx +124 -0
  456. package/dist/template/app/(admin)/admin/NotesPanel.tsx +161 -0
  457. package/dist/template/app/(admin)/admin/PreviewCanvas.tsx +583 -0
  458. package/dist/template/app/(admin)/admin/RichField.tsx +107 -0
  459. package/dist/template/app/(admin)/admin/ScorePanel.tsx +117 -0
  460. package/dist/template/app/(admin)/admin/SignOutButton.tsx +19 -0
  461. package/dist/template/app/(admin)/admin/ViewBar.tsx +162 -0
  462. package/dist/template/app/(admin)/admin/access/page.tsx +214 -0
  463. package/dist/template/app/(admin)/admin/ads/page.tsx +827 -0
  464. package/dist/template/app/(admin)/admin/agreements/[id]/page.tsx +148 -0
  465. package/dist/template/app/(admin)/admin/agreements/page.tsx +288 -0
  466. package/dist/template/app/(admin)/admin/appointments/[id]/page.tsx +522 -0
  467. package/dist/template/app/(admin)/admin/appointments/page.tsx +215 -0
  468. package/dist/template/app/(admin)/admin/assessments/BandEditor.tsx +295 -0
  469. package/dist/template/app/(admin)/admin/assessments/EscalationEditor.tsx +229 -0
  470. package/dist/template/app/(admin)/admin/assessments/PublishControls.tsx +76 -0
  471. package/dist/template/app/(admin)/admin/assessments/QuestionBuilder.tsx +489 -0
  472. package/dist/template/app/(admin)/admin/assessments/[id]/edit/page.tsx +64 -0
  473. package/dist/template/app/(admin)/admin/assessments/[id]/page.tsx +166 -0
  474. package/dist/template/app/(admin)/admin/assessments/labels.ts +106 -0
  475. package/dist/template/app/(admin)/admin/assessments/new/page.tsx +42 -0
  476. package/dist/template/app/(admin)/admin/assessments/page.tsx +95 -0
  477. package/dist/template/app/(admin)/admin/assistant/page.tsx +741 -0
  478. package/dist/template/app/(admin)/admin/automations/[id]/page.tsx +595 -0
  479. package/dist/template/app/(admin)/admin/automations/page.tsx +153 -0
  480. package/dist/template/app/(admin)/admin/blog/actions.ts +21 -0
  481. package/dist/template/app/(admin)/admin/blog/page.tsx +13 -0
  482. package/dist/template/app/(admin)/admin/briefing/page.tsx +179 -0
  483. package/dist/template/app/(admin)/admin/builder/page.tsx +205 -0
  484. package/dist/template/app/(admin)/admin/builder/proposals/[id]/page.tsx +88 -0
  485. package/dist/template/app/(admin)/admin/calculators/CalculatorBuilder.tsx +573 -0
  486. package/dist/template/app/(admin)/admin/calculators/CalculatorPublish.tsx +65 -0
  487. package/dist/template/app/(admin)/admin/calculators/[id]/page.tsx +75 -0
  488. package/dist/template/app/(admin)/admin/calculators/labels.ts +51 -0
  489. package/dist/template/app/(admin)/admin/calculators/new/page.tsx +35 -0
  490. package/dist/template/app/(admin)/admin/calculators/page.tsx +87 -0
  491. package/dist/template/app/(admin)/admin/calendar/page.tsx +326 -0
  492. package/dist/template/app/(admin)/admin/calendars/[id]/page.tsx +255 -0
  493. package/dist/template/app/(admin)/admin/calendars/audiences/page.tsx +256 -0
  494. package/dist/template/app/(admin)/admin/calendars/page.tsx +261 -0
  495. package/dist/template/app/(admin)/admin/calendars/waitlist/page.tsx +236 -0
  496. package/dist/template/app/(admin)/admin/carts/[id]/page.tsx +219 -0
  497. package/dist/template/app/(admin)/admin/carts/page.tsx +107 -0
  498. package/dist/template/app/(admin)/admin/collections/[id]/page.tsx +259 -0
  499. package/dist/template/app/(admin)/admin/collections/page.tsx +134 -0
  500. package/dist/template/app/(admin)/admin/community/page.tsx +293 -0
  501. package/dist/template/app/(admin)/admin/connect/ConnectForm.tsx +52 -0
  502. package/dist/template/app/(admin)/admin/connect/actions.ts +29 -0
  503. package/dist/template/app/(admin)/admin/connect/page.tsx +17 -0
  504. package/dist/template/app/(admin)/admin/contacts/ContactForm.tsx +287 -0
  505. package/dist/template/app/(admin)/admin/contacts/CustomFieldInputs.tsx +101 -0
  506. package/dist/template/app/(admin)/admin/contacts/[id]/MergePanel.tsx +113 -0
  507. package/dist/template/app/(admin)/admin/contacts/[id]/RelationshipPanel.tsx +234 -0
  508. package/dist/template/app/(admin)/admin/contacts/[id]/page.tsx +388 -0
  509. package/dist/template/app/(admin)/admin/contacts/contactLabels.ts +112 -0
  510. package/dist/template/app/(admin)/admin/contacts/duplicates/DuplicateReview.tsx +335 -0
  511. package/dist/template/app/(admin)/admin/contacts/duplicates/page.tsx +196 -0
  512. package/dist/template/app/(admin)/admin/contacts/fields/CustomFieldManager.tsx +199 -0
  513. package/dist/template/app/(admin)/admin/contacts/fields/page.tsx +58 -0
  514. package/dist/template/app/(admin)/admin/contacts/new/page.tsx +51 -0
  515. package/dist/template/app/(admin)/admin/contacts/organizations/OrganizationForm.tsx +144 -0
  516. package/dist/template/app/(admin)/admin/contacts/organizations/[id]/page.tsx +80 -0
  517. package/dist/template/app/(admin)/admin/contacts/organizations/labels.ts +26 -0
  518. package/dist/template/app/(admin)/admin/contacts/organizations/new/page.tsx +35 -0
  519. package/dist/template/app/(admin)/admin/contacts/organizations/page.tsx +140 -0
  520. package/dist/template/app/(admin)/admin/contacts/page.tsx +341 -0
  521. package/dist/template/app/(admin)/admin/contacts/privacy/PrivacyActionForm.tsx +59 -0
  522. package/dist/template/app/(admin)/admin/contacts/privacy/[id]/page.tsx +188 -0
  523. package/dist/template/app/(admin)/admin/contacts/privacy/page.tsx +241 -0
  524. package/dist/template/app/(admin)/admin/contribute/ContributeForms.tsx +190 -0
  525. package/dist/template/app/(admin)/admin/contribute/[id]/page.tsx +111 -0
  526. package/dist/template/app/(admin)/admin/contribute/page.tsx +114 -0
  527. package/dist/template/app/(admin)/admin/demos/page.tsx +174 -0
  528. package/dist/template/app/(admin)/admin/describeAction.ts +38 -0
  529. package/dist/template/app/(admin)/admin/design/DesignForm.tsx +206 -0
  530. package/dist/template/app/(admin)/admin/design/page.tsx +79 -0
  531. package/dist/template/app/(admin)/admin/documents/[id]/page.tsx +331 -0
  532. package/dist/template/app/(admin)/admin/documents/page.tsx +127 -0
  533. package/dist/template/app/(admin)/admin/editorLabels.ts +288 -0
  534. package/dist/template/app/(admin)/admin/events/[id]/page.tsx +192 -0
  535. package/dist/template/app/(admin)/admin/events/page.tsx +75 -0
  536. package/dist/template/app/(admin)/admin/experiments/page.tsx +71 -0
  537. package/dist/template/app/(admin)/admin/facts/FactForms.tsx +223 -0
  538. package/dist/template/app/(admin)/admin/facts/[key]/page.tsx +145 -0
  539. package/dist/template/app/(admin)/admin/facts/labels.ts +32 -0
  540. package/dist/template/app/(admin)/admin/facts/page.tsx +97 -0
  541. package/dist/template/app/(admin)/admin/forms/FieldBuilder.tsx +410 -0
  542. package/dist/template/app/(admin)/admin/forms/[id]/edit/page.tsx +87 -0
  543. package/dist/template/app/(admin)/admin/forms/[id]/page.tsx +198 -0
  544. package/dist/template/app/(admin)/admin/forms/builderLabels.ts +55 -0
  545. package/dist/template/app/(admin)/admin/forms/new/page.tsx +47 -0
  546. package/dist/template/app/(admin)/admin/forms/page.tsx +104 -0
  547. package/dist/template/app/(admin)/admin/fulfillment/page.tsx +87 -0
  548. package/dist/template/app/(admin)/admin/galleries/[id]/page.tsx +457 -0
  549. package/dist/template/app/(admin)/admin/galleries/page.tsx +132 -0
  550. package/dist/template/app/(admin)/admin/gifts/page.tsx +152 -0
  551. package/dist/template/app/(admin)/admin/guard.ts +59 -0
  552. package/dist/template/app/(admin)/admin/guidance/page.tsx +58 -0
  553. package/dist/template/app/(admin)/admin/health/page.tsx +141 -0
  554. package/dist/template/app/(admin)/admin/hire/page.tsx +228 -0
  555. package/dist/template/app/(admin)/admin/imports/ImportForms.tsx +167 -0
  556. package/dist/template/app/(admin)/admin/imports/[id]/page.tsx +65 -0
  557. package/dist/template/app/(admin)/admin/imports/contacts/[id]/page.tsx +273 -0
  558. package/dist/template/app/(admin)/admin/imports/contacts/page.tsx +212 -0
  559. package/dist/template/app/(admin)/admin/imports/page.tsx +68 -0
  560. package/dist/template/app/(admin)/admin/inbox/[id]/page.tsx +232 -0
  561. package/dist/template/app/(admin)/admin/inbox/page.tsx +306 -0
  562. package/dist/template/app/(admin)/admin/inventory/page.tsx +273 -0
  563. package/dist/template/app/(admin)/admin/invitations/InvitationManager.tsx +369 -0
  564. package/dist/template/app/(admin)/admin/invitations/page.tsx +102 -0
  565. package/dist/template/app/(admin)/admin/invoices/[id]/page.tsx +474 -0
  566. package/dist/template/app/(admin)/admin/invoices/format.ts +43 -0
  567. package/dist/template/app/(admin)/admin/invoices/new/page.tsx +206 -0
  568. package/dist/template/app/(admin)/admin/invoices/page.tsx +136 -0
  569. package/dist/template/app/(admin)/admin/invoices/recurring/page.tsx +227 -0
  570. package/dist/template/app/(admin)/admin/invoices/tax/page.tsx +378 -0
  571. package/dist/template/app/(admin)/admin/jobs/JobActionForm.tsx +54 -0
  572. package/dist/template/app/(admin)/admin/jobs/[name]/[id]/page.tsx +183 -0
  573. package/dist/template/app/(admin)/admin/jobs/outbox/[id]/page.tsx +130 -0
  574. package/dist/template/app/(admin)/admin/jobs/outbox/page.tsx +145 -0
  575. package/dist/template/app/(admin)/admin/jobs/page.tsx +221 -0
  576. package/dist/template/app/(admin)/admin/layout.tsx +194 -0
  577. package/dist/template/app/(admin)/admin/locations/DeleteButton.tsx +47 -0
  578. package/dist/template/app/(admin)/admin/locations/HoursForm.tsx +122 -0
  579. package/dist/template/app/(admin)/admin/locations/LocationForm.tsx +249 -0
  580. package/dist/template/app/(admin)/admin/locations/PrimaryButton.tsx +30 -0
  581. package/dist/template/app/(admin)/admin/locations/ServiceAreaForm.tsx +223 -0
  582. package/dist/template/app/(admin)/admin/locations/[id]/page.tsx +142 -0
  583. package/dist/template/app/(admin)/admin/locations/labels.ts +112 -0
  584. package/dist/template/app/(admin)/admin/locations/page.tsx +121 -0
  585. package/dist/template/app/(admin)/admin/loyalty/page.tsx +496 -0
  586. package/dist/template/app/(admin)/admin/marketplace/page.tsx +158 -0
  587. package/dist/template/app/(admin)/admin/media/AltTextForm.tsx +160 -0
  588. package/dist/template/app/(admin)/admin/media/DeleteAssetButton.tsx +74 -0
  589. package/dist/template/app/(admin)/admin/media/FocalPointForm.tsx +64 -0
  590. package/dist/template/app/(admin)/admin/media/RecordStudio.tsx +326 -0
  591. package/dist/template/app/(admin)/admin/media/TrashActions.tsx +100 -0
  592. package/dist/template/app/(admin)/admin/media/UploadForm.tsx +164 -0
  593. package/dist/template/app/(admin)/admin/media/page.tsx +415 -0
  594. package/dist/template/app/(admin)/admin/media/record/page.tsx +145 -0
  595. package/dist/template/app/(admin)/admin/media/upload-client.ts +313 -0
  596. package/dist/template/app/(admin)/admin/messaging/page.tsx +426 -0
  597. package/dist/template/app/(admin)/admin/newsletters/[id]/page.tsx +149 -0
  598. package/dist/template/app/(admin)/admin/newsletters/broadcasts/[id]/page.tsx +250 -0
  599. package/dist/template/app/(admin)/admin/newsletters/broadcasts/page.tsx +192 -0
  600. package/dist/template/app/(admin)/admin/newsletters/page.tsx +78 -0
  601. package/dist/template/app/(admin)/admin/newsletters/templates/page.tsx +254 -0
  602. package/dist/template/app/(admin)/admin/notifications/NotificationControls.tsx +197 -0
  603. package/dist/template/app/(admin)/admin/notifications/page.tsx +334 -0
  604. package/dist/template/app/(admin)/admin/orders/[id]/page.tsx +318 -0
  605. package/dist/template/app/(admin)/admin/orders/page.tsx +64 -0
  606. package/dist/template/app/(admin)/admin/page.tsx +159 -0
  607. package/dist/template/app/(admin)/admin/pages/SeedSiteButton.tsx +20 -0
  608. package/dist/template/app/(admin)/admin/pages/[id]/CopyPreviewLink.tsx +45 -0
  609. package/dist/template/app/(admin)/admin/pages/[id]/PageComments.tsx +242 -0
  610. package/dist/template/app/(admin)/admin/pages/[id]/PageEditor.tsx +105 -0
  611. package/dist/template/app/(admin)/admin/pages/[id]/PageLifecycle.tsx +210 -0
  612. package/dist/template/app/(admin)/admin/pages/[id]/PagePresence.tsx +63 -0
  613. package/dist/template/app/(admin)/admin/pages/[id]/PublishToggle.tsx +27 -0
  614. package/dist/template/app/(admin)/admin/pages/[id]/RevisionList.tsx +115 -0
  615. package/dist/template/app/(admin)/admin/pages/[id]/page.tsx +337 -0
  616. package/dist/template/app/(admin)/admin/pages/new/NewPageForm.tsx +65 -0
  617. package/dist/template/app/(admin)/admin/pages/new/page.tsx +45 -0
  618. package/dist/template/app/(admin)/admin/pages/page.tsx +171 -0
  619. package/dist/template/app/(admin)/admin/payments/page.tsx +203 -0
  620. package/dist/template/app/(admin)/admin/paywalls/page.tsx +199 -0
  621. package/dist/template/app/(admin)/admin/pipeline/page.tsx +313 -0
  622. package/dist/template/app/(admin)/admin/plugins/PluginForms.tsx +158 -0
  623. package/dist/template/app/(admin)/admin/plugins/page.tsx +150 -0
  624. package/dist/template/app/(admin)/admin/popups/[id]/PopupEditor.tsx +39 -0
  625. package/dist/template/app/(admin)/admin/popups/[id]/page.tsx +430 -0
  626. package/dist/template/app/(admin)/admin/popups/page.tsx +230 -0
  627. package/dist/template/app/(admin)/admin/pos/page.tsx +153 -0
  628. package/dist/template/app/(admin)/admin/price-lists/page.tsx +150 -0
  629. package/dist/template/app/(admin)/admin/print-on-demand/page.tsx +144 -0
  630. package/dist/template/app/(admin)/admin/procurement/page.tsx +208 -0
  631. package/dist/template/app/(admin)/admin/products/[id]/ProductEditor.tsx +61 -0
  632. package/dist/template/app/(admin)/admin/products/[id]/page.tsx +807 -0
  633. package/dist/template/app/(admin)/admin/products/new/page.tsx +55 -0
  634. package/dist/template/app/(admin)/admin/products/page.tsx +108 -0
  635. package/dist/template/app/(admin)/admin/projects/[id]/ProjectEditor.tsx +41 -0
  636. package/dist/template/app/(admin)/admin/projects/[id]/page.tsx +785 -0
  637. package/dist/template/app/(admin)/admin/projects/collections/[id]/page.tsx +166 -0
  638. package/dist/template/app/(admin)/admin/projects/collections/page.tsx +101 -0
  639. package/dist/template/app/(admin)/admin/projects/page.tsx +156 -0
  640. package/dist/template/app/(admin)/admin/promotions/page.tsx +206 -0
  641. package/dist/template/app/(admin)/admin/quotes/[id]/ConvertQuoteForm.tsx +34 -0
  642. package/dist/template/app/(admin)/admin/quotes/[id]/page.tsx +265 -0
  643. package/dist/template/app/(admin)/admin/quotes/page.tsx +193 -0
  644. package/dist/template/app/(admin)/admin/redirects/page.tsx +114 -0
  645. package/dist/template/app/(admin)/admin/referrals/page.tsx +464 -0
  646. package/dist/template/app/(admin)/admin/referrals/payouts/[id]/csv/route.ts +42 -0
  647. package/dist/template/app/(admin)/admin/reports/exports/[runId]/download/route.ts +41 -0
  648. package/dist/template/app/(admin)/admin/reports/exports/page.tsx +524 -0
  649. package/dist/template/app/(admin)/admin/reports/page.tsx +423 -0
  650. package/dist/template/app/(admin)/admin/retention/page.tsx +148 -0
  651. package/dist/template/app/(admin)/admin/returns/page.tsx +141 -0
  652. package/dist/template/app/(admin)/admin/reviews/page.tsx +250 -0
  653. package/dist/template/app/(admin)/admin/roles/RoleManager.tsx +381 -0
  654. package/dist/template/app/(admin)/admin/roles/page.tsx +78 -0
  655. package/dist/template/app/(admin)/admin/scoring/page.tsx +236 -0
  656. package/dist/template/app/(admin)/admin/search/page.tsx +137 -0
  657. package/dist/template/app/(admin)/admin/sections/[key]/SectionEditor.tsx +35 -0
  658. package/dist/template/app/(admin)/admin/sections/[key]/page.tsx +72 -0
  659. package/dist/template/app/(admin)/admin/sections/page.tsx +129 -0
  660. package/dist/template/app/(admin)/admin/segments/page.tsx +272 -0
  661. package/dist/template/app/(admin)/admin/settings/ApiKeysCard.tsx +268 -0
  662. package/dist/template/app/(admin)/admin/settings/MailSettingsCard.tsx +796 -0
  663. package/dist/template/app/(admin)/admin/settings/PasswordForm.tsx +86 -0
  664. package/dist/template/app/(admin)/admin/settings/SettingsForm.tsx +206 -0
  665. package/dist/template/app/(admin)/admin/settings/WebhooksCard.tsx +292 -0
  666. package/dist/template/app/(admin)/admin/settings/page.tsx +483 -0
  667. package/dist/template/app/(admin)/admin/sharing/page.tsx +426 -0
  668. package/dist/template/app/(admin)/admin/shipping/page.tsx +144 -0
  669. package/dist/template/app/(admin)/admin/social/page.tsx +544 -0
  670. package/dist/template/app/(admin)/admin/subscriptions/[id]/page.tsx +41 -0
  671. package/dist/template/app/(admin)/admin/subscriptions/page.tsx +491 -0
  672. package/dist/template/app/(admin)/admin/tasks/page.tsx +312 -0
  673. package/dist/template/app/(admin)/admin/templates/[key]/CreateFromTemplateForm.tsx +47 -0
  674. package/dist/template/app/(admin)/admin/templates/[key]/EmailInboxPreview.tsx +65 -0
  675. package/dist/template/app/(admin)/admin/templates/[key]/TemplateEditor.tsx +37 -0
  676. package/dist/template/app/(admin)/admin/templates/[key]/page.tsx +128 -0
  677. package/dist/template/app/(admin)/admin/templates/page.tsx +63 -0
  678. package/dist/template/app/(admin)/admin/time/page.tsx +328 -0
  679. package/dist/template/app/(admin)/admin/traffic/funnel/page.tsx +184 -0
  680. package/dist/template/app/(admin)/admin/traffic/page.tsx +409 -0
  681. package/dist/template/app/(admin)/admin/translations/TranslationEditor.tsx +166 -0
  682. package/dist/template/app/(admin)/admin/translations/[locale]/[id]/page.tsx +151 -0
  683. package/dist/template/app/(admin)/admin/translations/page.tsx +189 -0
  684. package/dist/template/app/(admin)/admin/trash/page.tsx +108 -0
  685. package/dist/template/app/(admin)/admin/updates/UpdateActionForm.tsx +72 -0
  686. package/dist/template/app/(admin)/admin/updates/page.tsx +520 -0
  687. package/dist/template/app/(admin)/admin/voice-video/GuestInvite.tsx +39 -0
  688. package/dist/template/app/(admin)/admin/voice-video/HostJoin.tsx +26 -0
  689. package/dist/template/app/(admin)/admin/voice-video/VerifyConnection.tsx +28 -0
  690. package/dist/template/app/(admin)/admin/voice-video/page.tsx +372 -0
  691. package/dist/template/app/(admin)/admin/work/LiveRun.tsx +112 -0
  692. package/dist/template/app/(admin)/admin/work/WorkForms.tsx +310 -0
  693. package/dist/template/app/(admin)/admin/work/[id]/page.tsx +248 -0
  694. package/dist/template/app/(admin)/admin/work/approvals/page.tsx +151 -0
  695. package/dist/template/app/(admin)/admin/work/page.tsx +349 -0
  696. package/dist/template/app/(admin)/admin/work/playbooks/PlaybookForms.tsx +139 -0
  697. package/dist/template/app/(admin)/admin/work/playbooks/page.tsx +285 -0
  698. package/dist/template/app/(admin)/admin/work/spend/page.tsx +126 -0
  699. package/dist/template/app/(admin)/ads-actions.ts +355 -0
  700. package/dist/template/app/(admin)/advanced-money-actions.ts +163 -0
  701. package/dist/template/app/(admin)/analytics-actions.ts +70 -0
  702. package/dist/template/app/(admin)/approval-actions.ts +57 -0
  703. package/dist/template/app/(admin)/assessments-actions.ts +224 -0
  704. package/dist/template/app/(admin)/assistant-actions.ts +184 -0
  705. package/dist/template/app/(admin)/audience-actions.ts +139 -0
  706. package/dist/template/app/(admin)/automation-actions.ts +347 -0
  707. package/dist/template/app/(admin)/availability-actions.ts +99 -0
  708. package/dist/template/app/(admin)/booking-actions.ts +295 -0
  709. package/dist/template/app/(admin)/briefing-actions.ts +46 -0
  710. package/dist/template/app/(admin)/broadcast-actions.ts +155 -0
  711. package/dist/template/app/(admin)/builder-actions.ts +92 -0
  712. package/dist/template/app/(admin)/calculators-actions.ts +127 -0
  713. package/dist/template/app/(admin)/calendar-actions.ts +96 -0
  714. package/dist/template/app/(admin)/capture-actions.ts +191 -0
  715. package/dist/template/app/(admin)/catalog-actions.ts +1054 -0
  716. package/dist/template/app/(admin)/cms-actions.ts +637 -0
  717. package/dist/template/app/(admin)/connection-actions.ts +72 -0
  718. package/dist/template/app/(admin)/contact-import-actions.ts +158 -0
  719. package/dist/template/app/(admin)/contract-actions.ts +138 -0
  720. package/dist/template/app/(admin)/contribute-actions.ts +145 -0
  721. package/dist/template/app/(admin)/demo-actions.ts +49 -0
  722. package/dist/template/app/(admin)/design-actions.ts +71 -0
  723. package/dist/template/app/(admin)/document-actions.ts +153 -0
  724. package/dist/template/app/(admin)/entitlement-actions.ts +92 -0
  725. package/dist/template/app/(admin)/event-actions.ts +109 -0
  726. package/dist/template/app/(admin)/export-actions.ts +122 -0
  727. package/dist/template/app/(admin)/facts-actions.ts +135 -0
  728. package/dist/template/app/(admin)/first-party-plugin-actions.ts +475 -0
  729. package/dist/template/app/(admin)/forgot/ForgotForm.tsx +54 -0
  730. package/dist/template/app/(admin)/forgot/page.tsx +78 -0
  731. package/dist/template/app/(admin)/forms-actions.ts +108 -0
  732. package/dist/template/app/(admin)/gallery-actions.ts +227 -0
  733. package/dist/template/app/(admin)/guidance-actions.ts +55 -0
  734. package/dist/template/app/(admin)/import-actions.ts +142 -0
  735. package/dist/template/app/(admin)/inbox-actions.ts +146 -0
  736. package/dist/template/app/(admin)/invitation-actions.ts +139 -0
  737. package/dist/template/app/(admin)/invite/AcceptInvitationForm.tsx +71 -0
  738. package/dist/template/app/(admin)/invite/page.tsx +110 -0
  739. package/dist/template/app/(admin)/invoice-actions.ts +357 -0
  740. package/dist/template/app/(admin)/login/PasskeySignIn.tsx +32 -0
  741. package/dist/template/app/(admin)/login/SignInForm.tsx +61 -0
  742. package/dist/template/app/(admin)/login/page.tsx +96 -0
  743. package/dist/template/app/(admin)/login/verify/VerifyLogin.tsx +80 -0
  744. package/dist/template/app/(admin)/login/verify/page.tsx +46 -0
  745. package/dist/template/app/(admin)/loyalty-actions.ts +208 -0
  746. package/dist/template/app/(admin)/media-actions.ts +203 -0
  747. package/dist/template/app/(admin)/messaging-actions.ts +173 -0
  748. package/dist/template/app/(admin)/newsletter-actions.ts +98 -0
  749. package/dist/template/app/(admin)/note-actions.ts +114 -0
  750. package/dist/template/app/(admin)/notification-actions.ts +113 -0
  751. package/dist/template/app/(admin)/payment-actions.ts +118 -0
  752. package/dist/template/app/(admin)/paywall-actions.ts +77 -0
  753. package/dist/template/app/(admin)/pipeline-actions.ts +123 -0
  754. package/dist/template/app/(admin)/playbook-actions.ts +202 -0
  755. package/dist/template/app/(admin)/plugin-actions.ts +112 -0
  756. package/dist/template/app/(admin)/popup-actions.ts +169 -0
  757. package/dist/template/app/(admin)/project-actions.ts +476 -0
  758. package/dist/template/app/(admin)/quote-actions.ts +148 -0
  759. package/dist/template/app/(admin)/read-helpers.ts +21 -0
  760. package/dist/template/app/(admin)/recurring-actions.ts +116 -0
  761. package/dist/template/app/(admin)/referral-actions.ts +187 -0
  762. package/dist/template/app/(admin)/rental-actions.ts +75 -0
  763. package/dist/template/app/(admin)/report-actions.ts +63 -0
  764. package/dist/template/app/(admin)/reset/ResetForm.tsx +68 -0
  765. package/dist/template/app/(admin)/reset/page.tsx +74 -0
  766. package/dist/template/app/(admin)/reset-actions.ts +59 -0
  767. package/dist/template/app/(admin)/retention-actions.ts +64 -0
  768. package/dist/template/app/(admin)/review-actions.ts +83 -0
  769. package/dist/template/app/(admin)/scoring-actions.ts +109 -0
  770. package/dist/template/app/(admin)/security/SecurityControls.tsx +240 -0
  771. package/dist/template/app/(admin)/security/labels.ts +24 -0
  772. package/dist/template/app/(admin)/security/page.tsx +51 -0
  773. package/dist/template/app/(admin)/security/verify/StepUpForm.tsx +69 -0
  774. package/dist/template/app/(admin)/security/verify/page.tsx +44 -0
  775. package/dist/template/app/(admin)/security-actions.ts +285 -0
  776. package/dist/template/app/(admin)/segment-actions.ts +144 -0
  777. package/dist/template/app/(admin)/seo-actions.ts +61 -0
  778. package/dist/template/app/(admin)/settings-module-actions.ts +37 -0
  779. package/dist/template/app/(admin)/share-actions.ts +116 -0
  780. package/dist/template/app/(admin)/social-actions.ts +211 -0
  781. package/dist/template/app/(admin)/subscription-actions.ts +154 -0
  782. package/dist/template/app/(admin)/task-actions.ts +118 -0
  783. package/dist/template/app/(admin)/template-actions.ts +92 -0
  784. package/dist/template/app/(admin)/time-actions.ts +175 -0
  785. package/dist/template/app/(admin)/translation-actions.ts +107 -0
  786. package/dist/template/app/(admin)/trash-actions.ts +89 -0
  787. package/dist/template/app/(admin)/view-actions.ts +111 -0
  788. package/dist/template/app/(admin)/work-actions.ts +274 -0
  789. package/dist/template/app/(preview)/canvas-bridge.ts +885 -0
  790. package/dist/template/app/(preview)/layout.tsx +193 -0
  791. package/dist/template/app/(preview)/preview/page/[id]/page.tsx +63 -0
  792. package/dist/template/app/(preview)/preview/popup/[id]/page.tsx +59 -0
  793. package/dist/template/app/(preview)/preview/product/[id]/page.tsx +41 -0
  794. package/dist/template/app/(preview)/preview/project/[id]/page.tsx +41 -0
  795. package/dist/template/app/(preview)/preview/section/[key]/page.tsx +63 -0
  796. package/dist/template/app/(preview)/preview/share/[token]/page.tsx +48 -0
  797. package/dist/template/app/(preview)/preview/template/[key]/page.tsx +57 -0
  798. package/dist/template/app/(public)/AnalyticsConsentControl.tsx +92 -0
  799. package/dist/template/app/(public)/AnalyticsRuntime.tsx +85 -0
  800. package/dist/template/app/(public)/NativeShare.tsx +48 -0
  801. package/dist/template/app/(public)/ShareBar.tsx +101 -0
  802. package/dist/template/app/(public)/[[...slug]]/alternates.ts +59 -0
  803. package/dist/template/app/(public)/[[...slug]]/page.tsx +541 -0
  804. package/dist/template/app/(public)/[[...slug]]/pageview.ts +88 -0
  805. package/dist/template/app/(public)/assessment-actions.ts +86 -0
  806. package/dist/template/app/(public)/book/actions.ts +38 -0
  807. package/dist/template/app/(public)/book/page.tsx +64 -0
  808. package/dist/template/app/(public)/browse/FacetPanel.tsx +285 -0
  809. package/dist/template/app/(public)/browse/SearchBox.tsx +42 -0
  810. package/dist/template/app/(public)/browse/SortLinks.tsx +58 -0
  811. package/dist/template/app/(public)/browse-params.ts +336 -0
  812. package/dist/template/app/(public)/buy/AddToCart.tsx +123 -0
  813. package/dist/template/app/(public)/buy/buy-actions.ts +96 -0
  814. package/dist/template/app/(public)/c/[slug]/CollectionGrid.tsx +130 -0
  815. package/dist/template/app/(public)/c/[slug]/page.tsx +344 -0
  816. package/dist/template/app/(public)/cart/cart-actions.ts +103 -0
  817. package/dist/template/app/(public)/cart/page.tsx +235 -0
  818. package/dist/template/app/(public)/checkout/DeliveryMethods.tsx +109 -0
  819. package/dist/template/app/(public)/checkout/checkout-actions.ts +183 -0
  820. package/dist/template/app/(public)/checkout/page.tsx +363 -0
  821. package/dist/template/app/(public)/community/[slug]/page.tsx +261 -0
  822. package/dist/template/app/(public)/community-actions.ts +108 -0
  823. package/dist/template/app/(public)/contribute/page.tsx +153 -0
  824. package/dist/template/app/(public)/contribute-actions.ts +48 -0
  825. package/dist/template/app/(public)/form-actions.ts +69 -0
  826. package/dist/template/app/(public)/gift-actions.ts +33 -0
  827. package/dist/template/app/(public)/gifts/[slug]/page.tsx +102 -0
  828. package/dist/template/app/(public)/inbound-actions.ts +114 -0
  829. package/dist/template/app/(public)/layout.tsx +225 -0
  830. package/dist/template/app/(public)/memberships/actions.ts +23 -0
  831. package/dist/template/app/(public)/memberships/page.tsx +27 -0
  832. package/dist/template/app/(public)/newsletter-actions.ts +32 -0
  833. package/dist/template/app/(public)/orders/confirm/page.tsx +173 -0
  834. package/dist/template/app/(public)/search/page.tsx +233 -0
  835. package/dist/template/app/(public)/share-actions.ts +70 -0
  836. package/dist/template/app/(public)/shopper-cart.ts +98 -0
  837. package/dist/template/app/.well-known/freeholder/route.ts +94 -0
  838. package/dist/template/app/README.md +30 -0
  839. package/dist/template/app/ads.txt/route.ts +18 -0
  840. package/dist/template/app/api/ads/third-party-consent/route.ts +64 -0
  841. package/dist/template/app/api/ads/view/route.ts +58 -0
  842. package/dist/template/app/api/analytics/consent/route.ts +168 -0
  843. package/dist/template/app/api/analytics/export/route.ts +36 -0
  844. package/dist/template/app/api/analytics/vitals/route.ts +62 -0
  845. package/dist/template/app/api/auth/login/route.ts +31 -0
  846. package/dist/template/app/api/auth/login/verify/route.ts +66 -0
  847. package/dist/template/app/api/auth/logout/route.ts +18 -0
  848. package/dist/template/app/api/auth/session/route.ts +57 -0
  849. package/dist/template/app/api/chat/assistant/route.ts +51 -0
  850. package/dist/template/app/api/chat/route.ts +82 -0
  851. package/dist/template/app/api/cms/defaults/route.ts +20 -0
  852. package/dist/template/app/api/connections/calendar/[provider]/callback/route.ts +117 -0
  853. package/dist/template/app/api/connections/mail-read/[provider]/callback/route.ts +114 -0
  854. package/dist/template/app/api/connections/signup-contacts/[provider]/callback/route.ts +58 -0
  855. package/dist/template/app/api/doctor/route.ts +34 -0
  856. package/dist/template/app/api/health/live/route.ts +11 -0
  857. package/dist/template/app/api/health/route.ts +56 -0
  858. package/dist/template/app/api/mail/oauth/[provider]/callback/route.ts +80 -0
  859. package/dist/template/app/api/mail/webhooks/postmark/route.ts +7 -0
  860. package/dist/template/app/api/mail/webhooks/resend/route.ts +7 -0
  861. package/dist/template/app/api/mail/webhooks/ses/route.ts +7 -0
  862. package/dist/template/app/api/mcp/route.ts +42 -0
  863. package/dist/template/app/api/media/route.ts +58 -0
  864. package/dist/template/app/api/media/uploads/abort/route.ts +6 -0
  865. package/dist/template/app/api/media/uploads/complete/route.ts +6 -0
  866. package/dist/template/app/api/media/uploads/parts/route.ts +6 -0
  867. package/dist/template/app/api/media/uploads/route.ts +7 -0
  868. package/dist/template/app/api/openapi.json/route.ts +38 -0
  869. package/dist/template/app/api/payments/webhooks/flutterwave/route.ts +6 -0
  870. package/dist/template/app/api/payments/webhooks/mollie/route.ts +6 -0
  871. package/dist/template/app/api/payments/webhooks/paypal/route.ts +6 -0
  872. package/dist/template/app/api/payments/webhooks/paystack/route.ts +6 -0
  873. package/dist/template/app/api/payments/webhooks/razorpay/route.ts +6 -0
  874. package/dist/template/app/api/payments/webhooks/square/route.ts +6 -0
  875. package/dist/template/app/api/payments/webhooks/stripe/route.ts +6 -0
  876. package/dist/template/app/api/plugins/voice-video/webhooks/paradise/route.ts +45 -0
  877. package/dist/template/app/api/popups/route.ts +141 -0
  878. package/dist/template/app/api/security/csp-report/route.ts +50 -0
  879. package/dist/template/app/api/setup/owner/route.ts +19 -0
  880. package/dist/template/app/api/sms/webhooks/twilio/route.ts +6 -0
  881. package/dist/template/app/api/social/[provider]/callback/route.ts +70 -0
  882. package/dist/template/app/api/v1/[service]/route.ts +22 -0
  883. package/dist/template/app/app-ads.txt/route.ts +18 -0
  884. package/dist/template/app/capture/[token]/page.tsx +71 -0
  885. package/dist/template/app/embed/booking/page.tsx +7 -0
  886. package/dist/template/app/embed/gallery/[slug]/page.tsx +52 -0
  887. package/dist/template/app/embed/layout.tsx +13 -0
  888. package/dist/template/app/embed/newsletter/[id]/page.tsx +65 -0
  889. package/dist/template/app/embed/newsletter/actions.ts +25 -0
  890. package/dist/template/app/embed/reviews/page.tsx +51 -0
  891. package/dist/template/app/feeds/[kind]/route.ts +39 -0
  892. package/dist/template/app/g/[slug]/archive/route.ts +41 -0
  893. package/dist/template/app/g/[slug]/download/[itemId]/route.ts +39 -0
  894. package/dist/template/app/g/[slug]/page.tsx +331 -0
  895. package/dist/template/app/g/[slug]/view/[itemId]/route.ts +51 -0
  896. package/dist/template/app/g/actions.ts +211 -0
  897. package/dist/template/app/gift/[token]/page.tsx +61 -0
  898. package/dist/template/app/globals.css +148 -0
  899. package/dist/template/app/go/ad/route.ts +113 -0
  900. package/dist/template/app/i18n.ts +73 -0
  901. package/dist/template/app/ics/bookings/[token]/route.ts +42 -0
  902. package/dist/template/app/ics/calendars/[token]/route.ts +44 -0
  903. package/dist/template/app/ics/events/[slug]/route.ts +23 -0
  904. package/dist/template/app/indexnow-key/route.ts +25 -0
  905. package/dist/template/app/layout.tsx +66 -0
  906. package/dist/template/app/llms-full.txt/route.ts +14 -0
  907. package/dist/template/app/llms.txt/route.ts +102 -0
  908. package/dist/template/app/manifest.ts +69 -0
  909. package/dist/template/app/media/[...key]/route.ts +48 -0
  910. package/dist/template/app/media/download/[id]/route.ts +48 -0
  911. package/dist/template/app/newsletters/confirm/route.ts +26 -0
  912. package/dist/template/app/not-found.tsx +29 -0
  913. package/dist/template/app/og/[[...slug]]/route.tsx +54 -0
  914. package/dist/template/app/og/og-template.tsx +81 -0
  915. package/dist/template/app/playground/actions.ts +18 -0
  916. package/dist/template/app/playground/page.tsx +29 -0
  917. package/dist/template/app/portal/(account)/[section]/page.tsx +113 -0
  918. package/dist/template/app/portal/(account)/layout.tsx +108 -0
  919. package/dist/template/app/portal/(account)/messages/[id]/page.tsx +120 -0
  920. package/dist/template/app/portal/(account)/page.tsx +112 -0
  921. package/dist/template/app/portal/(account)/profile/page.tsx +139 -0
  922. package/dist/template/app/portal/(account)/records/[section]/[id]/actions.ts +25 -0
  923. package/dist/template/app/portal/(account)/records/[section]/[id]/page.tsx +24 -0
  924. package/dist/template/app/portal/(account)/subscriptions/[id]/page.tsx +169 -0
  925. package/dist/template/app/portal/PortalLocaleChooser.tsx +69 -0
  926. package/dist/template/app/portal/actions.ts +323 -0
  927. package/dist/template/app/portal/agreements/[token]/page.tsx +151 -0
  928. package/dist/template/app/portal/agreements/actions.ts +81 -0
  929. package/dist/template/app/portal/appointments/[token]/intake/page.tsx +98 -0
  930. package/dist/template/app/portal/appointments/[token]/page.tsx +210 -0
  931. package/dist/template/app/portal/appointments/actions.ts +131 -0
  932. package/dist/template/app/portal/appointments/moved/page.tsx +30 -0
  933. package/dist/template/app/portal/contact-import/DeviceContactPicker.tsx +119 -0
  934. package/dist/template/app/portal/contact-import/[id]/page.tsx +170 -0
  935. package/dist/template/app/portal/contact-import/actions.ts +193 -0
  936. package/dist/template/app/portal/contact-import/page.tsx +298 -0
  937. package/dist/template/app/portal/files/[id]/route.ts +50 -0
  938. package/dist/template/app/portal/invoices/InvoiceView.tsx +64 -0
  939. package/dist/template/app/portal/invoices/PaymentButton.tsx +10 -0
  940. package/dist/template/app/portal/invoices/[id]/page.tsx +37 -0
  941. package/dist/template/app/portal/invoices/actions.ts +52 -0
  942. package/dist/template/app/portal/invoices/confirmation/[token]/page.tsx +41 -0
  943. package/dist/template/app/portal/invoices/loading.tsx +7 -0
  944. package/dist/template/app/portal/login/MagicLinkForm.tsx +30 -0
  945. package/dist/template/app/portal/login/page.tsx +76 -0
  946. package/dist/template/app/portal/magic/confirm/ConfirmMagicLink.tsx +24 -0
  947. package/dist/template/app/portal/magic/confirm/page.tsx +46 -0
  948. package/dist/template/app/portal/magic/route.ts +36 -0
  949. package/dist/template/app/portal/message-actions.ts +51 -0
  950. package/dist/template/app/portal/privacy/PortalPrivacyCentre.tsx +209 -0
  951. package/dist/template/app/portal/privacy/page.tsx +147 -0
  952. package/dist/template/app/portal/quotes/[token]/page.tsx +324 -0
  953. package/dist/template/app/portal/quotes/accepted/page.tsx +30 -0
  954. package/dist/template/app/portal/quotes/actions.ts +145 -0
  955. package/dist/template/app/portal/quotes/partner/[token]/page.tsx +128 -0
  956. package/dist/template/app/portal/registry/actions.ts +34 -0
  957. package/dist/template/app/portal/registry/page.tsx +81 -0
  958. package/dist/template/app/portal/subscription-actions.ts +69 -0
  959. package/dist/template/app/privacy/artifacts/[id]/route.ts +38 -0
  960. package/dist/template/app/registry/[token]/page.tsx +67 -0
  961. package/dist/template/app/report-exports/[token]/route.ts +45 -0
  962. package/dist/template/app/robots.txt/route.ts +18 -0
  963. package/dist/template/app/s/[ref]/route.ts +41 -0
  964. package/dist/template/app/setup/OwnerForm.tsx +87 -0
  965. package/dist/template/app/setup/Steps.tsx +55 -0
  966. package/dist/template/app/setup/access.ts +15 -0
  967. package/dist/template/app/setup/actions.ts +203 -0
  968. package/dist/template/app/setup/business/BusinessForm.tsx +170 -0
  969. package/dist/template/app/setup/business/page.tsx +41 -0
  970. package/dist/template/app/setup/businessLabels.ts +113 -0
  971. package/dist/template/app/setup/done/DoneForm.tsx +33 -0
  972. package/dist/template/app/setup/done/MailReadiness.tsx +137 -0
  973. package/dist/template/app/setup/done/page.tsx +90 -0
  974. package/dist/template/app/setup/layout.tsx +48 -0
  975. package/dist/template/app/setup/location/LocationStepForm.tsx +110 -0
  976. package/dist/template/app/setup/location/page.tsx +61 -0
  977. package/dist/template/app/setup/page.tsx +50 -0
  978. package/dist/template/app/setup/security/page.tsx +29 -0
  979. package/dist/template/app/share/route.ts +60 -0
  980. package/dist/template/app/sitemap.xml/route.ts +31 -0
  981. package/dist/template/app/sitemaps/[locale]/route.ts +56 -0
  982. package/dist/template/app/source/route.ts +67 -0
  983. package/dist/template/app/theme.ts +54 -0
  984. package/dist/template/app/themeLabels.ts +26 -0
  985. package/dist/template/app/unsubscribe/route.ts +49 -0
  986. package/dist/template/db/README.md +21 -0
  987. package/dist/template/db/migrations/0000_reviewed-baseline.sql +7342 -0
  988. package/dist/template/db/migrations/0001_community_rooms.sql +46 -0
  989. package/dist/template/db/migrations/0002_voice_video_rooms.sql +41 -0
  990. package/dist/template/db/migrations/0003_print_on_demand_fulfillment.sql +21 -0
  991. package/dist/template/db/migrations/0004_marketplace_channel_sync.sql +23 -0
  992. package/dist/template/db/migrations/0005_retention_policies.sql +14 -0
  993. package/dist/template/db/migrations/0006_contact_pagination.sql +5 -0
  994. package/dist/template/db/migrations/0007_marketplace_sync_lease.sql +6 -0
  995. package/dist/template/db/migrations/0008_printify_live_fulfillment.sql +21 -0
  996. package/dist/template/db/migrations/0009_daily_voice_video.sql +14 -0
  997. package/dist/template/db/migrations/0010_note_task_trash.sql +10 -0
  998. package/dist/template/db/migrations/0011_record_trash.sql +22 -0
  999. package/dist/template/db/migrations/0012_owner_storage_refunds.sql +41 -0
  1000. package/dist/template/db/migrations/0013_assessments.sql +119 -0
  1001. package/dist/template/db/migrations/0014_attestations.sql +67 -0
  1002. package/dist/template/db/migrations/0015_media_consents.sql +108 -0
  1003. package/dist/template/db/migrations/0016_calculators.sql +31 -0
  1004. package/dist/template/db/migrations/0017_postal_service_areas.sql +22 -0
  1005. package/dist/template/db/migrations/0018_area_delivery_windows.sql +17 -0
  1006. package/dist/template/db/migrations/0019_paradise_voice_video.sql +15 -0
  1007. package/dist/template/db/migrations/0020_collections.sql +54 -0
  1008. package/dist/template/db/migrations/0021_order_payment_milestones.sql +21 -0
  1009. package/dist/template/db/migrations/0022_customer_surfaces.sql +31 -0
  1010. package/dist/template/db/migrations/0023_gallery_private_delivery.sql +13 -0
  1011. package/dist/template/db/migrations/0024_broadcast_unsubscribe.sql +11 -0
  1012. package/dist/template/db/migrations/meta/0000_snapshot.json +53876 -0
  1013. package/dist/template/db/migrations/meta/_journal.json +181 -0
  1014. package/dist/template/deploy/README.md +130 -0
  1015. package/dist/template/deploy/accessibility-testing.md +77 -0
  1016. package/dist/template/deploy/agent-launch.md +129 -0
  1017. package/dist/template/deploy/alt-text-suggestions.md +75 -0
  1018. package/dist/template/deploy/analytics-governance.md +81 -0
  1019. package/dist/template/deploy/app-store-privacy.md +82 -0
  1020. package/dist/template/deploy/background-jobs.md +229 -0
  1021. package/dist/template/deploy/browser-journeys.md +78 -0
  1022. package/dist/template/deploy/c11-08-restore-drill-2026-09-28.log +41 -0
  1023. package/dist/template/deploy/c11-08-restore-summary.md +113 -0
  1024. package/dist/template/deploy/c224-editor-ux-audit-2026-09-29.md +120 -0
  1025. package/dist/template/deploy/c313-live-acceptance-2026-09-28.log +219 -0
  1026. package/dist/template/deploy/c313-live-acceptance-2026-09-28.md +83 -0
  1027. package/dist/template/deploy/c324-storefront-parity-2026-09-29.md +168 -0
  1028. package/dist/template/deploy/catalog-cart-access.md +35 -0
  1029. package/dist/template/deploy/catalog-checkout-milestones.md +56 -0
  1030. package/dist/template/deploy/ci-release-gate.md +83 -0
  1031. package/dist/template/deploy/client-readiness.md +49 -0
  1032. package/dist/template/deploy/commerce-catalog.md +119 -0
  1033. package/dist/template/deploy/commerce-money.md +191 -0
  1034. package/dist/template/deploy/commerce-payments.md +226 -0
  1035. package/dist/template/deploy/content-security-policy.md +84 -0
  1036. package/dist/template/deploy/contribute.md +37 -0
  1037. package/dist/template/deploy/customer-locales.md +82 -0
  1038. package/dist/template/deploy/customer-surfaces-2026-10-07.md +90 -0
  1039. package/dist/template/deploy/customization-seams.md +18 -0
  1040. package/dist/template/deploy/demo-scenarios.md +96 -0
  1041. package/dist/template/deploy/digitalocean-app/.env.example +15 -0
  1042. package/dist/template/deploy/digitalocean-app/README.md +26 -0
  1043. package/dist/template/deploy/digitalocean-app/infra/app.yaml +75 -0
  1044. package/dist/template/deploy/digitalocean-app/migrate.md +10 -0
  1045. package/dist/template/deploy/digitalocean-app/recipe.yaml +40 -0
  1046. package/dist/template/deploy/digitalocean-app/verify.md +10 -0
  1047. package/dist/template/deploy/digitalocean-droplet/.env.example +21 -0
  1048. package/dist/template/deploy/digitalocean-droplet/README.md +145 -0
  1049. package/dist/template/deploy/digitalocean-droplet/deploy.md +89 -0
  1050. package/dist/template/deploy/digitalocean-droplet/infra/Caddyfile +12 -0
  1051. package/dist/template/deploy/digitalocean-droplet/infra/backup.sh +52 -0
  1052. package/dist/template/deploy/digitalocean-droplet/infra/cloud-init.yml +46 -0
  1053. package/dist/template/deploy/digitalocean-droplet/infra/compose.yml +65 -0
  1054. package/dist/template/deploy/digitalocean-droplet/migrate.md +9 -0
  1055. package/dist/template/deploy/digitalocean-droplet/recipe.yaml +47 -0
  1056. package/dist/template/deploy/digitalocean-droplet/verify.md +117 -0
  1057. package/dist/template/deploy/doc-claim-mapping.md +261 -0
  1058. package/dist/template/deploy/docker-selfhost/.env.example +15 -0
  1059. package/dist/template/deploy/docker-selfhost/README.md +28 -0
  1060. package/dist/template/deploy/docker-selfhost/docker-updater/Caddyfile +9 -0
  1061. package/dist/template/deploy/docker-selfhost/docker-updater/README.md +121 -0
  1062. package/dist/template/deploy/docker-selfhost/docker-updater/compose.yml +64 -0
  1063. package/dist/template/deploy/docker-selfhost/docker-updater/config.example.json +10 -0
  1064. package/dist/template/deploy/docker-selfhost/docker-updater/freeholder-update-check.service +11 -0
  1065. package/dist/template/deploy/docker-selfhost/docker-updater/freeholder-update-check.timer +10 -0
  1066. package/dist/template/deploy/docker-selfhost/docker-updater/freeholder-updater.service +20 -0
  1067. package/dist/template/deploy/docker-selfhost/infra/compose.yml +41 -0
  1068. package/dist/template/deploy/docker-selfhost/migrate.md +9 -0
  1069. package/dist/template/deploy/docker-selfhost/playground/README.md +76 -0
  1070. package/dist/template/deploy/docker-selfhost/playground/compose.proxy-overlay.yml +14 -0
  1071. package/dist/template/deploy/docker-selfhost/playground/compose.yml +59 -0
  1072. package/dist/template/deploy/docker-selfhost/playground/demo.freeholder.ai.caddy +10 -0
  1073. package/dist/template/deploy/docker-selfhost/playground/freeholder-playground-reset.service +10 -0
  1074. package/dist/template/deploy/docker-selfhost/playground/freeholder-playground-reset.timer +10 -0
  1075. package/dist/template/deploy/docker-selfhost/playground/reset.sh +17 -0
  1076. package/dist/template/deploy/docker-selfhost/recipe.yaml +42 -0
  1077. package/dist/template/deploy/docker-selfhost/verify.md +9 -0
  1078. package/dist/template/deploy/edge-adapters.md +58 -0
  1079. package/dist/template/deploy/event-outbox.md +80 -0
  1080. package/dist/template/deploy/f-criteria-matrix.md +4649 -0
  1081. package/dist/template/deploy/first-party-plugins.md +219 -0
  1082. package/dist/template/deploy/fork-lane.md +93 -0
  1083. package/dist/template/deploy/host-updater.example.json +23 -0
  1084. package/dist/template/deploy/host-updater.md +107 -0
  1085. package/dist/template/deploy/mail-delivery.md +205 -0
  1086. package/dist/template/deploy/media-lifecycle.md +129 -0
  1087. package/dist/template/deploy/migration-runbook.md +117 -0
  1088. package/dist/template/deploy/n1-schema.md +34 -0
  1089. package/dist/template/deploy/notification-fanout.md +92 -0
  1090. package/dist/template/deploy/ownership-recovery.md +193 -0
  1091. package/dist/template/deploy/perf-reference-run-2026-09-27.log +432 -0
  1092. package/dist/template/deploy/performance-measurements.md +234 -0
  1093. package/dist/template/deploy/play-data-safety.md +73 -0
  1094. package/dist/template/deploy/privacy-rights.md +148 -0
  1095. package/dist/template/deploy/provider-recording-erasure.md +102 -0
  1096. package/dist/template/deploy/push-notifications.md +92 -0
  1097. package/dist/template/deploy/railway/.env.example +15 -0
  1098. package/dist/template/deploy/railway/README.md +24 -0
  1099. package/dist/template/deploy/railway/migrate.md +10 -0
  1100. package/dist/template/deploy/railway/recipe.yaml +35 -0
  1101. package/dist/template/deploy/railway/verify.md +9 -0
  1102. package/dist/template/deploy/recipe-verification.md +23 -0
  1103. package/dist/template/deploy/record-trash.md +115 -0
  1104. package/dist/template/deploy/release-channels.md +27 -0
  1105. package/dist/template/deploy/release-feed.md +53 -0
  1106. package/dist/template/deploy/release-notes-2026-09-14.md +86 -0
  1107. package/dist/template/deploy/release-notes-2026-09-15.md +52 -0
  1108. package/dist/template/deploy/release-notes-2026-09-16.md +114 -0
  1109. package/dist/template/deploy/release-notes-2026-09-26.md +209 -0
  1110. package/dist/template/deploy/release-notes-2026-09-27.md +47 -0
  1111. package/dist/template/deploy/release-notes-2026-09-28.md +142 -0
  1112. package/dist/template/deploy/release-notes-2026-09-29.md +138 -0
  1113. package/dist/template/deploy/release-notes-2026-09-30.md +50 -0
  1114. package/dist/template/deploy/release-notes-2026-10-01.md +112 -0
  1115. package/dist/template/deploy/release-readiness.md +46 -0
  1116. package/dist/template/deploy/render/.env.example +15 -0
  1117. package/dist/template/deploy/render/README.md +22 -0
  1118. package/dist/template/deploy/render/migrate.md +10 -0
  1119. package/dist/template/deploy/render/recipe.yaml +40 -0
  1120. package/dist/template/deploy/render/verify.md +9 -0
  1121. package/dist/template/deploy/replit/.env.example +10 -0
  1122. package/dist/template/deploy/replit/README.md +29 -0
  1123. package/dist/template/deploy/replit/migrate.md +10 -0
  1124. package/dist/template/deploy/replit/recipe.yaml +40 -0
  1125. package/dist/template/deploy/replit/verify.md +10 -0
  1126. package/dist/template/deploy/role-guidance.md +77 -0
  1127. package/dist/template/deploy/spec-reconciliation.md +188 -0
  1128. package/dist/template/deploy/stable-acceptance-2026-10-05.md +168 -0
  1129. package/dist/template/deploy/update-admin.md +83 -0
  1130. package/dist/template/deploy/update-apply.md +48 -0
  1131. package/dist/template/deploy/update-checks.md +27 -0
  1132. package/dist/template/deploy/update-escalation.md +71 -0
  1133. package/dist/template/deploy/update-policy.md +20 -0
  1134. package/dist/template/deploy/update-preflight.md +19 -0
  1135. package/dist/template/deploy/update-status.md +78 -0
  1136. package/dist/template/deploy/update-targets.md +90 -0
  1137. package/dist/template/deploy/webhook-delivery.md +36 -0
  1138. package/dist/template/drizzle.config.ts +24 -0
  1139. package/dist/template/eslint.config.mjs +241 -0
  1140. package/dist/template/freeholder.config.ts +11 -0
  1141. package/dist/template/gitignore.template +48 -0
  1142. package/dist/template/instrumentation.node.ts +113 -0
  1143. package/dist/template/instrumentation.ts +23 -0
  1144. package/dist/template/locales/README.md +68 -0
  1145. package/dist/template/locales/ar.json +7090 -0
  1146. package/dist/template/locales/en.json +7090 -0
  1147. package/dist/template/locales/es.json +7090 -0
  1148. package/dist/template/locales/fr.json +7090 -0
  1149. package/dist/template/next.config.ts +166 -0
  1150. package/dist/template/package.json +98 -0
  1151. package/dist/template/packages/README.md +31 -0
  1152. package/dist/template/packages/cli/LICENSE +202 -0
  1153. package/dist/template/packages/cli/README.md +63 -0
  1154. package/dist/template/packages/cli/package.json +29 -0
  1155. package/dist/template/packages/cli/src/index.ts +355 -0
  1156. package/dist/template/packages/cli/tsconfig.json +15 -0
  1157. package/dist/template/packages/create-freeholder/LICENSE +202 -0
  1158. package/dist/template/packages/create-freeholder/README.md +31 -0
  1159. package/dist/template/packages/create-freeholder/package.json +29 -0
  1160. package/dist/template/packages/create-freeholder/scripts/build.mjs +151 -0
  1161. package/dist/template/packages/create-freeholder/src/index.ts +789 -0
  1162. package/dist/template/packages/create-freeholder/tsconfig.json +15 -0
  1163. package/dist/template/packages/freeholder-app/LICENSE +202 -0
  1164. package/dist/template/packages/freeholder-app/README.md +72 -0
  1165. package/dist/template/packages/freeholder-app/package.json +29 -0
  1166. package/dist/template/packages/freeholder-app/src/assets.ts +320 -0
  1167. package/dist/template/packages/freeholder-app/src/branding.ts +134 -0
  1168. package/dist/template/packages/freeholder-app/src/config.ts +163 -0
  1169. package/dist/template/packages/freeholder-app/src/index.ts +158 -0
  1170. package/dist/template/packages/freeholder-app/src/init.ts +230 -0
  1171. package/dist/template/packages/freeholder-app/src/png.ts +214 -0
  1172. package/dist/template/packages/freeholder-app/tsconfig.json +15 -0
  1173. package/dist/template/packages/mobile-app/LICENSE +202 -0
  1174. package/dist/template/packages/mobile-app/README.md +137 -0
  1175. package/dist/template/packages/mobile-app/package.json +34 -0
  1176. package/dist/template/packages/mobile-app/src/branding.ts +91 -0
  1177. package/dist/template/packages/mobile-app/src/cached-discovery.ts +36 -0
  1178. package/dist/template/packages/mobile-app/src/capture-batches.ts +558 -0
  1179. package/dist/template/packages/mobile-app/src/capture.ts +262 -0
  1180. package/dist/template/packages/mobile-app/src/deep-links.ts +246 -0
  1181. package/dist/template/packages/mobile-app/src/discovery.ts +195 -0
  1182. package/dist/template/packages/mobile-app/src/format.ts +10 -0
  1183. package/dist/template/packages/mobile-app/src/index.ts +122 -0
  1184. package/dist/template/packages/mobile-app/src/messages.generated.ts +677 -0
  1185. package/dist/template/packages/mobile-app/src/offline.ts +183 -0
  1186. package/dist/template/packages/mobile-app/src/private-cache.ts +113 -0
  1187. package/dist/template/packages/mobile-app/src/screens.ts +411 -0
  1188. package/dist/template/packages/mobile-app/src/session.ts +317 -0
  1189. package/dist/template/packages/mobile-app/src/strings.ts +11 -0
  1190. package/dist/template/packages/mobile-app/src/transport.ts +50 -0
  1191. package/dist/template/packages/mobile-app/tsconfig.json +15 -0
  1192. package/dist/template/packages/plugin-kit/LICENSE +202 -0
  1193. package/dist/template/packages/plugin-kit/README.md +11 -0
  1194. package/dist/template/packages/plugin-kit/package.json +37 -0
  1195. package/dist/template/packages/plugin-kit/src/contract.ts +169 -0
  1196. package/dist/template/packages/plugin-kit/src/harness.ts +40 -0
  1197. package/dist/template/packages/plugin-kit/src/importer.ts +37 -0
  1198. package/dist/template/packages/plugin-kit/src/index.ts +41 -0
  1199. package/dist/template/packages/plugin-kit/src/scaffold.ts +54 -0
  1200. package/dist/template/packages/plugin-kit/src/semver.ts +78 -0
  1201. package/dist/template/packages/plugin-kit/tsconfig.json +15 -0
  1202. package/dist/template/packages/sdk/LICENSE +202 -0
  1203. package/dist/template/packages/sdk/README.md +38 -0
  1204. package/dist/template/packages/sdk/package.json +37 -0
  1205. package/dist/template/packages/sdk/src/generated.ts +8557 -0
  1206. package/dist/template/packages/sdk/src/index.ts +178 -0
  1207. package/dist/template/packages/sdk/src/version.ts +4 -0
  1208. package/dist/template/packages/sdk/test/generated.test.mjs +20 -0
  1209. package/dist/template/packages/sdk/tsconfig.json +15 -0
  1210. package/dist/template/packages/templates/LICENSE +202 -0
  1211. package/dist/template/packages/templates/README.md +17 -0
  1212. package/dist/template/packages/templates/package.json +37 -0
  1213. package/dist/template/packages/templates/src/presets.ts +377 -0
  1214. package/dist/template/packages/templates/tsconfig.json +14 -0
  1215. package/dist/template/playwright.a11y.config.ts +109 -0
  1216. package/dist/template/plugins/community/manifest.ts +19 -0
  1217. package/dist/template/plugins/community/plugin.json +10 -0
  1218. package/dist/template/plugins/community/schema.ts +116 -0
  1219. package/dist/template/plugins/community/service.ts +996 -0
  1220. package/dist/template/plugins/community/tables.ts +9 -0
  1221. package/dist/template/plugins/gift-registry/manifest.ts +16 -0
  1222. package/dist/template/plugins/gift-registry/plugin.json +10 -0
  1223. package/dist/template/plugins/gift-registry/schema.ts +44 -0
  1224. package/dist/template/plugins/gift-registry/service.ts +347 -0
  1225. package/dist/template/plugins/gift-registry/tables.ts +3 -0
  1226. package/dist/template/plugins/marketplace/adapter.ts +159 -0
  1227. package/dist/template/plugins/marketplace/jobs.ts +37 -0
  1228. package/dist/template/plugins/marketplace/manifest.ts +20 -0
  1229. package/dist/template/plugins/marketplace/plugin.json +10 -0
  1230. package/dist/template/plugins/marketplace/schema.ts +75 -0
  1231. package/dist/template/plugins/marketplace/service.ts +642 -0
  1232. package/dist/template/plugins/marketplace/shopify.ts +174 -0
  1233. package/dist/template/plugins/marketplace/tables.ts +3 -0
  1234. package/dist/template/plugins/print-on-demand/adapter.ts +86 -0
  1235. package/dist/template/plugins/print-on-demand/jobs.ts +29 -0
  1236. package/dist/template/plugins/print-on-demand/manifest.ts +21 -0
  1237. package/dist/template/plugins/print-on-demand/plugin.json +10 -0
  1238. package/dist/template/plugins/print-on-demand/printify.ts +139 -0
  1239. package/dist/template/plugins/print-on-demand/schema.ts +54 -0
  1240. package/dist/template/plugins/print-on-demand/service.ts +531 -0
  1241. package/dist/template/plugins/print-on-demand/tables.ts +3 -0
  1242. package/dist/template/plugins/social-fixture/adapter.ts +35 -0
  1243. package/dist/template/plugins/social-fixture/manifest.ts +18 -0
  1244. package/dist/template/plugins/social-fixture/plugin.json +10 -0
  1245. package/dist/template/plugins/social-fixture/service.ts +9 -0
  1246. package/dist/template/plugins/voice-video/adapter.ts +183 -0
  1247. package/dist/template/plugins/voice-video/daily.ts +262 -0
  1248. package/dist/template/plugins/voice-video/erasure.ts +93 -0
  1249. package/dist/template/plugins/voice-video/jobs.ts +79 -0
  1250. package/dist/template/plugins/voice-video/manifest.ts +34 -0
  1251. package/dist/template/plugins/voice-video/paradise-provider.ts +157 -0
  1252. package/dist/template/plugins/voice-video/paradise.ts +325 -0
  1253. package/dist/template/plugins/voice-video/plugin.json +10 -0
  1254. package/dist/template/plugins/voice-video/schema.ts +105 -0
  1255. package/dist/template/plugins/voice-video/service.ts +1019 -0
  1256. package/dist/template/plugins/voice-video/settings.ts +128 -0
  1257. package/dist/template/plugins/voice-video/tables.ts +3 -0
  1258. package/dist/template/plugins/voice-video/webhook.ts +134 -0
  1259. package/dist/template/pnpm-lock.yaml +5386 -0
  1260. package/dist/template/pnpm-workspace.yaml +81 -0
  1261. package/dist/template/postcss.config.mjs +7 -0
  1262. package/dist/template/proxy.ts +284 -0
  1263. package/dist/template/public/fonts/OFL-JetBrains-Mono.txt +93 -0
  1264. package/dist/template/public/fonts/OFL-Schibsted-Grotesk.txt +93 -0
  1265. package/dist/template/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  1266. package/dist/template/public/fonts/jetbrains-mono-latin.woff2 +0 -0
  1267. package/dist/template/public/fonts/schibsted-grotesk-latin-ext.woff2 +0 -0
  1268. package/dist/template/public/fonts/schibsted-grotesk-latin.woff2 +0 -0
  1269. package/dist/template/render.yaml +46 -0
  1270. package/dist/template/replit.nix +9 -0
  1271. package/dist/template/scripts/README.md +69 -0
  1272. package/dist/template/scripts/a11y-smoke.d.mts +24 -0
  1273. package/dist/template/scripts/a11y-smoke.mjs +163 -0
  1274. package/dist/template/scripts/changelog-gate.mjs +63 -0
  1275. package/dist/template/scripts/contract-evidence.d.mts +8 -0
  1276. package/dist/template/scripts/contract-evidence.mjs +18 -0
  1277. package/dist/template/scripts/dependency-audit.d.mts +18 -0
  1278. package/dist/template/scripts/dependency-audit.mjs +315 -0
  1279. package/dist/template/scripts/deploy-droplet-remote.sh +138 -0
  1280. package/dist/template/scripts/deploy-droplet.d.mts +59 -0
  1281. package/dist/template/scripts/deploy-droplet.mjs +322 -0
  1282. package/dist/template/scripts/docker-updater.py +524 -0
  1283. package/dist/template/scripts/doctor.d.mts +3 -0
  1284. package/dist/template/scripts/doctor.mjs +199 -0
  1285. package/dist/template/scripts/f-matrix.d.mts +53 -0
  1286. package/dist/template/scripts/f-matrix.mjs +298 -0
  1287. package/dist/template/scripts/fast-gates.mjs +128 -0
  1288. package/dist/template/scripts/generate-changelog.d.mts +16 -0
  1289. package/dist/template/scripts/generate-changelog.mjs +95 -0
  1290. package/dist/template/scripts/generate-mobile-messages.mjs +12 -0
  1291. package/dist/template/scripts/generate-sdk.mjs +54 -0
  1292. package/dist/template/scripts/host-updater.py +365 -0
  1293. package/dist/template/scripts/launch-prepare.d.mts +14 -0
  1294. package/dist/template/scripts/launch-prepare.mjs +93 -0
  1295. package/dist/template/scripts/license-headers.mjs +169 -0
  1296. package/dist/template/scripts/media-transfer.d.mts +19 -0
  1297. package/dist/template/scripts/media-transfer.mjs +144 -0
  1298. package/dist/template/scripts/mobile-store-gate.d.mts +72 -0
  1299. package/dist/template/scripts/mobile-store-gate.mjs +569 -0
  1300. package/dist/template/scripts/owner-password.mjs +107 -0
  1301. package/dist/template/scripts/ownership-drill.d.mts +20 -0
  1302. package/dist/template/scripts/ownership-drill.mjs +237 -0
  1303. package/dist/template/scripts/ownership-export.mjs +46 -0
  1304. package/dist/template/scripts/package-artifact-gate.mjs +291 -0
  1305. package/dist/template/scripts/performance-budgets.d.mts +53 -0
  1306. package/dist/template/scripts/performance-budgets.mjs +311 -0
  1307. package/dist/template/scripts/plan-gate.d.mts +38 -0
  1308. package/dist/template/scripts/plan-gate.mjs +515 -0
  1309. package/dist/template/scripts/playground-gate.sh +47 -0
  1310. package/dist/template/scripts/prepare-do-app-spec.d.mts +6 -0
  1311. package/dist/template/scripts/prepare-do-app-spec.mjs +70 -0
  1312. package/dist/template/scripts/public-gates.sh +186 -0
  1313. package/dist/template/scripts/recipe-matrix.sh +141 -0
  1314. package/dist/template/scripts/recipe-update-actions.mjs +157 -0
  1315. package/dist/template/scripts/release-feed.d.mts +49 -0
  1316. package/dist/template/scripts/release-feed.mjs +215 -0
  1317. package/dist/template/scripts/release-history.d.mts +3 -0
  1318. package/dist/template/scripts/release-history.mjs +27 -0
  1319. package/dist/template/scripts/release-packages.d.mts +13 -0
  1320. package/dist/template/scripts/release-packages.mjs +153 -0
  1321. package/dist/template/scripts/release-publication.d.mts +7 -0
  1322. package/dist/template/scripts/release-publication.mjs +58 -0
  1323. package/dist/template/scripts/resolve-append-conflicts.mjs +132 -0
  1324. package/dist/template/scripts/runtime-balanced-sequencer.ts +178 -0
  1325. package/dist/template/scripts/schema-baseline-identity.d.mts +35 -0
  1326. package/dist/template/scripts/schema-baseline-identity.mjs +373 -0
  1327. package/dist/template/scripts/schema-compat-gate.d.mts +44 -0
  1328. package/dist/template/scripts/schema-compat-gate.mjs +264 -0
  1329. package/dist/template/scripts/seo-gate.d.mts +31 -0
  1330. package/dist/template/scripts/seo-gate.mjs +326 -0
  1331. package/dist/template/scripts/standalone-artifact-gate.mjs +163 -0
  1332. package/dist/template/scripts/start-browser-server.mjs +29 -0
  1333. package/dist/template/scripts/start-replit.mjs +16 -0
  1334. package/dist/template/scripts/start.mjs +7 -0
  1335. package/dist/template/scripts/upgrade-gate.sh +134 -0
  1336. package/dist/template/scripts/verify-dependency-attestation.d.mts +13 -0
  1337. package/dist/template/scripts/verify-dependency-attestation.mjs +93 -0
  1338. package/dist/template/scripts/workflow-integrity-gate.d.mts +6 -0
  1339. package/dist/template/scripts/workflow-integrity-gate.mjs +190 -0
  1340. package/dist/template/security/adversarial-audit-2026-10-08.md +111 -0
  1341. package/dist/template/security/client-readiness-audit-2026-09-21.md +273 -0
  1342. package/dist/template/security/dependency-audit-exceptions.json +3 -0
  1343. package/dist/template/security/independent-review-packet.md +369 -0
  1344. package/dist/template/security/project-audit-2026-09-13.md +127 -0
  1345. package/dist/template/seed/README.md +86 -0
  1346. package/dist/template/seed/demo/content.ts +812 -0
  1347. package/dist/template/src/README.md +19 -0
  1348. package/dist/template/src/adapters/agent/index.ts +35 -0
  1349. package/dist/template/src/adapters/agent/pm-brain.ts +125 -0
  1350. package/dist/template/src/adapters/agent/types.ts +39 -0
  1351. package/dist/template/src/adapters/agent/workforce-anthropic.ts +191 -0
  1352. package/dist/template/src/adapters/agent/workforce-openai.ts +182 -0
  1353. package/dist/template/src/adapters/agent/workforce-types.ts +80 -0
  1354. package/dist/template/src/adapters/agent/workforce.ts +93 -0
  1355. package/dist/template/src/adapters/ai/anthropic.ts +176 -0
  1356. package/dist/template/src/adapters/ai/index.ts +41 -0
  1357. package/dist/template/src/adapters/ai/none.ts +14 -0
  1358. package/dist/template/src/adapters/ai/openai.ts +132 -0
  1359. package/dist/template/src/adapters/ai/types.ts +28 -0
  1360. package/dist/template/src/adapters/alt-text/index.ts +77 -0
  1361. package/dist/template/src/adapters/alt-text/openai.ts +143 -0
  1362. package/dist/template/src/adapters/alt-text/types.ts +30 -0
  1363. package/dist/template/src/adapters/calendar/index.ts +12 -0
  1364. package/dist/template/src/adapters/calendar/none.ts +18 -0
  1365. package/dist/template/src/adapters/calendar/types.ts +43 -0
  1366. package/dist/template/src/adapters/carrier/index.ts +12 -0
  1367. package/dist/template/src/adapters/carrier/none.ts +18 -0
  1368. package/dist/template/src/adapters/carrier/types.ts +60 -0
  1369. package/dist/template/src/adapters/git/github.ts +82 -0
  1370. package/dist/template/src/adapters/mail/console.ts +46 -0
  1371. package/dist/template/src/adapters/mail/gmail.ts +44 -0
  1372. package/dist/template/src/adapters/mail/http.ts +88 -0
  1373. package/dist/template/src/adapters/mail/index.ts +255 -0
  1374. package/dist/template/src/adapters/mail/mime.ts +57 -0
  1375. package/dist/template/src/adapters/mail/none.ts +18 -0
  1376. package/dist/template/src/adapters/mail/outlook.ts +71 -0
  1377. package/dist/template/src/adapters/mail/postmark.ts +105 -0
  1378. package/dist/template/src/adapters/mail/resend.ts +86 -0
  1379. package/dist/template/src/adapters/mail/ses.ts +114 -0
  1380. package/dist/template/src/adapters/mail/smtp.ts +85 -0
  1381. package/dist/template/src/adapters/mail/types.ts +79 -0
  1382. package/dist/template/src/adapters/malware/clamav.ts +90 -0
  1383. package/dist/template/src/adapters/malware/index.ts +43 -0
  1384. package/dist/template/src/adapters/malware/none.ts +16 -0
  1385. package/dist/template/src/adapters/malware/types.ts +28 -0
  1386. package/dist/template/src/adapters/notifications/index.ts +27 -0
  1387. package/dist/template/src/adapters/notifications/none.ts +27 -0
  1388. package/dist/template/src/adapters/notifications/types.ts +36 -0
  1389. package/dist/template/src/adapters/payments/currency.ts +50 -0
  1390. package/dist/template/src/adapters/payments/flutterwave.ts +239 -0
  1391. package/dist/template/src/adapters/payments/http.ts +82 -0
  1392. package/dist/template/src/adapters/payments/index.ts +42 -0
  1393. package/dist/template/src/adapters/payments/manual.ts +59 -0
  1394. package/dist/template/src/adapters/payments/mollie.ts +239 -0
  1395. package/dist/template/src/adapters/payments/none.ts +38 -0
  1396. package/dist/template/src/adapters/payments/paypal.ts +518 -0
  1397. package/dist/template/src/adapters/payments/paystack.ts +206 -0
  1398. package/dist/template/src/adapters/payments/provider-helpers.ts +122 -0
  1399. package/dist/template/src/adapters/payments/providers.ts +31 -0
  1400. package/dist/template/src/adapters/payments/razorpay.ts +246 -0
  1401. package/dist/template/src/adapters/payments/square.ts +251 -0
  1402. package/dist/template/src/adapters/payments/stripe.ts +462 -0
  1403. package/dist/template/src/adapters/payments/types.ts +244 -0
  1404. package/dist/template/src/adapters/point-of-sale/index.ts +21 -0
  1405. package/dist/template/src/adapters/point-of-sale/manual.ts +35 -0
  1406. package/dist/template/src/adapters/point-of-sale/none.ts +18 -0
  1407. package/dist/template/src/adapters/point-of-sale/stripe.ts +112 -0
  1408. package/dist/template/src/adapters/point-of-sale/types.ts +43 -0
  1409. package/dist/template/src/adapters/registry.ts +46 -0
  1410. package/dist/template/src/adapters/sms/index.ts +30 -0
  1411. package/dist/template/src/adapters/sms/none.ts +24 -0
  1412. package/dist/template/src/adapters/sms/twilio.ts +410 -0
  1413. package/dist/template/src/adapters/sms/types.ts +140 -0
  1414. package/dist/template/src/adapters/social/factory.ts +370 -0
  1415. package/dist/template/src/adapters/social/http.ts +109 -0
  1416. package/dist/template/src/adapters/social/index.ts +15 -0
  1417. package/dist/template/src/adapters/social/media.ts +53 -0
  1418. package/dist/template/src/adapters/social/networks.ts +174 -0
  1419. package/dist/template/src/adapters/social/none.ts +37 -0
  1420. package/dist/template/src/adapters/social/types.ts +130 -0
  1421. package/dist/template/src/adapters/storage/index.ts +82 -0
  1422. package/dist/template/src/adapters/storage/local.ts +164 -0
  1423. package/dist/template/src/adapters/storage/replit.ts +114 -0
  1424. package/dist/template/src/adapters/storage/s3.ts +298 -0
  1425. package/dist/template/src/adapters/storage/types.ts +138 -0
  1426. package/dist/template/src/adapters/tax/index.ts +10 -0
  1427. package/dist/template/src/adapters/tax/none.ts +14 -0
  1428. package/dist/template/src/adapters/tax/types.ts +60 -0
  1429. package/dist/template/src/adapters/types.ts +60 -0
  1430. package/dist/template/src/core/agents/budget-alerts.ts +73 -0
  1431. package/dist/template/src/core/agents/budget.ts +162 -0
  1432. package/dist/template/src/core/agents/cron.ts +77 -0
  1433. package/dist/template/src/core/agents/envelope.ts +68 -0
  1434. package/dist/template/src/core/agents/execution.ts +639 -0
  1435. package/dist/template/src/core/agents/managed.ts +586 -0
  1436. package/dist/template/src/core/agents/playbook-events.ts +77 -0
  1437. package/dist/template/src/core/agents/playbook-params.ts +121 -0
  1438. package/dist/template/src/core/agents/playbook-schedule.ts +305 -0
  1439. package/dist/template/src/core/agents/playbooks.ts +579 -0
  1440. package/dist/template/src/core/agents/previews.ts +86 -0
  1441. package/dist/template/src/core/agents/pricing.ts +111 -0
  1442. package/dist/template/src/core/agents/schema.ts +329 -0
  1443. package/dist/template/src/core/agents/service.ts +1382 -0
  1444. package/dist/template/src/core/agents/writes.ts +407 -0
  1445. package/dist/template/src/core/api/dispatch.ts +131 -0
  1446. package/dist/template/src/core/api/openapi.ts +246 -0
  1447. package/dist/template/src/core/apikeys/profiles.ts +24 -0
  1448. package/dist/template/src/core/apikeys/schema.ts +87 -0
  1449. package/dist/template/src/core/apikeys/service.ts +245 -0
  1450. package/dist/template/src/core/apikeys/tokens.ts +130 -0
  1451. package/dist/template/src/core/attestations/schema.ts +118 -0
  1452. package/dist/template/src/core/attestations/service.ts +354 -0
  1453. package/dist/template/src/core/auth/bootstrap.ts +22 -0
  1454. package/dist/template/src/core/auth/magic-links/service.ts +272 -0
  1455. package/dist/template/src/core/auth/passwords.ts +52 -0
  1456. package/dist/template/src/core/auth/reset.ts +238 -0
  1457. package/dist/template/src/core/auth/schema.ts +318 -0
  1458. package/dist/template/src/core/auth/service.ts +345 -0
  1459. package/dist/template/src/core/auth/session-management/service.ts +314 -0
  1460. package/dist/template/src/core/auth/sessions.ts +280 -0
  1461. package/dist/template/src/core/auth/two-factor-crypto.ts +172 -0
  1462. package/dist/template/src/core/auth/two-factor.ts +863 -0
  1463. package/dist/template/src/core/automations/core-verbs.ts +86 -0
  1464. package/dist/template/src/core/automations/verbs.ts +121 -0
  1465. package/dist/template/src/core/boot.ts +231 -0
  1466. package/dist/template/src/core/briefing/contributors.ts +288 -0
  1467. package/dist/template/src/core/briefing/playbook-section.ts +136 -0
  1468. package/dist/template/src/core/briefing/registry.ts +155 -0
  1469. package/dist/template/src/core/briefing/schema.ts +124 -0
  1470. package/dist/template/src/core/briefing/service.ts +425 -0
  1471. package/dist/template/src/core/briefing/update.ts +24 -0
  1472. package/dist/template/src/core/catalogue/schema.ts +136 -0
  1473. package/dist/template/src/core/catalogue/service.ts +724 -0
  1474. package/dist/template/src/core/config.test.ts +62 -0
  1475. package/dist/template/src/core/config.ts +69 -0
  1476. package/dist/template/src/core/connections/busy.ts +190 -0
  1477. package/dist/template/src/core/connections/calendar-oauth.ts +323 -0
  1478. package/dist/template/src/core/connections/calendar-providers.ts +352 -0
  1479. package/dist/template/src/core/connections/calendar-sync.ts +558 -0
  1480. package/dist/template/src/core/connections/calendar-write.ts +194 -0
  1481. package/dist/template/src/core/connections/crypto.ts +200 -0
  1482. package/dist/template/src/core/connections/grants.ts +322 -0
  1483. package/dist/template/src/core/connections/mail-import.ts +380 -0
  1484. package/dist/template/src/core/connections/mail-providers.ts +184 -0
  1485. package/dist/template/src/core/connections/mail-read-oauth.ts +296 -0
  1486. package/dist/template/src/core/connections/oauth-core.ts +472 -0
  1487. package/dist/template/src/core/connections/schema.ts +250 -0
  1488. package/dist/template/src/core/connections/service.ts +606 -0
  1489. package/dist/template/src/core/contacts/custom-fields.ts +287 -0
  1490. package/dist/template/src/core/contacts/duplicates.ts +359 -0
  1491. package/dist/template/src/core/contacts/funnel.ts +30 -0
  1492. package/dist/template/src/core/contacts/lifecycle.ts +91 -0
  1493. package/dist/template/src/core/contacts/organizations.ts +214 -0
  1494. package/dist/template/src/core/contacts/relationships.ts +477 -0
  1495. package/dist/template/src/core/contacts/schema.ts +300 -0
  1496. package/dist/template/src/core/contacts/service.ts +1401 -0
  1497. package/dist/template/src/core/contract/json-schema.ts +39 -0
  1498. package/dist/template/src/core/contract/projections.ts +58 -0
  1499. package/dist/template/src/core/contract/sdk.ts +287 -0
  1500. package/dist/template/src/core/contract.ts +20 -0
  1501. package/dist/template/src/core/contribute/deliver.ts +274 -0
  1502. package/dist/template/src/core/contribute/schema.ts +163 -0
  1503. package/dist/template/src/core/contribute/service.ts +1072 -0
  1504. package/dist/template/src/core/dates/cadence.ts +73 -0
  1505. package/dist/template/src/core/db/columns.ts +32 -0
  1506. package/dist/template/src/core/db/errors.ts +66 -0
  1507. package/dist/template/src/core/db/index.ts +90 -0
  1508. package/dist/template/src/core/demo/fixtures.ts +441 -0
  1509. package/dist/template/src/core/demo/handler.ts +89 -0
  1510. package/dist/template/src/core/demo/playground-policy.ts +73 -0
  1511. package/dist/template/src/core/demo/playground.ts +55 -0
  1512. package/dist/template/src/core/demo/schema.ts +135 -0
  1513. package/dist/template/src/core/demo/service.ts +673 -0
  1514. package/dist/template/src/core/design/read.ts +9 -0
  1515. package/dist/template/src/core/design/schema.ts +33 -0
  1516. package/dist/template/src/core/design/service.ts +280 -0
  1517. package/dist/template/src/core/design/theme.ts +45 -0
  1518. package/dist/template/src/core/design/tokens.ts +355 -0
  1519. package/dist/template/src/core/discovery.ts +116 -0
  1520. package/dist/template/src/core/doctor/index.ts +1169 -0
  1521. package/dist/template/src/core/doctor/service.ts +44 -0
  1522. package/dist/template/src/core/entitlements/access.ts +478 -0
  1523. package/dist/template/src/core/entitlements/schema.ts +163 -0
  1524. package/dist/template/src/core/entitlements/service.ts +590 -0
  1525. package/dist/template/src/core/env.test.ts +148 -0
  1526. package/dist/template/src/core/env.ts +442 -0
  1527. package/dist/template/src/core/events/catalogue.ts +61 -0
  1528. package/dist/template/src/core/events/index.ts +138 -0
  1529. package/dist/template/src/core/events/outbox-service.ts +198 -0
  1530. package/dist/template/src/core/events/outbox.ts +474 -0
  1531. package/dist/template/src/core/events/schema.ts +152 -0
  1532. package/dist/template/src/core/events/service.ts +37 -0
  1533. package/dist/template/src/core/funnel/stages.ts +106 -0
  1534. package/dist/template/src/core/guidance/definitions.ts +276 -0
  1535. package/dist/template/src/core/guidance/schema.ts +107 -0
  1536. package/dist/template/src/core/guidance/service.ts +530 -0
  1537. package/dist/template/src/core/http/actor.ts +115 -0
  1538. package/dist/template/src/core/http/body.ts +96 -0
  1539. package/dist/template/src/core/http/cookies.ts +88 -0
  1540. package/dist/template/src/core/http/csp.ts +118 -0
  1541. package/dist/template/src/core/http/csrf.ts +89 -0
  1542. package/dist/template/src/core/http/headers.ts +33 -0
  1543. package/dist/template/src/core/http/inline-json.ts +20 -0
  1544. package/dist/template/src/core/http/pinned-download.ts +118 -0
  1545. package/dist/template/src/core/http/request-metadata.ts +48 -0
  1546. package/dist/template/src/core/http/respond.ts +82 -0
  1547. package/dist/template/src/core/http/route.ts +83 -0
  1548. package/dist/template/src/core/i18n/customer.ts +187 -0
  1549. package/dist/template/src/core/i18n/index.ts +286 -0
  1550. package/dist/template/src/core/i18n/schema.ts +59 -0
  1551. package/dist/template/src/core/i18n/service.ts +339 -0
  1552. package/dist/template/src/core/i18n/zoned.ts +96 -0
  1553. package/dist/template/src/core/ics.ts +260 -0
  1554. package/dist/template/src/core/import/contacts-schema.ts +237 -0
  1555. package/dist/template/src/core/import/contacts-service.ts +923 -0
  1556. package/dist/template/src/core/import/contract.ts +135 -0
  1557. package/dist/template/src/core/import/csv.ts +190 -0
  1558. package/dist/template/src/core/import/parsers.ts +217 -0
  1559. package/dist/template/src/core/import/service.ts +606 -0
  1560. package/dist/template/src/core/import/signup-contact-providers.ts +219 -0
  1561. package/dist/template/src/core/import/signup-contact-service.ts +1077 -0
  1562. package/dist/template/src/core/import/vcard.ts +77 -0
  1563. package/dist/template/src/core/invitations/service.ts +656 -0
  1564. package/dist/template/src/core/jobs/core-jobs.ts +1000 -0
  1565. package/dist/template/src/core/jobs/health.ts +264 -0
  1566. package/dist/template/src/core/jobs/index.ts +926 -0
  1567. package/dist/template/src/core/jobs/schema.ts +111 -0
  1568. package/dist/template/src/core/jobs/service.ts +269 -0
  1569. package/dist/template/src/core/locations/coverage.ts +152 -0
  1570. package/dist/template/src/core/locations/jsonld.ts +155 -0
  1571. package/dist/template/src/core/locations/nap.ts +159 -0
  1572. package/dist/template/src/core/locations/read.ts +15 -0
  1573. package/dist/template/src/core/locations/schema.ts +257 -0
  1574. package/dist/template/src/core/locations/service.ts +667 -0
  1575. package/dist/template/src/core/mail/link-confirmation.ts +31 -0
  1576. package/dist/template/src/core/mail/oauth.ts +351 -0
  1577. package/dist/template/src/core/mail/outbox-crypto.ts +73 -0
  1578. package/dist/template/src/core/mail/route.ts +27 -0
  1579. package/dist/template/src/core/mail/schema.ts +359 -0
  1580. package/dist/template/src/core/mail/service.ts +1407 -0
  1581. package/dist/template/src/core/mail/webhooks.ts +735 -0
  1582. package/dist/template/src/core/manifest.ts +173 -0
  1583. package/dist/template/src/core/media/capture.ts +1191 -0
  1584. package/dist/template/src/core/media/framing.ts +265 -0
  1585. package/dist/template/src/core/media/schema.ts +388 -0
  1586. package/dist/template/src/core/media/service.ts +3321 -0
  1587. package/dist/template/src/core/media/validation.ts +264 -0
  1588. package/dist/template/src/core/media/variants.ts +213 -0
  1589. package/dist/template/src/core/media/watermark.ts +158 -0
  1590. package/dist/template/src/core/messaging/chat-cookie.ts +30 -0
  1591. package/dist/template/src/core/messaging/chat.ts +424 -0
  1592. package/dist/template/src/core/messaging/consent.ts +390 -0
  1593. package/dist/template/src/core/messaging/inbox.ts +602 -0
  1594. package/dist/template/src/core/messaging/keywords.ts +540 -0
  1595. package/dist/template/src/core/messaging/numbers-schema.ts +126 -0
  1596. package/dist/template/src/core/messaging/policy-schema.ts +84 -0
  1597. package/dist/template/src/core/messaging/policy.ts +575 -0
  1598. package/dist/template/src/core/messaging/portal.ts +30 -0
  1599. package/dist/template/src/core/messaging/purpose.ts +12 -0
  1600. package/dist/template/src/core/messaging/registration.ts +235 -0
  1601. package/dist/template/src/core/messaging/schema.ts +433 -0
  1602. package/dist/template/src/core/messaging/service.ts +805 -0
  1603. package/dist/template/src/core/messaging/sms.ts +1052 -0
  1604. package/dist/template/src/core/messaging/webhook-route.ts +118 -0
  1605. package/dist/template/src/core/migrate.ts +57 -0
  1606. package/dist/template/src/core/module.ts +105 -0
  1607. package/dist/template/src/core/notes/schema.ts +140 -0
  1608. package/dist/template/src/core/notes/service.ts +513 -0
  1609. package/dist/template/src/core/notifications/devices.ts +149 -0
  1610. package/dist/template/src/core/notifications/schema.ts +389 -0
  1611. package/dist/template/src/core/notifications/service.ts +1863 -0
  1612. package/dist/template/src/core/onboarding/contract.ts +130 -0
  1613. package/dist/template/src/core/onboarding/index.ts +213 -0
  1614. package/dist/template/src/core/onboarding/registry.ts +295 -0
  1615. package/dist/template/src/core/paywalls/evaluate.ts +266 -0
  1616. package/dist/template/src/core/paywalls/schema.ts +105 -0
  1617. package/dist/template/src/core/paywalls/service.ts +223 -0
  1618. package/dist/template/src/core/platform.ts +19 -0
  1619. package/dist/template/src/core/plugin.ts +68 -0
  1620. package/dist/template/src/core/plugins/integrity.ts +51 -0
  1621. package/dist/template/src/core/plugins/isolate.ts +49 -0
  1622. package/dist/template/src/core/plugins/registry.ts +70 -0
  1623. package/dist/template/src/core/plugins/schema.ts +96 -0
  1624. package/dist/template/src/core/plugins/service.ts +472 -0
  1625. package/dist/template/src/core/plugins/spine.ts +172 -0
  1626. package/dist/template/src/core/portability/archive.ts +77 -0
  1627. package/dist/template/src/core/portability/ownership-export.d.mts +56 -0
  1628. package/dist/template/src/core/portability/ownership-export.mjs +548 -0
  1629. package/dist/template/src/core/portability/service.ts +119 -0
  1630. package/dist/template/src/core/portal/record-service.ts +38 -0
  1631. package/dist/template/src/core/portal/return-path.ts +9 -0
  1632. package/dist/template/src/core/portal/sections.ts +101 -0
  1633. package/dist/template/src/core/portal/service.ts +202 -0
  1634. package/dist/template/src/core/portal/sign-in.ts +30 -0
  1635. package/dist/template/src/core/privacy/media-consent.ts +328 -0
  1636. package/dist/template/src/core/privacy/publish-veto.ts +59 -0
  1637. package/dist/template/src/core/privacy/schema.ts +320 -0
  1638. package/dist/template/src/core/privacy/service.ts +1935 -0
  1639. package/dist/template/src/core/provenance/service.ts +174 -0
  1640. package/dist/template/src/core/recipes.ts +15 -0
  1641. package/dist/template/src/core/reporting/csv.ts +102 -0
  1642. package/dist/template/src/core/reporting/dimensions.ts +114 -0
  1643. package/dist/template/src/core/retention/apply.ts +47 -0
  1644. package/dist/template/src/core/retention/holds.ts +45 -0
  1645. package/dist/template/src/core/retention/registry.ts +190 -0
  1646. package/dist/template/src/core/retention/schema.ts +34 -0
  1647. package/dist/template/src/core/retention/service.ts +109 -0
  1648. package/dist/template/src/core/retention/sources.ts +42 -0
  1649. package/dist/template/src/core/rewards/issue.ts +100 -0
  1650. package/dist/template/src/core/roles/defaults.ts +161 -0
  1651. package/dist/template/src/core/roles/service.ts +375 -0
  1652. package/dist/template/src/core/runs/schema.ts +290 -0
  1653. package/dist/template/src/core/runs/spine.ts +72 -0
  1654. package/dist/template/src/core/runtime/shutdown.ts +55 -0
  1655. package/dist/template/src/core/runtime.ts +45 -0
  1656. package/dist/template/src/core/scheduling/audience-schema.ts +179 -0
  1657. package/dist/template/src/core/scheduling/audiences.ts +504 -0
  1658. package/dist/template/src/core/scheduling/availability-service.ts +354 -0
  1659. package/dist/template/src/core/scheduling/availability.ts +213 -0
  1660. package/dist/template/src/core/scheduling/bookings.ts +1252 -0
  1661. package/dist/template/src/core/scheduling/funnel.ts +30 -0
  1662. package/dist/template/src/core/scheduling/ics-service.ts +355 -0
  1663. package/dist/template/src/core/scheduling/policy.ts +253 -0
  1664. package/dist/template/src/core/scheduling/portal.ts +50 -0
  1665. package/dist/template/src/core/scheduling/reminders.ts +352 -0
  1666. package/dist/template/src/core/scheduling/requirements.ts +307 -0
  1667. package/dist/template/src/core/scheduling/resolver-service.ts +206 -0
  1668. package/dist/template/src/core/scheduling/resolver.ts +564 -0
  1669. package/dist/template/src/core/scheduling/schema.ts +618 -0
  1670. package/dist/template/src/core/scheduling/service.ts +474 -0
  1671. package/dist/template/src/core/scheduling/waitlist.ts +678 -0
  1672. package/dist/template/src/core/scheduling/writeback.ts +213 -0
  1673. package/dist/template/src/core/scoring/schema.ts +147 -0
  1674. package/dist/template/src/core/scoring/service.ts +602 -0
  1675. package/dist/template/src/core/search/registry.ts +155 -0
  1676. package/dist/template/src/core/search/service.ts +81 -0
  1677. package/dist/template/src/core/search/sources.ts +195 -0
  1678. package/dist/template/src/core/security/csp-reports.ts +256 -0
  1679. package/dist/template/src/core/security/rate-limit.ts +117 -0
  1680. package/dist/template/src/core/security/schema.ts +60 -0
  1681. package/dist/template/src/core/segments/fields.ts +376 -0
  1682. package/dist/template/src/core/segments/schema.ts +112 -0
  1683. package/dist/template/src/core/segments/service.ts +731 -0
  1684. package/dist/template/src/core/seo/classify.ts +56 -0
  1685. package/dist/template/src/core/seo/entities.ts +61 -0
  1686. package/dist/template/src/core/seo/feeds.ts +77 -0
  1687. package/dist/template/src/core/seo/indexnow.ts +110 -0
  1688. package/dist/template/src/core/seo/jsonld.ts +307 -0
  1689. package/dist/template/src/core/seo/meta.ts +84 -0
  1690. package/dist/template/src/core/seo/origin.ts +55 -0
  1691. package/dist/template/src/core/seo/schema.ts +41 -0
  1692. package/dist/template/src/core/seo/service.ts +171 -0
  1693. package/dist/template/src/core/seo/sitemap.ts +185 -0
  1694. package/dist/template/src/core/service.ts +747 -0
  1695. package/dist/template/src/core/services.ts +242 -0
  1696. package/dist/template/src/core/settings/defaults.ts +129 -0
  1697. package/dist/template/src/core/settings/read.ts +24 -0
  1698. package/dist/template/src/core/settings/schema.ts +81 -0
  1699. package/dist/template/src/core/settings/service.ts +407 -0
  1700. package/dist/template/src/core/settings/setup.ts +41 -0
  1701. package/dist/template/src/core/spine/facts.ts +141 -0
  1702. package/dist/template/src/core/subjects.ts +95 -0
  1703. package/dist/template/src/core/tables.ts +180 -0
  1704. package/dist/template/src/core/tasks/schema.ts +174 -0
  1705. package/dist/template/src/core/tasks/service.ts +634 -0
  1706. package/dist/template/src/core/trash.ts +278 -0
  1707. package/dist/template/src/core/update/apply.ts +58 -0
  1708. package/dist/template/src/core/update/catalog.ts +222 -0
  1709. package/dist/template/src/core/update/channels.ts +39 -0
  1710. package/dist/template/src/core/update/check.ts +107 -0
  1711. package/dist/template/src/core/update/escalate-job.ts +111 -0
  1712. package/dist/template/src/core/update/escalation.ts +131 -0
  1713. package/dist/template/src/core/update/feed.ts +80 -0
  1714. package/dist/template/src/core/update/fork-delivery.ts +102 -0
  1715. package/dist/template/src/core/update/fork-merge.ts +195 -0
  1716. package/dist/template/src/core/update/fork.ts +217 -0
  1717. package/dist/template/src/core/update/host.ts +59 -0
  1718. package/dist/template/src/core/update/integrity.ts +118 -0
  1719. package/dist/template/src/core/update/keys.ts +29 -0
  1720. package/dist/template/src/core/update/policy.ts +111 -0
  1721. package/dist/template/src/core/update/preflight.ts +258 -0
  1722. package/dist/template/src/core/update/release-declaration.json +19 -0
  1723. package/dist/template/src/core/update/release-validation.d.mts +5 -0
  1724. package/dist/template/src/core/update/release-validation.mjs +29 -0
  1725. package/dist/template/src/core/update/release-version.d.mts +4 -0
  1726. package/dist/template/src/core/update/release-version.mjs +36 -0
  1727. package/dist/template/src/core/update/release.ts +97 -0
  1728. package/dist/template/src/core/update/schema.ts +172 -0
  1729. package/dist/template/src/core/update/seams.ts +70 -0
  1730. package/dist/template/src/core/update/service.ts +1075 -0
  1731. package/dist/template/src/core/update/targets.ts +425 -0
  1732. package/dist/template/src/core/update/this-release.ts +12 -0
  1733. package/dist/template/src/core/update/trusted-release-keys.json +7 -0
  1734. package/dist/template/src/core/views/entities.ts +48 -0
  1735. package/dist/template/src/core/views/registry.ts +121 -0
  1736. package/dist/template/src/core/views/schema.ts +82 -0
  1737. package/dist/template/src/core/views/service.ts +388 -0
  1738. package/dist/template/src/core/webhooks/address.ts +57 -0
  1739. package/dist/template/src/core/webhooks/deliver.ts +255 -0
  1740. package/dist/template/src/core/webhooks/schema.ts +128 -0
  1741. package/dist/template/src/core/webhooks/service.ts +532 -0
  1742. package/dist/template/src/core/webhooks/sign.ts +169 -0
  1743. package/dist/template/src/core/webhooks/transport.ts +180 -0
  1744. package/dist/template/src/mcp/server.ts +372 -0
  1745. package/dist/template/src/mcp/tools.ts +182 -0
  1746. package/dist/template/src/modules/ads/AdBeacon.tsx +76 -0
  1747. package/dist/template/src/modules/ads/ThirdPartyConsent.tsx +45 -0
  1748. package/dist/template/src/modules/ads/ads-txt.ts +60 -0
  1749. package/dist/template/src/modules/ads/blocks.tsx +246 -0
  1750. package/dist/template/src/modules/ads/clicks.ts +162 -0
  1751. package/dist/template/src/modules/ads/jobs.ts +17 -0
  1752. package/dist/template/src/modules/ads/manifest.ts +48 -0
  1753. package/dist/template/src/modules/ads/pacing.ts +47 -0
  1754. package/dist/template/src/modules/ads/schema.ts +360 -0
  1755. package/dist/template/src/modules/ads/select.ts +235 -0
  1756. package/dist/template/src/modules/ads/service.ts +2082 -0
  1757. package/dist/template/src/modules/ads/stats.ts +209 -0
  1758. package/dist/template/src/modules/ads/tables.ts +13 -0
  1759. package/dist/template/src/modules/ads/tags.ts +98 -0
  1760. package/dist/template/src/modules/ads/targeting.ts +0 -0
  1761. package/dist/template/src/modules/ads/viewability.ts +39 -0
  1762. package/dist/template/src/modules/analytics/classify.ts +128 -0
  1763. package/dist/template/src/modules/analytics/experiments.ts +197 -0
  1764. package/dist/template/src/modules/analytics/funnel-service.ts +201 -0
  1765. package/dist/template/src/modules/analytics/funnel.ts +40 -0
  1766. package/dist/template/src/modules/analytics/manifest.ts +37 -0
  1767. package/dist/template/src/modules/analytics/read.ts +17 -0
  1768. package/dist/template/src/modules/analytics/schema.ts +142 -0
  1769. package/dist/template/src/modules/analytics/service.ts +1380 -0
  1770. package/dist/template/src/modules/analytics/settings.ts +44 -0
  1771. package/dist/template/src/modules/analytics/tables.ts +4 -0
  1772. package/dist/template/src/modules/analytics/visitor.ts +91 -0
  1773. package/dist/template/src/modules/assessments/block.tsx +200 -0
  1774. package/dist/template/src/modules/assessments/blocks.ts +11 -0
  1775. package/dist/template/src/modules/assessments/manifest.ts +27 -0
  1776. package/dist/template/src/modules/assessments/onboarding.ts +45 -0
  1777. package/dist/template/src/modules/assessments/questions.ts +134 -0
  1778. package/dist/template/src/modules/assessments/schema.ts +201 -0
  1779. package/dist/template/src/modules/assessments/scoring.ts +99 -0
  1780. package/dist/template/src/modules/assessments/service.ts +1225 -0
  1781. package/dist/template/src/modules/assessments/tables.ts +9 -0
  1782. package/dist/template/src/modules/assistant/actions.ts +191 -0
  1783. package/dist/template/src/modules/assistant/contract.ts +48 -0
  1784. package/dist/template/src/modules/assistant/corpus.ts +137 -0
  1785. package/dist/template/src/modules/assistant/embed.ts +40 -0
  1786. package/dist/template/src/modules/assistant/guardrails.ts +220 -0
  1787. package/dist/template/src/modules/assistant/jobs.ts +17 -0
  1788. package/dist/template/src/modules/assistant/limits.ts +219 -0
  1789. package/dist/template/src/modules/assistant/manifest.ts +43 -0
  1790. package/dist/template/src/modules/assistant/prompt.ts +168 -0
  1791. package/dist/template/src/modules/assistant/provider.ts +100 -0
  1792. package/dist/template/src/modules/assistant/retrieve.ts +67 -0
  1793. package/dist/template/src/modules/assistant/schema.ts +336 -0
  1794. package/dist/template/src/modules/assistant/service.ts +1276 -0
  1795. package/dist/template/src/modules/assistant/tables.ts +11 -0
  1796. package/dist/template/src/modules/assistant/text.ts +42 -0
  1797. package/dist/template/src/modules/automations/engine.ts +350 -0
  1798. package/dist/template/src/modules/automations/graph.ts +325 -0
  1799. package/dist/template/src/modules/automations/guardrail-service.ts +68 -0
  1800. package/dist/template/src/modules/automations/guardrails.ts +211 -0
  1801. package/dist/template/src/modules/automations/manifest.ts +37 -0
  1802. package/dist/template/src/modules/automations/runtime.ts +771 -0
  1803. package/dist/template/src/modules/automations/schema.ts +192 -0
  1804. package/dist/template/src/modules/automations/service.ts +584 -0
  1805. package/dist/template/src/modules/automations/tables.ts +8 -0
  1806. package/dist/template/src/modules/builder/code-delivery.ts +131 -0
  1807. package/dist/template/src/modules/builder/code-gates.ts +374 -0
  1808. package/dist/template/src/modules/builder/code-service.ts +508 -0
  1809. package/dist/template/src/modules/builder/manifest.ts +14 -0
  1810. package/dist/template/src/modules/builder/schema.ts +135 -0
  1811. package/dist/template/src/modules/builder/service.ts +758 -0
  1812. package/dist/template/src/modules/builder/tables.ts +3 -0
  1813. package/dist/template/src/modules/calculators/formula.ts +197 -0
  1814. package/dist/template/src/modules/calculators/manifest.ts +19 -0
  1815. package/dist/template/src/modules/calculators/schema.ts +65 -0
  1816. package/dist/template/src/modules/calculators/service.ts +455 -0
  1817. package/dist/template/src/modules/calculators/tables.ts +4 -0
  1818. package/dist/template/src/modules/catalog/browse.ts +835 -0
  1819. package/dist/template/src/modules/catalog/cart-access.ts +37 -0
  1820. package/dist/template/src/modules/catalog/cart.ts +1066 -0
  1821. package/dist/template/src/modules/catalog/checkout-policy.ts +80 -0
  1822. package/dist/template/src/modules/catalog/collections.ts +856 -0
  1823. package/dist/template/src/modules/catalog/contract.ts +180 -0
  1824. package/dist/template/src/modules/catalog/cookies.ts +14 -0
  1825. package/dist/template/src/modules/catalog/demo.ts +108 -0
  1826. package/dist/template/src/modules/catalog/fulfillment.ts +978 -0
  1827. package/dist/template/src/modules/catalog/funnel.ts +46 -0
  1828. package/dist/template/src/modules/catalog/inventory.ts +900 -0
  1829. package/dist/template/src/modules/catalog/jobs.ts +74 -0
  1830. package/dist/template/src/modules/catalog/manifest.ts +76 -0
  1831. package/dist/template/src/modules/catalog/merchandising.ts +529 -0
  1832. package/dist/template/src/modules/catalog/offerings.ts +735 -0
  1833. package/dist/template/src/modules/catalog/onboarding.ts +33 -0
  1834. package/dist/template/src/modules/catalog/orders.ts +698 -0
  1835. package/dist/template/src/modules/catalog/portal.ts +36 -0
  1836. package/dist/template/src/modules/catalog/price-breaks.ts +144 -0
  1837. package/dist/template/src/modules/catalog/pricing.ts +590 -0
  1838. package/dist/template/src/modules/catalog/procurement.ts +689 -0
  1839. package/dist/template/src/modules/catalog/promo-quote.ts +53 -0
  1840. package/dist/template/src/modules/catalog/promotions.ts +784 -0
  1841. package/dist/template/src/modules/catalog/public-booking.ts +132 -0
  1842. package/dist/template/src/modules/catalog/public-pages.ts +173 -0
  1843. package/dist/template/src/modules/catalog/relations.ts +430 -0
  1844. package/dist/template/src/modules/catalog/reporting.ts +66 -0
  1845. package/dist/template/src/modules/catalog/reward-issuer.ts +73 -0
  1846. package/dist/template/src/modules/catalog/schema.ts +1672 -0
  1847. package/dist/template/src/modules/catalog/segment-fields.ts +52 -0
  1848. package/dist/template/src/modules/catalog/service.ts +1055 -0
  1849. package/dist/template/src/modules/catalog/shipping-quote.ts +205 -0
  1850. package/dist/template/src/modules/catalog/shipping.ts +324 -0
  1851. package/dist/template/src/modules/catalog/storefront.ts +524 -0
  1852. package/dist/template/src/modules/catalog/tables.ts +57 -0
  1853. package/dist/template/src/modules/catalog/tokens.ts +26 -0
  1854. package/dist/template/src/modules/catalog/variants.ts +581 -0
  1855. package/dist/template/src/modules/cms/a11y-hints.ts +258 -0
  1856. package/dist/template/src/modules/cms/blocks/SiteChatClient.tsx +233 -0
  1857. package/dist/template/src/modules/cms/blocks/edit.ts +295 -0
  1858. package/dist/template/src/modules/cms/blocks/fields.ts +208 -0
  1859. package/dist/template/src/modules/cms/blocks/help.tsx +241 -0
  1860. package/dist/template/src/modules/cms/blocks/html.ts +84 -0
  1861. package/dist/template/src/modules/cms/blocks/library.tsx +1226 -0
  1862. package/dist/template/src/modules/cms/blocks/merchandising.tsx +721 -0
  1863. package/dist/template/src/modules/cms/blocks/move.ts +115 -0
  1864. package/dist/template/src/modules/cms/blocks/registry.ts +296 -0
  1865. package/dist/template/src/modules/cms/blocks/rich-render.tsx +44 -0
  1866. package/dist/template/src/modules/cms/blocks/rich.ts +312 -0
  1867. package/dist/template/src/modules/cms/blocks/social.ts +38 -0
  1868. package/dist/template/src/modules/cms/blocks/store-sections.tsx +465 -0
  1869. package/dist/template/src/modules/cms/blocks/surfaces.tsx +1031 -0
  1870. package/dist/template/src/modules/cms/blocks/types.ts +241 -0
  1871. package/dist/template/src/modules/cms/blog.tsx +51 -0
  1872. package/dist/template/src/modules/cms/budgets.ts +52 -0
  1873. package/dist/template/src/modules/cms/cache.ts +49 -0
  1874. package/dist/template/src/modules/cms/chrome-nav.ts +53 -0
  1875. package/dist/template/src/modules/cms/collaboration.ts +433 -0
  1876. package/dist/template/src/modules/cms/defaults.ts +110 -0
  1877. package/dist/template/src/modules/cms/email-render.ts +161 -0
  1878. package/dist/template/src/modules/cms/email-service.ts +112 -0
  1879. package/dist/template/src/modules/cms/experiments.ts +108 -0
  1880. package/dist/template/src/modules/cms/help-service.ts +417 -0
  1881. package/dist/template/src/modules/cms/history.ts +106 -0
  1882. package/dist/template/src/modules/cms/inbound.ts +106 -0
  1883. package/dist/template/src/modules/cms/jobs.ts +28 -0
  1884. package/dist/template/src/modules/cms/layout-service.ts +327 -0
  1885. package/dist/template/src/modules/cms/lifecycle.ts +780 -0
  1886. package/dist/template/src/modules/cms/locations.ts +288 -0
  1887. package/dist/template/src/modules/cms/manifest.ts +76 -0
  1888. package/dist/template/src/modules/cms/onboarding.ts +53 -0
  1889. package/dist/template/src/modules/cms/read.ts +27 -0
  1890. package/dist/template/src/modules/cms/render.tsx +135 -0
  1891. package/dist/template/src/modules/cms/schema.ts +387 -0
  1892. package/dist/template/src/modules/cms/section-instances.ts +96 -0
  1893. package/dist/template/src/modules/cms/section-service.ts +263 -0
  1894. package/dist/template/src/modules/cms/service.ts +1815 -0
  1895. package/dist/template/src/modules/cms/sms-template-service.ts +273 -0
  1896. package/dist/template/src/modules/cms/tables.ts +14 -0
  1897. package/dist/template/src/modules/cms/template-service.ts +374 -0
  1898. package/dist/template/src/modules/cms/templates.ts +320 -0
  1899. package/dist/template/src/modules/cms/translate.ts +212 -0
  1900. package/dist/template/src/modules/cms/translation-workflow.ts +235 -0
  1901. package/dist/template/src/modules/contracts/manifest.ts +27 -0
  1902. package/dist/template/src/modules/contracts/portal.ts +27 -0
  1903. package/dist/template/src/modules/contracts/schema.ts +174 -0
  1904. package/dist/template/src/modules/contracts/service.ts +608 -0
  1905. package/dist/template/src/modules/contracts/tables.ts +3 -0
  1906. package/dist/template/src/modules/contracts/template-service.ts +458 -0
  1907. package/dist/template/src/modules/contracts/templates.ts +83 -0
  1908. package/dist/template/src/modules/crm/manifest.ts +30 -0
  1909. package/dist/template/src/modules/crm/schema.ts +209 -0
  1910. package/dist/template/src/modules/crm/service.ts +918 -0
  1911. package/dist/template/src/modules/crm/tables.ts +3 -0
  1912. package/dist/template/src/modules/documents/manifest.ts +29 -0
  1913. package/dist/template/src/modules/documents/portal.ts +41 -0
  1914. package/dist/template/src/modules/documents/schema.ts +243 -0
  1915. package/dist/template/src/modules/documents/service.ts +879 -0
  1916. package/dist/template/src/modules/documents/tables.ts +9 -0
  1917. package/dist/template/src/modules/documents/tokens.ts +33 -0
  1918. package/dist/template/src/modules/events/blocks.tsx +82 -0
  1919. package/dist/template/src/modules/events/ics.ts +47 -0
  1920. package/dist/template/src/modules/events/manifest.ts +26 -0
  1921. package/dist/template/src/modules/events/onboarding.ts +47 -0
  1922. package/dist/template/src/modules/events/public-pages.ts +140 -0
  1923. package/dist/template/src/modules/events/schema.ts +149 -0
  1924. package/dist/template/src/modules/events/service.ts +907 -0
  1925. package/dist/template/src/modules/events/tables.ts +3 -0
  1926. package/dist/template/src/modules/forms/antispam.ts +163 -0
  1927. package/dist/template/src/modules/forms/block.tsx +275 -0
  1928. package/dist/template/src/modules/forms/blocks.ts +11 -0
  1929. package/dist/template/src/modules/forms/briefing.ts +92 -0
  1930. package/dist/template/src/modules/forms/fieldKey.ts +43 -0
  1931. package/dist/template/src/modules/forms/fields.ts +165 -0
  1932. package/dist/template/src/modules/forms/manifest.ts +46 -0
  1933. package/dist/template/src/modules/forms/onboarding.ts +53 -0
  1934. package/dist/template/src/modules/forms/schema.ts +97 -0
  1935. package/dist/template/src/modules/forms/service.ts +905 -0
  1936. package/dist/template/src/modules/forms/tables.ts +4 -0
  1937. package/dist/template/src/modules/galleries/archive.ts +181 -0
  1938. package/dist/template/src/modules/galleries/cookies.ts +24 -0
  1939. package/dist/template/src/modules/galleries/demo.ts +105 -0
  1940. package/dist/template/src/modules/galleries/jobs.ts +49 -0
  1941. package/dist/template/src/modules/galleries/manifest.ts +33 -0
  1942. package/dist/template/src/modules/galleries/onboarding.ts +33 -0
  1943. package/dist/template/src/modules/galleries/schema.ts +442 -0
  1944. package/dist/template/src/modules/galleries/service.ts +2970 -0
  1945. package/dist/template/src/modules/galleries/tables.ts +13 -0
  1946. package/dist/template/src/modules/galleries/tokens.ts +30 -0
  1947. package/dist/template/src/modules/index.ts +96 -0
  1948. package/dist/template/src/modules/invoicing/advanced-money-service.ts +1071 -0
  1949. package/dist/template/src/modules/invoicing/briefing.ts +73 -0
  1950. package/dist/template/src/modules/invoicing/checkout-requirements.ts +19 -0
  1951. package/dist/template/src/modules/invoicing/contract.ts +541 -0
  1952. package/dist/template/src/modules/invoicing/customer-service.ts +336 -0
  1953. package/dist/template/src/modules/invoicing/customer-tokens.ts +43 -0
  1954. package/dist/template/src/modules/invoicing/demo.ts +114 -0
  1955. package/dist/template/src/modules/invoicing/funnel.ts +67 -0
  1956. package/dist/template/src/modules/invoicing/invoice-service.ts +1467 -0
  1957. package/dist/template/src/modules/invoicing/manifest.ts +58 -0
  1958. package/dist/template/src/modules/invoicing/money.ts +88 -0
  1959. package/dist/template/src/modules/invoicing/onboarding.ts +33 -0
  1960. package/dist/template/src/modules/invoicing/payment-plan-ledger.ts +115 -0
  1961. package/dist/template/src/modules/invoicing/payment-provider-service.ts +873 -0
  1962. package/dist/template/src/modules/invoicing/payment-webhook-route.ts +53 -0
  1963. package/dist/template/src/modules/invoicing/portal.ts +29 -0
  1964. package/dist/template/src/modules/invoicing/pos-service.ts +275 -0
  1965. package/dist/template/src/modules/invoicing/recurring-schema.ts +125 -0
  1966. package/dist/template/src/modules/invoicing/recurring-service.ts +608 -0
  1967. package/dist/template/src/modules/invoicing/reporting.ts +39 -0
  1968. package/dist/template/src/modules/invoicing/schema.ts +862 -0
  1969. package/dist/template/src/modules/invoicing/service.ts +37 -0
  1970. package/dist/template/src/modules/invoicing/tables.ts +33 -0
  1971. package/dist/template/src/modules/invoicing/tax-engine.ts +214 -0
  1972. package/dist/template/src/modules/invoicing/tax-service.ts +716 -0
  1973. package/dist/template/src/modules/invoicing/tax-templates.ts +316 -0
  1974. package/dist/template/src/modules/local-plugins.ts +15 -0
  1975. package/dist/template/src/modules/loyalty/jobs.ts +224 -0
  1976. package/dist/template/src/modules/loyalty/manifest.ts +58 -0
  1977. package/dist/template/src/modules/loyalty/rewards-service.ts +607 -0
  1978. package/dist/template/src/modules/loyalty/schema.ts +333 -0
  1979. package/dist/template/src/modules/loyalty/service.ts +922 -0
  1980. package/dist/template/src/modules/loyalty/spine.ts +97 -0
  1981. package/dist/template/src/modules/loyalty/tables.ts +12 -0
  1982. package/dist/template/src/modules/newsletters/blocks.tsx +128 -0
  1983. package/dist/template/src/modules/newsletters/broadcast-schema.ts +166 -0
  1984. package/dist/template/src/modules/newsletters/broadcast-service.ts +806 -0
  1985. package/dist/template/src/modules/newsletters/jobs.ts +29 -0
  1986. package/dist/template/src/modules/newsletters/manifest.ts +39 -0
  1987. package/dist/template/src/modules/newsletters/public-pages.ts +128 -0
  1988. package/dist/template/src/modules/newsletters/schema.ts +134 -0
  1989. package/dist/template/src/modules/newsletters/service.ts +708 -0
  1990. package/dist/template/src/modules/newsletters/tables.ts +9 -0
  1991. package/dist/template/src/modules/newsletters/template-schema.ts +92 -0
  1992. package/dist/template/src/modules/newsletters/template-service.ts +368 -0
  1993. package/dist/template/src/modules/popups/PopupSurface.tsx +401 -0
  1994. package/dist/template/src/modules/popups/http.ts +26 -0
  1995. package/dist/template/src/modules/popups/manifest.ts +42 -0
  1996. package/dist/template/src/modules/popups/mount.tsx +89 -0
  1997. package/dist/template/src/modules/popups/schema.ts +252 -0
  1998. package/dist/template/src/modules/popups/service.ts +948 -0
  1999. package/dist/template/src/modules/popups/tables.ts +4 -0
  2000. package/dist/template/src/modules/popups/tally.ts +194 -0
  2001. package/dist/template/src/modules/popups/targeting.ts +206 -0
  2002. package/dist/template/src/modules/projects/blocks.tsx +444 -0
  2003. package/dist/template/src/modules/projects/consent-gate.ts +104 -0
  2004. package/dist/template/src/modules/projects/jobs.ts +24 -0
  2005. package/dist/template/src/modules/projects/manifest.ts +33 -0
  2006. package/dist/template/src/modules/projects/portal.ts +32 -0
  2007. package/dist/template/src/modules/projects/portfolio-service.ts +712 -0
  2008. package/dist/template/src/modules/projects/publishing-service.ts +782 -0
  2009. package/dist/template/src/modules/projects/schema.ts +437 -0
  2010. package/dist/template/src/modules/projects/service.ts +1055 -0
  2011. package/dist/template/src/modules/projects/tables.ts +12 -0
  2012. package/dist/template/src/modules/projects/time-schema.ts +166 -0
  2013. package/dist/template/src/modules/projects/time-service.ts +631 -0
  2014. package/dist/template/src/modules/proof/blocks.tsx +34 -0
  2015. package/dist/template/src/modules/proof/manifest.ts +24 -0
  2016. package/dist/template/src/modules/proof/schema.ts +21 -0
  2017. package/dist/template/src/modules/proof/seed.ts +11 -0
  2018. package/dist/template/src/modules/proof/service.ts +74 -0
  2019. package/dist/template/src/modules/proof/tables.ts +3 -0
  2020. package/dist/template/src/modules/quotes/conversion.ts +425 -0
  2021. package/dist/template/src/modules/quotes/cookies.ts +9 -0
  2022. package/dist/template/src/modules/quotes/demo.ts +99 -0
  2023. package/dist/template/src/modules/quotes/funnel.ts +44 -0
  2024. package/dist/template/src/modules/quotes/manifest.ts +34 -0
  2025. package/dist/template/src/modules/quotes/onboarding.ts +33 -0
  2026. package/dist/template/src/modules/quotes/portal.ts +46 -0
  2027. package/dist/template/src/modules/quotes/schema.ts +250 -0
  2028. package/dist/template/src/modules/quotes/service.ts +1554 -0
  2029. package/dist/template/src/modules/quotes/tables.ts +9 -0
  2030. package/dist/template/src/modules/quotes/tokens.ts +28 -0
  2031. package/dist/template/src/modules/quotes/view-entity.ts +20 -0
  2032. package/dist/template/src/modules/referrals/attribution-service.ts +134 -0
  2033. package/dist/template/src/modules/referrals/attribution.ts +99 -0
  2034. package/dist/template/src/modules/referrals/commission-service.ts +1114 -0
  2035. package/dist/template/src/modules/referrals/commission.ts +150 -0
  2036. package/dist/template/src/modules/referrals/jobs.ts +32 -0
  2037. package/dist/template/src/modules/referrals/manifest.ts +53 -0
  2038. package/dist/template/src/modules/referrals/portal.ts +37 -0
  2039. package/dist/template/src/modules/referrals/schema.ts +421 -0
  2040. package/dist/template/src/modules/referrals/service.ts +619 -0
  2041. package/dist/template/src/modules/referrals/spine.ts +92 -0
  2042. package/dist/template/src/modules/referrals/tables.ts +13 -0
  2043. package/dist/template/src/modules/referrals/tokens.ts +28 -0
  2044. package/dist/template/src/modules/rentals/manifest.ts +26 -0
  2045. package/dist/template/src/modules/rentals/portal.ts +34 -0
  2046. package/dist/template/src/modules/rentals/pricing.ts +150 -0
  2047. package/dist/template/src/modules/rentals/schema.ts +210 -0
  2048. package/dist/template/src/modules/rentals/service.ts +759 -0
  2049. package/dist/template/src/modules/rentals/tables.ts +3 -0
  2050. package/dist/template/src/modules/reporting/demo.ts +88 -0
  2051. package/dist/template/src/modules/reporting/export-schema.ts +319 -0
  2052. package/dist/template/src/modules/reporting/export-service.ts +1224 -0
  2053. package/dist/template/src/modules/reporting/export-shapes.ts +429 -0
  2054. package/dist/template/src/modules/reporting/export-tokens.ts +23 -0
  2055. package/dist/template/src/modules/reporting/jobs.ts +117 -0
  2056. package/dist/template/src/modules/reporting/manifest.ts +34 -0
  2057. package/dist/template/src/modules/reporting/onboarding.ts +33 -0
  2058. package/dist/template/src/modules/reporting/schema.ts +48 -0
  2059. package/dist/template/src/modules/reporting/service.ts +540 -0
  2060. package/dist/template/src/modules/reporting/tables.ts +4 -0
  2061. package/dist/template/src/modules/reviews/blocks.tsx +97 -0
  2062. package/dist/template/src/modules/reviews/manifest.ts +26 -0
  2063. package/dist/template/src/modules/reviews/schema.ts +182 -0
  2064. package/dist/template/src/modules/reviews/service.ts +663 -0
  2065. package/dist/template/src/modules/reviews/tables.ts +3 -0
  2066. package/dist/template/src/modules/reviews/tokens.ts +22 -0
  2067. package/dist/template/src/modules/seed/boot.ts +94 -0
  2068. package/dist/template/src/modules/seed/manifest.ts +24 -0
  2069. package/dist/template/src/modules/seed/onboarding.ts +276 -0
  2070. package/dist/template/src/modules/seed/preset-install.ts +181 -0
  2071. package/dist/template/src/modules/seed/service.ts +260 -0
  2072. package/dist/template/src/modules/share/embeds.ts +54 -0
  2073. package/dist/template/src/modules/share/intents.ts +126 -0
  2074. package/dist/template/src/modules/share/links.ts +164 -0
  2075. package/dist/template/src/modules/share/manifest.ts +34 -0
  2076. package/dist/template/src/modules/share/schema.ts +130 -0
  2077. package/dist/template/src/modules/share/service.ts +697 -0
  2078. package/dist/template/src/modules/share/tables.ts +4 -0
  2079. package/dist/template/src/modules/social/capabilities.ts +71 -0
  2080. package/dist/template/src/modules/social/compose.ts +825 -0
  2081. package/dist/template/src/modules/social/contract.ts +59 -0
  2082. package/dist/template/src/modules/social/gbp.ts +570 -0
  2083. package/dist/template/src/modules/social/ingest.ts +727 -0
  2084. package/dist/template/src/modules/social/jobs.ts +125 -0
  2085. package/dist/template/src/modules/social/manifest.ts +34 -0
  2086. package/dist/template/src/modules/social/oauth.ts +300 -0
  2087. package/dist/template/src/modules/social/onboarding.ts +45 -0
  2088. package/dist/template/src/modules/social/policy.ts +48 -0
  2089. package/dist/template/src/modules/social/render.ts +135 -0
  2090. package/dist/template/src/modules/social/schema.ts +322 -0
  2091. package/dist/template/src/modules/social/service.ts +660 -0
  2092. package/dist/template/src/modules/social/tables.ts +13 -0
  2093. package/dist/template/src/modules/subscriptions/billing.ts +1042 -0
  2094. package/dist/template/src/modules/subscriptions/jobs.ts +52 -0
  2095. package/dist/template/src/modules/subscriptions/manifest.ts +34 -0
  2096. package/dist/template/src/modules/subscriptions/portal.ts +34 -0
  2097. package/dist/template/src/modules/subscriptions/public-signup.ts +124 -0
  2098. package/dist/template/src/modules/subscriptions/schema.ts +294 -0
  2099. package/dist/template/src/modules/subscriptions/service.ts +1659 -0
  2100. package/dist/template/src/modules/subscriptions/tables.ts +3 -0
  2101. package/dist/template/src/ui/GuidancePanel.tsx +200 -0
  2102. package/dist/template/src/ui/ShareCopyButton.tsx +28 -0
  2103. package/dist/template/src/ui/SkipLink.tsx +21 -0
  2104. package/dist/template/src/ui/ThemeToggle.tsx +79 -0
  2105. package/dist/template/src/ui/primitives.tsx +269 -0
  2106. package/dist/template/tests/README.md +5 -0
  2107. package/dist/template/tests/adapters/social-conformance.test.ts +71 -0
  2108. package/dist/template/tests/browser/accessibility.spec.ts +793 -0
  2109. package/dist/template/tests/browser/agent-launch.spec.ts +110 -0
  2110. package/dist/template/tests/browser/assessments.spec.ts +188 -0
  2111. package/dist/template/tests/browser/c11-01-visitor-to-paid.spec.ts +281 -0
  2112. package/dist/template/tests/browser/c11-04-capture.spec.ts +80 -0
  2113. package/dist/template/tests/browser/calculators.spec.ts +196 -0
  2114. package/dist/template/tests/browser/cart-access.spec.ts +42 -0
  2115. package/dist/template/tests/browser/customer-surfaces.spec.ts +115 -0
  2116. package/dist/template/tests/browser/database.ts +60 -0
  2117. package/dist/template/tests/browser/demo-scenarios.spec.ts +117 -0
  2118. package/dist/template/tests/browser/editor-drag-drop.spec.ts +259 -0
  2119. package/dist/template/tests/browser/editor-inline-editing.spec.ts +186 -0
  2120. package/dist/template/tests/browser/editor-media-tools.spec.ts +231 -0
  2121. package/dist/template/tests/browser/editor-store-sections.spec.ts +391 -0
  2122. package/dist/template/tests/browser/events.spec.ts +195 -0
  2123. package/dist/template/tests/browser/facts.spec.ts +140 -0
  2124. package/dist/template/tests/browser/first-party-plugins.spec.ts +161 -0
  2125. package/dist/template/tests/browser/guidance.spec.ts +148 -0
  2126. package/dist/template/tests/browser/journeys.spec.ts +662 -0
  2127. package/dist/template/tests/browser/location-access.spec.ts +59 -0
  2128. package/dist/template/tests/browser/media-consent.spec.ts +93 -0
  2129. package/dist/template/tests/browser/owner-session.ts +53 -0
  2130. package/dist/template/tests/browser/playground.spec.ts +151 -0
  2131. package/dist/template/tests/browser/provider-erasure.spec.ts +50 -0
  2132. package/dist/template/tests/browser/record-search.spec.ts +107 -0
  2133. package/dist/template/tests/browser/record-trash.spec.ts +127 -0
  2134. package/dist/template/tests/browser/storefront-checkout.spec.ts +272 -0
  2135. package/dist/template/tests/browser/storefront-merch-blocks.spec.ts +319 -0
  2136. package/dist/template/tests/browser/workflow-search.spec.ts +53 -0
  2137. package/dist/template/tests/core/a11y-smoke.test.ts +92 -0
  2138. package/dist/template/tests/core/admin-journey-screens.test.ts +143 -0
  2139. package/dist/template/tests/core/advanced-money.test.ts +232 -0
  2140. package/dist/template/tests/core/adversarial-gallery-privacy.test.ts +185 -0
  2141. package/dist/template/tests/core/adversarial-portal-privacy.test.ts +93 -0
  2142. package/dist/template/tests/core/agent-launch.test.ts +74 -0
  2143. package/dist/template/tests/core/agents-approvals.test.ts +168 -0
  2144. package/dist/template/tests/core/agents-autonomy.test.ts +364 -0
  2145. package/dist/template/tests/core/agents-board.test.ts +111 -0
  2146. package/dist/template/tests/core/agents-budgets.test.ts +329 -0
  2147. package/dist/template/tests/core/agents-inbound.test.ts +535 -0
  2148. package/dist/template/tests/core/agents-injection.test.ts +351 -0
  2149. package/dist/template/tests/core/agents-managed-loop.test.ts +261 -0
  2150. package/dist/template/tests/core/agents-pause.test.ts +183 -0
  2151. package/dist/template/tests/core/agents-playbooks.test.ts +285 -0
  2152. package/dist/template/tests/core/agents-run.test.ts +119 -0
  2153. package/dist/template/tests/core/agents-schedule.test.ts +231 -0
  2154. package/dist/template/tests/core/agents-workforce-adapter.test.ts +359 -0
  2155. package/dist/template/tests/core/agents.test.ts +436 -0
  2156. package/dist/template/tests/core/alt-text-adapter.test.ts +97 -0
  2157. package/dist/template/tests/core/analytics-consent.test.ts +272 -0
  2158. package/dist/template/tests/core/analytics-experiments.test.ts +63 -0
  2159. package/dist/template/tests/core/analytics-governance-migration.test.ts +28 -0
  2160. package/dist/template/tests/core/analytics.test.ts +660 -0
  2161. package/dist/template/tests/core/api.test.ts +338 -0
  2162. package/dist/template/tests/core/apikeys.test.ts +366 -0
  2163. package/dist/template/tests/core/attestations.test.ts +311 -0
  2164. package/dist/template/tests/core/audit-labels.test.ts +37 -0
  2165. package/dist/template/tests/core/autofill-safety.test.ts +279 -0
  2166. package/dist/template/tests/core/availability.test.ts +389 -0
  2167. package/dist/template/tests/core/booking-audiences.test.ts +334 -0
  2168. package/dist/template/tests/core/booking-concurrency.test.ts +288 -0
  2169. package/dist/template/tests/core/bookings.test.ts +343 -0
  2170. package/dist/template/tests/core/boot.test.ts +195 -0
  2171. package/dist/template/tests/core/bootstrap-security.test.ts +38 -0
  2172. package/dist/template/tests/core/briefing-contributors.test.ts +200 -0
  2173. package/dist/template/tests/core/briefing-playbooks.test.ts +171 -0
  2174. package/dist/template/tests/core/briefing.test.ts +298 -0
  2175. package/dist/template/tests/core/browse-storefront.test.ts +561 -0
  2176. package/dist/template/tests/core/builder-authority.test.ts +205 -0
  2177. package/dist/template/tests/core/builder-code-lane.test.ts +213 -0
  2178. package/dist/template/tests/core/builder-content-lane.test.ts +249 -0
  2179. package/dist/template/tests/core/c11-02-catalog-journey.test.ts +227 -0
  2180. package/dist/template/tests/core/c11-03-booking-journey.test.ts +422 -0
  2181. package/dist/template/tests/core/c11-04-gallery-social-journey.test.ts +310 -0
  2182. package/dist/template/tests/core/c11-05-subscription-journey.test.ts +193 -0
  2183. package/dist/template/tests/core/c11-06-agent-journey.test.ts +208 -0
  2184. package/dist/template/tests/core/c11-07-mail-calendar-journey.test.ts +179 -0
  2185. package/dist/template/tests/core/c11-08-install-update-journey.test.ts +166 -0
  2186. package/dist/template/tests/core/c11-13-failure-drills.test.ts +446 -0
  2187. package/dist/template/tests/core/c11-14-retention.test.ts +320 -0
  2188. package/dist/template/tests/core/c11-14-search.test.ts +527 -0
  2189. package/dist/template/tests/core/calendar-busy.test.ts +198 -0
  2190. package/dist/template/tests/core/calendar-oauth-callback.test.ts +154 -0
  2191. package/dist/template/tests/core/calendar-oauth.test.ts +312 -0
  2192. package/dist/template/tests/core/calendar-sync.test.ts +363 -0
  2193. package/dist/template/tests/core/calendars.test.ts +267 -0
  2194. package/dist/template/tests/core/cart-access.test.ts +107 -0
  2195. package/dist/template/tests/core/cart-storefront.test.ts +507 -0
  2196. package/dist/template/tests/core/catalog-browse.test.ts +587 -0
  2197. package/dist/template/tests/core/catalog-carts.test.ts +150 -0
  2198. package/dist/template/tests/core/catalog-collections.test.ts +454 -0
  2199. package/dist/template/tests/core/catalog-fulfillment.test.ts +191 -0
  2200. package/dist/template/tests/core/catalog-inventory.test.ts +198 -0
  2201. package/dist/template/tests/core/catalog-merchandising.test.ts +107 -0
  2202. package/dist/template/tests/core/catalog-offerings.test.ts +213 -0
  2203. package/dist/template/tests/core/catalog-orders.test.ts +279 -0
  2204. package/dist/template/tests/core/catalog-pricing.test.ts +85 -0
  2205. package/dist/template/tests/core/catalog-procurement.test.ts +154 -0
  2206. package/dist/template/tests/core/catalog-promotions.test.ts +109 -0
  2207. package/dist/template/tests/core/catalog-public-pages.test.ts +73 -0
  2208. package/dist/template/tests/core/catalog-relations.test.ts +79 -0
  2209. package/dist/template/tests/core/catalog-variants.test.ts +113 -0
  2210. package/dist/template/tests/core/catalog.test.ts +233 -0
  2211. package/dist/template/tests/core/catalogue.test.ts +300 -0
  2212. package/dist/template/tests/core/change-password.test.ts +164 -0
  2213. package/dist/template/tests/core/changelog-output.test.ts +33 -0
  2214. package/dist/template/tests/core/checkout-policy.test.ts +34 -0
  2215. package/dist/template/tests/core/client-galleries.test.ts +609 -0
  2216. package/dist/template/tests/core/client-readiness-security.test.ts +136 -0
  2217. package/dist/template/tests/core/cms-a11y.test.ts +157 -0
  2218. package/dist/template/tests/core/cms-blocks.test.ts +283 -0
  2219. package/dist/template/tests/core/cms-cache.test.ts +121 -0
  2220. package/dist/template/tests/core/cms-chrome.test.ts +114 -0
  2221. package/dist/template/tests/core/cms-collaboration.test.ts +196 -0
  2222. package/dist/template/tests/core/cms-drafts.test.ts +78 -0
  2223. package/dist/template/tests/core/cms-email.test.ts +71 -0
  2224. package/dist/template/tests/core/cms-experiments.test.ts +109 -0
  2225. package/dist/template/tests/core/cms-fields.test.ts +137 -0
  2226. package/dist/template/tests/core/cms-history.test.ts +34 -0
  2227. package/dist/template/tests/core/cms-layouts.test.ts +110 -0
  2228. package/dist/template/tests/core/cms-lifecycle.test.ts +267 -0
  2229. package/dist/template/tests/core/cms-move.test.ts +101 -0
  2230. package/dist/template/tests/core/cms-plugin-proof.test.ts +56 -0
  2231. package/dist/template/tests/core/cms-public-boundary.test.ts +85 -0
  2232. package/dist/template/tests/core/cms-rich.test.ts +144 -0
  2233. package/dist/template/tests/core/cms-sections.test.ts +139 -0
  2234. package/dist/template/tests/core/cms-service.test.ts +358 -0
  2235. package/dist/template/tests/core/cms-surfaces.test.ts +117 -0
  2236. package/dist/template/tests/core/cms-templates.test.ts +115 -0
  2237. package/dist/template/tests/core/cms-translation-workflow.test.ts +88 -0
  2238. package/dist/template/tests/core/collections-storefront.test.ts +328 -0
  2239. package/dist/template/tests/core/colour-literals.test.ts +73 -0
  2240. package/dist/template/tests/core/community-rooms.test.ts +324 -0
  2241. package/dist/template/tests/core/connection-grants.test.ts +209 -0
  2242. package/dist/template/tests/core/connections.test.ts +435 -0
  2243. package/dist/template/tests/core/consent-publish-surfaces.test.ts +577 -0
  2244. package/dist/template/tests/core/contact-data-depth.test.ts +426 -0
  2245. package/dist/template/tests/core/contact-duplicate-review.test.ts +357 -0
  2246. package/dist/template/tests/core/contact-import.test.ts +404 -0
  2247. package/dist/template/tests/core/contact-privacy-rights.test.ts +636 -0
  2248. package/dist/template/tests/core/contacts-read.test.ts +165 -0
  2249. package/dist/template/tests/core/contract-evidence.test.ts +43 -0
  2250. package/dist/template/tests/core/contract-projections.test.ts +47 -0
  2251. package/dist/template/tests/core/contract-templates.test.ts +270 -0
  2252. package/dist/template/tests/core/contribute.test.ts +497 -0
  2253. package/dist/template/tests/core/conversations.test.ts +381 -0
  2254. package/dist/template/tests/core/coverage-enforcement.test.ts +296 -0
  2255. package/dist/template/tests/core/coverage.test.ts +308 -0
  2256. package/dist/template/tests/core/create-freeholder.test.ts +307 -0
  2257. package/dist/template/tests/core/csp-migration.test.ts +30 -0
  2258. package/dist/template/tests/core/csp-reports.test.ts +150 -0
  2259. package/dist/template/tests/core/csp.test.ts +194 -0
  2260. package/dist/template/tests/core/csrf.test.ts +139 -0
  2261. package/dist/template/tests/core/customer-galleries.test.ts +137 -0
  2262. package/dist/template/tests/core/customer-invoices.test.ts +235 -0
  2263. package/dist/template/tests/core/customer-locale-migration.test.ts +40 -0
  2264. package/dist/template/tests/core/customer-locale-ui.test.ts +39 -0
  2265. package/dist/template/tests/core/customer-locale.test.ts +85 -0
  2266. package/dist/template/tests/core/customer-magic-links.test.ts +281 -0
  2267. package/dist/template/tests/core/customer-reply.test.ts +155 -0
  2268. package/dist/template/tests/core/customer-return-path.test.ts +11 -0
  2269. package/dist/template/tests/core/daily-adapter.test.ts +185 -0
  2270. package/dist/template/tests/core/daily-flow.test.ts +94 -0
  2271. package/dist/template/tests/core/daily-import.test.ts +206 -0
  2272. package/dist/template/tests/core/dashboard.test.ts +147 -0
  2273. package/dist/template/tests/core/db-errors.test.ts +52 -0
  2274. package/dist/template/tests/core/deferred-erasure.test.ts +124 -0
  2275. package/dist/template/tests/core/demo-migration.test.ts +39 -0
  2276. package/dist/template/tests/core/demo-paths.test.ts +49 -0
  2277. package/dist/template/tests/core/demo-scenarios.test.ts +200 -0
  2278. package/dist/template/tests/core/dependency-attestation.test.ts +84 -0
  2279. package/dist/template/tests/core/dependency-audit.test.ts +124 -0
  2280. package/dist/template/tests/core/deploy-droplet.test.ts +323 -0
  2281. package/dist/template/tests/core/deploy-recipe.test.ts +134 -0
  2282. package/dist/template/tests/core/design-tokens.test.ts +113 -0
  2283. package/dist/template/tests/core/doc-claim-mapping.test.ts +167 -0
  2284. package/dist/template/tests/core/docs-availability.test.ts +94 -0
  2285. package/dist/template/tests/core/doctor-script.test.ts +16 -0
  2286. package/dist/template/tests/core/doctor.test.ts +220 -0
  2287. package/dist/template/tests/core/edge-adapters.test.ts +220 -0
  2288. package/dist/template/tests/core/editor-canvas-drag.test.ts +348 -0
  2289. package/dist/template/tests/core/editor-inline-edit.test.ts +416 -0
  2290. package/dist/template/tests/core/editor-media-tools.test.ts +450 -0
  2291. package/dist/template/tests/core/editor-preview-bridge.test.ts +428 -0
  2292. package/dist/template/tests/core/editor-preview-draft.test.ts +226 -0
  2293. package/dist/template/tests/core/editor-reorder.test.ts +339 -0
  2294. package/dist/template/tests/core/editor-store-sections.test.ts +476 -0
  2295. package/dist/template/tests/core/embeds.test.ts +60 -0
  2296. package/dist/template/tests/core/entitlements.test.ts +312 -0
  2297. package/dist/template/tests/core/events.test.ts +113 -0
  2298. package/dist/template/tests/core/f-matrix.test.ts +206 -0
  2299. package/dist/template/tests/core/f04-remaining-screens.test.ts +258 -0
  2300. package/dist/template/tests/core/first-party-plugins.test.ts +783 -0
  2301. package/dist/template/tests/core/forms.test.ts +446 -0
  2302. package/dist/template/tests/core/freeholder-app-init.test.ts +504 -0
  2303. package/dist/template/tests/core/gallery-archive.test.ts +265 -0
  2304. package/dist/template/tests/core/gallery-delivery-routes.test.ts +72 -0
  2305. package/dist/template/tests/core/gallery-partner-share.test.ts +320 -0
  2306. package/dist/template/tests/core/gallery-proofing.test.ts +311 -0
  2307. package/dist/template/tests/core/gallery-rounds.test.ts +291 -0
  2308. package/dist/template/tests/core/gallery-sales.test.ts +309 -0
  2309. package/dist/template/tests/core/guidance-definitions.test.ts +135 -0
  2310. package/dist/template/tests/core/guidance-ui.test.ts +92 -0
  2311. package/dist/template/tests/core/guidance.test.ts +309 -0
  2312. package/dist/template/tests/core/host-update-socket.test.ts +121 -0
  2313. package/dist/template/tests/core/host-updater-recipe.test.ts +68 -0
  2314. package/dist/template/tests/core/http-auth.test.ts +286 -0
  2315. package/dist/template/tests/core/http-body-boundary.test.ts +69 -0
  2316. package/dist/template/tests/core/http.test.ts +284 -0
  2317. package/dist/template/tests/core/i18n-gate.test.ts +440 -0
  2318. package/dist/template/tests/core/i18n.test.ts +190 -0
  2319. package/dist/template/tests/core/ics-and-writeback.test.ts +446 -0
  2320. package/dist/template/tests/core/importers.test.ts +102 -0
  2321. package/dist/template/tests/core/inbox.test.ts +304 -0
  2322. package/dist/template/tests/core/inline-script-safety.test.ts +41 -0
  2323. package/dist/template/tests/core/instrumentation-boundary.test.ts +16 -0
  2324. package/dist/template/tests/core/intake-waivers-reminders.test.ts +533 -0
  2325. package/dist/template/tests/core/internal-services.test.ts +298 -0
  2326. package/dist/template/tests/core/invitations.test.ts +341 -0
  2327. package/dist/template/tests/core/invoice-admin.test.ts +41 -0
  2328. package/dist/template/tests/core/invoicing-pos.test.ts +107 -0
  2329. package/dist/template/tests/core/invoicing.test.ts +776 -0
  2330. package/dist/template/tests/core/job-runtime-health.test.ts +123 -0
  2331. package/dist/template/tests/core/locale-quality.test.ts +107 -0
  2332. package/dist/template/tests/core/locale-routing.test.ts +321 -0
  2333. package/dist/template/tests/core/locations.test.ts +599 -0
  2334. package/dist/template/tests/core/long-running-service-boundary.test.ts +216 -0
  2335. package/dist/template/tests/core/mail-adapters.test.ts +423 -0
  2336. package/dist/template/tests/core/mail-import.test.ts +325 -0
  2337. package/dist/template/tests/core/mail-migration.test.ts +163 -0
  2338. package/dist/template/tests/core/mail-oauth-callback.test.ts +159 -0
  2339. package/dist/template/tests/core/mail-oauth.test.ts +447 -0
  2340. package/dist/template/tests/core/mail-outbox-crypto.test.ts +88 -0
  2341. package/dist/template/tests/core/mail-read-oauth-callback.test.ts +111 -0
  2342. package/dist/template/tests/core/mail-service.test.ts +644 -0
  2343. package/dist/template/tests/core/mail-ui.test.ts +206 -0
  2344. package/dist/template/tests/core/mail-webhooks.test.ts +454 -0
  2345. package/dist/template/tests/core/malware.test.ts +85 -0
  2346. package/dist/template/tests/core/marketplace-claims.test.ts +68 -0
  2347. package/dist/template/tests/core/mcp-input-schema.test.ts +18 -0
  2348. package/dist/template/tests/core/mcp.test.ts +459 -0
  2349. package/dist/template/tests/core/media-capture.test.ts +345 -0
  2350. package/dist/template/tests/core/media-consent.test.ts +357 -0
  2351. package/dist/template/tests/core/media-framing.test.ts +210 -0
  2352. package/dist/template/tests/core/media-transfer.test.ts +48 -0
  2353. package/dist/template/tests/core/media-watermark.test.ts +308 -0
  2354. package/dist/template/tests/core/media.test.ts +1446 -0
  2355. package/dist/template/tests/core/merch-blocks.test.ts +465 -0
  2356. package/dist/template/tests/core/merge-completeness.test.ts +228 -0
  2357. package/dist/template/tests/core/migrate.test.ts +75 -0
  2358. package/dist/template/tests/core/migration-journal.test.ts +59 -0
  2359. package/dist/template/tests/core/mobile-app-shell.test.ts +238 -0
  2360. package/dist/template/tests/core/mobile-app.test.ts +728 -0
  2361. package/dist/template/tests/core/mobile-capture-batches.test.ts +223 -0
  2362. package/dist/template/tests/core/mobile-private-cache.test.ts +339 -0
  2363. package/dist/template/tests/core/mobile-screens.test.ts +362 -0
  2364. package/dist/template/tests/core/mobile-store-gate.test.ts +310 -0
  2365. package/dist/template/tests/core/module.test.ts +60 -0
  2366. package/dist/template/tests/core/money-arithmetic.test.ts +279 -0
  2367. package/dist/template/tests/core/newsletters.test.ts +178 -0
  2368. package/dist/template/tests/core/notes.test.ts +338 -0
  2369. package/dist/template/tests/core/notification-migration.test.ts +174 -0
  2370. package/dist/template/tests/core/notification-ui.test.ts +97 -0
  2371. package/dist/template/tests/core/notifications.test.ts +510 -0
  2372. package/dist/template/tests/core/onboarding-contract.test.ts +133 -0
  2373. package/dist/template/tests/core/outbound-boundaries.test.ts +29 -0
  2374. package/dist/template/tests/core/outbox.test.ts +407 -0
  2375. package/dist/template/tests/core/owner-password-script.test.ts +106 -0
  2376. package/dist/template/tests/core/ownership-export.test.ts +273 -0
  2377. package/dist/template/tests/core/page-editor-publish.test.ts +94 -0
  2378. package/dist/template/tests/core/paradise-adapter.test.ts +177 -0
  2379. package/dist/template/tests/core/paradise-flow.test.ts +350 -0
  2380. package/dist/template/tests/core/paradise-webhook.test.ts +148 -0
  2381. package/dist/template/tests/core/password-reset.test.ts +289 -0
  2382. package/dist/template/tests/core/passwords.test.ts +57 -0
  2383. package/dist/template/tests/core/payment-adapters.test.ts +604 -0
  2384. package/dist/template/tests/core/payment-provider-service.test.ts +226 -0
  2385. package/dist/template/tests/core/paywalls.test.ts +358 -0
  2386. package/dist/template/tests/core/performance-budgets.test.ts +332 -0
  2387. package/dist/template/tests/core/performance-measurement-families.test.ts +296 -0
  2388. package/dist/template/tests/core/pipelines.test.ts +382 -0
  2389. package/dist/template/tests/core/plan-gate.test.ts +251 -0
  2390. package/dist/template/tests/core/playground.test.ts +412 -0
  2391. package/dist/template/tests/core/plugin-claims.test.ts +41 -0
  2392. package/dist/template/tests/core/plugin-contract.test.ts +149 -0
  2393. package/dist/template/tests/core/plugin-provider-boundary.test.ts +35 -0
  2394. package/dist/template/tests/core/plugin-scaffold.test.ts +27 -0
  2395. package/dist/template/tests/core/plugins-lifecycle.test.ts +196 -0
  2396. package/dist/template/tests/core/portability.test.ts +58 -0
  2397. package/dist/template/tests/core/portal-rooms.test.ts +280 -0
  2398. package/dist/template/tests/core/portal-shell.test.ts +116 -0
  2399. package/dist/template/tests/core/pos-adapters.test.ts +78 -0
  2400. package/dist/template/tests/core/price-breaks.test.ts +63 -0
  2401. package/dist/template/tests/core/printify-adapter.test.ts +85 -0
  2402. package/dist/template/tests/core/printify-fulfillment.test.ts +149 -0
  2403. package/dist/template/tests/core/product-gift-share.test.ts +116 -0
  2404. package/dist/template/tests/core/project-case-studies.test.ts +277 -0
  2405. package/dist/template/tests/core/project-portfolios.test.ts +197 -0
  2406. package/dist/template/tests/core/projects.test.ts +292 -0
  2407. package/dist/template/tests/core/promo-quote.test.ts +51 -0
  2408. package/dist/template/tests/core/proxy-locale.test.ts +55 -0
  2409. package/dist/template/tests/core/public-entity-drafts.test.ts +166 -0
  2410. package/dist/template/tests/core/push-devices.test.ts +147 -0
  2411. package/dist/template/tests/core/quote-conversion.test.ts +291 -0
  2412. package/dist/template/tests/core/quote-partner-share.test.ts +192 -0
  2413. package/dist/template/tests/core/quotes.test.ts +357 -0
  2414. package/dist/template/tests/core/rate-limit.test.ts +216 -0
  2415. package/dist/template/tests/core/recipes.test.ts +212 -0
  2416. package/dist/template/tests/core/record-participation.test.ts +121 -0
  2417. package/dist/template/tests/core/record-trash-families.test.ts +321 -0
  2418. package/dist/template/tests/core/record-trash.test.ts +154 -0
  2419. package/dist/template/tests/core/recurring-invoices.test.ts +284 -0
  2420. package/dist/template/tests/core/registry-completeness.test.ts +143 -0
  2421. package/dist/template/tests/core/release-history.test.ts +47 -0
  2422. package/dist/template/tests/core/release-packages.test.ts +35 -0
  2423. package/dist/template/tests/core/release-publication.test.ts +69 -0
  2424. package/dist/template/tests/core/rentals.test.ts +408 -0
  2425. package/dist/template/tests/core/resolver.test.ts +481 -0
  2426. package/dist/template/tests/core/reviews.test.ts +229 -0
  2427. package/dist/template/tests/core/roles.test.ts +199 -0
  2428. package/dist/template/tests/core/route-boot.test.ts +64 -0
  2429. package/dist/template/tests/core/runtime-balanced-sequencer.test.ts +117 -0
  2430. package/dist/template/tests/core/runtime-shutdown.test.ts +58 -0
  2431. package/dist/template/tests/core/runtime-version-integrity.test.ts +43 -0
  2432. package/dist/template/tests/core/saved-views.test.ts +271 -0
  2433. package/dist/template/tests/core/schema-baseline-identity.test.ts +70 -0
  2434. package/dist/template/tests/core/schema-compat-gate.test.ts +172 -0
  2435. package/dist/template/tests/core/scoring.test.ts +364 -0
  2436. package/dist/template/tests/core/sdk-generation.test.ts +55 -0
  2437. package/dist/template/tests/core/sdk-schema.test.ts +106 -0
  2438. package/dist/template/tests/core/sdk.test.ts +181 -0
  2439. package/dist/template/tests/core/security-headers.test.ts +41 -0
  2440. package/dist/template/tests/core/seed-demo.test.ts +355 -0
  2441. package/dist/template/tests/core/segments.test.ts +528 -0
  2442. package/dist/template/tests/core/seo-gate.test.ts +193 -0
  2443. package/dist/template/tests/core/seo-public-entities.test.ts +105 -0
  2444. package/dist/template/tests/core/seo-surface.test.ts +279 -0
  2445. package/dist/template/tests/core/seo.test.ts +277 -0
  2446. package/dist/template/tests/core/service-composition.test.ts +248 -0
  2447. package/dist/template/tests/core/service-output.test.ts +48 -0
  2448. package/dist/template/tests/core/service.test.ts +394 -0
  2449. package/dist/template/tests/core/session-management.test.ts +223 -0
  2450. package/dist/template/tests/core/settings.test.ts +421 -0
  2451. package/dist/template/tests/core/shipping-quote.test.ts +105 -0
  2452. package/dist/template/tests/core/shopify-adapter.test.ts +121 -0
  2453. package/dist/template/tests/core/shopify-refunds.test.ts +177 -0
  2454. package/dist/template/tests/core/shopify-sync.test.ts +62 -0
  2455. package/dist/template/tests/core/signup-contact-import.test.ts +383 -0
  2456. package/dist/template/tests/core/site-chat.test.ts +250 -0
  2457. package/dist/template/tests/core/sms-consent.test.ts +295 -0
  2458. package/dist/template/tests/core/sms-keywords.test.ts +139 -0
  2459. package/dist/template/tests/core/sms-policy.test.ts +348 -0
  2460. package/dist/template/tests/core/sms-registration.test.ts +304 -0
  2461. package/dist/template/tests/core/sms-templates.test.ts +61 -0
  2462. package/dist/template/tests/core/sms.test.ts +563 -0
  2463. package/dist/template/tests/core/social-http.test.ts +91 -0
  2464. package/dist/template/tests/core/spec-reconciliation.test.ts +62 -0
  2465. package/dist/template/tests/core/spine.test.ts +682 -0
  2466. package/dist/template/tests/core/standalone-artifact.test.ts +40 -0
  2467. package/dist/template/tests/core/storage.test.ts +360 -0
  2468. package/dist/template/tests/core/store-sections.test.ts +466 -0
  2469. package/dist/template/tests/core/storefront-commerce.test.ts +431 -0
  2470. package/dist/template/tests/core/tasks.test.ts +356 -0
  2471. package/dist/template/tests/core/tax-templates.test.ts +129 -0
  2472. package/dist/template/tests/core/templates.test.ts +148 -0
  2473. package/dist/template/tests/core/theme.test.ts +64 -0
  2474. package/dist/template/tests/core/time-entries.test.ts +343 -0
  2475. package/dist/template/tests/core/tokens.test.ts +167 -0
  2476. package/dist/template/tests/core/transactional-jobs.test.ts +590 -0
  2477. package/dist/template/tests/core/two-factor.test.ts +297 -0
  2478. package/dist/template/tests/core/update-admin.test.ts +103 -0
  2479. package/dist/template/tests/core/update-apply.test.ts +34 -0
  2480. package/dist/template/tests/core/update-catalog.test.ts +172 -0
  2481. package/dist/template/tests/core/update-check.test.ts +114 -0
  2482. package/dist/template/tests/core/update-cli.test.ts +119 -0
  2483. package/dist/template/tests/core/update-escalation.test.ts +178 -0
  2484. package/dist/template/tests/core/update-feed.test.ts +104 -0
  2485. package/dist/template/tests/core/update-fork.test.ts +244 -0
  2486. package/dist/template/tests/core/update-policy.test.ts +73 -0
  2487. package/dist/template/tests/core/update-preflight.test.ts +59 -0
  2488. package/dist/template/tests/core/update-release.test.ts +127 -0
  2489. package/dist/template/tests/core/update-seams.test.ts +94 -0
  2490. package/dist/template/tests/core/update-targets.test.ts +325 -0
  2491. package/dist/template/tests/core/upgrade-gate.test.ts +36 -0
  2492. package/dist/template/tests/core/waitlists-and-policy.test.ts +544 -0
  2493. package/dist/template/tests/core/webhooks.test.ts +742 -0
  2494. package/dist/template/tests/core/workflow-integrity.test.ts +142 -0
  2495. package/dist/template/tests/core/zoned.test.ts +84 -0
  2496. package/dist/template/tests/fixtures/c1019-chain.catalog +6597 -0
  2497. package/dist/template/tests/fixtures/locales.ts +55 -0
  2498. package/dist/template/tests/fixtures/sample-plugin/README.md +3 -0
  2499. package/dist/template/tests/fixtures/sample-plugin/plugin.json +10 -0
  2500. package/dist/template/tests/helpers/booking-time.ts +11 -0
  2501. package/dist/template/tests/helpers/database-lock.ts +18 -0
  2502. package/dist/template/tests/helpers/mail.ts +17 -0
  2503. package/dist/template/tests/helpers/performance-boot.ts +194 -0
  2504. package/dist/template/tests/helpers/performance-browser.ts +684 -0
  2505. package/dist/template/tests/helpers/performance-migration.ts +165 -0
  2506. package/dist/template/tests/helpers/performance.ts +203 -0
  2507. package/dist/template/tests/helpers/queue-performance.ts +62 -0
  2508. package/dist/template/tests/helpers/spine.ts +93 -0
  2509. package/dist/template/tests/host/test_docker_updater.py +630 -0
  2510. package/dist/template/tests/host/test_host_updater.py +430 -0
  2511. package/dist/template/tests/modules/ads-measurement.test.ts +360 -0
  2512. package/dist/template/tests/modules/ads-serving.test.ts +694 -0
  2513. package/dist/template/tests/modules/ads-third-party.test.ts +353 -0
  2514. package/dist/template/tests/modules/ads.test.ts +377 -0
  2515. package/dist/template/tests/modules/adversarial-customer-privacy.test.ts +88 -0
  2516. package/dist/template/tests/modules/assessments.test.ts +581 -0
  2517. package/dist/template/tests/modules/assistant-grounding.test.ts +182 -0
  2518. package/dist/template/tests/modules/assistant-guardrails.test.ts +341 -0
  2519. package/dist/template/tests/modules/assistant.test.ts +665 -0
  2520. package/dist/template/tests/modules/automations-guardrails.test.ts +319 -0
  2521. package/dist/template/tests/modules/automations-runtime.test.ts +467 -0
  2522. package/dist/template/tests/modules/automations.test.ts +426 -0
  2523. package/dist/template/tests/modules/broadcasts.test.ts +769 -0
  2524. package/dist/template/tests/modules/calculators.test.ts +407 -0
  2525. package/dist/template/tests/modules/customer-surfaces.test.ts +223 -0
  2526. package/dist/template/tests/modules/documents.test.ts +401 -0
  2527. package/dist/template/tests/modules/form-fields.test.ts +73 -0
  2528. package/dist/template/tests/modules/funnel.test.ts +208 -0
  2529. package/dist/template/tests/modules/help-centre.test.ts +285 -0
  2530. package/dist/template/tests/modules/location-pages.test.ts +232 -0
  2531. package/dist/template/tests/modules/loyalty-rewards.test.ts +490 -0
  2532. package/dist/template/tests/modules/loyalty.test.ts +484 -0
  2533. package/dist/template/tests/modules/one-audience.test.ts +263 -0
  2534. package/dist/template/tests/modules/popups.test.ts +769 -0
  2535. package/dist/template/tests/modules/referrals-commission.test.ts +740 -0
  2536. package/dist/template/tests/modules/referrals.test.ts +349 -0
  2537. package/dist/template/tests/modules/reporting-exports.test.ts +1082 -0
  2538. package/dist/template/tests/modules/reporting.test.ts +384 -0
  2539. package/dist/template/tests/modules/share.test.ts +431 -0
  2540. package/dist/template/tests/modules/social-composer.test.ts +251 -0
  2541. package/dist/template/tests/modules/social-gbp.test.ts +281 -0
  2542. package/dist/template/tests/modules/social-ingest.test.ts +295 -0
  2543. package/dist/template/tests/modules/social-onboarding.test.ts +109 -0
  2544. package/dist/template/tests/modules/social.test.ts +289 -0
  2545. package/dist/template/tests/modules/subscription-billing.test.ts +483 -0
  2546. package/dist/template/tests/modules/subscriptions.test.ts +582 -0
  2547. package/dist/template/tests/modules/templates.test.ts +358 -0
  2548. package/dist/template/tests/modules/translate.test.ts +128 -0
  2549. package/dist/template/tests/setup/migrate.ts +20 -0
  2550. package/dist/template/tsconfig.json +54 -0
  2551. package/dist/template/vitest.config.ts +91 -0
  2552. package/dist/template-manifest.json +12746 -0
  2553. package/package.json +22 -7
@@ -0,0 +1,1467 @@
1
+ // Copyright (C) 2026 Tony Aly
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Transaction-safe invoice, payment, refund, and credit-note state machines.
4
+
5
+ import { createHash } from "node:crypto";
6
+ import { and, asc, desc, eq, inArray, ne, or, sql } from "drizzle-orm";
7
+ import { z } from "zod";
8
+ import {
9
+ registerContactReference,
10
+ } from "@/core/contacts/service";
11
+ import { contacts } from "@/core/contacts/schema";
12
+ import { registerContactPrivacySource } from "@/core/privacy/service";
13
+ import {
14
+ clipSnippet,
15
+ matchesIlike,
16
+ registerSearchSource,
17
+ } from "@/core/search/registry";
18
+ import {
19
+ actorString,
20
+ defineService,
21
+ permits,
22
+ ServiceError,
23
+ type ServiceContext,
24
+ type Tx,
25
+ } from "@/core/service";
26
+ import { listed, uuid } from "@/core/contract";
27
+ import {
28
+ creditNoteRow,
29
+ invoiceBundle as invoiceBundleOutput,
30
+ invoiceRow,
31
+ paymentReceipt,
32
+ paymentRow,
33
+ refundRow,
34
+ } from "./contract";
35
+ import {
36
+ creditNoteLines,
37
+ creditNotes,
38
+ invoiceLines,
39
+ invoiceSequences,
40
+ invoices,
41
+ moneyStateEvents,
42
+ paymentMethods,
43
+ paymentProviderCustomers,
44
+ payments,
45
+ refunds,
46
+ taxExemptions,
47
+ taxLines,
48
+ } from "./schema";
49
+ import {
50
+ extendMinor,
51
+ subtractMinor,
52
+ sumMinor,
53
+ } from "./money";
54
+ import { quoteTax } from "./tax-service";
55
+ import { allocateSettledPayment } from "./payment-plan-ledger";
56
+
57
+ const currency = z.string().trim().toUpperCase().regex(/^[A-Z]{3}$/);
58
+ const minor = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
59
+ const positiveMinor = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
60
+ const quantityMicros = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
61
+ const idempotencyKey = z.string().trim().min(1).max(240);
62
+ const boundedObject = z
63
+ .record(z.string().min(1).max(100), z.unknown())
64
+ .refine((value) => {
65
+ try {
66
+ return JSON.stringify(value).length <= 65_536;
67
+ } catch {
68
+ return false;
69
+ }
70
+ }, "Metadata must be JSON and no larger than 64 KiB.");
71
+ const address = z.object({
72
+ name: z.string().trim().min(1).max(200).optional(),
73
+ street1: z.string().trim().min(1).max(300).optional(),
74
+ street2: z.string().trim().max(300).optional(),
75
+ city: z.string().trim().max(200).optional(),
76
+ region: z.string().trim().toUpperCase().max(100).optional(),
77
+ postalCode: z.string().trim().toUpperCase().max(30).optional(),
78
+ country: z.string().trim().toUpperCase().regex(/^[A-Z]{2}$/),
79
+ });
80
+ const taxAddress = address.pick({ city: true, region: true, postalCode: true, country: true });
81
+ const lineInput = z.object({
82
+ sourceType: z.string().trim().max(80).optional(),
83
+ sourceId: z.string().trim().max(240).optional(),
84
+ description: z.string().trim().min(1).max(1_000),
85
+ quantityMicros,
86
+ unitAmountMinor: minor,
87
+ discountMinor: minor.default(0),
88
+ taxCategoryCode: z
89
+ .string()
90
+ .trim()
91
+ .toLowerCase()
92
+ .regex(/^[a-z0-9]+(?:_[a-z0-9]+)*$/)
93
+ .max(80)
94
+ .default("standard"),
95
+ requiresShipping: z.boolean().default(false),
96
+ snapshot: boundedObject.default({}),
97
+ });
98
+ const taxChoice = z.discriminatedUnion("mode", [
99
+ z.object({
100
+ mode: z.literal("calculate"),
101
+ origin: taxAddress,
102
+ destination: taxAddress,
103
+ }),
104
+ z.object({
105
+ mode: z.literal("not_applicable"),
106
+ reason: z.string().trim().min(3).max(1_000),
107
+ }),
108
+ ]);
109
+
110
+ function canonical(value: unknown): string {
111
+ if (value instanceof Date) return JSON.stringify(value.toISOString());
112
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
113
+ if (value && typeof value === "object") {
114
+ return `{${Object.entries(value as Record<string, unknown>)
115
+ .sort(([left], [right]) => left.localeCompare(right))
116
+ .map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`)
117
+ .join(",")}}`;
118
+ }
119
+ return JSON.stringify(value) ?? "null";
120
+ }
121
+
122
+ function requestHash(value: unknown): string {
123
+ return createHash("sha256").update(canonical(value), "utf8").digest("hex");
124
+ }
125
+
126
+ async function lock(tx: Tx, kind: string, id: string): Promise<void> {
127
+ await tx.execute(sql`select pg_advisory_xact_lock(hashtext(${`${kind}:${id}`}))`);
128
+ }
129
+
130
+ async function stateEvent(
131
+ ctx: ServiceContext,
132
+ subjectType: "invoice" | "payment" | "refund" | "credit_note" | "dispute" | "payment_plan" | "payout",
133
+ subjectId: string,
134
+ fromState: string | null,
135
+ toState: string,
136
+ reason?: string,
137
+ metadata: Record<string, unknown> = {},
138
+ ): Promise<void> {
139
+ await ctx.tx.insert(moneyStateEvents).values({
140
+ subjectType,
141
+ subjectId,
142
+ fromState,
143
+ toState,
144
+ reason,
145
+ actor: actorString(ctx.actor),
146
+ metadata,
147
+ });
148
+ }
149
+
150
+ async function allocateNumber(
151
+ tx: Tx,
152
+ key: string,
153
+ prefix: string,
154
+ ): Promise<string> {
155
+ await tx
156
+ .insert(invoiceSequences)
157
+ .values({ key, prefix, nextValue: 1, padding: 6 })
158
+ .onConflictDoNothing();
159
+ const [sequence] = await tx
160
+ .select()
161
+ .from(invoiceSequences)
162
+ .where(eq(invoiceSequences.key, key))
163
+ .for("update");
164
+ if (!sequence) throw new Error(`Invoice sequence ${key} disappeared.`);
165
+ await tx
166
+ .update(invoiceSequences)
167
+ .set({ nextValue: sequence.nextValue + 1 })
168
+ .where(eq(invoiceSequences.key, key));
169
+ return `${sequence.prefix}${String(sequence.nextValue).padStart(sequence.padding, "0")}`;
170
+ }
171
+
172
+ async function invoiceBundle(tx: Tx, id: string) {
173
+ const [invoice] = await tx.select().from(invoices).where(eq(invoices.id, id)).limit(1);
174
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
175
+ const [lines, taxes, invoicePayments, invoiceRefunds, notes] = await Promise.all([
176
+ tx.select().from(invoiceLines).where(eq(invoiceLines.invoiceId, id)).orderBy(asc(invoiceLines.position)),
177
+ tx.select().from(taxLines).where(eq(taxLines.invoiceId, id)).orderBy(asc(taxLines.priority)),
178
+ tx.select().from(payments).where(eq(payments.invoiceId, id)).orderBy(asc(payments.createdAt)),
179
+ tx.select().from(refunds).where(eq(refunds.invoiceId, id)).orderBy(asc(refunds.createdAt)),
180
+ tx.select().from(creditNotes).where(eq(creditNotes.invoiceId, id)).orderBy(asc(creditNotes.createdAt)),
181
+ ]);
182
+ return { invoice, lines, taxLines: taxes, payments: invoicePayments, refunds: invoiceRefunds, creditNotes: notes };
183
+ }
184
+
185
+ interface PointerRow {
186
+ id: string;
187
+ contactId: string;
188
+ }
189
+
190
+ function registerPointer(
191
+ table: "invoices" | "tax_exemptions" | "payment_provider_customers" | "payment_methods",
192
+ selectRows: (tx: Tx, ids: string[]) => Promise<PointerRow[]>,
193
+ repointRows: (tx: Tx, from: string, to: string) => Promise<unknown>,
194
+ ): void {
195
+ registerContactReference({
196
+ table,
197
+ repoint: repointRows,
198
+ captureForUndo: async (tx, duplicateId, survivingId) => ({
199
+ state: await selectRows(tx, [duplicateId, survivingId]),
200
+ undoable: true,
201
+ }),
202
+ restoreAfterUndo: async (tx, beforeState, afterState, duplicateId) => {
203
+ const schema = z.array(z.object({ id: z.string().uuid(), contactId: z.string().uuid() }));
204
+ const before = schema.parse(beforeState);
205
+ const after = schema.parse(afterState);
206
+ const current = after.length ? await selectRows(tx, [...new Set(after.map((row) => row.contactId))]) : [];
207
+ const currentById = new Map(current.map((row) => [row.id, row.contactId]));
208
+ if (current.length !== after.length || after.some((row) => currentById.get(row.id) !== row.contactId)) {
209
+ throw new ServiceError(
210
+ "conflict",
211
+ `A ${table.replaceAll("_", " ")} record changed after this merge. Leave the merge in place or restore that record first.`,
212
+ );
213
+ }
214
+ const movedIds = before.filter((row) => row.contactId === duplicateId).map((row) => row.id);
215
+ if (movedIds.length === 0) return;
216
+ if (table === "invoices") {
217
+ await tx.update(invoices).set({ contactId: duplicateId }).where(inArray(invoices.id, movedIds));
218
+ } else if (table === "tax_exemptions") {
219
+ await tx.update(taxExemptions).set({ contactId: duplicateId }).where(inArray(taxExemptions.id, movedIds));
220
+ } else if (table === "payment_provider_customers") {
221
+ await tx.update(paymentProviderCustomers).set({ contactId: duplicateId }).where(inArray(paymentProviderCustomers.id, movedIds));
222
+ } else {
223
+ await tx.update(paymentMethods).set({ contactId: duplicateId }).where(inArray(paymentMethods.id, movedIds));
224
+ }
225
+ },
226
+ });
227
+ }
228
+
229
+ registerPointer(
230
+ "invoices",
231
+ (tx, ids) => tx.select({ id: invoices.id, contactId: invoices.contactId }).from(invoices).where(inArray(invoices.contactId, ids)),
232
+ (tx, from, to) => tx.update(invoices).set({ contactId: to }).where(eq(invoices.contactId, from)),
233
+ );
234
+ registerPointer(
235
+ "tax_exemptions",
236
+ (tx, ids) => tx.select({ id: taxExemptions.id, contactId: taxExemptions.contactId }).from(taxExemptions).where(inArray(taxExemptions.contactId, ids)),
237
+ (tx, from, to) => tx.update(taxExemptions).set({ contactId: to }).where(eq(taxExemptions.contactId, from)),
238
+ );
239
+ registerPointer(
240
+ "payment_provider_customers",
241
+ (tx, ids) => tx.select({ id: paymentProviderCustomers.id, contactId: paymentProviderCustomers.contactId }).from(paymentProviderCustomers).where(inArray(paymentProviderCustomers.contactId, ids)),
242
+ (tx, from, to) => tx.update(paymentProviderCustomers).set({ contactId: to }).where(eq(paymentProviderCustomers.contactId, from)),
243
+ );
244
+ registerPointer(
245
+ "payment_methods",
246
+ (tx, ids) => tx.select({ id: paymentMethods.id, contactId: paymentMethods.contactId }).from(paymentMethods).where(inArray(paymentMethods.contactId, ids)),
247
+ (tx, from, to) => tx.update(paymentMethods).set({ contactId: to }).where(eq(paymentMethods.contactId, from)),
248
+ );
249
+
250
+ registerSearchSource({
251
+ kind: "invoice",
252
+ readService: "invoicing.list",
253
+ module: "invoicing",
254
+ tables: ["invoices"],
255
+ search: async ({ tx, pattern, limit }) => {
256
+ const rows = await tx
257
+ .select({
258
+ id: invoices.id,
259
+ number: invoices.number,
260
+ memo: invoices.memo,
261
+ contactId: invoices.contactId,
262
+ })
263
+ .from(invoices)
264
+ .where(or(matchesIlike(invoices.number, pattern), matchesIlike(invoices.memo, pattern)))
265
+ .orderBy(desc(invoices.updatedAt))
266
+ .limit(limit);
267
+ return rows.map((row) => ({
268
+ kind: "invoice",
269
+ id: row.id,
270
+ title: row.number ?? clipSnippet(row.memo) ?? "Invoice",
271
+ href: `/admin/invoices/${row.id}`,
272
+ snippet: clipSnippet(row.memo),
273
+ contactId: row.contactId,
274
+ module: "invoicing",
275
+ }));
276
+ },
277
+ });
278
+
279
+ registerContactPrivacySource({
280
+ scope: "commerce.money",
281
+ tables: ["invoices", "tax_exemptions", "payment_provider_customers", "payment_methods"],
282
+ exportData: async (tx, contactId) => {
283
+ const owned = await tx.select({ id: invoices.id }).from(invoices).where(eq(invoices.contactId, contactId));
284
+ const ids = owned.map((row) => row.id);
285
+ return {
286
+ invoices: await Promise.all(ids.map((id) => invoiceBundle(tx, id))),
287
+ taxExemptions: await tx.select().from(taxExemptions).where(eq(taxExemptions.contactId, contactId)),
288
+ paymentProviderCustomers: await tx.select().from(paymentProviderCustomers).where(eq(paymentProviderCustomers.contactId, contactId)),
289
+ paymentMethods: await tx.select().from(paymentMethods).where(eq(paymentMethods.contactId, contactId)),
290
+ };
291
+ },
292
+ erase: async (tx, contactId) => {
293
+ const owned = await tx.select({ id: invoices.id }).from(invoices).where(eq(invoices.contactId, contactId));
294
+ const ids = owned.map((row) => row.id);
295
+ let affected = 0;
296
+ if (ids.length) {
297
+ affected += (
298
+ await tx
299
+ .update(invoices)
300
+ .set({ billingAddress: {}, customerTaxId: null, memo: null, schedule: null })
301
+ .where(inArray(invoices.id, ids))
302
+ .returning({ id: invoices.id })
303
+ ).length;
304
+ await tx.update(payments).set({ failureMessage: null, metadata: {} }).where(inArray(payments.invoiceId, ids));
305
+ await tx.update(refunds).set({ failureMessage: null, reason: null }).where(inArray(refunds.invoiceId, ids));
306
+ }
307
+ affected += (
308
+ await tx
309
+ .update(taxExemptions)
310
+ .set({ certificateRef: null, status: "revoked" })
311
+ .where(eq(taxExemptions.contactId, contactId))
312
+ .returning({ id: taxExemptions.id })
313
+ ).length;
314
+ affected += (
315
+ await tx.delete(paymentMethods).where(eq(paymentMethods.contactId, contactId)).returning({ id: paymentMethods.id })
316
+ ).length;
317
+ affected += (
318
+ await tx.delete(paymentProviderCustomers).where(eq(paymentProviderCustomers.contactId, contactId)).returning({ id: paymentProviderCustomers.id })
319
+ ).length;
320
+ return { affected };
321
+ },
322
+ });
323
+
324
+ const invoiceListRow = invoiceRow.extend({
325
+ sequenceKey: z.string().optional(),
326
+ idempotencyKey: z.string().optional(),
327
+ requestHash: z.string().optional(),
328
+ });
329
+
330
+ export const listInvoices = defineService({
331
+ name: "invoicing.list",
332
+ summary: "List invoices by contact or lifecycle state.",
333
+ kind: "query",
334
+ permission: "scoped",
335
+ // C8.11: the customer this asks about may ask it themselves. The
336
+ // contract layer verifies the field is present and is their own contact
337
+ // before the handler runs, so this widens what a customer can *see*
338
+ // about themselves and nothing else.
339
+ selfService: { contactField: "contactId" },
340
+ input: z.object({
341
+ contactId: z.string().uuid().optional(),
342
+ status: z.enum(["draft", "sent", "viewed", "partially_paid", "paid", "overdue", "void", "refunded"]).optional(),
343
+ limit: z.number().int().min(1).max(500).default(100),
344
+ }),
345
+ output: listed(invoiceListRow),
346
+ handler: async (input, ctx): Promise<z.output<typeof invoiceListRow>[]> => {
347
+ const staffRead = permits(ctx.actor, "scoped", "invoicing.list", "query");
348
+ const filters = [
349
+ input.contactId ? eq(invoices.contactId, input.contactId) : undefined,
350
+ input.status ? eq(invoices.status, input.status) : undefined,
351
+ staffRead ? undefined : and(ne(invoices.status, "draft"), sql`${invoices.issuedAt} is not null`),
352
+ ].filter((value): value is NonNullable<typeof value> => Boolean(value));
353
+ const found = await ctx.tx
354
+ .select()
355
+ .from(invoices)
356
+ .where(filters.length ? and(...filters) : undefined)
357
+ .orderBy(desc(invoices.createdAt))
358
+ .limit(input.limit);
359
+ if (staffRead) return found;
360
+ // Named projection: future provider/workflow columns must not silently
361
+ // become customer-visible just because this shared query gains a column.
362
+ return found.map(invoice => ({
363
+ id: invoice.id, contactId: invoice.contactId, number: invoice.number,
364
+ sourceType: invoice.sourceType, sourceId: invoice.sourceId, status: invoice.status,
365
+ currency: invoice.currency, subtotalMinor: invoice.subtotalMinor,
366
+ discountMinor: invoice.discountMinor, shippingMinor: invoice.shippingMinor,
367
+ taxMinor: invoice.taxMinor, taxZoneId: invoice.taxZoneId, totalMinor: invoice.totalMinor,
368
+ paidMinor: invoice.paidMinor, refundedMinor: invoice.refundedMinor,
369
+ billingAddress: invoice.billingAddress, customerTaxId: invoice.customerTaxId,
370
+ requiredTaxLegend: invoice.requiredTaxLegend, memo: invoice.memo,
371
+ schedule: invoice.schedule, depositOfInvoiceId: invoice.depositOfInvoiceId,
372
+ dueAt: invoice.dueAt, issuedAt: invoice.issuedAt, viewedAt: invoice.viewedAt,
373
+ paidAt: invoice.paidAt, voidedAt: invoice.voidedAt,
374
+ createdAt: invoice.createdAt, updatedAt: invoice.updatedAt,
375
+ }));
376
+ },
377
+ });
378
+
379
+ export const getInvoice = defineService({
380
+ name: "invoicing.get",
381
+ summary: "Read one invoice with immutable lines, tax evidence, payments, refunds, and credits.",
382
+ kind: "query",
383
+ permission: "scoped",
384
+ input: z.object({ id: z.string().uuid() }),
385
+ output: invoiceBundleOutput,
386
+ handler: (input, ctx) => invoiceBundle(ctx.tx, input.id),
387
+ });
388
+
389
+ export const getPaymentReceipt = defineService({
390
+ name: "invoicing.receipt",
391
+ summary: "Build the stable receipt record for one successful payment.",
392
+ kind: "query",
393
+ permission: "scoped",
394
+ input: z.object({ paymentId: z.string().uuid() }),
395
+ output: paymentReceipt,
396
+ handler: async (input, ctx) => {
397
+ const [payment] = await ctx.tx.select().from(payments).where(eq(payments.id, input.paymentId)).limit(1);
398
+ if (!payment) throw new ServiceError("not_found", "That payment is not here.");
399
+ if (payment.status !== "succeeded" || !payment.processedAt || !payment.providerRef) {
400
+ throw new ServiceError("conflict", "A receipt exists only after payment succeeds.");
401
+ }
402
+ const bundle = await invoiceBundle(ctx.tx, payment.invoiceId);
403
+ if (!bundle.invoice.number || !bundle.invoice.issuedAt) {
404
+ throw new ServiceError("conflict", "That payment does not belong to an issued invoice.");
405
+ }
406
+ const [customer] = await ctx.tx
407
+ .select({ id: contacts.id, name: contacts.name, email: contacts.email })
408
+ .from(contacts)
409
+ .where(eq(contacts.id, bundle.invoice.contactId))
410
+ .limit(1);
411
+ const paymentRefunds = bundle.refunds.filter(
412
+ (refund) => refund.paymentId === payment.id && refund.status === "succeeded",
413
+ );
414
+ return {
415
+ receiptNumber: `${bundle.invoice.number}-PAY-${payment.id.slice(0, 8).toUpperCase()}`,
416
+ issuedAt: payment.processedAt,
417
+ invoice: {
418
+ id: bundle.invoice.id,
419
+ number: bundle.invoice.number,
420
+ issuedAt: bundle.invoice.issuedAt,
421
+ currency: bundle.invoice.currency,
422
+ totalMinor: bundle.invoice.totalMinor,
423
+ },
424
+ customer: customer ?? { id: bundle.invoice.contactId, name: null, email: null },
425
+ payment: {
426
+ id: payment.id,
427
+ provider: payment.provider,
428
+ providerRef: payment.providerRef,
429
+ method: payment.method,
430
+ amountMinor: payment.amountMinor,
431
+ refundedMinor: payment.refundedMinor,
432
+ netMinor: payment.amountMinor - payment.refundedMinor,
433
+ },
434
+ lines: bundle.lines,
435
+ taxLines: bundle.taxLines,
436
+ refunds: paymentRefunds,
437
+ requiredTaxLegend: bundle.invoice.requiredTaxLegend,
438
+ };
439
+ },
440
+ });
441
+
442
+ export const reconcileMoney = defineService({
443
+ name: "invoicing.reconciliation",
444
+ summary: "Reconcile invoice and payment balances against successful money movements.",
445
+ kind: "query",
446
+ permission: "scoped",
447
+ input: z.object({ limit: z.number().int().min(1).max(5_000).default(1_000) }),
448
+ output: z.object({
449
+ balanced: z.boolean(),
450
+ checked: z.object({
451
+ invoices: z.number().int(),
452
+ payments: z.number().int(),
453
+ refunds: z.number().int(),
454
+ }),
455
+ discrepancies: listed(
456
+ z.object({
457
+ subjectType: z.enum(["invoice", "payment"]),
458
+ subjectId: uuid,
459
+ field: z.string(),
460
+ recordedMinor: z.number().int(),
461
+ calculatedMinor: z.number().int(),
462
+ }),
463
+ ),
464
+ }),
465
+ handler: async (input, ctx) => {
466
+ const invoiceRows = await ctx.tx
467
+ .select()
468
+ .from(invoices)
469
+ .orderBy(desc(invoices.createdAt))
470
+ .limit(input.limit);
471
+ const invoiceIds = invoiceRows.map((invoice) => invoice.id);
472
+ const [paymentRows, refundRows] = invoiceIds.length
473
+ ? await Promise.all([
474
+ ctx.tx.select().from(payments).where(inArray(payments.invoiceId, invoiceIds)),
475
+ ctx.tx.select().from(refunds).where(inArray(refunds.invoiceId, invoiceIds)),
476
+ ])
477
+ : [[], []];
478
+ const discrepancies: Array<{
479
+ subjectType: "invoice" | "payment";
480
+ subjectId: string;
481
+ field: string;
482
+ recordedMinor: number;
483
+ calculatedMinor: number;
484
+ }> = [];
485
+ for (const invoice of invoiceRows) {
486
+ const calculatedPaid = sumMinor(
487
+ paymentRows
488
+ .filter((payment) => payment.invoiceId === invoice.id && payment.status === "succeeded")
489
+ .map((payment) => payment.amountMinor),
490
+ "Reconciled invoice payments",
491
+ );
492
+ const calculatedRefunded = sumMinor(
493
+ refundRows
494
+ .filter((refund) => refund.invoiceId === invoice.id && refund.status === "succeeded")
495
+ .map((refund) => refund.amountMinor),
496
+ "Reconciled invoice refunds",
497
+ );
498
+ if (invoice.paidMinor !== calculatedPaid) {
499
+ discrepancies.push({
500
+ subjectType: "invoice",
501
+ subjectId: invoice.id,
502
+ field: "paidMinor",
503
+ recordedMinor: invoice.paidMinor,
504
+ calculatedMinor: calculatedPaid,
505
+ });
506
+ }
507
+ if (invoice.refundedMinor !== calculatedRefunded) {
508
+ discrepancies.push({
509
+ subjectType: "invoice",
510
+ subjectId: invoice.id,
511
+ field: "refundedMinor",
512
+ recordedMinor: invoice.refundedMinor,
513
+ calculatedMinor: calculatedRefunded,
514
+ });
515
+ }
516
+ }
517
+ for (const payment of paymentRows) {
518
+ const calculatedRefunded = sumMinor(
519
+ refundRows
520
+ .filter((refund) => refund.paymentId === payment.id && refund.status === "succeeded")
521
+ .map((refund) => refund.amountMinor),
522
+ "Reconciled payment refunds",
523
+ );
524
+ if (payment.refundedMinor !== calculatedRefunded) {
525
+ discrepancies.push({
526
+ subjectType: "payment",
527
+ subjectId: payment.id,
528
+ field: "refundedMinor",
529
+ recordedMinor: payment.refundedMinor,
530
+ calculatedMinor: calculatedRefunded,
531
+ });
532
+ }
533
+ }
534
+ return {
535
+ balanced: discrepancies.length === 0,
536
+ checked: {
537
+ invoices: invoiceRows.length,
538
+ payments: paymentRows.length,
539
+ refunds: refundRows.length,
540
+ },
541
+ discrepancies,
542
+ };
543
+ },
544
+ });
545
+
546
+ const createDraftInput = z.object({
547
+ contactId: z.string().uuid(),
548
+ currency,
549
+ sourceType: z.enum(["order", "quote", "booking", "subscription", "manual", "deposit", "balance", "tip", "pay_what_you_want", "late_fee", "unlock", "ad_campaign"]).default("manual"),
550
+ sourceId: z.string().trim().max(240).optional(),
551
+ idempotencyKey,
552
+ lines: z.array(lineInput).min(1).max(1_000),
553
+ shippingMinor: minor.default(0),
554
+ billingAddress: address.optional(),
555
+ customerTaxId: z.string().trim().max(200).optional(),
556
+ memo: z.string().trim().max(4_000).optional(),
557
+ schedule: boundedObject.optional(),
558
+ depositOfInvoiceId: z.string().uuid().optional(),
559
+ dueAt: z.coerce.date().optional(),
560
+ tax: taxChoice,
561
+ });
562
+
563
+ export const createDraftInvoice = defineService({
564
+ name: "invoicing.createDraft",
565
+ summary: "Create one idempotent draft with fixed-point lines and explicit tax treatment.",
566
+ kind: "mutation",
567
+ permission: "scoped",
568
+ input: createDraftInput,
569
+ output: invoiceBundleOutput,
570
+ handler: async (input, ctx) => {
571
+ const hash = requestHash(input);
572
+ await lock(ctx.tx, "invoice-idempotency", input.idempotencyKey);
573
+ const [existing] = await ctx.tx
574
+ .select({ id: invoices.id, requestHash: invoices.requestHash })
575
+ .from(invoices)
576
+ .where(eq(invoices.idempotencyKey, input.idempotencyKey))
577
+ .limit(1);
578
+ if (existing) {
579
+ if (existing.requestHash !== hash) {
580
+ throw new ServiceError("conflict", "That invoice idempotency key was already used for different contents.");
581
+ }
582
+ return invoiceBundle(ctx.tx, existing.id);
583
+ }
584
+
585
+ if (input.depositOfInvoiceId) {
586
+ if (input.sourceType !== "balance") {
587
+ throw new ServiceError("validation", "Only a balance invoice can point to its deposit invoice.");
588
+ }
589
+ const [deposit] = await ctx.tx
590
+ .select()
591
+ .from(invoices)
592
+ .where(eq(invoices.id, input.depositOfInvoiceId))
593
+ .limit(1);
594
+ if (!deposit) throw new ServiceError("not_found", "That deposit invoice is not here.");
595
+ if (deposit.sourceType !== "deposit") {
596
+ throw new ServiceError("validation", "A balance invoice must point to an invoice created as a deposit.");
597
+ }
598
+ if (deposit.contactId !== input.contactId || deposit.currency !== input.currency) {
599
+ throw new ServiceError("validation", "A deposit and its balance must belong to the same contact and currency.");
600
+ }
601
+ }
602
+
603
+ const itemKeys = input.lines.map((_, index) => `line:${index}`);
604
+ const taxInput = {
605
+ currency: input.currency,
606
+ contactId: input.contactId,
607
+ items: input.lines.map((line, index) => ({
608
+ id: itemKeys[index]!,
609
+ quantityMicros: line.quantityMicros,
610
+ unitAmountMinor: line.unitAmountMinor,
611
+ discountMinor: line.discountMinor,
612
+ category: line.taxCategoryCode,
613
+ requiresShipping: line.requiresShipping,
614
+ })),
615
+ shippingMinor: input.shippingMinor,
616
+ };
617
+ const quote =
618
+ input.tax.mode === "calculate"
619
+ ? await ctx.call(quoteTax, {
620
+ ...taxInput,
621
+ origin: input.tax.origin,
622
+ destination: input.tax.destination,
623
+ })
624
+ : {
625
+ provider: "explicit_none" as const,
626
+ currency: input.currency,
627
+ lines: [],
628
+ totalTaxMinor: 0,
629
+ includedTaxMinor: 0,
630
+ explanation: [input.tax.reason],
631
+ zone: null,
632
+ };
633
+ const preDiscountQuote =
634
+ input.tax.mode === "calculate" && quote.lines.some((line) => line.inclusive)
635
+ ? await ctx.call(quoteTax, {
636
+ ...taxInput,
637
+ items: taxInput.items.map((line) => ({ ...line, discountMinor: 0 })),
638
+ origin: input.tax.origin,
639
+ destination: input.tax.destination,
640
+ })
641
+ : quote;
642
+
643
+ const calculatedLines = input.lines.map((line, index) => {
644
+ const key = itemKeys[index]!;
645
+ const grossSubtotal = extendMinor(line.unitAmountMinor, line.quantityMicros);
646
+ if (line.discountMinor > grossSubtotal) {
647
+ throw new ServiceError("validation", `Line ${index + 1}'s discount exceeds its extended amount.`);
648
+ }
649
+ const currentTax = quote.lines.filter((tax) => tax.itemId === key);
650
+ const beforeTax = preDiscountQuote.lines.filter((tax) => tax.itemId === key);
651
+ const includedAfter = sumMinor(currentTax.filter((tax) => tax.inclusive).map((tax) => tax.taxMinor), "Included line tax");
652
+ const includedBefore = sumMinor(beforeTax.filter((tax) => tax.inclusive).map((tax) => tax.taxMinor), "Included pre-discount tax");
653
+ const taxDiscount = subtractMinor(includedBefore, includedAfter, "Included-tax discount");
654
+ const subtotalMinor = subtractMinor(grossSubtotal, includedBefore, "Net line subtotal");
655
+ const discountMinor = subtractMinor(line.discountMinor, taxDiscount, "Net line discount");
656
+ const taxMinor = sumMinor(currentTax.map((tax) => tax.taxMinor), "Line tax");
657
+ return {
658
+ input: line,
659
+ key,
660
+ position: index,
661
+ subtotalMinor,
662
+ discountMinor,
663
+ taxMinor,
664
+ totalMinor: sumMinor([subtractMinor(subtotalMinor, discountMinor, "Net line"), taxMinor], "Line total"),
665
+ };
666
+ });
667
+ const shippingTaxes = quote.lines.filter((line) => !line.itemId);
668
+ const includedShippingTax = sumMinor(
669
+ shippingTaxes.filter((line) => line.inclusive).map((line) => line.taxMinor),
670
+ "Included shipping tax",
671
+ );
672
+ const netShippingMinor = subtractMinor(input.shippingMinor, includedShippingTax, "Net shipping");
673
+ const subtotalMinor = sumMinor(calculatedLines.map((line) => line.subtotalMinor), "Invoice subtotal");
674
+ const discountMinor = sumMinor(calculatedLines.map((line) => line.discountMinor), "Invoice discount");
675
+ const taxMinor = sumMinor(quote.lines.map((line) => line.taxMinor), "Invoice tax");
676
+ const totalMinor = sumMinor(
677
+ [subtractMinor(subtotalMinor, discountMinor, "Invoice subtotal after discount"), netShippingMinor, taxMinor],
678
+ "Invoice total",
679
+ );
680
+ const quoteDetails = quote as typeof quote & {
681
+ registration?: { number: string | null };
682
+ exemption?: { kind: string } | null;
683
+ };
684
+ const [invoice] = await ctx.tx
685
+ .insert(invoices)
686
+ .values({
687
+ contactId: input.contactId,
688
+ currency: input.currency,
689
+ sourceType: input.sourceType,
690
+ sourceId: input.sourceId,
691
+ idempotencyKey: input.idempotencyKey,
692
+ requestHash: hash,
693
+ subtotalMinor,
694
+ discountMinor,
695
+ shippingMinor: netShippingMinor,
696
+ taxMinor,
697
+ taxZoneId: quote.zone?.id,
698
+ totalMinor,
699
+ billingAddress: input.billingAddress,
700
+ customerTaxId: input.customerTaxId,
701
+ requiredTaxLegend:
702
+ quoteDetails.exemption?.kind === "reverse_charge"
703
+ ? "Tax not charged — reverse charge applies."
704
+ : input.tax.mode === "not_applicable"
705
+ ? input.tax.reason
706
+ : quote.totalTaxMinor === 0
707
+ ? quote.explanation.join(" ").slice(0, 4_000)
708
+ : undefined,
709
+ memo: input.memo,
710
+ schedule: input.schedule,
711
+ depositOfInvoiceId: input.depositOfInvoiceId,
712
+ dueAt: input.dueAt,
713
+ })
714
+ .returning();
715
+ const savedLines = await ctx.tx
716
+ .insert(invoiceLines)
717
+ .values(
718
+ calculatedLines.map((line) => ({
719
+ invoiceId: invoice!.id,
720
+ position: line.position,
721
+ sourceType: line.input.sourceType,
722
+ sourceId: line.input.sourceId,
723
+ description: line.input.description,
724
+ quantityMicros: line.input.quantityMicros,
725
+ unitAmountMinor: line.input.unitAmountMinor,
726
+ subtotalMinor: line.subtotalMinor,
727
+ discountMinor: line.discountMinor,
728
+ taxMinor: line.taxMinor,
729
+ totalMinor: line.totalMinor,
730
+ taxCategoryCode: line.input.taxCategoryCode,
731
+ snapshot: line.input.snapshot,
732
+ })),
733
+ )
734
+ .returning();
735
+ const lineIdByKey = new Map(savedLines.map((line) => [itemKeys[line.position]!, line.id]));
736
+ if (quote.lines.length) {
737
+ await ctx.tx.insert(taxLines).values(
738
+ quote.lines.map((line) => ({
739
+ invoiceId: invoice!.id,
740
+ invoiceLineId: line.itemId ? lineIdByKey.get(line.itemId) : undefined,
741
+ kind: quoteDetails.exemption ? "exemption" as const : line.itemId ? "item" as const : "shipping" as const,
742
+ rateName: line.name,
743
+ ratePpm: line.ratePartsPerMillion,
744
+ taxableMinor: line.taxableMinor,
745
+ amountMinor: line.taxMinor,
746
+ jurisdiction: line.jurisdiction,
747
+ registrationNumber: quoteDetails.registration?.number ?? undefined,
748
+ inclusive: line.inclusive,
749
+ compound: line.compound,
750
+ priority: line.priority,
751
+ exemptionKind: quoteDetails.exemption?.kind,
752
+ explanation: quote.explanation.join(" ").slice(0, 4_000),
753
+ })),
754
+ );
755
+ }
756
+ await stateEvent(ctx, "invoice", invoice!.id, null, "draft", "created");
757
+ await ctx.emitTimeline({
758
+ contactId: input.contactId,
759
+ eventType: "invoice.created",
760
+ subjectType: "invoice",
761
+ subjectId: invoice!.id,
762
+ payload: { currency: input.currency, totalMinor, sourceType: input.sourceType },
763
+ });
764
+ ctx.queueEvent("invoice.created", { invoiceId: invoice!.id, contactId: input.contactId, totalMinor, currency: input.currency });
765
+ ctx.setSubject("invoice", invoice!.id);
766
+ return invoiceBundle(ctx.tx, invoice!.id);
767
+ },
768
+ });
769
+
770
+ export const issueInvoice = defineService({
771
+ name: "invoicing.issue",
772
+ summary: "Allocate a gapless number and issue an immutable draft invoice.",
773
+ kind: "mutation",
774
+ permission: "scoped",
775
+ input: z.object({ id: z.string().uuid(), dueAt: z.coerce.date().optional() }),
776
+ output: invoiceBundleOutput,
777
+ handler: async (input, ctx) => {
778
+ await lock(ctx.tx, "invoice", input.id);
779
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, input.id)).limit(1);
780
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
781
+ if (invoice.status !== "draft") {
782
+ if (invoice.number) return invoiceBundle(ctx.tx, invoice.id);
783
+ throw new ServiceError("conflict", "Only a draft invoice can be issued.");
784
+ }
785
+ const number = await allocateNumber(ctx.tx, invoice.sequenceKey, "INV-");
786
+ const issuedAt = new Date();
787
+ const zero = invoice.totalMinor === 0;
788
+ const [updated] = await ctx.tx
789
+ .update(invoices)
790
+ .set({
791
+ number,
792
+ status: zero ? "paid" : "sent",
793
+ issuedAt,
794
+ dueAt: input.dueAt ?? invoice.dueAt,
795
+ ...(zero ? { paidAt: issuedAt } : {}),
796
+ })
797
+ .where(and(eq(invoices.id, invoice.id), eq(invoices.status, "draft")))
798
+ .returning();
799
+ if (!updated) throw new ServiceError("conflict", "That invoice changed while it was being issued.");
800
+ await stateEvent(ctx, "invoice", updated.id, "draft", updated.status, zero ? "zero_total" : "issued");
801
+ await ctx.emitTimeline({
802
+ contactId: updated.contactId,
803
+ eventType: zero ? "invoice.paid" : "invoice.sent",
804
+ subjectType: "invoice",
805
+ subjectId: updated.id,
806
+ payload: { number, currency: updated.currency, totalMinor: updated.totalMinor, sourceType: updated.sourceType },
807
+ });
808
+ ctx.queueEvent(zero ? "invoice.paid" : "invoice.sent", { invoiceId: updated.id, contactId: updated.contactId, number });
809
+ if (zero && updated.sourceType === "unlock") {
810
+ const { issueUnlock } = await import("@/core/entitlements/service");
811
+ await ctx.callAsSystem(issueUnlock, {
812
+ contactId: updated.contactId,
813
+ invoiceId: updated.id,
814
+ name: number,
815
+ resource: { kind: "content", selector: updated.sourceId ?? updated.id },
816
+ });
817
+ }
818
+ ctx.setSubject("invoice", updated.id);
819
+ return invoiceBundle(ctx.tx, updated.id);
820
+ },
821
+ });
822
+
823
+ export const markInvoiceViewed = defineService({
824
+ name: "invoicing.markViewed",
825
+ summary: "Record the first verified customer view of a sent invoice.",
826
+ kind: "mutation",
827
+ permission: "scoped",
828
+ input: z.object({ id: z.string().uuid() }),
829
+ output: invoiceRow,
830
+ handler: async (input, ctx) => {
831
+ await lock(ctx.tx, "invoice", input.id);
832
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, input.id)).limit(1);
833
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
834
+ if (invoice.status === "viewed" || invoice.viewedAt) return invoice;
835
+ if (!["sent", "overdue", "partially_paid"].includes(invoice.status)) throw new ServiceError("conflict", "Only an open invoice can be marked viewed.");
836
+ const status = invoice.status === "sent" ? "viewed" : invoice.status;
837
+ const [updated] = await ctx.tx.update(invoices).set({ status, viewedAt: new Date() }).where(eq(invoices.id, invoice.id)).returning();
838
+ if (status !== invoice.status) await stateEvent(ctx, "invoice", invoice.id, invoice.status, status);
839
+ await ctx.emitTimeline({ contactId: invoice.contactId, eventType: "invoice.viewed", subjectType: "invoice", subjectId: invoice.id, payload: { number: invoice.number } });
840
+ ctx.queueEvent("invoice.viewed", { invoiceId: invoice.id, contactId: invoice.contactId });
841
+ ctx.setSubject("invoice", invoice.id);
842
+ return updated!;
843
+ },
844
+ });
845
+
846
+ export const markInvoiceOverdue = defineService({
847
+ name: "invoicing.markOverdue",
848
+ summary: "Mark a due, unpaid issued invoice overdue without changing its balance.",
849
+ kind: "mutation",
850
+ permission: "scoped",
851
+ input: z.object({ id: z.string().uuid(), asOf: z.coerce.date().default(() => new Date()) }),
852
+ output: invoiceRow,
853
+ handler: async (input, ctx) => {
854
+ await lock(ctx.tx, "invoice", input.id);
855
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, input.id)).limit(1);
856
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
857
+ if (invoice.status === "overdue") return invoice;
858
+ if (!inArrayValue(invoice.status, ["sent", "viewed", "partially_paid"]) || !invoice.dueAt || invoice.dueAt >= input.asOf) {
859
+ throw new ServiceError("conflict", "That invoice is not both unpaid and past due.");
860
+ }
861
+ const [updated] = await ctx.tx.update(invoices).set({ status: "overdue" }).where(eq(invoices.id, invoice.id)).returning();
862
+ await stateEvent(ctx, "invoice", invoice.id, invoice.status, "overdue", "past_due");
863
+ ctx.queueEvent("invoice.overdue", { invoiceId: invoice.id, contactId: invoice.contactId });
864
+ ctx.setSubject("invoice", invoice.id);
865
+ return updated!;
866
+ },
867
+ });
868
+
869
+ function inArrayValue<T extends string>(value: string, choices: readonly T[]): value is T {
870
+ return choices.includes(value as T);
871
+ }
872
+
873
+ export const voidInvoice = defineService({
874
+ name: "invoicing.void",
875
+ writeClass: "destructive",
876
+ summary: "Void an unpaid invoice while retaining its issued number and audit trail.",
877
+ kind: "mutation",
878
+ permission: "scoped",
879
+ stepUp: true,
880
+ input: z.object({ id: z.string().uuid(), reason: z.string().trim().min(3).max(1_000) }),
881
+ output: invoiceRow,
882
+ handler: async (input, ctx) => {
883
+ await lock(ctx.tx, "invoice", input.id);
884
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, input.id)).limit(1);
885
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
886
+ if (invoice.status === "void") return invoice;
887
+ if (invoice.status === "paid" || invoice.status === "refunded" || invoice.paidMinor > 0) {
888
+ throw new ServiceError("conflict", "A paid invoice cannot be voided. Issue a credit note and refund instead.");
889
+ }
890
+ const [activeAttempt] = await ctx.tx.select({ id: payments.id }).from(payments).where(and(
891
+ eq(payments.invoiceId, invoice.id), inArray(payments.status, ["created", "processing"]),
892
+ )).limit(1);
893
+ if (activeAttempt) throw new ServiceError("conflict", "A payment attempt is still active. Reconcile or cancel it before voiding the invoice.");
894
+ const [updated] = await ctx.tx
895
+ .update(invoices)
896
+ .set({ status: "void", voidedAt: new Date() })
897
+ .where(eq(invoices.id, invoice.id))
898
+ .returning();
899
+ await stateEvent(ctx, "invoice", invoice.id, invoice.status, "void", input.reason);
900
+ await ctx.emitTimeline({
901
+ contactId: invoice.contactId,
902
+ eventType: "invoice.voided",
903
+ subjectType: "invoice",
904
+ subjectId: invoice.id,
905
+ payload: { reason: input.reason },
906
+ });
907
+ ctx.queueEvent("invoice.voided", { invoiceId: invoice.id, contactId: invoice.contactId });
908
+ ctx.setSubject("invoice", invoice.id);
909
+ return updated!;
910
+ },
911
+ });
912
+
913
+ const paymentInput = z.object({
914
+ invoiceId: z.string().uuid(),
915
+ provider: z.string().trim().min(1).max(100),
916
+ method: z.string().trim().min(1).max(100),
917
+ amountMinor: positiveMinor,
918
+ idempotencyKey,
919
+ metadata: boundedObject.default({}),
920
+ });
921
+
922
+ export const createPayment = defineService({
923
+ name: "invoicing.createPayment",
924
+ summary: "Create an idempotent payment attempt against an issued invoice.",
925
+ kind: "mutation",
926
+ permission: "scoped",
927
+ input: paymentInput,
928
+ output: paymentRow,
929
+ handler: async (input, ctx) => {
930
+ const hash = requestHash(input);
931
+ await lock(ctx.tx, "payment-idempotency", `${input.provider}:${input.idempotencyKey}`);
932
+ const [duplicate] = await ctx.tx
933
+ .select()
934
+ .from(payments)
935
+ .where(and(eq(payments.provider, input.provider), eq(payments.idempotencyKey, input.idempotencyKey)))
936
+ .limit(1);
937
+ if (duplicate) {
938
+ if (duplicate.requestHash !== hash) {
939
+ throw new ServiceError("conflict", "That payment idempotency key was already used for a different attempt.");
940
+ }
941
+ return duplicate;
942
+ }
943
+ await lock(ctx.tx, "invoice", input.invoiceId);
944
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, input.invoiceId)).limit(1);
945
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
946
+ if (!inArrayValue(invoice.status, ["sent", "viewed", "partially_paid", "overdue"])) {
947
+ throw new ServiceError("conflict", "That invoice is not open for payment.");
948
+ }
949
+ const outstanding = invoice.totalMinor - invoice.paidMinor;
950
+ if (input.amountMinor > outstanding) {
951
+ throw new ServiceError("validation", "The payment exceeds this invoice's outstanding balance.");
952
+ }
953
+ const [created] = await ctx.tx
954
+ .insert(payments)
955
+ .values({
956
+ invoiceId: invoice.id,
957
+ provider: input.provider,
958
+ method: input.method,
959
+ currency: invoice.currency,
960
+ amountMinor: input.amountMinor,
961
+ idempotencyKey: input.idempotencyKey,
962
+ requestHash: hash,
963
+ metadata: input.metadata,
964
+ })
965
+ .returning();
966
+ await stateEvent(ctx, "payment", created!.id, null, "created");
967
+ ctx.queueEvent("payment.created", { paymentId: created!.id, invoiceId: invoice.id, contactId: invoice.contactId });
968
+ ctx.setSubject("payment", created!.id);
969
+ return created!;
970
+ },
971
+ });
972
+
973
+ export const startPayment = defineService({
974
+ name: "invoicing.startPayment",
975
+ summary: "Move a created provider payment into processing.",
976
+ kind: "mutation",
977
+ permission: "scoped",
978
+ input: z.object({
979
+ id: z.string().uuid(),
980
+ providerRef: z.string().trim().min(1).max(500).optional(),
981
+ providerCheckoutRef: z.string().trim().min(1).max(500).optional(),
982
+ }),
983
+ output: paymentRow,
984
+ handler: async (input, ctx) => {
985
+ await lock(ctx.tx, "payment", input.id);
986
+ const [payment] = await ctx.tx.select().from(payments).where(eq(payments.id, input.id)).limit(1);
987
+ if (!payment) throw new ServiceError("not_found", "That payment is not here.");
988
+ if (payment.status === "processing") {
989
+ if (input.providerRef && payment.providerRef && input.providerRef !== payment.providerRef) throw new ServiceError("conflict", "That payment is already processing under a different provider reference.");
990
+ if (input.providerCheckoutRef && payment.providerCheckoutRef && input.providerCheckoutRef !== payment.providerCheckoutRef) throw new ServiceError("conflict", "That payment is already processing under a different checkout reference.");
991
+ return payment;
992
+ }
993
+ if (payment.status !== "created") throw new ServiceError("conflict", "Only a created payment can start processing.");
994
+ const [updated] = await ctx.tx.update(payments).set({
995
+ status: "processing",
996
+ providerRef: input.providerRef,
997
+ providerCheckoutRef: input.providerCheckoutRef,
998
+ }).where(eq(payments.id, payment.id)).returning();
999
+ await stateEvent(ctx, "payment", payment.id, "created", "processing");
1000
+ ctx.queueEvent("payment.processing", { paymentId: payment.id, invoiceId: payment.invoiceId });
1001
+ ctx.setSubject("payment", payment.id);
1002
+ return updated!;
1003
+ },
1004
+ });
1005
+
1006
+ export const failPayment = defineService({
1007
+ name: "invoicing.failPayment",
1008
+ summary: "Record a safe terminal provider failure without leaking its raw response.",
1009
+ kind: "mutation",
1010
+ permission: "scoped",
1011
+ input: z.object({
1012
+ id: z.string().uuid(),
1013
+ code: z.string().trim().max(100).optional(),
1014
+ message: z.string().trim().min(1).max(500),
1015
+ }),
1016
+ output: paymentRow,
1017
+ handler: async (input, ctx) => {
1018
+ await lock(ctx.tx, "payment", input.id);
1019
+ const [payment] = await ctx.tx.select().from(payments).where(eq(payments.id, input.id)).limit(1);
1020
+ if (!payment) throw new ServiceError("not_found", "That payment is not here.");
1021
+ if (payment.status === "failed") return payment;
1022
+ if (!inArrayValue(payment.status, ["created", "processing"])) {
1023
+ throw new ServiceError("conflict", "A terminal payment cannot fail again.");
1024
+ }
1025
+ const [updated] = await ctx.tx.update(payments).set({ status: "failed", failureCode: input.code, failureMessage: input.message, failedAt: new Date() }).where(eq(payments.id, payment.id)).returning();
1026
+ await stateEvent(ctx, "payment", payment.id, payment.status, "failed", input.code);
1027
+ ctx.queueEvent("payment.failed", { paymentId: payment.id, invoiceId: payment.invoiceId, code: input.code });
1028
+ ctx.setSubject("payment", payment.id);
1029
+ return updated!;
1030
+ },
1031
+ });
1032
+
1033
+ export const cancelPayment = defineService({
1034
+ name: "invoicing.cancelPayment",
1035
+ summary: "Cancel an unsettled payment attempt while retaining its audit evidence.",
1036
+ kind: "mutation",
1037
+ permission: "scoped",
1038
+ input: z.object({ id: z.string().uuid(), reason: z.string().trim().min(3).max(500) }),
1039
+ output: paymentRow,
1040
+ handler: async (input, ctx) => {
1041
+ await lock(ctx.tx, "payment", input.id);
1042
+ const [payment] = await ctx.tx.select().from(payments).where(eq(payments.id, input.id)).limit(1);
1043
+ if (!payment) throw new ServiceError("not_found", "That payment is not here.");
1044
+ if (payment.status === "cancelled") return payment;
1045
+ if (!inArrayValue(payment.status, ["created", "processing"])) {
1046
+ throw new ServiceError("conflict", "A terminal payment cannot be cancelled.");
1047
+ }
1048
+ if (payment.method === "hosted_checkout") {
1049
+ throw new ServiceError("conflict", "A hosted checkout must be reconciled with its provider before its payment can be closed.");
1050
+ }
1051
+ const [updated] = await ctx.tx
1052
+ .update(payments)
1053
+ .set({ status: "cancelled", failureCode: null, failureMessage: null })
1054
+ .where(eq(payments.id, payment.id))
1055
+ .returning();
1056
+ await stateEvent(ctx, "payment", payment.id, payment.status, "cancelled", input.reason);
1057
+ ctx.queueEvent("payment.cancelled", { paymentId: payment.id, invoiceId: payment.invoiceId });
1058
+ ctx.setSubject("payment", payment.id);
1059
+ return updated!;
1060
+ },
1061
+ });
1062
+
1063
+ export const settlePayment = defineService({
1064
+ name: "invoicing.settlePayment",
1065
+ summary: "Settle a provider payment and atomically advance the invoice balance.",
1066
+ kind: "mutation",
1067
+ permission: "scoped",
1068
+ input: z.object({ id: z.string().uuid(), providerRef: z.string().trim().min(1).max(500), processedAt: z.coerce.date().default(() => new Date()) }),
1069
+ output: paymentRow,
1070
+ handler: async (input, ctx) => {
1071
+ await lock(ctx.tx, "payment", input.id);
1072
+ const [payment] = await ctx.tx.select().from(payments).where(eq(payments.id, input.id)).limit(1);
1073
+ if (!payment) throw new ServiceError("not_found", "That payment is not here.");
1074
+ if (payment.status === "succeeded") {
1075
+ if (payment.providerRef !== input.providerRef) throw new ServiceError("conflict", "That payment already settled under a different provider reference.");
1076
+ return payment;
1077
+ }
1078
+ if (!inArrayValue(payment.status, ["created", "processing"])) {
1079
+ throw new ServiceError("conflict", "A failed or cancelled payment cannot settle.");
1080
+ }
1081
+ // A cancellation locks the order before its invoice. Match that order so
1082
+ // provider settlement and cancellation cannot deadlock or race past one
1083
+ // another while deciding whether any money has arrived.
1084
+ const [source] = await ctx.tx.select({ sourceType: invoices.sourceType, sourceId: invoices.sourceId })
1085
+ .from(invoices).where(eq(invoices.id, payment.invoiceId)).limit(1);
1086
+ if (source?.sourceType === "order" && source.sourceId) {
1087
+ const { orders } = await import("@/modules/catalog/schema");
1088
+ await ctx.tx.select({ id: orders.id }).from(orders).where(eq(orders.id, source.sourceId)).for("update");
1089
+ }
1090
+ await lock(ctx.tx, "invoice", payment.invoiceId);
1091
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, payment.invoiceId)).limit(1);
1092
+ if (!invoice) throw new ServiceError("not_found", "That payment's invoice is not here.");
1093
+ if (!inArrayValue(invoice.status, ["sent", "viewed", "partially_paid", "overdue"])) {
1094
+ throw new ServiceError("conflict", "That invoice is no longer open for payment.");
1095
+ }
1096
+ const paidMinor = sumMinor([invoice.paidMinor, payment.amountMinor], "Paid balance");
1097
+ if (paidMinor > invoice.totalMinor) {
1098
+ throw new ServiceError("conflict", "Settling this payment would overpay the invoice. Refund or cancel the competing attempt first.");
1099
+ }
1100
+ const invoiceStatus = paidMinor === invoice.totalMinor ? "paid" as const : "partially_paid" as const;
1101
+ const [updatedPayment] = await ctx.tx.update(payments).set({ status: "succeeded", providerRef: input.providerRef, processedAt: input.processedAt, failureCode: null, failureMessage: null }).where(eq(payments.id, payment.id)).returning();
1102
+ await ctx.tx.update(invoices).set({ status: invoiceStatus, paidMinor, ...(invoiceStatus === "paid" ? { paidAt: input.processedAt } : {}) }).where(eq(invoices.id, invoice.id));
1103
+ await allocateSettledPayment(ctx, updatedPayment!, input.processedAt);
1104
+ if (invoice.sourceType === "order" && invoice.sourceId) {
1105
+ const { orders, stockReservations } = await import("@/modules/catalog/schema");
1106
+ const [order] = await ctx.tx.select().from(orders).where(eq(orders.id, invoice.sourceId)).limit(1);
1107
+ if (!order || order.invoiceId !== invoice.id || order.status === "cancelled") {
1108
+ throw new ServiceError("conflict", "The order linked to this payment is not open.");
1109
+ }
1110
+ if (invoiceStatus === "paid") {
1111
+ const { payOrder } = await import("@/modules/catalog/orders");
1112
+ await ctx.callAsSystem(payOrder, { id: order.id });
1113
+ } else if (order.status === "pending_payment") {
1114
+ await ctx.tx.update(orders).set({ status: "partially_paid", updatedAt: new Date() }).where(eq(orders.id, order.id));
1115
+ await ctx.tx.update(stockReservations).set({
1116
+ expiresAt: new Date(Date.now() + 30 * 86_400_000), updatedAt: new Date(),
1117
+ }).where(and(eq(stockReservations.holderType, "order"), eq(stockReservations.holderId, order.id), eq(stockReservations.status, "active")));
1118
+ ctx.queueEvent("catalog.orderPartiallyPaid", { orderId: order.id, invoiceId: invoice.id, paidMinor });
1119
+ await ctx.emitTimeline({ contactId: order.contactId, eventType: "order.partiallyPaid", subjectType: "order", subjectId: order.id,
1120
+ payload: { invoiceId: invoice.id, paidMinor, totalMinor: invoice.totalMinor, currency: invoice.currency } });
1121
+ }
1122
+ }
1123
+ await stateEvent(ctx, "payment", payment.id, payment.status, "succeeded");
1124
+ if (invoice.status !== invoiceStatus) {
1125
+ await stateEvent(ctx, "invoice", invoice.id, invoice.status, invoiceStatus, "payment_settled", { paymentId: payment.id, amountMinor: payment.amountMinor });
1126
+ }
1127
+ await ctx.emitTimeline({
1128
+ contactId: invoice.contactId,
1129
+ eventType: invoiceStatus === "paid" ? "invoice.paid" : "invoice.partiallyPaid",
1130
+ subjectType: "invoice",
1131
+ subjectId: invoice.id,
1132
+ // `sourceType` rides along so a listener can tell what was actually
1133
+ // bought without reading this module's tables. §4.3 makes the invoice
1134
+ // "the single money object", which means every listener that cares
1135
+ // about money resolves to an invoice and would otherwise have to guess
1136
+ // whether it settled an order, a booking or a subscription — and
1137
+ // guessing wrong misfiles somebody's commission (C9.10).
1138
+ payload: { paymentId: payment.id, amountMinor: payment.amountMinor, paidMinor, totalMinor: invoice.totalMinor, currency: invoice.currency, sourceType: invoice.sourceType },
1139
+ });
1140
+ ctx.queueEvent("payment.succeeded", { paymentId: payment.id, invoiceId: invoice.id, contactId: invoice.contactId, amountMinor: payment.amountMinor });
1141
+ ctx.queueEvent(invoiceStatus === "paid" ? "invoice.paid" : "invoice.partiallyPaid", { invoiceId: invoice.id, contactId: invoice.contactId, paidMinor });
1142
+ if (invoiceStatus === "paid" && invoice.sourceType === "unlock") {
1143
+ const { issueUnlock } = await import("@/core/entitlements/service");
1144
+ await ctx.callAsSystem(issueUnlock, {
1145
+ contactId: invoice.contactId,
1146
+ invoiceId: invoice.id,
1147
+ name: invoice.number ?? "Unlock",
1148
+ resource: { kind: "content", selector: invoice.sourceId ?? invoice.id },
1149
+ });
1150
+ }
1151
+ ctx.setSubject("payment", payment.id);
1152
+ return updatedPayment!;
1153
+ },
1154
+ });
1155
+
1156
+ export const createRefund = defineService({
1157
+ name: "invoicing.createRefund",
1158
+ writeClass: "money",
1159
+ summary: "Reserve an idempotent refund amount against one successful payment.",
1160
+ kind: "mutation",
1161
+ permission: "scoped",
1162
+ stepUp: true,
1163
+ input: z.object({
1164
+ paymentId: z.string().uuid(),
1165
+ amountMinor: positiveMinor,
1166
+ idempotencyKey,
1167
+ reason: z.string().trim().min(3).max(1_000),
1168
+ }),
1169
+ output: refundRow,
1170
+ handler: async (input, ctx) => {
1171
+ await lock(ctx.tx, "refund-idempotency", input.idempotencyKey);
1172
+ await lock(ctx.tx, "payment", input.paymentId);
1173
+ const [payment] = await ctx.tx.select().from(payments).where(eq(payments.id, input.paymentId)).limit(1);
1174
+ if (!payment) throw new ServiceError("not_found", "That payment is not here.");
1175
+ if (payment.status !== "succeeded") throw new ServiceError("conflict", "Only a successful payment can be refunded.");
1176
+ const hash = requestHash({ ...input, provider: payment.provider });
1177
+ const [duplicate] = await ctx.tx.select().from(refunds).where(and(eq(refunds.provider, payment.provider), eq(refunds.idempotencyKey, input.idempotencyKey))).limit(1);
1178
+ if (duplicate) {
1179
+ if (duplicate.requestHash !== hash) throw new ServiceError("conflict", "That refund idempotency key was already used for a different refund.");
1180
+ return duplicate;
1181
+ }
1182
+ const reserved = await ctx.tx
1183
+ .select({ amountMinor: refunds.amountMinor })
1184
+ .from(refunds)
1185
+ .where(and(eq(refunds.paymentId, payment.id), inArray(refunds.status, ["created", "processing", "succeeded"])));
1186
+ const reservedMinor = sumMinor(reserved.map((row) => row.amountMinor), "Reserved refunds");
1187
+ if (sumMinor([reservedMinor, input.amountMinor], "Refund reservation") > payment.amountMinor) {
1188
+ throw new ServiceError("validation", "Refunds cannot exceed the successful payment amount.");
1189
+ }
1190
+ const [created] = await ctx.tx.insert(refunds).values({
1191
+ paymentId: payment.id,
1192
+ invoiceId: payment.invoiceId,
1193
+ provider: payment.provider,
1194
+ idempotencyKey: input.idempotencyKey,
1195
+ requestHash: hash,
1196
+ currency: payment.currency,
1197
+ amountMinor: input.amountMinor,
1198
+ reason: input.reason,
1199
+ }).returning();
1200
+ await stateEvent(ctx, "refund", created!.id, null, "created", input.reason);
1201
+ ctx.queueEvent("refund.created", { refundId: created!.id, paymentId: payment.id, invoiceId: payment.invoiceId });
1202
+ ctx.setSubject("refund", created!.id);
1203
+ return created!;
1204
+ },
1205
+ });
1206
+
1207
+ export const startRefund = defineService({
1208
+ name: "invoicing.startRefund",
1209
+ summary: "Move a created provider refund into processing.",
1210
+ kind: "mutation",
1211
+ permission: "scoped",
1212
+ input: z.object({ id: z.string().uuid(), providerRef: z.string().trim().min(1).max(500).optional() }),
1213
+ output: refundRow,
1214
+ handler: async (input, ctx) => {
1215
+ await lock(ctx.tx, "refund", input.id);
1216
+ const [refund] = await ctx.tx.select().from(refunds).where(eq(refunds.id, input.id)).limit(1);
1217
+ if (!refund) throw new ServiceError("not_found", "That refund is not here.");
1218
+ if (refund.status === "processing") return refund;
1219
+ if (refund.status !== "created") throw new ServiceError("conflict", "Only a created refund can start processing.");
1220
+ const [updated] = await ctx.tx.update(refunds).set({ status: "processing", providerRef: input.providerRef }).where(eq(refunds.id, refund.id)).returning();
1221
+ await stateEvent(ctx, "refund", refund.id, "created", "processing");
1222
+ ctx.queueEvent("refund.processing", { refundId: refund.id, paymentId: refund.paymentId });
1223
+ ctx.setSubject("refund", refund.id);
1224
+ return updated!;
1225
+ },
1226
+ });
1227
+
1228
+ export const failRefund = defineService({
1229
+ name: "invoicing.failRefund",
1230
+ summary: "Record a safe terminal refund failure and release its reservation.",
1231
+ kind: "mutation",
1232
+ permission: "scoped",
1233
+ input: z.object({ id: z.string().uuid(), code: z.string().trim().max(100).optional(), message: z.string().trim().min(1).max(500) }),
1234
+ output: refundRow,
1235
+ handler: async (input, ctx) => {
1236
+ await lock(ctx.tx, "refund", input.id);
1237
+ const [refund] = await ctx.tx.select().from(refunds).where(eq(refunds.id, input.id)).limit(1);
1238
+ if (!refund) throw new ServiceError("not_found", "That refund is not here.");
1239
+ if (refund.status === "failed") return refund;
1240
+ if (!inArrayValue(refund.status, ["created", "processing"])) throw new ServiceError("conflict", "A terminal refund cannot fail again.");
1241
+ const [updated] = await ctx.tx.update(refunds).set({ status: "failed", failureCode: input.code, failureMessage: input.message, failedAt: new Date() }).where(eq(refunds.id, refund.id)).returning();
1242
+ await stateEvent(ctx, "refund", refund.id, refund.status, "failed", input.code);
1243
+ ctx.queueEvent("refund.failed", { refundId: refund.id, paymentId: refund.paymentId, code: input.code });
1244
+ ctx.setSubject("refund", refund.id);
1245
+ return updated!;
1246
+ },
1247
+ });
1248
+
1249
+ export const cancelRefund = defineService({
1250
+ name: "invoicing.cancelRefund",
1251
+ summary: "Cancel an unsettled refund and release its reserved payment balance.",
1252
+ kind: "mutation",
1253
+ permission: "scoped",
1254
+ stepUp: true,
1255
+ input: z.object({ id: z.string().uuid(), reason: z.string().trim().min(3).max(500) }),
1256
+ output: refundRow,
1257
+ handler: async (input, ctx) => {
1258
+ await lock(ctx.tx, "refund", input.id);
1259
+ const [refund] = await ctx.tx.select().from(refunds).where(eq(refunds.id, input.id)).limit(1);
1260
+ if (!refund) throw new ServiceError("not_found", "That refund is not here.");
1261
+ if (refund.status === "cancelled") return refund;
1262
+ if (!inArrayValue(refund.status, ["created", "processing"])) {
1263
+ throw new ServiceError("conflict", "A terminal refund cannot be cancelled.");
1264
+ }
1265
+ const [updated] = await ctx.tx
1266
+ .update(refunds)
1267
+ .set({ status: "cancelled", failureCode: null, failureMessage: null })
1268
+ .where(eq(refunds.id, refund.id))
1269
+ .returning();
1270
+ await stateEvent(ctx, "refund", refund.id, refund.status, "cancelled", input.reason);
1271
+ ctx.queueEvent("refund.cancelled", { refundId: refund.id, paymentId: refund.paymentId });
1272
+ ctx.setSubject("refund", refund.id);
1273
+ return updated!;
1274
+ },
1275
+ });
1276
+
1277
+ export const settleRefund = defineService({
1278
+ name: "invoicing.settleRefund",
1279
+ summary: "Settle a provider refund and atomically update payment and invoice balances.",
1280
+ kind: "mutation",
1281
+ permission: "scoped",
1282
+ input: z.object({ id: z.string().uuid(), providerRef: z.string().trim().min(1).max(500), processedAt: z.coerce.date().default(() => new Date()) }),
1283
+ output: refundRow,
1284
+ handler: async (input, ctx) => {
1285
+ await lock(ctx.tx, "refund", input.id);
1286
+ const [refund] = await ctx.tx.select().from(refunds).where(eq(refunds.id, input.id)).limit(1);
1287
+ if (!refund) throw new ServiceError("not_found", "That refund is not here.");
1288
+ if (refund.status === "succeeded") {
1289
+ if (refund.providerRef !== input.providerRef) throw new ServiceError("conflict", "That refund already settled under a different provider reference.");
1290
+ return refund;
1291
+ }
1292
+ if (!inArrayValue(refund.status, ["created", "processing"])) throw new ServiceError("conflict", "A failed or cancelled refund cannot settle.");
1293
+ await lock(ctx.tx, "payment", refund.paymentId);
1294
+ await lock(ctx.tx, "invoice", refund.invoiceId);
1295
+ const [[payment], [invoice]] = await Promise.all([
1296
+ ctx.tx.select().from(payments).where(eq(payments.id, refund.paymentId)).limit(1),
1297
+ ctx.tx.select().from(invoices).where(eq(invoices.id, refund.invoiceId)).limit(1),
1298
+ ]);
1299
+ if (!payment || !invoice) throw new ServiceError("not_found", "That refund's payment or invoice is not here.");
1300
+ const paymentRefunded = sumMinor([payment.refundedMinor, refund.amountMinor], "Payment refunded balance");
1301
+ const invoiceRefunded = sumMinor([invoice.refundedMinor, refund.amountMinor], "Invoice refunded balance");
1302
+ if (paymentRefunded > payment.amountMinor || invoiceRefunded > invoice.paidMinor) throw new ServiceError("conflict", "Settling this refund would exceed the paid balance.");
1303
+ const invoiceStatus = invoiceRefunded === invoice.paidMinor ? "refunded" as const : invoice.status;
1304
+ const [updatedRefund] = await ctx.tx.update(refunds).set({ status: "succeeded", providerRef: input.providerRef, processedAt: input.processedAt, failureCode: null, failureMessage: null }).where(eq(refunds.id, refund.id)).returning();
1305
+ await ctx.tx.update(payments).set({ refundedMinor: paymentRefunded }).where(eq(payments.id, payment.id));
1306
+ await ctx.tx.update(invoices).set({ refundedMinor: invoiceRefunded, status: invoiceStatus }).where(eq(invoices.id, invoice.id));
1307
+ await stateEvent(ctx, "refund", refund.id, refund.status, "succeeded");
1308
+ if (invoiceStatus !== invoice.status) await stateEvent(ctx, "invoice", invoice.id, invoice.status, invoiceStatus, "fully_refunded", { refundId: refund.id });
1309
+ await ctx.emitTimeline({
1310
+ contactId: invoice.contactId,
1311
+ eventType: "invoice.refunded",
1312
+ subjectType: "invoice",
1313
+ subjectId: invoice.id,
1314
+ payload: { refundId: refund.id, amountMinor: refund.amountMinor, refundedMinor: invoiceRefunded, currency: invoice.currency, full: invoiceStatus === "refunded" },
1315
+ });
1316
+ ctx.queueEvent("refund.succeeded", { refundId: refund.id, paymentId: payment.id, invoiceId: invoice.id, contactId: invoice.contactId, amountMinor: refund.amountMinor });
1317
+ if (invoiceStatus === "refunded") ctx.queueEvent("invoice.refunded", { invoiceId: invoice.id, contactId: invoice.contactId });
1318
+ ctx.setSubject("refund", refund.id);
1319
+ return updatedRefund!;
1320
+ },
1321
+ });
1322
+
1323
+ const creditLine = z.object({
1324
+ invoiceLineId: z.string().uuid().optional(),
1325
+ description: z.string().trim().min(1).max(1_000),
1326
+ quantityMicros,
1327
+ subtotalMinor: minor,
1328
+ taxMinor: minor.default(0),
1329
+ });
1330
+
1331
+ export const createCreditNote = defineService({
1332
+ name: "invoicing.createCreditNote",
1333
+ summary: "Create an idempotent draft credit note bounded by the original invoice.",
1334
+ kind: "mutation",
1335
+ permission: "scoped",
1336
+ stepUp: true,
1337
+ input: z.object({
1338
+ invoiceId: z.string().uuid(),
1339
+ idempotencyKey,
1340
+ reason: z.string().trim().min(3).max(1_000),
1341
+ lines: z.array(creditLine).min(1).max(1_000),
1342
+ }),
1343
+ output: creditNoteRow,
1344
+ handler: async (input, ctx) => {
1345
+ const hash = requestHash(input);
1346
+ await lock(ctx.tx, "credit-idempotency", input.idempotencyKey);
1347
+ const [duplicate] = await ctx.tx.select().from(creditNotes).where(eq(creditNotes.idempotencyKey, input.idempotencyKey)).limit(1);
1348
+ if (duplicate) {
1349
+ if (duplicate.requestHash !== hash) throw new ServiceError("conflict", "That credit-note idempotency key was already used for different contents.");
1350
+ return duplicate;
1351
+ }
1352
+ await lock(ctx.tx, "invoice", input.invoiceId);
1353
+ const [invoice] = await ctx.tx.select().from(invoices).where(eq(invoices.id, input.invoiceId)).limit(1);
1354
+ if (!invoice) throw new ServiceError("not_found", "That invoice is not here.");
1355
+ if (invoice.status === "draft" || invoice.status === "void") throw new ServiceError("conflict", "Only an issued, non-void invoice can receive a credit note.");
1356
+ const originalLines = await ctx.tx.select().from(invoiceLines).where(eq(invoiceLines.invoiceId, invoice.id));
1357
+ const originalById = new Map(originalLines.map((line) => [line.id, line]));
1358
+ for (const line of input.lines) {
1359
+ if (line.invoiceLineId && !originalById.has(line.invoiceLineId)) {
1360
+ throw new ServiceError("validation", "A credit line points outside this invoice.");
1361
+ }
1362
+ }
1363
+ const subtotalMinor = sumMinor(input.lines.map((line) => line.subtotalMinor), "Credit subtotal");
1364
+ const taxMinor = sumMinor(input.lines.map((line) => line.taxMinor), "Credit tax");
1365
+ const totalMinor = sumMinor([subtotalMinor, taxMinor], "Credit total");
1366
+ const prior = await ctx.tx.select({ totalMinor: creditNotes.totalMinor }).from(creditNotes).where(and(eq(creditNotes.invoiceId, invoice.id), ne(creditNotes.status, "void")));
1367
+ if (sumMinor([...prior.map((row) => row.totalMinor), totalMinor], "Total invoice credits") > invoice.totalMinor) {
1368
+ throw new ServiceError("validation", "Credit notes cannot exceed the original invoice total.");
1369
+ }
1370
+ const [created] = await ctx.tx.insert(creditNotes).values({
1371
+ invoiceId: invoice.id,
1372
+ idempotencyKey: input.idempotencyKey,
1373
+ requestHash: hash,
1374
+ currency: invoice.currency,
1375
+ reason: input.reason,
1376
+ subtotalMinor,
1377
+ taxMinor,
1378
+ totalMinor,
1379
+ }).returning();
1380
+ await ctx.tx.insert(creditNoteLines).values(input.lines.map((line, position) => ({
1381
+ creditNoteId: created!.id,
1382
+ invoiceLineId: line.invoiceLineId,
1383
+ position,
1384
+ description: line.description,
1385
+ quantityMicros: line.quantityMicros,
1386
+ subtotalMinor: line.subtotalMinor,
1387
+ taxMinor: line.taxMinor,
1388
+ totalMinor: sumMinor([line.subtotalMinor, line.taxMinor], "Credit line total"),
1389
+ })));
1390
+ await stateEvent(ctx, "credit_note", created!.id, null, "draft", input.reason);
1391
+ ctx.queueEvent("creditNote.created", { creditNoteId: created!.id, invoiceId: invoice.id, contactId: invoice.contactId });
1392
+ ctx.setSubject("creditNote", created!.id);
1393
+ return created!;
1394
+ },
1395
+ });
1396
+
1397
+ export const issueCreditNote = defineService({
1398
+ name: "invoicing.issueCreditNote",
1399
+ summary: "Allocate a gapless credit-note number and freeze its draft.",
1400
+ kind: "mutation",
1401
+ permission: "scoped",
1402
+ stepUp: true,
1403
+ input: z.object({ id: z.string().uuid() }),
1404
+ output: creditNoteRow,
1405
+ handler: async (input, ctx) => {
1406
+ await lock(ctx.tx, "credit-note", input.id);
1407
+ const [note] = await ctx.tx.select().from(creditNotes).where(eq(creditNotes.id, input.id)).limit(1);
1408
+ if (!note) throw new ServiceError("not_found", "That credit note is not here.");
1409
+ if (note.status === "issued") return note;
1410
+ if (note.status !== "draft") throw new ServiceError("conflict", "Only a draft credit note can be issued.");
1411
+ const number = await allocateNumber(ctx.tx, note.sequenceKey, "CN-");
1412
+ const [updated] = await ctx.tx.update(creditNotes).set({ status: "issued", number, issuedAt: new Date() }).where(eq(creditNotes.id, note.id)).returning();
1413
+ await stateEvent(ctx, "credit_note", note.id, "draft", "issued");
1414
+ const [invoice] = await ctx.tx.select({ contactId: invoices.contactId }).from(invoices).where(eq(invoices.id, note.invoiceId));
1415
+ ctx.queueEvent("creditNote.issued", { creditNoteId: note.id, invoiceId: note.invoiceId, contactId: invoice?.contactId, number });
1416
+ ctx.setSubject("creditNote", note.id);
1417
+ return updated!;
1418
+ },
1419
+ });
1420
+
1421
+ export const voidCreditNote = defineService({
1422
+ name: "invoicing.voidCreditNote",
1423
+ writeClass: "destructive",
1424
+ summary: "Void an issued credit note without deleting its legal number or history.",
1425
+ kind: "mutation",
1426
+ permission: "scoped",
1427
+ stepUp: true,
1428
+ input: z.object({ id: z.string().uuid(), reason: z.string().trim().min(3).max(1_000) }),
1429
+ output: creditNoteRow,
1430
+ handler: async (input, ctx) => {
1431
+ await lock(ctx.tx, "credit-note", input.id);
1432
+ const [note] = await ctx.tx.select().from(creditNotes).where(eq(creditNotes.id, input.id)).limit(1);
1433
+ if (!note) throw new ServiceError("not_found", "That credit note is not here.");
1434
+ if (note.status === "void") return note;
1435
+ if (note.status !== "issued") throw new ServiceError("conflict", "Issue this credit note before voiding it.");
1436
+ const [updated] = await ctx.tx.update(creditNotes).set({ status: "void", voidedAt: new Date() }).where(eq(creditNotes.id, note.id)).returning();
1437
+ await stateEvent(ctx, "credit_note", note.id, "issued", "void", input.reason);
1438
+ ctx.queueEvent("creditNote.voided", { creditNoteId: note.id, invoiceId: note.invoiceId });
1439
+ ctx.setSubject("creditNote", note.id);
1440
+ return updated!;
1441
+ },
1442
+ });
1443
+
1444
+ export default [
1445
+ listInvoices,
1446
+ getInvoice,
1447
+ getPaymentReceipt,
1448
+ reconcileMoney,
1449
+ createDraftInvoice,
1450
+ issueInvoice,
1451
+ markInvoiceViewed,
1452
+ markInvoiceOverdue,
1453
+ voidInvoice,
1454
+ createPayment,
1455
+ startPayment,
1456
+ failPayment,
1457
+ cancelPayment,
1458
+ settlePayment,
1459
+ createRefund,
1460
+ startRefund,
1461
+ failRefund,
1462
+ cancelRefund,
1463
+ settleRefund,
1464
+ createCreditNote,
1465
+ issueCreditNote,
1466
+ voidCreditNote,
1467
+ ];