better-supabase 0.59.0 → 0.61.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 (757) hide show
  1. package/api/naming.json +1994 -0
  2. package/dist/{account-parts-DxSyD4yi.d.ts → account-parts-DtC5voD1.d.ts} +3 -3
  3. package/dist/{activities-BkfN6cef.d.ts → activities-BMQuBkrQ.d.ts} +8 -8
  4. package/dist/{adapter-base-BAjra5Eb.js → adapter-base-DGiRWzEo.js} +2 -2
  5. package/dist/{agents-CbsEgoLN.d.ts → agents-3wTmHYZr.d.ts} +6 -6
  6. package/dist/{agents-B8kXBfH9.d.ts → agents-NaSREeo_.d.ts} +4 -4
  7. package/dist/{ai-cache-DfbYR_jG.d.ts → ai-cache-CKOJ9cLZ.d.ts} +4 -4
  8. package/dist/{ai-chat-DyffOt16.d.ts → ai-chat-C8FEgeTd.d.ts} +4 -4
  9. package/dist/{ai-guardrails-y6RVvDOH.d.ts → ai-guardrails-fzpJmgzI.d.ts} +3 -3
  10. package/dist/{ai-schedules-BxBsTpji.d.ts → ai-schedules-CtxaSWA1.d.ts} +5 -5
  11. package/dist/ai-sdk/agents/index.d.ts +2 -2
  12. package/dist/ai-sdk/batches/index.d.ts +3 -3
  13. package/dist/ai-sdk/cache/index.d.ts +1 -1
  14. package/dist/ai-sdk/chat/index.d.ts +2 -2
  15. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  16. package/dist/ai-sdk/files/index.d.ts +1 -1
  17. package/dist/ai-sdk/index.d.ts +8 -8
  18. package/dist/ai-sdk/mcp/index.d.ts +3 -3
  19. package/dist/ai-sdk/memory/index.d.ts +3 -3
  20. package/dist/ai-sdk/workflow/index.d.ts +4 -4
  21. package/dist/ai-sdk/workflow/index.js +1 -1
  22. package/dist/{api-DAJJ7N_0.js → api-Q23GAwx1.js} +1 -1
  23. package/dist/{api-keys-BlfwKpXq.d.ts → api-keys-Bfk9mJgz.d.ts} +4 -4
  24. package/dist/{api-wRlj_7so.d.ts → api-pGkHTqH6.d.ts} +5 -5
  25. package/dist/{app-tables-DBmFqdFN.d.ts → app-tables-BHoeMC9w.d.ts} +1 -1
  26. package/dist/{approvals-Bbxeiywy.d.ts → approvals-B1mzlyzk.d.ts} +12 -6
  27. package/dist/{approvals-Clg-7ghA.js → approvals-D7Xhpd52.js} +8 -6
  28. package/dist/{assistant-53zK5w6Q.d.ts → assistant-BQAjAXDe.d.ts} +2 -2
  29. package/dist/astro/index.d.ts +6 -6
  30. package/dist/astro/index.js +4 -4
  31. package/dist/{auth-module-D_RA-X_y.js → auth-module-B19zCsb4.js} +1 -1
  32. package/dist/{authorization-Dq47C4vf.d.ts → authorization-glyinWcf.d.ts} +9 -3
  33. package/dist/{authorization-hooks-DtuVzDBf.d.ts → authorization-hooks-Oe0WJTn2.d.ts} +2 -2
  34. package/dist/{authz-refresh-CNV_LFEh.js → authz-refresh-27sp45FG.js} +1 -1
  35. package/dist/{banking-reads-4m0_lltt.js → banking-reads-Baaatsuj.js} +1 -1
  36. package/dist/{base64-CEBz6-Jj.js → base64-DgNIlSAS.js} +1 -1
  37. package/dist/better-result/index.d.ts +3 -3
  38. package/dist/{bind-Bx0H1vAc.d.ts → bind-B-NW7-Fd.d.ts} +8 -8
  39. package/dist/{block-controller-CHtFwmpj.d.ts → block-controller-Dy-Jyy8A.d.ts} +2 -2
  40. package/dist/{block-env-DUn5reXc.d.ts → block-env-BN4cyqTj.d.ts} +4 -4
  41. package/dist/{block-event-listener-B1JTV_Ca.d.ts → block-event-listener-CQrt2JR-.d.ts} +1 -1
  42. package/dist/{block-events-records-x6GNmg6M.d.ts → block-events-records-CUCsDp0S.d.ts} +2 -2
  43. package/dist/{block-helpers-D0QSs8ss.d.ts → block-helpers-DDotKGAf.d.ts} +1 -1
  44. package/dist/{block-hooks-StmUvtuT.d.ts → block-hooks-b7-RUIxS.d.ts} +2 -2
  45. package/dist/{block-subjects-DzCWFD-t.d.ts → block-subjects-CG1x9djp.d.ts} +1 -1
  46. package/dist/{block-tables-BaLXCQha.d.ts → block-tables-CkbJsNys.d.ts} +1 -1
  47. package/dist/{block-transport-BNMvuuyC.d.ts → block-transport-Bqne7_GN.d.ts} +2 -2
  48. package/dist/blocks/access-requests/index.d.ts +3 -3
  49. package/dist/blocks/accounting/index.d.ts +3 -3
  50. package/dist/blocks/acknowledgements/index.d.ts +2 -2
  51. package/dist/blocks/activities/index.d.ts +6 -6
  52. package/dist/blocks/activities/index.js +1 -1
  53. package/dist/blocks/advisories/index.d.ts +5 -5
  54. package/dist/blocks/agent-checkout/index.d.ts +7 -7
  55. package/dist/blocks/agent-checkout/index.js +2 -2
  56. package/dist/blocks/agents/index.d.ts +5 -5
  57. package/dist/blocks/ai-cache/index.d.ts +3 -3
  58. package/dist/blocks/ai-chat/index.d.ts +4 -4
  59. package/dist/blocks/ai-evals/index.d.ts +4 -4
  60. package/dist/blocks/ai-files/index.d.ts +3 -3
  61. package/dist/blocks/ai-guardrails/index.d.ts +4 -4
  62. package/dist/blocks/ai-keys/index.d.ts +4 -4
  63. package/dist/blocks/ai-schedules/index.d.ts +3 -3
  64. package/dist/blocks/announcements/index.d.ts +8 -8
  65. package/dist/blocks/api-keys/index.d.ts +3 -3
  66. package/dist/blocks/appraisals/index.d.ts +5 -5
  67. package/dist/blocks/approvals/index.d.ts +3 -3
  68. package/dist/blocks/approvals/index.js +2 -2
  69. package/dist/blocks/assets/index.d.ts +4 -4
  70. package/dist/blocks/assignment/index.d.ts +3 -3
  71. package/dist/blocks/attachments/index.d.ts +10 -10
  72. package/dist/blocks/audit/index.d.ts +4 -4
  73. package/dist/blocks/audit/index.js +1 -1
  74. package/dist/blocks/automations/index.d.ts +12 -12
  75. package/dist/blocks/banking/index.d.ts +3 -3
  76. package/dist/blocks/banking/index.js +1 -1
  77. package/dist/blocks/billable-time/index.d.ts +3 -3
  78. package/dist/blocks/billing/index.d.ts +6 -6
  79. package/dist/blocks/billing/index.js +1 -1
  80. package/dist/blocks/bookings/index.d.ts +3 -3
  81. package/dist/blocks/bulk-actions/index.d.ts +5 -5
  82. package/dist/blocks/calendar/index.d.ts +3 -3
  83. package/dist/blocks/care/index.d.ts +30 -30
  84. package/dist/blocks/care/index.js +8 -8
  85. package/dist/blocks/care-plans/index.d.ts +6 -6
  86. package/dist/blocks/care-plans/index.js +2 -2
  87. package/dist/blocks/cases/index.d.ts +5 -5
  88. package/dist/blocks/catalog/index.d.ts +4 -4
  89. package/dist/blocks/channels/index.d.ts +7 -7
  90. package/dist/blocks/clinical-decision-support/index.d.ts +4 -4
  91. package/dist/blocks/cms/index.d.ts +7 -7
  92. package/dist/blocks/cms/index.js +1 -1
  93. package/dist/blocks/collaboration/index.d.ts +8 -8
  94. package/dist/blocks/collections/index.d.ts +15 -12
  95. package/dist/blocks/collections/index.js +1 -1
  96. package/dist/blocks/comments/index.d.ts +4 -4
  97. package/dist/blocks/commerce/index.d.ts +7 -7
  98. package/dist/blocks/commerce/index.js +1 -1
  99. package/dist/blocks/commissions/index.d.ts +5 -5
  100. package/dist/blocks/compliance/index.d.ts +5 -5
  101. package/dist/blocks/connectors/index.d.ts +4 -4
  102. package/dist/blocks/consents/index.d.ts +5 -5
  103. package/dist/blocks/contacts/index.d.ts +5 -5
  104. package/dist/blocks/contacts/index.js +1 -1
  105. package/dist/blocks/content/index.d.ts +4 -4
  106. package/dist/blocks/contracts/index.d.ts +6 -6
  107. package/dist/blocks/courses/index.d.ts +4 -4
  108. package/dist/blocks/courses/index.js +2 -2
  109. package/dist/blocks/created-by/index.d.ts +3 -3
  110. package/dist/blocks/crm/index.d.ts +18 -18
  111. package/dist/blocks/crm/index.js +5 -5
  112. package/dist/blocks/custom-fields/index.d.ts +2 -2
  113. package/dist/blocks/dam/index.d.ts +6 -6
  114. package/dist/blocks/data-lifecycle/index.d.ts +3 -3
  115. package/dist/blocks/deadlines/index.d.ts +5 -5
  116. package/dist/blocks/deals/index.d.ts +3 -3
  117. package/dist/blocks/dispatch/index.d.ts +4 -4
  118. package/dist/blocks/document-templates/index.d.ts +6 -6
  119. package/dist/blocks/documents/index.d.ts +4 -4
  120. package/dist/blocks/documents/index.js +1 -1
  121. package/dist/blocks/domains/index.d.ts +6 -6
  122. package/dist/blocks/donations/index.d.ts +6 -6
  123. package/dist/blocks/drive/index.d.ts +6 -6
  124. package/dist/blocks/drive/index.js +1 -1
  125. package/dist/blocks/e-prescribing/index.d.ts +4 -4
  126. package/dist/blocks/employees/index.d.ts +3 -3
  127. package/dist/blocks/enrichment/index.d.ts +3 -3
  128. package/dist/blocks/enrollments/index.d.ts +4 -4
  129. package/dist/blocks/entitlements/index.d.ts +4 -4
  130. package/dist/blocks/events/index.d.ts +5 -5
  131. package/dist/blocks/events/index.js +1 -1
  132. package/dist/blocks/expenses/index.d.ts +5 -5
  133. package/dist/blocks/field-history/index.d.ts +3 -3
  134. package/dist/blocks/filespace/index.d.ts +9 -9
  135. package/dist/blocks/filespace/index.js +1 -1
  136. package/dist/blocks/finance/index.d.ts +6 -6
  137. package/dist/blocks/finance/index.js +3 -3
  138. package/dist/blocks/flags/index.d.ts +5 -5
  139. package/dist/blocks/forecasts/index.d.ts +3 -3
  140. package/dist/blocks/forms/index.d.ts +4 -4
  141. package/dist/blocks/funding/index.d.ts +5 -5
  142. package/dist/blocks/funding/index.js +1 -1
  143. package/dist/blocks/goals/index.d.ts +3 -3
  144. package/dist/blocks/governance/index.d.ts +5 -5
  145. package/dist/blocks/guests/index.d.ts +3 -3
  146. package/dist/blocks/hiring/index.d.ts +3 -3
  147. package/dist/blocks/hiring/index.js +1 -1
  148. package/dist/blocks/identities/index.d.ts +5 -5
  149. package/dist/blocks/imports/index.d.ts +6 -6
  150. package/dist/blocks/inbox/index.d.ts +10 -10
  151. package/dist/blocks/incidents/index.d.ts +5 -5
  152. package/dist/blocks/index.d.ts +12 -12
  153. package/dist/blocks/index.js +2 -2
  154. package/dist/blocks/inspections/index.d.ts +6 -6
  155. package/dist/blocks/inventory/index.d.ts +3 -3
  156. package/dist/blocks/invoices/index.d.ts +6 -6
  157. package/dist/blocks/invoices/index.js +1 -1
  158. package/dist/blocks/knowledge/index.d.ts +3 -3
  159. package/dist/blocks/lead-scoring/index.d.ts +4 -4
  160. package/dist/blocks/learning/index.d.ts +5 -5
  161. package/dist/blocks/leases/index.d.ts +6 -6
  162. package/dist/blocks/leave/index.d.ts +3 -3
  163. package/dist/blocks/ledger/index.d.ts +6 -6
  164. package/dist/blocks/legal-entities/index.d.ts +6 -6
  165. package/dist/blocks/lims/index.d.ts +6 -6
  166. package/dist/blocks/mail-sync/index.d.ts +5 -5
  167. package/dist/blocks/maintenance/index.d.ts +4 -4
  168. package/dist/blocks/manufacturing/index.d.ts +7 -7
  169. package/dist/blocks/medications/index.d.ts +4 -4
  170. package/dist/blocks/medications/index.js +1 -1
  171. package/dist/blocks/meetings/index.d.ts +5 -5
  172. package/dist/blocks/memberships/index.d.ts +3 -3
  173. package/dist/blocks/memory/index.d.ts +4 -4
  174. package/dist/blocks/messaging/index.d.ts +11 -11
  175. package/dist/blocks/metrics/index.d.ts +6 -6
  176. package/dist/blocks/mfa/index.d.ts +2 -2
  177. package/dist/blocks/moderation/index.d.ts +7 -7
  178. package/dist/blocks/notifications/index.d.ts +10 -10
  179. package/dist/blocks/notifications/index.js +2 -2
  180. package/dist/blocks/numbering/index.d.ts +1 -1
  181. package/dist/blocks/oauth-server/index.d.ts +5 -5
  182. package/dist/blocks/oauth-server/index.js +1 -1
  183. package/dist/blocks/observations/index.d.ts +5 -5
  184. package/dist/blocks/onboarding/index.d.ts +3 -3
  185. package/dist/blocks/option-sets/index.d.ts +6 -6
  186. package/dist/blocks/orders/index.d.ts +4 -4
  187. package/dist/blocks/orders/index.js +1 -1
  188. package/dist/blocks/organizations/index.d.ts +4 -4
  189. package/dist/blocks/outbox/index.d.ts +4 -4
  190. package/dist/blocks/outbox/index.js +1 -1
  191. package/dist/blocks/passes/index.d.ts +4 -4
  192. package/dist/blocks/passes/index.js +1 -1
  193. package/dist/blocks/payroll-export/index.d.ts +4 -4
  194. package/dist/blocks/payroll-export/index.js +1 -1
  195. package/dist/blocks/people/index.d.ts +8 -8
  196. package/dist/blocks/people/index.js +1 -1
  197. package/dist/blocks/periods/index.d.ts +5 -5
  198. package/dist/blocks/permissions/index.d.ts +7 -7
  199. package/dist/blocks/pipelines/index.d.ts +4 -4
  200. package/dist/blocks/posts/index.d.ts +6 -6
  201. package/dist/blocks/procurement/index.d.ts +6 -6
  202. package/dist/blocks/procurement/index.js +2 -2
  203. package/dist/blocks/profiles/index.d.ts +3 -3
  204. package/dist/blocks/projects/index.d.ts +8 -8
  205. package/dist/blocks/projects/index.js +2 -2
  206. package/dist/blocks/promotions/index.d.ts +3 -3
  207. package/dist/blocks/prompts/index.d.ts +4 -4
  208. package/dist/blocks/push/index.d.ts +7 -7
  209. package/dist/blocks/qualifications/index.d.ts +4 -4
  210. package/dist/blocks/queue/index.d.ts +5 -5
  211. package/dist/blocks/queue/index.js +2 -2
  212. package/dist/blocks/quotes/index.d.ts +5 -5
  213. package/dist/blocks/rank/index.d.ts +7 -7
  214. package/dist/blocks/rank/index.js +1 -1
  215. package/dist/blocks/reactions/index.d.ts +6 -6
  216. package/dist/blocks/recruiting/index.d.ts +5 -5
  217. package/dist/blocks/recruiting/index.js +1 -1
  218. package/dist/blocks/referrals/index.d.ts +5 -5
  219. package/dist/blocks/relations/index.d.ts +7 -7
  220. package/dist/blocks/reminders/index.d.ts +1 -1
  221. package/dist/blocks/reminders/index.js +1 -1
  222. package/dist/blocks/reviews/index.d.ts +5 -5
  223. package/dist/blocks/rfqs/index.d.ts +4 -4
  224. package/dist/blocks/risks/index.d.ts +6 -6
  225. package/dist/blocks/saas/index.d.ts +14 -14
  226. package/dist/blocks/saas/index.js +2 -2
  227. package/dist/blocks/sales/index.d.ts +1 -1
  228. package/dist/blocks/sales/index.js +1 -1
  229. package/dist/blocks/saved-views/index.d.ts +6 -6
  230. package/dist/blocks/scheduling/index.d.ts +6 -6
  231. package/dist/blocks/scheduling/index.js +1 -1
  232. package/dist/blocks/scores/index.d.ts +6 -6
  233. package/dist/blocks/search/index.d.ts +5 -5
  234. package/dist/blocks/search/index.js +1 -1
  235. package/dist/blocks/security-events/index.d.ts +7 -7
  236. package/dist/blocks/security-events/index.js +1 -1
  237. package/dist/blocks/segments/index.d.ts +4 -4
  238. package/dist/blocks/sequences/index.d.ts +5 -5
  239. package/dist/blocks/service/index.d.ts +8 -8
  240. package/dist/blocks/service-accounts/index.d.ts +5 -5
  241. package/dist/blocks/sessions/index.d.ts +4 -4
  242. package/dist/blocks/settings/index.d.ts +4 -4
  243. package/dist/blocks/share-links/index.d.ts +1 -1
  244. package/dist/blocks/shifts/index.d.ts +4 -4
  245. package/dist/blocks/shipments/index.d.ts +6 -6
  246. package/dist/blocks/shipments/index.js +1 -1
  247. package/dist/blocks/signatures/index.d.ts +3 -3
  248. package/dist/blocks/signing-keys/index.d.ts +3 -3
  249. package/dist/blocks/signing-keys/index.js +2 -2
  250. package/dist/blocks/sla/index.d.ts +3 -3
  251. package/dist/blocks/sso/index.d.ts +6 -6
  252. package/dist/blocks/state-machine/index.d.ts +2 -2
  253. package/dist/blocks/state-machine/index.js +1 -1
  254. package/dist/blocks/subjects/index.d.ts +7 -7
  255. package/dist/blocks/subjects/index.js +1 -1
  256. package/dist/blocks/support/index.d.ts +6 -6
  257. package/dist/blocks/tags/index.d.ts +3 -3
  258. package/dist/blocks/tasks/index.d.ts +4 -4
  259. package/dist/blocks/tax/index.d.ts +4 -4
  260. package/dist/blocks/tax/index.js +1 -1
  261. package/dist/blocks/teams/index.d.ts +1 -1
  262. package/dist/blocks/templates/index.d.ts +8 -8
  263. package/dist/blocks/tills/index.d.ts +5 -5
  264. package/dist/blocks/time-entries/index.d.ts +3 -3
  265. package/dist/blocks/timeline/index.d.ts +2 -2
  266. package/dist/blocks/trash/index.d.ts +3 -3
  267. package/dist/blocks/undo/index.d.ts +4 -4
  268. package/dist/blocks/updated-at/index.d.ts +3 -3
  269. package/dist/blocks/usage/index.d.ts +4 -4
  270. package/dist/blocks/vercel-marketplace/index.d.ts +5 -5
  271. package/dist/blocks/vercel-marketplace/index.js +3 -3
  272. package/dist/blocks/versions/index.d.ts +2 -2
  273. package/dist/blocks/waitlist/index.d.ts +5 -5
  274. package/dist/blocks/waitlist/index.js +1 -1
  275. package/dist/blocks/warehouse/index.d.ts +5 -5
  276. package/dist/blocks/warranty/index.d.ts +5 -5
  277. package/dist/blocks/webhooks/index.d.ts +15 -15
  278. package/dist/blocks/webhooks/index.js +6 -6
  279. package/dist/blocks/workflow-editor/index.d.ts +9 -9
  280. package/dist/blocks/workflows/index.d.ts +7 -7
  281. package/dist/{blocks-RVd7m590.d.ts → blocks-D4ngpPJ_.d.ts} +17 -7
  282. package/dist/{bookings-sBb-GMK8.d.ts → bookings-6dC83XE6.d.ts} +3 -3
  283. package/dist/{bootstrap-permissions-BOkRVEEh.js → bootstrap-permissions-CulW-R_u.js} +2 -2
  284. package/dist/{bucket-CbRyXRp3.d.ts → bucket-BJ03ZblY.d.ts} +1 -1
  285. package/dist/{build-Rz89mkdS.js → build-CRxrX567.js} +1 -1
  286. package/dist/{cache-tags-BxpxsCtq.d.ts → cache-tags-UWvxDMDO.d.ts} +1 -1
  287. package/dist/{care-plans-BR3TkinL.d.ts → care-plans-q3m4ph4G.d.ts} +2 -2
  288. package/dist/{care-plans-sql-DyB5TB6y.js → care-plans-sql-B__5eEaI.js} +1 -1
  289. package/dist/chat-sdk/index.d.ts +6 -6
  290. package/dist/claims/index.d.ts +7 -7
  291. package/dist/{claims-source-BEVTXHQx.d.ts → claims-source-D-4CztOl.d.ts} +2 -2
  292. package/dist/cli/{add-BJNTq7Ti.js → add-CN5jkEFM.js} +2 -2
  293. package/dist/cli/add-fra98UnY.js +1 -0
  294. package/dist/cli/{add-CnCt2QoB.js → add-ucxskHiv.js} +11 -11
  295. package/dist/cli/{app-table-files-CfB0_NuX.js → app-table-files-FcgTfOf9.js} +4 -4
  296. package/dist/cli/{app-tables-oieRU_sP.js → app-tables-DCpSNfJ3.js} +2 -2
  297. package/dist/cli/{backfill-Cr5jgVi1.js → backfill-DVP_elK_.js} +3 -3
  298. package/dist/cli/bin.js +1 -1
  299. package/dist/cli/{blocks-DLMVaOFG.js → blocks-CFKjKW4s.js} +1 -1
  300. package/dist/cli/{blocks-B-ANsRnH.js → blocks-iSEepN2Y.js} +1 -1
  301. package/dist/cli/{cache-Ba26VW2N.js → cache-CNa3fjK-.js} +1 -1
  302. package/dist/cli/{codemod-x1I7Mjr3.js → codemod-DH-VSZps.js} +6 -6
  303. package/dist/cli/{codemod-naming-CZhndoO7.js → codemod-naming-CuQ0ltfE.js} +1 -1
  304. package/dist/cli/{codes-DNq30BZg.js → codes-D_oa7Aw5.js} +3 -3
  305. package/dist/cli/{column-renames-BEEDF6P6.js → column-renames-CtcG8MR5.js} +2 -2
  306. package/dist/cli/{config-DkjilxeE.js → config-CoW6aoul.js} +1 -1
  307. package/dist/cli/{config-DD_MnPRL.js → config-DX58lDf7.js} +7 -1
  308. package/dist/cli/{content-mapper-z7CrnE1s.js → content-mapper-TATvvrmb.js} +1 -1
  309. package/dist/cli/{db-CEUnv3hK.js → db-CZ9qHsDs.js} +2 -2
  310. package/dist/cli/{dev-D9nn9Gzt.js → dev-BDv1efAy.js} +5 -5
  311. package/dist/cli/{doctor-DCorhlir.js → doctor-CkO1yd7F.js} +242 -109
  312. package/dist/cli/{emit-qQdWBc9e.js → emit-OhupwGNp.js} +3 -3
  313. package/dist/cli/{gen-Bf1ujcTm.js → gen-1lVJoeH1.js} +5 -5
  314. package/dist/cli/{gen-tasks-q9JJSJ6r.js → gen-tasks-BgxoXxuF.js} +11 -11
  315. package/dist/cli/index.d.ts +1 -1
  316. package/dist/cli/index.js +8 -8
  317. package/dist/cli/{init-DLLfL1uL.js → init-Defy7VJ0.js} +9 -9
  318. package/dist/cli/{live-D4giSEyd.js → live-DmvnAvGV.js} +2 -2
  319. package/dist/cli/{mcp-DwjeMbmV.js → mcp-BGKeD-lo.js} +2 -2
  320. package/dist/cli/{memo-backend-DPGMyJvH.js → memo-backend-3u-X51UO.js} +1 -1
  321. package/dist/cli/{metadata-Cft3CW1M.js → metadata-D0UazHyQ.js} +4 -4
  322. package/dist/cli/{migrate-Ci_UUuPv.js → migrate-PshyB8a6.js} +1 -1
  323. package/dist/cli/{migration-safety-D3raBuJx.js → migration-safety-DYgRA8-5.js} +2 -2
  324. package/dist/cli/{module-migration-DZtxNO8A.js → module-migration-CRsIlrig.js} +1 -1
  325. package/dist/cli/{partition-DWJ6icQ5.js → partition-ht8zldUV.js} +3 -3
  326. package/dist/cli/powersync-BztAuUyy.js +1 -0
  327. package/dist/cli/{powersync-BAyDVR-N.js → powersync-r6iL7zEo.js} +4 -4
  328. package/dist/cli/{print-BSy5c62C.js → print-Ca78W5ZF.js} +2 -2
  329. package/dist/cli/{providers-BbFKOale.js → providers-DhMSptuy.js} +1 -1
  330. package/dist/cli/{prune-workflows-VY7C9vhb.js → prune-workflows-DyZx-veL.js} +3 -3
  331. package/dist/cli/{remove-CcBoTjEO.js → remove-37g_SvZW.js} +6 -6
  332. package/dist/cli/{render-CIrcdge6.js → render-Bfh2EtMO.js} +5 -5
  333. package/dist/cli/{render-cache-bbL2UdJ6.js → render-cache-BYkVt264.js} +1 -1
  334. package/dist/cli/round-trips-BHfeIu6I.js +238 -0
  335. package/dist/cli/{run-D_p_WkPh.js → run-CfWFddfH.js} +8 -8
  336. package/dist/cli/{run-qCtE--0z.js → run-DEPt1rAn.js} +37 -36
  337. package/dist/cli/seed-B6_MBFd2.js +1 -0
  338. package/dist/cli/{seed-CvDA1ItH.js → seed-pDWlnzyK.js} +2 -2
  339. package/dist/cli/{shared-CkqZm0Bz.js → shared-BrAtQXmC.js} +1 -1
  340. package/dist/cli/{source-io7b1UpH.js → source-Bt6UAek-.js} +1 -1
  341. package/dist/cli/{source-args-yU6N6JLm.js → source-args-D5BSEgUG.js} +1 -1
  342. package/dist/cli/{spec-QGOfTJvS.js → spec-BJreyth3.js} +1 -1
  343. package/dist/cli/{spec-djAAvGKU.js → spec-DsNayDt2.js} +2 -2
  344. package/dist/cli/{sql-layout-1ASqdR4g.js → sql-layout-Bt7NcWXk.js} +4 -4
  345. package/dist/cli/{squash-DEmB47YZ.js → squash-DmbB7Gx9.js} +1 -1
  346. package/dist/cli/{sync-CUcxtnwa.js → sync-DFAkNjw_.js} +60 -8
  347. package/dist/cli/{upgrade-FWW6hKCv.js → upgrade-D8GOjXrv.js} +5 -5
  348. package/dist/cli/{upgrade-DV9mKpAp.js → upgrade-DP-30QID.js} +9 -7
  349. package/dist/cli/{verify-CrFHs8Lr.js → verify-O5zxWWuE.js} +2 -2
  350. package/dist/cli/{version-CSdXYnhG.js → version-CHVFvh95.js} +1 -1
  351. package/dist/client/index.d.ts +6 -6
  352. package/dist/client/index.js +1 -1
  353. package/dist/client/native/index.d.ts +7 -7
  354. package/dist/client/native/index.js +4 -4
  355. package/dist/{client-D1grRDjj.js → client-CPG7YGP2.js} +1 -1
  356. package/dist/{client-bucket-BLVysX-A.js → client-bucket-DvoYllSB.js} +1 -1
  357. package/dist/{clinical-decision-support-BHRUL6qj.d.ts → clinical-decision-support-D6FWGbEw.d.ts} +3 -3
  358. package/dist/{cloud-event-BtWOKfsx.d.ts → cloud-event-B0AsPtwP.d.ts} +1 -1
  359. package/dist/{codec-Cjquuv8M.js → codec-CJaAdLjG.js} +2 -2
  360. package/dist/commerce/index.js +1 -1
  361. package/dist/{compiler-BwJR_BHq.d.ts → compiler-u6lO9V7r.d.ts} +2 -2
  362. package/dist/{composite-WUO6K2Hu.js → composite-Bxpd7oru.js} +2 -2
  363. package/dist/{composite-CL4zDLjs.d.ts → composite-CxojRRUF.d.ts} +7 -7
  364. package/dist/{composite-reads-BJeDe1yV.js → composite-reads-BJJBI4tL.js} +1 -1
  365. package/dist/{composite-reads-B9psRGqQ.d.ts → composite-reads-CK-Y5b6M.d.ts} +2 -2
  366. package/dist/config/index.d.ts +5 -5
  367. package/dist/config/index.js +2 -2
  368. package/dist/{config-C3yry9U5.js → config-cisS43w5.js} +1 -1
  369. package/dist/{connectors-VX1FIU-t.d.ts → connectors-BCIhimzA.d.ts} +4 -4
  370. package/dist/{consents-OI2OWAfb.d.ts → consents-BuIwU6T3.d.ts} +3 -3
  371. package/dist/{contacts-D9_KMOgs.d.ts → contacts-4xMnNBVk.d.ts} +5 -5
  372. package/dist/{context-DMTfze4z.d.ts → context-m-t6Kr9_.d.ts} +24 -10
  373. package/dist/contract/index.d.ts +9 -9
  374. package/dist/{contributions-Bh-HcHoJ.js → contributions-Ba-C1ueE.js} +6 -6
  375. package/dist/{controller-l9h4TtKg.d.ts → controller-zwQFyrOG.d.ts} +1 -1
  376. package/dist/{conversion-D70FELty.d.ts → conversion-b6htac73.d.ts} +1 -1
  377. package/dist/create/index.d.ts +4 -4
  378. package/dist/create/index.js +2 -2
  379. package/dist/create/lite/index.d.ts +4 -4
  380. package/dist/create/lite/index.js +6 -4
  381. package/dist/credentials/index.d.ts +4 -4
  382. package/dist/credentials/index.js +1 -1
  383. package/dist/{cron-route-Cg1V2MUq.js → cron-route-spE8XDgv.js} +1 -1
  384. package/dist/{data-engine-CQiEEoNx.d.ts → data-engine-nmeUijzR.d.ts} +1 -1
  385. package/dist/{db-blocks-Db3LVXco.d.ts → db-blocks-_jJICfjp.d.ts} +16 -7
  386. package/dist/{define-BDrm9Vl7.d.ts → define-BVBAeKTi.d.ts} +1 -1
  387. package/dist/{define-block-D-Z8xB6y.d.ts → define-block-DQvTGOGv.d.ts} +14 -14
  388. package/dist/{define-runtime-Dv8OYnKW.js → define-runtime-DsFTahQB.js} +2 -2
  389. package/dist/{define-runtime-full-C4eTtJAx.js → define-runtime-full-B_cMkyCk.js} +3 -3
  390. package/dist/{delete-account-BHXzIUIq.d.ts → delete-account-BQDeafVT.d.ts} +4 -4
  391. package/dist/{documents-BHddH30g.d.ts → documents-B8Q_BKha.d.ts} +3 -3
  392. package/dist/{drive-DrD94tWF.d.ts → drive-DaEK5ZxU.d.ts} +5 -5
  393. package/dist/e-invoicing/index.d.ts +2 -2
  394. package/dist/{e-prescribing-DkV1wF9y.d.ts → e-prescribing-CP0lcOje.d.ts} +4 -4
  395. package/dist/edge/index.d.ts +9 -9
  396. package/dist/edge/index.js +5 -5
  397. package/dist/elysia/index.d.ts +1 -1
  398. package/dist/{embeddings-4zY3hhO8.d.ts → embeddings-BriQ4hQ1.d.ts} +2 -2
  399. package/dist/{ended-B1oCwF0v.d.ts → ended-CzWPQkkG.d.ts} +2 -2
  400. package/dist/{entitlements-B6q7TIMP.d.ts → entitlements-D4ob6MfK.d.ts} +3 -3
  401. package/dist/eve/index.d.ts +9 -9
  402. package/dist/eve/index.js +2 -2
  403. package/dist/{eve-BZhRFAWs.d.ts → eve-D-hvUFYE.d.ts} +2 -2
  404. package/dist/events/index.d.ts +5 -5
  405. package/dist/{events-Bk63_mjA.d.ts → events-zz8DwtZi.d.ts} +2 -2
  406. package/dist/{executor-BypvvW56.d.ts → executor-7zo2arIZ.d.ts} +1 -1
  407. package/dist/{executor-BaFzh9pS.d.ts → executor-BLv4T8kT.d.ts} +1 -1
  408. package/dist/{executor-BmcRcw83.js → executor-D24_D6dr.js} +2 -2
  409. package/dist/{executor-Dp4A_McY.d.ts → executor-nx2Q8Xdy.d.ts} +4 -4
  410. package/dist/expo/index.d.ts +6 -6
  411. package/dist/expo/index.js +5 -5
  412. package/dist/{extract-D4QPFB_M.d.ts → extract-W4zb3wIh.d.ts} +5 -5
  413. package/dist/{extras-C0cnpjDP.d.ts → extras-ByEPERCR.d.ts} +2 -2
  414. package/dist/fhir/index.d.ts +5 -5
  415. package/dist/fhir/index.js +1 -1
  416. package/dist/{field-errors-Br3wwgbu.d.ts → field-errors-pj0uOXSg.d.ts} +9 -9
  417. package/dist/{fields-OBEVi7hN.d.ts → fields-BATxzuhy.d.ts} +1 -1
  418. package/dist/{filter-evaluate-CVwpzMX-.d.ts → filter-evaluate-C2JXrZst.d.ts} +1 -1
  419. package/dist/{filter-query-CI5u0oca.d.ts → filter-query-DwJ1iMQ0.d.ts} +1 -1
  420. package/dist/{flags-Du06K0gA.d.ts → flags-CkMvfo73.d.ts} +2 -2
  421. package/dist/flags-sdk/index.d.ts +2 -2
  422. package/dist/{former-permission-keys-BwJW5uc6.js → former-permission-keys-D8FbWktT.js} +2 -2
  423. package/dist/{framework-BUzOnlJN.d.ts → framework-BYx1ke3r.d.ts} +8 -8
  424. package/dist/{framework-CbjS8M33.js → framework-pfJvMQy3.js} +1 -1
  425. package/dist/{funding-DpFfyIiK.d.ts → funding-B4vqlKq2.d.ts} +7 -7
  426. package/dist/{gateway-ChuQD_IL.d.ts → gateway-eFh5pEIu.d.ts} +3 -3
  427. package/dist/generators/factories/index.d.ts +1 -1
  428. package/dist/generators/factories/index.js +1 -1
  429. package/dist/generators/index.d.ts +2 -2
  430. package/dist/generators/json-schema/index.d.ts +2 -2
  431. package/dist/generators/json-schema/index.js +1 -1
  432. package/dist/generators/nuqs/index.d.ts +1 -1
  433. package/dist/generators/nuqs/index.js +1 -1
  434. package/dist/generators/standard-schema/index.d.ts +1 -1
  435. package/dist/generators/standard-schema/index.js +1 -1
  436. package/dist/generators/valibot/index.d.ts +1 -1
  437. package/dist/generators/valibot/index.js +1 -1
  438. package/dist/generators/zod/index.d.ts +1 -1
  439. package/dist/generators/zod/index.js +1 -1
  440. package/dist/h3/index.d.ts +1 -1
  441. package/dist/h3/v1/index.d.ts +1 -1
  442. package/dist/hono/index.d.ts +9 -9
  443. package/dist/hono/index.js +4 -4
  444. package/dist/{inbox-CDGfVOyZ.d.ts → inbox-Cr4WDuhI.d.ts} +5 -5
  445. package/dist/{index-DmoaxGHV.d.ts → index-1FGquKaz.d.ts} +3 -3
  446. package/dist/{index-DG187JM_.d.ts → index-46tesKqa.d.ts} +6 -6
  447. package/dist/{index-BAku12tP.d.ts → index-BHkxtS6f.d.ts} +1 -1
  448. package/dist/{index-BWxcC8ll.d.ts → index-BLPzvJ5v.d.ts} +9 -9
  449. package/dist/{index-BquYRGtV.d.ts → index-BVuN7_fC.d.ts} +8 -8
  450. package/dist/{index-jCKNxp8C.d.ts → index-BYDpdZxq.d.ts} +5 -5
  451. package/dist/{index-BZHDwHGW.d.ts → index-BZCCv04g.d.ts} +4 -4
  452. package/dist/{index-Dyns9a8l.d.ts → index-Bb_il0ub.d.ts} +5 -5
  453. package/dist/{index-CHOeFZUB.d.ts → index-BfnBjZpy.d.ts} +5 -5
  454. package/dist/{index-Cg0lDbXs.d.ts → index-BomyYKtC.d.ts} +6 -6
  455. package/dist/{index-DMyMrXPW.d.ts → index-BpQxfGSO.d.ts} +6 -6
  456. package/dist/{index-DU_gZYuh.d.ts → index-Bu4YwWl0.d.ts} +3 -3
  457. package/dist/{index-DtVZnjKf.d.ts → index-ByCXNZ2j.d.ts} +2 -2
  458. package/dist/{index-D3d7m03L.d.ts → index-C37Wq488.d.ts} +6 -6
  459. package/dist/{index-NNox0BqF.d.ts → index-CDX9U_CH.d.ts} +4 -4
  460. package/dist/{index-WuUhLgMp.d.ts → index-CQGi7Jnn.d.ts} +9 -9
  461. package/dist/{index-CnTxcNyl.d.ts → index-CWTWbIz_.d.ts} +3 -3
  462. package/dist/{index-ClysJ8O-.d.ts → index-CjoB5SrD.d.ts} +5 -5
  463. package/dist/{index-DLlAc0wg.d.ts → index-ClqA-t45.d.ts} +5 -5
  464. package/dist/{index-BfoKErj3.d.ts → index-CriIH7di.d.ts} +5 -5
  465. package/dist/{index-o2y0w9lX.d.ts → index-Crm9IjfQ.d.ts} +7 -7
  466. package/dist/{index-Dg4lbDzI.d.ts → index-CxX_Bgfa.d.ts} +6 -6
  467. package/dist/{index-DK0Hj3pi.d.ts → index-CxZV8RJE.d.ts} +6 -6
  468. package/dist/{index-d2TijvXV.d.ts → index-D2R8Msu5.d.ts} +1 -1
  469. package/dist/{index-B6h9m3ml.d.ts → index-DCqy0ESb.d.ts} +2 -2
  470. package/dist/{index-C7Tcervm.d.ts → index-DW_S9n3h.d.ts} +7 -7
  471. package/dist/{index-DkALeCTq.d.ts → index-DYh76mE_.d.ts} +2 -2
  472. package/dist/{index-DHjZvZWC.d.ts → index-D_0l5hHh.d.ts} +4 -4
  473. package/dist/{index-B4uPo3Sr.d.ts → index-DeI4h1N1.d.ts} +7 -7
  474. package/dist/{index-bkm44ycq.d.ts → index-Dea13gIz.d.ts} +6 -6
  475. package/dist/{index-BbpacfC0.d.ts → index-DlUd0CTA.d.ts} +9 -9
  476. package/dist/{index-BFvj-fNS.d.ts → index-DpoUltRu.d.ts} +2 -2
  477. package/dist/{index-DGszLnec.d.ts → index-DsNwQRWG.d.ts} +3 -3
  478. package/dist/{index-DYX_uL5t.d.ts → index-DyV6z0Q_.d.ts} +8 -8
  479. package/dist/{index-ouiV6zqH.d.ts → index-Dyhkn8FU.d.ts} +5 -5
  480. package/dist/{index-DKuOnwh6.d.ts → index-IrsC8TLH.d.ts} +8 -8
  481. package/dist/{index-D_xJSanv.d.ts → index-SWDnWdWw.d.ts} +3 -3
  482. package/dist/{index-C9p3wiWn.d.ts → index-SZ8qGIVO.d.ts} +15 -15
  483. package/dist/{index-X-ihJBuJ.d.ts → index-WoE9Z_V-.d.ts} +5 -5
  484. package/dist/{index-qzFFTwel.d.ts → index-r_SO6mVm.d.ts} +5 -5
  485. package/dist/index.d.ts +8 -8
  486. package/dist/index.js +2 -2
  487. package/dist/{invoices-CWp9jcI2.d.ts → invoices-L6khZ9kt.d.ts} +10 -5
  488. package/dist/{json-schema-B8f7HdoX.js → json-schema-CU9Mg-_d.js} +1 -1
  489. package/dist/{jwks-cache-C5Bkk8wb.js → jwks-cache-DcfC4DmK.js} +1 -1
  490. package/dist/{jws-D5t4Ylus.js → jws-DChBKezH.js} +1 -1
  491. package/dist/{kit-DN6lGKB6.d.ts → kit-BwlTgitb.d.ts} +4 -4
  492. package/dist/{knowledge-pN-5j-oj.d.ts → knowledge-C7RZqwQu.d.ts} +9 -6
  493. package/dist/lint/index.d.ts +1 -1
  494. package/dist/list/export/index.d.ts +1 -1
  495. package/dist/list/index.d.ts +3 -3
  496. package/dist/list/order/index.d.ts +3 -3
  497. package/dist/{list-query-qCpvTDGH.d.ts → list-query-B6lXbY0T.d.ts} +4 -4
  498. package/dist/{manifest-D80LSWzZ.d.ts → manifest-2sJavyD8.d.ts} +6 -6
  499. package/dist/{manifest-BTR978h8.js → manifest-3XKIMZkJ.js} +1 -1
  500. package/dist/{manifest-Co41j70r.d.ts → manifest-4S1YGIS3.d.ts} +6 -6
  501. package/dist/{manifest-CZoRtSvn.d.ts → manifest-5i2UwyQr.d.ts} +4 -4
  502. package/dist/{manifest-CvncELVO.d.ts → manifest-B0pan6cS.d.ts} +5 -5
  503. package/dist/{manifest-VbHg6E4F.js → manifest-BBcaI1P8.js} +1 -1
  504. package/dist/{manifest-ra7MSo-3.d.ts → manifest-BEQWkGmf.d.ts} +5 -5
  505. package/dist/{manifest-Clzy2rSU.d.ts → manifest-BKiaRgiZ.d.ts} +3 -3
  506. package/dist/{manifest-BESrR9Xp.d.ts → manifest-BMilYLsh.d.ts} +3 -3
  507. package/dist/{manifest-dt25CCQA.js → manifest-BNmYcT7b.js} +1 -1
  508. package/dist/{manifest-BS8p47JO.d.ts → manifest-BRvnB8C0.d.ts} +5 -5
  509. package/dist/{manifest-CNLJLsHB.d.ts → manifest-BZPruG-S.d.ts} +4 -4
  510. package/dist/{manifest-CLG2lmYA.js → manifest-B_qm9fCI.js} +1 -1
  511. package/dist/{manifest-BoUGzBpS.d.ts → manifest-BaIG9QRj.d.ts} +4 -4
  512. package/dist/{manifest-V0QSCEfx.d.ts → manifest-Bf6Rzatq.d.ts} +4 -4
  513. package/dist/{manifest-TvLJWs_L.d.ts → manifest-Bfu-Cu0f.d.ts} +7 -7
  514. package/dist/{manifest-Dp92U_iP.d.ts → manifest-Bj8bumDU.d.ts} +6 -6
  515. package/dist/{manifest-WK23vBlH.js → manifest-Bkm_17rp.js} +2 -2
  516. package/dist/{manifest-CIVhJzKF.d.ts → manifest-BpgNJhYN.d.ts} +2 -2
  517. package/dist/{manifest-VCJSqffq.d.ts → manifest-BxvFH1G_.d.ts} +3 -3
  518. package/dist/{manifest-RitquXSE.d.ts → manifest-BzXqieUD.d.ts} +7 -7
  519. package/dist/{manifest-BGmmK9bZ.d.ts → manifest-C2hpeEBF.d.ts} +3 -3
  520. package/dist/{manifest-BLFyjEv_.js → manifest-C6bwnO77.js} +1 -1
  521. package/dist/{manifest-CKDaQT_5.d.ts → manifest-C95ET4CL.d.ts} +4 -4
  522. package/dist/{manifest-Dvm2mwFy.d.ts → manifest-CA5EhKZ9.d.ts} +3 -3
  523. package/dist/{manifest-CLukD6aB.d.ts → manifest-CF3BUmbe.d.ts} +5 -5
  524. package/dist/{manifest-BTgU8Kcf.js → manifest-CG38X6q2.js} +1 -1
  525. package/dist/{manifest-CXNXmH86.js → manifest-CK1J6NE1.js} +1 -1
  526. package/dist/{manifest-B1lOqNaq.js → manifest-CLw7q0PB.js} +1 -1
  527. package/dist/{manifest-qvMWfrZ-.d.ts → manifest-CMn61uKN.d.ts} +5 -5
  528. package/dist/{manifest-DlLxdk7P.d.ts → manifest-CS8I2fku.d.ts} +3 -3
  529. package/dist/{manifest-D08Cdndm.js → manifest-CSYLcs5d.js} +2 -2
  530. package/dist/{manifest--_00y416.d.ts → manifest-CWFhOuFW.d.ts} +4 -4
  531. package/dist/{manifest-BA-urVob.d.ts → manifest-CXdJUJjX.d.ts} +8 -8
  532. package/dist/{manifest-B_2lEGUS.d.ts → manifest-CYO44YUb.d.ts} +5 -5
  533. package/dist/{manifest-Dpad_5Lw.d.ts → manifest-Ccc0ZZup.d.ts} +6 -6
  534. package/dist/{manifest-QmYmc98q.d.ts → manifest-CiF1Sb29.d.ts} +6 -6
  535. package/dist/{manifest-BAn3lTr4.d.ts → manifest-Cl2U3bic.d.ts} +3 -3
  536. package/dist/{manifest-Ch08RUKa.d.ts → manifest-CnVa_nHw.d.ts} +3 -3
  537. package/dist/{manifest-DBT7GiWE.js → manifest-CoR7UHm9.js} +1 -1
  538. package/dist/{manifest-Dxff277Z.js → manifest-CsJhHOcl.js} +2 -2
  539. package/dist/{manifest-DHTVfgX9.d.ts → manifest-CtL5JmoY.d.ts} +4 -4
  540. package/dist/{manifest-ByNpLQWh.d.ts → manifest-CumC7hH5.d.ts} +4 -4
  541. package/dist/{manifest-CyaHDD_i.d.ts → manifest-Cv7Mji7w.d.ts} +5 -5
  542. package/dist/{manifest-iMnrzuzj.js → manifest-CwvLYm4x.js} +2 -2
  543. package/dist/{manifest-CUtvLTr3.js → manifest-CzDKrwRf.js} +2 -2
  544. package/dist/{manifest-CXYg8gzt.d.ts → manifest-D48Fi0bR.d.ts} +3 -3
  545. package/dist/{manifest-CWwdLMT0.d.ts → manifest-DOtSiMt5.d.ts} +4 -4
  546. package/dist/{manifest-r6DHrB4Q.d.ts → manifest-DUPKC2rO.d.ts} +5 -5
  547. package/dist/{manifest-CCKfdYiH.d.ts → manifest-DZyxhWcb.d.ts} +3 -3
  548. package/dist/{manifest-ByV81mLa.d.ts → manifest-DfC1XBrV.d.ts} +4 -4
  549. package/dist/{manifest-DHulRwzL.d.ts → manifest-DftU8SXo.d.ts} +5 -5
  550. package/dist/{manifest-CxgOFWlh.d.ts → manifest-Dg2BCyzg.d.ts} +4 -4
  551. package/dist/{manifest-CjzlsilW.d.ts → manifest-DiXINLQQ.d.ts} +5 -5
  552. package/dist/{manifest-D_wBteR5.d.ts → manifest-Dim5U8TQ.d.ts} +3 -3
  553. package/dist/{manifest-CQrTRkRh.js → manifest-DkpKjNGT.js} +1 -1
  554. package/dist/{manifest-qOwMTJHI.js → manifest-DlNcTvH_.js} +1 -1
  555. package/dist/{manifest-C0v6IEWk.d.ts → manifest-DoZXpoG_.d.ts} +6 -6
  556. package/dist/{manifest-DofXV9lE.d.ts → manifest-Dp9ZtoFo.d.ts} +7 -7
  557. package/dist/{manifest-DLSzZMXM.d.ts → manifest-DpFy7git.d.ts} +8 -8
  558. package/dist/{manifest-DVZmJvrE.d.ts → manifest-DsINyvTh.d.ts} +6 -6
  559. package/dist/{manifest-C-pVDUC6.d.ts → manifest-DucB6ix_.d.ts} +4 -4
  560. package/dist/{manifest-CKCaFg8y.d.ts → manifest-DwBFwxFo.d.ts} +6 -6
  561. package/dist/{manifest-Cj6lOdW6.js → manifest-DwZwlGaz.js} +1 -1
  562. package/dist/{manifest-C8PUzse6.d.ts → manifest-FVkgBS-K.d.ts} +4 -4
  563. package/dist/{manifest-eUUJnoB5.d.ts → manifest-N5wuAzq4.d.ts} +8 -8
  564. package/dist/{manifest-BvzmDxod.d.ts → manifest-NkuGL5p2.d.ts} +4 -4
  565. package/dist/{manifest-DKnWcgse.d.ts → manifest-NuYSYeQT.d.ts} +5 -5
  566. package/dist/{manifest-D5aZyD1b.js → manifest-OxHBbWrs.js} +1 -1
  567. package/dist/{manifest-BEw6nEKW.d.ts → manifest-TG95ksdH.d.ts} +11 -11
  568. package/dist/{manifest-BMcuCUre.d.ts → manifest-YtnGn7F9.d.ts} +2 -2
  569. package/dist/{manifest-B7lSTuVC.d.ts → manifest-_zu02ImE.d.ts} +5 -5
  570. package/dist/{manifest-DCkeNzPW.d.ts → manifest-cJ3rQXtl.d.ts} +11 -11
  571. package/dist/{manifest-Fapf4NdA.d.ts → manifest-dOFbx7Iv.d.ts} +2 -2
  572. package/dist/{manifest-wbs2VkcB.d.ts → manifest-eaGk_4rq.d.ts} +6 -6
  573. package/dist/{manifest-B94f27dU.js → manifest-icEpY96-.js} +1 -1
  574. package/dist/{manifest-BYv5BqtY.d.ts → manifest-tP62uJrR.d.ts} +4 -4
  575. package/dist/{manifest-BgmY9fuz.d.ts → manifest-ubm80xCr.d.ts} +6 -6
  576. package/dist/{manifest-D0eItVsP.d.ts → manifest-wXk0ZLhO.d.ts} +4 -4
  577. package/dist/{manifest-Djy3wcSo.js → manifest-waO9DHVc.js} +1 -0
  578. package/dist/{manifest-DBfQe19Z.d.ts → manifest-x_fSttX7.d.ts} +4 -4
  579. package/dist/{manifest-C5LxShda.d.ts → manifest-xlpYSpLJ.d.ts} +4 -4
  580. package/dist/mapper/bin.js +6 -6
  581. package/dist/mcp/index.d.ts +3 -3
  582. package/dist/mcp/index.js +1 -1
  583. package/dist/mcp/sdk/index.d.ts +6 -6
  584. package/dist/mcp/sdk/index.js +2 -2
  585. package/dist/{mcp-aMq1fkoe.js → mcp-CULIbS-b.js} +5 -5
  586. package/dist/{medications-Cxvrfid3.d.ts → medications-3mcGOelG.d.ts} +5 -5
  587. package/dist/{messaging-C-PJ2LBY.d.ts → messaging-DasXvQj7.d.ts} +4 -4
  588. package/dist/nestjs/index.d.ts +2 -2
  589. package/dist/next/client/index.d.ts +1 -1
  590. package/dist/next/index.d.ts +20 -20
  591. package/dist/next/index.js +15 -10
  592. package/dist/next/offline/index.d.ts +1 -1
  593. package/dist/next/proxy/index.d.ts +5 -5
  594. package/dist/next/proxy/index.js +2 -2
  595. package/dist/node/index.d.ts +2 -2
  596. package/dist/{observations-BBQZWl54.d.ts → observations-8pt9Lflf.d.ts} +3 -3
  597. package/dist/{operations-nnC3pvwn.d.ts → operations-D4zxY2TL.d.ts} +1 -1
  598. package/dist/{orders-ePaBZDl9.d.ts → orders-BCR5H9Tz.d.ts} +3 -3
  599. package/dist/{orders-reads-CWCAZHgZ.js → orders-reads-BGMu5-Ug.js} +2 -2
  600. package/dist/orpc/index.d.ts +8 -8
  601. package/dist/orpc/index.js +3 -3
  602. package/dist/otel/index.d.ts +2 -2
  603. package/dist/otel/index.js +5 -5
  604. package/dist/{outbox-EXHTONFS.d.ts → outbox-DNyzkxyX.d.ts} +4 -4
  605. package/dist/{payroll-export-CIVukFDd.js → payroll-export-kpVJj_Gj.js} +13 -13
  606. package/dist/{permissions-ZLtxCurD.d.ts → permissions-BkUcXwtV.d.ts} +1 -1
  607. package/dist/{permissions-model-CYfIupG0.js → permissions-model-B7E_f7GV.js} +13 -1
  608. package/dist/{pool-tXlDkx18.d.ts → pool-Dzeln5IJ.d.ts} +3 -3
  609. package/dist/{ports-DfDzwMCR.js → ports-BBowiGiD.js} +4 -4
  610. package/dist/{ports-CfVACwW_.d.ts → ports-DD-pDkHu.d.ts} +1 -1
  611. package/dist/postgres/index.d.ts +4 -4
  612. package/dist/{postgrest-gG_GIWFi.d.ts → postgrest-CgAxVpiW.d.ts} +1 -1
  613. package/dist/powersync/index.d.ts +9 -9
  614. package/dist/powersync/index.js +1 -1
  615. package/dist/preset/index.d.ts +4 -4
  616. package/dist/preset/index.js +1 -1
  617. package/dist/{preset-HzYIrxUS.js → preset-ZZ4H2s92.js} +5 -5
  618. package/dist/{preview-BoJkQw2E.d.ts → preview-GUvVjUxf.d.ts} +6 -6
  619. package/dist/{project-DI09JnXz.js → project-wJ3jYipI.js} +3 -3
  620. package/dist/{provider-r2RjlARm.d.ts → provider-DSokOaUo.d.ts} +1 -1
  621. package/dist/{push-token-Rv1CxW_N.d.ts → push-token-C8MoiM7E.d.ts} +1 -1
  622. package/dist/query/index.d.ts +1 -1
  623. package/dist/rate-limit/index.d.ts +1 -1
  624. package/dist/{rate-limit-CxN-zbLC.d.ts → rate-limit-Ddv4xmsH.d.ts} +5 -5
  625. package/dist/react/index.d.ts +9 -9
  626. package/dist/react/index.js +2 -2
  627. package/dist/react/native/index.d.ts +1 -1
  628. package/dist/react/native/index.js +3 -3
  629. package/dist/react/server.d.ts +8 -8
  630. package/dist/react/server.js +2 -2
  631. package/dist/react/session.d.ts +2 -2
  632. package/dist/{react-CvgCNgo-.js → react-hb2gg5UV.js} +2 -2
  633. package/dist/react-router/index.d.ts +6 -6
  634. package/dist/react-router/index.js +4 -4
  635. package/dist/{read-set-BptYceHc.js → read-set-DfScfSsf.js} +3 -2
  636. package/dist/realtime/index.d.ts +6 -6
  637. package/dist/realtime/index.js +2 -2
  638. package/dist/{record-form-BHUYs5ju.d.ts → record-form-CbFN-AdD.d.ts} +1 -1
  639. package/dist/{recordings-Bdf1OnQS.d.ts → recordings-C1BOyHYu.d.ts} +1 -1
  640. package/dist/records/index.d.ts +9 -9
  641. package/dist/{refusal-DHSRBaS6.d.ts → refusal-6HGi0oY9.d.ts} +3 -3
  642. package/dist/{resolve-oJsHQ9Ib.js → resolve-DP8w5Nl0.js} +2 -2
  643. package/dist/{resolve-Chhtdk4M.d.ts → resolve-Pn7KvQ23.d.ts} +1 -1
  644. package/dist/{resource-BfkM1JZ0.d.ts → resource-DFEtCFTy.d.ts} +1 -1
  645. package/dist/{resource-execute-Bb-zKYUc.d.ts → resource-execute-BQx_Pmeu.d.ts} +2 -2
  646. package/dist/{resource-types-C8kdoZ-J.d.ts → resource-types-lBguZ_8J.d.ts} +4 -4
  647. package/dist/{resources-B9dfA1jH.d.ts → resources-CWfoS1er.d.ts} +2 -2
  648. package/dist/{respond-DNcBzi_Y.d.ts → respond-vxhdVf23.d.ts} +1 -1
  649. package/dist/{runs-CTo9cjAz.js → runs-bv1S-1JM.js} +2 -2
  650. package/dist/{sales-D_yZoFUU.js → sales-Br66jZAO.js} +3 -3
  651. package/dist/{sales-lines-CX-xpQQW.d.ts → sales-lines-DWwWHLJj.d.ts} +1 -1
  652. package/dist/{sandboxes-vO9Yb0Bd.d.ts → sandboxes-BjvFi1Wh.d.ts} +1 -1
  653. package/dist/{scores-C8fy3RXF.d.ts → scores-LZaJOHkr.d.ts} +5 -5
  654. package/dist/server/account/index.d.ts +3 -3
  655. package/dist/server/accounts/index.d.ts +6 -6
  656. package/dist/server/accounts/index.js +1 -1
  657. package/dist/server/index.d.ts +27 -27
  658. package/dist/server/index.js +12 -12
  659. package/dist/{server-Bgugpk3A.js → server-af58-Q51.js} +10 -6
  660. package/dist/{server-types-C8zErBy9.d.ts → server-types-By5oBsDZ.d.ts} +18 -12
  661. package/dist/{session-DRn_URq0.d.ts → session-D5IrTUwv.d.ts} +6 -6
  662. package/dist/{session-status-CywvasN_.d.ts → session-status-m5VN1pW1.d.ts} +2 -2
  663. package/dist/{sessions-Dedk1ubX.js → sessions-w6xril_l.js} +1 -1
  664. package/dist/{settings-CMcdSyT4.d.ts → settings-C_zEVfCy.d.ts} +2 -2
  665. package/dist/{sign-in-DgvuMl59.js → sign-in-CxnkReKM.js} +2 -2
  666. package/dist/{sign-in-BwI5DHy5.js → sign-in-DklEPfDI.js} +2 -2
  667. package/dist/{sign-in-R_Ou2FMR.d.ts → sign-in-Dni-tX9B.d.ts} +1 -1
  668. package/dist/{sign-in-Dp-X2YXo.d.ts → sign-in-TNX4Pj9E.d.ts} +18 -18
  669. package/dist/{signatures-D9_TUapq.js → signatures-BZ10RZbf.js} +1 -1
  670. package/dist/{signers-BnUPoU0u.d.ts → signers-DB0S8YhO.d.ts} +4 -4
  671. package/dist/{signing-keys-DulqHr3n.d.ts → signing-keys-BNwqmUlK.d.ts} +2 -2
  672. package/dist/{signing-keys-BxAcK3ve.js → signing-keys-Cr08qRGc.js} +1 -1
  673. package/dist/solid/index.d.ts +11 -11
  674. package/dist/solid/index.js +1 -1
  675. package/dist/solid-start/index.d.ts +6 -6
  676. package/dist/solid-start/index.js +4 -4
  677. package/dist/spec/index.d.ts +2 -2
  678. package/dist/spec/index.js +2 -2
  679. package/dist/sql/index.d.ts +5 -5
  680. package/dist/sql/index.js +3 -3
  681. package/dist/{sql-BqOBYRvI.js → sql-CP1j2jfo.js} +596 -227
  682. package/dist/sqlite/index.d.ts +3 -3
  683. package/dist/sqlite/index.js +1 -1
  684. package/dist/{sso-DcxycaaP.d.ts → sso-CK6_NPWp.d.ts} +3 -3
  685. package/dist/ssr/index.d.ts +4 -4
  686. package/dist/ssr/index.js +1 -1
  687. package/dist/storage/client/index.d.ts +2 -2
  688. package/dist/storage/client/index.js +1 -1
  689. package/dist/storage/index.d.ts +3 -3
  690. package/dist/storage/index.js +1 -1
  691. package/dist/streams/index.d.ts +1 -1
  692. package/dist/streams/resumable/index.d.ts +1 -1
  693. package/dist/{subject-readers-61Xd5vAQ.js → subject-readers-qnt9P3Tf.js} +2 -2
  694. package/dist/{subject-readers-DNPGHMEg.d.ts → subject-readers-zsCxIZ_1.d.ts} +5 -5
  695. package/dist/{subjects-Bb5-VIcs.d.ts → subjects-Bnhj8AsZ.d.ts} +9 -9
  696. package/dist/{support-N97YzVgD.d.ts → support-8jVUURe-.d.ts} +4 -4
  697. package/dist/{support--EPft3tt.js → support-B9mOOkAy.js} +1 -1
  698. package/dist/{support-view-D0VmaQVg.d.ts → support-view-CfyHFSq4.d.ts} +1 -1
  699. package/dist/{suspend-account-DcQFTDGI.d.ts → suspend-account-Bi-ebizL.d.ts} +2 -2
  700. package/dist/svelte/index.d.ts +10 -10
  701. package/dist/svelte/index.js +1 -1
  702. package/dist/sveltekit/index.d.ts +7 -7
  703. package/dist/sveltekit/index.js +4 -4
  704. package/dist/{tags-Bh4zXrnl.d.ts → tags-Csj8VfA7.d.ts} +1 -1
  705. package/dist/tanstack-db/index.d.ts +3 -3
  706. package/dist/tanstack-start/index.d.ts +6 -6
  707. package/dist/tanstack-start/index.js +4 -4
  708. package/dist/{tax-sql-DrR78UUW.js → tax-sql-sSJTtYtF.js} +1 -1
  709. package/dist/{tenant-BQaG8Hma.d.ts → tenant-CVRFoaDM.d.ts} +1 -1
  710. package/dist/testing/index.d.ts +36 -36
  711. package/dist/testing/index.js +38 -19
  712. package/dist/{timeline-D7T-qrKN.d.ts → timeline-T1qkzVdR.d.ts} +5 -5
  713. package/dist/{topic-CTqz7oYG.js → topic-CZ8FVS1o.js} +1 -1
  714. package/dist/{topic-R7kIJ_xI.d.ts → topic-DytYYyP3.d.ts} +16 -5
  715. package/dist/{types-BQaFrgFr.d.ts → types-BEuYPFta.d.ts} +4 -4
  716. package/dist/{types-BIpCfsXW.d.ts → types-BcBKymdQ.d.ts} +1 -1
  717. package/dist/{types-BME_OjVm.d.ts → types-CID74uQG.d.ts} +5 -5
  718. package/dist/{types-arsKcxoV.d.ts → types-CNE-ybHL.d.ts} +3 -3
  719. package/dist/{types-D9qT7VIV.d.ts → types-CVq6-P5G.d.ts} +7 -7
  720. package/dist/{types-BE6BvLv2.d.ts → types-Cge5o3f5.d.ts} +2 -2
  721. package/dist/{types-BFNVzP1M.d.ts → types-Cikitezb.d.ts} +5 -5
  722. package/dist/{types-BJ4cg51a.d.ts → types-Dizn1liT.d.ts} +12 -2
  723. package/dist/{undo-B_8VpTy2.d.ts → undo-CRejYq21.d.ts} +2 -2
  724. package/dist/{usage-BBR7z7ra.d.ts → usage-CrTrlxoi.d.ts} +4 -4
  725. package/dist/{vault-B2AI88Jz.d.ts → vault-Dyy9I0IE.d.ts} +2 -2
  726. package/dist/vercel-connect/index.d.ts +1 -1
  727. package/dist/vercel-sandbox/index.d.ts +2 -2
  728. package/dist/verifiable-credentials/index.js +2 -2
  729. package/dist/{verify-yUHyGq0u.js → verify-Bu2FKS9o.js} +1 -1
  730. package/dist/{verify-BfcOHiUP.d.ts → verify-dg8Q3iRY.d.ts} +2 -2
  731. package/dist/{version-CkYT3KbT.js → version-B0uw5rOF.js} +1 -1
  732. package/dist/{view-DKo-Koiu.d.ts → view-DwTCw_jZ.d.ts} +1 -1
  733. package/dist/vue/index.d.ts +11 -11
  734. package/dist/vue/index.js +1 -1
  735. package/dist/{watch-topic-D18gT7-K.d.ts → watch-topic-DT31uYqF.d.ts} +1 -1
  736. package/dist/{webhook-inbox-Bn-dV-vF.js → webhook-inbox-DIPjKka6.js} +1 -1
  737. package/dist/webmcp/index.d.ts +2 -2
  738. package/dist/webmcp/index.js +1 -1
  739. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  740. package/dist/workflow-sdk/index.d.ts +1 -1
  741. package/dist/workflow-sdk/index.js +1 -1
  742. package/dist/workflow-sdk/world/index.d.ts +1 -1
  743. package/dist/workflow-sdk/world/index.js +1 -1
  744. package/dist/{workflow-sdk-c025kSHf.js → workflow-sdk-IPsOMGEC.js} +1 -1
  745. package/dist/{workflow-sdk-B_yeWl8N.d.ts → workflow-sdk-Js7efMDi.d.ts} +3 -3
  746. package/dist/{workflows-DR6nJ9vq.d.ts → workflows-CUcK8Axx.d.ts} +4 -4
  747. package/dist/yjs/index.d.ts +2 -2
  748. package/dist/yjs/index.js +2 -2
  749. package/package.json +3 -1
  750. package/schemas/config-v1.json +27 -0
  751. package/schemas/error-codes.json +3 -3
  752. package/skills/better-supabase/SKILL.md +2 -2
  753. package/skills/better-supabase/references/ui-recipes.md +2 -2
  754. package/dist/cli/add-C04PIE9H.js +0 -1
  755. package/dist/cli/powersync-DnKUA1tu.js +0 -1
  756. package/dist/cli/round-trips-n_Dk1iUI.js +0 -54
  757. package/dist/cli/seed-CucH5loT.js +0 -1
