better-supabase 0.59.0 → 0.60.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 (512) hide show
  1. package/dist/{account-parts-DxSyD4yi.d.ts → account-parts-D-cLYi0Y.d.ts} +1 -1
  2. package/dist/{adapter-base-BAjra5Eb.js → adapter-base-BHtxRoRg.js} +1 -1
  3. package/dist/{agents-CbsEgoLN.d.ts → agents-FJk0CNex.d.ts} +2 -2
  4. package/dist/{ai-schedules-BxBsTpji.d.ts → ai-schedules-wlL3DKqu.d.ts} +1 -1
  5. package/dist/ai-sdk/agents/index.d.ts +1 -1
  6. package/dist/ai-sdk/workflow/index.d.ts +1 -1
  7. package/dist/{api-wRlj_7so.d.ts → api-CSx2F4zg.d.ts} +1 -1
  8. package/dist/{api-DAJJ7N_0.js → api-Clu-XitC.js} +1 -1
  9. package/dist/{app-tables-DBmFqdFN.d.ts → app-tables-C_bRG0ek.d.ts} +1 -1
  10. package/dist/{approvals-Clg-7ghA.js → approvals-D7Xhpd52.js} +8 -6
  11. package/dist/{approvals-Bbxeiywy.d.ts → approvals-Dn_DM4Oi.d.ts} +6 -0
  12. package/dist/astro/index.d.ts +3 -3
  13. package/dist/astro/index.js +3 -3
  14. package/dist/{authorization-Dq47C4vf.d.ts → authorization-Cn_oEGoA.d.ts} +1 -1
  15. package/dist/better-result/index.d.ts +2 -2
  16. package/dist/{bind-Bx0H1vAc.d.ts → bind-Dopmkg_T.d.ts} +4 -4
  17. package/dist/{block-env-DUn5reXc.d.ts → block-env-4tgXDIAX.d.ts} +4 -4
  18. package/dist/{block-tables-BaLXCQha.d.ts → block-tables-KnVB7FH0.d.ts} +1 -1
  19. package/dist/blocks/access-requests/index.d.ts +1 -1
  20. package/dist/blocks/accounting/index.d.ts +1 -1
  21. package/dist/blocks/acknowledgements/index.d.ts +1 -1
  22. package/dist/blocks/activities/index.d.ts +2 -2
  23. package/dist/blocks/advisories/index.d.ts +1 -1
  24. package/dist/blocks/agent-checkout/index.d.ts +1 -1
  25. package/dist/blocks/agents/index.d.ts +1 -1
  26. package/dist/blocks/ai-cache/index.d.ts +1 -1
  27. package/dist/blocks/ai-chat/index.d.ts +1 -1
  28. package/dist/blocks/ai-evals/index.d.ts +1 -1
  29. package/dist/blocks/ai-files/index.d.ts +1 -1
  30. package/dist/blocks/ai-guardrails/index.d.ts +1 -1
  31. package/dist/blocks/ai-keys/index.d.ts +1 -1
  32. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  33. package/dist/blocks/announcements/index.d.ts +4 -4
  34. package/dist/blocks/api-keys/index.d.ts +1 -1
  35. package/dist/blocks/appraisals/index.d.ts +1 -1
  36. package/dist/blocks/approvals/index.d.ts +2 -2
  37. package/dist/blocks/approvals/index.js +2 -2
  38. package/dist/blocks/assets/index.d.ts +2 -2
  39. package/dist/blocks/assignment/index.d.ts +1 -1
  40. package/dist/blocks/attachments/index.d.ts +5 -5
  41. package/dist/blocks/audit/index.d.ts +2 -2
  42. package/dist/blocks/automations/index.d.ts +4 -4
  43. package/dist/blocks/banking/index.d.ts +1 -1
  44. package/dist/blocks/billable-time/index.d.ts +1 -1
  45. package/dist/blocks/billing/index.d.ts +3 -3
  46. package/dist/blocks/bookings/index.d.ts +2 -2
  47. package/dist/blocks/bulk-actions/index.d.ts +2 -2
  48. package/dist/blocks/calendar/index.d.ts +3 -3
  49. package/dist/blocks/care/index.d.ts +27 -27
  50. package/dist/blocks/care/index.js +1 -1
  51. package/dist/blocks/care-plans/index.d.ts +3 -3
  52. package/dist/blocks/cases/index.d.ts +3 -3
  53. package/dist/blocks/catalog/index.d.ts +2 -2
  54. package/dist/blocks/channels/index.d.ts +1 -1
  55. package/dist/blocks/clinical-decision-support/index.d.ts +1 -1
  56. package/dist/blocks/cms/index.d.ts +5 -5
  57. package/dist/blocks/cms/index.js +1 -1
  58. package/dist/blocks/collaboration/index.d.ts +6 -6
  59. package/dist/blocks/collections/index.d.ts +1 -1
  60. package/dist/blocks/comments/index.d.ts +2 -2
  61. package/dist/blocks/commerce/index.d.ts +5 -5
  62. package/dist/blocks/commissions/index.d.ts +1 -1
  63. package/dist/blocks/compliance/index.d.ts +1 -1
  64. package/dist/blocks/connectors/index.d.ts +1 -1
  65. package/dist/blocks/consents/index.d.ts +2 -2
  66. package/dist/blocks/contacts/index.d.ts +2 -2
  67. package/dist/blocks/content/index.d.ts +2 -2
  68. package/dist/blocks/contracts/index.d.ts +1 -1
  69. package/dist/blocks/courses/index.d.ts +2 -2
  70. package/dist/blocks/created-by/index.d.ts +2 -2
  71. package/dist/blocks/crm/index.d.ts +17 -17
  72. package/dist/blocks/crm/index.js +2 -2
  73. package/dist/blocks/custom-fields/index.d.ts +1 -1
  74. package/dist/blocks/dam/index.d.ts +2 -2
  75. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  76. package/dist/blocks/deadlines/index.d.ts +1 -1
  77. package/dist/blocks/deals/index.d.ts +1 -1
  78. package/dist/blocks/dispatch/index.d.ts +2 -2
  79. package/dist/blocks/document-templates/index.d.ts +2 -2
  80. package/dist/blocks/documents/index.d.ts +1 -1
  81. package/dist/blocks/domains/index.d.ts +1 -1
  82. package/dist/blocks/donations/index.d.ts +1 -1
  83. package/dist/blocks/drive/index.d.ts +5 -5
  84. package/dist/blocks/e-prescribing/index.d.ts +1 -1
  85. package/dist/blocks/employees/index.d.ts +1 -1
  86. package/dist/blocks/enrichment/index.d.ts +1 -1
  87. package/dist/blocks/enrollments/index.d.ts +2 -2
  88. package/dist/blocks/entitlements/index.d.ts +3 -3
  89. package/dist/blocks/events/index.d.ts +3 -3
  90. package/dist/blocks/expenses/index.d.ts +1 -1
  91. package/dist/blocks/field-history/index.d.ts +1 -1
  92. package/dist/blocks/filespace/index.d.ts +8 -8
  93. package/dist/blocks/finance/index.d.ts +5 -5
  94. package/dist/blocks/finance/index.js +1 -1
  95. package/dist/blocks/flags/index.d.ts +1 -1
  96. package/dist/blocks/forecasts/index.d.ts +1 -1
  97. package/dist/blocks/forms/index.d.ts +3 -3
  98. package/dist/blocks/funding/index.d.ts +2 -2
  99. package/dist/blocks/goals/index.d.ts +1 -1
  100. package/dist/blocks/governance/index.d.ts +4 -4
  101. package/dist/blocks/guests/index.d.ts +1 -1
  102. package/dist/blocks/hiring/index.d.ts +1 -1
  103. package/dist/blocks/identities/index.d.ts +1 -1
  104. package/dist/blocks/imports/index.d.ts +2 -2
  105. package/dist/blocks/inbox/index.d.ts +6 -6
  106. package/dist/blocks/incidents/index.d.ts +1 -1
  107. package/dist/blocks/index.d.ts +5 -5
  108. package/dist/blocks/index.js +2 -2
  109. package/dist/blocks/inspections/index.d.ts +2 -2
  110. package/dist/blocks/inventory/index.d.ts +1 -1
  111. package/dist/blocks/invoices/index.d.ts +2 -2
  112. package/dist/blocks/invoices/index.js +1 -1
  113. package/dist/blocks/knowledge/index.d.ts +1 -1
  114. package/dist/blocks/lead-scoring/index.d.ts +2 -2
  115. package/dist/blocks/learning/index.d.ts +3 -3
  116. package/dist/blocks/leases/index.d.ts +1 -1
  117. package/dist/blocks/leave/index.d.ts +1 -1
  118. package/dist/blocks/ledger/index.d.ts +1 -1
  119. package/dist/blocks/legal-entities/index.d.ts +2 -2
  120. package/dist/blocks/lims/index.d.ts +2 -2
  121. package/dist/blocks/mail-sync/index.d.ts +3 -3
  122. package/dist/blocks/maintenance/index.d.ts +2 -2
  123. package/dist/blocks/manufacturing/index.d.ts +2 -2
  124. package/dist/blocks/medications/index.d.ts +1 -1
  125. package/dist/blocks/meetings/index.d.ts +3 -3
  126. package/dist/blocks/memberships/index.d.ts +2 -2
  127. package/dist/blocks/memory/index.d.ts +1 -1
  128. package/dist/blocks/messaging/index.d.ts +5 -5
  129. package/dist/blocks/metrics/index.d.ts +1 -1
  130. package/dist/blocks/mfa/index.d.ts +2 -2
  131. package/dist/blocks/moderation/index.d.ts +2 -2
  132. package/dist/blocks/notifications/index.d.ts +5 -5
  133. package/dist/blocks/numbering/index.d.ts +1 -1
  134. package/dist/blocks/oauth-server/index.d.ts +1 -1
  135. package/dist/blocks/observations/index.d.ts +2 -2
  136. package/dist/blocks/onboarding/index.d.ts +2 -2
  137. package/dist/blocks/option-sets/index.d.ts +2 -2
  138. package/dist/blocks/orders/index.d.ts +1 -1
  139. package/dist/blocks/organizations/index.d.ts +2 -2
  140. package/dist/blocks/outbox/index.d.ts +1 -1
  141. package/dist/blocks/passes/index.d.ts +2 -2
  142. package/dist/blocks/payroll-export/index.d.ts +2 -2
  143. package/dist/blocks/people/index.d.ts +7 -7
  144. package/dist/blocks/periods/index.d.ts +1 -1
  145. package/dist/blocks/permissions/index.d.ts +3 -3
  146. package/dist/blocks/pipelines/index.d.ts +2 -2
  147. package/dist/blocks/posts/index.d.ts +2 -2
  148. package/dist/blocks/procurement/index.d.ts +5 -5
  149. package/dist/blocks/procurement/index.js +1 -1
  150. package/dist/blocks/profiles/index.d.ts +1 -1
  151. package/dist/blocks/projects/index.d.ts +7 -7
  152. package/dist/blocks/projects/index.js +2 -2
  153. package/dist/blocks/promotions/index.d.ts +1 -1
  154. package/dist/blocks/prompts/index.d.ts +1 -1
  155. package/dist/blocks/push/index.d.ts +2 -2
  156. package/dist/blocks/qualifications/index.d.ts +2 -2
  157. package/dist/blocks/queue/index.d.ts +2 -2
  158. package/dist/blocks/quotes/index.d.ts +1 -1
  159. package/dist/blocks/rank/index.d.ts +1 -1
  160. package/dist/blocks/reactions/index.d.ts +4 -4
  161. package/dist/blocks/recruiting/index.d.ts +4 -4
  162. package/dist/blocks/referrals/index.d.ts +1 -1
  163. package/dist/blocks/relations/index.d.ts +1 -1
  164. package/dist/blocks/reminders/index.d.ts +1 -1
  165. package/dist/blocks/reviews/index.d.ts +1 -1
  166. package/dist/blocks/rfqs/index.d.ts +2 -2
  167. package/dist/blocks/risks/index.d.ts +2 -2
  168. package/dist/blocks/saas/index.d.ts +12 -12
  169. package/dist/blocks/sales/index.d.ts +1 -1
  170. package/dist/blocks/sales/index.js +1 -1
  171. package/dist/blocks/saved-views/index.d.ts +3 -3
  172. package/dist/blocks/scheduling/index.d.ts +4 -4
  173. package/dist/blocks/scores/index.d.ts +2 -2
  174. package/dist/blocks/search/index.d.ts +3 -3
  175. package/dist/blocks/security-events/index.d.ts +1 -1
  176. package/dist/blocks/segments/index.d.ts +2 -2
  177. package/dist/blocks/sequences/index.d.ts +3 -3
  178. package/dist/blocks/service/index.d.ts +7 -7
  179. package/dist/blocks/service-accounts/index.d.ts +1 -1
  180. package/dist/blocks/sessions/index.d.ts +2 -2
  181. package/dist/blocks/settings/index.d.ts +2 -2
  182. package/dist/blocks/share-links/index.d.ts +1 -1
  183. package/dist/blocks/shifts/index.d.ts +2 -2
  184. package/dist/blocks/shipments/index.d.ts +1 -1
  185. package/dist/blocks/signatures/index.d.ts +2 -2
  186. package/dist/blocks/signing-keys/index.d.ts +1 -1
  187. package/dist/blocks/sla/index.d.ts +1 -1
  188. package/dist/blocks/sso/index.d.ts +1 -1
  189. package/dist/blocks/state-machine/index.d.ts +1 -1
  190. package/dist/blocks/subjects/index.d.ts +2 -2
  191. package/dist/blocks/support/index.d.ts +5 -5
  192. package/dist/blocks/tags/index.d.ts +2 -2
  193. package/dist/blocks/tasks/index.d.ts +2 -2
  194. package/dist/blocks/tax/index.d.ts +2 -2
  195. package/dist/blocks/teams/index.d.ts +1 -1
  196. package/dist/blocks/templates/index.d.ts +1 -1
  197. package/dist/blocks/tills/index.d.ts +1 -1
  198. package/dist/blocks/time-entries/index.d.ts +2 -2
  199. package/dist/blocks/timeline/index.d.ts +1 -1
  200. package/dist/blocks/trash/index.d.ts +1 -1
  201. package/dist/blocks/undo/index.d.ts +2 -2
  202. package/dist/blocks/updated-at/index.d.ts +2 -2
  203. package/dist/blocks/usage/index.d.ts +2 -2
  204. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  205. package/dist/blocks/versions/index.d.ts +1 -1
  206. package/dist/blocks/waitlist/index.d.ts +1 -1
  207. package/dist/blocks/warehouse/index.d.ts +1 -1
  208. package/dist/blocks/warranty/index.d.ts +1 -1
  209. package/dist/blocks/webhooks/index.d.ts +2 -2
  210. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  211. package/dist/blocks/workflows/index.d.ts +4 -4
  212. package/dist/{blocks-RVd7m590.d.ts → blocks-sDhFO8-h.d.ts} +4 -4
  213. package/dist/{build-Rz89mkdS.js → build-QM0GdQ2B.js} +1 -1
  214. package/dist/{cache-tags-BxpxsCtq.d.ts → cache-tags-FrJaMalu.d.ts} +1 -1
  215. package/dist/claims/index.d.ts +4 -4
  216. package/dist/{claims-source-BEVTXHQx.d.ts → claims-source-CeefCyGV.d.ts} +1 -1
  217. package/dist/cli/add-BBZULhs3.js +1 -0
  218. package/dist/cli/{add-CnCt2QoB.js → add-OllEkXon.js} +9 -9
  219. package/dist/cli/{add-BJNTq7Ti.js → add-djLR310z.js} +2 -2
  220. package/dist/cli/{app-table-files-CfB0_NuX.js → app-table-files-DnoDAkVJ.js} +3 -3
  221. package/dist/cli/{app-tables-oieRU_sP.js → app-tables-C4shCkBv.js} +2 -2
  222. package/dist/cli/{backfill-Cr5jgVi1.js → backfill-_spwSvnn.js} +1 -1
  223. package/dist/cli/bin.js +1 -1
  224. package/dist/cli/{blocks-B-ANsRnH.js → blocks-Cvs0nhC2.js} +1 -1
  225. package/dist/cli/{blocks-DLMVaOFG.js → blocks-DFkzCFQi.js} +1 -1
  226. package/dist/cli/{cache-Ba26VW2N.js → cache-B0JnXfiY.js} +1 -1
  227. package/dist/cli/{codemod-x1I7Mjr3.js → codemod-D2Lnca97.js} +5 -5
  228. package/dist/cli/{codemod-naming-CZhndoO7.js → codemod-naming-CHIeOTt5.js} +1 -1
  229. package/dist/cli/{column-renames-BEEDF6P6.js → column-renames-4OHEvCAj.js} +2 -2
  230. package/dist/cli/{content-mapper-z7CrnE1s.js → content-mapper-DAYxPQ18.js} +1 -1
  231. package/dist/cli/{dev-D9nn9Gzt.js → dev-Xw7pt3KG.js} +3 -3
  232. package/dist/cli/{doctor-DCorhlir.js → doctor-diSKQp-6.js} +238 -105
  233. package/dist/cli/{emit-qQdWBc9e.js → emit-CICey-Za.js} +2 -2
  234. package/dist/cli/{gen-Bf1ujcTm.js → gen-BVuNFeLB.js} +3 -3
  235. package/dist/cli/{gen-tasks-q9JJSJ6r.js → gen-tasks-C2vwKKTc.js} +9 -9
  236. package/dist/cli/index.d.ts +1 -1
  237. package/dist/cli/index.js +7 -7
  238. package/dist/cli/{init-DLLfL1uL.js → init-9BSoBkny.js} +8 -8
  239. package/dist/cli/{live-D4giSEyd.js → live-Ce8vdcCn.js} +2 -2
  240. package/dist/cli/{mcp-DwjeMbmV.js → mcp-UW-gEnP_.js} +2 -2
  241. package/dist/cli/{memo-backend-DPGMyJvH.js → memo-backend-BMdfsihK.js} +1 -1
  242. package/dist/cli/{metadata-Cft3CW1M.js → metadata-DqrbS0sS.js} +4 -4
  243. package/dist/cli/{migrate-Ci_UUuPv.js → migrate-Cn8L_0co.js} +1 -1
  244. package/dist/cli/{migration-safety-D3raBuJx.js → migration-safety-C1Ysrthi.js} +1 -1
  245. package/dist/cli/{module-migration-DZtxNO8A.js → module-migration-DXI95fqs.js} +1 -1
  246. package/dist/cli/{partition-DWJ6icQ5.js → partition-CJCrIueu.js} +1 -1
  247. package/dist/cli/{powersync-BAyDVR-N.js → powersync-CB-7AksZ.js} +3 -3
  248. package/dist/cli/powersync-JTdU1Xpy.js +1 -0
  249. package/dist/cli/{print-BSy5c62C.js → print-AVVgXsLG.js} +2 -2
  250. package/dist/cli/{providers-BbFKOale.js → providers-B3FLmlud.js} +1 -1
  251. package/dist/cli/{prune-workflows-VY7C9vhb.js → prune-workflows-CrLDmFf1.js} +1 -1
  252. package/dist/cli/{remove-CcBoTjEO.js → remove-00SZWfyi.js} +6 -6
  253. package/dist/cli/{render-CIrcdge6.js → render-3J7sk_CL.js} +4 -4
  254. package/dist/cli/{render-cache-bbL2UdJ6.js → render-cache-P4gQeivH.js} +1 -1
  255. package/dist/cli/round-trips-BHfeIu6I.js +238 -0
  256. package/dist/cli/{run-qCtE--0z.js → run-CByEIEng.js} +30 -30
  257. package/dist/cli/{run-D_p_WkPh.js → run-D_z9ULO7.js} +7 -7
  258. package/dist/cli/{shared-CkqZm0Bz.js → shared-d021xfdn.js} +1 -1
  259. package/dist/cli/{source-io7b1UpH.js → source-DdqeWoO4.js} +1 -1
  260. package/dist/cli/{spec-djAAvGKU.js → spec-ClfqDbVv.js} +2 -2
  261. package/dist/cli/{spec-QGOfTJvS.js → spec-Diudl7hC.js} +1 -1
  262. package/dist/cli/{sql-layout-1ASqdR4g.js → sql-layout-Bl3iOXMS.js} +3 -3
  263. package/dist/cli/{squash-DEmB47YZ.js → squash-C07y7CsQ.js} +1 -1
  264. package/dist/cli/{sync-CUcxtnwa.js → sync-Cw0ke-3h.js} +4 -4
  265. package/dist/cli/{upgrade-DV9mKpAp.js → upgrade-niwEovfl.js} +5 -5
  266. package/dist/cli/{upgrade-FWW6hKCv.js → upgrade-oc6s5Xoe.js} +5 -5
  267. package/dist/cli/{version-CSdXYnhG.js → version-Bd3kCDzL.js} +1 -1
  268. package/dist/client/index.d.ts +5 -5
  269. package/dist/client/index.js +1 -1
  270. package/dist/client/native/index.d.ts +5 -5
  271. package/dist/client/native/index.js +2 -2
  272. package/dist/{codec-Cjquuv8M.js → codec-BI1mq95W.js} +1 -1
  273. package/dist/{composite-CL4zDLjs.d.ts → composite-BVEOyec_.d.ts} +3 -3
  274. package/dist/{composite-WUO6K2Hu.js → composite-Tsm5QFS2.js} +1 -1
  275. package/dist/{composite-reads-BJeDe1yV.js → composite-reads-BJJBI4tL.js} +1 -1
  276. package/dist/{composite-reads-B9psRGqQ.d.ts → composite-reads-DvN7EgDO.d.ts} +1 -1
  277. package/dist/config/index.d.ts +4 -4
  278. package/dist/config/index.js +2 -2
  279. package/dist/{config-C3yry9U5.js → config-cisS43w5.js} +1 -1
  280. package/dist/{context-DMTfze4z.d.ts → context-C_Rx1QaW.d.ts} +3 -3
  281. package/dist/contract/index.d.ts +4 -4
  282. package/dist/{controller-l9h4TtKg.d.ts → controller-D9N4NKbM.d.ts} +1 -1
  283. package/dist/{conversion-D70FELty.d.ts → conversion-CruLbcu8.d.ts} +1 -1
  284. package/dist/create/index.d.ts +4 -4
  285. package/dist/create/index.js +1 -1
  286. package/dist/create/lite/index.d.ts +3 -3
  287. package/dist/create/lite/index.js +3 -3
  288. package/dist/{db-blocks-Db3LVXco.d.ts → db-blocks-DB8Ct8Eu.d.ts} +11 -2
  289. package/dist/{define-block-D-Z8xB6y.d.ts → define-block-Cd7dm2o6.d.ts} +2 -2
  290. package/dist/{define-runtime-Dv8OYnKW.js → define-runtime-Ca5NN0gu.js} +2 -2
  291. package/dist/{define-runtime-full-C4eTtJAx.js → define-runtime-full-DeuaXsV7.js} +3 -3
  292. package/dist/{delete-account-BHXzIUIq.d.ts → delete-account-DwGFiIYv.d.ts} +1 -1
  293. package/dist/{drive-DrD94tWF.d.ts → drive-C6thwExa.d.ts} +2 -2
  294. package/dist/e-invoicing/index.d.ts +1 -1
  295. package/dist/edge/index.d.ts +5 -5
  296. package/dist/edge/index.js +4 -4
  297. package/dist/{entitlements-B6q7TIMP.d.ts → entitlements-CR5HRd3S.d.ts} +2 -2
  298. package/dist/eve/index.d.ts +1 -1
  299. package/dist/eve/index.js +1 -1
  300. package/dist/{executor-BmcRcw83.js → executor-Bot0tkvU.js} +2 -2
  301. package/dist/{executor-Dp4A_McY.d.ts → executor-CTuilcgE.d.ts} +2 -2
  302. package/dist/expo/index.d.ts +2 -2
  303. package/dist/expo/index.js +3 -3
  304. package/dist/{extract-D4QPFB_M.d.ts → extract-B2My7IhT.d.ts} +1 -1
  305. package/dist/{extras-C0cnpjDP.d.ts → extras-CKwPSpGL.d.ts} +1 -1
  306. package/dist/{field-errors-Br3wwgbu.d.ts → field-errors-CihTLojJ.d.ts} +6 -6
  307. package/dist/{former-permission-keys-BwJW5uc6.js → former-permission-keys-D8FbWktT.js} +2 -2
  308. package/dist/{framework-CbjS8M33.js → framework-BYZ8c9_g.js} +1 -1
  309. package/dist/{framework-BUzOnlJN.d.ts → framework-giXStk8k.d.ts} +3 -3
  310. package/dist/generators/factories/index.d.ts +1 -1
  311. package/dist/generators/factories/index.js +1 -1
  312. package/dist/generators/index.d.ts +2 -2
  313. package/dist/generators/json-schema/index.d.ts +2 -2
  314. package/dist/generators/json-schema/index.js +1 -1
  315. package/dist/generators/nuqs/index.d.ts +1 -1
  316. package/dist/generators/nuqs/index.js +1 -1
  317. package/dist/generators/standard-schema/index.d.ts +1 -1
  318. package/dist/generators/standard-schema/index.js +1 -1
  319. package/dist/generators/valibot/index.d.ts +1 -1
  320. package/dist/generators/valibot/index.js +1 -1
  321. package/dist/generators/zod/index.d.ts +1 -1
  322. package/dist/generators/zod/index.js +1 -1
  323. package/dist/hono/index.d.ts +4 -4
  324. package/dist/hono/index.js +3 -3
  325. package/dist/{index-DKuOnwh6.d.ts → index-28PPT5w7.d.ts} +2 -2
  326. package/dist/{index-ouiV6zqH.d.ts → index-69aFw9Id.d.ts} +2 -2
  327. package/dist/{index-o2y0w9lX.d.ts → index-74TASXlD.d.ts} +1 -1
  328. package/dist/{index-Dg4lbDzI.d.ts → index-B0dSXth6.d.ts} +1 -1
  329. package/dist/{index-DK0Hj3pi.d.ts → index-BOuJSOaf.d.ts} +1 -1
  330. package/dist/{index-C9p3wiWn.d.ts → index-BnY5lZtT.d.ts} +9 -9
  331. package/dist/{index-jCKNxp8C.d.ts → index-BqUY2MB-.d.ts} +1 -1
  332. package/dist/{index-BZHDwHGW.d.ts → index-BrnGYShi.d.ts} +2 -2
  333. package/dist/{index-BquYRGtV.d.ts → index-Bs6OCtxW.d.ts} +1 -1
  334. package/dist/{index-B6h9m3ml.d.ts → index-BszN5nLs.d.ts} +2 -2
  335. package/dist/{index-Cg0lDbXs.d.ts → index-Bv2kSYet.d.ts} +4 -4
  336. package/dist/{index-CHOeFZUB.d.ts → index-BvRseRob.d.ts} +3 -3
  337. package/dist/{index-DtVZnjKf.d.ts → index-BvZ3uvj9.d.ts} +2 -2
  338. package/dist/{index-ClysJ8O-.d.ts → index-C1na2fiY.d.ts} +3 -3
  339. package/dist/{index-D3d7m03L.d.ts → index-C59gKJBx.d.ts} +1 -1
  340. package/dist/{index-X-ihJBuJ.d.ts → index-CGAcXNod.d.ts} +1 -1
  341. package/dist/{index-BbpacfC0.d.ts → index-CMyUugyW.d.ts} +8 -8
  342. package/dist/{index-DkALeCTq.d.ts → index-CdoTvK2W.d.ts} +1 -1
  343. package/dist/{index-DG187JM_.d.ts → index-CiCmlbtu.d.ts} +1 -1
  344. package/dist/{index-qzFFTwel.d.ts → index-CiLb3DTI.d.ts} +3 -3
  345. package/dist/{index-WuUhLgMp.d.ts → index-Cnc4wyTo.d.ts} +2 -2
  346. package/dist/{index-DLlAc0wg.d.ts → index-Cpj79WyM.d.ts} +1 -1
  347. package/dist/{index-NNox0BqF.d.ts → index-D50ulqMJ.d.ts} +1 -1
  348. package/dist/{index-C7Tcervm.d.ts → index-D6px-XTD.d.ts} +2 -2
  349. package/dist/{index-BfoKErj3.d.ts → index-DMHxmit5.d.ts} +4 -4
  350. package/dist/{index-Dyns9a8l.d.ts → index-DflyfGR8.d.ts} +2 -2
  351. package/dist/{index-BFvj-fNS.d.ts → index-DibtbiIW.d.ts} +1 -1
  352. package/dist/{index-CnTxcNyl.d.ts → index-DpXMVE12.d.ts} +1 -1
  353. package/dist/{index-DMyMrXPW.d.ts → index-DsLMqyB5.d.ts} +1 -1
  354. package/dist/{index-DGszLnec.d.ts → index-DzUnwtxa.d.ts} +1 -1
  355. package/dist/{index-B4uPo3Sr.d.ts → index-Hzbfht3Z.d.ts} +1 -1
  356. package/dist/{index-bkm44ycq.d.ts → index-Sl13L6VB.d.ts} +4 -4
  357. package/dist/{index-DU_gZYuh.d.ts → index-UQOB8v1I.d.ts} +1 -1
  358. package/dist/{index-DYX_uL5t.d.ts → index-_No9Jb9O.d.ts} +1 -1
  359. package/dist/{index-BWxcC8ll.d.ts → index-cgHbN_EA.d.ts} +4 -4
  360. package/dist/{index-DHjZvZWC.d.ts → index-pry9PXpK.d.ts} +2 -2
  361. package/dist/{index-D_xJSanv.d.ts → index-wc3-R_cK.d.ts} +1 -1
  362. package/dist/index.d.ts +2 -2
  363. package/dist/index.js +2 -2
  364. package/dist/{invoices-CWp9jcI2.d.ts → invoices-BXwG7Jwp.d.ts} +5 -0
  365. package/dist/{json-schema-B8f7HdoX.js → json-schema-BveJfXoz.js} +1 -1
  366. package/dist/list/export/index.d.ts +1 -1
  367. package/dist/list/index.d.ts +1 -1
  368. package/dist/list/order/index.d.ts +2 -2
  369. package/dist/{list-query-qCpvTDGH.d.ts → list-query-CBjzZmjx.d.ts} +1 -1
  370. package/dist/{manifest-Clzy2rSU.d.ts → manifest-2JeNUq8t.d.ts} +1 -1
  371. package/dist/{manifest-B_2lEGUS.d.ts → manifest-3e0zfaQt.d.ts} +1 -1
  372. package/dist/{manifest-CKDaQT_5.d.ts → manifest-3or1oZTo.d.ts} +1 -1
  373. package/dist/{manifest-qvMWfrZ-.d.ts → manifest-AS4QwWdu.d.ts} +1 -1
  374. package/dist/{manifest-BvzmDxod.d.ts → manifest-B1lYVfIp.d.ts} +1 -1
  375. package/dist/{manifest-DVZmJvrE.d.ts → manifest-B7xyFqWo.d.ts} +1 -1
  376. package/dist/{manifest-Dpad_5Lw.d.ts → manifest-B9m_UaiY.d.ts} +1 -1
  377. package/dist/{manifest-CKCaFg8y.d.ts → manifest-B9qFGJ_A.d.ts} +1 -1
  378. package/dist/{manifest-DLSzZMXM.d.ts → manifest-BSjzLeb-.d.ts} +1 -1
  379. package/dist/{manifest-BS8p47JO.d.ts → manifest-BVn2Xglt.d.ts} +1 -1
  380. package/dist/{manifest-BoUGzBpS.d.ts → manifest-BWKFNoxP.d.ts} +1 -1
  381. package/dist/{manifest-D0eItVsP.d.ts → manifest-BXWhDMFt.d.ts} +1 -1
  382. package/dist/{manifest-DlLxdk7P.d.ts → manifest-Bi44m1V3.d.ts} +1 -1
  383. package/dist/{manifest-DHTVfgX9.d.ts → manifest-Bluupj7R.d.ts} +1 -1
  384. package/dist/{manifest-V0QSCEfx.d.ts → manifest-Bo0SCigB.d.ts} +1 -1
  385. package/dist/{manifest-DCkeNzPW.d.ts → manifest-ByRLUGaJ.d.ts} +3 -3
  386. package/dist/{manifest-C0v6IEWk.d.ts → manifest-C1--UMCz.d.ts} +1 -1
  387. package/dist/{manifest-CyaHDD_i.d.ts → manifest-C20SXAzp.d.ts} +1 -1
  388. package/dist/{manifest-CxgOFWlh.d.ts → manifest-C40ISJVj.d.ts} +1 -1
  389. package/dist/{manifest-C-pVDUC6.d.ts → manifest-C7KPtGTu.d.ts} +2 -2
  390. package/dist/{manifest-BAn3lTr4.d.ts → manifest-C82tY_RD.d.ts} +1 -1
  391. package/dist/{manifest-DBfQe19Z.d.ts → manifest-C94eugvl.d.ts} +1 -1
  392. package/dist/{manifest-BESrR9Xp.d.ts → manifest-CBdMkxZD.d.ts} +1 -1
  393. package/dist/{manifest-B7lSTuVC.d.ts → manifest-CCPioFQl.d.ts} +1 -1
  394. package/dist/{manifest-CCKfdYiH.d.ts → manifest-CD5D0OWo.d.ts} +1 -1
  395. package/dist/{manifest-Co41j70r.d.ts → manifest-CGnN_2Yx.d.ts} +1 -1
  396. package/dist/{manifest-ByV81mLa.d.ts → manifest-CH1MFzXN.d.ts} +1 -1
  397. package/dist/{manifest-BEw6nEKW.d.ts → manifest-CJRob2Ms.d.ts} +1 -1
  398. package/dist/{manifest-D80LSWzZ.d.ts → manifest-CgljOcHt.d.ts} +1 -1
  399. package/dist/{manifest-CNLJLsHB.d.ts → manifest-Ci7NEusH.d.ts} +1 -1
  400. package/dist/{manifest-DHulRwzL.d.ts → manifest-CiXl1kUg.d.ts} +1 -1
  401. package/dist/{manifest-VCJSqffq.d.ts → manifest-CjzIpyBP.d.ts} +2 -2
  402. package/dist/{manifest-eUUJnoB5.d.ts → manifest-ClDcyCPP.d.ts} +3 -3
  403. package/dist/{manifest-DKnWcgse.d.ts → manifest-Co0CBReD.d.ts} +1 -1
  404. package/dist/{manifest-QmYmc98q.d.ts → manifest-CpmJIEt7.d.ts} +1 -1
  405. package/dist/{manifest-C5LxShda.d.ts → manifest-Cqv6c1KN.d.ts} +1 -1
  406. package/dist/{manifest-CZoRtSvn.d.ts → manifest-CtUKrkx1.d.ts} +1 -1
  407. package/dist/{manifest-BGmmK9bZ.d.ts → manifest-D1FPczc-.d.ts} +1 -1
  408. package/dist/{manifest-RitquXSE.d.ts → manifest-D43yma-v.d.ts} +1 -1
  409. package/dist/{manifest-BMcuCUre.d.ts → manifest-DAF4J0gk.d.ts} +1 -1
  410. package/dist/{manifest-BgmY9fuz.d.ts → manifest-DGoI006V.d.ts} +1 -1
  411. package/dist/{manifest-ByNpLQWh.d.ts → manifest-DHN6WiIJ.d.ts} +1 -1
  412. package/dist/{manifest-BYv5BqtY.d.ts → manifest-DIl_cNua.d.ts} +1 -1
  413. package/dist/{manifest-CjzlsilW.d.ts → manifest-DJhjOnvk.d.ts} +1 -1
  414. package/dist/{manifest-CvncELVO.d.ts → manifest-DMhuQgOx.d.ts} +1 -1
  415. package/dist/{manifest-Fapf4NdA.d.ts → manifest-DQkz9UVy.d.ts} +1 -1
  416. package/dist/{manifest-BA-urVob.d.ts → manifest-DUZUtWBi.d.ts} +1 -1
  417. package/dist/{manifest-Dp92U_iP.d.ts → manifest-DY2KtVcD.d.ts} +1 -1
  418. package/dist/{manifest-CXYg8gzt.d.ts → manifest-DaB1w2xo.d.ts} +1 -1
  419. package/dist/{manifest-C8PUzse6.d.ts → manifest-DpXgCZEd.d.ts} +1 -1
  420. package/dist/{manifest-ra7MSo-3.d.ts → manifest-Dqf2Uw17.d.ts} +1 -1
  421. package/dist/{manifest-D5aZyD1b.js → manifest-OxHBbWrs.js} +1 -1
  422. package/dist/{manifest-r6DHrB4Q.d.ts → manifest-Utivc7Qa.d.ts} +1 -1
  423. package/dist/{manifest-CWwdLMT0.d.ts → manifest-WJ-UHuEx.d.ts} +1 -1
  424. package/dist/{manifest-CIVhJzKF.d.ts → manifest-WpIMAJCT.d.ts} +1 -1
  425. package/dist/{manifest-Ch08RUKa.d.ts → manifest-at0NS8cT.d.ts} +1 -1
  426. package/dist/{manifest-Dvm2mwFy.d.ts → manifest-d7vR6coE.d.ts} +2 -2
  427. package/dist/{manifest-TvLJWs_L.d.ts → manifest-gl856Z9G.d.ts} +1 -1
  428. package/dist/{manifest--_00y416.d.ts → manifest-iGmnzfGD.d.ts} +1 -1
  429. package/dist/{manifest-D_wBteR5.d.ts → manifest-j4_V-qhA.d.ts} +1 -1
  430. package/dist/{manifest-CLukD6aB.d.ts → manifest-mAxLRfeu.d.ts} +1 -1
  431. package/dist/{manifest-DofXV9lE.d.ts → manifest-mBKFNynL.d.ts} +1 -1
  432. package/dist/{manifest-wbs2VkcB.d.ts → manifest-wPIH-Oo7.d.ts} +1 -1
  433. package/dist/{manifest-Djy3wcSo.js → manifest-waO9DHVc.js} +1 -0
  434. package/dist/mapper/bin.js +5 -5
  435. package/dist/mcp/index.d.ts +2 -2
  436. package/dist/mcp/index.js +1 -1
  437. package/dist/mcp/sdk/index.d.ts +2 -2
  438. package/dist/mcp/sdk/index.js +1 -1
  439. package/dist/{mcp-aMq1fkoe.js → mcp-mSD-ic9W.js} +3 -3
  440. package/dist/next/index.d.ts +12 -12
  441. package/dist/next/index.js +10 -5
  442. package/dist/next/proxy/index.d.ts +3 -3
  443. package/dist/{operations-nnC3pvwn.d.ts → operations-dIOdHqYz.d.ts} +1 -1
  444. package/dist/orpc/index.d.ts +4 -4
  445. package/dist/orpc/index.js +2 -2
  446. package/dist/otel/index.js +5 -5
  447. package/dist/{permissions-ZLtxCurD.d.ts → permissions-DG0t2lrA.d.ts} +1 -1
  448. package/dist/{ports-CfVACwW_.d.ts → ports-CfiOCL2r.d.ts} +1 -1
  449. package/dist/{ports-DfDzwMCR.js → ports-DR88RF0N.js} +2 -2
  450. package/dist/powersync/index.d.ts +3 -3
  451. package/dist/powersync/index.js +1 -1
  452. package/dist/preset/index.d.ts +4 -4
  453. package/dist/{preview-BoJkQw2E.d.ts → preview-3nes4WG4.d.ts} +2 -2
  454. package/dist/{project-DI09JnXz.js → project-CXcoauzs.js} +2 -2
  455. package/dist/{push-token-Rv1CxW_N.d.ts → push-token-CRBieazN.d.ts} +1 -1
  456. package/dist/query/index.d.ts +1 -1
  457. package/dist/react/index.d.ts +5 -5
  458. package/dist/react/native/index.d.ts +1 -1
  459. package/dist/react/server.d.ts +6 -6
  460. package/dist/react-router/index.d.ts +3 -3
  461. package/dist/react-router/index.js +3 -3
  462. package/dist/{read-set-BptYceHc.js → read-set-DfScfSsf.js} +3 -2
  463. package/dist/realtime/index.d.ts +3 -3
  464. package/dist/{record-form-BHUYs5ju.d.ts → record-form-BggNAKZA.d.ts} +1 -1
  465. package/dist/records/index.d.ts +7 -7
  466. package/dist/{resource-execute-Bb-zKYUc.d.ts → resource-execute-BIqAzA57.d.ts} +1 -1
  467. package/dist/{resource-types-C8kdoZ-J.d.ts → resource-types-DcEe07vC.d.ts} +1 -1
  468. package/dist/{resources-B9dfA1jH.d.ts → resources-Bb_JRadM.d.ts} +1 -1
  469. package/dist/{sales-D_yZoFUU.js → sales-CIe7dE4J.js} +1 -1
  470. package/dist/server/account/index.d.ts +2 -2
  471. package/dist/server/accounts/index.d.ts +1 -1
  472. package/dist/server/index.d.ts +12 -12
  473. package/dist/server/index.js +4 -4
  474. package/dist/{server-Bgugpk3A.js → server-DA5SRGHQ.js} +2 -2
  475. package/dist/{server-types-C8zErBy9.d.ts → server-types-Cp2en4rP.d.ts} +2 -2
  476. package/dist/{session-DRn_URq0.d.ts → session-Bro3jmnu.d.ts} +1 -1
  477. package/dist/{sign-in-Dp-X2YXo.d.ts → sign-in-Cj7Y0mSU.d.ts} +11 -11
  478. package/dist/solid/index.d.ts +6 -6
  479. package/dist/solid-start/index.d.ts +3 -3
  480. package/dist/solid-start/index.js +3 -3
  481. package/dist/spec/index.d.ts +1 -1
  482. package/dist/spec/index.js +2 -2
  483. package/dist/sql/index.d.ts +5 -5
  484. package/dist/sql/index.js +1 -1
  485. package/dist/{sql-BqOBYRvI.js → sql-BwfPwN8v.js} +304 -95
  486. package/dist/sqlite/index.d.ts +1 -1
  487. package/dist/sqlite/index.js +1 -1
  488. package/dist/ssr/index.d.ts +1 -1
  489. package/dist/svelte/index.d.ts +6 -6
  490. package/dist/sveltekit/index.d.ts +4 -4
  491. package/dist/sveltekit/index.js +3 -3
  492. package/dist/{tags-Bh4zXrnl.d.ts → tags-C7NyJTdU.d.ts} +1 -1
  493. package/dist/tanstack-db/index.d.ts +1 -1
  494. package/dist/tanstack-start/index.d.ts +3 -3
  495. package/dist/tanstack-start/index.js +3 -3
  496. package/dist/{tenant-BQaG8Hma.d.ts → tenant-BFABaxQ5.d.ts} +1 -1
  497. package/dist/testing/index.d.ts +9 -9
  498. package/dist/testing/index.js +4 -4
  499. package/dist/{timeline-D7T-qrKN.d.ts → timeline-0a7kclhg.d.ts} +3 -3
  500. package/dist/{topic-R7kIJ_xI.d.ts → topic-BH4L7H8n.d.ts} +2 -2
  501. package/dist/{types-BE6BvLv2.d.ts → types-BMLgTFzf.d.ts} +2 -2
  502. package/dist/{verify-BfcOHiUP.d.ts → verify-tK2F49Gn.d.ts} +1 -1
  503. package/dist/{version-CkYT3KbT.js → version-BHgdHcZN.js} +1 -1
  504. package/dist/vue/index.d.ts +6 -6
  505. package/dist/{watch-topic-D18gT7-K.d.ts → watch-topic-BYfSlldk.d.ts} +1 -1
  506. package/dist/webmcp/index.d.ts +1 -1
  507. package/dist/webmcp/index.js +1 -1
  508. package/dist/yjs/index.d.ts +1 -1
  509. package/package.json +1 -1
  510. package/dist/cli/add-C04PIE9H.js +0 -1
  511. package/dist/cli/powersync-DnKUA1tu.js +0 -1
  512. package/dist/cli/round-trips-n_Dk1iUI.js +0 -54
