@tokenoftrust/storefront-runner 7.3.1 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
  2. package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
  3. package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
  4. package/apps/storefront/astro.config.mjs +8 -2
  5. package/apps/storefront/package.json +1 -2
  6. package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
  7. package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
  8. package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
  9. package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
  10. package/apps/storefront/src/layouts/Layout.astro +17 -0
  11. package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
  12. package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +147 -0
  13. package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +67 -1
  14. package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
  15. package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
  16. package/apps/storefront/src/lib/access/auth/session.ts +79 -0
  17. package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
  18. package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
  19. package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
  20. package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
  21. package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
  22. package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
  23. package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
  24. package/apps/storefront/src/lib/activity/store.ts +9 -3
  25. package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
  26. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
  27. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
  28. package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
  29. package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
  30. package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
  31. package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +447 -0
  32. package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
  33. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
  34. package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
  35. package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
  36. package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
  37. package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
  38. package/apps/storefront/src/middleware/controlPlane.ts +15 -1
  39. package/apps/storefront/src/middleware/index.ts +40 -1
  40. package/apps/storefront/src/middleware/renderChain.ts +46 -33
  41. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
  42. package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
  43. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
  44. package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
  45. package/apps/storefront/src/pages/products/[handle].astro +2 -15
  46. package/apps/storefront/tsconfig.astro.json +11 -0
  47. package/package.json +1 -1
  48. package/packages/public-runtime/src/activity/README.md +12 -0
  49. package/packages/public-runtime/src/activity/catalog.ts +7 -0
  50. package/packages/public-runtime/src/activity/event.ts +19 -0
  51. package/packages/public-runtime/src/activity/redaction.ts +31 -2
  52. package/packages/public-runtime/src/catalog-files.ts +3 -2
  53. package/packages/public-runtime/src/checkout-orders.ts +18 -19
  54. package/packages/public-runtime/src/checkout.ts +70 -0
  55. package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
  56. package/packages/public-runtime/src/compliance/index.ts +1 -1
  57. package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
  58. package/packages/public-runtime/src/compliance/profile.ts +268 -20
  59. package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
  60. package/packages/public-runtime/src/customization-runtime.ts +1 -1
  61. package/packages/public-runtime/src/product.ts +9 -1
  62. package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
  63. package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
  64. package/pnpm-lock.runner.yaml +0 -15
  65. package/scripts/tenant/materialize-tenant-content.mjs +3 -0
  66. package/scripts/tenant/validate.mjs +128 -0
  67. package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
  68. package/apps/storefront/drizzle.config.apps.ts +0 -13
  69. package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
  70. package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
  71. package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
  72. package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
  73. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
  74. package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
  75. package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
  76. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
  77. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
  78. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
  79. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
  80. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
  81. package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
  82. package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
  83. package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
  84. package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
  85. package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
  86. package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
  87. package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
  88. package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
  89. package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
  90. package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
  91. package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
  92. package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
  93. package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
  94. package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
  95. package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
  96. package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
  97. package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
  98. package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
  99. package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
  100. package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
  101. package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
  102. package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
  103. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
  104. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
  105. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
  106. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
  107. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
  108. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
  109. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
  110. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
  111. package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
  112. package/apps/storefront/perf/README.md +0 -64
  113. package/apps/storefront/perf/assert-budgets.ts +0 -159
  114. package/apps/storefront/platform-reconcile-tenants.json +0 -3
  115. package/apps/storefront/playwright.config.ts +0 -23
  116. package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
  117. package/apps/storefront/public/js/dashboard-apps.js +0 -183
  118. package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
  119. package/apps/storefront/public/js/dashboard-delegate.js +0 -167
  120. package/apps/storefront/public/js/dashboard-team.js +0 -356
  121. package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
  122. package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
  123. package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
  124. package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
  125. package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
  126. package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
  127. package/apps/storefront/src/config/storeName.ts +0 -34
  128. package/apps/storefront/src/lib/access/admin/README.md +0 -122
  129. package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
  130. package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
  131. package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
  132. package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
  133. package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
  134. package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
  135. package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
  136. package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
  137. package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -150
  138. package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -452
  139. package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
  140. package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
  141. package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
  142. package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
  143. package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
  144. package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
  145. package/apps/storefront/src/lib/activity/alerts.ts +0 -426
  146. package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
  147. package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
  148. package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
  149. package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
  150. package/apps/storefront/src/lib/activity/query.ts +0 -403
  151. package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
  152. package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
  153. package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
  154. package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
  155. package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
  156. package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
  157. package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
  158. package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
  159. package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
  160. package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
  161. package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
  162. package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
  163. package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
  164. package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
  165. package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
  166. package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
  167. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
  168. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
  169. package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
  170. package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
  171. package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
  172. package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
  173. package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
  174. package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
  175. package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
  176. package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
  177. package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
  178. package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
  179. package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
  180. package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
  181. package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
  182. package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
  183. package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
  184. package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
  185. package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
  186. package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
  187. package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
  188. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
  189. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
  190. package/apps/storefront/src/lib/content/index.ts +0 -27
  191. package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
  192. package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
  193. package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
  194. package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
  195. package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
  196. package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
  197. package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
  198. package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
  199. package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
  200. package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
  201. package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
  202. package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
  203. package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
  204. package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
  205. package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
  206. package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
  207. package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
  208. package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
  209. package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
  210. package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
  211. package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
  212. package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
  213. package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
  214. package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
  215. package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
  216. package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
  217. package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
  218. package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
  219. package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
  220. package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
  221. package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
  222. package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
  223. package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
  224. package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
  225. package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
  226. package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
  227. package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
  228. package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
  229. package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
  230. package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
  231. package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
  232. package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
  233. package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
  234. package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
  235. package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
  236. package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
  237. package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
  238. package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
  239. package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
  240. package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
  241. package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
  242. package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
  243. package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
  244. package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
  245. package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
  246. package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
  247. package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
  248. package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
  249. package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
  250. package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
  251. package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
  252. package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
  253. package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
  254. package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
  255. package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
  256. package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
  257. package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
  258. package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
  259. package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
  260. package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
  261. package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
  262. package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
  263. package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
  264. package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
  265. package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
  266. package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
  267. package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
  268. package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
  269. package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
  270. package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
  271. package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
  272. package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
  273. package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
  274. package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
  275. package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
  276. package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
  277. package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
  278. package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
  279. package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
  280. package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
  281. package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
  282. package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
  283. package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
  284. package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
  285. package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
  286. package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
  287. package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
  288. package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
  289. package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
  290. package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
  291. package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
  292. package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
  293. package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
  294. package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
  295. package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
  296. package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
  297. package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
  298. package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
  299. package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
  300. package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
  301. package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
  302. package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
  303. package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
  304. package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
  305. package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
  306. package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
  307. package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
  308. package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
  309. package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
  310. package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
  311. package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
  312. package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
  313. package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
  314. package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
  315. package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
  316. package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
  317. package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
  318. package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
  319. package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
  320. package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
  321. package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
  322. package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
  323. package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
  324. package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
  325. package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
  326. package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
  327. package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
  328. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
  329. package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
  330. package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
  331. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
  332. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
  333. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
  334. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
  335. package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
  336. package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
  337. package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
  338. package/apps/storefront/src/pages/api/contact.ts +0 -144
  339. package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
  340. package/apps/storefront/src/styles/admin.css +0 -1161
  341. package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
  342. package/apps/storefront/test/pipeline/harness.ts +0 -209
  343. package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
  344. package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
  345. package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
  346. package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
  347. package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
  348. package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
  349. package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
  350. package/apps/storefront/vitest.config.cts +0 -44
  351. package/apps/storefront/vitest.faults.config.cts +0 -13
  352. package/apps/storefront/vitest.workers.config.cts +0 -7
  353. package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
  354. package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
  355. package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
  356. package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
  357. package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
  358. package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
  359. package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
  360. package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
  361. package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
  362. package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
  363. package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
  364. package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
  365. package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
  366. package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
  367. package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
  368. package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
  369. package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
  370. package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
  371. package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
  372. package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
  373. package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
  374. package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
  375. package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
  376. package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
  377. package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
  378. package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
  379. package/packages/feedback/package.json +0 -35
  380. package/packages/feedback/scripts/build-player.mjs +0 -28
  381. package/packages/feedback/src/index.ts +0 -1
  382. package/packages/feedback/src/primitives/composer.ts +0 -639
  383. package/packages/feedback/src/primitives/dialog.ts +0 -263
  384. package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
  385. package/packages/feedback/src/primitives/index.ts +0 -10
  386. package/packages/feedback/src/primitives/launcher.ts +0 -200
  387. package/packages/feedback/src/primitives/picker.ts +0 -663
  388. package/packages/feedback/src/primitives/redaction.ts +0 -204
  389. package/packages/feedback/src/primitives/selection.ts +0 -49
  390. package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
  391. package/packages/feedback/src/primitives/styles.ts +0 -77
  392. package/packages/feedback/src/primitives/surface.ts +0 -124
  393. package/packages/feedback/src/primitives/target.ts +0 -293
  394. package/packages/feedback/src/tour/canonical.ts +0 -27
  395. package/packages/feedback/src/tour/index.ts +0 -3
  396. package/packages/feedback/src/tour/player/browser.ts +0 -5
  397. package/packages/feedback/src/tour/player/host.ts +0 -12
  398. package/packages/feedback/src/tour/player/index.ts +0 -205
  399. package/packages/feedback/src/tour/player/manifest.ts +0 -76
  400. package/packages/feedback/src/tour/player/player.css +0 -130
  401. package/packages/feedback/src/tour/player/resolver.ts +0 -12
  402. package/packages/feedback/src/tour/player/surface.ts +0 -295
  403. package/packages/feedback/src/tour/player/types.ts +0 -8
  404. package/packages/feedback/src/tour/resolve/core.ts +0 -267
  405. package/packages/feedback/src/tour/resolve/dom.ts +0 -115
  406. package/packages/feedback/src/tour/resolve/index.ts +0 -29
  407. package/packages/feedback/src/tour/sanitize.ts +0 -76
  408. package/packages/feedback/src/tour/schema.ts +0 -362
  409. package/packages/feedback/src/v1/guards.ts +0 -335
  410. package/packages/feedback/src/v1/index.ts +0 -3
  411. package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
  412. package/packages/feedback/src/v1/types.ts +0 -177
  413. package/packages/feedback/tsconfig.json +0 -9
  414. package/packages/feedback/vitest.config.cts +0 -21