@@ -1,9 +1,9 @@
1
1
  import { d as temporalText } from "./temporal-VgABWvpY.js";
2
- import { a as hasPlaceholder, f as isFunctionSpec, l as splitPlaceholders, r as containsPlaceholder, s as placeholderOf } from "./read-set-BptYceHc.js";
2
+ import { a as hasPlaceholder, f as isFunctionSpec, l as splitPlaceholders, r as containsPlaceholder, s as placeholderOf } from "./read-set-DfScfSsf.js";
3
3
  import { a as ok } from "./result-DijoXEFG.js";
4
4
  import { n as isRecord$1, t as isList } from "./guards-CsRa6v57.js";
5
5
  import { t as SPEC_PINS } from "./spec-pins-Dlz8OVqi.js";
6
- import { _ as CONFIG_DEFAULTS, d as blockColumnName, f as checkTenantEntry, g as resolveJsonSchema, h as clientFunctions, l as installedBlockSubjects, m as resolveNames, n as checkFormerPermissionKeys, p as entityType, r as renames } from "./former-permission-keys-BwJW5uc6.js";
6
+ import { _ as CONFIG_DEFAULTS, d as blockColumnName, f as checkTenantEntry, g as resolveJsonSchema, h as clientFunctions, l as installedBlockSubjects, m as resolveNames, n as checkFormerPermissionKeys, p as entityType, r as renames } from "./former-permission-keys-D8FbWktT.js";
7
7
  import { t as DEFAULT_CLAIMS } from "./claims-CX-ar1vt.js";