@@ -1,7 +1,7 @@
1
- import { C as BlockOptionsRegistry, S as BLOCK_OPTION_SCHEMAS, b as resolveBlock } from "../blocks-RVd7m590.js";
2
- import { A as declaredTableColumns, Br as sameTenantLayout, C as notNullCheckName, D as addedColumnTypes, E as PolicyGrant, F as policyGrants, Hr as auditRegistrations, I as rlsTables, M as declaredUpdatedAtTriggers, N as declaredViews, O as declaredColumnTypes, P as extensionSchema, S as blockSqlVersion, T as OwnIndex, Vr as AuditedTable, _ as BlockSqlFile, a as BlockSqlTableSpec, aa as readArgSqlType, b as BlockSqlUpgrade, c as moduleIdType, d as appValues, ea as BlockSqlRead, f as checkedValueMaps, g as BlockSqlEntitlementsProvider, h as BlockSqlDeprecation, i as BlockSqlNames, ia as readArgSource, j as declaredTables, k as declaredIndexes, l as ValueMap, m as BlockSqlAccessProvider, n as BlockSqlContractFunction, na as BlockSqlReadArgType, o as MODULE_ID_TYPES, p as BlockSql, r as BlockSqlIdType, ra as declareRead, s as isBlockSqlIdType, t as BlockSqlContext, ta as BlockSqlReadArg, u as ValueMaps, v as BlockSqlLayout, w as DeclaredView, x as OwnView, y as BlockSqlTestFile, zr as DeclaredForeignKey } from "../context-DMTfze4z.js";
1
+ import { C as BlockOptionsRegistry, S as BLOCK_OPTION_SCHEMAS, b as resolveBlock } from "../blocks-sDhFO8-h.js";
2
+ import { A as declaredTableColumns, Br as sameTenantLayout, C as notNullCheckName, D as addedColumnTypes, E as PolicyGrant, F as policyGrants, Hr as auditRegistrations, I as rlsTables, M as declaredUpdatedAtTriggers, N as declaredViews, O as declaredColumnTypes, P as extensionSchema, S as blockSqlVersion, T as OwnIndex, Vr as AuditedTable, _ as BlockSqlFile, a as BlockSqlTableSpec, aa as readArgSqlType, b as BlockSqlUpgrade, c as moduleIdType, d as appValues, ea as BlockSqlRead, f as checkedValueMaps, g as BlockSqlEntitlementsProvider, h as BlockSqlDeprecation, i as BlockSqlNames, ia as readArgSource, j as declaredTables, k as declaredIndexes, l as ValueMap, m as BlockSqlAccessProvider, n as BlockSqlContractFunction, na as BlockSqlReadArgType, o as MODULE_ID_TYPES, p as BlockSql, r as BlockSqlIdType, ra as declareRead, s as isBlockSqlIdType, t as BlockSqlContext, ta as BlockSqlReadArg, u as ValueMaps, v as BlockSqlLayout, w as DeclaredView, x as OwnView, y as BlockSqlTestFile, zr as DeclaredForeignKey } from "../context-C_Rx1QaW.js";
3
3
  import { a as BlockSqlEmit, i as BlockSqlAudit, n as AuditCategory, r as BlockSqlAction, t as AUDIT_CATEGORIES } from "../audit-actions-DC-AtyWB.js";