@@ -1,342 +0,0 @@
1
- -- Field-level contact vault: each personal field is its own AES-256-GCM ciphertext under a
2
- -- per-tenant data key wrapped by AWS KMS (src/lib/customers/contactVault/). Retention is per
3
- -- field group: an immutable ceiling bound into every field's AAD, a shrink-only effective expiry,
4
- -- and an immutable seal-time floor (retentionPolicy.ts). The vault row is also the long-lived
5
- -- facts row: after its last group is cleared it is detached from the order and keeps only
6
- -- unlinked month, zip3, region, country and totals.
7
- --
8
- -- allow-destructive: order_contact_vault, order_contact_tombstones and contact_access_audit are
9
- -- dropped and rebuilt only when empty (the guard below aborts the whole file otherwise), and
10
- -- contact_messages is rebuilt preserving every row; no contact data exists in any of them yet.
11
- CREATE TABLE `_gv_vault_v2_guard` (`n` integer NOT NULL CHECK (`n` = 0));
12
- --> statement-breakpoint
13
- INSERT INTO `_gv_vault_v2_guard` (`n`)
14
- SELECT (SELECT COUNT(*) FROM `order_contact_vault`)
15
- + (SELECT COUNT(*) FROM `order_contact_tombstones`)
16
- + (SELECT COUNT(*) FROM `contact_access_audit`)
17
- + (SELECT COUNT(*) FROM `contact_messages` WHERE `ciphertext` IS NOT NULL);
18
- --> statement-breakpoint
19
- DROP TABLE `_gv_vault_v2_guard`;
20
- --> statement-breakpoint
21
- DROP TABLE `order_contact_vault`;
22
- --> statement-breakpoint
23
- DROP TABLE `order_contact_tombstones`;
24
- --> statement-breakpoint
25
- DROP TABLE `contact_access_audit`;
26
- --> statement-breakpoint
27
- CREATE TABLE `contact_vault_data_keys` (
28
- `tenant_id` text NOT NULL,
29
- `stage` text NOT NULL CHECK (stage IN ('preview', 'publication')),
30
- `purpose` text NOT NULL CHECK (`purpose` IN ('order-contact', 'contact-message', 'blind-index')),
31
- `kid` text NOT NULL,
32
- `wrapped_key` text NOT NULL,
33
- `kms_key_arn` text NOT NULL,
34
- `created_at` text NOT NULL,
35
- `retired_at` text,
36
- PRIMARY KEY (`tenant_id`, `stage`, `purpose`, `kid`)
37
- );
38
- --> statement-breakpoint
39
- CREATE UNIQUE INDEX `uq_contact_vault_data_keys_active`
40
- ON `contact_vault_data_keys` (`tenant_id`, `stage`, `purpose`) WHERE `retired_at` IS NULL;
41
- --> statement-breakpoint
42
- CREATE TRIGGER `contact_vault_data_keys_immutable`
43
- BEFORE UPDATE ON `contact_vault_data_keys`
44
- WHEN NEW.`wrapped_key` IS NOT OLD.`wrapped_key`
45
- OR NEW.`kms_key_arn` IS NOT OLD.`kms_key_arn`
46
- OR NEW.`kid` IS NOT OLD.`kid`
47
- OR NEW.`tenant_id` IS NOT OLD.`tenant_id`
48
- OR NEW.`stage` IS NOT OLD.`stage`
49
- OR NEW.`purpose` IS NOT OLD.`purpose`
50
- OR (OLD.`retired_at` IS NOT NULL AND NEW.`retired_at` IS NOT OLD.`retired_at`)
51
- BEGIN
52
- SELECT RAISE(ABORT, 'data-key-immutable');
53
- END;
54
- --> statement-breakpoint
55
- CREATE TABLE `order_contact_vault` (
56
- `fact_id` text PRIMARY KEY NOT NULL,
57
- `tenant_id` text NOT NULL,
58
- `stage` text NOT NULL CHECK (stage IN ('preview', 'publication')),
59
- `order_id` text,
60
- `placed_month` text NOT NULL CHECK (length(`placed_month`) = 6),
61
- `currency` text,
62
- `order_total_minor` integer,
63
- `item_count` integer,
64
- `ship_region` text,
65
- `ship_country` text,
66
- `ship_zip3` text,
67
- `bill_region` text,
68
- `bill_country` text,
69
- `bill_zip3` text,
70
- `time_scale` integer,
71
- `rule_version` text,
72
- `order_kid` text,
73
- `bidx_kid` text,
74
- `sealed_at` text,
75
- `sealed_jti` text,
76
- `erased_at` text,
77
- `name_ct` text,
78
- `company_ct` text,
79
- `identity_ceiling` text,
80
- `identity_expires_at` text,
81
- `identity_floor_until` text,
82
- `identity_rule` text,
83
- `email_ct` text,
84
- `email_bidx` text,
85
- `email_ceiling` text,
86
- `email_expires_at` text,
87
- `email_floor_until` text,
88
- `email_rule` text,
89
- `phone_ct` text,
90
- `phone_bidx` text,
91
- `phone_ceiling` text,
92
- `phone_expires_at` text,
93
- `phone_floor_until` text,
94
- `phone_rule` text,
95
- `ship_name_ct` text,
96
- `ship_company_ct` text,
97
- `ship_line1_ct` text,
98
- `ship_line2_ct` text,
99
- `ship_city` text,
100
- `ship_postal_code` text,
101
- `ship_ceiling` text,
102
- `ship_expires_at` text,
103
- `ship_floor_until` text,
104
- `ship_rule` text,
105
- `bill_name_ct` text,
106
- `bill_company_ct` text,
107
- `bill_line1_ct` text,
108
- `bill_line2_ct` text,
109
- `bill_city` text,
110
- `bill_postal_code` text,
111
- `bill_ceiling` text,
112
- `bill_expires_at` text,
113
- `bill_floor_until` text,
114
- `bill_rule` text,
115
- CHECK (`identity_expires_at` IS NULL OR `identity_expires_at` <= `identity_ceiling`),
116
- CHECK (`email_expires_at` IS NULL OR `email_expires_at` <= `email_ceiling`),
117
- CHECK (`phone_expires_at` IS NULL OR `phone_expires_at` <= `phone_ceiling`),
118
- CHECK (`ship_expires_at` IS NULL OR `ship_expires_at` <= `ship_ceiling`),
119
- CHECK (`bill_expires_at` IS NULL OR `bill_expires_at` <= `bill_ceiling`),
120
- FOREIGN KEY (`tenant_id`, `stage`, `order_id`) REFERENCES `scrappy_commerce_orders` (`tenant_id`, `stage`, `order_id`)
121
- );
122
- --> statement-breakpoint
123
- CREATE UNIQUE INDEX `uq_order_contact_vault_order`
124
- ON `order_contact_vault` (`tenant_id`, `stage`, `order_id`) WHERE `order_id` IS NOT NULL;
125
- --> statement-breakpoint
126
- CREATE INDEX `idx_order_contact_vault_email_bidx`
127
- ON `order_contact_vault` (`tenant_id`, `stage`, `email_bidx`) WHERE `email_bidx` IS NOT NULL;
128
- --> statement-breakpoint
129
- CREATE INDEX `idx_order_contact_vault_phone_bidx`
130
- ON `order_contact_vault` (`tenant_id`, `stage`, `phone_bidx`) WHERE `phone_bidx` IS NOT NULL;
131
- --> statement-breakpoint
132
- CREATE INDEX `idx_order_contact_vault_order_kid` ON `order_contact_vault` (`order_kid`) WHERE `order_kid` IS NOT NULL;
133
- --> statement-breakpoint
134
- CREATE INDEX `idx_order_contact_vault_bidx_kid` ON `order_contact_vault` (`bidx_kid`) WHERE `bidx_kid` IS NOT NULL;
135
- --> statement-breakpoint
136
- CREATE INDEX `idx_order_contact_vault_linked` ON `order_contact_vault` (`tenant_id`, `stage`) WHERE `order_id` IS NOT NULL;
137
- --> statement-breakpoint
138
- -- A group may only expire sooner (to a non-NULL value) and may only be cleared, never refilled;
139
- -- its ceiling, floor and rule never change. The one exception is the detach statement (the order
140
- -- link goes to NULL with every group already empty), which nulls all of them. A blind index takes
141
- -- a new value only as a rotation recompute: its group still sealed with the same ciphertext and
142
- -- bidx_kid moving to another kid in the same statement, replacing every index the row holds;
143
- -- bidx_kid goes to NULL only with both indexes. The order link only ever goes to NULL.
144
- CREATE TRIGGER `order_contact_vault_shrink_only`
145
- BEFORE UPDATE ON `order_contact_vault`
146
- WHEN NEW.`tenant_id` IS NOT OLD.`tenant_id`
147
- OR NEW.`stage` IS NOT OLD.`stage`
148
- OR NEW.`fact_id` IS NOT OLD.`fact_id`
149
- OR NEW.`placed_month` IS NOT OLD.`placed_month`
150
- OR (NEW.`order_id` IS NOT NULL AND NEW.`order_id` IS NOT OLD.`order_id`)
151
- OR (NEW.`identity_ceiling` IS NOT OLD.`identity_ceiling` AND (NEW.`identity_ceiling` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
152
- OR (NEW.`identity_floor_until` IS NOT OLD.`identity_floor_until` AND (NEW.`identity_floor_until` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
153
- OR (NEW.`identity_rule` IS NOT OLD.`identity_rule` AND (NEW.`identity_rule` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
154
- OR (NEW.`identity_expires_at` IS NOT OLD.`identity_expires_at` AND NOT ((NEW.`identity_expires_at` IS NULL AND (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)) OR (NEW.`identity_expires_at` IS NOT NULL AND OLD.`identity_expires_at` IS NOT NULL AND NEW.`identity_expires_at` < OLD.`identity_expires_at`)))
155
- OR (NEW.`email_ceiling` IS NOT OLD.`email_ceiling` AND (NEW.`email_ceiling` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
156
- OR (NEW.`email_floor_until` IS NOT OLD.`email_floor_until` AND (NEW.`email_floor_until` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
157
- OR (NEW.`email_rule` IS NOT OLD.`email_rule` AND (NEW.`email_rule` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
158
- OR (NEW.`email_expires_at` IS NOT OLD.`email_expires_at` AND NOT ((NEW.`email_expires_at` IS NULL AND (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)) OR (NEW.`email_expires_at` IS NOT NULL AND OLD.`email_expires_at` IS NOT NULL AND NEW.`email_expires_at` < OLD.`email_expires_at`)))
159
- OR (NEW.`phone_ceiling` IS NOT OLD.`phone_ceiling` AND (NEW.`phone_ceiling` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
160
- OR (NEW.`phone_floor_until` IS NOT OLD.`phone_floor_until` AND (NEW.`phone_floor_until` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
161
- OR (NEW.`phone_rule` IS NOT OLD.`phone_rule` AND (NEW.`phone_rule` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
162
- OR (NEW.`phone_expires_at` IS NOT OLD.`phone_expires_at` AND NOT ((NEW.`phone_expires_at` IS NULL AND (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)) OR (NEW.`phone_expires_at` IS NOT NULL AND OLD.`phone_expires_at` IS NOT NULL AND NEW.`phone_expires_at` < OLD.`phone_expires_at`)))
163
- OR (NEW.`ship_ceiling` IS NOT OLD.`ship_ceiling` AND (NEW.`ship_ceiling` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
164
- OR (NEW.`ship_floor_until` IS NOT OLD.`ship_floor_until` AND (NEW.`ship_floor_until` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
165
- OR (NEW.`ship_rule` IS NOT OLD.`ship_rule` AND (NEW.`ship_rule` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
166
- OR (NEW.`ship_expires_at` IS NOT OLD.`ship_expires_at` AND NOT ((NEW.`ship_expires_at` IS NULL AND (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)) OR (NEW.`ship_expires_at` IS NOT NULL AND OLD.`ship_expires_at` IS NOT NULL AND NEW.`ship_expires_at` < OLD.`ship_expires_at`)))
167
- OR (NEW.`bill_ceiling` IS NOT OLD.`bill_ceiling` AND (NEW.`bill_ceiling` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
168
- OR (NEW.`bill_floor_until` IS NOT OLD.`bill_floor_until` AND (NEW.`bill_floor_until` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
169
- OR (NEW.`bill_rule` IS NOT OLD.`bill_rule` AND (NEW.`bill_rule` IS NOT NULL OR NOT (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)))
170
- OR (NEW.`bill_expires_at` IS NOT OLD.`bill_expires_at` AND NOT ((NEW.`bill_expires_at` IS NULL AND (NEW.`order_id` IS NULL AND NEW.`name_ct` IS NULL AND NEW.`company_ct` IS NULL AND NEW.`email_ct` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_ct` IS NULL AND NEW.`phone_bidx` IS NULL AND NEW.`ship_name_ct` IS NULL AND NEW.`ship_company_ct` IS NULL AND NEW.`ship_line1_ct` IS NULL AND NEW.`ship_line2_ct` IS NULL AND NEW.`ship_city` IS NULL AND NEW.`ship_postal_code` IS NULL AND NEW.`bill_name_ct` IS NULL AND NEW.`bill_company_ct` IS NULL AND NEW.`bill_line1_ct` IS NULL AND NEW.`bill_line2_ct` IS NULL AND NEW.`bill_city` IS NULL AND NEW.`bill_postal_code` IS NULL)) OR (NEW.`bill_expires_at` IS NOT NULL AND OLD.`bill_expires_at` IS NOT NULL AND NEW.`bill_expires_at` < OLD.`bill_expires_at`)))
171
- OR (NEW.`name_ct` IS NOT NULL AND NEW.`name_ct` IS NOT OLD.`name_ct`)
172
- OR (NEW.`company_ct` IS NOT NULL AND NEW.`company_ct` IS NOT OLD.`company_ct`)
173
- OR (NEW.`email_ct` IS NOT NULL AND NEW.`email_ct` IS NOT OLD.`email_ct`)
174
- OR (NEW.`phone_ct` IS NOT NULL AND NEW.`phone_ct` IS NOT OLD.`phone_ct`)
175
- OR (NEW.`ship_name_ct` IS NOT NULL AND NEW.`ship_name_ct` IS NOT OLD.`ship_name_ct`)
176
- OR (NEW.`ship_company_ct` IS NOT NULL AND NEW.`ship_company_ct` IS NOT OLD.`ship_company_ct`)
177
- OR (NEW.`ship_line1_ct` IS NOT NULL AND NEW.`ship_line1_ct` IS NOT OLD.`ship_line1_ct`)
178
- OR (NEW.`ship_line2_ct` IS NOT NULL AND NEW.`ship_line2_ct` IS NOT OLD.`ship_line2_ct`)
179
- OR (NEW.`ship_city` IS NOT NULL AND NEW.`ship_city` IS NOT OLD.`ship_city`)
180
- OR (NEW.`ship_postal_code` IS NOT NULL AND NEW.`ship_postal_code` IS NOT OLD.`ship_postal_code`)
181
- OR (NEW.`bill_name_ct` IS NOT NULL AND NEW.`bill_name_ct` IS NOT OLD.`bill_name_ct`)
182
- OR (NEW.`bill_company_ct` IS NOT NULL AND NEW.`bill_company_ct` IS NOT OLD.`bill_company_ct`)
183
- OR (NEW.`bill_line1_ct` IS NOT NULL AND NEW.`bill_line1_ct` IS NOT OLD.`bill_line1_ct`)
184
- OR (NEW.`bill_line2_ct` IS NOT NULL AND NEW.`bill_line2_ct` IS NOT OLD.`bill_line2_ct`)
185
- OR (NEW.`bill_city` IS NOT NULL AND NEW.`bill_city` IS NOT OLD.`bill_city`)
186
- OR (NEW.`bill_postal_code` IS NOT NULL AND NEW.`bill_postal_code` IS NOT OLD.`bill_postal_code`)
187
- OR (NEW.`email_bidx` IS NOT NULL AND NEW.`email_bidx` IS NOT OLD.`email_bidx` AND NOT (
188
- OLD.`email_bidx` IS NOT NULL AND OLD.`email_ct` IS NOT NULL AND NEW.`email_ct` IS OLD.`email_ct`
189
- AND OLD.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT OLD.`bidx_kid`))
190
- OR (NEW.`phone_bidx` IS NOT NULL AND NEW.`phone_bidx` IS NOT OLD.`phone_bidx` AND NOT (
191
- OLD.`phone_bidx` IS NOT NULL AND OLD.`phone_ct` IS NOT NULL AND NEW.`phone_ct` IS OLD.`phone_ct`
192
- AND OLD.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT OLD.`bidx_kid`))
193
- OR (NEW.`order_kid` IS NOT NULL AND NEW.`order_kid` IS NOT OLD.`order_kid`)
194
- OR (NEW.`bidx_kid` IS NOT OLD.`bidx_kid` AND NOT (
195
- (NEW.`bidx_kid` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_bidx` IS NULL)
196
- OR (NEW.`bidx_kid` IS NOT NULL AND OLD.`bidx_kid` IS NOT NULL
197
- AND (OLD.`email_bidx` IS NULL OR NEW.`email_bidx` IS NOT OLD.`email_bidx`)
198
- AND (OLD.`phone_bidx` IS NULL OR NEW.`phone_bidx` IS NOT OLD.`phone_bidx`)
199
- AND (NEW.`email_bidx` IS NOT NULL OR NEW.`phone_bidx` IS NOT NULL))))
200
- BEGIN
201
- SELECT RAISE(ABORT, 'vault-immutable');
202
- END;
203
- --> statement-breakpoint
204
- CREATE TABLE `order_contact_markers` (
205
- `tenant_id` text NOT NULL,
206
- `stage` text NOT NULL CHECK (stage IN ('preview', 'publication')),
207
- `order_id` text NOT NULL,
208
- PRIMARY KEY (`tenant_id`, `stage`, `order_id`),
209
- FOREIGN KEY (`tenant_id`, `stage`, `order_id`) REFERENCES `scrappy_commerce_orders` (`tenant_id`, `stage`, `order_id`)
210
- );
211
- --> statement-breakpoint
212
- CREATE TABLE `contact_access_audit` (
213
- `audit_id` text NOT NULL PRIMARY KEY,
214
- `tenant_id` text NOT NULL,
215
- `stage` text NOT NULL CHECK (stage IN ('preview', 'publication')),
216
- `record_kind` text NOT NULL CHECK (`record_kind` IN ('order-contact', 'contact-message')),
217
- `record_id` text,
218
- `record_count` integer,
219
- `at` text NOT NULL,
220
- `actor_id` text NOT NULL,
221
- `actor_role` text NOT NULL CHECK (`actor_role` IN ('owner', 'staff')),
222
- `reason_code` text,
223
- `ticket_ref` text,
224
- `action` text NOT NULL CHECK (`action` IN ('read', 'list', 'erase', 'search')),
225
- `groups` text,
226
- `outcome` text NOT NULL CHECK (`outcome` = 'admitted'),
227
- CHECK (`actor_role` = 'owner' OR (`reason_code` IS NOT NULL AND `ticket_ref` IS NOT NULL))
228
- );
229
- --> statement-breakpoint
230
- CREATE INDEX `idx_contact_access_audit_quota` ON `contact_access_audit` (`tenant_id`, `actor_id`, `actor_role`, `at`);
231
- --> statement-breakpoint
232
- CREATE TRIGGER `contact_access_audit_no_update`
233
- BEFORE UPDATE ON `contact_access_audit`
234
- BEGIN
235
- SELECT RAISE(ABORT, 'append-only');
236
- END;
237
- --> statement-breakpoint
238
- CREATE TRIGGER `contact_access_audit_no_delete`
239
- BEFORE DELETE ON `contact_access_audit`
240
- BEGIN
241
- SELECT RAISE(ABORT, 'append-only');
242
- END;
243
- --> statement-breakpoint
244
- -- contact_messages: every row is kept; legacy plaintext rows stay in legacy_* until the rollout
245
- -- seals them field by field. New rows are written sealed only.
246
- CREATE TABLE `contact_messages_v2` (
247
- `id` text PRIMARY KEY NOT NULL,
248
- `tenant_id` text NOT NULL,
249
- `stage` text NOT NULL CHECK (stage IN ('preview', 'publication')),
250
- `msg_kid` text,
251
- `bidx_kid` text,
252
- `name_ct` text,
253
- `email_ct` text,
254
- `email_bidx` text,
255
- `phone_ct` text,
256
- `phone_bidx` text,
257
- `message_ct` text,
258
- `ceiling` text NOT NULL,
259
- `expires_at` text NOT NULL CHECK (`expires_at` <= `ceiling`),
260
- `time_scale` integer,
261
- `rule_version` text,
262
- `page_path` text,
263
- `status` text NOT NULL DEFAULT 'unread' CHECK (`status` IN ('unread', 'read')),
264
- `created_at` text NOT NULL,
265
- `read_at` text,
266
- `notify_status` text NOT NULL DEFAULT 'pending' CHECK (`notify_status` IN ('pending', 'sent', 'failed')),
267
- `notify_attempts` integer NOT NULL DEFAULT 0,
268
- `legacy_name` text,
269
- `legacy_email` text,
270
- `legacy_phone` text,
271
- `legacy_message` text,
272
- CHECK (`msg_kid` IS NULL OR (`legacy_name` IS NULL AND `legacy_email` IS NULL AND `legacy_phone` IS NULL AND `legacy_message` IS NULL))
273
- );
274
- --> statement-breakpoint
275
- INSERT INTO `contact_messages_v2`
276
- (`id`, `tenant_id`, `stage`, `ceiling`, `expires_at`, `page_path`, `status`, `created_at`, `read_at`,
277
- `notify_status`, `notify_attempts`, `legacy_name`, `legacy_email`, `legacy_phone`, `legacy_message`)
278
- SELECT `id`, `tenant_id`, `stage`, `not_after`, `expires_at`, `page_path`, `status`, `created_at`, `read_at`,
279
- `notify_status`, `notify_attempts`, `legacy_name`, `legacy_email`, `legacy_phone`, `legacy_message`
280
- FROM `contact_messages`;
281
- --> statement-breakpoint
282
- DROP TABLE `contact_messages`;
283
- --> statement-breakpoint
284
- ALTER TABLE `contact_messages_v2` RENAME TO `contact_messages`;
285
- --> statement-breakpoint
286
- CREATE INDEX `idx_contact_messages_tenant_stage_created` ON `contact_messages` (`tenant_id`, `stage`, `created_at`);
287
- --> statement-breakpoint
288
- CREATE INDEX `idx_contact_messages_tenant_stage_status` ON `contact_messages` (`tenant_id`, `stage`, `status`);
289
- --> statement-breakpoint
290
- CREATE INDEX `idx_contact_messages_expires` ON `contact_messages` (`expires_at`);
291
- --> statement-breakpoint
292
- CREATE INDEX `idx_contact_messages_legacy` ON `contact_messages` (`id`) WHERE `msg_kid` IS NULL AND `legacy_message` IS NOT NULL;
293
- --> statement-breakpoint
294
- CREATE INDEX `idx_contact_messages_email_bidx`
295
- ON `contact_messages` (`tenant_id`, `stage`, `email_bidx`) WHERE `email_bidx` IS NOT NULL;
296
- --> statement-breakpoint
297
- CREATE INDEX `idx_contact_messages_phone_bidx`
298
- ON `contact_messages` (`tenant_id`, `stage`, `phone_bidx`) WHERE `phone_bidx` IS NOT NULL;
299
- --> statement-breakpoint
300
- CREATE TRIGGER `contact_messages_no_plaintext_insert`
301
- BEFORE INSERT ON `contact_messages`
302
- WHEN NEW.`legacy_name` IS NOT NULL OR NEW.`legacy_email` IS NOT NULL
303
- OR NEW.`legacy_phone` IS NOT NULL OR NEW.`legacy_message` IS NOT NULL
304
- BEGIN
305
- SELECT RAISE(ABORT, 'plaintext-refused');
306
- END;
307
- --> statement-breakpoint
308
- -- Once a row is sealed (msg_kid set) its kid never changes, not even to NULL; its ciphertexts only
309
- -- go to NULL; a blind index takes a new value only as a rotation recompute (bidx_kid moving to
310
- -- another kid in the same statement, replacing every index the row holds); and bidx_kid goes to
311
- -- NULL only with both indexes.
312
- CREATE TRIGGER `contact_messages_no_plaintext_update`
313
- BEFORE UPDATE ON `contact_messages`
314
- WHEN (NEW.`legacy_name` IS NOT NULL AND NEW.`legacy_name` IS NOT OLD.`legacy_name`)
315
- OR (NEW.`legacy_email` IS NOT NULL AND NEW.`legacy_email` IS NOT OLD.`legacy_email`)
316
- OR (NEW.`legacy_phone` IS NOT NULL AND NEW.`legacy_phone` IS NOT OLD.`legacy_phone`)
317
- OR (NEW.`legacy_message` IS NOT NULL AND NEW.`legacy_message` IS NOT OLD.`legacy_message`)
318
- OR NEW.`expires_at` > OLD.`expires_at`
319
- OR NEW.`ceiling` IS NOT OLD.`ceiling`
320
- OR (OLD.`msg_kid` IS NOT NULL AND NEW.`msg_kid` IS NOT OLD.`msg_kid`)
321
- OR (OLD.`msg_kid` IS NOT NULL AND (
322
- (NEW.`name_ct` IS NOT NULL AND NEW.`name_ct` IS NOT OLD.`name_ct`)
323
- OR (NEW.`email_ct` IS NOT NULL AND NEW.`email_ct` IS NOT OLD.`email_ct`)
324
- OR (NEW.`phone_ct` IS NOT NULL AND NEW.`phone_ct` IS NOT OLD.`phone_ct`)
325
- OR (NEW.`message_ct` IS NOT NULL AND NEW.`message_ct` IS NOT OLD.`message_ct`)
326
- OR (NEW.`email_bidx` IS NOT NULL AND NEW.`email_bidx` IS NOT OLD.`email_bidx` AND NOT (
327
- OLD.`email_bidx` IS NOT NULL AND OLD.`email_ct` IS NOT NULL AND NEW.`email_ct` IS OLD.`email_ct`
328
- AND OLD.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT OLD.`bidx_kid`))
329
- OR (NEW.`phone_bidx` IS NOT NULL AND NEW.`phone_bidx` IS NOT OLD.`phone_bidx` AND NOT (
330
- OLD.`phone_bidx` IS NOT NULL AND OLD.`phone_ct` IS NOT NULL AND NEW.`phone_ct` IS OLD.`phone_ct`
331
- AND OLD.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT NULL AND NEW.`bidx_kid` IS NOT OLD.`bidx_kid`))
332
- OR (NEW.`bidx_kid` IS NOT OLD.`bidx_kid` AND NOT (
333
- (NEW.`bidx_kid` IS NULL AND NEW.`email_bidx` IS NULL AND NEW.`phone_bidx` IS NULL)
334
- OR (NEW.`bidx_kid` IS NOT NULL AND OLD.`bidx_kid` IS NOT NULL
335
- AND (OLD.`email_bidx` IS NULL OR NEW.`email_bidx` IS NOT OLD.`email_bidx`)
336
- AND (OLD.`phone_bidx` IS NULL OR NEW.`phone_bidx` IS NOT OLD.`phone_bidx`)
337
- AND (NEW.`email_bidx` IS NOT NULL OR NEW.`phone_bidx` IS NOT NULL))))))
338
- OR NEW.`tenant_id` IS NOT OLD.`tenant_id`
339
- OR NEW.`stage` IS NOT OLD.`stage`
340
- BEGIN
341
- SELECT RAISE(ABORT, 'vault-immutable');
342
- END;
@@ -1,15 +0,0 @@
1
- -- Grantee emails for principal grants made through storefront, shown only on the store owner's own
2
- -- Team page. tot20's grant list names a grantee by an opaque principal id, so storefront records the
3
- -- email beside the opaque grant ref when tot20 confirms a grant. Display only: never consulted to
4
- -- decide access. Retention-bounded: expires_at is the grant's confirmed expiry; expired rows are
5
- -- purged on writes, owner reads and the hourly sweep, and a row is deleted when its grant is revoked
6
- -- through storefront or no longer appears in the store's active grant list.
7
- CREATE TABLE principal_grant_contacts (
8
- tenant_id TEXT NOT NULL,
9
- grant_ref TEXT NOT NULL,
10
- grantee_email TEXT NOT NULL,
11
- recorded_at TEXT NOT NULL,
12
- expires_at TEXT NOT NULL,
13
- PRIMARY KEY (tenant_id, grant_ref)
14
- );
15
- CREATE INDEX idx_principal_grant_contacts_expires ON principal_grant_contacts(expires_at);
@@ -1,22 +0,0 @@
1
- -- Erasure group bits: identity=1, email=2, phone=4, ship=8, bill=16.
2
- ALTER TABLE `order_contact_markers`
3
- ADD COLUMN `erased_groups` integer NOT NULL DEFAULT 0 CHECK (`erased_groups` BETWEEN 0 AND 31);
4
- --> statement-breakpoint
5
- UPDATE `order_contact_markers` AS m SET `erased_groups` = COALESCE((
6
- SELECT MAX(CASE WHEN instr(',' || a.groups || ',', ',identity,') > 0 THEN 1 ELSE 0 END)
7
- + MAX(CASE WHEN instr(',' || a.groups || ',', ',email,') > 0 THEN 2 ELSE 0 END)
8
- + MAX(CASE WHEN instr(',' || a.groups || ',', ',phone,') > 0 THEN 4 ELSE 0 END)
9
- + MAX(CASE WHEN instr(',' || a.groups || ',', ',ship,') > 0 THEN 8 ELSE 0 END)
10
- + MAX(CASE WHEN instr(',' || a.groups || ',', ',bill,') > 0 THEN 16 ELSE 0 END)
11
- FROM `contact_access_audit` AS a
12
- WHERE a.tenant_id = m.tenant_id AND a.stage = m.stage AND a.record_id = m.order_id
13
- AND a.record_kind = 'order-contact' AND a.action = 'erase' AND a.outcome = 'admitted'
14
- ), 0);
15
- --> statement-breakpoint
16
- CREATE TRIGGER `order_contact_markers_erasure_monotonic`
17
- BEFORE UPDATE ON `order_contact_markers`
18
- WHEN NEW.tenant_id != OLD.tenant_id OR NEW.stage != OLD.stage OR NEW.order_id != OLD.order_id
19
- OR (NEW.erased_groups | OLD.erased_groups) != NEW.erased_groups
20
- BEGIN
21
- SELECT RAISE(ABORT, 'erasure-monotonic');
22
- END;
@@ -1,2 +0,0 @@
1
- CREATE INDEX `scrappy_shipment_audit_order_lookup`
2
- ON `scrappy_shipment_audit` (`tenant_id`, `stage`, `order_id`, `kind`, `to_state`, `at`);
@@ -1,44 +0,0 @@
1
- -- Processor config: one row per (tenant, stage) naming the install that processes released orders.
2
- -- A cleared config keeps the row with state `cleared`; rows are never deleted.
3
- CREATE TABLE `fulfillment_processor_config` (
4
- `tenant_id` text NOT NULL,
5
- `stage` text NOT NULL CHECK (`stage` IN ('preview', 'publication')),
6
- `install_id` text NOT NULL,
7
- `state` text NOT NULL CHECK (`state` IN ('active', 'cleared')),
8
- `updated_by` text NOT NULL,
9
- `updated_at` text NOT NULL,
10
- PRIMARY KEY (`tenant_id`, `stage`)
11
- );
12
- --> statement-breakpoint
13
- -- Assignments move by state and keep history; none is deleted.
14
- CREATE TABLE `fulfillment_assignments` (
15
- `assignment_id` text PRIMARY KEY NOT NULL,
16
- `tenant_id` text NOT NULL,
17
- `stage` text NOT NULL CHECK (`stage` IN ('preview', 'publication')),
18
- `order_id` text NOT NULL,
19
- `install_id` text NOT NULL,
20
- `state` text NOT NULL CHECK (`state` IN ('active', 'held', 'cancelled', 'released')),
21
- `event_version` integer NOT NULL CHECK (`event_version` >= 0),
22
- `assigned_at` text NOT NULL,
23
- `updated_at` text NOT NULL
24
- );
25
- --> statement-breakpoint
26
- CREATE UNIQUE INDEX `fulfillment_assignments_open_order`
27
- ON `fulfillment_assignments` (`tenant_id`, `stage`, `order_id`)
28
- WHERE `state` IN ('active', 'held');
29
- --> statement-breakpoint
30
- CREATE INDEX `fulfillment_assignments_install_state`
31
- ON `fulfillment_assignments` (`tenant_id`, `stage`, `install_id`, `state`, `assigned_at`);
32
- --> statement-breakpoint
33
- -- One claim per business event across every emitter that can report it.
34
- CREATE TABLE `commerce_event_claims` (
35
- `tenant_id` text NOT NULL,
36
- `stage` text NOT NULL CHECK (`stage` IN ('preview', 'publication')),
37
- `source` text NOT NULL,
38
- `source_order_id` text NOT NULL,
39
- `topic` text NOT NULL CHECK (`topic` IN ('order.fulfilled')),
40
- `event_id` text NOT NULL,
41
- `claimed_by` text NOT NULL CHECK (`claimed_by` IN ('handoff', 'forward')),
42
- `claimed_at` text NOT NULL,
43
- PRIMARY KEY (`tenant_id`, `stage`, `source`, `source_order_id`, `topic`)
44
- );
@@ -1,70 +0,0 @@
1
- -- Owner consent for a Private App install to read order recipients for one purpose. Opaque ids and
2
- -- times only; granted_by is sha256 of the owner actor id. Revoke sets revoked_at once; rows are never
3
- -- deleted, and re-granting inserts a new row.
4
- CREATE TABLE `app_contact_consents` (
5
- `consent_id` text PRIMARY KEY NOT NULL,
6
- `install_id` text NOT NULL,
7
- `tenant_id` text NOT NULL,
8
- `stage` text NOT NULL CHECK (`stage` IN ('preview', 'publication')),
9
- `purpose` text NOT NULL CHECK (`purpose` = 'fulfillment-shipping'),
10
- `granted_by` text NOT NULL CHECK (length(`granted_by`) = 64 AND `granted_by` NOT GLOB '*[^0-9a-f]*'),
11
- `granted_at` text NOT NULL,
12
- `expires_at` text NOT NULL,
13
- `revoked_at` text,
14
- CHECK (`expires_at` > `granted_at`),
15
- CHECK (julianday(`expires_at`) IS NOT NULL AND julianday(`granted_at`) IS NOT NULL
16
- AND julianday(`expires_at`) - julianday(`granted_at`) <= 365)
17
- );
18
- --> statement-breakpoint
19
- CREATE UNIQUE INDEX `app_contact_consents_live`
20
- ON `app_contact_consents` (`install_id`, `tenant_id`, `stage`, `purpose`)
21
- WHERE `revoked_at` IS NULL;
22
- --> statement-breakpoint
23
- CREATE TRIGGER `app_contact_consents_no_delete`
24
- BEFORE DELETE ON `app_contact_consents`
25
- BEGIN
26
- SELECT RAISE(ABORT, 'append-only');
27
- END;
28
- --> statement-breakpoint
29
- CREATE TRIGGER `app_contact_consents_revoke_only`
30
- BEFORE UPDATE ON `app_contact_consents`
31
- WHEN OLD.`revoked_at` IS NOT NULL
32
- OR NEW.`revoked_at` IS NULL
33
- OR NEW.`consent_id` IS NOT OLD.`consent_id`
34
- OR NEW.`install_id` IS NOT OLD.`install_id`
35
- OR NEW.`tenant_id` IS NOT OLD.`tenant_id`
36
- OR NEW.`stage` IS NOT OLD.`stage`
37
- OR NEW.`purpose` IS NOT OLD.`purpose`
38
- OR NEW.`granted_by` IS NOT OLD.`granted_by`
39
- OR NEW.`granted_at` IS NOT OLD.`granted_at`
40
- OR NEW.`expires_at` IS NOT OLD.`expires_at`
41
- BEGIN
42
- SELECT RAISE(ABORT, 'revoke-only');
43
- END;
44
- --> statement-breakpoint
45
- -- Every admitted app read of an order recipient, written before anything is decrypted. Opaque ids
46
- -- only; append-only.
47
- CREATE TABLE `app_contact_access_audit` (
48
- `audit_id` text PRIMARY KEY NOT NULL,
49
- `install_id` text NOT NULL,
50
- `tenant_id` text NOT NULL,
51
- `stage` text NOT NULL CHECK (`stage` IN ('preview', 'publication')),
52
- `order_id` text NOT NULL,
53
- `purpose` text NOT NULL CHECK (`purpose` = 'fulfillment-shipping'),
54
- `at` text NOT NULL,
55
- `outcome` text NOT NULL CHECK (`outcome` = 'admitted')
56
- );
57
- --> statement-breakpoint
58
- CREATE INDEX `idx_app_contact_access_audit_quota` ON `app_contact_access_audit` (`install_id`, `tenant_id`, `at`);
59
- --> statement-breakpoint
60
- CREATE TRIGGER `app_contact_access_audit_no_update`
61
- BEFORE UPDATE ON `app_contact_access_audit`
62
- BEGIN
63
- SELECT RAISE(ABORT, 'append-only');
64
- END;
65
- --> statement-breakpoint
66
- CREATE TRIGGER `app_contact_access_audit_no_delete`
67
- BEFORE DELETE ON `app_contact_access_audit`
68
- BEGIN
69
- SELECT RAISE(ABORT, 'append-only');
70
- END;
@@ -1,133 +0,0 @@
1
- -- How an install's client authenticates at the token endpoint. A private_key_jwt credential keeps a
2
- -- secret_hash of discarded random bytes, and the secret path refuses it.
3
- ALTER TABLE `app_credentials` ADD `auth_method` text DEFAULT 'client_secret' NOT NULL
4
- CHECK (`auth_method` IN ('client_secret', 'private_key_jwt'));
5
- --> statement-breakpoint
6
- -- Public client keys for private_key_jwt: a validated public JWKS or a jwks_uri, bound to exactly one
7
- -- install or one production candidate. Opaque actor ids only. Never deleted; a candidate's key set
8
- -- is part of its immutable snapshot.
9
- CREATE TABLE `app_client_keys` (
10
- `key_set_id` text PRIMARY KEY NOT NULL,
11
- `install_id` text,
12
- `candidate_id` text,
13
- `tenant_id` text NOT NULL,
14
- `jwks` text,
15
- `jwks_uri` text,
16
- `updated_at` text NOT NULL,
17
- `updated_by` text NOT NULL,
18
- CHECK ((`install_id` IS NULL) <> (`candidate_id` IS NULL)),
19
- CHECK ((`jwks` IS NULL) <> (`jwks_uri` IS NULL))
20
- );
21
- --> statement-breakpoint
22
- CREATE UNIQUE INDEX `app_client_keys_install` ON `app_client_keys` (`install_id`);
23
- --> statement-breakpoint
24
- CREATE UNIQUE INDEX `app_client_keys_candidate` ON `app_client_keys` (`candidate_id`);
25
- --> statement-breakpoint
26
- CREATE TRIGGER `app_client_keys_no_delete`
27
- BEFORE DELETE ON `app_client_keys`
28
- BEGIN
29
- SELECT RAISE(ABORT, 'append-only');
30
- END;
31
- --> statement-breakpoint
32
- CREATE TRIGGER `app_client_keys_binding_fixed`
33
- BEFORE UPDATE ON `app_client_keys`
34
- WHEN OLD.`candidate_id` IS NOT NULL
35
- OR NEW.`key_set_id` IS NOT OLD.`key_set_id`
36
- OR NEW.`install_id` IS NOT OLD.`install_id`
37
- OR NEW.`candidate_id` IS NOT OLD.`candidate_id`
38
- OR NEW.`tenant_id` IS NOT OLD.`tenant_id`
39
- BEGIN
40
- SELECT RAISE(ABORT, 'binding-fixed');
41
- END;
42
- --> statement-breakpoint
43
- -- Single-use client assertion ids. Rows past exp_at (epoch seconds) plus the clock tolerance are
44
- -- pruned on insert; nothing else deletes or updates them.
45
- CREATE TABLE `app_client_assertion_jti` (
46
- `client_id` text NOT NULL,
47
- `jti` text NOT NULL,
48
- `exp_at` integer NOT NULL,
49
- PRIMARY KEY (`client_id`, `jti`)
50
- );
51
- --> statement-breakpoint
52
- CREATE INDEX `idx_app_client_assertion_jti_exp` ON `app_client_assertion_jti` (`exp_at`);
53
- --> statement-breakpoint
54
- CREATE TRIGGER `app_client_assertion_jti_no_update`
55
- BEFORE UPDATE ON `app_client_assertion_jti`
56
- BEGIN
57
- SELECT RAISE(ABORT, 'append-only');
58
- END;
59
- --> statement-breakpoint
60
- -- A staged production install awaiting a human owner. The snapshot columns are immutable; the only
61
- -- update is the single pending_approval -> approved|rejected transition. Rows are never deleted.
62
- CREATE TABLE `app_install_candidates` (
63
- `candidate_id` text PRIMARY KEY NOT NULL,
64
- `tenant_id` text NOT NULL,
65
- `app_id` text NOT NULL,
66
- `app_version` text NOT NULL,
67
- `env` text DEFAULT 'production' NOT NULL CHECK (`env` = 'production'),
68
- `scopes` text NOT NULL,
69
- `manifest` text NOT NULL,
70
- `webhook_endpoint` text,
71
- `widget_placements` text DEFAULT '[]' NOT NULL,
72
- `client_id` text NOT NULL,
73
- `request_consent` integer DEFAULT 0 NOT NULL CHECK (`request_consent` IN (0, 1)),
74
- `snapshot_digest` text NOT NULL CHECK (length(`snapshot_digest`) = 64 AND `snapshot_digest` NOT GLOB '*[^0-9a-f]*'),
75
- `status` text DEFAULT 'pending_approval' NOT NULL
76
- CHECK (`status` IN ('pending_approval', 'approved', 'rejected')),
77
- `staged_by` text NOT NULL,
78
- `staged_at` text NOT NULL,
79
- `decided_by` text,
80
- `decided_at` text,
81
- `decision_id` text,
82
- `install_id` text,
83
- CHECK (
84
- (`status` = 'pending_approval' AND `decided_by` IS NULL AND `decided_at` IS NULL
85
- AND `decision_id` IS NULL AND `install_id` IS NULL)
86
- OR (`status` = 'approved' AND `decided_by` IS NOT NULL AND `decided_at` IS NOT NULL
87
- AND `decision_id` IS NOT NULL AND `install_id` IS NOT NULL)
88
- OR (`status` = 'rejected' AND `decided_by` IS NOT NULL AND `decided_at` IS NOT NULL
89
- AND `decision_id` IS NOT NULL AND `install_id` IS NULL)
90
- )
91
- );
92
- --> statement-breakpoint
93
- CREATE UNIQUE INDEX `app_install_candidates_client_id` ON `app_install_candidates` (`client_id`);
94
- --> statement-breakpoint
95
- CREATE UNIQUE INDEX `app_install_candidates_one_pending`
96
- ON `app_install_candidates` (`tenant_id`, `app_id`)
97
- WHERE `status` = 'pending_approval';
98
- --> statement-breakpoint
99
- CREATE INDEX `idx_app_install_candidates_tenant` ON `app_install_candidates` (`tenant_id`, `staged_at`);
100
- --> statement-breakpoint
101
- CREATE TRIGGER `app_install_candidates_no_delete`
102
- BEFORE DELETE ON `app_install_candidates`
103
- BEGIN
104
- SELECT RAISE(ABORT, 'append-only');
105
- END;
106
- --> statement-breakpoint
107
- CREATE TRIGGER `app_install_candidates_decide_once`
108
- BEFORE UPDATE ON `app_install_candidates`
109
- WHEN OLD.`status` <> 'pending_approval'
110
- BEGIN
111
- SELECT RAISE(ABORT, 'decide-once');
112
- END;
113
- --> statement-breakpoint
114
- CREATE TRIGGER `app_install_candidates_snapshot_immutable`
115
- BEFORE UPDATE ON `app_install_candidates`
116
- WHEN NEW.`status` = 'pending_approval'
117
- OR NEW.`candidate_id` IS NOT OLD.`candidate_id`
118
- OR NEW.`tenant_id` IS NOT OLD.`tenant_id`
119
- OR NEW.`app_id` IS NOT OLD.`app_id`
120
- OR NEW.`app_version` IS NOT OLD.`app_version`
121
- OR NEW.`env` IS NOT OLD.`env`
122
- OR NEW.`scopes` IS NOT OLD.`scopes`
123
- OR NEW.`manifest` IS NOT OLD.`manifest`
124
- OR NEW.`webhook_endpoint` IS NOT OLD.`webhook_endpoint`
125
- OR NEW.`widget_placements` IS NOT OLD.`widget_placements`
126
- OR NEW.`client_id` IS NOT OLD.`client_id`
127
- OR NEW.`request_consent` IS NOT OLD.`request_consent`
128
- OR NEW.`snapshot_digest` IS NOT OLD.`snapshot_digest`
129
- OR NEW.`staged_by` IS NOT OLD.`staged_by`
130
- OR NEW.`staged_at` IS NOT OLD.`staged_at`
131
- BEGIN
132
- SELECT RAISE(ABORT, 'snapshot-immutable');
133
- END;