8
8
  import { o as tenantNames, r as composeNames } from "./entity-naming-CUsC8bC1.js";
9
9
  import { B as resolveBlock, C as columnsWithAccess, E as hiddenColumns, I as PRESET_CATALOG, L as BLOCK_SCOPES, N as createdFromLink, P as link, S as hasComputed, T as hasColumnAccess, V as tenantNameOf, a as isRenamedInstance, g as appTableVersions, i as instancePrefix, l as APP_RANK_COLUMN, m as appTableEventKinds, s as APP_DELETED_AT_COLUMN, w as encryptedColumns, y as lookupColumn } from "./instances-07Lopbd1.js";
@@ -32,7 +32,7 @@ import { i as billingSqlOptions, n as BILLING_READS, r as billingReads } from ".
32
32
  import { t as bookingsSqlOptions } from "./options-CtPokOpy.js";
33
33
  import { t as bulkActionsSqlOptions } from "./options-Cv8jRbcG.js";
34
34
  import { t as calendarSqlOptions } from "./options-D9fAmLff.js";
35
- import { a as CARE_PLAN_STATUSES, i as CARE_PLAN_PROBLEM_STATUSES, n as CARE_PLAN_ACTION_STATUSES, o as carePlansSql, r as CARE_PLAN_GOAL_STATUSES, s as carePlansSqlOptions, t as CARE_PLAN_ACTION_KINDS } from "./care-plans-sql-DyB5TB6y.js";
35
+ import { a as CARE_PLAN_STATUSES, i as CARE_PLAN_PROBLEM_STATUSES, n as CARE_PLAN_ACTION_STATUSES, o as carePlansSql, r as CARE_PLAN_GOAL_STATUSES, s as carePlansSqlOptions, t as CARE_PLAN_ACTION_KINDS } from "./care-plans-sql-B__5eEaI.js";
36
36
  import { a as casesSqlOptions, i as CASE_STATUSES, r as CASE_STATS_GROUPS, t as CASE_ACTION_TYPES } from "./cases-values-DMWz7VPN.js";