4
- import { $ as PolicyCommand, $n as moduleContext, $t as AdoptedView, A as POLICY_FUNCTIONS, An as EntityRenameStep, At as checkValues, B as policyFunctionsSql, Bn as ParseStore, Bt as DataExportPlan, C as setTagBlock, Cn as blockFileState, Ct as templateFunctions, D as formatBsbComment, Dn as moduleDataDir, Dt as writtenValues, E as commentOnTableSql, En as sameBlockFile, Et as duplicateObjects, F as RulePolicy, Fn as ModuleRenderEntry, Ft as TenantQuery, G as bsbPolicyName, Gn as duplicatePolicies, Gt as excludedColumns, H as renderRule, Hn as appColumnsOf, Ht as dataExportPlan, I as RulePolicyInput, In as ModuleRenderStore, It as tenantsQuery, J as widenedCommands, Jn as setParseStore, Jt as clearMemo, K as appTablePolicyNotes, Kn as ownerOf, Kt as resolveExposeColumns, L as RuleValue, Ln as moduleRenderStats, Lt as expiredFlagsQuery, M as ReadRulePolicy, Mn as SqlStatement, Mt as ReadRolesModule, N as Rule, Nn as splitStatements, Nt as blockReadRoles, O as parseBsbComment, On as moduleFilePaths, Ot as CheckValues, P as RuleOperator, Pn as renderKey, Pt as subjectColumns, Q as Policy, Qn as upgradePlan, Qt as AdoptedTable, R as disallowedPolicyCalls, Rn as setModuleRenderStore, Rt as sameTenantColumn, S as renderTagBlock, Sn as moduleSchemaExtensions, St as scopeProblems, T as BsbTag, Tn as moduleFileVersion, Tt as DuplicateObject, U as renderRulePolicy, Un as buildModel, Ut as OwnedColumn, V as readRulePolicies, Vn as SchemaModel, Vt as SECRET_COLUMNS, W as rulePolicy, Wn as conflicts, Wt as ownedColumns, X as TENANT_SCOPE_POLICY, Xn as InstalledBlock, Xt as memoized, Y as TENANT_SCOPE_NAMES, Yn as BlockSqlUpgradePlan, Yt as memoStats, Z as Grant, Zn as moduleDeprecations, Zt as setMemoBackend, _ as tableTagComments, _n as BlockSqlExtension, _t as migrationOptionUses, a as ListTemplateOptions, an as PRELUDE_FUNCTIONS, ar as customContracts, at as policy, b as TagRenderOptions, bn as moduleHidingColumns, bt as resolveProviderSql, c as listDeclare, cn as APP_TABLES_MODULE, cr as renderBlocks, ct as readPolicy, d as TableFeature, dn as instanceFunctions, dt as hasColumnAccess, en as adoptedColumnProblems, er as redundantNulls, et as PolicyInput, f as createsTable, fn as SeedDefaultsFunction, ft as CompiledReadSet, g as tableFeatures, gn as resolveBlocks, gt as MigrationOptionUse, h as setTableFeature, hn as moduleSource, ht as sharedRolesProblems, i as ListSortKey, in as UNSCOPED_MODULE, ir as BlockSqlTopic, it as maskSql, j as PolicyFunctionsOptions, jn as entityRenamePlan, jt as declaredCheckValues, k as setBsbTag, kn as EntityRenamePlan, kt as TableCheckValues, l as listOrder, ln as appTablesFiles, lr as contractSignature, lt as renderPolicy, m as setFeatureStatement, mn as SQL_MODULES, mt as compileReadSets, n as renderAutoEmbedding, nn as adoptedViews, nr as legacyOptionTarget, nt as RenderPolicyOptions, o as keysetPredicate, on as PRELUDE_MODULE, or as moduleBody, ot as readGrants, p as isTableFeature, pn as seedDefaultsFunctions, pt as compileReadSet, q as declaredPolicies, qn as parseDeclared, qt as MemoBackend, r as LIST_TOTAL_CAP, rn as moduleWritesText, rr as LEGACY_OPTION, rt as catalogPolicy, s as listBody, sn as APP_TABLES_MARKER, sr as moduleTopics, st as readPolicies, t as AutoEmbeddingConfig, tn as adoptedTables, tr as legacyOptionTables, tt as ReadPolicy, u as TABLE_FEATURES, un as DEFAULT_ROLES, ut as scopePolicyName, v as RENDERED_FEATURES, vn as BlockSqlPermissionKey, vt as moduleLayout, w as BsbComment, wn as isModuleDataFile, wt as templatePlaceholderProblems, x as isRenderedFeature, xn as modulePermissionKeys, xt as sameTemplateFunction, y as RenderedFeature, yn as moduleEventTriggers, yt as SCOPE_ID_TYPES, z as isRule, zn as Declaration, zt as sameTenantTrigger } from "../index-BfoKErj3.js";
5
- import { n as BlockTables, r as blockTables, t as BlockTable } from "../block-tables-BaLXCQha.js";
6
- import { a as appTableEventTypes } from "../app-tables-DBmFqdFN.js";
4
+ import { $ as PolicyCommand, $n as moduleContext, $t as AdoptedView, A as POLICY_FUNCTIONS, An as EntityRenameStep, At as checkValues, B as policyFunctionsSql, Bn as ParseStore, Bt as DataExportPlan, C as setTagBlock, Cn as blockFileState, Ct as templateFunctions, D as formatBsbComment, Dn as moduleDataDir, Dt as writtenValues, E as commentOnTableSql, En as sameBlockFile, Et as duplicateObjects, F as RulePolicy, Fn as ModuleRenderEntry, Ft as TenantQuery, G as bsbPolicyName, Gn as duplicatePolicies, Gt as excludedColumns, H as renderRule, Hn as appColumnsOf, Ht as dataExportPlan, I as RulePolicyInput, In as ModuleRenderStore, It as tenantsQuery, J as widenedCommands, Jn as setParseStore, Jt as clearMemo, K as appTablePolicyNotes, Kn as ownerOf, Kt as resolveExposeColumns, L as RuleValue, Ln as moduleRenderStats, Lt as expiredFlagsQuery, M as ReadRulePolicy, Mn as SqlStatement, Mt as ReadRolesModule, N as Rule, Nn as splitStatements, Nt as blockReadRoles, O as parseBsbComment, On as moduleFilePaths, Ot as CheckValues, P as RuleOperator, Pn as renderKey, Pt as subjectColumns, Q as Policy, Qn as upgradePlan, Qt as AdoptedTable, R as disallowedPolicyCalls, Rn as setModuleRenderStore, Rt as sameTenantColumn, S as renderTagBlock, Sn as moduleSchemaExtensions, St as scopeProblems, T as BsbTag, Tn as moduleFileVersion, Tt as DuplicateObject, U as renderRulePolicy, Un as buildModel, Ut as OwnedColumn, V as readRulePolicies, Vn as SchemaModel, Vt as SECRET_COLUMNS, W as rulePolicy, Wn as conflicts, Wt as ownedColumns, X as TENANT_SCOPE_POLICY, Xn as InstalledBlock, Xt as memoized, Y as TENANT_SCOPE_NAMES, Yn as BlockSqlUpgradePlan, Yt as memoStats, Z as Grant, Zn as moduleDeprecations, Zt as setMemoBackend, _ as tableTagComments, _n as BlockSqlExtension, _t as migrationOptionUses, a as ListTemplateOptions, an as PRELUDE_FUNCTIONS, ar as customContracts, at as policy, b as TagRenderOptions, bn as moduleHidingColumns, bt as resolveProviderSql, c as listDeclare, cn as APP_TABLES_MODULE, cr as renderBlocks, ct as readPolicy, d as TableFeature, dn as instanceFunctions, dt as hasColumnAccess, en as adoptedColumnProblems, er as redundantNulls, et as PolicyInput, f as createsTable, fn as SeedDefaultsFunction, ft as CompiledReadSet, g as tableFeatures, gn as resolveBlocks, gt as MigrationOptionUse, h as setTableFeature, hn as moduleSource, ht as sharedRolesProblems, i as ListSortKey, in as UNSCOPED_MODULE, ir as BlockSqlTopic, it as maskSql, j as PolicyFunctionsOptions, jn as entityRenamePlan, jt as declaredCheckValues, k as setBsbTag, kn as EntityRenamePlan, kt as TableCheckValues, l as listOrder, ln as appTablesFiles, lr as contractSignature, lt as renderPolicy, m as setFeatureStatement, mn as SQL_MODULES, mt as compileReadSets, n as renderAutoEmbedding, nn as adoptedViews, nr as legacyOptionTarget, nt as RenderPolicyOptions, o as keysetPredicate, on as PRELUDE_MODULE, or as moduleBody, ot as readGrants, p as isTableFeature, pn as seedDefaultsFunctions, pt as compileReadSet, q as declaredPolicies, qn as parseDeclared, qt as MemoBackend, r as LIST_TOTAL_CAP, rn as moduleWritesText, rr as LEGACY_OPTION, rt as catalogPolicy, s as listBody, sn as APP_TABLES_MARKER, sr as moduleTopics, st as readPolicies, t as AutoEmbeddingConfig, tn as adoptedTables, tr as legacyOptionTables, tt as ReadPolicy, u as TABLE_FEATURES, un as DEFAULT_ROLES, ut as scopePolicyName, v as RENDERED_FEATURES, vn as BlockSqlPermissionKey, vt as moduleLayout, w as BsbComment, wn as isModuleDataFile, wt as templatePlaceholderProblems, x as isRenderedFeature, xn as modulePermissionKeys, xt as sameTemplateFunction, y as RenderedFeature, yn as moduleEventTriggers, yt as SCOPE_ID_TYPES, z as isRule, zn as Declaration, zt as sameTenantTrigger } from "../index-DMHxmit5.js";
5
+ import { n as BlockTables, r as blockTables, t as BlockTable } from "../block-tables-KnVB7FH0.js";
6
+ import { a as appTableEventTypes } from "../app-tables-C_bRG0ek.js";
7
7
  export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, type AdoptedTable, type AdoptedView, type AuditCategory, type AuditedTable, type AutoEmbeddingConfig, BLOCK_OPTION_SCHEMAS, type BlockOptionsRegistry, type BlockSql, type BlockSqlAccessProvider, type BlockSqlAction, type BlockSqlAudit, type BlockSqlContext, type BlockSqlContractFunction, type BlockSqlDeprecation, type BlockSqlEmit, type BlockSqlEntitlementsProvider, type BlockSqlExtension, type BlockSqlFile, type BlockSqlIdType, type BlockSqlLayout, type BlockSqlNames, type BlockSqlPermissionKey, type BlockSqlRead, type BlockSqlReadArg, type BlockSqlReadArgType, type BlockSqlTableSpec, type BlockSqlTestFile, type BlockSqlTopic, type BlockSqlUpgrade, type BlockSqlUpgradePlan, type BlockTable, type BlockTables, type BsbComment, type BsbTag, type CheckValues, type CompiledReadSet, DEFAULT_ROLES, type DataExportPlan, type Declaration, type DeclaredForeignKey, type DeclaredView, type DuplicateObject, type EntityRenamePlan, type EntityRenameStep, type Grant, type InstalledBlock, LEGACY_OPTION, LIST_TOTAL_CAP, type ListSortKey, type ListTemplateOptions, MODULE_ID_TYPES, type MemoBackend, type MigrationOptionUse, type ModuleRenderEntry, type ModuleRenderStore, type OwnIndex, type OwnView, type OwnedColumn, POLICY_FUNCTIONS, PRELUDE_FUNCTIONS, PRELUDE_MODULE, type ParseStore, type Policy, type PolicyCommand, type PolicyFunctionsOptions, type PolicyGrant, type PolicyInput, RENDERED_FEATURES, type ReadPolicy, type ReadRolesModule, type ReadRulePolicy, type RenderPolicyOptions, type RenderedFeature, type Rule, type RuleOperator, type RulePolicy, type RulePolicyInput, type RuleValue, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, type SchemaModel, type SeedDefaultsFunction, type SqlStatement, TABLE_FEATURES, TENANT_SCOPE_NAMES, TENANT_SCOPE_POLICY, type TableCheckValues, type TableFeature, type TagRenderOptions, type TenantQuery, UNSCOPED_MODULE, type ValueMap, type ValueMaps, addedColumnTypes, adoptedColumnProblems, adoptedTables, adoptedViews, appColumnsOf, appTableEventTypes, appTablePolicyNotes, appTablesFiles, appValues, auditRegistrations, blockFileState, blockReadRoles, blockSqlVersion, blockTables, bsbPolicyName, buildModel, catalogPolicy, checkValues, checkedValueMaps, clearMemo, commentOnTableSql, compileReadSet, compileReadSets, conflicts, contractSignature, createsTable, customContracts, dataExportPlan, declareRead, declaredCheckValues, declaredColumnTypes, declaredIndexes, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, disallowedPolicyCalls, duplicateObjects, duplicatePolicies, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formatBsbComment, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, isRenderedFeature, isRule, isTableFeature, keysetPredicate, legacyOptionTables, legacyOptionTarget, listBody, listDeclare, listOrder, maskSql, memoStats, memoized, migrationOptionUses, moduleBody, moduleContext, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleRenderStats, moduleSchemaExtensions, moduleSource, moduleTopics, moduleWritesText, notNullCheckName, ownedColumns, ownerOf, parseBsbComment, parseDeclared, policy, policyFunctionsSql, policyGrants, readArgSource, readArgSqlType, readGrants, readPolicies, readPolicy, readRulePolicies, redundantNulls, renderAutoEmbedding, renderBlocks, renderKey, renderPolicy, renderRule, renderRulePolicy, renderTagBlock, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, rulePolicy, sameBlockFile, sameTemplateFunction, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, seedDefaultsFunctions, setBsbTag, setFeatureStatement, setMemoBackend, setModuleRenderStore, setParseStore, setTableFeature, setTagBlock, sharedRolesProblems, splitStatements, subjectColumns, tableFeatures, tableTagComments, templateFunctions, templatePlaceholderProblems, tenantsQuery, upgradePlan, widenedCommands, writtenValues };