37
37
  import { t as catalogSqlOptions } from "./options-BD2yc6ZW.js";
38
38
  import { t as commentsSqlOptions } from "./options-D2E1rdl1.js";
@@ -86,11 +86,11 @@ import { t as oauthServerSqlOptions } from "./options-BiSW8oLm.js";
86
86
  import { t as observationsSqlOptions } from "./options-BNRQevXM.js";
87
87
  import { t as onboardingSqlOptions } from "./options-BKLYKPxy.js";
88
88
  import { t as optionSetsSqlOptions } from "./options-CggBzOJ5.js";
89
- import { A as assignWhen, B as templateColumnSql, C as storefrontOption, D as uniqueViolationOn, E as columnDefaults, F as sequenceEntry, G as rankAfter, H as templateRowsOf, I as sequences, K as rankBackfill, L as excludeTemplates, M as scopeSql, N as sequenceFormatOf, O as withColumnDefault, P as withFixedNumber, R as liveRowsIndex, S as productSettingTypes, T as catalogRank, U as templateTriggerReturn, V as templateGuardSql, W as RANK_KEY_PATTERN, _ as categoryExtras, a as asService, b as productExtras, c as guard$12, d as orderTemplatesOn, f as paymentWindow, g as amountOf, h as SLUG$7, i as amountOf$1, j as hasLegalEntityColumn, k as assignNumberSql, l as orderFields, m as transitionFunction, o as assignNumber$1, p as serviceOnlyGuard, q as ordersSqlOptions, r as orderReads, s as columns, t as ORDER_READS, u as orderPayload, v as guard$11, w as variantExtras, x as productFunctions$1, y as optionFunctions, z as sourceTemplateColumnSql } from "./orders-reads-CWCAZHgZ.js";
89
+ import { A as assignWhen, B as templateColumnSql, C as storefrontOption, D as uniqueViolationOn, E as columnDefaults, F as sequenceEntry, G as rankAfter, H as templateRowsOf, I as sequences, K as rankBackfill, L as excludeTemplates, M as scopeSql, N as sequenceFormatOf, O as withColumnDefault, P as withFixedNumber, R as liveRowsIndex, S as productSettingTypes, T as catalogRank, U as templateTriggerReturn, V as templateGuardSql, W as RANK_KEY_PATTERN, _ as categoryExtras, a as asService, b as productExtras, c as guard$12, d as orderTemplatesOn, f as paymentWindow, g as amountOf, h as SLUG$7, i as amountOf$1, j as hasLegalEntityColumn, k as assignNumberSql, l as orderFields, m as transitionFunction, o as assignNumber$1, p as serviceOnlyGuard, q as ordersSqlOptions, r as orderReads, s as columns, t as ORDER_READS, u as orderPayload, v as guard$11, w as variantExtras, x as productFunctions$1, y as optionFunctions, z as sourceTemplateColumnSql } from "./orders-reads-BGMu5-Ug.js";
90
90
  import { a as organizationsSqlOptions, i as invitationsSqlOptions, n as ORGANIZATION_READS, r as organizationOverview } from "./organizations-overview-P_-d0K-l.js";
91
91
  import { t as outboxSqlOptions } from "./options-BBRvZUrV.js";
92
92
  import { t as passesSqlOptions } from "./options-MlhPEf5z.js";
93
- import { $ as qualifiedTable$2, A as editableContracts, B as entryEnded, C as leaveOwner, D as recordOwner, E as ownerIsEmployee, F as splitName, G as boundSubjectMatch, H as lockedColumns, I as feedOptions, J as liveShareLink, K as boundSubjects$1, L as feedWindow, M as majorSalary, N as overlappingContracts, O as FLAT_DETAILS, P as reportsMoveUp, Q as onSettings, R as byEmployee, S as leaveConfidentialReader, T as leavePartsMapped, U as timeOwner, V as entrySubjects, W as boundRowSubject, X as touchShareLink, Y as shareLinkRow, Z as andSubjectAction, _ as leaveBalancesTable, a as leaveEndPart, at as subjectTableBindings, b as leaveConfidentialFilter, c as leavePartial, ct as tableCascades, d as leaveTeamFeedSubject, dt as tryColumnType, et as subjectAccess, f as leaveTypeKey, ft as payrollExportSqlOptions, g as leaveAutoApproveMapped, h as leaveAutoApprove, it as subjectReadable, j as flatDetails, k as denyOverlaps, l as leaveRequestUser, lt as asColumnType, m as halfDays, nt as subjectCascades, o as leaveFeed, ot as subjectTypeGuard, p as dropSignatures, q as SHARE_LINKS, rt as subjectIdMatches, s as leaveFeedSubject, st as subjectsOption, t as PAYROLL_EXPORT, tt as subjectActionCheck, u as leaveStartPart, ut as columnTypeFunctions, v as leaveByEmployee, w as leaveParts, x as leaveConfidentialKey, y as leaveConfidential, z as durationEntries } from "./payroll-export-CIVukFDd.js";
93
+ import { $ as qualifiedTable$2, A as editableContracts, B as entryEnded, C as leaveOwner, D as recordOwner, E as ownerIsEmployee, F as splitName, G as boundSubjectMatch, H as lockedColumns, I as feedOptions, J as liveShareLink, K as boundSubjects$1, L as feedWindow, M as majorSalary, N as overlappingContracts, O as FLAT_DETAILS, P as reportsMoveUp, Q as onSettings, R as byEmployee, S as leaveConfidentialReader, T as leavePartsMapped, U as timeOwner, V as entrySubjects, W as boundRowSubject, X as touchShareLink, Y as shareLinkRow, Z as andSubjectAction, _ as leaveBalancesTable, a as leaveEndPart, at as subjectTableBindings, b as leaveConfidentialFilter, c as leavePartial, ct as tableCascades, d as leaveTeamFeedSubject, dt as tryColumnType, et as subjectAccess, f as leaveTypeKey, ft as payrollExportSqlOptions, g as leaveAutoApproveMapped, h as leaveAutoApprove, it as subjectReadable, j as flatDetails, k as denyOverlaps, l as leaveRequestUser, lt as asColumnType, m as halfDays, nt as subjectCascades, o as leaveFeed, ot as subjectTypeGuard, p as dropSignatures, q as SHARE_LINKS, rt as subjectIdMatches, s as leaveFeedSubject, st as subjectsOption, t as PAYROLL_EXPORT, tt as subjectActionCheck, u as leaveStartPart, ut as columnTypeFunctions, v as leaveByEmployee, w as leaveParts, x as leaveConfidentialKey, y as leaveConfidential, z as durationEntries } from "./payroll-export-kpVJj_Gj.js";
94
94
  import { t as permissionsSqlOptions } from "./options-B3DU_tjC.js";
95
95
  import { t as pipelinesSqlOptions } from "./options-t8W7XEHD.js";
96
96
  import { t as postsSqlOptions } from "./options-BfnSHM0_.js";
@@ -134,40 +134,40 @@ import { t as waitlistSqlOptions } from "./options-CzP_V8dF.js";
134
134
  import { n as webhooksOutSqlOptions, t as webhooksInSqlOptions } from "./options-BKrQcqTf.js";
135
135
  import { t as MAX_BATCH$1 } from "./batch-limit-DqQ3d6op.js";
136
136
  import { $ as userGrant, A as notNullCheckName, B as replaceColumnCheck, C as insertExtraColumns, D as memberAddedRecord, E as lockTable, F as raise$1, G as sha256HexSql, H as schemaPreamble, I as readLine, J as transitionActorSql, K as shortHash, L as recordTrigger, M as ownRowPolicies, N as pageSize, O as membershipDisabledAt, P as quotedTable, Q as updatedAt, R as registerPartitions, S as fail, T as jwtClaim, U as serviceGrant, V as revokeTable, W as serviceOnly$1, X as triggerGrant, Y as transitionReasonSql, Z as updateExtraColumns, _ as disabledHelpersNeedLaterTables, a as SERVICE_CALLER$1, at as grantTable, b as extraFieldsArg, c as addCheck, d as batchFunction, et as withExtraFields, f as columnRef, g as disabledHelpers, h as defaultPartitionName, i as PARTITION_VARIABLES, j as organizationMissing, k as membershipSuspended, l as addForeignKey, m as defaultPartition, n as MONTHLY_PARTITIONS, nt as createTable$1, o as accessDefinesDisabledHelpers, p as columnsObject, q as splitTable$1, r as NOTHING, rt as enableRowSecurity, s as activeMembership, t as EQUIVALENT_TRIGGERS, tt as writeExtraColumns, u as addNotNullCheck, v as dropExpiredPartitions, w as jsonSchemaChecks, x as extraFieldsJson, y as ensureCheck, z as renameSql } from "./shared-D-qwk29i.js";
137
- import { a as registeredIdMatches, c as teamActions, d as subjectPermissionKey, f as subjectPermissionOf, i as logsSubjectReads, l as tenantColumnOf, n as auditedSubjects, o as registeredSubjects, r as checkCall, t as uniqueContributions, u as urlExpression } from "./contributions-Bh-HcHoJ.js";
137
+ import { a as registeredIdMatches, c as teamActions, d as subjectPermissionKey, f as subjectPermissionOf, i as logsSubjectReads, l as tenantColumnOf, n as auditedSubjects, o as registeredSubjects, r as checkCall, t as uniqueContributions, u as urlExpression } from "./contributions-Ba-C1ueE.js";
138
138
  import { n as SUBJECT_TYPE_SQL_PATTERN, r as subjectTypeIdent } from "./subject-type-BarjdHZV.js";
139
139
  import { d as templatePlaceholders, i as fillTemplate } from "./access-sql-Dvl7BRy0.js";
140
- import { a as moduleOperations, c as roleNames, d as tenantScope, i as isOperationModule$1, l as roleScopeIs, n as OPERATIONS$1, o as modulePermission, r as accessModel, s as modulePermissionKey, u as rolesOf } from "./permissions-model-CYfIupG0.js";
140
+ import { a as isOperationModule$1, c as modulePermissionKey, d as rolesOf, f as tenantScope, i as accessModel, l as roleNames, n as INTERACTIVE_ONLY_OPERATIONS, o as moduleOperations, r as OPERATIONS$1, s as modulePermission, u as roleScopeIs } from "./permissions-model-B7E_f7GV.js";
141
141
  import { a as readGrants, c as renderPolicy, i as policy$1, n as closingParen$1, o as readPolicies, r as maskSql, s as readPolicy$6, t as catalogPolicy } from "./policy-Buem9L_M.js";
142
142
  import { i as CHECKOUT_SESSION_STATUSES, n as AGENT_MANDATE_TYPES, r as CHECKOUT_PROTOCOLS, t as AGENT_MANDATE_STATUSES } from "./agent-checkout-values-Cn6rZgn4.js";
143
143
  import { t as AI_MESSAGE_PART_TYPES } from "./ai-message-cnroprVB.js";
144
144
  import { t as FINAL_RUN_STATES$1 } from "./run-state-DGiyDQxH.js";
145
145
  import { a as rankKeys, n as RANK_REBALANCE_QUEUE, t as RANK_ALPHABET } from "./rank-keys-CEBzd9Xa.js";
146
+ import { r as operationPermission, t as OPERATION_PREFIXES } from "./operations-BNFbWv1t.js";
146
147
  import { i as APPRAISAL_STATUSES, n as APPRAISAL_CYCLE_STATUSES, r as APPRAISAL_REVIEW_KINDS, t as APPRAISAL_ANONYMITY } from "./appraisals-values-Cf2GBgyC.js";
147
148
  import { t as declareRead } from "./reads-CWVqw2JB.js";
148
149
  import { r as NEGATIVE, t as FILTER_OPERATORS } from "./filter-query-Cm2fvkE9.js";
149
- import { _ as UNMATCH_REFERENCE, a as BATCH_ITEMS_TABLE, c as batchContract, d as batchTablesSql, f as hasBatches, g as TRANSACTION_STATUSES, h as STATEMENT_FORMATS, i as BATCHES_TABLE, l as batchFunctions, m as MATCH_TARGETS, p as MATCH_REFERENCE, r as bankingReads, t as BANK_READS, u as batchSettle, v as bankingSql, y as linked$8 } from "./banking-reads-4m0_lltt.js";
150
+ import { _ as UNMATCH_REFERENCE, a as BATCH_ITEMS_TABLE, c as batchContract, d as batchTablesSql, f as hasBatches, g as TRANSACTION_STATUSES, h as STATEMENT_FORMATS, i as BATCHES_TABLE, l as batchFunctions, m as MATCH_TARGETS, p as MATCH_REFERENCE, r as bankingReads, t as BANK_READS, u as batchSettle, v as bankingSql, y as linked$8 } from "./banking-reads-Baaatsuj.js";
150
151
  import { t as ISO_4217_MINOR_UNITS } from "./iso4217-oKsif_hW.js";
151
152
  import { a as moveStock, c as stockHistory, d as variantTracked, i as locationsOf, l as strict, n as guard$13, o as reservationFunctions, r as locationFunctions, s as stockFunctions, t as columns$1, u as threshold } from "./inventory-stock-D7rVAss1.js";
152
153
  import { a as CARE_BUILT_IN_SOURCE, i as CARE_ALERT_STATUSES, n as CARE_ALERT_KINDS, o as CARE_RULE_KINDS, r as CARE_ALERT_SEVERITIES, t as CARE_ALERT_DECISIONS } from "./clinical-decision-support-values-Bk1AzL7L.js";
153
154
  import { t as DAM_RENDITION_STATUSES } from "./dam-values-C1SGxSoe.js";
154
155
  import { a as EXCEPTION_RESULTS, c as LAST_FURNISHING_FACT, d as OBSERVED_FALLS_ON, f as OBSERVED_MOVES, g as ROLL_DAYS, h as PART_STATUSES, i as DEADLINE_STATES, l as META_LIMIT, m as OFFSET_UNITS, o as FIRST_FURNISHING_FACT, p as OFFSET_LIMIT, r as DEADLINE_RESULTS, t as DEADLINE_ADJUSTMENTS, u as NOTE_LIMIT, v as RULE_VERSION_STATUSES, y as WEEKDAYS } from "./deadlines-values-vmaCCdGl.js";
155
156
  import { i as FORM_SCHEMA_DIALECT, o as UNSCORED_FIELD_TYPES, r as FORM_MAX_LENGTH, t as FORM_DEFINITION_SCHEMA } from "./form-definition-DbyY2DKZ.js";
156
- import { r as operationPermission, t as OPERATION_PREFIXES } from "./operations-BNFbWv1t.js";
157
157
  import { i as MAINTENANCE_PRIORITIES, n as MAINTENANCE_PLAN_KINDS, r as MAINTENANCE_PLAN_STATUSES, t as MAINTENANCE_CALIBRATION_RESULTS } from "./maintenance-values-DlqhkGvQ.js";
158
158
  import { a as metricsOf, i as grainDivides, t as METRIC_GRAINS } from "./metric-definition-D4H6IQT7.js";
159
159
  import { t as PERIOD_STATUSES } from "./periods-values-DeeudWL4.js";
160
160
  import { n as RFQ_STATUSES, r as RFQ_SUPPLIER_STATUSES, t as RFQ_QUOTE_STATUSES } from "./rfqs-values-BgIYOeVa.js";
161
161
  import { n as AUTHZ_TOPIC, t as AUTHZ_EVENT } from "./authz-topic-D7fPUY4P.js";
162
162
  import { a as TRACKING_STATUSES, i as SHIPMENT_STATUSES, n as LINE_DIRECTIONS, r as RETURN_DISPOSITIONS, t as LABEL_FORMATS } from "./statuses-Qqpzda35.js";
163
- import { a as taxSql, n as EU_SALES_KINDS, r as RETURN_STATUSES, t as EPOCH } from "./tax-sql-DrR78UUW.js";
163
+ import { a as taxSql, n as EU_SALES_KINDS, r as RETURN_STATUSES, t as EPOCH } from "./tax-sql-sSJTtYtF.js";
164
164
  import { i as TILL_SESSION_STATUSES, n as TILL_MOVEMENT_INFLOWS, r as TILL_MOVEMENT_KINDS, t as TILL_DEPOSIT_STATUSES } from "./tills-values-DoUJ0B__.js";
165
165
  import { n as PICK_LIST_STATUSES, r as PICK_WAVE_STATUSES, t as PICK_LINE_STATUSES } from "./warehouse-values-CyoqvWRp.js";
166
166
  import { n as WARRANTY_STATUSES } from "./warranty-values-BJo_g1F1.js";
167
- import { n as WORKFLOW_SDK_WORLD } from "./workflow-sdk-c025kSHf.js";
167
+ import { n as WORKFLOW_SDK_WORLD } from "./workflow-sdk-IPsOMGEC.js";
168
168
  import { s as permissionMatches$1 } from "./delegation-CnCIKysL.js";
169
169
  import { n as quoteIdent, t as compileSql } from "./sql-DqCwJ2qB.js";
170
- import { t as provideConnectionRuntime } from "./define-runtime-full-C4eTtJAx.js";
170
+ import { t as provideConnectionRuntime } from "./define-runtime-full-B_cMkyCk.js";
171
171
  // src/sql/api-schema.ts
172
172
  /** The roles PostgREST runs a request as. */
173
173
  const API_ROLES = /* @__PURE__ */ new Set([
@@ -12271,7 +12271,7 @@ const readIfAny = (statement, rows, when) => statement === "" ? "" : `\n if jso
12271
12271
  // src/sql/subject-check-sql.ts
12272
12272
  /**
12273
12273
  * SQL that is true when `type`/`id` (text expressions) names a record in
12274
- * `config.subjects` that belongs to tenant `tenant` and that the caller can
12274
+ * `config.recordTypes` that belongs to tenant `tenant` and that the caller can
12275
12275
  * read through `can_subject`. Types without a tenant column never match. The
12276
12276
  * module must require `subjects`.
12277
12277
  */
@@ -12285,8 +12285,8 @@ ${subjects.map((subject) => ` when ${sqlString(subject.type)} then exists (
12285
12285
  end and ${canSubject}(${type}, ${id}, 'read'))`;
12286
12286
  }
12287
12287
  /**
12288
- * SQL for the tenant (as text) of record `type`/`id` in `config.subjects`, or
12289
- * null for an unknown record or type. Reads the table directly, so use it in
12288
+ * SQL for the tenant (as text) of record `type`/`id` in `config.recordTypes`,
12289
+ * or null for an unknown record or type. Reads the table directly, so use it in
12290
12290
  * security definer code after checking the caller.
12291
12291
  */
12292
12292
  function subjectTenant(ctx, type, id) {
@@ -12298,9 +12298,9 @@ ${subjects.map((subject) => ` when ${sqlString(subject.type)} then (select
12298
12298
  end)`;
12299
12299
  }
12300
12300
  /**
12301
- * SQL for the title (as text) of record `type`/`id` in `config.subjects`, from
12302
- * the entry's `title` column, or null for an unknown record or a type without
12303
- * one. Reads the table directly, so check the caller first.
12301
+ * SQL for the title (as text) of record `type`/`id` in `config.recordTypes`,
12302
+ * from the entry's `title` column, or null for an unknown record or a type
12303
+ * without one. Reads the table directly, so check the caller first.
12304
12304
  */
12305
12305
  function subjectTitle(ctx, type, id) {
12306
12306
  const subjects = registeredSubjects(ctx.subjects, ctx.naming).filter((subject) => subject.config.title !== void 0);
@@ -20190,17 +20190,35 @@ function providerRowCheck(ctx, where, rows, key) {
20190
20190
  }))} else false end)`;
20191
20191
  };
20192
20192
  }
20193
+ /**
20194
+ * `providerRowCheck` for a set reader: one `rowsWith` call answers every
20195
+ * candidate id of a statement (ADR 0434), where the check calls it once per
20196
+ * row. It runs as the caller, so only `authorization.functions.rowsWith`
20197
+ * applies.
20198
+ */
20199
+ function providerRowSet(ctx, where, rows, key) {
20200
+ const rowsWith = ctx.providerRowsWith;
20201
+ if (rowsWith === void 0) throw new TypeError(`${where}.rows needs blocks.permissions.model "provider" and an authorization provider with functions.rowsWith`);
20202
+ const permission = sqlString(key);
20203
+ return (ids) => `select r.id::text from ${fillTemplate("authorization.functions.rowsWith", rowsWith, {
20204
+ resource: rows,
20205
+ permission,
20206
+ ids
20207
+ })} as r(id)`;
20208
+ }
20193
20209
  // src/sql/modules/drive-roles.ts