package/dist/sql/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { B as resolveBlock, T as hasColumnAccess, h as appTableEventTypes } from "../instances-07Lopbd1.js";
2
- import { $ as ownerOf, $t as redundantNulls, A as declaredCheckValues, At as sameBlockFile, B as clearMemo, Bt as excludedColumns, C as rulePolicy, Ct as appTablesFiles, D as duplicateObjects, Dt as blockFileState, E as sharedRolesProblems, Et as blockSqlVersion, F as sameTenantLayout, Ft as SQL_MODULES, G as blockTables, Gt as keysetPredicate, H as memoized, Ht as SECRET_COLUMNS, I as adoptedColumnProblems, It as moduleSource, J as entityRenamePlan, Jt as listOrder, K as seedDefaultsFunctions, Kt as listBody, L as adoptedTables, Lt as resolveBlocks, M as tenantsQuery, Mt as moduleHidingColumns, N as expiredFlagsQuery, Nt as modulePermissionKeys, O as writtenValues, Ot as isModuleDataFile, P as ownedColumns, Pt as moduleSchemaExtensions, Q as duplicatePolicies, Qt as moduleContext, R as adoptedViews, Rt as TENANT_SCOPE_NAMES, S as renderRulePolicy, St as APP_TABLES_MODULE, T as compileReadSets, Tt as renderAutoEmbedding, U as setMemoBackend, Ut as dataExportPlan, V as memoStats, Vt as resolveExposeColumns, W as instanceFunctions, Wt as LIST_TOTAL_CAP, X as buildModel, Xt as sameTenantTrigger, Y as appColumnsOf, Yt as sameTenantColumn, Z as conflicts, Zt as migrationOptionUses, _ as disallowedPolicyCalls, _n as extensionSchema, _t as setModuleRenderStore, a as setTableFeature, an as checkedValueMaps, at as moduleTopics, b as readRulePolicies, bn as auditRegistrations, bt as moduleFilePaths, c as RENDERED_FEATURES, cn as AUDIT_CATEGORIES, ct as upgradePlan, d as setTagBlock, dn as declaredColumnTypes, dt as appTablePolicyNotes, en as MODULE_ID_TYPES, et as parseDeclared, f as commentOnTableSql, fn as declaredIndexes, ft as declaredPolicies, g as POLICY_FUNCTIONS, gn as declaredViews, gt as moduleRenderStats, h as setBsbTag, hn as declaredUpdatedAtTriggers, ht as PRELUDE_MODULE, i as setFeatureStatement, in as appValues, it as moduleBody, j as blockReadRoles, jt as moduleEventTriggers, k as checkValues, kt as moduleFileVersion, l as isRenderedFeature, ln as BLOCK_OPTION_SCHEMAS, lt as bsbPolicyName, m as parseBsbComment, mn as declaredTables, mt as PRELUDE_FUNCTIONS, n as createsTable, nn as moduleIdType, nt as splitStatements, o as tableFeatures, on as legacyOptionTables, ot as renderBlocks, p as formatBsbComment, pn as declaredTableColumns, pt as widenedCommands, q as moduleLayout, qt as listDeclare, r as isTableFeature, rn as contractSignature, rt as customContracts, s as tableTagComments, sn as legacyOptionTarget, st as moduleDeprecations, t as TABLE_FEATURES, tn as isBlockSqlIdType, tt as setParseStore, u as renderTagBlock, un as addedColumnTypes, ut as UNSCOPED_MODULE, v as isRule, vn as policyGrants, vt as renderKey, w as compileReadSet, wt as scopePolicyName, x as renderRule, xt as APP_TABLES_MARKER, y as policyFunctionsSql, yn as rlsTables, yt as moduleDataDir, z as moduleWritesText, zt as TENANT_SCOPE_POLICY } from "../sql-BqOBYRvI.js";
2
+ import { $ as ownerOf, $t as redundantNulls, A as declaredCheckValues, At as sameBlockFile, B as clearMemo, Bt as excludedColumns, C as rulePolicy, Ct as appTablesFiles, D as duplicateObjects, Dt as blockFileState, E as sharedRolesProblems, Et as blockSqlVersion, F as sameTenantLayout, Ft as SQL_MODULES, G as blockTables, Gt as keysetPredicate, H as memoized, Ht as SECRET_COLUMNS, I as adoptedColumnProblems, It as moduleSource, J as entityRenamePlan, Jt as listOrder, K as seedDefaultsFunctions, Kt as listBody, L as adoptedTables, Lt as resolveBlocks, M as tenantsQuery, Mt as moduleHidingColumns, N as expiredFlagsQuery, Nt as modulePermissionKeys, O as writtenValues, Ot as isModuleDataFile, P as ownedColumns, Pt as moduleSchemaExtensions, Q as duplicatePolicies, Qt as moduleContext, R as adoptedViews, Rt as TENANT_SCOPE_NAMES, S as renderRulePolicy, St as APP_TABLES_MODULE, T as compileReadSets, Tt as renderAutoEmbedding, U as setMemoBackend, Ut as dataExportPlan, V as memoStats, Vt as resolveExposeColumns, W as instanceFunctions, Wt as LIST_TOTAL_CAP, X as buildModel, Xt as sameTenantTrigger, Y as appColumnsOf, Yt as sameTenantColumn, Z as conflicts, Zt as migrationOptionUses, _ as disallowedPolicyCalls, _n as extensionSchema, _t as setModuleRenderStore, a as setTableFeature, an as checkedValueMaps, at as moduleTopics, b as readRulePolicies, bn as auditRegistrations, bt as moduleFilePaths, c as RENDERED_FEATURES, cn as AUDIT_CATEGORIES, ct as upgradePlan, d as setTagBlock, dn as declaredColumnTypes, dt as appTablePolicyNotes, en as MODULE_ID_TYPES, et as parseDeclared, f as commentOnTableSql, fn as declaredIndexes, ft as declaredPolicies, g as POLICY_FUNCTIONS, gn as declaredViews, gt as moduleRenderStats, h as setBsbTag, hn as declaredUpdatedAtTriggers, ht as PRELUDE_MODULE, i as setFeatureStatement, in as appValues, it as moduleBody, j as blockReadRoles, jt as moduleEventTriggers, k as checkValues, kt as moduleFileVersion, l as isRenderedFeature, ln as BLOCK_OPTION_SCHEMAS, lt as bsbPolicyName, m as parseBsbComment, mn as declaredTables, mt as PRELUDE_FUNCTIONS, n as createsTable, nn as moduleIdType, nt as splitStatements, o as tableFeatures, on as legacyOptionTables, ot as renderBlocks, p as formatBsbComment, pn as declaredTableColumns, pt as widenedCommands, q as moduleLayout, qt as listDeclare, r as isTableFeature, rn as contractSignature, rt as customContracts, s as tableTagComments, sn as legacyOptionTarget, st as moduleDeprecations, t as TABLE_FEATURES, tn as isBlockSqlIdType, tt as setParseStore, u as renderTagBlock, un as addedColumnTypes, ut as UNSCOPED_MODULE, v as isRule, vn as policyGrants, vt as renderKey, w as compileReadSet, wt as scopePolicyName, x as renderRule, xt as APP_TABLES_MARKER, y as policyFunctionsSql, yn as rlsTables, yt as moduleDataDir, z as moduleWritesText, zt as TENANT_SCOPE_POLICY } from "../sql-BwfPwN8v.js";
3
3
  import { a as LEGACY_OPTION } from "../options-Bfd-k6yw.js";
4
4
  import { A as notNullCheckName } from "../shared-D-qwk29i.js";
5
5
  import { s as subjectColumns } from "../contributions-Bh-HcHoJ.js";
@@ -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";
@@ -167,7 +167,7 @@ import { n as WARRANTY_STATUSES } from "./warranty-values-BJo_g1F1.js";
167
167
  import { n as WORKFLOW_SDK_WORLD } from "./workflow-sdk-c025kSHf.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-DeuaXsV7.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([
@@ -24494,6 +24494,35 @@ end;
24494
24494
  $$;
24495
24495
  ${userGrant(`${fn("get_approval")}(uuid)`)}
24496
24496
 
24497
+ -- Many requests with their decisions and items in one read, in the order
24498
+ -- requested. A request that is missing or that the caller cannot read is left
24499
+ -- out instead of failing the batch.
24500
+ create or replace function ${fn("get_approvals")}(request_ids uuid[])
24501
+ returns jsonb
24502
+ language plpgsql
24503
+ stable
24504
+ security definer
24505
+ set search_path = ''
24506
+ as $$
24507
+ begin
24508
+ return (
24509
+ select coalesce(jsonb_agg(${json("r")} || jsonb_build_object(
24510
+ 'canDecide', ${fn("approval_eligible")}(r.${c("id")}),
24511
+ 'decisions', coalesce((
24512
+ 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")})
24513
+ from ${decisions} x where x.${d("request")} = r.${c("id")}
24514
+ ), '[]'::jsonb),
24515
+ 'items', ${itemsOf$1(ctx, `r.${c("id")}`)}
24516
+ ) order by array_position(get_approvals.request_ids, r.${c("id")})), '[]'::jsonb)
24517
+ from ${requests} r
24518
+ where r.${c("id")} = any (get_approvals.request_ids)
24519
+ and (${SERVICE_CALLER$1} or coalesce(r.${c("requestedBy")} = auth.uid(), false) or ${fn("approval_eligible")}(r.${c("id")})
24520
+ or (${ctx.can("tenant", `r.${c("tenant")}`, read)} and ${readable("r")}))
24521
+ );
24522
+ end;
24523
+ $$;
24524
+ ${userGrant(`${fn("get_approvals")}(uuid[])`)}
24525
+
24497
24526
  -- assigned: only requests whose current step the caller can decide.