20194
20210
  const QUALIFIED$3 = /^[A-Za-z_][\w$]*\.[A-Za-z_][\w$]*$/;
20195
20211
  function providerRoles(ctx, all, at, rows, map) {
20196
20212
  if (!isResourceName(rows) || !isRecord$1(map) || Object.keys(map).length === 0 || !Object.entries(map).every(([role, key]) => all.includes(role) && typeof key === "string" && key !== "")) throw new TypeError(`${at} takes { rows, roles }: the provider's resource name and a permission key for each of options.roles it grants`);
20197
20213
  const checks = all.filter((role) => map[role] !== void 0).toReversed().map((role) => ({
20198
20214
  role,
20199
- check: providerRowCheck(ctx, at, rows, String(map[role]))
20215
+ check: providerRowCheck(ctx, at, rows, String(map[role])),
20216
+ set: providerRowSet(ctx, at, rows, String(map[role]))
20200
20217
  }));
20201
20218
  return {
20202
20219
  label: `the authorization provider's grants on ${rows}`,
20203
- role: (id, user) => `case ${checks.map(({ role, check }) => `when ${check(id, user)} then ${sqlString(role)}`).join(" ")} end`
20220
+ role: (id, user) => `case ${checks.map(({ role, check }) => `when ${check(id, user)} then ${sqlString(role)}`).join(" ")} end`,
20221
+ readable: (candidates) => checks.map(({ set }) => set(candidates)).join("\n union\n ")
20204
20222
  };
20205
20223
  }
20206
20224
  /** `options.roleFunctions`: app functions that return the caller's role. */
@@ -20231,7 +20249,7 @@ function driveRoleFunctions(ctx, all) {
20231
20249
  // src/sql/subject-write.ts
20232
20250
  /**
20233
20251
  * Whether the caller holds the `write` key a registered subject type names
20234
- * (`config.subjects.<type>.permissions.write`) in `tenant`. `true` for types
20252
+ * (`config.recordTypes.<type>.permissions.write`) in `tenant`. `true` for types
20235
20253
  * without one, so a module's own check decides.
20236
20254
  */
20237
20255
  function subjectWritable(ctx, subjects, args) {
@@ -23442,7 +23460,7 @@ function build$148(ctx, layout) {
23442
23460
  const provider = accessModel(ctx) === "provider" ? layout.accessProvider : void 0;
23443
23461
  const fn = (name) => ctx.fn(name);
23444
23462
  return `${schemaPreamble(ctx)}${recordTeamTable(ctx)}
23445
- -- The app's subject registry (config.subjects, ADR 0020). Each function runs
23463
+ -- The app's subject registry (config.recordTypes, ADR 0020). Each function runs
23446
23464
  -- as the caller, so the subject table's own policies decide what is visible.
23447
23465
  create or replace function ${fn("subject_types")}()
23448
23466
  returns text[]
@@ -23522,7 +23540,7 @@ $$;
23522
23540
  ${userGrant(`${fn("subject_titles")}(jsonb)`)}
23523
23541
 
23524
23542
  -- True when the caller can see the subject row and, for an action with a
23525
- -- key in config.subjects.<type>.permissions, holds that key in the
23543
+ -- key in config.recordTypes.<type>.permissions, holds that key in the
23526
23544
  -- subject's tenant (or on the record, through the subject's scope), and the
23527
23545
  -- action's check function, when it names one, returns true for the row.
23528
23546
  create or replace function ${fn("can_subject")}(subject_type text, subject_id text, action text)
@@ -23587,7 +23605,7 @@ ${userGrant(`${fn("record_summary")}(text, text, text[], timestamptz)`)}
23587
23605
 
23588
23606
  -- can_subject for another user, for server code that decides who receives
23589
23607
  -- an event. It reads the row past its policies and asks can_user for the
23590
- -- action's key in config.subjects.<type>.permissions, so an action without
23608
+ -- action's key in config.recordTypes.<type>.permissions, so an action without
23591
23609
  -- a key is false and a share-link grant never counts. A provider that
23592
23610
  -- can't answer for others (no idsWithFor) gives false.
23593
23611
  create or replace function ${fn("can_subject_for")}(member uuid, subject_type text, subject_id text, action text)
@@ -23744,7 +23762,7 @@ const SUBJECTS = {
23744
23762
  name: "subjects",
23745
23763
  scopes: ["tenant"],
23746
23764
  title: "Subjects",
23747
- description: "The app-wide subject registry from config.subjects: subject_title, subject_url, subject_titles, can_subject, can_subject_for and record_summary for every registered type, my_work across the installed blocks, record teams (subject_members, add_subject_member, end_subject_member, list_subject_members, my_subjects) that grant subjects.<type>.team actions, read logging for types with subjects.<type>.auditReads (record_subject_read, subject_access_log), and Realtime presence on presence:<type>:<id> for readers of the subject.",
23765
+ description: "The app-wide subject registry from config.recordTypes: subject_title, subject_url, subject_titles, can_subject, can_subject_for and record_summary for every registered type, my_work across the installed blocks, record teams (subject_members, add_subject_member, end_subject_member, list_subject_members, my_subjects) that grant subjects.<type>.team actions, read logging for types with subjects.<type>.auditReads (record_subject_read, subject_access_log), and Realtime presence on presence:<type>:<id> for readers of the subject.",
23748
23766
  requires: ["permissions"],
23749
23767
  integrates: [
23750
23768
  "teams",
@@ -24494,6 +24512,35 @@ end;
24494
24512
  $$;
24495
24513
  ${userGrant(`${fn("get_approval")}(uuid)`)}
24496
24514
 
24515
+ -- Many requests with their decisions and items in one read, in the order
24516
+ -- requested. A request that is missing or that the caller cannot read is left
24517
+ -- out instead of failing the batch.
24518
+ create or replace function ${fn("get_approvals")}(request_ids uuid[])
24519
+ returns jsonb
24520
+ language plpgsql
24521
+ stable
24522
+ security definer
24523
+ set search_path = ''
24524
+ as $$
24525
+ begin
24526
+ return (
24527
+ select coalesce(jsonb_agg(${json("r")} || jsonb_build_object(
24528
+ 'canDecide', ${fn("approval_eligible")}(r.${c("id")}),
24529
+ 'decisions', coalesce((
24530
+ select jsonb_agg(jsonb_build_object('id', x.${d("id")}, 'step', x.${d("step")}, 'approver', x.${d("approver")}, 'decision', x.${d("decision")}, 'delegateTo', ${or("decisions", "x", "delegateTo")}, 'comment', ${or("decisions", "x", "comment")}, 'createdAt', x.${d("createdAt")}) order by x.${d("createdAt")}, x.${d("id")})
24531
+ from ${decisions} x where x.${d("request")} = r.${c("id")}
24532
+ ), '[]'::jsonb),
24533
+ 'items', ${itemsOf$1(ctx, `r.${c("id")}`)}
24534
+ ) order by array_position(get_approvals.request_ids, r.${c("id")})), '[]'::jsonb)
24535
+ from ${requests} r
24536
+ where r.${c("id")} = any (get_approvals.request_ids)
24537
+ and (${SERVICE_CALLER$1} or coalesce(r.${c("requestedBy")} = auth.uid(), false) or ${fn("approval_eligible")}(r.${c("id")})
24538
+ or (${ctx.can("tenant", `r.${c("tenant")}`, read)} and ${readable("r")}))
24539
+ );
24540
+ end;
24541
+ $$;
24542
+ ${userGrant(`${fn("get_approvals")}(uuid[])`)}
24543
+
24497
24544
  -- assigned: only requests whose current step the caller can decide.
24498
24545
  create or replace function ${fn("list_approvals")}(tenant ${ctx.idType}, status text default 'pending', assigned boolean default false, subject_type text default null, subject_id text default null, page_size integer default 50, before timestamptz default null)
24499
24546
  returns jsonb
@@ -33574,6 +33621,63 @@ const ANNOUNCEMENTS = {
33574
33621
  build: build$138,
33575
33622
  topics: (ctx) => [ctx.text("topic", "announcements")]
33576
33623
  };
33624
+ // src/sql/modules/permissions-operations.ts
33625
+ const isOperationModule = (name) => Object.hasOwn(MODULE_PERMISSION_SCOPES, name);
33626
+ /**
33627
+ * The permission key of every operation the layout knows: each installed
33628
+ * module's `OPERATIONS` after `blocks.<name>.permissions` renames, with the
33629
+ * provider's `authorization.operations` over them.
33630
+ */
33631
+ function operationKeys(ctx, layout) {
33632
+ const keys = /* @__PURE__ */ new Map();
33633
+ for (const module of ctx.installedModules) {
33634
+ if (!isOperationModule(module)) continue;
33635
+ const of = moduleContext(module, layout, ctx.installedModules);
33636
+ if (of.mode === "custom") continue;
33637
+ for (const [action, fallback] of Object.entries(moduleOperations(module))) keys.set(`${module}.${action}`, modulePermissionKey(of, action, fallback));
33638
+ }
33639
+ const operations = layout.accessProvider?.operations;
33640
+ for (const name of Object.keys(operations ?? {})) {
33641
+ const key = operationPermission(operations, name, keys.get(name));
33642
+ if (key !== void 0) keys.set(name, key);
33643
+ }
33644
+ return keys;
33645
+ }
33646
+ /**
33647
+ * The permission keys only a signed-in user gets: the installed
33648
+ * `INTERACTIVE_ONLY_OPERATIONS` after renames, with
33649
+ * `authorization.delegation.interactiveOnly` and
33650
+ * `blocks.permissions.interactiveOnly`.
33651
+ */
33652
+ function interactiveOnlyKeys(ctx, layout) {
33653
+ const keys = operationKeys(ctx, layout);
33654
+ return [.../* @__PURE__ */ new Set([
33655
+ ...INTERACTIVE_ONLY_OPERATIONS.flatMap((op) => keys.get(op) ?? []),
33656
+ ...layout.delegationInteractiveOnly ?? [],
33657
+ ...ctx.modules.permissions?.interactiveOnly ?? []
33658
+ ])].toSorted();
33659
+ }
33660
+ /**
33661
+ * `operation_permission(op)`: the key an operation checks, `null` for one
33662
+ * nobody declared.
33663
+ */
33664
+ function operationsSql(ctx, layout) {
33665
+ const keys = [...operationKeys(ctx, layout)].toSorted(([a], [b]) => a.localeCompare(b));
33666
+ return `
33667
+ -- The permission key an operation (<module>.<action>, or a name in
33668
+ -- authorization.operations) checks, after renames and the provider's table.
33669
+ -- Null for an operation nobody declared, which callers refuse.
33670
+ create or replace function better_supabase.operation_permission(op text)
33671
+ returns text
33672
+ language sql
33673
+ immutable
33674
+ set search_path = ''
33675
+ as $$
33676
+ select ${keys.length === 0 ? "null::text" : `case op
33677
+ ${keys.map(([name, key]) => `when ${sqlString(name)} then ${sqlString(key)}`).join("\n ")}
33678
+ end`}
33679
+ $$;`;
33680
+ }
33577
33681
  // src/sql/modules/api-keys.ts
33578
33682
  const EVENTS$33 = {
33579
33683
  "api_key.created": {
@@ -33743,6 +33847,9 @@ function build$137(ctx, layout) {
33743
33847
  if exists (select 1 from unnest(coalesce(scopes, '{}')) s where s <> all (${sqlString(`{${allowed.join(",")}}`)}::text[])) then
33744
33848
  ${fail("API_KEY_SCOPE_UNKNOWN", "A scope is not one of blocks.api-keys.options.scopes", "22023")}
33745
33849
  end if;` : "";
33850
+ const interactiveCheck = interactiveScopeCheck(interactiveOnlyKeys(ctx, layout));
33851
+ const mapsScopes = ctx.of("permissions").mode !== "custom";
33852
+ const withinToken = (scopes) => tokenScopeCheck(scopes, mapsScopes);
33746
33853
  const state = (alias) => `case
33747
33854
  when ${alias}.${c("revokedAt")} is not null and ${alias}.${c("revokedAt")} <= now() then 'revoked'
33748
33855
  when ${alias}.${c("expiresAt")} is not null and ${alias}.${c("expiresAt")} <= now() then 'expired'
@@ -33879,7 +33986,7 @@ begin
33879
33986
  ) then
33880
33987
  ${fail("API_KEY_FORBIDDEN", "Not allowed to create API keys for every tenant")}
33881
33988
  end if;
33882
- end if;${scopeCheck}${wildcard}
33989
+ end if;${scopeCheck}${interactiveCheck}${withinToken("scopes")}${wildcard}
33883
33990
  if expires_at is not null and expires_at <= now() then
33884
33991
  ${fail("API_KEY_EXPIRED", "expires_at is in the past", "22023")}
33885
33992
  end if;
@@ -33954,7 +34061,7 @@ begin
33954
34061
  select * into old from ${t} k where k.${c("id")} = rotate_api_key.key for update;
33955
34062
  if old.${c("id")} is null or not ${mayChange("old")} then
33956
34063
  ${fail("API_KEY_NOT_FOUND", "API key not found", "P0002")}
33957
- end if;
34064
+ end if;${withinToken(`old.${c("scopes")}`)}
33958
34065
  if old.${c("revokedAt")} is not null and old.${c("revokedAt")} <= now() then
33959
34066
  ${fail("API_KEY_REVOKED", "A revoked API key cannot be rotated", "22023")}
33960
34067
  end if;
@@ -34133,6 +34240,44 @@ const API_KEYS = {
34133
34240
  ],
34134
34241
  build: build$137
34135
34242
  };
34243
+ /** Refuses an interactive-only permission key as a key scope. */
34244
+ function interactiveScopeCheck(interactive) {
34245
+ return interactive.length === 0 ? "" : `
34246
+ if exists (select 1 from unnest(coalesce(scopes, '{}')) s where s = any (${sqlString(`{${interactive.join(",")}}`)}::text[])) then
34247
+ ${fail("API_KEY_FORBIDDEN", "Only a signed-in user may use this permission, so an API key cannot carry it")}
34248
+ end if;`;
34249
+ }
34250
+ /**
34251
+ * An API key, OAuth client or agent hands on at most its own scopes: a key's
34252
+ * scopes (or *), or the keys the token's OAuth scopes map to.
34253
+ */
34254
+ function tokenScopeCheck(scopes, mapsScopes) {
34255
+ return `
34256
+ if (auth.jwt() -> 'api_key' is not null
34257
+ or coalesce(auth.jwt() ->> 'client_id', '') <> ''
34258
+ or auth.jwt() -> 'act' is not null) and exists (
34259
+ select 1 from unnest(coalesce(${scopes}, '{}')) s
34260
+ where not case
34261
+ when auth.jwt() -> 'api_key' is not null then
34262
+ coalesce(auth.jwt() -> 'api_key' -> 'scopes', '[]'::jsonb) ?| array['*', s]
34263
+ else exists (
34264
+ select 1
34265
+ from unnest(case jsonb_typeof(auth.jwt() -> 'scope')
34266
+ when 'string' then regexp_split_to_array(btrim(auth.jwt() ->> 'scope'), '\\s+')
34267
+ when 'array' then array(select jsonb_array_elements_text(auth.jwt() -> 'scope'))
34268
+ else '{}'::text[]
34269
+ end) t(scope)
34270
+ where t.scope <> ''
34271
+ and (t.scope = s${mapsScopes ? ` or exists (
34272
+ select 1 from unnest(better_supabase.scope_permissions(t.scope)) k(key)
34273
+ where better_supabase.permission_matches(k.key, s)
34274
+ )` : ""})
34275
+ )
34276
+ end
34277
+ ) then
34278
+ ${fail("API_KEY_FORBIDDEN", "A token may only give a key the scopes it holds itself")}
34279
+ end if;`;
34280
+ }
34136
34281
  // src/sql/modules/appraisals-rubrics.ts
34137
34282
  /**
34138
34283
  * Whether the caller must not learn who wrote a review. Only peer reviews are
@@ -70600,7 +70745,7 @@ begin
70600
70745
  ${fail("COLLECTION_INVALID", "scope must be user, team or tenant", "22023")}
70601
70746
  end if;
70602
70747
  if create_collection.subject_type is null or not (create_collection.subject_type = any (${names.subjectTypes})) then
70603
- ${fail("COLLECTION_SUBJECT_TYPE_UNKNOWN", "not a subject type in config.subjects", "22023")}
70748
+ ${fail("COLLECTION_SUBJECT_TYPE_UNKNOWN", "not a subject type in config.recordTypes", "22023")}
70604
70749
  end if;
70605
70750
  if v_name is null then
70606
70751
  ${fail("COLLECTION_NAME_REQUIRED", "a name is required", "23502")}
@@ -71476,7 +71621,7 @@ function build$117(ctx, layout) {
71476
71621
  return `${schemaPreamble(ctx)}
71477
71622
  -- Favorites (a member's starred records, ranked for a sidebar), lists (named,
71478
71623
  -- static collections of one subject type) and saved items (a member's records
71479
- -- to come back to, with a reminder) on config.subjects records.
71624
+ -- to come back to, with a reminder) on config.recordTypes records.
71480
71625
  ${tables$49(ctx, names)}${ctx.manages ? policies(ctx, names) : ""}${collectionFunctions(ctx, names)}${starFunctions(ctx, names)}${savedItemFunctions(ctx, names)}${subjectCascades(ctx, cascading(ctx), `delete from ${ctx.table("entries")} where ${en("subjectType")} = v_type and ${en("subjectId")} = v_id;
71481
71626
  delete from ${ctx.table("favorites")} where ${fa("subjectType")} = v_type and ${fa("subjectId")} = v_id;
71482
71627
  delete from ${ctx.table("savedItems")} where ${sv("subjectType")} = v_type and ${sv("subjectId")} = v_id;`)}`;
@@ -71653,6 +71798,37 @@ const COLLECTIONS$1 = {
71653
71798
  contract: contract$103,
71654
71799
  build: build$117
71655
71800
  };
71801
+ // src/sql/modules/comments-mention-groups.ts
71802
+ const MENTION_GROUP_KEYS = /* @__PURE__ */ new Set([
71803
+ "table",
71804
+ "group",
71805
+ "member",
71806
+ "tenant"
71807
+ ]);
71808
+ function mentionGroupsOf(ctx) {
71809
+ const option = ctx.option("mentionGroups");
71810
+ if (option === void 0) return;
71811
+ const where = "blocks.comments.options.mentionGroups";
71812
+ if (!isRecord$1(option)) throw new TypeError(`${where} must be { table, group, member, tenant? }`);
71813
+ for (const key of Object.keys(option)) if (!MENTION_GROUP_KEYS.has(key)) throw new TypeError(`${where}.${key} is not an option. Options: table, group, member, tenant`);
71814
+ const text = (key) => {
71815
+ const value = option[key];
71816
+ if (value === void 0) return;
71817
+ if (typeof value !== "string" || value.length === 0) throw new TypeError(`${where}.${key} must be a non-empty string`);
71818
+ return value;
71819
+ };
71820
+ const table = text("table");
71821
+ const group = text("group");
71822
+ const member = text("member");
71823
+ if (table === void 0 || group === void 0 || member === void 0) throw new TypeError(`${where} needs table, group and member`);
71824
+ const tenant = text("tenant");
71825
+ return {
71826
+ table,
71827
+ group,
71828
+ member,
71829
+ ...tenant !== void 0 && { tenant }
71830
+ };
71831
+ }
71656
71832
  // src/sql/modules/messaging-tables.ts
71657
71833
  const MESSAGE_RESERVED = ["fields"];
71658
71834
  /** The longest thread summary `save_thread_summary` stores. */
@@ -71697,9 +71873,14 @@ function guestOnRecord(q, alias, action) {
71697
71873
  return guest === "false" ? "" : `
71698
71874
  or (${alias}.${cv("kind")} = 'subject' and ${guest})`;
71699
71875
  }
71700
- /** With the inbox: a note shows to the inbox's staff only. */
71701
- function noteReadable(q, conversation) {
71702
- return q.ctx.installed("inbox") ? `\n and (${q.cols("messages")("kind")} = 'message' or ${q.ctx.of("inbox").fn("inbox_note_readable")}(${conversation}))` : "";
71876
+ /**
71877
+ * With the inbox: a note shows to the inbox's staff only. `alias` qualifies the
71878
+ * message's columns.
71879
+ */
71880
+ function noteReadable(q, alias) {
71881
+ const ms = q.cols("messages");
71882
+ const at = alias === void 0 ? "" : `${alias}.`;
71883
+ return q.ctx.installed("inbox") ? `\n and (${at}${ms("kind")} = 'message' or ${q.ctx.of("inbox").fn("inbox_note_readable")}(${at}${ms("conversation")}))` : "";
71703
71884
  }
71704
71885
  function tableDdl(q) {
71705
71886
  const { ctx, t, id } = q;
@@ -71913,7 +72094,7 @@ ${renderPolicy(policy$1({
71913
72094
  command: "select",
71914
72095
  roles: ["authenticated"],
71915
72096
  using: `(${ms("sentAt")} is not null or ${ms("author")} = (select auth.uid()))
71916
- and exists (select 1 from ${t("conversations")} c where c.${cv("id")} = ${ms("conversation")})${noteReadable(q, ms("conversation"))}`
72097
+ and exists (select 1 from ${t("conversations")} c where c.${cv("id")} = ${ms("conversation")})${noteReadable(q)}`
71917
72098
  }), { target: t("messages") })}
71918
72099
 
71919
72100
  ${ddl.edits}
@@ -72167,36 +72348,6 @@ const NAMES$113 = {
72167
72348
  };
72168
72349
  /** Sorts after every uuid, so `after` without `after_id` means strictly later. */
72169
72350
  const MAX_UUID$1 = "'ffffffff-ffff-ffff-ffff-ffffffffffff'::uuid";
72170
- const MENTION_GROUP_KEYS = /* @__PURE__ */ new Set([
72171
- "table",
72172
- "group",
72173
- "member",
72174
- "tenant"
72175
- ]);
72176
- function mentionGroupsOf(ctx) {
72177
- const option = ctx.option("mentionGroups");
72178
- if (option === void 0) return;
72179
- const where = "blocks.comments.options.mentionGroups";
72180
- if (!isRecord$1(option)) throw new TypeError(`${where} must be { table, group, member, tenant? }`);
72181
- for (const key of Object.keys(option)) if (!MENTION_GROUP_KEYS.has(key)) throw new TypeError(`${where}.${key} is not an option. Options: table, group, member, tenant`);
72182
- const text = (key) => {
72183
- const value = option[key];
72184
- if (value === void 0) return;
72185
- if (typeof value !== "string" || value.length === 0) throw new TypeError(`${where}.${key} must be a non-empty string`);
72186
- return value;
72187
- };
72188
- const table = text("table");
72189
- const group = text("group");
72190
- const member = text("member");
72191
- if (table === void 0 || group === void 0 || member === void 0) throw new TypeError(`${where} needs table, group and member`);
72192
- const tenant = text("tenant");
72193
- return {
72194
- table,
72195
- group,
72196
- member,
72197
- ...tenant !== void 0 && { tenant }
72198
- };
72199
- }
72200
72351
  /** A column name as a JSON key of `to_jsonb(row)`. */
72201
72352
  const key = (column) => sqlString(column.replaceAll("\"", ""));
72202
72353
  /**
@@ -72323,7 +72474,7 @@ end;
72323
72474
  $$;
72324
72475
  ${userGrant(`${fn("assign_comment")}(uuid, uuid, jsonb)`)}`;
72325
72476
  }
72326
- function build$116(ctx) {
72477
+ function build$116(ctx, layout) {
72327
72478
  if (ctx.mode === "custom") return "";
72328
72479
  const id = ctx.idType;
72329
72480
  const m = ctx.of("messaging");
@@ -72338,6 +72489,39 @@ function build$116(ctx) {
72338
72489
  const expand = groups === void 0 ? "select x from unnest(v_raw) x" : `select x from unnest(v_raw) x
72339
72490
  union select g.${sqlIdent$1(groups.member)} from ${quotedTable(groups.table)} g where g.${sqlIdent$1(groups.group)} = any (v_raw)${groups.tenant === void 0 ? "" : ` and g.${sqlIdent$1(groups.tenant)} = create_comment.tenant`}`;
72340
72491
  const sent = afterSend(ctx);
72492
+ const mq = messagingSql(m, layout.accessProvider);
72493
+ const pageIds = (conversation, f, notes) => `array(
72494
+ select x.${ms("id")} from ${m.table("messages")} x
72495
+ where x.${ms("conversation")} = ${conversation} and x.${ms("sentAt")} is not null${notes}
72496
+ and (coalesce(${f}.include_deleted, true) or x.${ms("deletedAt")} is null)
72497
+ and (${f}.after is null
72498
+ or (x.${ms("sentAt")}, x.${ms("id")}) > (${f}.after, coalesce(${f}.after_id, ${MAX_UUID$1})))
72499
+ order by x.${ms("sentAt")}, x.${ms("id")}
72500
+ limit ${pageSize(`${f}.max_rows`, 100, 500)}
72501
+ offset greatest(coalesce(${f}.skip, 0), 0)
72502
+ )`;
72503
+ const commentsOf = (messagesJson, ids) => `(
72504
+ with e as materialized (
72505
+ select x.row, x.n from jsonb_array_elements(${messagesJson}(${ids})) with ordinality x(row, n)
72506
+ ),
72507
+ c as materialized (
72508
+ select c.${cv("id")} as id, c.${cv("subjectType")} as subject_type, c.${cv("subjectId")} as subject_id
72509
+ from ${m.table("conversations")} c
72510
+ where c.${cv("id")} = any (array(select distinct (e.row ->> ${key(ms("conversation"))})::uuid from e))
72511
+ ),
72512
+ t as materialized (
72513
+ select t.${k("message")} as message, t.${k("task")} as task from ${tasks} t
72514
+ where t.${k("message")} = any (${ids})
72515
+ )
72516
+ select coalesce(jsonb_agg(e.row || jsonb_build_object(
72517
+ 'subject_type', c.subject_type,
72518
+ 'subject_id', c.subject_id,
72519
+ 'task_id', t.task
72520
+ ) order by e.n), '[]'::jsonb)
72521
+ from e
72522
+ join c on c.id = (e.row ->> ${key(ms("conversation"))})::uuid
72523
+ left join t on t.message = (e.row ->> ${key(ms("id"))})::uuid
72524
+ )`;
72341
72525
  return `${schemaPreamble(ctx)}
72342
72526
  -- Comments are a record's conversation (kind subject) on the messaging core:
72343
72527
  -- whoever reads the record reads its comments. These functions open it,
@@ -72425,32 +72609,40 @@ security invoker
72425
72609
  set search_path = ''
72426
72610
  as $$
72427
72611
  begin
72428
- return (
72429
- with e as materialized (
72430
- select x.row, x.n from jsonb_array_elements(${m.fn("messaging_messages_json")}(comments_json.ids)) with ordinality x(row, n)
72431
- ),
72432
- c as materialized (
72433
- select c.${cv("id")} as id, c.${cv("subjectType")} as subject_type, c.${cv("subjectId")} as subject_id
72434
- from ${m.table("conversations")} c
72435
- where c.${cv("id")} = any (array(select distinct (e.row ->> ${key(ms("conversation"))})::uuid from e))
72436
- ),
72437
- t as materialized (
72438
- select t.${k("message")} as message, t.${k("task")} as task from ${tasks} t
72439
- where t.${k("message")} = any (comments_json.ids)
72440
- )
72441
- select coalesce(jsonb_agg(e.row || jsonb_build_object(
72442
- 'subject_type', c.subject_type,
72443
- 'subject_id', c.subject_id,
72444
- 'task_id', t.task
72445
- ) order by e.n), '[]'::jsonb)
72446
- from e
72447
- join c on c.id = (e.row ->> ${key(ms("conversation"))})::uuid
72448
- left join t on t.message = (e.row ->> ${key(ms("id"))})::uuid
72449
- );
72612
+ return ${commentsOf(m.fn("messaging_messages_json"), "comments_json.ids")};
72450
72613
  end;
72451
72614
  $$;
72452
72615
  ${userGrant(`${fn("comments_json")}(uuid[])`)}
72453
72616
 
72617
+ -- A page of a record conversation's sent comment ids, as their owner, once
72618
+ -- the conversation passes the read check.
72619
+ create or replace function ${fn("comment_page")}(
72620
+ conversation uuid,
72621
+ after timestamptz default null,
72622
+ max_rows integer default 100,
72623
+ skip integer default 0,
72624
+ after_id uuid default null,
72625
+ include_deleted boolean default true
72626
+ )
72627
+ returns uuid[]
72628
+ language plpgsql
72629
+ stable
72630
+ security definer
72631
+ set search_path = ''
72632
+ as $$
72633
+ begin
72634
+ if not exists (
72635
+ select 1 from ${m.table("conversations")} c
72636
+ where c.${cv("id")} = comment_page.conversation and c.${cv("kind")} = 'subject'
72637
+ and (${SERVICE_CALLER$1} or ${conversationReadable(mq, "c")})
72638
+ ) then
72639
+ return '{}'::uuid[];
72640
+ end if;
72641
+ return ${pageIds("comment_page.conversation", "comment_page", noteReadable(mq, "x"))};
72642
+ end;
72643
+ $$;
72644
+ ${userGrant(`${fn("comment_page")}(uuid, timestamptz, integer, integer, uuid, boolean)`)}
72645
+
72454
72646
  -- One comment the caller reads, or null.
72455
72647
  create or replace function ${fn("get_comment")}(message uuid)
72456
72648
  returns jsonb
@@ -72547,20 +72739,46 @@ begin
72547
72739
  if v_conv is null then
72548
72740
  return '[]'::jsonb;
72549
72741
  end if;${readLine(ctx.read("list_comments.subject_type", "list_comments.subject_id", "list_comments"))}
72550
- return ${fn("comments_json")}(array(
72551
- select x.${ms("id")} from ${m.table("messages")} x
72552
- where x.${ms("conversation")} = v_conv and x.${ms("sentAt")} is not null
72553
- and (coalesce(list_comments.include_deleted, true) or x.${ms("deletedAt")} is null)
72554
- and (list_comments.after is null
72555
- or (x.${ms("sentAt")}, x.${ms("id")}) > (list_comments.after, coalesce(list_comments.after_id, ${MAX_UUID$1})))
72556
- order by x.${ms("sentAt")}, x.${ms("id")}
72557
- limit ${pageSize("list_comments.max_rows", 100, 500)}
72558
- offset greatest(coalesce(list_comments.skip, 0), 0)
72559
- ));
72742
+ return ${fn("comments_json")}(${fn("comment_page")}(v_conv, list_comments.after, list_comments.max_rows, list_comments.skip, list_comments.after_id, list_comments.include_deleted));
72560
72743
  end;
72561
72744
  $$;
72562
72745
  ${userGrant(`${fn("list_comments")}(${id}, text, text, timestamptz, integer, integer, uuid, boolean)`)}
72563
72746
 
72747
+ -- list_comments without any check, as the owner. Only for the app's own
72748
+ -- security definer function after it checked that the caller reads the
72749
+ -- record and holds the comment read key in its tenant. Service role only.
72750
+ create or replace function ${fn("list_comments_unchecked")}(
72751
+ tenant ${id},
72752
+ subject_type text,
72753
+ subject_id text,
72754
+ after timestamptz default null,
72755
+ max_rows integer default 100,
72756
+ skip integer default 0,
72757
+ after_id uuid default null,
72758
+ include_deleted boolean default true
72759
+ )
72760
+ returns jsonb
72761
+ language plpgsql
72762
+ ${ctx.readVolatility()}
72763
+ security definer
72764
+ set search_path = ''
72765
+ as $$
72766
+ declare
72767
+ v_conv uuid;
72768
+ v_ids uuid[];
72769
+ begin
72770
+ select c.${cv("id")} into v_conv from ${m.table("conversations")} c
72771
+ where c.${cv("tenant")} = list_comments_unchecked.tenant and c.${cv("kind")} = 'subject'
72772
+ and c.${cv("subjectType")} = list_comments_unchecked.subject_type and c.${cv("subjectId")} = list_comments_unchecked.subject_id;
72773
+ if v_conv is null then
72774
+ return '[]'::jsonb;
72775
+ end if;${readLine(ctx.read("list_comments_unchecked.subject_type", "list_comments_unchecked.subject_id", "list_comments_unchecked"))}
72776
+ v_ids := ${pageIds("v_conv", "list_comments_unchecked", "")};
72777
+ return ${commentsOf(m.fn("messaging_messages_json_unchecked"), "v_ids")};
72778
+ end;
72779
+ $$;
72780
+ ${serviceGrant(`${fn("list_comments_unchecked")}(${id}, text, text, timestamptz, integer, integer, uuid, boolean)`)}
72781
+
72564
72782
  -- The top-level comments anchored to a file, oldest first: on its pages,
72565
72783
  -- regions and moments, on any record the caller can read.
72566
72784
  create or replace function ${fn("list_file_comments")}(attachment uuid, max_rows integer default 100)
@@ -72584,8 +72802,32 @@ end;
72584
72802
  $$;
72585
72803
  ${userGrant(`${fn("list_file_comments")}(uuid, integer)`)}
72586
72804
 
72805
+ -- The number of sent, not deleted comments per conversation, as their
72806
+ -- owner, for the conversations of the list that pass the read check.
72807
+ create or replace function ${fn("comment_count_rows")}(conversations uuid[])
72808
+ returns table (id uuid, n bigint)
72809
+ language plpgsql
72810
+ stable
72811
+ security definer
72812
+ set search_path = ''
72813
+ as $$
72814
+ begin
72815
+ return query
72816
+ select x.${ms("conversation")}, count(*) from ${m.table("messages")} x
72817
+ where x.${ms("conversation")} = any (array(
72818
+ select c.${cv("id")} from ${m.table("conversations")} c
72819
+ where c.${cv("id")} = any (comment_count_rows.conversations) and c.${cv("kind")} = 'subject'
72820
+ and (${SERVICE_CALLER$1} or ${conversationReadable(mq, "c")})
72821
+ ))
72822
+ and x.${ms("sentAt")} is not null and x.${ms("deletedAt")} is null${noteReadable(mq, "x")}
72823
+ group by x.${ms("conversation")};
72824
+ end;
72825
+ $$;
72826
+ ${userGrant(`${fn("comment_count_rows")}(uuid[])`)}
72827
+
72587
72828
  -- Comments per record the caller can read, for counters in a list:
72588
- -- { subject_id: count }, deleted ones left out.
72829
+ -- { subject_id: count }, deleted ones left out. The records' conversations
72830
+ -- are read under the caller's policies, then counted by key.
72589
72831
  create or replace function ${fn("comment_counts")}(tenant ${id}, subject_type text, subject_ids text[])
72590
72832
  returns jsonb
72591
72833
  language plpgsql
@@ -72595,17 +72837,16 @@ set search_path = ''
72595
72837
  as $$
72596
72838
  begin
72597
72839
  return (
72598
- select coalesce(jsonb_object_agg(s.subject_id, s.n), '{}'::jsonb)
72599
- from (
72600
- select c.${cv("subjectId")} as subject_id, count(*) as n
72840
+ with c as materialized (
72841
+ select c.${cv("id")} as id, c.${cv("subjectId")} as subject_id
72601
72842
  from ${m.table("conversations")} c
72602
- join ${m.table("messages")} x on x.${ms("conversation")} = c.${cv("id")}
72603
72843
  where c.${cv("tenant")} = comment_counts.tenant and c.${cv("kind")} = 'subject'
72604
72844
  and c.${cv("subjectType")} = comment_counts.subject_type
72605
72845
  and c.${cv("subjectId")} = any (comment_counts.subject_ids)
72606
- and x.${ms("sentAt")} is not null and x.${ms("deletedAt")} is null
72607
- group by 1
72608
- ) s
72846
+ )
72847
+ select coalesce(jsonb_object_agg(c.subject_id, n.n), '{}'::jsonb)
72848
+ from c
72849
+ join ${fn("comment_count_rows")}(array(select c.id from c)) n on n.id = c.id
72609
72850
  );
72610
72851
  end;
72611
72852
  $$;
@@ -72794,7 +73035,10 @@ const COMMENTS = {
72794
73035
  internal: [
72795
73036
  "comment_message_readable",
72796
73037
  "comments_json",
72797
- "comment_sent"
73038
+ "comment_sent",
73039
+ "comment_page",
73040
+ "comment_count_rows",
73041
+ "list_comments_unchecked"
72798
73042
  ],
72799
73043
  name: "comments",
72800
73044
  scopes: ["tenant"],
@@ -84831,7 +85075,7 @@ function keyCheck(ctx, perType, fallback, kind, at) {
84831
85075
  }
84832
85076
  /**
84833
85077
  * The subjects whose field values follow record reads: `readAccess` on the
84834
- * record type (`config.subjects.<type>` or `on.<type>`), else the module's
85078
+ * record type (`config.recordTypes.<type>` or `on.<type>`), else the module's
84835
85079
  * `options.readAccess`.
84836
85080
  */