24498
24527
  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
24528
  returns jsonb
@@ -71653,6 +71682,37 @@ const COLLECTIONS$1 = {
71653
71682
  contract: contract$103,
71654
71683
  build: build$117
71655
71684
  };
71685
+ // src/sql/modules/comments-mention-groups.ts
71686
+ const MENTION_GROUP_KEYS = /* @__PURE__ */ new Set([
71687
+ "table",
71688
+ "group",
71689
+ "member",
71690
+ "tenant"
71691
+ ]);
71692
+ function mentionGroupsOf(ctx) {
71693
+ const option = ctx.option("mentionGroups");
71694
+ if (option === void 0) return;
71695
+ const where = "blocks.comments.options.mentionGroups";
71696
+ if (!isRecord$1(option)) throw new TypeError(`${where} must be { table, group, member, tenant? }`);
71697
+ 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`);
71698
+ const text = (key) => {
71699
+ const value = option[key];
71700
+ if (value === void 0) return;
71701
+ if (typeof value !== "string" || value.length === 0) throw new TypeError(`${where}.${key} must be a non-empty string`);
71702
+ return value;
71703
+ };
71704
+ const table = text("table");
71705
+ const group = text("group");
71706
+ const member = text("member");
71707
+ if (table === void 0 || group === void 0 || member === void 0) throw new TypeError(`${where} needs table, group and member`);
71708
+ const tenant = text("tenant");
71709
+ return {
71710
+ table,
71711
+ group,
71712
+ member,
71713
+ ...tenant !== void 0 && { tenant }
71714
+ };
71715
+ }
71656
71716
  // src/sql/modules/messaging-tables.ts
71657
71717
  const MESSAGE_RESERVED = ["fields"];
71658
71718
  /** The longest thread summary `save_thread_summary` stores. */
@@ -71697,9 +71757,14 @@ function guestOnRecord(q, alias, action) {
71697
71757
  return guest === "false" ? "" : `
71698
71758
  or (${alias}.${cv("kind")} = 'subject' and ${guest})`;
71699
71759
  }
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}))` : "";
71760
+ /**
71761
+ * With the inbox: a note shows to the inbox's staff only. `alias` qualifies the
71762
+ * message's columns.
71763
+ */
71764
+ function noteReadable(q, alias) {
71765
+ const ms = q.cols("messages");
71766
+ const at = alias === void 0 ? "" : `${alias}.`;
71767
+ return q.ctx.installed("inbox") ? `\n and (${at}${ms("kind")} = 'message' or ${q.ctx.of("inbox").fn("inbox_note_readable")}(${at}${ms("conversation")}))` : "";
71703
71768
  }
71704
71769
  function tableDdl(q) {
71705
71770
  const { ctx, t, id } = q;
@@ -71913,7 +71978,7 @@ ${renderPolicy(policy$1({
71913
71978
  command: "select",
71914
71979
  roles: ["authenticated"],
71915
71980
  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"))}`
71981
+ and exists (select 1 from ${t("conversations")} c where c.${cv("id")} = ${ms("conversation")})${noteReadable(q)}`
71917
71982
  }), { target: t("messages") })}
71918
71983
 
71919
71984
  ${ddl.edits}
@@ -72167,36 +72232,6 @@ const NAMES$113 = {
72167
72232
  };
72168
72233
  /** Sorts after every uuid, so `after` without `after_id` means strictly later. */
72169
72234
  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
72235
  /** A column name as a JSON key of `to_jsonb(row)`. */
72201
72236
  const key = (column) => sqlString(column.replaceAll("\"", ""));
72202
72237
  /**
@@ -72323,7 +72358,7 @@ end;
72323
72358
  $$;
72324
72359
  ${userGrant(`${fn("assign_comment")}(uuid, uuid, jsonb)`)}`;
72325
72360
  }
72326
- function build$116(ctx) {
72361
+ function build$116(ctx, layout) {
72327
72362
  if (ctx.mode === "custom") return "";
72328
72363
  const id = ctx.idType;
72329
72364
  const m = ctx.of("messaging");
@@ -72338,6 +72373,39 @@ function build$116(ctx) {
72338
72373
  const expand = groups === void 0 ? "select x from unnest(v_raw) x" : `select x from unnest(v_raw) x
72339
72374
  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
72375
  const sent = afterSend(ctx);
72376
+ const mq = messagingSql(m, layout.accessProvider);
72377
+ const pageIds = (conversation, f, notes) => `array(
72378
+ select x.${ms("id")} from ${m.table("messages")} x
72379
+ where x.${ms("conversation")} = ${conversation} and x.${ms("sentAt")} is not null${notes}
72380
+ and (coalesce(${f}.include_deleted, true) or x.${ms("deletedAt")} is null)
72381
+ and (${f}.after is null
72382
+ or (x.${ms("sentAt")}, x.${ms("id")}) > (${f}.after, coalesce(${f}.after_id, ${MAX_UUID$1})))
72383
+ order by x.${ms("sentAt")}, x.${ms("id")}
72384
+ limit ${pageSize(`${f}.max_rows`, 100, 500)}
72385
+ offset greatest(coalesce(${f}.skip, 0), 0)
72386
+ )`;
72387
+ const commentsOf = (messagesJson, ids) => `(
72388
+ with e as materialized (
72389
+ select x.row, x.n from jsonb_array_elements(${messagesJson}(${ids})) with ordinality x(row, n)
72390
+ ),
72391
+ c as materialized (
72392
+ select c.${cv("id")} as id, c.${cv("subjectType")} as subject_type, c.${cv("subjectId")} as subject_id
72393
+ from ${m.table("conversations")} c
72394
+ where c.${cv("id")} = any (array(select distinct (e.row ->> ${key(ms("conversation"))})::uuid from e))
72395
+ ),
72396
+ t as materialized (
72397
+ select t.${k("message")} as message, t.${k("task")} as task from ${tasks} t
72398
+ where t.${k("message")} = any (${ids})
72399
+ )
72400
+ select coalesce(jsonb_agg(e.row || jsonb_build_object(
72401
+ 'subject_type', c.subject_type,
72402
+ 'subject_id', c.subject_id,
72403
+ 'task_id', t.task
72404
+ ) order by e.n), '[]'::jsonb)
72405
+ from e
72406
+ join c on c.id = (e.row ->> ${key(ms("conversation"))})::uuid
72407
+ left join t on t.message = (e.row ->> ${key(ms("id"))})::uuid
72408
+ )`;
72341
72409
  return `${schemaPreamble(ctx)}
72342
72410
  -- Comments are a record's conversation (kind subject) on the messaging core:
72343
72411
  -- whoever reads the record reads its comments. These functions open it,
@@ -72425,32 +72493,40 @@ security invoker
72425
72493
  set search_path = ''
72426
72494
  as $$
72427
72495
  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
- );
72496
+ return ${commentsOf(m.fn("messaging_messages_json"), "comments_json.ids")};
72450
72497
  end;
72451
72498
  $$;
72452
72499
  ${userGrant(`${fn("comments_json")}(uuid[])`)}
72453
72500
 
72501
+ -- A page of a record conversation's sent comment ids, as their owner, once
72502
+ -- the conversation passes the read check.
72503
+ create or replace function ${fn("comment_page")}(
72504
+ conversation uuid,
72505
+ after timestamptz default null,
72506
+ max_rows integer default 100,
72507
+ skip integer default 0,
72508
+ after_id uuid default null,
72509
+ include_deleted boolean default true
72510
+ )
72511
+ returns uuid[]
72512
+ language plpgsql
72513
+ stable
72514
+ security definer
72515
+ set search_path = ''
72516
+ as $$
72517
+ begin
72518
+ if not exists (
72519
+ select 1 from ${m.table("conversations")} c
72520
+ where c.${cv("id")} = comment_page.conversation and c.${cv("kind")} = 'subject'
72521
+ and (${SERVICE_CALLER$1} or ${conversationReadable(mq, "c")})
72522
+ ) then
72523
+ return '{}'::uuid[];
72524
+ end if;
72525
+ return ${pageIds("comment_page.conversation", "comment_page", noteReadable(mq, "x"))};
72526
+ end;
72527
+ $$;
72528
+ ${userGrant(`${fn("comment_page")}(uuid, timestamptz, integer, integer, uuid, boolean)`)}
72529
+
72454
72530
  -- One comment the caller reads, or null.
72455
72531
  create or replace function ${fn("get_comment")}(message uuid)
72456
72532
  returns jsonb
@@ -72547,20 +72623,46 @@ begin
72547
72623
  if v_conv is null then
72548
72624
  return '[]'::jsonb;
72549
72625
  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
- ));
72626
+ 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
72627
  end;
72561
72628
  $$;
72562
72629
  ${userGrant(`${fn("list_comments")}(${id}, text, text, timestamptz, integer, integer, uuid, boolean)`)}
72563
72630
 
72631
+ -- list_comments without any check, as the owner. Only for the app's own
72632
+ -- security definer function after it checked that the caller reads the
72633
+ -- record and holds the comment read key in its tenant. Service role only.
72634
+ create or replace function ${fn("list_comments_unchecked")}(
72635
+ tenant ${id},
72636
+ subject_type text,
72637
+ subject_id text,
72638
+ after timestamptz default null,
72639
+ max_rows integer default 100,
72640
+ skip integer default 0,
72641
+ after_id uuid default null,
72642
+ include_deleted boolean default true
72643
+ )
72644
+ returns jsonb
72645
+ language plpgsql
72646
+ ${ctx.readVolatility()}
72647
+ security definer
72648
+ set search_path = ''
72649
+ as $$
72650
+ declare
72651
+ v_conv uuid;
72652
+ v_ids uuid[];
72653
+ begin
72654
+ select c.${cv("id")} into v_conv from ${m.table("conversations")} c
72655
+ where c.${cv("tenant")} = list_comments_unchecked.tenant and c.${cv("kind")} = 'subject'
72656
+ and c.${cv("subjectType")} = list_comments_unchecked.subject_type and c.${cv("subjectId")} = list_comments_unchecked.subject_id;
72657
+ if v_conv is null then
72658
+ return '[]'::jsonb;
72659
+ end if;${readLine(ctx.read("list_comments_unchecked.subject_type", "list_comments_unchecked.subject_id", "list_comments_unchecked"))}
72660
+ v_ids := ${pageIds("v_conv", "list_comments_unchecked", "")};
72661
+ return ${commentsOf(m.fn("messaging_messages_json_unchecked"), "v_ids")};
72662
+ end;
72663
+ $$;
72664
+ ${serviceGrant(`${fn("list_comments_unchecked")}(${id}, text, text, timestamptz, integer, integer, uuid, boolean)`)}
72665
+
72564
72666
  -- The top-level comments anchored to a file, oldest first: on its pages,
72565
72667
  -- regions and moments, on any record the caller can read.
72566
72668
  create or replace function ${fn("list_file_comments")}(attachment uuid, max_rows integer default 100)
@@ -72584,8 +72686,32 @@ end;
72584
72686
  $$;
72585
72687
  ${userGrant(`${fn("list_file_comments")}(uuid, integer)`)}
72586
72688
 
72689
+ -- The number of sent, not deleted comments per conversation, as their
72690
+ -- owner, for the conversations of the list that pass the read check.
72691
+ create or replace function ${fn("comment_count_rows")}(conversations uuid[])
72692
+ returns table (id uuid, n bigint)
72693
+ language plpgsql
72694
+ stable
72695
+ security definer
72696
+ set search_path = ''
72697
+ as $$
72698
+ begin
72699
+ return query
72700
+ select x.${ms("conversation")}, count(*) from ${m.table("messages")} x
72701
+ where x.${ms("conversation")} = any (array(
72702
+ select c.${cv("id")} from ${m.table("conversations")} c
72703
+ where c.${cv("id")} = any (comment_count_rows.conversations) and c.${cv("kind")} = 'subject'
72704
+ and (${SERVICE_CALLER$1} or ${conversationReadable(mq, "c")})
72705
+ ))
72706
+ and x.${ms("sentAt")} is not null and x.${ms("deletedAt")} is null${noteReadable(mq, "x")}
72707
+ group by x.${ms("conversation")};
72708
+ end;
72709
+ $$;
72710
+ ${userGrant(`${fn("comment_count_rows")}(uuid[])`)}
72711
+
72587
72712
  -- Comments per record the caller can read, for counters in a list:
72588
- -- { subject_id: count }, deleted ones left out.
72713
+ -- { subject_id: count }, deleted ones left out. The records' conversations
72714
+ -- are read under the caller's policies, then counted by key.
72589
72715
  create or replace function ${fn("comment_counts")}(tenant ${id}, subject_type text, subject_ids text[])
72590
72716
  returns jsonb
72591
72717
  language plpgsql
@@ -72595,17 +72721,16 @@ set search_path = ''
72595
72721
  as $$
72596
72722
  begin
72597
72723
  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
72724
+ with c as materialized (
72725
+ select c.${cv("id")} as id, c.${cv("subjectId")} as subject_id
72601
72726
  from ${m.table("conversations")} c
72602
- join ${m.table("messages")} x on x.${ms("conversation")} = c.${cv("id")}
72603
72727
  where c.${cv("tenant")} = comment_counts.tenant and c.${cv("kind")} = 'subject'
72604
72728
  and c.${cv("subjectType")} = comment_counts.subject_type
72605
72729
  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
72730
+ )
72731
+ select coalesce(jsonb_object_agg(c.subject_id, n.n), '{}'::jsonb)
72732
+ from c
72733
+ join ${fn("comment_count_rows")}(array(select c.id from c)) n on n.id = c.id
72609
72734
  );
72610
72735
  end;
72611
72736
  $$;
@@ -72794,7 +72919,10 @@ const COMMENTS = {
72794
72919
  internal: [
72795
72920
  "comment_message_readable",
72796
72921
  "comments_json",
72797
- "comment_sent"
72922
+ "comment_sent",
72923
+ "comment_page",
72924
+ "comment_count_rows",
72925
+ "list_comments_unchecked"
72798
72926
  ],
72799
72927
  name: "comments",
72800
72928
  scopes: ["tenant"],
@@ -140457,6 +140585,25 @@ end;
140457
140585
  $$;
140458
140586
  ${userGrant(`${fn("purchase_invoice_approval_status")}(uuid)`)}
140459
140587
 
140588
+ -- The approval of many purchase invoices in one read, keyed by invoice id. An
140589
+ -- invoice the caller cannot read has no key.
140590
+ create or replace function ${fn("purchase_invoice_approval_statuses")}(invoice_ids uuid[])
140591
+ returns jsonb
140592
+ language plpgsql
140593
+ stable
140594
+ security definer
140595
+ set search_path = ''
140596
+ as $$
140597
+ begin
140598
+ return (
140599
+ select coalesce(jsonb_object_agg(x.${i("id")}, ${fn("invoice_approval_state")}(x.${i("id")})), '{}'::jsonb)
140600
+ from ${t("invoices")} x
140601
+ where x.${i("id")} = any (purchase_invoice_approval_statuses.invoice_ids) and ${h.can("x", n.read)}
140602
+ );
140603
+ end;
140604
+ $$;
140605
+ ${userGrant(`${fn("purchase_invoice_approval_statuses")}(uuid[])`)}
140606
+
140460
140607
  -- Approves a purchase bill at every pending level the caller is the approver
140461
140608
  -- of; the service role approves the lowest pending level for its approver.
140462
140609
  -- Needs invoices.approve and an open bill. Returns the bill with its approval.
@@ -140538,6 +140685,11 @@ function approvalContract(ctx) {
140538
140685
  args: ["uuid"],
140539
140686
  returns: "jsonb"
140540
140687
  },
140688
+ {
140689
+ name: "purchase_invoice_approval_statuses",
140690
+ args: ["uuid[]"],
140691
+ returns: "jsonb"
140692
+ },
140541
140693
  {
140542
140694
  name: "approve_purchase_invoice",
140543
140695
  args: ["uuid", "text"],
@@ -160945,20 +161097,20 @@ function messagesJson(q) {
160945
161097
  const at = ctx.of("attachments");
160946
161098
  const a = (column) => at.col("attachments", column);
160947
161099
  return `,
160948
- f as (
161100
+ f as materialized (
160949
161101
  select coalesce(jsonb_object_agg(g.id, g.files), '{}'::jsonb) as files
160950
161102
  from (
160951
161103
  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
161104
  from ${at.table("attachments")} a
160953
161105
  where a.${a("subjectType")} = ${message}
160954
- and a.${a("subjectId")} = any (array(select x::text from unnest(messaging_messages_json.ids) x))
161106
+ and a.${a("subjectId")} = any (array(select x.${ms("id")}::text from page_rows x))
160955
161107
  and a.${a("status")} <> 'infected'
160956
161108
  group by a.${a("subjectId")}
160957
161109
  ) g
160958
161110
  )`;
160959
161111
  })() : "";
160960
161112
  const reactions = ctx.installed("reactions") ? `,
160961
- r as (
161113
+ r as materialized (
160962
161114
  select coalesce(jsonb_object_agg(g.tenant, ${ctx.of("reactions").fn("reaction_summary")}(g.tenant, ${message}, g.ids)), '{}'::jsonb) as reactions
160963
161115
  from (
160964
161116
  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 +161128,38 @@ function messagesJson(q) {
160976
161128
  ...files ? ["f"] : [],
160977
161129
  ...reactions ? ["r"] : []
160978
161130
  ].join(", ");
161131
+ const cv = q.cols("conversations");
161132
+ const select = (rows, ids) => ` with ${rows}${authors ? `,\n a as materialized (select ${authors.call(ids)} as authors)` : ""}${files}${reactions}
161133
+ 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)
161134
+ from ${from}`;
160979
161135
  return `${authors?.sql ?? ""}
160980
161136
 
161137
+ -- The messages of ids the caller may read, as their owner: each distinct
161138
+ -- conversation of ids is checked once, so a read never weighs every
161139
+ -- conversation the caller can see. A sent message shows to the
161140
+ -- conversation's readers, an unsent one to its author.
161141
+ create or replace function ${fn("messaging_message_rows")}(ids uuid[])
161142
+ returns setof ${t("messages")}
161143
+ language sql
161144
+ stable
161145
+ security definer
161146
+ set search_path = ''
161147
+ as $$
161148
+ select m.* from ${t("messages")} m
161149
+ where m.${ms("id")} = any (messaging_message_rows.ids)
161150
+ and m.${ms("conversation")} = any (array(
161151
+ select c.${cv("id")} from ${t("conversations")} c
161152
+ where c.${cv("id")} = any (array(select distinct v.${ms("conversation")} from ${t("messages")} v where v.${ms("id")} = any (messaging_message_rows.ids)))
161153
+ and (${q.service} or ${conversationReadable(q, "c")})
161154
+ ))
161155
+ and (${q.service} or ((m.${ms("sentAt")} is not null or m.${ms("author")} = (select auth.uid()))${noteReadable(q, "m")}))
161156
+ $$;
161157
+ ${userGrant(`${fn("messaging_message_rows")}(uuid[])`)}
161158
+
160981
161159
  -- The messages of ids the caller may read, oldest first, each with its
160982
- -- author, files and reactions when those modules are installed.
161160
+ -- author, files and reactions when those modules are installed. The rows
161161
+ -- come from messaging_message_rows, and the conversations they belong to
161162
+ -- are read once more under the caller's policies.
160983
161163
  create or replace function ${fn("messaging_messages_json")}(ids uuid[])
160984
161164
  returns jsonb
160985
161165
  language sql
@@ -160987,13 +161167,35 @@ stable
160987
161167
  security invoker
160988
161168
  set search_path = ''
160989
161169
  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}
161170
+ ${select(`checked as materialized (
161171
+ select m.* from ${fn("messaging_message_rows")}(messaging_messages_json.ids) m
161172
+ ),
161173
+ page_rows as (
161174
+ select k.* from checked k
161175
+ where k.${ms("conversation")} = any (array(
161176
+ select c.${cv("id")} from ${t("conversations")} c
161177
+ where c.${cv("id")} = any (array(select distinct v.${ms("conversation")} from checked v))
161178
+ ))
161179
+ )`, "messaging_messages_json.ids")}
161180
+ $$;
161181
+ ${userGrant(`${fn("messaging_messages_json")}(uuid[])`)}
161182
+
161183
+ -- messaging_messages_json without any access check, for a security definer
161184
+ -- function that has already checked the caller reads every conversation of
161185
+ -- ids. Never grant it to anon or authenticated: it returns any message,
161186
+ -- sent or not, with its files and reactions.
161187
+ create or replace function ${fn("messaging_messages_json_unchecked")}(ids uuid[])
161188
+ returns jsonb
161189
+ language sql
161190
+ stable
161191
+ security definer
161192
+ set search_path = ''
161193
+ as $$
161194
+ ${select(`page_rows as (
161195
+ select m.* from ${t("messages")} m where m.${ms("id")} = any (messaging_messages_json_unchecked.ids)
161196
+ )`, "messaging_messages_json_unchecked.ids")}
160995
161197
  $$;
160996
- ${userGrant(`${fn("messaging_messages_json")}(uuid[])`)}`;
161198
+ ${serviceGrant(`${fn("messaging_messages_json_unchecked")}(uuid[])`)}`;
160997
161199
  }
160998
161200
  /**
160999
161201
  * The service-role notifications and the event of a message once it is sent:
@@ -161288,11 +161490,7 @@ as $$
161288
161490
  select case when not coalesce(${ctx.of("subjects").fn("can_subject")}(list_record_mentions.subject_type, list_record_mentions.subject_id, 'read'), false)
161289
161491
  then '[]'::jsonb
161290
161492
  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 (
161493
+ with p as materialized (
161296
161494
  select x.${rm("message")} as message, x.${rm("conversation")} as conversation, x.${rm("createdAt")} as created_at
161297
161495
  from ${t("recordMentions")} x
161298
161496
  where x.${rm("subjectType")} = list_record_mentions.subject_type and x.${rm("subjectId")} = list_record_mentions.subject_id
@@ -161300,8 +161498,17 @@ as $$
161300
161498
  or (x.${rm("createdAt")}, x.${rm("message")}) < (list_record_mentions.before, coalesce(list_record_mentions.before_id, ${MAX_UUID})))
161301
161499
  order by x.${rm("createdAt")} desc, x.${rm("message")} desc
161302
161500
  limit ${pageSize("list_record_mentions.max_rows", 20, 100)}
161303
- ) p
161501
+ ),
161502
+ j as materialized (
161503
+ select e.row from jsonb_array_elements(${fn("messaging_messages_json")}(array(select p.message from p))) e(row)
161504
+ )
161505
+ select jsonb_agg(jsonb_build_object(
161506
+ 'message', j.row,
161507
+ '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")})
161508
+ ) order by p.created_at desc, p.message desc)
161509
+ from p
161304
161510
  join ${t("conversations")} c on c.${cv("id")} = p.conversation
161511
+ left join j on (j.row ->> ${sqlString(ms("id").replaceAll("\"", ""))})::uuid = p.message
161305
161512
  ), '[]'::jsonb)
161306
161513
  end
161307
161514
  $$;
@@ -162043,6 +162250,8 @@ const MESSAGING = {
162043
162250
  "is_conversation_member",
162044
162251
  "conversation_topic_allowed",
162045
162252
  "messaging_messages_json",
162253
+ "messaging_message_rows",
162254
+ "messaging_messages_json_unchecked",
162046
162255
  "message_authors",
162047
162256
  "parse_mentions",
162048
162257
  "index_record_mentions"
@@ -1,6 +1,6 @@
1
1
  import { c as LocalTablesOption, n as DataEngine, s as LiveEngineOptions } from "../data-engine-CQiEEoNx.js";
2
2
  import { Vt as Executor } from "../types-BJ4cg51a.js";
3
- import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-Dp4A_McY.js";
3
+ import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-CTuilcgE.js";
4
4
  /** A SQLite database that may report which tables changed. */
5
5
  interface ChangingSqliteDatabase extends SqliteDatabaseLike {
6
6
  onChange?(handler: {
@@ -1,5 +1,5 @@
1
1
  import { i as localEngine } from "../data-engine-MRAlinsa.js";
2
- import { i as checkSqlite, r as sqliteExecutor, t as fromSqliteError } from "../executor-BmcRcw83.js";
2
+ import { i as checkSqlite, r as sqliteExecutor, t as fromSqliteError } from "../executor-Bot0tkvU.js";
3
3
  // src/sqlite/engine.ts
4
4
  /**
5
5
  * A UUID v4 from SQLite's `randomblob`, for runtimes without