84837
85081
  function recordReadSubjects(subjects, fallback) {
@@ -85182,8 +85426,8 @@ const FIELD_VALUE_IMPORT_ENTITY = "field_value";
85182
85426
  const zeroUuid = "'00000000-0000-0000-0000-000000000000'::uuid";
85183
85427
  /**
85184
85428
  * The subject types field definitions can name: `blocks.custom-fields.on`, else
85185
- * `config.subjects` with the entities of the installed blocks. Empty when the
85186
- * app registers none, and then an entity stays free text.
85429
+ * `config.recordTypes` with the entities of the installed blocks. Empty when
85430
+ * the app registers none, and then an entity stays free text.
85187
85431
  */
85188
85432
  function registeredEntities(ctx) {
85189
85433
  return fieldSubjects(ctx).map(([type]) => type);
@@ -85889,7 +86133,7 @@ ${keyedFields(ctx, {
85889
86133
  const recordSubjects = recordReadSubjects(subjects, readAccess);
85890
86134
  const keyed = subjects.find(([, subject]) => subject.extra["keys"] !== void 0);
85891
86135
  if (keyed !== void 0) throw new TypeError(`blocks.custom-fields.on.${keyed[0]}.keys applies only to layout "keyed"`);
85892
- if (readAccess === "record" && subjects.length === 0) throw new TypeError("blocks.custom-fields.options.readAccess \"record\" needs record types in config.subjects or blocks.custom-fields.on");
86136
+ if (readAccess === "record" && subjects.length === 0) throw new TypeError("blocks.custom-fields.options.readAccess \"record\" needs record types in config.recordTypes or blocks.custom-fields.on");
85893
86137
  const subjectWrite = subjectActionCheck(ctx, subjects, {
85894
86138
  type: "set_field_value.subject_type",
85895
86139
  id: "set_field_value.subject_id"
@@ -88812,7 +89056,7 @@ grant execute on function ${ctx.fn("request_subject_export")}(text, text, text)
88812
89056
  const lookup = types.length === 0 ? fail("DATA_EXPORT_SUBJECT", "No record type can be exported", "22023") : `case request_subject_export.subject_type
88813
89057
  ${types.map((type) => recordBranch(ctx, type, omits)).join("\n ")}
88814
89058
  else
88815
- ${fail("DATA_EXPORT_SUBJECT", "subject_type is not a record type in config.subjects", "22023")}
89059
+ ${fail("DATA_EXPORT_SUBJECT", "subject_type is not a record type in config.recordTypes", "22023")}
88816
89060
  end case;`;
88817
89061
  const managed = ctx.installed("subjects") ? types.filter((type) => Object.hasOwn(ctx.subjects[type]?.permissions ?? {}, "manage")) : [];
88818
89062
  const manage = managed.length === 0 ? "" : ` or (request_subject_export.subject_type in (${managed.map((type) => sqlString(type)).join(", ")}) and coalesce(${ctx.of("subjects").fn("can_subject")}(request_subject_export.subject_type, request_subject_export.subject_id, 'manage'), false))`;
@@ -89761,7 +90005,7 @@ const DATA_LIFECYCLE = {
89761
90005
  },
89762
90006
  {
89763
90007
  from: 6,
89764
- description: "request_subject_export exports one config.subjects record (subject 'record'): its row decrypted through its reveal function and every module's rows attached to it, held in data_export_contents until the export job writes them. data_exports gains subject_type, subject_id and format, one named subject check replaces the generated ones, and the data_export events carry subjectType and subjectId.",
90008
+ description: "request_subject_export exports one config.recordTypes record (subject 'record'): its row decrypted through its reveal function and every module's rows attached to it, held in data_export_contents until the export job writes them. data_exports gains subject_type, subject_id and format, one named subject check replaces the generated ones, and the data_export events carry subjectType and subjectId.",
89765
90009
  sql: () => ""
89766
90010
  },
89767
90011
  {
@@ -91346,7 +91590,7 @@ ${lockTable(deadlines, { read: true })}
91346
91590
 
91347
91591
  -- Whether the caller may read the subject a deadline belongs to: its row is
91348
91592
  -- visible to them (the subject table's own policies apply) and they hold its
91349
- -- read permission, as blocks.deadlines.on or config.subjects declares it.
91593
+ -- read permission, as blocks.deadlines.on or config.recordTypes declares it.
91350
91594
  -- Without subjects every subject passes; with them an unlisted type fails.
91351
91595
  -- plpgsql, so a subject table a later module creates binds late.
91352
91596
  create or replace function ${fn("deadline_subject_readable")}(subject_type text, subject_id text, tenant ${idType})
@@ -102723,11 +102967,22 @@ ${driveRole === void 0 ? ` select d.${d("id")} from ${D} d
102723
102967
  and ${rank(`dg.${dg("role")}`)} >= ${rank(sqlString(roles.read))}
102724
102968
  and ${rank(sqlString(roles.read))} > 0
102725
102969
  and d.${d("tenant")} in (select ${ctx.scope.ids(read)})
102726
- and ${drivePrincipalMatch("dg", "auth.uid()", `d.${d("tenant")}`)}` : ` select d.${d("id")} from ${D} d
102970
+ and ${drivePrincipalMatch("dg", "auth.uid()", `d.${d("tenant")}`)}` : driveRole.readable === void 0 ? ` select d.${d("id")} from ${D} d
102971
+ where ${SERVICE_CALLER$1}
102972
+ or (auth.uid() is not null
102973
+ and d.${d("tenant")} in (select ${ctx.scope.ids(read)})
102974
+ and (${driveRole.role(`d.${d("id")}`, "auth.uid()")}) = any (${rolesArray}))` : ` with candidates as materialized (
102975
+ select coalesce(array_agg(d.${d("id")}::text), '{}'::text[]) as ids from ${D} d
102976
+ where auth.uid() is not null
102977
+ and d.${d("tenant")} in (select ${ctx.scope.ids(read)})
102978
+ )
102979
+ select d.${d("id")} from ${D} d
102727
102980
  where ${SERVICE_CALLER$1}
102728
102981
  or (auth.uid() is not null
102729
102982
  and d.${d("tenant")} in (select ${ctx.scope.ids(read)})
102730
- and (${driveRole.role(`d.${d("id")}`, "auth.uid()")}) = any (${rolesArray}))`}
102983
+ and d.${d("id")}::text in (
102984
+ ${driveRole.readable("(select c.ids from candidates c)")}
102985
+ ))`}
102731
102986
  $$;
102732
102987
  ${userGrant(`${fn("drive_drive_readable_ids")}()`)}
102733
102988
  ` : ""}
@@ -102783,7 +103038,7 @@ $$;
102783
103038
  ${userGrant(`${fn("drive_can")}(uuid, text)`)}
102784
103039
 
102785
103040
  -- Whether the caller may read the node: the read role on it, so a check
102786
- -- function in config.subjects can follow drive grants.
103041
+ -- function in config.recordTypes can follow drive grants.
102787
103042
  create or replace function ${fn("drive_node_readable")}(node uuid)
102788
103043
  returns boolean
102789
103044
  language sql
@@ -102848,11 +103103,22 @@ ${nodeRole === void 0 ? ` select x.${n("id")} from ${T} x
102848
103103
  and ${rank(`dg.${dg("role")}`)} >= ${rank(sqlString(roles.read))}
102849
103104
  and ${rank(sqlString(roles.read))} > 0
102850
103105
  and x.${n("tenant")} in (select ${ctx.scope.ids(read)})
102851
- and ${drivePrincipalMatch("dg", "auth.uid()", `x.${n("tenant")}`)}` : ""}` : ` select x.${n("id")} from ${T} x
103106
+ and ${drivePrincipalMatch("dg", "auth.uid()", `x.${n("tenant")}`)}` : ""}` : nodeRole.readable === void 0 ? ` select x.${n("id")} from ${T} x
103107
+ where ${SERVICE_CALLER$1}
103108
+ or (auth.uid() is not null
103109
+ and x.${n("tenant")} in (select ${ctx.scope.ids(read)})
103110
+ and (${nodeRole.role(`x.${n("id")}`, "auth.uid()")}) = any (${rolesArray}))` : ` with candidates as materialized (
103111
+ select coalesce(array_agg(x.${n("id")}::text), '{}'::text[]) as ids from ${T} x
103112
+ where auth.uid() is not null
103113
+ and x.${n("tenant")} in (select ${ctx.scope.ids(read)})
103114
+ )
103115
+ select x.${n("id")} from ${T} x
102852
103116
  where ${SERVICE_CALLER$1}
102853
103117
  or (auth.uid() is not null
102854
103118
  and x.${n("tenant")} in (select ${ctx.scope.ids(read)})
102855
- and (${nodeRole.role(`x.${n("id")}`, "auth.uid()")}) = any (${rolesArray}))`}
103119
+ and x.${n("id")}::text in (
103120
+ ${nodeRole.readable("(select c.ids from candidates c)")}
103121
+ ))`}
102856
103122
  $$;
102857
103123
  ${userGrant(`${fn("drive_readable_ids")}()`)}
102858
103124
 
@@ -104936,9 +105202,9 @@ const INTEGRATES$1 = [
104936
105202
  * of them; `drive-files` adds what needs those modules.
104937
105203
  */
104938
105204
  /**
104939
- * Access requests on nodes, when config.subjects gives the node type a team: an
104940
- * approved request becomes a node grant, and the members who may share the node
104941
- * approve it.
105205
+ * Access requests on nodes, when config.recordTypes gives the node type a team:
105206
+ * an approved request becomes a node grant, and the members who may share the
105207
+ * node approve it.
104942
105208
  */
104943
105209
  function accessRequests(own, target) {
104944
105210
  if (own.mode === "custom" || !target.installed("subjects")) return [];
@@ -106230,7 +106496,7 @@ function fromApplication(ctx, n) {
106230
106496
  const jobType = asText$3(hiring, "jobs", hiring.label("jobs", "employmentType", `v_job.${j("employmentType")}`));
106231
106497
  return `
106232
106498
  -- The employee for a hired application, in preboarding: the name comes from
106233
- -- the candidate's record in config.subjects, and the job title, team and
106499
+ -- the candidate's record in config.recordTypes, and the job title, team and
106234
106500
  -- employment type from the job. attrs overrides any of them. Calling it
106235
106501
  -- again returns the same employee, and with the relations module the
106236
106502
  -- employee is created_from the application.
@@ -111373,7 +111639,7 @@ const NAMES$88 = {
111373
111639
  const COLUMN$9 = /^[a-z_][a-z0-9_]{0,62}$/u;
111374
111640
  /**
111375
111641
  * `blocks.field-history.on`, record type to `{ fields }`, checked against
111376
- * `config.subjects`.
111642
+ * `config.recordTypes`.
111377
111643
  */
111378
111644
  function historyBindings(ctx) {
111379
111645
  const registry = registeredSubjects(ctx.subjects, ctx.naming);
@@ -111384,7 +111650,7 @@ function historyBindings(ctx) {
111384
111650
  const listed = Object.entries(onSettings(ctx)).map(([type, settings]) => {
111385
111651
  const where = `blocks.field-history.on.${type}`;
111386
111652
  const subject = registry.find((item) => item.type === type);
111387
- if (subject?.tenant === void 0) throw new TypeError(`${where}: register "${type}" with a tenant column in config.subjects first`);
111653
+ if (subject?.tenant === void 0) throw new TypeError(`${where}: register "${type}" with a tenant column in config.recordTypes first`);
111388
111654
  const fields = isRecord$1(settings) ? settings["fields"] : void 0;
111389
111655
  if (!Array.isArray(fields) || fields.length === 0 || fields.some((field) => typeof field !== "string" || !COLUMN$9.test(field))) throw new TypeError(`${where}.fields must be a non-empty list of column names`);
111390
111656
  return {
@@ -116285,7 +116551,7 @@ ${readPolicy("products", ctx.scope.check(p("tenant"), read))}
116285
116551
  create table if not exists ${awards} (
116286
116552
  ${w("id")} uuid primary key default gen_random_uuid(),
116287
116553
  ${w("tenant")} ${ctx.idType} not null,
116288
- -- The record the award is for, a type in config.subjects.
116554
+ -- The record the award is for, a type in config.recordTypes.
116289
116555
  ${w("subjectType")} text not null,
116290
116556
  ${w("subjectId")} text not null,
116291
116557
  -- The contacts company or person that pays, holding the funder role.
@@ -119745,7 +120011,7 @@ end;
119745
120011
  $$;
119746
120012
  ${userGrant(`${fn("save_job")}(${ctx.idType}, uuid, jsonb)`)}
119747
120013
 
119748
- -- An application of a candidate (a record in config.subjects, a person by
120014
+ -- An application of a candidate (a record in config.recordTypes, a person by
119749
120015
  -- default) to an open job. Applying again returns the same application.${appExtras.length > 0 ? "\n-- fields sets the applicationExtraColumns by name." : ""}
119750
120016
  ${appFields.drop(fn("apply_to_job"), "uuid, jsonb, text, uuid")}
119751
120017
  create or replace function ${fn("apply_to_job")}(job uuid, candidate jsonb, source text, owner uuid${appFields.param})
@@ -120125,7 +120391,7 @@ const HIRING = {
120125
120391
  name: "hiring",
120126
120392
  scopes: ["tenant"],
120127
120393
  title: "Hiring",
120128
- description: "Jobs and applications on a pipeline per job, candidates from config.subjects, scorecards per stage, interviews, and hire, reject and withdraw events for the app to act on.",
120394
+ description: "Jobs and applications on a pipeline per job, candidates from config.recordTypes, scorecards per stage, interviews, and hire, reject and withdraw events for the app to act on.",
120129
120395
  requires: [
120130
120396
  "memberships",
120131
120397
  "permissions",
@@ -134254,7 +134520,7 @@ ${userGrant(`${fn("purchase_order_tax_lines")}(uuid)`)}
134254
134520
  -- Creates a draft purchase order (purchase_order null) or replaces a draft's
134255
134521
  -- fields and lines. lines: [{ "variantId": uuid, "quantity": n, "unitCost": "minor units"
134256
134522
  -- }], and per line "taxRateBps" and "taxCode" when the order keeps tax lines.
134257
- -- supplier_type and supplier_id name a config.subjects record, or are both null.
134523
+ -- supplier_type and supplier_id name a config.recordTypes record, or are both null.
134258
134524
  ${numbered ? `drop function if exists ${fn("save_purchase_order")}(${ctx.idType}, uuid, uuid, text, text, text, timestamptz, jsonb, text);\n` : ""}create or replace function ${fn("save_purchase_order")}(tenant ${ctx.idType}, purchase_order uuid, location uuid, supplier_type text, supplier_id text, currency text, expected_at timestamptz, lines jsonb, note text${numbered ? ", number text default null" : ""})
134259
134525
  returns jsonb
134260
134526
  language plpgsql
@@ -136218,11 +136484,11 @@ ${addForeignKey({
136218
136484
  */
136219
136485
  const capFor = (member, permission) => `(${member} is distinct from auth.uid() or better_supabase.cap_allows(${permission}))`;
136220
136486
  /**
136221
- * `scope_permissions` and `cap_allows`: a delegated token (a `client_id`, or an
136222
- * `act` chain that is not a support or impersonation level) holds only the keys
136223
- * its scopes map to, and a `forContext({ permissions })` cap holds only its
136224
- * keys. The access functions apply both, so every policy and module that asks
136225
- * them is narrowed without calling `token_scope_allows`.
136487
+ * `scope_permissions` and `cap_allows`: an API key or a delegated token (a
136488
+ * `client_id`, or an `act` chain that is not a support or impersonation level)
136489
+ * holds only the keys its scopes map to, and a `forContext({ permissions })`
136490
+ * cap holds only its keys. The access functions apply both, so every policy and
136491
+ * module that asks them is narrowed without calling `token_scope_allows`.
136226
136492
  */
136227
136493
  function delegationSql(ctx, layout) {
136228
136494
  const scopes = {
@@ -136230,7 +136496,52 @@ function delegationSql(ctx, layout) {
136230
136496
  ...ctx.modules.permissions?.scopes
136231
136497
  };
136232
136498
  const entries = Object.entries(scopes);
136499
+ const body = entries.length === 0 ? "array[scope]" : `case scope
136500
+ ${entries.map(([scope, keys]) => `when ${sqlString(scope)} then array[${keys.map(sqlString).join(", ")}]::text[]`).join("\n ")}
136501
+ else array[scope]
136502
+ end`;
136503
+ const interactive = interactiveOnlyKeys(ctx, layout);
136504
+ const owner = ctx.installedModules.includes("organizations") ? ctx.of("organizations").text("ownerRole", "owner") : void 0;
136233
136505
  return `
136506
+ -- True for a user's own session and for no token at all. False for an API
136507
+ -- key (api_key), an OAuth client (client_id) and an act chain (an agent, a
136508
+ -- delegation, support or impersonation).
136509
+ create or replace function better_supabase.interactive_session()
136510
+ returns boolean
136511
+ language sql
136512
+ stable
136513
+ set search_path = ''
136514
+ as $$
136515
+ select auth.jwt() is null
136516
+ or (auth.jwt() -> 'api_key' is null
136517
+ and coalesce(auth.jwt() ->> 'client_id', '') = ''
136518
+ and auth.jwt() -> 'act' is null)
136519
+ $$;
136520
+
136521
+ -- The permission keys only a signed-in user gets (the built-in
136522
+ -- interactive-only operations, authorization.delegation.interactiveOnly and
136523
+ -- blocks.permissions.interactiveOnly): cap_allows refuses them to every
136524
+ -- other session, whatever its scopes.
136525
+ create or replace function better_supabase.interactive_only(permission text)
136526
+ returns boolean
136527
+ language sql
136528
+ immutable
136529
+ set search_path = ''
136530
+ as $$
136531
+ select ${interactive.length === 0 ? "false" : `coalesce(permission = any (array[${interactive.map(sqlString).join(", ")}]::text[]), false)`}
136532
+ $$;
136533
+
136534
+ -- The roles only a signed-in user grants or takes away: the organization
136535
+ -- owner role. can_assign refuses them to every other session.
136536
+ create or replace function better_supabase.interactive_only_role(role text)
136537
+ returns boolean
136538
+ language sql
136539
+ immutable
136540
+ set search_path = ''
136541
+ as $$
136542
+ select ${owner === void 0 ? "false" : `coalesce(role = ${sqlString(owner)}, false)`}
136543
+ $$;
136544
+
136234
136545
  -- The permission keys an OAuth scope grants a delegated token
136235
136546
  -- (authorization.delegation.scopes, blocks.permissions.scopes). A scope
136236
136547
  -- without an entry grants the key with its own name.
@@ -136240,15 +136551,14 @@ language sql
136240
136551
  immutable
136241
136552
  set search_path = ''
136242
136553
  as $$
136243
- select ${entries.length === 0 ? "array[scope]" : `case scope
136244
- ${entries.map(([scope, keys]) => `when ${sqlString(scope)} then array[${keys.map(sqlString).join(", ")}]::text[]`).join("\n ")}
136245
- else array[scope]
136246
- end`}
136554
+ select ${body}
136247
136555
  $$;
136248
136556
 
136249
- -- False when the token is narrower than the permission: a permission cap
136250
- -- (bsb_permission_cap) without the key, or a delegated token whose scopes
136251
- -- don't map to it. True for every other token, the service role included.
136557
+ -- False when the token is narrower than the permission: an interactive-only
136558
+ -- key outside a user's own session, a permission cap (bsb_permission_cap)
136559
+ -- without the key, an API key (api_key) or a delegated token whose scopes
136560
+ -- don't map to it. An API key without scopes holds no permission. True
136561
+ -- for every other token, the service role included.
136252
136562
  -- 0.14 named the cap bs_permission_cap; 0.15 still reads it when the new
136253
136563
  -- claim is missing, so a cap from an older runAs keeps narrowing.
136254
136564
  create or replace function better_supabase.cap_allows(permission text)
@@ -136260,11 +136570,22 @@ set search_path = ''
136260
136570
  as $$
136261
136571
  select case
136262
136572
  when jwt is null then true
136573
+ when better_supabase.interactive_only(cap_allows.permission)
136574
+ and not better_supabase.interactive_session() then false
136263
136575
  when jsonb_typeof(cap) = 'array'
136264
136576
  and not exists (
136265
136577
  select 1 from jsonb_array_elements_text(cap) c(key)
136266
136578
  where better_supabase.permission_matches(c.key, cap_allows.permission)
136267
136579
  ) then false
136580
+ when jsonb_typeof(jwt -> 'api_key') = 'object' then exists (
136581
+ select 1
136582
+ from jsonb_array_elements_text(case jsonb_typeof(jwt -> 'api_key' -> 'scopes')
136583
+ when 'array' then jwt -> 'api_key' -> 'scopes'
136584
+ else '[]'::jsonb
136585
+ end) s(scope)
136586
+ cross join lateral unnest(better_supabase.scope_permissions(s.scope)) k(key)
136587
+ where better_supabase.permission_matches(k.key, cap_allows.permission)
136588
+ )
136268
136589
  when coalesce(jwt ->> 'client_id', '') = ''
136269
136590
  and (jwt -> 'act' is null
136270
136591
  or (jsonb_typeof(jwt -> 'act') = 'object'
@@ -136483,49 +136804,6 @@ as $$
136483
136804
  }[wildcards]}
136484
136805
  $$;`;
136485
136806
  }
136486
- // src/sql/modules/permissions-operations.ts
136487
- const isOperationModule = (name) => Object.hasOwn(MODULE_PERMISSION_SCOPES, name);
136488
- /**
136489
- * The permission key of every operation the layout knows: each installed
136490
- * module's `OPERATIONS` after `blocks.<name>.permissions` renames, with the
136491
- * provider's `authorization.operations` over them.
136492
- */
136493
- function operationKeys(ctx, layout) {
136494
- const keys = /* @__PURE__ */ new Map();
136495
- for (const module of ctx.installedModules) {
136496
- if (!isOperationModule(module)) continue;
136497
- const of = moduleContext(module, layout, ctx.installedModules);
136498
- if (of.mode === "custom") continue;
136499
- for (const [action, fallback] of Object.entries(moduleOperations(module))) keys.set(`${module}.${action}`, modulePermissionKey(of, action, fallback));
136500
- }
136501
- const operations = layout.accessProvider?.operations;
136502
- for (const name of Object.keys(operations ?? {})) {
136503
- const key = operationPermission(operations, name, keys.get(name));
136504
- if (key !== void 0) keys.set(name, key);
136505
- }
136506
- return keys;
136507
- }
136508
- /**
136509
- * `operation_permission(op)`: the key an operation checks, `null` for one
136510
- * nobody declared.
136511
- */
136512
- function operationsSql(ctx, layout) {
136513
- const keys = [...operationKeys(ctx, layout)].toSorted(([a], [b]) => a.localeCompare(b));
136514
- return `
136515
- -- The permission key an operation (<module>.<action>, or a name in
136516
- -- authorization.operations) checks, after renames and the provider's table.
136517
- -- Null for an operation nobody declared, which callers refuse.
136518
- create or replace function better_supabase.operation_permission(op text)
136519
- returns text
136520
- language sql
136521
- immutable
136522
- set search_path = ''
136523
- as $$
136524
- select ${keys.length === 0 ? "null::text" : `case op
136525
- ${keys.map(([name, key]) => `when ${sqlString(name)} then ${sqlString(key)}`).join("\n ")}
136526
- end`}
136527
- $$;`;
136528
- }
136529
136807
  // src/sql/modules/permissions-roles.ts
136530
136808
  /**
136531
136809
  * `list_roles` and `set_permission_override`: the catalog's tenant roles with
@@ -136668,6 +136946,7 @@ ${userGrant(`${ctx.fn("set_permission_override")}(${id}, text, text, boolean)`)}
136668
136946
  }
136669
136947
  // src/sql/modules/permissions.ts
136670
136948
  const SERVICE = `coalesce(auth.jwt() ->> 'role', '') = 'service_role'`;
136949
+ const ROLE_GATE = "(better_supabase.interactive_session() or not better_supabase.interactive_only_role(can_assign.role))";
136671
136950
  const NOT_ACTING = `(platform_can.member is distinct from auth.uid() or auth.jwt() -> 'act' is null)`;
136672
136951
  /** Fills `{name}` placeholders of a `blocks.permissions.functions` template. */
136673
136952
  function fill(template, values) {
@@ -136942,7 +137221,7 @@ stable
136942
137221
  security definer
136943
137222
  set search_path = ''
136944
137223
  as $$
136945
- select ${SERVICE} or better_supabase.can_assign_as(auth.uid(), can_assign.tenant, can_assign.role)
137224
+ select ${SERVICE} or (${ROLE_GATE} and better_supabase.can_assign_as(auth.uid(), can_assign.tenant, can_assign.role))
136946
137225
  $$;
136947
137226
  ${platformCanAssign(ctx)}
136948
137227
 
@@ -137223,7 +137502,7 @@ stable
137223
137502
  security definer
137224
137503
  set search_path = ''
137225
137504
  as $$
137226
- select ${SERVICE} or coalesce((${providerCanAssign(ctx, layout)}), false)
137505
+ select ${SERVICE} or (${ROLE_GATE} and coalesce((${providerCanAssign(ctx, layout)}), false))
137227
137506
  $$;`;
137228
137507
  }
137229
137508
  function customFunctions(ctx) {
@@ -137312,11 +137591,11 @@ stable
137312
137591
  security definer
137313
137592
  set search_path = ''
137314
137593
  as $$
137315
- select ${SERVICE} or coalesce((${fill(functions.canAssign, {
137594
+ select ${SERVICE} or (${ROLE_GATE} and coalesce((${fill(functions.canAssign, {
137316
137595
  tenant: "can_assign.tenant",
137317
137596
  role: "can_assign.role",
137318
137597
  roles: "array[can_assign.role]::text[]"
137319
- })}), false)
137598
+ })}), false))
137320
137599
  $$;
137321
137600
 
137322
137601
  create or replace function better_supabase.permission_claims(user_id uuid)
@@ -137423,6 +137702,9 @@ ${[
137423
137702
  "permission_matches(text, text)",
137424
137703
  "scope_permissions(text)",
137425
137704
  "cap_allows(text)",
137705
+ "interactive_session()",
137706
+ "interactive_only(text)",
137707
+ "interactive_only_role(text)",
137426
137708
  "operation_permission(text)",
137427
137709
  `can(text, ${id}, text)`,
137428
137710
  "tenant_ids_with(text)",
@@ -140457,6 +140739,25 @@ end;
140457
140739
  $$;
140458
140740
  ${userGrant(`${fn("purchase_invoice_approval_status")}(uuid)`)}
140459
140741
 
140742
+ -- The approval of many purchase invoices in one read, keyed by invoice id. An
140743
+ -- invoice the caller cannot read has no key.
140744
+ create or replace function ${fn("purchase_invoice_approval_statuses")}(invoice_ids uuid[])
140745
+ returns jsonb
140746
+ language plpgsql
140747
+ stable
140748
+ security definer
140749
+ set search_path = ''
140750
+ as $$
140751
+ begin
140752
+ return (
140753
+ select coalesce(jsonb_object_agg(x.${i("id")}, ${fn("invoice_approval_state")}(x.${i("id")})), '{}'::jsonb)
140754
+ from ${t("invoices")} x
140755
+ where x.${i("id")} = any (purchase_invoice_approval_statuses.invoice_ids) and ${h.can("x", n.read)}
140756
+ );
140757
+ end;
140758
+ $$;
140759
+ ${userGrant(`${fn("purchase_invoice_approval_statuses")}(uuid[])`)}
140760
+
140460
140761
  -- Approves a purchase bill at every pending level the caller is the approver
140461
140762
  -- of; the service role approves the lowest pending level for its approver.
140462
140763
  -- Needs invoices.approve and an open bill. Returns the bill with its approval.
@@ -140538,6 +140839,11 @@ function approvalContract(ctx) {
140538
140839
  args: ["uuid"],
140539
140840
  returns: "jsonb"
140540
140841
  },
140842
+ {
140843
+ name: "purchase_invoice_approval_statuses",
140844
+ args: ["uuid[]"],
140845
+ returns: "jsonb"
140846
+ },
140541
140847
  {
140542
140848
  name: "approve_purchase_invoice",
140543
140849
  args: ["uuid", "text"],
@@ -157417,7 +157723,7 @@ ${lockModuleTable(ctx, "medications", { read: true })}
157417
157723
  create table if not exists ${orders} (
157418
157724
  ${o("id")} uuid primary key default gen_random_uuid(),
157419
157725
  ${o("tenant")} ${ctx.idType} not null,
157420
- -- The record the order is for, a type in config.subjects.
157726
+ -- The record the order is for, a type in config.recordTypes.
157421
157727
  ${o("subjectType")} text not null,
157422
157728
  ${o("subjectId")} text not null,
157423
157729
  ${o("medication")} uuid not null,
@@ -160945,20 +161251,20 @@ function messagesJson(q) {
160945
161251
  const at = ctx.of("attachments");
160946
161252
  const a = (column) => at.col("attachments", column);
160947
161253
  return `,
160948
- f as (
161254
+ f as materialized (
160949
161255
  select coalesce(jsonb_object_agg(g.id, g.files), '{}'::jsonb) as files
160950
161256
  from (
160951
161257
  select a.${a("subjectId")} as id, jsonb_agg(jsonb_build_object('id', a.${a("id")}, 'name', a.${a("name")}, 'mimeType', a.${a("mimeType")}, 'size', a.${a("size")}, 'status', a.${a("status")}) order by a.${a("createdAt")}, a.${a("id")}) as files
160952
161258
  from ${at.table("attachments")} a
160953
161259
  where a.${a("subjectType")} = ${message}
160954
- and a.${a("subjectId")} = any (array(select x::text from unnest(messaging_messages_json.ids) x))
161260
+ and a.${a("subjectId")} = any (array(select x.${ms("id")}::text from page_rows x))
160955
161261
  and a.${a("status")} <> 'infected'
160956
161262
  group by a.${a("subjectId")}
160957
161263
  ) g
160958
161264
  )`;
160959
161265
  })() : "";
160960
161266
  const reactions = ctx.installed("reactions") ? `,
160961
- r as (
161267
+ r as materialized (
160962
161268
  select coalesce(jsonb_object_agg(g.tenant, ${ctx.of("reactions").fn("reaction_summary")}(g.tenant, ${message}, g.ids)), '{}'::jsonb) as reactions
160963
161269
  from (
160964
161270
  select m.${ms("tenant")} as tenant, array_agg(m.${ms("id")}::text) as ids from page_rows m group by m.${ms("tenant")}
@@ -160976,10 +161282,38 @@ function messagesJson(q) {
160976
161282
  ...files ? ["f"] : [],
160977
161283
  ...reactions ? ["r"] : []
160978
161284
  ].join(", ");
161285
+ const cv = q.cols("conversations");
161286
+ const select = (rows, ids) => ` with ${rows}${authors ? `,\n a as materialized (select ${authors.call(ids)} as authors)` : ""}${files}${reactions}
161287
+ select coalesce(jsonb_agg(${json} order by coalesce(x.${ms("sentAt")}, ${ctx.has("messages", "scheduledFor") ? `x.${ms("scheduledFor")}, ` : ""}x.${ms("createdAt")}), x.${ms("id")}), '[]'::jsonb)
161288
+ from ${from}`;
160979
161289
  return `${authors?.sql ?? ""}
160980
161290
 
161291
+ -- The messages of ids the caller may read, as their owner: each distinct
161292
+ -- conversation of ids is checked once, so a read never weighs every
161293
+ -- conversation the caller can see. A sent message shows to the
161294
+ -- conversation's readers, an unsent one to its author.
161295
+ create or replace function ${fn("messaging_message_rows")}(ids uuid[])
161296
+ returns setof ${t("messages")}
161297
+ language sql
161298
+ stable
161299
+ security definer
161300
+ set search_path = ''
161301
+ as $$
161302
+ select m.* from ${t("messages")} m
161303
+ where m.${ms("id")} = any (messaging_message_rows.ids)
161304
+ and m.${ms("conversation")} = any (array(
161305
+ select c.${cv("id")} from ${t("conversations")} c
161306
+ where c.${cv("id")} = any (array(select distinct v.${ms("conversation")} from ${t("messages")} v where v.${ms("id")} = any (messaging_message_rows.ids)))
161307
+ and (${q.service} or ${conversationReadable(q, "c")})
161308
+ ))
161309
+ and (${q.service} or ((m.${ms("sentAt")} is not null or m.${ms("author")} = (select auth.uid()))${noteReadable(q, "m")}))
161310
+ $$;
161311
+ ${userGrant(`${fn("messaging_message_rows")}(uuid[])`)}
161312
+
160981
161313
  -- The messages of ids the caller may read, oldest first, each with its
160982
- -- author, files and reactions when those modules are installed.
161314
+ -- author, files and reactions when those modules are installed. The rows
161315
+ -- come from messaging_message_rows, and the conversations they belong to
161316
+ -- are read once more under the caller's policies.
160983
161317
  create or replace function ${fn("messaging_messages_json")}(ids uuid[])
160984
161318
  returns jsonb
160985
161319
  language sql
@@ -160987,13 +161321,35 @@ stable
160987
161321
  security invoker
160988
161322
  set search_path = ''
160989
161323
  as $$
160990
- with page_rows as (
160991
- select m.* from ${t("messages")} m where m.${ms("id")} = any (messaging_messages_json.ids)
160992
- )${authors ? `,\n a as (select ${authors.call("messaging_messages_json.ids")} as authors)` : ""}${files}${reactions}
160993
- select coalesce(jsonb_agg(${json} order by coalesce(x.${ms("sentAt")}, ${ctx.has("messages", "scheduledFor") ? `x.${ms("scheduledFor")}, ` : ""}x.${ms("createdAt")}), x.${ms("id")}), '[]'::jsonb)
160994
- from ${from}
161324
+ ${select(`checked as materialized (
161325
+ select m.* from ${fn("messaging_message_rows")}(messaging_messages_json.ids) m
161326
+ ),
161327
+ page_rows as (
161328
+ select k.* from checked k
161329
+ where k.${ms("conversation")} = any (array(
161330
+ select c.${cv("id")} from ${t("conversations")} c
161331
+ where c.${cv("id")} = any (array(select distinct v.${ms("conversation")} from checked v))
161332
+ ))
161333
+ )`, "messaging_messages_json.ids")}
161334
+ $$;
161335
+ ${userGrant(`${fn("messaging_messages_json")}(uuid[])`)}
161336
+
161337
+ -- messaging_messages_json without any access check, for a security definer
161338
+ -- function that has already checked the caller reads every conversation of
161339
+ -- ids. Never grant it to anon or authenticated: it returns any message,
161340
+ -- sent or not, with its files and reactions.
161341
+ create or replace function ${fn("messaging_messages_json_unchecked")}(ids uuid[])
161342
+ returns jsonb
161343
+ language sql
161344
+ stable
161345
+ security definer
161346
+ set search_path = ''
161347
+ as $$
161348
+ ${select(`page_rows as (
161349
+ select m.* from ${t("messages")} m where m.${ms("id")} = any (messaging_messages_json_unchecked.ids)
161350
+ )`, "messaging_messages_json_unchecked.ids")}
160995
161351
  $$;
160996
- ${userGrant(`${fn("messaging_messages_json")}(uuid[])`)}`;
161352
+ ${serviceGrant(`${fn("messaging_messages_json_unchecked")}(uuid[])`)}`;
160997
161353
  }
160998
161354
  /**
160999
161355
  * The service-role notifications and the event of a message once it is sent:
@@ -161288,11 +161644,7 @@ as $$
161288
161644
  select case when not coalesce(${ctx.of("subjects").fn("can_subject")}(list_record_mentions.subject_type, list_record_mentions.subject_id, 'read'), false)
161289
161645
  then '[]'::jsonb
161290
161646
  else coalesce((
161291
- select jsonb_agg(jsonb_build_object(
161292
- 'message', ${fn("messaging_messages_json")}(array[p.message]) -> 0,
161293
- 'conversation', jsonb_build_object('id', c.${cv("id")}, 'kind', c.${cv("kind")}, 'title', c.${cv("title")}, 'subject_type', c.${cv("subjectType")}, 'subject_id', c.${cv("subjectId")})
161294
- ) order by p.created_at desc, p.message desc)
161295
- from (
161647
+ with p as materialized (
161296
161648
  select x.${rm("message")} as message, x.${rm("conversation")} as conversation, x.${rm("createdAt")} as created_at
161297
161649
  from ${t("recordMentions")} x
161298
161650
  where x.${rm("subjectType")} = list_record_mentions.subject_type and x.${rm("subjectId")} = list_record_mentions.subject_id
@@ -161300,8 +161652,17 @@ as $$
161300
161652
  or (x.${rm("createdAt")}, x.${rm("message")}) < (list_record_mentions.before, coalesce(list_record_mentions.before_id, ${MAX_UUID})))
161301
161653
  order by x.${rm("createdAt")} desc, x.${rm("message")} desc
161302
161654
  limit ${pageSize("list_record_mentions.max_rows", 20, 100)}
161303
- ) p
161655
+ ),
161656
+ j as materialized (
161657
+ select e.row from jsonb_array_elements(${fn("messaging_messages_json")}(array(select p.message from p))) e(row)
161658
+ )
161659
+ select jsonb_agg(jsonb_build_object(
161660
+ 'message', j.row,
161661
+ 'conversation', jsonb_build_object('id', c.${cv("id")}, 'kind', c.${cv("kind")}, 'title', c.${cv("title")}, 'subject_type', c.${cv("subjectType")}, 'subject_id', c.${cv("subjectId")})
161662
+ ) order by p.created_at desc, p.message desc)
161663
+ from p
161304
161664
  join ${t("conversations")} c on c.${cv("id")} = p.conversation
161665
+ left join j on (j.row ->> ${sqlString(ms("id").replaceAll("\"", ""))})::uuid = p.message
161305
161666
  ), '[]'::jsonb)
161306
161667
  end
161307
161668
  $$;
@@ -162043,6 +162404,8 @@ const MESSAGING = {
162043
162404
  "is_conversation_member",
162044
162405
  "conversation_topic_allowed",
162045
162406
  "messaging_messages_json",
162407
+ "messaging_message_rows",
162408
+ "messaging_messages_json_unchecked",
162046
162409
  "message_authors",
162047
162410
  "parse_mentions",
162048
162411
  "index_record_mentions"
@@ -170500,8 +170863,8 @@ function optionBindings(ctx) {
170500
170863
  }, ctx.naming);
170501
170864
  return Object.entries(raw).flatMap(([type, fields]) => {
170502
170865
  const subject = registry.find((item) => item.type === type);
170503
- if (subject === void 0) throw new TypeError(`blocks.${ctx.instance}.on.${type}: register "${type}" in config.subjects first`);
170504
- if (subject.tenant === void 0) throw new TypeError(`blocks.${ctx.instance}.on.${type}: config.subjects.${type} needs a tenant column`);
170866
+ if (subject === void 0) throw new TypeError(`blocks.${ctx.instance}.on.${type}: register "${type}" in config.recordTypes first`);
170867
+ if (subject.tenant === void 0) throw new TypeError(`blocks.${ctx.instance}.on.${type}: config.recordTypes.${type} needs a tenant column`);
170505
170868
  return Object.entries(fields).map(([field, entry]) => {
170506
170869
  const where = `blocks.${ctx.instance}.on.${type}.${field}`;
170507
170870
  if (!FIELD$1.test(field) || !isRecord$1(entry)) throw new TypeError(`${where} must be an object under a field name`);
@@ -172625,7 +172988,7 @@ function dropShipFunctions(ctx, names) {
172625
172988
  return `
172626
172989
  -- A draft purchase order for an order's lines, shipped by the supplier
172627
172990
  -- straight to the order's shipping address (drop ship): the supplier is a
172628
- -- config.subjects record (a contacts company by default), the location the
172991
+ -- config.recordTypes record (a contacts company by default), the location the
172629
172992
  -- one the order's lines were reserved at or the first active one, the unit
172630
172993
  -- cost the variant's average cost in the order's currency (0 without one;
172631
172994
  -- edit the draft before placing it). Needs inventory.purchase.
@@ -179252,12 +179615,14 @@ $$;
179252
179615
 
179253
179616
  create or replace function tests.age_import_run(run uuid, age interval)
179254
179617
  returns void
179255
- language sql
179618
+ language plpgsql
179256
179619
  set search_path = ''
179257
179620
  as $$
179621
+ begin
179258
179622
  update better_supabase.import_runs
179259
179623
  set lease_expires_at = now() - age, heartbeat_at = now() - age
179260
- where id = run
179624
+ where id = run;
179625
+ end;
179261
179626
  $$;
179262
179627
 
179263
179628
  -- Moves the stored import stamp into the past so a current subject looks edited.
@@ -179433,8 +179798,8 @@ function pipelineBindings(ctx) {
179433
179798
  return Object.entries(raw).map(([type, entry]) => {
179434
179799
  const where = `blocks.${ctx.instance}.on.${type}`;
179435
179800
  const subject = registry.find((item) => item.type === type);
179436
- if (subject === void 0) throw new TypeError(`${where}: register "${type}" in config.subjects first`);
179437
- if (subject.tenant === void 0) throw new TypeError(`${where}: config.subjects.${type} needs a tenant column`);
179801
+ if (subject === void 0) throw new TypeError(`${where}: register "${type}" in config.recordTypes first`);
179802
+ if (subject.tenant === void 0) throw new TypeError(`${where}: config.recordTypes.${type} needs a tenant column`);
179438
179803
  if (!isRecord$1(entry)) throw new TypeError(`${where} must be an object`);
179439
179804
  const categories = categoriesOf(where, entry["categories"]);
179440
179805
  const optional = (key) => columnOf$1(`${where}.${key}`, entry[key]);
@@ -188032,7 +188397,7 @@ function build$41(ctx) {
188032
188397
  if (ctx.mode === "custom") return "";
188033
188398
  const subjects = ranked(ctx);
188034
188399
  const fn = (name) => ctx.fn(name);
188035
- const unknown = fail("RANK_SUBJECT_UNKNOWN", "this subject type has no rank column in config.subjects", "22023");
188400
+ const unknown = fail("RANK_SUBJECT_UNKNOWN", "this subject type has no rank column in config.recordTypes", "22023");
188036
188401
  const invalid = (arg) => `if ${arg} is not null and ${arg} !~ '^[0-9A-Za-z]*[1-9A-Za-z]$' then
188037
188402
  ${fail("RANK_KEY_INVALID", "not a rank key", "22023")}
188038
188403
  end if;`;
@@ -188199,7 +188564,7 @@ const RANK = {
188199
188564
  name: "rank",
188200
188565
  scopes: ["tenant"],
188201
188566
  title: "Rank",
188202
- description: "Fractional rank keys: rank_between, move() for every config.subjects entry with a rank column (through the caller's policies and any state-machine trigger), and a rebalance job.",
188567
+ description: "Fractional rank keys: rank_between, move() for every config.recordTypes entry with a rank column (through the caller's policies and any state-machine trigger), and a rebalance job.",
188203
188568
  requires: ["permissions", "subjects"],
188204
188569
  integrates: ["queue"],
188205
188570
  target: "schema",
@@ -193802,7 +194167,7 @@ ${lockTable(sql.lines, { read: true })}
193802
194167
  ${readPolicy("lines", l("tenant"))}
193803
194168
 
193804
194169
  -- A supplier invited to quote. supplier_type and supplier_id name a contacts
193805
- -- party (or another config.subjects record without the contacts block).
194170
+ -- party (or another config.recordTypes record without the contacts block).
193806
194171
  create table if not exists ${sql.suppliers} (
193807
194172
  ${s("id")} uuid primary key default gen_random_uuid(),
193808
194173
  ${s("tenant")} ${ctx.idType} not null,
@@ -197527,7 +197892,7 @@ as $$
197527
197892
  $$;
197528
197893
  ${userGrant(`${fn("search_normalize")}(text)`)}
197529
197894
 
197530
- -- Reads one registered subject row (config.subjects.<type>.search) into the
197895
+ -- Reads one registered subject row (config.recordTypes.<type>.search) into the
197531
197896
  -- index, or drops it when the row is gone or soft-deleted (deletedAt).
197532
197897
  create or replace function ${fn("search_refresh")}(subject_type text, subject_id text)
197533
197898
  returns boolean
@@ -197548,7 +197913,7 @@ begin
197548
197913
  case search_refresh.subject_type
197549
197914
  ${cases}
197550
197915
  else
197551
- ${fail("SEARCH_SUBJECT_UNKNOWN", "this subject type has no search entry in config.subjects", "22023")}
197916
+ ${fail("SEARCH_SUBJECT_UNKNOWN", "this subject type has no search entry in config.recordTypes", "22023")}
197552
197917
  end case;
197553
197918
  if not v_found then
197554
197919
  delete from ${docs}
@@ -197774,7 +198139,7 @@ const SEARCH = {
197774
198139
  name: "search",
197775
198140
  scopes: ["tenant"],
197776
198141
  title: "Search",
197777
- description: "A search_documents index kept up by triggers from each config.subjects search entry, with search(q) as the caller (websearch, trigram prefixes, can_subject, hybrid with embeddings), and recents and favorites from the share-links user state.",
198142
+ description: "A search_documents index kept up by triggers from each config.recordTypes search entry, with search(q) as the caller (websearch, trigram prefixes, can_subject, hybrid with embeddings), and recents and favorites from the share-links user state.",
197778
198143
  requires: [
197779
198144
  "memberships",
197780
198145
  "permissions",
@@ -198644,7 +199009,7 @@ function matchingIds(ctx, n) {
198644
199009
  limit ${String(n.maxMembers + 1)}
198645
199010
  ) x;`;
198646
199011
  };
198647
- const unknown = fail("SEGMENT_SUBJECT_UNKNOWN", "The segment's subject type is not registered in config.subjects", "22023");
199012
+ const unknown = fail("SEGMENT_SUBJECT_UNKNOWN", "The segment's subject type is not registered in config.recordTypes", "22023");
198648
199013
  if (n.subjects.length === 0) return unknown;
198649
199014
  return `${n.subjects.map(branch).join("\n els")}
198650
199015
  else
@@ -198721,7 +199086,7 @@ begin
198721
199086
  end if;
198722
199087
  v_type := coalesce(v_old.${s("subjectType")}, segment ->> 'subjectType');
198723
199088
  if v_type is null or v_type not in ${knownList} then
198724
- ${fail("SEGMENT_SUBJECT_UNKNOWN", "subjectType must be a type in config.subjects", "22023")}
199089
+ ${fail("SEGMENT_SUBJECT_UNKNOWN", "subjectType must be a type in config.recordTypes", "22023")}
198725
199090
  end if;
198726
199091
  v_name := coalesce(nullif(trim(segment ->> 'name'), ''), v_old.${s("name")});
198727
199092
  if v_name is null or length(v_name) > 200 then
@@ -200901,11 +201266,12 @@ function hasVersionSource(ctx, layout) {
200901
201266
  /**
200902
201267
  * The `'subject'` pair of a wrapper. With `subjectForTenant` a call that names
200903
201268
  * a tenant gets the subject restricted to it, and a call without one the whole
200904
- * subject.
201269
+ * subject. `subject_tenant` names the tenant the subject is restricted to, so a
201270
+ * seed that a cache keys by user and version says what it covers.
200905
201271
  */
200906
201272
  function subjectSql(subject, subjectForTenant) {
200907
201273
  if (!subject) return "";
200908
- return subjectForTenant === void 0 ? `,\n 'subject', to_jsonb(${subject}())` : `,\n 'subject', case when nullif(args ->> 'tenant', '') is null then to_jsonb(${subject}()) else to_jsonb(${subjectForTenant}) end`;
201274
+ return subjectForTenant === void 0 ? `,\n 'subject', to_jsonb(${subject}())` : `,\n 'subject', case when nullif(args ->> 'tenant', '') is null then to_jsonb(${subject}()) else to_jsonb(${subjectForTenant}) end,\n 'subject_tenant', nullif(args ->> 'tenant', '')`;
200909
201275
  }
200910
201276
  /**
200911
201277
  * One wrapper per `bootstrap` entry: the session check, the authorization
@@ -206659,7 +207025,7 @@ function bindings(ctx) {
206659
207025
  return Object.entries(onSettings(ctx)).map(([type, entry]) => {
206660
207026
  const where = `blocks.${ctx.instance}.on.${type}`;
206661
207027
  const subject = registry.find((item) => item.type === type);
206662
- if (subject?.tenant === void 0) throw new TypeError(`${where}: register "${type}" with a tenant column in config.subjects first`);
207028
+ if (subject?.tenant === void 0) throw new TypeError(`${where}: register "${type}" with a tenant column in config.recordTypes first`);
206663
207029
  if (!isRecord$1(entry)) throw new TypeError(`${where} must be an object`);
206664
207030
  const status = entry["status"];
206665
207031
  const priority = entry["priority"];
@@ -209054,13 +209420,13 @@ function machines(ctx) {
209054
209420
  return [...configured, ...contributed];
209055
209421
  }
209056
209422
  /**
209057
- * The table keys of `config.subjects.<name>`, used when the machine names no
209423
+ * The table keys of `config.recordTypes.<name>`, used when the machine names no
209058
209424
  * table.
209059
209425
  */
209060
209426
  function registered(name, registry, where, naming) {
209061
209427
  const entry = Object.hasOwn(registry, name) ? registry[name] : void 0;
209062
209428
  if (entry === void 0) return {};
209063
- if (entry.tenant === false) throw new TypeError(`${where}: config.subjects.${name} has no tenant column, which a machine needs`);
209429
+ if (entry.tenant === false) throw new TypeError(`${where}: config.recordTypes.${name} has no tenant column, which a machine needs`);
209064
209430
  return {
209065
209431
  table: entry.table,
209066
209432
  ...entry.id !== void 0 && { id: entry.id },
@@ -209115,7 +209481,7 @@ function machine(name, entry, registry, naming) {
209115
209481
  const order = statusList(record["order"], `${where}.order`);
209116
209482
  for (const status of order) if (!statuses.has(status)) throw new TypeError(`${where}.order: ${status} is not a status`);
209117
209483
  const tenantColumn = typeof record["tenant"] === "string" ? record["tenant"] : tenantColumnOf(table, registry, naming);
209118
- if (tenantColumn === void 0) throw new TypeError(`${where}: ${table} has no tenant column in config.subjects, which a machine needs`);
209484
+ if (tenantColumn === void 0) throw new TypeError(`${where}: ${table} has no tenant column in config.recordTypes, which a machine needs`);
209119
209485
  const history = historyOf(record["history"], where, tenantColumn);
209120
209486
  return {
209121
209487
  name,
@@ -210079,7 +210445,7 @@ const STATE_MACHINE = {
210079
210445
  name: "state-machine",
210080
210446
  scopes: ["tenant"],
210081
210447
  title: "State machine",
210082
- description: "Allowed status transitions as the caller, a history row and a status.changed event. A machine can also write a stages timeline and keep a lifecycle row (pause, flags, pinned version). Each machine is a subject table named in options.machines, or a config.subjects type.",
210448
+ description: "Allowed status transitions as the caller, a history row and a status.changed event. A machine can also write a stages timeline and keep a lifecycle row (pause, flags, pinned version). Each machine is a subject table named in options.machines, or a config.recordTypes type.",
210083
210449
  requires: ["memberships", "permissions"],
210084
210450
  integrates: [
210085
210451
  "outbox",
@@ -235307,6 +235673,8 @@ const DESCRIPTION = "Event triggers and triggers on auth tables. They belong to
235307
235673
  * comment lines just above it.
235308
235674
  */
235309
235675
  const UNSCOPED = /(?:^--[^\n]*\n)*(?:^drop event trigger [^;]*;[ \t]*\n)*^create (?:event trigger [^;]*|(?:or replace )?(?:constraint )?trigger [^;]*?\bon\s+"?auth"?\.[^;]*);[ \t]*\n?/gim;
235676
+ /** The `drop event trigger` lines a declarative file must not carry. */
235677
+ const DROP_EVENT_TRIGGER = /^drop event trigger [^;]*;[ \t]*\n/gim;
235310
235678
  /** `contents` without its unscoped statements, and those statements. */
235311
235679
  function takeUnscoped(contents) {
235312
235680
  const statements = [...contents.matchAll(UNSCOPED)].map((match) => match[0].trim());
@@ -235326,7 +235694,7 @@ function withUnscopedFile(files, layout) {
235326
235694
  const rest = files.map((file) => {
235327
235695
  if (file.kind !== "schema") return file;
235328
235696
  const taken = takeUnscoped(file.contents);
235329
- found.push(...taken.statements);
235697
+ found.push(...taken.statements.map((statement) => statement.replaceAll(DROP_EVENT_TRIGGER, "").trim()));
235330
235698
  return taken.statements.length === 0 ? file : {
235331
235699
  ...file,
235332
235700
  contents: taken.rest
@@ -235347,7 +235715,7 @@ function withUnscopedFile(files, layout) {
235347
235715
  module: UNSCOPED_MODULE,
235348
235716
  kind: "schema",
235349
235717
  path: `${dir}/${prefix}_999_${UNSCOPED_MODULE}.sql`,
235350
- contents: `${header}\n\n${found.join("\n\n")}\n`
235718
+ contents: `${header}\n\n${[...new Set(found)].join("\n\n")}\n`
235351
235719
  }];
235352
235720
  }
235353
235721
  // src/sql/policy-names.ts
@@ -236657,6 +237025,7 @@ function moduleLayout(config, testsDir = config.sql.testsDir, readSets = [], ent
236657
237025
  function: config.authorization.versions.function
236658
237026
  } } : {},
236659
237027
  ...config.authorization?.delegation?.scopes ? { delegationScopes: config.authorization.delegation.scopes } : {},
237028
+ ...config.authorization?.delegation?.interactiveOnly ? { delegationInteractiveOnly: config.authorization.delegation.interactiveOnly } : {},
236660
237029
  seedDefaults: config.seed.defaults,
236661
237030
  dir: config.sql.dir,
236662
237031
  prefix: config.sql.prefix,