better-supabase 0.52.0 → 0.53.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 (813) hide show
  1. package/dist/{access-sql-DVntbgJf.js → access-sql-DH2LbcQe.js} +2 -1
  2. package/dist/{adapter-iCMh_XnC.js → adapter-CJa5ys5O.js} +46 -11
  3. package/dist/{agents-C_VAKJ_s.d.ts → agents-BrLBg0gC.d.ts} +2 -2
  4. package/dist/{agents-CkRsaxAr.js → agents-CEna9P0O.js} +1 -1
  5. package/dist/{ai-cache-DV8O7Kav.js → ai-cache-CqNHapwf.js} +1 -1
  6. package/dist/{ai-files-BD6YE9TZ.js → ai-files-C8n2QKlX.js} +1 -1
  7. package/dist/{ai-schedules-BMM-ZHOC.d.ts → ai-schedules-Dfbcor59.d.ts} +1 -1
  8. package/dist/ai-sdk/agents/index.d.ts +1 -1
  9. package/dist/ai-sdk/agents/index.js +1 -1
  10. package/dist/ai-sdk/cache/index.js +1 -1
  11. package/dist/ai-sdk/embeddings/index.js +1 -1
  12. package/dist/ai-sdk/files/index.js +1 -1
  13. package/dist/ai-sdk/workflow/index.d.ts +1 -1
  14. package/dist/ai-sdk/workflow/index.js +1 -1
  15. package/dist/{api-YjQpioTT.d.ts → api-CGYctFBt.d.ts} +1 -1
  16. package/dist/{api-keys-mfwDRWHv.d.ts → api-keys-COJAXdGF.d.ts} +1 -1
  17. package/dist/{app-tables-D2uN1feV.d.ts → app-tables-CZLNOXeA.d.ts} +1 -1
  18. package/dist/{approvals-BSweHvij.js → approvals-DCLl96Xf.js} +1 -1
  19. package/dist/astro/index.d.ts +3 -3
  20. package/dist/astro/index.js +2 -2
  21. package/dist/{attachments-DqQ61LfS.js → attachments-Djs8uyat.js} +1 -1
  22. package/dist/{auth-reply-CgXF76sz.js → auth-reply-CimDH13K.js} +4 -1
  23. package/dist/{authorization-hk0TAA6-.d.ts → authorization-UYejwQsk.d.ts} +70 -9
  24. package/dist/{automations-CrdULEET.js → automations-DChuvKPy.js} +1 -1
  25. package/dist/better-result/index.d.ts +2 -2
  26. package/dist/{bind-CEN9Us3B.d.ts → bind-D4qLTlY4.d.ts} +11 -7
  27. package/dist/{block-env-CvQj4rbD.d.ts → block-env-BLBr90is.d.ts} +4 -4
  28. package/dist/{block-hooks-BIRJauOk.js → block-hooks-Bd5bRM9B.js} +1 -0
  29. package/dist/{block-subjects-SKkp3d_Q.js → block-subjects-Cvd-RaMY.js} +2 -2
  30. package/dist/{block-tables-BR6Ckm_1.d.ts → block-tables-BkgafSZd.d.ts} +1 -1
  31. package/dist/blocks/access-requests/index.d.ts +1 -1
  32. package/dist/blocks/access-requests/index.js +10 -10
  33. package/dist/blocks/accounting/index.d.ts +1 -1
  34. package/dist/blocks/accounting/index.js +2 -2
  35. package/dist/blocks/acknowledgements/index.d.ts +1 -1
  36. package/dist/blocks/acknowledgements/index.js +1 -1
  37. package/dist/blocks/activities/index.d.ts +2 -2
  38. package/dist/blocks/activities/index.js +2 -2
  39. package/dist/blocks/advisories/index.d.ts +1 -1
  40. package/dist/blocks/advisories/index.js +16 -16
  41. package/dist/blocks/agent-checkout/index.d.ts +1 -1
  42. package/dist/blocks/agent-checkout/index.js +11 -11
  43. package/dist/blocks/agents/index.d.ts +1 -1
  44. package/dist/blocks/agents/index.js +11 -11
  45. package/dist/blocks/ai-cache/index.d.ts +1 -1
  46. package/dist/blocks/ai-cache/index.js +3 -3
  47. package/dist/blocks/ai-chat/index.d.ts +1 -1
  48. package/dist/blocks/ai-chat/index.js +10 -10
  49. package/dist/blocks/ai-evals/index.d.ts +1 -1
  50. package/dist/blocks/ai-evals/index.js +3 -3
  51. package/dist/blocks/ai-files/index.d.ts +1 -1
  52. package/dist/blocks/ai-files/index.js +3 -3
  53. package/dist/blocks/ai-guardrails/index.d.ts +1 -1
  54. package/dist/blocks/ai-guardrails/index.js +5 -5
  55. package/dist/blocks/ai-keys/index.d.ts +1 -1
  56. package/dist/blocks/ai-keys/index.js +8 -8
  57. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  58. package/dist/blocks/ai-schedules/index.js +3 -3
  59. package/dist/blocks/announcements/index.d.ts +4 -4
  60. package/dist/blocks/announcements/index.js +8 -8
  61. package/dist/blocks/api-keys/index.d.ts +2 -2
  62. package/dist/blocks/api-keys/index.js +1 -1
  63. package/dist/blocks/appraisals/index.d.ts +1 -1
  64. package/dist/blocks/appraisals/index.js +12 -12
  65. package/dist/blocks/approvals/index.d.ts +1 -1
  66. package/dist/blocks/approvals/index.js +2 -2
  67. package/dist/blocks/assets/index.d.ts +2 -2
  68. package/dist/blocks/assets/index.js +2 -2
  69. package/dist/blocks/assignment/index.d.ts +1 -1
  70. package/dist/blocks/assignment/index.js +2 -2
  71. package/dist/blocks/attachments/index.d.ts +5 -5
  72. package/dist/blocks/attachments/index.js +2 -2
  73. package/dist/blocks/audit/index.d.ts +2 -2
  74. package/dist/blocks/audit/index.js +1 -1
  75. package/dist/blocks/automations/index.d.ts +3 -3
  76. package/dist/blocks/automations/index.js +12 -12
  77. package/dist/blocks/banking/index.d.ts +1 -1
  78. package/dist/blocks/banking/index.js +2 -2
  79. package/dist/blocks/billable-time/index.d.ts +1 -1
  80. package/dist/blocks/billable-time/index.js +2 -2
  81. package/dist/blocks/billing/index.d.ts +3 -3
  82. package/dist/blocks/billing/index.js +1 -1
  83. package/dist/blocks/bookings/index.d.ts +2 -2
  84. package/dist/blocks/bookings/index.js +1 -1
  85. package/dist/blocks/bulk/index.d.ts +1 -1
  86. package/dist/blocks/bulk/index.js +5 -5
  87. package/dist/blocks/calendar/index.d.ts +3 -3
  88. package/dist/blocks/calendar/index.js +1 -1
  89. package/dist/blocks/care/index.d.ts +27 -27
  90. package/dist/blocks/care/index.js +37 -46
  91. package/dist/blocks/care-plans/index.d.ts +3 -3
  92. package/dist/blocks/care-plans/index.js +2 -2
  93. package/dist/blocks/cases/index.d.ts +3 -3
  94. package/dist/blocks/cases/index.js +2 -2
  95. package/dist/blocks/catalog/index.d.ts +2 -2
  96. package/dist/blocks/catalog/index.js +2 -2
  97. package/dist/blocks/channels/index.d.ts +1 -1
  98. package/dist/blocks/channels/index.js +7 -7
  99. package/dist/blocks/clinical-decision-support/index.d.ts +1 -1
  100. package/dist/blocks/clinical-decision-support/index.js +11 -11
  101. package/dist/blocks/cms/index.d.ts +5 -5
  102. package/dist/blocks/cms/index.js +7 -7
  103. package/dist/blocks/collaboration/index.d.ts +6 -6
  104. package/dist/blocks/collaboration/index.js +8 -8
  105. package/dist/blocks/collections/index.d.ts +1 -1
  106. package/dist/blocks/collections/index.js +10 -10
  107. package/dist/blocks/comments/index.d.ts +2 -2
  108. package/dist/blocks/comments/index.js +1 -1
  109. package/dist/blocks/commerce/index.d.ts +5 -5
  110. package/dist/blocks/commerce/index.js +7 -7
  111. package/dist/blocks/commissions/index.d.ts +1 -1
  112. package/dist/blocks/commissions/index.js +11 -11
  113. package/dist/blocks/compliance/index.d.ts +1 -1
  114. package/dist/blocks/compliance/index.js +11 -11
  115. package/dist/blocks/connectors/index.d.ts +1 -1
  116. package/dist/blocks/connectors/index.js +11 -11
  117. package/dist/blocks/consents/index.d.ts +2 -2
  118. package/dist/blocks/consents/index.js +2 -2
  119. package/dist/blocks/contacts/index.d.ts +2 -2
  120. package/dist/blocks/contacts/index.js +2 -2
  121. package/dist/blocks/content/index.d.ts +2 -2
  122. package/dist/blocks/content/index.js +2 -2
  123. package/dist/blocks/contracts/index.d.ts +1 -1
  124. package/dist/blocks/contracts/index.js +12 -12
  125. package/dist/blocks/courses/index.d.ts +3 -3
  126. package/dist/blocks/courses/index.js +2 -2
  127. package/dist/blocks/created-by/index.d.ts +2 -2
  128. package/dist/blocks/created-by/index.js +2 -2
  129. package/dist/blocks/crm/index.d.ts +17 -17
  130. package/dist/blocks/crm/index.js +19 -19
  131. package/dist/blocks/custom-fields/index.d.ts +1 -1
  132. package/dist/blocks/custom-fields/index.js +11 -11
  133. package/dist/blocks/dam/index.d.ts +2 -2
  134. package/dist/blocks/dam/index.js +11 -11
  135. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  136. package/dist/blocks/data-lifecycle/index.js +1 -1
  137. package/dist/blocks/deals/index.d.ts +1 -1
  138. package/dist/blocks/deals/index.js +2 -2
  139. package/dist/blocks/dispatch/index.d.ts +2 -2
  140. package/dist/blocks/dispatch/index.js +2 -2
  141. package/dist/blocks/document-templates/index.d.ts +1 -1
  142. package/dist/blocks/document-templates/index.js +10 -10
  143. package/dist/blocks/documents/index.d.ts +1 -1
  144. package/dist/blocks/documents/index.js +9 -9
  145. package/dist/blocks/domains/index.d.ts +1 -1
  146. package/dist/blocks/domains/index.js +10 -10
  147. package/dist/blocks/donations/index.d.ts +1 -1
  148. package/dist/blocks/donations/index.js +12 -12
  149. package/dist/blocks/drive/index.d.ts +5 -5
  150. package/dist/blocks/drive/index.js +4 -4
  151. package/dist/blocks/e-prescribing/index.d.ts +1 -1
  152. package/dist/blocks/e-prescribing/index.js +11 -11
  153. package/dist/blocks/employees/index.d.ts +1 -1
  154. package/dist/blocks/employees/index.js +2 -2
  155. package/dist/blocks/enrichment/index.d.ts +1 -1
  156. package/dist/blocks/enrichment/index.js +2 -2
  157. package/dist/blocks/enrollments/index.d.ts +2 -2
  158. package/dist/blocks/enrollments/index.js +2 -2
  159. package/dist/blocks/entitlements/index.d.ts +3 -3
  160. package/dist/blocks/entitlements/index.js +2 -2
  161. package/dist/blocks/events/index.d.ts +3 -3
  162. package/dist/blocks/events/index.js +5 -5
  163. package/dist/blocks/expenses/index.d.ts +1 -1
  164. package/dist/blocks/expenses/index.js +18 -18
  165. package/dist/blocks/field-history/index.d.ts +1 -1
  166. package/dist/blocks/field-history/index.js +2 -2
  167. package/dist/blocks/filespace/index.d.ts +8 -8
  168. package/dist/blocks/filespace/index.js +9 -9
  169. package/dist/blocks/finance/index.d.ts +5 -5
  170. package/dist/blocks/finance/index.js +7 -7
  171. package/dist/blocks/flags/index.d.ts +1 -1
  172. package/dist/blocks/flags/index.js +9 -9
  173. package/dist/blocks/forecasts/index.d.ts +1 -1
  174. package/dist/blocks/forecasts/index.js +2 -2
  175. package/dist/blocks/forms/index.d.ts +3 -3
  176. package/dist/blocks/forms/index.js +1 -1
  177. package/dist/blocks/funding/index.d.ts +2 -2
  178. package/dist/blocks/funding/index.js +2 -2
  179. package/dist/blocks/goals/index.d.ts +1 -1
  180. package/dist/blocks/goals/index.js +2 -2
  181. package/dist/blocks/governance/index.d.ts +4 -4
  182. package/dist/blocks/governance/index.js +6 -6
  183. package/dist/blocks/guests/index.d.ts +1 -1
  184. package/dist/blocks/guests/index.js +2 -2
  185. package/dist/blocks/hiring/index.d.ts +1 -1
  186. package/dist/blocks/hiring/index.js +2 -2
  187. package/dist/blocks/identities/index.d.ts +1 -1
  188. package/dist/blocks/identities/index.js +3 -3
  189. package/dist/blocks/imports/index.d.ts +2 -2
  190. package/dist/blocks/imports/index.js +8 -8
  191. package/dist/blocks/inbox/index.d.ts +6 -6
  192. package/dist/blocks/inbox/index.js +1 -1
  193. package/dist/blocks/incidents/index.d.ts +1 -1
  194. package/dist/blocks/incidents/index.js +12 -12
  195. package/dist/blocks/index.d.ts +6 -6
  196. package/dist/blocks/index.js +8 -7
  197. package/dist/blocks/inspections/index.d.ts +2 -2
  198. package/dist/blocks/inspections/index.js +19 -19
  199. package/dist/blocks/inventory/index.d.ts +1 -1
  200. package/dist/blocks/inventory/index.js +2 -2
  201. package/dist/blocks/invoices/index.d.ts +1 -1
  202. package/dist/blocks/invoices/index.js +2 -2
  203. package/dist/blocks/knowledge/index.d.ts +1 -1
  204. package/dist/blocks/knowledge/index.js +2 -2
  205. package/dist/blocks/lead-scoring/index.d.ts +2 -2
  206. package/dist/blocks/lead-scoring/index.js +2 -2
  207. package/dist/blocks/learning/index.d.ts +3 -3
  208. package/dist/blocks/learning/index.js +5 -5
  209. package/dist/blocks/leases/index.d.ts +1 -1
  210. package/dist/blocks/leases/index.js +11 -11
  211. package/dist/blocks/leave/index.d.ts +1 -1
  212. package/dist/blocks/leave/index.js +2 -2
  213. package/dist/blocks/ledger/index.d.ts +1 -1
  214. package/dist/blocks/ledger/index.js +12 -12
  215. package/dist/blocks/legal-entities/index.d.ts +2 -2
  216. package/dist/blocks/legal-entities/index.js +7 -7
  217. package/dist/blocks/lims/index.d.ts +2 -2
  218. package/dist/blocks/lims/index.js +14 -14
  219. package/dist/blocks/mail-sync/index.d.ts +3 -3
  220. package/dist/blocks/mail-sync/index.js +2 -2
  221. package/dist/blocks/maintenance/index.d.ts +2 -2
  222. package/dist/blocks/maintenance/index.js +2 -2
  223. package/dist/blocks/manufacturing/index.d.ts +2 -2
  224. package/dist/blocks/manufacturing/index.js +9 -9
  225. package/dist/blocks/medications/index.d.ts +1 -1
  226. package/dist/blocks/medications/index.js +2 -2
  227. package/dist/blocks/meetings/index.d.ts +3 -3
  228. package/dist/blocks/meetings/index.js +2 -2
  229. package/dist/blocks/memberships/index.d.ts +2 -2
  230. package/dist/blocks/memberships/index.js +2 -2
  231. package/dist/blocks/memory/index.d.ts +1 -1
  232. package/dist/blocks/memory/index.js +4 -4
  233. package/dist/blocks/messaging/index.d.ts +5 -5
  234. package/dist/blocks/messaging/index.js +14 -14
  235. package/dist/blocks/metrics/index.d.ts +1 -1
  236. package/dist/blocks/metrics/index.js +3 -3
  237. package/dist/blocks/mfa/index.d.ts +2 -2
  238. package/dist/blocks/mfa/index.js +3 -3
  239. package/dist/blocks/moderation/index.d.ts +2 -2
  240. package/dist/blocks/moderation/index.js +14 -14
  241. package/dist/blocks/notifications/index.d.ts +5 -5
  242. package/dist/blocks/notifications/index.js +2 -2
  243. package/dist/blocks/numbering/index.d.ts +1 -1
  244. package/dist/blocks/numbering/index.js +1 -1
  245. package/dist/blocks/oauth-server/index.d.ts +1 -1
  246. package/dist/blocks/oauth-server/index.js +9 -9
  247. package/dist/blocks/observations/index.d.ts +2 -2
  248. package/dist/blocks/observations/index.js +2 -2
  249. package/dist/blocks/onboarding/index.d.ts +2 -2
  250. package/dist/blocks/onboarding/index.js +1 -1
  251. package/dist/blocks/orders/index.d.ts +1 -1
  252. package/dist/blocks/orders/index.js +2 -2
  253. package/dist/blocks/organizations/index.d.ts +2 -2
  254. package/dist/blocks/organizations/index.js +3 -3
  255. package/dist/blocks/outbox/index.d.ts +1 -1
  256. package/dist/blocks/outbox/index.js +1 -1
  257. package/dist/blocks/passes/index.d.ts +2 -2
  258. package/dist/blocks/passes/index.js +2 -2
  259. package/dist/blocks/payroll-export/index.d.ts +2 -2
  260. package/dist/blocks/payroll-export/index.js +2 -2
  261. package/dist/blocks/people/index.d.ts +7 -7
  262. package/dist/blocks/people/index.js +9 -9
  263. package/dist/blocks/periods/index.d.ts +1 -1
  264. package/dist/blocks/periods/index.js +9 -9
  265. package/dist/blocks/permissions/index.d.ts +3 -3
  266. package/dist/blocks/permissions/index.js +3 -3
  267. package/dist/blocks/pipelines/index.d.ts +1 -1
  268. package/dist/blocks/pipelines/index.js +2 -2
  269. package/dist/blocks/posts/index.d.ts +2 -2
  270. package/dist/blocks/posts/index.js +13 -13
  271. package/dist/blocks/procurement/index.d.ts +5 -5
  272. package/dist/blocks/procurement/index.js +7 -7
  273. package/dist/blocks/profiles/index.d.ts +1 -1
  274. package/dist/blocks/profiles/index.js +2 -2
  275. package/dist/blocks/projects/index.d.ts +7 -7
  276. package/dist/blocks/projects/index.js +9 -9
  277. package/dist/blocks/promotions/index.d.ts +1 -1
  278. package/dist/blocks/promotions/index.js +2 -2
  279. package/dist/blocks/prompts/index.d.ts +1 -1
  280. package/dist/blocks/prompts/index.js +3 -3
  281. package/dist/blocks/push/index.d.ts +2 -2
  282. package/dist/blocks/push/index.js +7 -7
  283. package/dist/blocks/qualifications/index.d.ts +2 -2
  284. package/dist/blocks/qualifications/index.js +2 -2
  285. package/dist/blocks/queue/index.d.ts +2 -2
  286. package/dist/blocks/queue/index.js +2 -2
  287. package/dist/blocks/quotes/index.d.ts +1 -1
  288. package/dist/blocks/quotes/index.js +2 -2
  289. package/dist/blocks/rank/index.d.ts +1 -1
  290. package/dist/blocks/rank/index.js +3 -3
  291. package/dist/blocks/reactions/index.d.ts +4 -4
  292. package/dist/blocks/reactions/index.js +1 -1
  293. package/dist/blocks/recruiting/index.d.ts +4 -4
  294. package/dist/blocks/recruiting/index.js +6 -6
  295. package/dist/blocks/referrals/index.d.ts +1 -1
  296. package/dist/blocks/referrals/index.js +10 -10
  297. package/dist/blocks/relations/index.d.ts +1 -1
  298. package/dist/blocks/relations/index.js +8 -8
  299. package/dist/blocks/reminders/index.d.ts +1 -1
  300. package/dist/blocks/reminders/index.js +1 -1
  301. package/dist/blocks/reviews/index.d.ts +1 -1
  302. package/dist/blocks/reviews/index.js +10 -10
  303. package/dist/blocks/rfqs/index.d.ts +2 -2
  304. package/dist/blocks/rfqs/index.js +2 -2
  305. package/dist/blocks/risks/index.d.ts +2 -2
  306. package/dist/blocks/risks/index.js +14 -14
  307. package/dist/blocks/saas/index.d.ts +13 -13
  308. package/dist/blocks/saas/index.js +14 -14
  309. package/dist/blocks/sales/index.d.ts +1 -1
  310. package/dist/blocks/sales/index.js +1 -1
  311. package/dist/blocks/saved-views/index.d.ts +3 -3
  312. package/dist/blocks/saved-views/index.js +8 -8
  313. package/dist/blocks/scheduling/index.d.ts +4 -4
  314. package/dist/blocks/scheduling/index.js +6 -6
  315. package/dist/blocks/scores/index.d.ts +2 -2
  316. package/dist/blocks/scores/index.js +10 -10
  317. package/dist/blocks/search/index.d.ts +3 -3
  318. package/dist/blocks/search/index.js +1 -1
  319. package/dist/blocks/security-events/index.d.ts +1 -1
  320. package/dist/blocks/security-events/index.js +8 -8
  321. package/dist/blocks/segments/index.d.ts +2 -2
  322. package/dist/blocks/segments/index.js +2 -2
  323. package/dist/blocks/sequences/index.d.ts +3 -3
  324. package/dist/blocks/sequences/index.js +2 -2
  325. package/dist/blocks/service/index.d.ts +7 -7
  326. package/dist/blocks/service/index.js +9 -9
  327. package/dist/blocks/service-accounts/index.d.ts +1 -1
  328. package/dist/blocks/service-accounts/index.js +8 -8
  329. package/dist/blocks/sessions/index.d.ts +2 -2
  330. package/dist/blocks/sessions/index.js +4 -4
  331. package/dist/blocks/settings/index.d.ts +2 -2
  332. package/dist/blocks/settings/index.js +2 -2
  333. package/dist/blocks/share-links/index.d.ts +1 -1
  334. package/dist/blocks/share-links/index.js +1 -1
  335. package/dist/blocks/shifts/index.d.ts +2 -2
  336. package/dist/blocks/shifts/index.js +2 -2
  337. package/dist/blocks/shipments/index.d.ts +2 -2
  338. package/dist/blocks/shipments/index.js +10 -10
  339. package/dist/blocks/signatures/index.d.ts +2 -2
  340. package/dist/blocks/signatures/index.js +1 -1
  341. package/dist/blocks/signing-keys/index.d.ts +1 -1
  342. package/dist/blocks/signing-keys/index.js +7 -7
  343. package/dist/blocks/sla/index.d.ts +1 -1
  344. package/dist/blocks/sla/index.js +2 -2
  345. package/dist/blocks/sso/index.d.ts +2 -2
  346. package/dist/blocks/sso/index.js +20 -20
  347. package/dist/blocks/state-machine/index.d.ts +1 -1
  348. package/dist/blocks/state-machine/index.js +1 -1
  349. package/dist/blocks/subjects/index.d.ts +2 -2
  350. package/dist/blocks/subjects/index.js +1 -1
  351. package/dist/blocks/support/index.d.ts +5 -5
  352. package/dist/blocks/support/index.js +7 -7
  353. package/dist/blocks/tags/index.d.ts +2 -2
  354. package/dist/blocks/tags/index.js +1 -1
  355. package/dist/blocks/tasks/index.d.ts +2 -2
  356. package/dist/blocks/tasks/index.js +2 -2
  357. package/dist/blocks/tax/index.d.ts +2 -2
  358. package/dist/blocks/tax/index.js +2 -2
  359. package/dist/blocks/teams/index.d.ts +1 -1
  360. package/dist/blocks/teams/index.js +1 -1
  361. package/dist/blocks/templates/index.d.ts +1 -1
  362. package/dist/blocks/templates/index.js +7 -7
  363. package/dist/blocks/tills/index.d.ts +1 -1
  364. package/dist/blocks/tills/index.js +12 -12
  365. package/dist/blocks/time-tracking/index.d.ts +2 -2
  366. package/dist/blocks/time-tracking/index.js +1 -1
  367. package/dist/blocks/timeline/index.d.ts +1 -1
  368. package/dist/blocks/timeline/index.js +1 -1
  369. package/dist/blocks/trash/index.d.ts +1 -1
  370. package/dist/blocks/trash/index.js +1 -1
  371. package/dist/blocks/undo/index.d.ts +2 -2
  372. package/dist/blocks/undo/index.js +3 -3
  373. package/dist/blocks/updated-at/index.d.ts +2 -2
  374. package/dist/blocks/updated-at/index.js +2 -2
  375. package/dist/blocks/usage/index.d.ts +2 -2
  376. package/dist/blocks/usage/index.js +3 -3
  377. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  378. package/dist/blocks/vercel-marketplace/index.js +9 -9
  379. package/dist/blocks/versions/index.d.ts +1 -1
  380. package/dist/blocks/versions/index.js +1 -1
  381. package/dist/blocks/waitlist/index.d.ts +1 -1
  382. package/dist/blocks/waitlist/index.js +10 -10
  383. package/dist/blocks/warehouse/index.d.ts +1 -1
  384. package/dist/blocks/warehouse/index.js +12 -12
  385. package/dist/blocks/webhooks/index.d.ts +2 -2
  386. package/dist/blocks/webhooks/index.js +19 -19
  387. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  388. package/dist/blocks/workflow-editor/index.js +7 -7
  389. package/dist/blocks/workflows/index.d.ts +4 -4
  390. package/dist/blocks/workflows/index.js +8 -8
  391. package/dist/{blocks-C_ArClZU.d.ts → blocks-EFj0duwB.d.ts} +18 -5
  392. package/dist/{build-k56UjnbK.js → build-OCuu29wd.js} +1 -0
  393. package/dist/{cache-tags-JJWT0mkn.d.ts → cache-tags-TT8h2zMg.d.ts} +1 -1
  394. package/dist/claims/index.d.ts +3 -3
  395. package/dist/cli/{account-CBDO_E5S.js → account-C1vKOJOX.js} +1 -1
  396. package/dist/cli/{account-D7bjOpRN.js → account-MSvhufSp.js} +1 -1
  397. package/dist/cli/{add-7mEozwbY.js → add-C3yGPSQS.js} +14 -14
  398. package/dist/cli/add-C4B2wdfz.js +1 -0
  399. package/dist/cli/{add-Cn03PJzF.js → add-DlucpPCL.js} +4 -4
  400. package/dist/cli/{app-table-files-C50U5rM-.js → app-table-files-CC5n8Si8.js} +4 -4
  401. package/dist/cli/{app-tables-CvY1qzV7.js → app-tables-C-Rk_GnI.js} +3 -3
  402. package/dist/cli/{authorization-DJkkOjjG.js → authorization-DAYgx04b.js} +3 -1
  403. package/dist/cli/{automations-Mx4gbtJf.js → automations-0G37FqXw.js} +1 -1
  404. package/dist/cli/{backfill-D8xu2ME9.js → backfill-DbqA8coR.js} +4 -4
  405. package/dist/cli/bin.js +1 -1
  406. package/dist/cli/{blocks-C-bZ2mX9.js → blocks-BBBpNbQD.js} +1 -1
  407. package/dist/cli/{blocks-CFYBoQVe.js → blocks-BFlOktiM.js} +3 -3
  408. package/dist/cli/{cache-vvJW9h-r.js → cache-BgNWPD9a.js} +1 -1
  409. package/dist/cli/{codemod-CR3I3yN9.js → codemod-B4DpCiqX.js} +34 -4
  410. package/dist/cli/{command-CJomeJg-.js → command-CLvgELKk.js} +6 -0
  411. package/dist/cli/{completion-BbBXWoj-.js → completion-BrARDcFB.js} +1 -1
  412. package/dist/cli/{completion-CxG9ycKP.js → completion-CifzoO8f.js} +2 -2
  413. package/dist/cli/{completion-CN2g0Fy_.js → completion-Q1M-cdP-.js} +2 -2
  414. package/dist/cli/{config-CP9zs7sG.js → config-COfXd-G3.js} +1 -1
  415. package/dist/cli/{config-C0aclGpw.js → config-FN5Cp861.js} +30 -5
  416. package/dist/cli/{config-BxiYiAN6.js → config-U32Vo0h6.js} +1 -1
  417. package/dist/cli/{content-mapper-BPtXLD3N.js → content-mapper-BaJhpTQA.js} +2 -2
  418. package/dist/cli/{db-kIWj4SJu.js → db-T8u160uM.js} +3 -3
  419. package/dist/cli/{doctor-0vyTC81z.js → doctor-Dnq5J_p_.js} +293 -103
  420. package/dist/cli/env-BMQqBhS_.js +1 -0
  421. package/dist/cli/{env-D8ndoCoC.js → env-G6fCEgJi.js} +1 -1
  422. package/dist/cli/{gen-CxJYiySd.js → gen-Bf9cVgpR.js} +16 -16
  423. package/dist/cli/index.d.ts +18 -1
  424. package/dist/cli/index.js +9 -9
  425. package/dist/cli/{init-CHBWJGSc.js → init-_IFg5fe6.js} +11 -11
  426. package/dist/cli/{keys-DjNcartA.js → keys-BnVLA3NK.js} +1 -1
  427. package/dist/cli/{live-De6AKObd.js → live-pq1yvvsl.js} +2 -2
  428. package/dist/cli/{mcp-Bw7PKU4b.js → mcp-YD0Ap6ok.js} +3 -3
  429. package/dist/cli/{metadata-BRrfdS8c.js → metadata-CfauXPW0.js} +3 -3
  430. package/dist/cli/{migrate-CR7e0qjQ.js → migrate-DWCu2Nny.js} +2 -2
  431. package/dist/cli/{migration-safety-Cy-T3xws.js → migration-safety-rjlsDMDU.js} +3 -3
  432. package/dist/cli/{migrations-C6DXXH2j.js → migrations-BRCqeu8k.js} +2 -2
  433. package/dist/cli/{module-migration-B-VqMxE-.js → module-migration-BpptcXiB.js} +2 -2
  434. package/dist/cli/{moved-CC2yanOJ.js → moved-B_XzRpRE.js} +1 -1
  435. package/dist/cli/{parse-BaW3_Itq.js → parse-BwGYCpEv.js} +1 -1
  436. package/dist/cli/powersync-BejxIowk.js +1 -0
  437. package/dist/cli/{powersync-CK8AR-WC.js → powersync-DsbJBuTR.js} +4 -4
  438. package/dist/cli/{print-DnZdC-oy.js → print-A9UGTj_t.js} +2 -2
  439. package/dist/cli/{providers-WCZgGeBy.js → providers-MlTm8nMs.js} +2 -2
  440. package/dist/cli/{prune-workflows-B69exaiW.js → prune-workflows-B6sqjrR0.js} +4 -4
  441. package/dist/cli/{remove-8f3luaAm.js → remove-BpY-E_l4.js} +8 -8
  442. package/dist/cli/{render-CZw4nKPe.js → render-8qD7j0se.js} +173 -64
  443. package/dist/cli/{run-BEKT_kd3.js → run-CAvLtfJG.js} +2 -2
  444. package/dist/cli/{run-R1XanA6K.js → run-DHRA46qf.js} +53 -52
  445. package/dist/cli/{run-C7VeseCS.js → run-Dl1TZGsM.js} +45 -11
  446. package/dist/cli/{seed-Q0D1Vr2S.js → seed-BgpovbwF.js} +4 -4
  447. package/dist/cli/seed-CRD1tYPA.js +1 -0
  448. package/dist/cli/{shared-B4Lw35PY.js → shared-B77Q9x0E.js} +1 -1
  449. package/dist/cli/{skills-BGn6lqa3.js → skills-aC7X7bhq.js} +1 -1
  450. package/dist/cli/{snapshot-Cj8BlMTz.js → snapshot-_roTbSZM.js} +26 -5
  451. package/dist/cli/{source-D1s75o6g.js → source-BseR3sy9.js} +1 -1
  452. package/dist/cli/{source-args-B3Po6qsn.js → source-args-DC8snM7e.js} +1 -1
  453. package/dist/cli/{spec-L6nabkxl.js → spec-Ct3i4drt.js} +3 -3
  454. package/dist/cli/{spec-CvKK1F-_.js → spec-n6QRlBOJ.js} +1 -1
  455. package/dist/cli/{sql-layout-D2H2DL4t.js → sql-layout-D_fJsw3B.js} +11 -4
  456. package/dist/cli/{stack-DzA4tS9O.js → stack-DINh7KWu.js} +1 -1
  457. package/dist/cli/{sync-6b06cM1c.js → sync-DqBQi0QQ.js} +6 -6
  458. package/dist/cli/{table-CSiri9RG.js → table-Cup45iWj.js} +1 -1
  459. package/dist/cli/{upgrade-C91Jw5xZ.js → upgrade-MRqrFaO1.js} +3 -3
  460. package/dist/cli/{upgrade-c7oPXvNG.js → upgrade-y3Iv4wl8.js} +5 -5
  461. package/dist/cli/{version-_XjqP_ML.js → version-CiE6Pt0K.js} +1 -1
  462. package/dist/client/index.d.ts +5 -5
  463. package/dist/client/index.js +1 -1
  464. package/dist/client/native/index.d.ts +4 -4
  465. package/dist/client/native/index.js +1 -1
  466. package/dist/{composite-DuN-BnSc.js → composite-CgxTMZTK.js} +1 -1
  467. package/dist/{composite-B3L12SH4.d.ts → composite-CvlcYj8Y.d.ts} +4 -4
  468. package/dist/{composite-reads-MV2aCxBz.js → composite-reads-B99Cfmcf.js} +1 -1
  469. package/dist/{composite-reads-BIUJE_Rs.d.ts → composite-reads-CEI-IJ5A.d.ts} +1 -1
  470. package/dist/config/index.d.ts +5 -5
  471. package/dist/config/index.js +4 -4
  472. package/dist/{config-BOc24DLJ.js → config-B1m2PpjB.js} +1 -1
  473. package/dist/{config-7TP5XUaX.js → config-BWYT86yp.js} +3 -3
  474. package/dist/{context-DyXTQUb_.d.ts → context-DcHcHc2b.d.ts} +38 -4
  475. package/dist/contract/index.d.ts +6 -6
  476. package/dist/{controller-BHEUaOKo.d.ts → controller-BrTPi8Po.d.ts} +1 -1
  477. package/dist/{controller-o6DleXLi.js → controller-DvihM19C.js} +1 -1
  478. package/dist/{conversion-BBIeUsfd.d.ts → conversion-t1F0y--Y.d.ts} +1 -1
  479. package/dist/{copy-DurB738g.js → copy-DJBlRqH6.js} +1 -1
  480. package/dist/create/index.d.ts +4 -4
  481. package/dist/create/index.js +3 -3
  482. package/dist/create/lite/index.d.ts +19 -2
  483. package/dist/create/lite/index.js +55 -3
  484. package/dist/{create-blocks-C6Ty49vp.js → create-blocks-CkhSm4iX.js} +117 -5
  485. package/dist/credentials/index.js +4 -4
  486. package/dist/{db-blocks-CFqt-e4_.d.ts → db-blocks-Dp-4qbYN.d.ts} +18 -0
  487. package/dist/{define-C2OUEXIf.js → define-UhyrfLYX.js} +147 -100
  488. package/dist/{define-block-DHOCtKKS.d.ts → define-block-B2um61Uj.d.ts} +65 -6
  489. package/dist/{define-block-DyZiZQrx.js → define-block-D3uNVp2k.js} +1 -0
  490. package/dist/{drive-C2o3Xx_i.d.ts → drive-BSp7gloI.d.ts} +1 -1
  491. package/dist/edge/index.d.ts +5 -5
  492. package/dist/edge/index.js +3 -3
  493. package/dist/{embeddings-yvAeg_C7.js → embeddings-BamT6vln.js} +1 -1
  494. package/dist/{entitlements-Ckadglcj.js → entitlements-B2rEDiKh.js} +1 -1
  495. package/dist/{entitlements-DIVgwFPk.d.ts → entitlements-DuNBTDsH.d.ts} +1 -1
  496. package/dist/error-kind-Bkmljt19.js +40 -0
  497. package/dist/eve/index.js +1 -1
  498. package/dist/{event-map-DxfsFgQT.js → event-map-DLajpFiJ.js} +2 -0
  499. package/dist/events/index.js +1 -1
  500. package/dist/events-CCw0FE_F.js +25 -0
  501. package/dist/{executor-BN24zqcr.js → executor-Bed-RLhP.js} +3 -3
  502. package/dist/{executor-CTiacxbx.js → executor-DhQDDIqq.js} +1 -1
  503. package/dist/{executor-ClpWppJK.d.ts → executor-RNhfR91D.d.ts} +2 -2
  504. package/dist/expo/index.d.ts +2 -2
  505. package/dist/expo/index.js +2 -2
  506. package/dist/{extract-CrOX8i1t.d.ts → extract-DvU_lPRQ.d.ts} +1 -1
  507. package/dist/{field-errors-B9cPS36j.d.ts → field-errors-Mo8dzoyA.d.ts} +6 -6
  508. package/dist/{framework-GAR2no7D.js → framework-BfP8NwDY.js} +1 -1
  509. package/dist/{framework-G-kFZ_Zu.d.ts → framework-BoDTo47q.d.ts} +3 -3
  510. package/dist/hono/index.d.ts +4 -4
  511. package/dist/hono/index.js +2 -2
  512. package/dist/{index-OXEh0xet.d.ts → index-46Mwoxp8.d.ts} +4 -4
  513. package/dist/{index-70sHeLK0.d.ts → index-B2zDRJMB.d.ts} +1 -1
  514. package/dist/{index-Cq91CC2i.d.ts → index-BDEwjrNn.d.ts} +1 -1
  515. package/dist/{index-Bh-mcFvM.d.ts → index-BFw-iTQT.d.ts} +1 -1
  516. package/dist/{index-DS1cREWV.d.ts → index-BGje-MeF.d.ts} +1 -1
  517. package/dist/{index-C9rUCq13.d.ts → index-BLRLF6iG.d.ts} +1 -1
  518. package/dist/{index-WdVPDjby.d.ts → index-BLpP1czF.d.ts} +1 -1
  519. package/dist/{index-CekZhXD2.d.ts → index-BMt0EVnl.d.ts} +1 -1
  520. package/dist/{index-DX0AQN4S.d.ts → index-BPz1IGUB.d.ts} +1 -1
  521. package/dist/{index-Cu7TSSiT.d.ts → index-Bdd-8C1P.d.ts} +2 -2
  522. package/dist/{index-xaSPPgB7.d.ts → index-BpCBGOVF.d.ts} +3 -3
  523. package/dist/{index-Bl44eUq9.d.ts → index-Bxu7m8vw.d.ts} +1 -1
  524. package/dist/{index--qIecGmt.d.ts → index-C2ilfaOF.d.ts} +1 -1
  525. package/dist/{index-A9U5y90N.d.ts → index-C3pOr989.d.ts} +1 -1
  526. package/dist/{index-Rj_9oAEO.d.ts → index-C8-8-t1s.d.ts} +2 -2
  527. package/dist/{index-Dfm7cQdw.d.ts → index-CNNGDSxy.d.ts} +2 -2
  528. package/dist/{index--qWRLdDu.d.ts → index-CV7Ibpek.d.ts} +1 -1
  529. package/dist/{index-Bo_5VFCD.d.ts → index-C_Ilif3i.d.ts} +1 -1
  530. package/dist/{index-DOPaoauk.d.ts → index-CaMHCzBp.d.ts} +1 -1
  531. package/dist/{index-XhmH0QFF.d.ts → index-CnQ27iFg.d.ts} +2 -2
  532. package/dist/{index-DGPYJUsm.d.ts → index-DLKMzlbR.d.ts} +1 -1
  533. package/dist/{index-Csx1g10j.d.ts → index-DNdYTori.d.ts} +2 -2
  534. package/dist/{index-DXlGFVDA.d.ts → index-DTqpt8XQ.d.ts} +1 -1
  535. package/dist/{index-C0MuI4v1.d.ts → index-DaClvzRy.d.ts} +4 -4
  536. package/dist/{index-CVOgOU3Z.d.ts → index-DfuF_8Ph.d.ts} +1 -1
  537. package/dist/{index-DL-X_e7F.d.ts → index-Dndo_is2.d.ts} +6 -5
  538. package/dist/{index-DxRrnBQR.d.ts → index-ISihFGu9.d.ts} +7 -7
  539. package/dist/{index-Cq6sRJPI.d.ts → index-OHQg8Sdx.d.ts} +3 -3
  540. package/dist/{index-BU5ifSPf.d.ts → index-PeaYXjhx.d.ts} +1 -1
  541. package/dist/{index-AAC2eWs-.d.ts → index-TNNEpcgG.d.ts} +4 -4
  542. package/dist/{index-Bksw5AoY.d.ts → index-Xsu3egx_.d.ts} +20 -9
  543. package/dist/{index-CUS-3XG1.d.ts → index-YgUHItkp.d.ts} +1 -1
  544. package/dist/{index-DERMRibg.d.ts → index-Zf3t4MuL.d.ts} +17 -10
  545. package/dist/{index-BKsK1OFh.d.ts → index-bOWESOEm.d.ts} +2 -2
  546. package/dist/{index-CqtV72-L.d.ts → index-kKkGf0_-.d.ts} +3 -3
  547. package/dist/{index-BFCUcLda.d.ts → index-s1IQy8sK.d.ts} +2 -2
  548. package/dist/{index-3QwzddR3.d.ts → index-xA8WHuDE.d.ts} +4 -4
  549. package/dist/index.d.ts +1 -1
  550. package/dist/index.js +5 -5
  551. package/dist/{instances-B3gBKh8G.js → instances-CFXFHQMK.js} +2 -1
  552. package/dist/{knowledge-CJhz_QTb.js → knowledge-5Qz_NTXw.js} +1 -1
  553. package/dist/list/index.d.ts +1 -1
  554. package/dist/{list-query-yg-W4BlQ.d.ts → list-query-CREBmVkm.d.ts} +1 -1
  555. package/dist/{manifest-BoOhT_Sh.d.ts → manifest-09aHVu5Q.d.ts} +1 -1
  556. package/dist/{manifest-CnyT7c1s.d.ts → manifest-0PeNUYcv.d.ts} +1 -1
  557. package/dist/{manifest-Q9_hEoaz.js → manifest-0UcJEkVv.js} +10 -10
  558. package/dist/{manifest-C6Tpng5m.js → manifest-5f_9qQnw.js} +9 -9
  559. package/dist/{manifest-CVL8uWZM.js → manifest-8oyDNj1x.js} +10 -10
  560. package/dist/{manifest-BGfX8wev.js → manifest-B-GhBRkt.js} +10 -10
  561. package/dist/{manifest-Dy1YssHm.js → manifest-B-LuM8VG.js} +7 -7
  562. package/dist/{manifest-Btbo698t.js → manifest-B-wRV_0N.js} +13 -13
  563. package/dist/{manifest-DGWojJC1.js → manifest-B1CzCbIE.js} +13 -13
  564. package/dist/{manifest-DDd8ppp7.d.ts → manifest-B3RgCccj.d.ts} +1 -1
  565. package/dist/{manifest-vUGVlXLh.d.ts → manifest-B3YkuXKR.d.ts} +1 -1
  566. package/dist/{manifest-H9u744d9.js → manifest-B3b2Y84h.js} +3 -3
  567. package/dist/{manifest-3bD3TaDt.d.ts → manifest-B3xj3-ew.d.ts} +1 -1
  568. package/dist/{manifest-BO4rlrML.d.ts → manifest-B4HXWUh8.d.ts} +1 -1
  569. package/dist/{manifest-CAwbcrJO.d.ts → manifest-B5vPAt-u.d.ts} +1 -1
  570. package/dist/{manifest-xoePLm1M.js → manifest-B7-Numjr.js} +13 -13
  571. package/dist/{manifest-Cc3wO1KI.js → manifest-BEeu_r4Y.js} +3 -3
  572. package/dist/{manifest-urrijhoM.d.ts → manifest-BFXybbMn.d.ts} +1 -1
  573. package/dist/{manifest-BY60j47w.js → manifest-BHAaE8V8.js} +5 -5
  574. package/dist/{manifest-D-Cq1TTO.js → manifest-BKJXc9sY.js} +3 -3
  575. package/dist/{manifest-D3sWX05O.d.ts → manifest-BLOufikB.d.ts} +1 -1
  576. package/dist/{manifest-D_wDGSVQ.js → manifest-BNT_WDkt.js} +5 -5
  577. package/dist/{manifest-N4AW74PT.js → manifest-BQhSqR4D.js} +14 -14
  578. package/dist/{manifest-Bc10Mthq.js → manifest-BRFen7mE.js} +31 -31
  579. package/dist/{manifest-CS9W2n9y.js → manifest-BSaRwzEH.js} +12 -12
  580. package/dist/{manifest-BvTS58t8.js → manifest-BUktyXMR.js} +22 -22
  581. package/dist/{manifest-BHthvzO5.d.ts → manifest-BUrKk2Ww.d.ts} +1 -1
  582. package/dist/{manifest-BhL35Pr2.js → manifest-BVAHowRk.js} +12 -12
  583. package/dist/{manifest-gA_niypr.js → manifest-BWh9leJI.js} +8 -8
  584. package/dist/{manifest-DKZEyfK6.js → manifest-BXN6WKgs.js} +3 -3
  585. package/dist/{manifest-Cds0y0r4.d.ts → manifest-BYUIgwGb.d.ts} +1 -1
  586. package/dist/{manifest-B4E33DXF.d.ts → manifest-Bc_2t9mY.d.ts} +1 -1
  587. package/dist/{manifest-CQOdY5Cc.d.ts → manifest-BdcBkznK.d.ts} +1 -1
  588. package/dist/{manifest-CkeHPwD_.d.ts → manifest-Bg1swpdk.d.ts} +1 -1
  589. package/dist/{manifest-DgsbIFLv.js → manifest-BhKkBdlV.js} +11 -11
  590. package/dist/{manifest-D25mxZdE.js → manifest-BnFuyvL7.js} +8 -8
  591. package/dist/{manifest-eUnjSmkX.js → manifest-BnJqvwXA.js} +14 -14
  592. package/dist/{manifest-Cw3Ak4ac.js → manifest-BnmxgXet.js} +4 -4
  593. package/dist/{manifest-S2EhG5Gw.js → manifest-BpAI3Me7.js} +34 -34
  594. package/dist/{manifest-D-D1xDw2.d.ts → manifest-BpiZFLbl.d.ts} +1 -1
  595. package/dist/{manifest-C4oqpEqj.js → manifest-BrkF61-W.js} +8 -8
  596. package/dist/{manifest-Cl13wY3u.d.ts → manifest-BwYOds2o.d.ts} +1 -1
  597. package/dist/{manifest-B2HCw2CH.js → manifest-BwZjGHRu.js} +14 -14
  598. package/dist/{manifest-CiSSfthq.d.ts → manifest-Bwv273Tb.d.ts} +1 -1
  599. package/dist/{manifest-D6jxUviz.js → manifest-C-QxTuzM.js} +3 -3
  600. package/dist/{manifest-CNNWN9Rr.js → manifest-C15_YXQV.js} +3 -3
  601. package/dist/{manifest-C9kzPc3l.d.ts → manifest-C4CIOVkt.d.ts} +2 -2
  602. package/dist/{manifest-cLGmrzgW.js → manifest-C692l8af.js} +12 -12
  603. package/dist/{manifest-C8AENKFu.js → manifest-C8_k9anI.js} +8 -8
  604. package/dist/{manifest-dOdQx0hy.d.ts → manifest-C9Kn7gwK.d.ts} +1 -1
  605. package/dist/{manifest-Dry8RIXq.js → manifest-C9fN2qRW.js} +12 -12
  606. package/dist/{manifest-CM5RhlxN.js → manifest-CBFQeKg6.js} +12 -12
  607. package/dist/{manifest-oZ1s2HoJ.d.ts → manifest-CDK8R8Ze.d.ts} +1 -1
  608. package/dist/{manifest-Dsi1aOKw.d.ts → manifest-CF-LsgEw.d.ts} +1 -1
  609. package/dist/{manifest-CWnpnTcL.js → manifest-CF92Kiog.js} +3 -3
  610. package/dist/{manifest-B3VjTLRv.d.ts → manifest-CFFaunME.d.ts} +1 -1
  611. package/dist/{manifest-Bgx1ETpN.js → manifest-CMnr9qpi.js} +10 -10
  612. package/dist/{manifest-C3fDS3NG.d.ts → manifest-CNcJxi93.d.ts} +1 -1
  613. package/dist/{manifest-CaKD48WX.d.ts → manifest-COoFT2vY.d.ts} +1 -1
  614. package/dist/{manifest-CMjAfphZ.js → manifest-CQ9I_8q2.js} +8 -8
  615. package/dist/{manifest-Bq11rIm6.js → manifest-CScOn17C.js} +12 -12
  616. package/dist/{manifest-CyMaBCGq.d.ts → manifest-CW47rgqj.d.ts} +1 -1
  617. package/dist/{manifest-DKqcq-LB.d.ts → manifest-C_ZDkBv4.d.ts} +1 -1
  618. package/dist/{manifest-Cg6iafYQ.js → manifest-C__pecuF.js} +14 -14
  619. package/dist/{manifest-DlRpMwfK.d.ts → manifest-CaKVpJZM.d.ts} +1 -1
  620. package/dist/{manifest-Dv8Hfpym.d.ts → manifest-CazVMbdf.d.ts} +1 -1
  621. package/dist/{manifest-DpUGCrdL.d.ts → manifest-Ccn2k0vb.d.ts} +1 -1
  622. package/dist/{manifest-oSaeMiYm.js → manifest-Cg25x0rD.js} +11 -11
  623. package/dist/{manifest-D5AuRrMx.d.ts → manifest-CgCpK4Wm.d.ts} +1 -1
  624. package/dist/{manifest-DqVGGnLa.d.ts → manifest-CgP-MDb3.d.ts} +1 -1
  625. package/dist/{manifest-CBzq9IhS.d.ts → manifest-CiOcPFFy.d.ts} +1 -1
  626. package/dist/{manifest-DsLlJTUa.js → manifest-CmSVpPBS.js} +7 -7
  627. package/dist/{manifest-BQzebb6B.js → manifest-CmquAtQC.js} +8 -8
  628. package/dist/{manifest-BbrSRrrB.js → manifest-CnSZ16xc.js} +3 -3
  629. package/dist/{manifest-BDEAP2_6.d.ts → manifest-Cnb5QGMK.d.ts} +1 -1
  630. package/dist/{manifest-eIWKtbU-.d.ts → manifest-CnkVWwAg.d.ts} +1 -1
  631. package/dist/{manifest-B5JVSm7q.js → manifest-CnlgJJDS.js} +10 -10
  632. package/dist/{manifest-qO6Dn0Rf.js → manifest-D0DK7Gdu.js} +12 -12
  633. package/dist/{manifest-BYIGiQA0.d.ts → manifest-D0KUPw4L.d.ts} +1 -1
  634. package/dist/{manifest-D5bH3Mec.d.ts → manifest-D1-lCZro.d.ts} +1 -1
  635. package/dist/{manifest-BeMK5Uir.js → manifest-D1VrUJOA.js} +5 -5
  636. package/dist/{manifest-C0BV1Dqr.js → manifest-D3LeYpRm.js} +13 -13
  637. package/dist/{manifest-CTjhS3_I.js → manifest-D3To2MLR.js} +6 -6
  638. package/dist/{manifest-3ImEz2CE.js → manifest-D46SY8Og.js} +17 -17
  639. package/dist/{manifest-57rK1ngY.d.ts → manifest-D6ZukDGm.d.ts} +1 -1
  640. package/dist/{manifest-CoGArkb4.js → manifest-D8teMyal.js} +11 -11
  641. package/dist/{manifest-DA8v7QwQ.js → manifest-DAZuHpm2.js} +14 -14
  642. package/dist/{manifest-DFDQCoIR.d.ts → manifest-DBSs1jJ_.d.ts} +1 -1
  643. package/dist/{manifest-DPQ1ECvV.js → manifest-DEx8OSZK.js} +8 -8
  644. package/dist/{manifest-Cs_BBJMk.d.ts → manifest-DF49Pt6Q.d.ts} +1 -1
  645. package/dist/{manifest-nghaYPXC.js → manifest-DFoZF4CI.js} +14 -14
  646. package/dist/{manifest-CTH_3PQ8.js → manifest-DHfYjJMJ.js} +12 -12
  647. package/dist/{manifest-_5YD_7qt.js → manifest-DIC1MsM0.js} +15 -15
  648. package/dist/{manifest-DFhs8tTZ.js → manifest-DKthWXiw.js} +9 -9
  649. package/dist/{manifest-DisFKYTB.js → manifest-DLsq8M80.js} +5 -5
  650. package/dist/{manifest-D7zENukq.d.ts → manifest-DMTmTHBy.d.ts} +1 -1
  651. package/dist/{manifest-t0UobwxV.d.ts → manifest-DQwFCQkG.d.ts} +1 -1
  652. package/dist/{manifest-CXRuupEQ.js → manifest-DWGEzte4.js} +18 -18
  653. package/dist/{manifest-CMwKGDuJ.js → manifest-DWLGd0FS.js} +8 -8
  654. package/dist/{manifest-D9ldgISN.js → manifest-DYpXtqzm.js} +8 -8
  655. package/dist/{manifest-CRrS1eXB.js → manifest-DcI69zyP.js} +12 -12
  656. package/dist/{manifest-DpUU_GQF.d.ts → manifest-Dh3kIEzu.d.ts} +1 -1
  657. package/dist/{manifest-CPGq3poM.js → manifest-DiPqog2j.js} +3 -3
  658. package/dist/{manifest-B0PJg-oT.js → manifest-Dj7bGfoy.js} +11 -11
  659. package/dist/{manifest-BpCVzhPX.js → manifest-DkI--7fx.js} +14 -14
  660. package/dist/{manifest-B2nCtBhS.js → manifest-Dm822kx0.js} +9 -9
  661. package/dist/{manifest-BWuJw7AI.js → manifest-DnSvthaM.js} +10 -10
  662. package/dist/{manifest-CehK0epY.d.ts → manifest-DpoO491p.d.ts} +1 -1
  663. package/dist/{manifest-CVQW9Vcl.js → manifest-DsJukV9d.js} +18 -18
  664. package/dist/{manifest-BYiCfDfW.d.ts → manifest-Du_-0ruw.d.ts} +1 -1
  665. package/dist/{manifest-CcErLbUW.d.ts → manifest-Dvhqz3qo.d.ts} +1 -1
  666. package/dist/{manifest-BEE8kXlc.js → manifest-DxPMUjhY.js} +17 -17
  667. package/dist/{manifest-CFEY-PSe.d.ts → manifest-Dy5_Rc0q.d.ts} +1 -1
  668. package/dist/{manifest-BdWn7BTX.d.ts → manifest-DyZcERh_.d.ts} +1 -1
  669. package/dist/{manifest-DqbXAQwZ.d.ts → manifest-ETlyMx6o.d.ts} +1 -1
  670. package/dist/{manifest-Cu1zCdXg.js → manifest-EcWk4ytT.js} +9 -9
  671. package/dist/{manifest-CPecIPI5.js → manifest-EwHcMCiW.js} +4 -4
  672. package/dist/{manifest-amQk8j7Y.js → manifest-FXQp4dob.js} +13 -13
  673. package/dist/{manifest-Y1Z5L2T3.js → manifest-Gi6V1g3E.js} +12 -12
  674. package/dist/{manifest-e7ZbaKYF.js → manifest-H65OlXiB.js} +15 -15
  675. package/dist/{manifest-DyjQZh7Z.js → manifest-IZ9GQI7f.js} +13 -13
  676. package/dist/{manifest-Hm1-O138.d.ts → manifest-JdAQqp5w.d.ts} +3 -3
  677. package/dist/{manifest-D8iIf1Kb.js → manifest-Lasq6DPg.js} +10 -10
  678. package/dist/{manifest-0F7lof-8.d.ts → manifest-Lsz6rH3B.d.ts} +1 -1
  679. package/dist/{manifest-DSGLUrYq.js → manifest-MTW4mY5N.js} +10 -10
  680. package/dist/{manifest-B_6NoKFg.d.ts → manifest-RAijfop2.d.ts} +1 -1
  681. package/dist/{manifest-DAxxMf9a.js → manifest-X24lr5XH.js} +3 -3
  682. package/dist/{manifest-Hr6MyREb.d.ts → manifest-XZV2sKgk.d.ts} +1 -1
  683. package/dist/{manifest-BLnVv55R.js → manifest-YB3ZtXEb.js} +11 -11
  684. package/dist/{manifest-gSko__Wn.d.ts → manifest-a0YxYgo0.d.ts} +1 -1
  685. package/dist/{manifest-CgMNtyTZ.d.ts → manifest-aJOA6D9w.d.ts} +1 -1
  686. package/dist/{manifest-CwJZGhJ8.d.ts → manifest-c8mlNzOv.d.ts} +1 -1
  687. package/dist/{manifest-KUbi4IKj.d.ts → manifest-dLThrKqV.d.ts} +1 -1
  688. package/dist/{manifest-Bde5xCaP.d.ts → manifest-dlqXYOfB.d.ts} +1 -1
  689. package/dist/{manifest-BUFE6Vda.js → manifest-jLh9Rwsh.js} +11 -11
  690. package/dist/{manifest-iKyF53SI.d.ts → manifest-jb384ocG.d.ts} +1 -1
  691. package/dist/{manifest-DBu84LST.d.ts → manifest-jiaWr0x4.d.ts} +1 -1
  692. package/dist/{manifest-t-8upuXv.js → manifest-kZCtkWqj.js} +9 -9
  693. package/dist/{manifest-BGhS_IRb.js → manifest-kbSJq3sR.js} +17 -17
  694. package/dist/{manifest-oVRDNj7t.d.ts → manifest-pLJIrNwi.d.ts} +1 -1
  695. package/dist/{manifest-DlK0gus-.js → manifest-rHukkAIC.js} +16 -16
  696. package/dist/{manifest-NSNQGS0I.js → manifest-wlx1-yvJ.js} +5 -5
  697. package/dist/{manifest-BUvqSThC.d.ts → manifest-xAeOKTub.d.ts} +3 -3
  698. package/dist/{manifest-CbXBkXqf.d.ts → manifest-y2y5xPQC.d.ts} +1 -1
  699. package/dist/{manifest-MleiBHu4.js → manifest-yLshQDXw.js} +6 -6
  700. package/dist/mapper/bin.js +6 -6
  701. package/dist/mcp/index.d.ts +2 -2
  702. package/dist/mcp/index.js +1 -1
  703. package/dist/mcp/sdk/index.d.ts +2 -2
  704. package/dist/mcp/sdk/index.js +1 -1
  705. package/dist/{mcp-DAJ7WsQb.js → mcp-Cu-bD9KQ.js} +1 -1
  706. package/dist/next/client/index.d.ts +1 -1
  707. package/dist/next/index.d.ts +92 -35
  708. package/dist/next/index.js +123 -44
  709. package/dist/{operations-Cqx3ghVP.d.ts → operations-_3oh-CEO.d.ts} +1 -1
  710. package/dist/{options-PM7IaIFP.js → options-B1rQBo1M.js} +4 -1
  711. package/dist/orpc/index.d.ts +4 -4
  712. package/dist/orpc/index.js +1 -1
  713. package/dist/otel/index.js +4 -4
  714. package/dist/{parse-B1g9TF99.js → parse-BRW-aTQQ.js} +1 -1
  715. package/dist/{payroll-export-CrEznq6i.js → payroll-export-CNji28TX.js} +1 -1
  716. package/dist/{permissions-cKhOwOuj.d.ts → permissions-u_qqedin.d.ts} +1 -1
  717. package/dist/{ports-DEC5OfLy.js → ports-BhCn6uGk.js} +1 -1
  718. package/dist/{ports-zqXSEoFP.d.ts → ports-DT5zRdYx.d.ts} +1 -1
  719. package/dist/postgres/index.js +2 -2
  720. package/dist/{postgrest-executor-DaDNeFDr.js → postgrest-executor-BMNA_O9-.js} +1 -1
  721. package/dist/powersync/index.d.ts +3 -3
  722. package/dist/powersync/index.js +1 -1
  723. package/dist/preset/index.d.ts +4 -4
  724. package/dist/preset/index.js +3 -3
  725. package/dist/{preset-BILsEo24.js → preset--1OMwypM.js} +4 -3
  726. package/dist/{preview-DN0JKESa.d.ts → preview-BBA-VaEZ.d.ts} +2 -2
  727. package/dist/{preview-DsrEvLWG.js → preview-Bd7ZBtf2.js} +2 -2
  728. package/dist/{project-C23WlGy4.js → project-BhE6_64F.js} +5 -5
  729. package/dist/{push-token-DZACGqYX.d.ts → push-token-hs6_Vt-I.d.ts} +1 -1
  730. package/dist/query/index.d.ts +1 -1
  731. package/dist/query/index.js +1 -1
  732. package/dist/rate-limit/index.js +1 -1
  733. package/dist/{rate-limit-DSOwe_Re.js → rate-limit-ruAG2w45.js} +1 -1
  734. package/dist/react/index.d.ts +6 -6
  735. package/dist/react/index.js +2 -2
  736. package/dist/react/native/index.d.ts +1 -1
  737. package/dist/react/server.d.ts +10 -6
  738. package/dist/react/server.js +6 -2
  739. package/dist/{react-oftUdRLD.js → react-olMpD8et.js} +31 -24
  740. package/dist/react-router/index.d.ts +3 -3
  741. package/dist/react-router/index.js +2 -2
  742. package/dist/{read-set-Vqn_XdqV.js → read-set-4EsAPjII.js} +2 -1
  743. package/dist/realtime/index.d.ts +3 -3
  744. package/dist/realtime/index.js +1 -1
  745. package/dist/{record-form-S1-QnCI_.d.ts → record-form-Cze5j1OB.d.ts} +1 -1
  746. package/dist/{record-type-uD8JMf0g.js → record-type-BPUobukL.js} +1 -0
  747. package/dist/records/index.d.ts +7 -7
  748. package/dist/records/index.js +3 -3
  749. package/dist/{resource-execute-y2wGRwTn.d.ts → resource-execute-D2cJfrKu.d.ts} +1 -1
  750. package/dist/{resource-types-B8ocsWgZ.d.ts → resource-types-Cs1zWvrn.d.ts} +1 -1
  751. package/dist/{resources-DS3fQtwv.d.ts → resources-DyP9cP9i.d.ts} +1 -1
  752. package/dist/{sales-DKOs8F12.js → sales-BCArDSEX.js} +9 -9
  753. package/dist/{scores-Dfes6BDr.js → scores-D3fvLQGX.js} +1 -1
  754. package/dist/server/index.d.ts +13 -13
  755. package/dist/server/index.js +9 -9
  756. package/dist/{server-types-CXNFIjFU.d.ts → server-types-Bpxk5UWh.d.ts} +32 -10
  757. package/dist/{session-CDkvmd52.d.ts → session-DQ5huqEw.d.ts} +2 -2
  758. package/dist/{session-status-PE2_AdYA.d.ts → session-status-DDPrDS36.d.ts} +1 -1
  759. package/dist/{settings-CqhQrT3a.js → settings-DhzIPgTN.js} +1 -1
  760. package/dist/{shared-B0clSLXG.js → shared-BTf7Qrnk.js} +1 -1
  761. package/dist/{sign-in-BRT-0QYF.js → sign-in-03gtm616.js} +34 -9
  762. package/dist/{signing-keys-hgspu0oB.js → signing-keys-sEdfxGbZ.js} +1 -1
  763. package/dist/solid/index.d.ts +13 -6
  764. package/dist/solid/index.js +10 -3
  765. package/dist/solid-start/index.d.ts +3 -3
  766. package/dist/solid-start/index.js +2 -2
  767. package/dist/spec/index.d.ts +1 -1
  768. package/dist/{spec-CGD_BzCF.js → spec-BSc8n34a.js} +1 -1
  769. package/dist/sql/index.d.ts +5 -5
  770. package/dist/sql/index.js +3 -3
  771. package/dist/{sql-DUonzxhb.js → sql-B0t41P1F.js} +2 -2
  772. package/dist/{sql-DWsHDJ3c.js → sql-BVUbNexh.js} +581 -242
  773. package/dist/sqlite/index.d.ts +1 -1
  774. package/dist/sqlite/index.js +1 -1
  775. package/dist/{sso-CSfrymeX.js → sso-fXXdjhyz.js} +1 -1
  776. package/dist/ssr/index.d.ts +1 -1
  777. package/dist/storage/index.js +1 -1
  778. package/dist/{support-DLms-JZd.d.ts → support-tDhEwXbu.d.ts} +18 -9
  779. package/dist/svelte/index.d.ts +13 -6
  780. package/dist/svelte/index.js +10 -3
  781. package/dist/sveltekit/index.d.ts +4 -4
  782. package/dist/sveltekit/index.js +2 -2
  783. package/dist/{tags-BGwWAMVB.d.ts → tags-CBASI98_.d.ts} +1 -1
  784. package/dist/tanstack-db/index.d.ts +1 -1
  785. package/dist/tanstack-start/index.d.ts +3 -3
  786. package/dist/tanstack-start/index.js +2 -2
  787. package/dist/{tenant-DNoe5dUa.d.ts → tenant-c_6qMyFI.d.ts} +1 -1
  788. package/dist/testing/index.d.ts +111 -10
  789. package/dist/testing/index.js +217 -7
  790. package/dist/{timeline-Dy099qKD.d.ts → timeline-DvZ7C5zf.d.ts} +3 -3
  791. package/dist/{topic-CqSqDnjb.js → topic-CW7sraaQ.js} +1 -1
  792. package/dist/{topic-EkhjfSPH.d.ts → topic-fwPlelNI.d.ts} +2 -2
  793. package/dist/{types-CkLE9lwr.d.ts → types-Cwai2qe4.d.ts} +2 -2
  794. package/dist/{undo-CnWDmntn.js → undo-DhLhQlyY.js} +1 -1
  795. package/dist/{verify-Dh2MQQze.d.ts → verify-CupKPoHW.d.ts} +1 -1
  796. package/dist/vue/index.d.ts +13 -6
  797. package/dist/vue/index.js +10 -3
  798. package/dist/{watch-topic-B4eLrVUl.d.ts → watch-topic-D4AzYs9E.d.ts} +1 -1
  799. package/dist/{webhook-inbox-_7ApdH2q.js → webhook-inbox-TA5H3ti3.js} +1 -1
  800. package/dist/webmcp/index.d.ts +1 -1
  801. package/dist/webmcp/index.js +1 -1
  802. package/dist/yjs/index.d.ts +1 -1
  803. package/dist/yjs/index.js +1 -1
  804. package/package.json +1 -1
  805. package/schemas/config-v1.json +89 -0
  806. package/schemas/doctor-report-v1.json +12 -0
  807. package/skills/better-supabase/references/ui-recipes.md +13 -13
  808. package/dist/cli/add-TZa-GEt2.js +0 -1
  809. package/dist/cli/env-DWtI_scC.js +0 -1
  810. package/dist/cli/powersync-DfiIdCgd.js +0 -1
  811. package/dist/cli/seed-DsoWExFu.js +0 -1
  812. package/dist/events-BRKIxVQD.js +0 -25
  813. package/dist/cli/{orphans-CPcR85QN.js → orphans-ByB0gKOp.js} +1 -1
@@ -2,22 +2,22 @@ import { n as isRecord$1 } from "./guards-CsRa6v57.js";
2
2
  import { d as temporalText } from "./temporal-DKTdGK9i.js";
3
3
  import { r as NEGATIVE, t as FILTER_OPERATORS } from "./filter-query-Ds7Z6lgZ.js";
4
4
  import { a as ok } from "./result-DrBaeIVt.js";
5
- import { a as hasPlaceholder, l as splitPlaceholders, r as containsPlaceholder, s as placeholderOf } from "./read-set-Vqn_XdqV.js";
6
- import { r as isFunctionSpec } from "./spec-CGD_BzCF.js";
5
+ import { a as hasPlaceholder, l as splitPlaceholders, r as containsPlaceholder, s as placeholderOf } from "./read-set-4EsAPjII.js";
6
+ import { r as isFunctionSpec } from "./spec-BSc8n34a.js";
7
7
  import { a as OPERATION_RENAMES, c as PROGRAM_EVENT_MOVES, f as configuredAction, g as isOldPermissionKey, i as EVENT_TYPE_SPLITS, m as currentPermissionKeys, o as PERMISSION_KEY_RENAMES, p as currentEventTypes, r as EVENT_TYPE_RENAMES, s as PERMISSION_KEY_SPLITS, t as ENTITY_KEY_RENAMES, u as SUBJECT_TYPE_RENAMES } from "./renames-PnqMkqit.js";
8
8
  import { t as SPEC_PINS } from "./spec-pins-Dlz8OVqi.js";
9
- import { _ as resolveJsonSchema, a as blockFormerSubjectTypes, d as freesTableName, f as tableBase, g as clientFunctions, h as resolveNames, l as blockColumnName, m as entityType, p as tableMoves, s as installedBlockSubjects, u as columnRenamer, v as CONFIG_DEFAULTS } from "./block-subjects-SKkp3d_Q.js";
9
+ import { _ as resolveJsonSchema, a as blockFormerSubjectTypes, d as freesTableName, f as tableBase, g as clientFunctions, h as resolveNames, l as blockColumnName, m as entityType, p as tableMoves, s as installedBlockSubjects, u as columnRenamer, v as CONFIG_DEFAULTS } from "./block-subjects-Cvd-RaMY.js";
10
10
  import { t as DEFAULT_CLAIMS } from "./claims-CqTr_N1n.js";
11
11
  import { o as tenantNames, r as composeNames } from "./entity-naming-BES3pkQI.js";
12
- 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-B3gBKh8G.js";
12
+ 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-CFXFHQMK.js";
13
13
  import { i as FIELD_FORMATS, n as CUSTOM_FIELD_FORM_TYPES, o as FIELD_FORMAT_VALIDATORS, r as CUSTOM_FIELD_TYPES, s as RATING_BOUNDS, t as CUSTOM_FIELD_CHECKED_FORMATS } from "./field-formats-sLYMh1ZK.js";
14
14
  import { t as isSqlType } from "./sql-type-XWMeZRAl.js";
15
15
  import { a as sqlString, i as sqlIdent$1 } from "./template-1e2akYYK.js";
16
- import { i as fillTemplate, u as templatePlaceholders } from "./access-sql-DVntbgJf.js";
16
+ import { i as fillTemplate, u as templatePlaceholders } from "./access-sql-DH2LbcQe.js";
17
17
  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-B9UWDXMF.js";
18
18
  import { t as MAX_BATCH$1 } from "./batch-limit-DqQ3d6op.js";
19
19
  import { $ as updateExtraColumns, A as membershipDisabledAt, B as registerPartitions, C as extraFieldsJson, D as jwtClaim, E as jsonSchemaChecks, F as pageSize, G as serviceGrant, H as replaceColumnCheck, I as quotedTable, J as shortHash, K as serviceOnly$1, L as raise$1, M as notNullCheckName, N as organizationMissing, O as lockTable, P as ownRowPolicies, Q as triggerGrant, R as readLine, S as extraFieldsArg, T as insertExtraColumns, U as revokeTable, V as renameSql, W as schemaPreamble, X as transitionActorSql, Y as splitTable$1, Z as transitionReasonSql, _ as defaultPartitionName, a as SCHEMA$6, b as dropExpiredPartitions, c as activeMembership, d as addForeignKey, et as updatedAt, f as addNotNullCheck, g as defaultPartition, h as columnsObject, i as PARTITION_VARIABLES, j as membershipSuspended, k as memberAddedRecord, l as addCheck, m as columnRef, n as MONTHLY_PARTITIONS, nt as withExtraFields, o as SERVICE_CALLER$1, p as batchFunction, q as sha256HexSql, r as NOTHING, rt as writeExtraColumns, s as accessDefinesDisabledHelpers, t as EQUIVALENT_TRIGGERS, tt as userGrant, u as addExtraColumns, v as disabledHelpers, w as fail$1, x as ensureCheck, y as disabledHelpersNeedLaterTables, z as recordTrigger } from "./shared-DwShIqeQ.js";
20
- 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 payrollExportSqlOptions, d as leaveTeamFeedSubject, dt as withColumnTypeFunction, et as subjectAccess, f as leaveTypeKey, 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 tryColumnType, v as leaveByEmployee, w as leaveParts, x as leaveConfidentialKey, y as leaveConfidential, z as durationEntries } from "./payroll-export-CrEznq6i.js";
20
+ 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 payrollExportSqlOptions, d as leaveTeamFeedSubject, dt as withColumnTypeFunction, et as subjectAccess, f as leaveTypeKey, 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 tryColumnType, v as leaveByEmployee, w as leaveParts, x as leaveConfidentialKey, y as leaveConfidential, z as durationEntries } from "./payroll-export-CNji28TX.js";
21
21
  import { n as blockOptions, r as option, t as NO_OPTIONS } from "./options-Z-bd_H1E.js";
22
22
  import { t as accessRequestsSqlOptions } from "./options-Cl7lLI30.js";
23
23
  import { t as accountingSqlOptions } from "./options-C3FFnaE-.js";
@@ -31,7 +31,7 @@ import { t as aiGuardrailsSqlOptions } from "./options-feqG502e.js";
31
31
  import { t as aiKeysSqlOptions } from "./options-DQkhhBLy.js";
32
32
  import { t as aiSchedulesSqlOptions } from "./options-BgCS5ODi.js";
33
33
  import { t as announcementsSqlOptions } from "./options-Bs2dC-at.js";
34
- import { t as apiKeysSqlOptions } from "./options-PM7IaIFP.js";
34
+ import { t as apiKeysSqlOptions } from "./options-B1rQBo1M.js";
35
35
  import { t as approvalsSqlOptions } from "./options-DLJTiX29.js";
36
36
  import { t as assetsSqlOptions } from "./options-BLn1PFyu.js";
37
37
  import { t as attachmentsSqlOptions } from "./options-B_26uE3i.js";
@@ -179,7 +179,7 @@ import { i as TILL_SESSION_STATUSES, n as TILL_MOVEMENT_INFLOWS, r as TILL_MOVEM
179
179
  import { n as PICK_LIST_STATUSES, r as PICK_WAVE_STATUSES, t as PICK_LINE_STATUSES } from "./warehouse-values-CyoqvWRp.js";
180
180
  import { n as WORKFLOW_SDK_WORLD } from "./workflow-sdk-C-rVKZTS.js";
181
181
  import { s as permissionMatches } from "./delegation-D0IcjvtS.js";
182
- import { n as quoteIdent, t as compileSql } from "./sql-DUonzxhb.js";
182
+ import { n as quoteIdent, t as compileSql } from "./sql-B0t41P1F.js";
183
183
  // src/sql/actor-guard.ts
184
184
  /**
185
185
  * Functions granted to `authenticated` that write, but a read-only support or
@@ -435,10 +435,14 @@ function signatures(sql, schema) {
435
435
  const rest = sql.slice(close + 1);
436
436
  const returns = /^\s*returns\s+([\s\S]*?)\n(?=\s*(?:language|stable|volatile|immutable|security|set|as|strict|parallel|cost|rows)\b)/i.exec(rest);
437
437
  if (!returns) continue;
438
+ const header = /^[\s\S]*?\n\s*as\s+(?:\$|')/i.exec(rest)?.[0] ?? "";
439
+ const declared = /\n\s*(?:language\s+\w+\s+)?(stable|immutable)\b/i.exec(header)?.[1]?.toLowerCase();
440
+ const volatility = declared === "stable" || declared === "immutable" ? declared : void 0;
438
441
  found.push({
439
442
  name: match[1] ?? match[2],
440
443
  args: splitTopLevel$1(sql.slice(open + 1, close)).map(argument$1),
441
- returns: returns[1].trim()
444
+ returns: returns[1].trim(),
445
+ ...volatility === void 0 ? {} : { volatility }
442
446
  });
443
447
  }
444
448
  return found;
@@ -474,7 +478,7 @@ function wrapper(signature, source, api, grant) {
474
478
  const revoked = ["public", ...[...API_ROLES].filter((role) => !grant.roles.includes(role))].join(", ");
475
479
  return `create or replace function ${target}(${signature.args.map((arg) => arg.declaration).join(", ")})
476
480
  returns ${signature.returns}
477
- language sql
481
+ language sql${signature.volatility === void 0 ? "" : `\n${signature.volatility}`}
478
482
  security invoker
479
483
  set search_path = ''
480
484
  as $$ select ${set ? "* from " : ""}${call} $$;
@@ -2889,7 +2893,7 @@ function withProviderDefaults(layout) {
2889
2893
  * to `null`, with the required columns they lack.
2890
2894
  */
2891
2895
  function viewColumnsOf(layout) {
2892
- return viewColumns(layout, withProviderRoles(layout, withProviderSuspension(layout)), (module) => registry$1().modules[module]?.names);
2896
+ return viewColumns(layout, withProviderPlatformRoles(layout, withProviderDisabledAt(layout, withProviderRoles(layout, withProviderSuspension(layout)))), (module) => registry$1().modules[module]?.names);
2893
2897
  }
2894
2898
  /**
2895
2899
  * `blocks.permissions.disabled` from the provider's `suspension` under the
@@ -2915,6 +2919,52 @@ function withProviderSuspension(layout) {
2915
2919
  }
2916
2920
  };
2917
2921
  }
2922
+ /**
2923
+ * `blocks.memberships.columns.memberships.disabledAt` from the provider's
2924
+ * membership table, unless the config maps it.
2925
+ */
2926
+ function withProviderDisabledAt(layout, modules) {
2927
+ const members = layout.accessProvider?.memberships;
2928
+ const tenant = modules?.["memberships"];
2929
+ if (!modules || !members || tenant === void 0 || tenant.mode === "custom" || tenant.columns?.["memberships"]?.["disabledAt"] !== void 0) return modules;
2930
+ const mapped = tenant.tables?.["memberships"];
2931
+ if (typeof mapped !== "string") return modules;
2932
+ const table = mapped.includes(".") ? mapped : `${tenant.schema ?? "better_supabase"}.${mapped}`;
2933
+ const disabledAt = members.find((entry) => entry.table === table)?.disabledAt;
2934
+ if (disabledAt === void 0 || layout.ownTables?.[table] === void 0) return modules;
2935
+ return {
2936
+ ...modules,
2937
+ memberships: {
2938
+ ...tenant,
2939
+ columns: {
2940
+ ...tenant.columns,
2941
+ memberships: {
2942
+ ...tenant.columns?.["memberships"],
2943
+ disabledAt
2944
+ }
2945
+ }
2946
+ }
2947
+ };
2948
+ }
2949
+ /**
2950
+ * `blocks.invitations.options.platformRoles` from the provider's
2951
+ * `platformRoles` under the `provider` model, unless the config sets it.
2952
+ */
2953
+ function withProviderPlatformRoles(layout, modules) {
2954
+ const platform = layout.accessProvider?.platformRoles;
2955
+ const invitations = modules?.["invitations"];
2956
+ if (!modules || !platform || modules.permissions?.model !== "provider" || invitations === void 0 || invitations.mode === "custom" || invitations.options?.["platformRoles"] !== void 0) return modules;
2957
+ return {
2958
+ ...modules,
2959
+ invitations: {
2960
+ ...invitations,
2961
+ options: {
2962
+ ...invitations.options,
2963
+ platformRoles: platform
2964
+ }
2965
+ }
2966
+ };
2967
+ }
2918
2968
  function withProviderRoles(layout, modules) {
2919
2969
  const sources = layout.accessProvider?.roleSources;
2920
2970
  const tenant = modules?.["memberships"];
@@ -17463,6 +17513,31 @@ ${lockTable(t.harness)}
17463
17513
  -- service role reads it, through load_ai_harness_session.
17464
17514
  drop policy if exists ai_harness_sessions_owner_read on ${t.harness};`;
17465
17515
  }
17516
+ // src/sql/memo.ts
17517
+ /**
17518
+ * A memo for one transaction, over a transaction-local setting. PostgREST runs
17519
+ * one request in one transaction, so a policy helper can compute a value once
17520
+ * and every later call in the statement reads it (ADR 0230). The empty string
17521
+ * reads as unset.
17522
+ */
17523
+ const MEMO_FUNCTIONS = `
17524
+ create or replace function better_supabase.memo_get(key text)
17525
+ returns text
17526
+ language sql
17527
+ volatile
17528
+ set search_path = ''
17529
+ as $$
17530
+ select nullif(pg_catalog.current_setting('better_supabase.memo.' || key, true), '')
17531
+ $$;
17532
+
17533
+ create or replace function better_supabase.memo_set(key text, value text)
17534
+ returns text
17535
+ language sql
17536
+ volatile
17537
+ set search_path = ''
17538
+ as $$
17539
+ select pg_catalog.set_config('better_supabase.memo.' || key, value, true)
17540
+ $$;`;
17466
17541
  // src/sql/modules/approvals-items.ts
17467
17542
  /** The most items one request carries. */
17468
17543
  const MAX_ITEMS = 200;
@@ -19168,6 +19243,51 @@ $$;
19168
19243
  revoke execute on function ${fn("approval_settle")}(text, text, text, text, uuid, text) from public, anon, authenticated;
19169
19244
  `;
19170
19245
  }
19246
+ // src/sql/modules/approvals-tests.ts
19247
+ /**
19248
+ * Checks that `approval_eligible_ids()` returns the pending requests
19249
+ * `approval_eligible` accepts, for each user of the database in turn.
19250
+ */
19251
+ function approvalTests(ctx) {
19252
+ const requests = ctx.table("requests");
19253
+ const id = ctx.col("requests", "id");
19254
+ return [{
19255
+ name: "eligible_ids",
19256
+ sql: `begin;
19257
+ create extension if not exists pgtap with schema extensions;
19258
+ select extensions.plan(1);
19259
+
19260
+ do $$
19261
+ declare
19262
+ u record;
19263
+ bad bigint := 0;
19264
+ begin
19265
+ for u in select a.id from auth.users a order by a.id limit 25 loop
19266
+ perform set_config('request.jwt.claims', jsonb_build_object('sub', u.id, 'role', 'authenticated')::text, true);
19267
+ if (
19268
+ select coalesce(array_agg(r.${id} order by r.${id}), '{}') from ${requests} r
19269
+ where r.${ctx.col("requests", "status")} = 'pending' and ${ctx.fn("approval_eligible")}(r.${id})
19270
+ ) is distinct from (
19271
+ select coalesce(array_agg(x order by x), '{}') from ${ctx.fn("approval_eligible_ids")}() x
19272
+ ) then
19273
+ bad := bad + 1;
19274
+ end if;
19275
+ end loop;
19276
+ perform set_config('request.jwt.claims', '', true);
19277
+ perform set_config('bsb.parity', bad::text, true);
19278
+ end;
19279
+ $$;
19280
+
19281
+ select extensions.is(
19282
+ current_setting('bsb.parity')::bigint,
19283
+ 0::bigint,
19284
+ 'approval_eligible_ids returns the pending requests approval_eligible accepts, for every user'
19285
+ );
19286
+
19287
+ select * from extensions.finish();
19288
+ rollback;`
19289
+ }];
19290
+ }
19171
19291
  // src/sql/modules/approver.ts
19172
19292
  /** The `{kind}` of an AI tool call that waits for approval. */
19173
19293
  const AI_TOOL_APPROVAL = "ai-tool";
@@ -23182,7 +23302,7 @@ function build$144(ctx, layout) {
23182
23302
  select t.id::text from ${memberIdsFor("delegate_approval.to_user")} as t(id)
23183
23303
  )`;
23184
23304
  const teams = ctx.installed("teams") && ctx.of("teams").mode !== "custom" ? ctx.of("teams") : void 0;
23185
- const teamMatch = (member) => teams === void 0 ? "false" : `exists (select 1 from ${teams.table("members")} tm where tm.${teams.col("members", "team")}::text = v_approvers ->> 'team' and tm.${teams.col("members", "user")} = ${member})`;
23305
+ const teamMatch = (member, team) => teams === void 0 ? "false" : `exists (select 1 from ${teams.table("members")} tm where tm.${teams.col("members", "team")}::text = ${team} and tm.${teams.col("members", "user")} = ${member})`;
23186
23306
  const teamMembers = teams === void 0 ? "" : `
23187
23307
  union
23188
23308
  select tm.${teams.col("members", "user")} from ${teams.table("members")} tm
@@ -23192,19 +23312,34 @@ function build$144(ctx, layout) {
23192
23312
  const managerMember = manager === void 0 ? "" : `
23193
23313
  union
23194
23314
  select ${manager} where coalesce((v_approvers ->> 'manager')::boolean, false)`;
23195
- const approverMatch = `((coalesce(v_approvers -> 'users', '[]'::jsonb) ? v_me::text)
23196
- or (v_approvers ->> 'permission' is not null and ${tenantless ? `case when v_req.${c("tenant")} is null then ${ctx.staff("v_approvers ->> 'permission'")} else ${ctx.can("tenant", `v_req.${c("tenant")}`, "v_approvers ->> 'permission'")} end` : ctx.can("tenant", `v_req.${c("tenant")}`, "v_approvers ->> 'permission'")})
23197
- or (v_approvers ->> 'role' is not null and exists (
23315
+ const factTenant = "approval_fact.tenant";
23316
+ const factValue = "approval_fact.value";
23317
+ const permissionMatch = tenantless ? `case when v_req.${c("tenant")} is null then ${ctx.staff("v_approvers ->> 'permission'")} else ${ctx.can("tenant", `v_req.${c("tenant")}`, "v_approvers ->> 'permission'")} end` : ctx.can("tenant", `v_req.${c("tenant")}`, "v_approvers ->> 'permission'");
23318
+ const roleFact = `exists (
23198
23319
  select 1 from ${members.table("memberships")} m
23199
- where m.${mt} = v_req.${c("tenant")} and m.${mu} = v_me and m.${mr} = ${approverRole}
23200
- ))
23201
- or (v_approvers ->> 'team' is not null and ${teamMatch("v_me")})${manager === void 0 ? "" : `
23202
- or (coalesce((v_approvers ->> 'manager')::boolean, false) and ${managerMatch(ctx, {
23203
- requester: `v_req.${c("requestedBy")}`,
23204
- tenant: `v_req.${c("tenant")}`,
23320
+ where m.${mt} = ${factTenant} and m.${mu} = v_me and m.${mr} = ${roleValue(ctx, factValue, factTenant)}
23321
+ )`;
23322
+ const managerFact = manager === void 0 ? "false" : managerMatch(ctx, {
23323
+ requester: "approval_fact.requester",
23324
+ tenant: factTenant,
23205
23325
  user: "v_me",
23206
- ...managerEmployee === void 0 ? {} : { employee: managerEmployee }
23207
- })})`})`;
23326
+ ...managerEmployee === void 0 ? {} : { employee: factValue }
23327
+ });
23328
+ const fact = (kind, value, requester = "null") => `${fn("approval_fact")}(v_req.${c("tenant")}, ${sqlString(kind)}, ${value}, ${requester})`;
23329
+ const approverMatch = `((coalesce(v_approvers -> 'users', '[]'::jsonb) ? v_me::text)
23330
+ or (v_approvers ->> 'permission' is not null and ${permissionMatch})
23331
+ or (v_approvers ->> 'role' is not null and ${fact("role", "v_approvers ->> 'role'")})
23332
+ or (v_approvers ->> 'team' is not null and ${fact("team", "v_approvers ->> 'team'")})${manager === void 0 ? "" : `
23333
+ or (coalesce((v_approvers ->> 'manager')::boolean, false) and ${fact("manager", managerEmployee ?? "null", `v_req.${c("requestedBy")}`)})`})`;
23334
+ const through = roleThrough(members);
23335
+ const rolesTable = through ? through.table : accessModel(ctx) === "catalog" ? ctx.of("permissions").table("roles") : void 0;
23336
+ const memoTriggers = [
23337
+ members.table("memberships"),
23338
+ ...rolesTable === void 0 ? [] : [rolesTable],
23339
+ ...teams === void 0 ? [] : [teams.table("members")]
23340
+ ].map((table) => `drop trigger if exists ${ctx.trigger("approval_memo")} on ${table};
23341
+ create trigger ${ctx.trigger("approval_memo")} after insert or update or delete on ${table}
23342
+ for each statement execute function ${fn("approval_memo_bump")}();`).join("\n");
23208
23343
  const notFound = fail$1("APPROVAL_NOT_FOUND", "approval request not found", "P0002");
23209
23344
  const queues = [...new Set(policies.flatMap((policy) => policy.run?.kind === "queue" ? [policy.run.queue] : []))];
23210
23345
  const queueRun = queues.length === 0 ? "" : `
@@ -23405,12 +23540,57 @@ as $$
23405
23540
  $$;
23406
23541
  ${userGrant(`${fn("approval_policy")}(text, text)`)}
23407
23542
 
23543
+ ${MEMO_FUNCTIONS.trim()}
23544
+
23545
+ create or replace function ${fn("approval_memo_bump")}()
23546
+ returns trigger
23547
+ language plpgsql
23548
+ security definer
23549
+ set search_path = ''
23550
+ as $$
23551
+ begin
23552
+ perform better_supabase.memo_set('approvals.gen', (coalesce(better_supabase.memo_get('approvals.gen'), '0')::bigint + 1)::text);
23553
+ return null;
23554
+ end;
23555
+ $$;
23556
+ ${triggerGrant(`${fn("approval_memo_bump")}()`)}
23557
+ ${memoTriggers}
23558
+
23559
+ create or replace function ${fn("approval_fact")}(tenant ${ctx.idType}, kind text, value text, requester uuid default null)
23560
+ returns boolean
23561
+ language plpgsql
23562
+ stable
23563
+ security definer
23564
+ set search_path = ''
23565
+ as $$
23566
+ declare
23567
+ v_me uuid := auth.uid();
23568
+ v_key text := 'approvals.f' || md5(format('%s|%s|%s|%s|%s', v_me, approval_fact.tenant, approval_fact.kind, approval_fact.value, approval_fact.requester));
23569
+ v_stamp text := statement_timestamp()::text || '/' || coalesce(better_supabase.memo_get('approvals.gen'), '0');
23570
+ v_hit text := better_supabase.memo_get(v_key);
23571
+ v_result boolean;
23572
+ begin
23573
+ if v_hit is not null and split_part(v_hit, '|', 1) = v_stamp then
23574
+ return split_part(v_hit, '|', 2) = 't';
23575
+ end if;
23576
+ v_result := coalesce(case approval_fact.kind
23577
+ when 'role' then ${roleFact}
23578
+ when 'team' then ${teamMatch("v_me", factValue)}
23579
+ when 'manager' then ${managerFact}
23580
+ else false
23581
+ end, false);
23582
+ perform better_supabase.memo_set(v_key, v_stamp || '|' || case when v_result then 't' else 'f' end);
23583
+ return v_result;
23584
+ end;
23585
+ $$;
23586
+ ${triggerGrant(`${fn("approval_fact")}(${ctx.idType}, text, text, uuid)`)}
23587
+
23408
23588
  -- Whether the caller may decide the request's current step: a named user,
23409
23589
  -- a holder of the permission, a member with the role or in the team, or a
23410
23590
  -- delegate. The requester can't, unless the policy allows self-approval.${provider ? `
23411
23591
  -- A user the provider's isApprover allows for kind <subject type>.<action>
23412
23592
  -- may decide as well, never the requester.` : ""}
23413
- create or replace function ${fn("approval_eligible")}(request_id uuid)
23593
+ create or replace function ${fn("approval_eligible")}(request ${requests})
23414
23594
  returns boolean
23415
23595
  language plpgsql
23416
23596
  stable
@@ -23418,13 +23598,12 @@ security definer
23418
23598
  set search_path = ''
23419
23599
  as $$
23420
23600
  declare
23421
- v_req ${requests}%rowtype;
23601
+ v_req ${requests}%rowtype := approval_eligible.request;
23422
23602
  v_step jsonb;
23423
23603
  v_approvers jsonb;
23424
23604
  v_me uuid := auth.uid();
23425
23605
  begin
23426
- select * into v_req from ${requests} r where r.${c("id")} = approval_eligible.request_id;
23427
- if not found or v_me is null or v_req.${c("status")} <> 'pending' then
23606
+ if v_req.${c("id")} is null or v_me is null or v_req.${c("status")} <> 'pending' then
23428
23607
  return false;
23429
23608
  end if;
23430
23609
  if exists (
@@ -23459,8 +23638,45 @@ begin
23459
23638
  )`] : [], ...provider ? [`(v_me is distinct from v_req.${c("requestedBy")} and coalesce((${provider.sql}), false))`] : []].join("\n or ") || "false"};
23460
23639
  end;
23461
23640
  $$;
23641
+ ${userGrant(`${fn("approval_eligible")}(${requests})`)}
23642
+
23643
+ create or replace function ${fn("approval_eligible")}(request_id uuid)
23644
+ returns boolean
23645
+ language plpgsql
23646
+ stable
23647
+ security definer
23648
+ set search_path = ''
23649
+ as $$
23650
+ declare
23651
+ v_req ${requests}%rowtype;
23652
+ begin
23653
+ select * into v_req from ${requests} r where r.${c("id")} = approval_eligible.request_id;
23654
+ if not found then
23655
+ return false;
23656
+ end if;
23657
+ return ${fn("approval_eligible")}(v_req);
23658
+ end;
23659
+ $$;
23462
23660
  ${userGrant(`${fn("approval_eligible")}(uuid)`)}
23463
23661
 
23662
+ -- The pending requests the caller may decide, as a set, for a policy or a list
23663
+ -- (\`id in (select ${fn("approval_eligible_ids")}())\`): Postgres evaluates the set once per
23664
+ -- statement, not once per row. It calls approval_eligible for each pending
23665
+ -- request, so the two never disagree. Pass a tenant to read one tenant's.
23666
+ create or replace function ${fn("approval_eligible_ids")}(tenant ${ctx.idType} default null)
23667
+ returns setof uuid
23668
+ language sql
23669
+ stable
23670
+ security definer
23671
+ set search_path = ''
23672
+ as $$
23673
+ select r.${c("id")} from ${requests} r
23674
+ where r.${c("status")} = 'pending'
23675
+ and (approval_eligible_ids.tenant is null or r.${c("tenant")} = approval_eligible_ids.tenant)
23676
+ and ${fn("approval_eligible")}(r)
23677
+ $$;
23678
+ ${userGrant(`${fn("approval_eligible_ids")}(${ctx.idType})`)}
23679
+
23464
23680
  -- Notifies the current step's approvers (requested, reminder), its fallback
23465
23681
  -- approvers (escalated), a delegate (delegated) or the requester (approved,
23466
23682
  -- rejected, expired).
@@ -23683,8 +23899,8 @@ begin
23683
23899
  and (list_approvals.subject_id is null or x.${c("subjectId")} = list_approvals.subject_id)
23684
23900
  and (list_approvals.before is null or x.${c("createdAt")} < list_approvals.before)
23685
23901
  and case
23686
- when list_approvals.assigned then ${fn("approval_eligible")}(x.${c("id")})
23687
- else x.${c("requestedBy")} = auth.uid() or (v_read and (${SERVICE_CALLER$1} or ${readable("x")})) or ${fn("approval_eligible")}(x.${c("id")})
23902
+ when list_approvals.assigned then x.${c("id")} in (select ${fn("approval_eligible_ids")}(list_approvals.tenant))
23903
+ else x.${c("requestedBy")} = auth.uid() or (v_read and (${SERVICE_CALLER$1} or ${readable("x")})) or x.${c("id")} in (select ${fn("approval_eligible_ids")}(list_approvals.tenant))
23688
23904
  end
23689
23905
  order by x.${c("createdAt")} desc, x.${c("id")}
23690
23906
  limit ${pageSize("list_approvals.page_size", 50, 200)}
@@ -23800,7 +24016,7 @@ const APPROVALS$1 = {
23800
24016
  from ${own.table("requests")} r
23801
24017
  where ${r("status")} = 'pending'${own.has("requests", "expiresAt") ? `\n and (${r("expiresAt")} is null or ${r("expiresAt")} > now())` : ""}
23802
24018
  and ${myWorkTenant(r("tenant"))}
23803
- and ${own.fn("approval_eligible")}(${r("id")})` }];
24019
+ and ${own.fn("approval_eligible")}(r)` }];
23804
24020
  }
23805
24021
  },
23806
24022
  name: "approvals",
@@ -23825,15 +24041,28 @@ const APPROVALS$1 = {
23825
24041
  ],
23826
24042
  target: "schema",
23827
24043
  modes: ["managed", "custom"],
23828
- version: 2,
24044
+ version: 4,
23829
24045
  names: APPROVALS_NAMES,
23830
- upgrades: [{
23831
- from: 1,
23832
- description: "Adds approval_items and the item functions; decide_approval refuses a request that has items.",
23833
- sql: () => ""
23834
- }],
24046
+ upgrades: [
24047
+ {
24048
+ from: 1,
24049
+ description: "Adds approval_items and the item functions; decide_approval refuses a request that has items.",
24050
+ sql: () => ""
24051
+ },
24052
+ {
24053
+ from: 2,
24054
+ description: "Adds approval_eligible_ids(tenant), the set of pending requests the caller may decide; list_approvals reads it once per statement.",
24055
+ sql: () => ""
24056
+ },
24057
+ {
24058
+ from: 3,
24059
+ description: "Adds approval_eligible(approval_requests) and approval_fact, which reads the caller's permission, role, team and manager approvals once per statement.",
24060
+ sql: () => ""
24061
+ }
24062
+ ],
23835
24063
  contract: contract$125,
23836
- build: build$144
24064
+ build: build$144,
24065
+ tests: approvalTests
23837
24066
  };
23838
24067
  // src/sql/modules/ai-chat-extras.ts
23839
24068
  /**
@@ -39601,6 +39830,28 @@ function tenantLabel(ctx, tenant) {
39601
39830
  if (!organizations.has("organizations", "name")) return "null";
39602
39831
  return `(select o.${organizations.col("organizations", "name")}::text from ${organizations.table("organizations")} o where o.${organizations.col("organizations", "id")} = ${tenant})`;
39603
39832
  }
39833
+ /**
39834
+ * The row trigger's insert values with the tenant label read from a transaction
39835
+ * memo: one lookup per tenant and transaction, not per row.
39836
+ */
39837
+ function memoizedTenantLabel(ctx, values) {
39838
+ const label = tenantLabel(ctx, "row_tenant");
39839
+ if (label === "null" || !values.includes(label)) return {
39840
+ values,
39841
+ sql: ""
39842
+ };
39843
+ return {
39844
+ values: values.replaceAll(label, "v_label"),
39845
+ sql: `
39846
+ if row_tenant is not null then
39847
+ v_label := better_supabase.memo_get('audit.tenant_label.t' || replace(row_tenant::text, '-', ''));
39848
+ if v_label is null then
39849
+ v_label := ${label};
39850
+ perform better_supabase.memo_set('audit.tenant_label.t' || replace(row_tenant::text, '-', ''), coalesce(v_label, ''));
39851
+ end if;
39852
+ end if;`
39853
+ };
39854
+ }
39604
39855
  // src/sql/modules/audit-api.ts
39605
39856
  /** Logical log column to the key `list_audit_events` returns it under. */
39606
39857
  const ENTRY_KEYS = [
@@ -40726,6 +40977,51 @@ function recordedMarkSql() {
40726
40977
  perform pg_catalog.set_config('bsb.recorded', coalesce(pg_catalog.current_setting('bsb.recorded', true), '') || E'\\n' || audit_event.target_type || ':' || audit_event.record_id, true);
40727
40978
  end if;`;
40728
40979
  }
40980
+ // src/sql/modules/audit-event-args.ts
40981
+ /** `audit_event`'s argument types. */
40982
+ const EVENT_ARGS = (id) => `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text, text, text, uuid, uuid, text`;
40983
+ /** `audit_event`'s arguments, as the keys of an `audit_event_many` element. */
40984
+ const EVENT_KEYS$1 = (id) => [
40985
+ ["event_type", "text"],
40986
+ ["category", "text"],
40987
+ [
40988
+ "outcome",
40989
+ "text",
40990
+ "'success'"
40991
+ ],
40992
+ ["source", "text"],
40993
+ ["target_type", "text"],
40994
+ ["record_id", "text"],
40995
+ ["tenant", id],
40996
+ [
40997
+ "metadata",
40998
+ "jsonb",
40999
+ "'{}'"
41000
+ ],
41001
+ ["idempotency_key", "text"],
41002
+ ["restricted", "jsonb"],
41003
+ ["actor_id", "uuid"],
41004
+ ["summary", "text"],
41005
+ ["target_label", "text"],
41006
+ ["correlation_id", "text"],
41007
+ ["actor_kind", "text"],
41008
+ ["actor_label", "text"],
41009
+ ["ip", "inet"],
41010
+ ["user_agent", "text"],
41011
+ ["session_id", "text"],
41012
+ ["request_id", "text"],
41013
+ ["scope", "text"],
41014
+ ["support_session", "uuid"],
41015
+ ["impersonated_by", "uuid"],
41016
+ ["impersonation_reason", "text"]
41017
+ ];
41018
+ const PREVIOUS_EVENT_ARGS = (id) => [
41019
+ `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text`,
41020
+ `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text`,
41021
+ `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text, text, text`
41022
+ ];
41023
+ /** `audit_event_trusted`'s signatures before the current one. */
41024
+ const PREVIOUS_TRUSTED_ARGS = (id) => [`text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text, text, text`];
40729
41025
  // src/sql/modules/audit-metadata.ts
40730
41026
  /**
40731
41027
  * `blocks.audit.options.metadataColumns`: an adopted log's own columns and the
@@ -41146,87 +41442,6 @@ function rowPairs(ctx, snapshots, expr, context) {
41146
41442
  ...context
41147
41443
  ];
41148
41444
  }
41149
- // src/sql/modules/audit-statement.ts
41150
- /**
41151
- * The trigger reads the JWT and the request headers once per call, not once per
41152
- * column that uses them.
41153
- */
41154
- function once(sql) {
41155
- return sql.replaceAll("auth.jwt()", "v_jwt").replaceAll(/better_supabase\.request_header\(('[^']*')\)/g, "(v_headers ->> $1)");
41156
- }
41157
- const KEY$4 = (row) => `(select string_agg(to_jsonb(${row}) ->> k.name, ',' order by k.ord) from unnest(entry.key_columns) with ordinality k(name, ord))`;
41158
- /**
41159
- * `audit_statement_change()`: the trigger function of a table audited with
41160
- * `statement => true`. It reads the transition tables once and writes every
41161
- * entry of the statement in one insert, instead of one insert per row.
41162
- */
41163
- function statementFunction$1(ctx, parts) {
41164
- const write = (source) => `with src as (
41165
- ${source}
41166
- ), paired as (
41167
- select case when s.old_row is null then 'insert' when s.new_row is null then 'delete' else 'update' end as op,
41168
- coalesce(s.new_row, s.old_row) as row_data,
41169
- s.old_row - entry.ignore as old_row, s.new_row - entry.ignore as new_row
41170
- from src s
41171
- ), changed as (
41172
- select p.*, case when p.op = 'update' then (
41173
- select array_agg(e.key order by e.key) from jsonb_each(p.new_row) e
41174
- where e.value is distinct from p.old_row -> e.key
41175
- ) end as changed_columns
41176
- from paired p
41177
- ), kept as (
41178
- select c.*, ${parts.tenantValue} as row_tenant
41179
- from changed c
41180
- where (c.op <> 'update' or c.changed_columns is not null)
41181
- and not (${recordedPredicate()})
41182
- ), final as (
41183
- select k.op, k.row_data, k.changed_columns, k.row_tenant,
41184
- k.old_row || coalesce((select jsonb_object_agg(r, '"[redacted]"'::jsonb) from unnest(entry.redact) r where k.old_row ? r), '{}') as old_row,
41185
- k.new_row || coalesce((select jsonb_object_agg(r, '"[redacted]"'::jsonb) from unnest(entry.redact) r where k.new_row ? r), '{}') as new_row
41186
- from kept k
41187
- )
41188
- insert into ${ctx.table("log")} (${parts.insert.columns})
41189
- select ${once(parts.insert.values)}
41190
- from final;`;
41191
- const sides = {
41192
- insert: "select null::jsonb as old_row, to_jsonb(n) as new_row from new_rows n",
41193
- delete: "select to_jsonb(o) as old_row, null::jsonb as new_row from old_rows o",
41194
- update: `select o.j as old_row, n.j as new_row
41195
- from (select to_jsonb(r) as j, ${KEY$4("r")} as k from old_rows r) o
41196
- full join (select to_jsonb(r) as j, ${KEY$4("r")} as k from new_rows r) n on o.k = n.k`
41197
- };
41198
- return `-- Statement-level audit (audit(..., statement => true)): the transition tables
41199
- -- hold every row the statement changed, so the whole statement is audited with
41200
- -- one insert. An update that changes a key column is audited as a delete and an
41201
- -- insert.
41202
- create or replace function better_supabase.audit_statement_change()
41203
- returns trigger
41204
- language plpgsql
41205
- security definer
41206
- set search_path = ''
41207
- as $$
41208
- declare
41209
- entry record;
41210
- settings jsonb;
41211
- v_jwt jsonb := auth.jwt();
41212
- v_headers jsonb := better_supabase.request_headers();
41213
- begin
41214
- if current_setting('better_supabase.import_audit', true) = 'summary' and better_supabase.import_run() is not null then
41215
- return null;
41216
- end if;
41217
- ${entryLoadSql(ctx)}
41218
- if tg_op = 'INSERT' then
41219
- ${write(sides.insert)}
41220
- elsif tg_op = 'DELETE' then
41221
- ${write(sides.delete)}
41222
- else
41223
- ${write(sides.update)}
41224
- end if;
41225
- return null;
41226
- end;
41227
- $$;
41228
- ${parts.grant}`;
41229
- }
41230
41445
  // src/sql/modules/audit-subjects.ts
41231
41446
  const HEADER = /^[a-z0-9-]+$/;
41232
41447
  const COLUMN$8 = /^[a-z_][a-z0-9_]*$/;
@@ -41340,12 +41555,14 @@ create index if not exists ${sqlIdent$1(`audit_events_${name}_idx`)} on ${log} (
41340
41555
  }
41341
41556
  /**
41342
41557
  * How the caller acted: service, support, impersonation, oauth-client, staff
41343
- * (with `staffClaim`), user or system.
41558
+ * (with `staffClaim`), user or system. `import_run()` sits in a scalar
41559
+ * subselect, so a statement-level insert reads it once, not once per row.
41344
41560
  */
41561
+ const INTEGRATION_TEST = "(select better_supabase.import_run()) is not null";
41345
41562
  function actorKind(ctx) {
41346
41563
  const staff = staffTest(ctx);
41347
41564
  return `case
41348
- when better_supabase.import_run() is not null then 'integration'
41565
+ when ${INTEGRATION_TEST} then 'integration'
41349
41566
  when coalesce(auth.jwt() ->> 'role', '') = 'service_role' then 'service'
41350
41567
  when auth.jwt() -> 'act' ->> 'kind' = 'support' then 'support'
41351
41568
  when auth.jwt() -> 'act' is not null then 'impersonation'
@@ -41354,9 +41571,101 @@ function actorKind(ctx) {
41354
41571
  else 'system'
41355
41572
  end`;
41356
41573
  }
41574
+ // src/sql/modules/audit-statement.ts
41575
+ /**
41576
+ * The trigger reads the JWT and the request headers once per call, not once per
41577
+ * column that uses them.
41578
+ */
41579
+ function once(sql) {
41580
+ return sql.replaceAll(INTEGRATION_TEST, "v_integration").replaceAll("auth.jwt()", "v_jwt").replaceAll(/better_supabase\.request_header\(('[^']*')\)/g, "(v_headers ->> $1)");
41581
+ }
41582
+ const KEY$4 = (row) => `(select string_agg(to_jsonb(${row}) ->> k.name, ',' order by k.ord) from unnest(entry.key_columns) with ordinality k(name, ord))`;
41583
+ /**
41584
+ * `audit_statement_change()`: the trigger function of a table audited with
41585
+ * `statement => true`. It reads the transition tables once and writes every
41586
+ * entry of the statement in one insert, instead of one insert per row.
41587
+ */
41588
+ function statementFunction$1(ctx, parts) {
41589
+ const label = tenantLabel(ctx, "row_tenant");
41590
+ const labels = label !== "null" && parts.insert.values.includes(label);
41591
+ const values = labels ? parts.insert.values.replaceAll(label, "l.label") : parts.insert.values;
41592
+ const write = (source) => `with src as (
41593
+ ${source}
41594
+ ), paired as (
41595
+ select case when s.old_row is null then 'insert' when s.new_row is null then 'delete' else 'update' end as op,
41596
+ coalesce(s.new_row, s.old_row) as row_data,
41597
+ s.old_row - entry.ignore as old_row, s.new_row - entry.ignore as new_row
41598
+ from src s
41599
+ ), changed as (
41600
+ select p.*, case when p.op = 'update' then (
41601
+ select array_agg(e.key order by e.key) from jsonb_each(p.new_row) e
41602
+ where e.value is distinct from p.old_row -> e.key
41603
+ ) end as changed_columns
41604
+ from paired p
41605
+ ), kept as (
41606
+ select c.*, ${parts.tenantValue} as row_tenant
41607
+ from changed c
41608
+ where (c.op <> 'update' or c.changed_columns is not null)
41609
+ and not (${recordedPredicate()})
41610
+ ), final as (
41611
+ select k.op, k.row_data, k.changed_columns, k.row_tenant,
41612
+ k.old_row || coalesce((select jsonb_object_agg(r, '"[redacted]"'::jsonb) from unnest(entry.redact) r where k.old_row ? r), '{}') as old_row,
41613
+ k.new_row || coalesce((select jsonb_object_agg(r, '"[redacted]"'::jsonb) from unnest(entry.redact) r where k.new_row ? r), '{}') as new_row
41614
+ from kept k
41615
+ )${labels ? `, labels as (
41616
+ select t.row_tenant as tenant_key, ${tenantLabel(ctx, "t.row_tenant")} as label
41617
+ from (select distinct row_tenant from kept) t
41618
+ )` : ""}
41619
+ insert into ${ctx.table("log")} (${parts.insert.columns})
41620
+ select ${once(values)}
41621
+ from final${labels ? "\n left join labels l on l.tenant_key is not distinct from final.row_tenant" : ""};`;
41622
+ const sides = {
41623
+ insert: "select null::jsonb as old_row, to_jsonb(n) as new_row from new_rows n",
41624
+ delete: "select to_jsonb(o) as old_row, null::jsonb as new_row from old_rows o",
41625
+ update: `select o.j as old_row, n.j as new_row
41626
+ from (select to_jsonb(r) as j, ${KEY$4("r")} as k from old_rows r) o
41627
+ full join (select to_jsonb(r) as j, ${KEY$4("r")} as k from new_rows r) n on o.k = n.k`
41628
+ };
41629
+ return `-- Statement-level audit (audit(..., statement => true)): the transition tables
41630
+ -- hold every row the statement changed, so the whole statement is audited with
41631
+ -- one insert. An update that changes a key column is audited as a delete and an
41632
+ -- insert.
41633
+ create or replace function better_supabase.audit_statement_change()
41634
+ returns trigger
41635
+ language plpgsql
41636
+ security definer
41637
+ set search_path = ''
41638
+ as $$
41639
+ declare
41640
+ entry record;
41641
+ settings jsonb;
41642
+ v_jwt jsonb := auth.jwt();
41643
+ v_headers jsonb := better_supabase.request_headers();
41644
+ v_integration boolean := better_supabase.import_run() is not null;
41645
+ begin
41646
+ if v_integration and current_setting('better_supabase.import_audit', true) = 'summary' then
41647
+ return null;
41648
+ end if;
41649
+ ${entryLoadSql(ctx)}
41650
+ if tg_op = 'INSERT' then
41651
+ ${write(sides.insert)}
41652
+ elsif tg_op = 'DELETE' then
41653
+ ${write(sides.delete)}
41654
+ else
41655
+ ${write(sides.update)}
41656
+ end if;
41657
+ return null;
41658
+ end;
41659
+ $$;
41660
+ ${parts.grant}`;
41661
+ }
41357
41662
  // src/sql/modules/audit-tests.ts
41358
- const PROBE = "pg_temp.bsb_audit_probe";
41359
- const PROBE_NAME = "(select n.nspname from pg_catalog.pg_namespace n where n.oid = pg_catalog.pg_my_temp_schema()) || '.bsb_audit_probe'";
41663
+ /**
41664
+ * Each table gets its own probe name: the log keeps an earlier probe's entries
41665
+ * for the whole transaction.
41666
+ */
41667
+ const probeTable = (index) => `bsb_audit_probe_${String(index)}`;
41668
+ const probeName = (index) => `(select n.nspname from pg_catalog.pg_namespace n where n.oid = pg_catalog.pg_my_temp_schema()) || '.${probeTable(index)}'`;
41360
41669
  const textArray$8 = (names) => `${sqlString(`{${names.map((name) => `"${name.replaceAll("\"", "\\\"")}"`).join(",")}}`)}::text[]`;
41361
41670
  /** A quoted identifier for `schema.table` from its unquoted parts. */
41362
41671
  const quotedTarget = (target) => {
@@ -41369,7 +41678,7 @@ const quotedTarget = (target) => {
41369
41678
  * carries the same registration as the table, so the trigger writes the same
41370
41679
  * entries the table's rows would.
41371
41680
  */
41372
- const probe = (table) => `create temp table bsb_audit_probe (like ${quotedTarget(table.target)} including defaults including identity including generated) on commit drop;
41681
+ const probe = (table, index) => `create temp table ${probeTable(index)} (like ${quotedTarget(table.target)} including defaults including identity including generated) on commit drop;
41373
41682
  do $$
41374
41683
  declare
41375
41684
  col record;
@@ -41377,13 +41686,13 @@ declare
41377
41686
  begin
41378
41687
  for col in
41379
41688
  select a.attname from pg_catalog.pg_attribute a
41380
- where a.attrelid = '${PROBE}'::regclass and a.attnum > 0 and not a.attisdropped
41689
+ where a.attrelid = 'pg_temp.${probeTable(index)}'::regclass and a.attnum > 0 and not a.attisdropped
41381
41690
  and a.attnotnull and a.attidentity = ''
41382
41691
  loop
41383
- execute format('alter table ${PROBE} alter column %I drop not null', col.attname);
41692
+ execute format('alter table pg_temp.${probeTable(index)} alter column %I drop not null', col.attname);
41384
41693
  end loop;
41385
- perform better_supabase.audit('${PROBE}', ignore => ${textArray$8(table.ignore)}, redact => ${textArray$8(table.redact)});
41386
- insert into ${PROBE} default values;
41694
+ perform better_supabase.audit('pg_temp.${probeTable(index)}', ignore => ${textArray$8(table.ignore)}, redact => ${textArray$8(table.redact)});
41695
+ insert into pg_temp.${probeTable(index)} default values;
41387
41696
  select string_agg(format('%I = %s', a.attname, v.value), ', ') into sets
41388
41697
  from pg_catalog.pg_attribute a
41389
41698
  join pg_catalog.pg_type t on t.oid = a.atttypid
@@ -41402,20 +41711,20 @@ begin
41402
41711
  when t.typcategory = 'A' then quote_literal('{}') || '::' || format_type(t.oid, null)
41403
41712
  end as value
41404
41713
  ) v
41405
- where a.attrelid = '${PROBE}'::regclass and a.attnum > 0 and not a.attisdropped
41714
+ where a.attrelid = 'pg_temp.${probeTable(index)}'::regclass and a.attnum > 0 and not a.attisdropped
41406
41715
  and a.attidentity = '' and a.attgenerated = '' and v.value is not null;
41407
41716
  if sets is not null then
41408
- execute format('update ${PROBE} set %s', sets);
41717
+ execute format('update pg_temp.${probeTable(index)} set %s', sets);
41409
41718
  end if;
41410
- delete from ${PROBE};
41719
+ delete from pg_temp.${probeTable(index)};
41411
41720
  end;
41412
41721
  $$;`;
41413
41722
  /**
41414
- * The pgTAP file for one audited table: the trigger and registration match the
41723
+ * The section for one audited table: the trigger and registration match the
41415
41724
  * `audit()` call, and inserts, updates and deletes on a copy of the table write
41416
41725
  * entries without the ignored columns and with the redacted values masked.
41417
41726
  */
41418
- function auditTableTest(ctx, table, restricted) {
41727
+ function auditTableSection(ctx, table, restricted, index) {
41419
41728
  const dot = table.target.indexOf(".");
41420
41729
  const schema = sqlString(table.target.slice(0, dot));
41421
41730
  const name = sqlString(table.target.slice(dot + 1));
@@ -41428,16 +41737,12 @@ function auditTableTest(ctx, table, restricted) {
41428
41737
  `select extensions.is(array(select jsonb_array_elements_text(coalesce(better_supabase.audit_settings(${regclass}) -> 'ignore', '[]'))), ${textArray$8(table.ignore)}, ${sqlString(`${table.target} is registered with its ignored columns`)});`,
41429
41738
  `select extensions.is(array(select jsonb_array_elements_text(coalesce(better_supabase.audit_settings(${regclass}) -> 'redact', '[]'))), ${textArray$8(table.redact)}, ${sqlString(`${table.target} is registered with its redacted columns`)});`
41430
41739
  ];
41431
- if (!(ctx.has("log", "table") && ctx.has("log", "op"))) return `begin;
41432
- create extension if not exists pgtap with schema extensions;
41433
- select extensions.plan(${String(checks.length)});
41434
-
41435
- ${checks.join("\n")}
41436
-
41437
- select * from extensions.finish();
41438
- rollback;`;
41740
+ if (!(ctx.has("log", "table") && ctx.has("log", "op"))) return {
41741
+ setup: "",
41742
+ checks
41743
+ };
41439
41744
  const joined = restricted && ctx.hasTable("restricted");
41440
- const entries = `from ${log} l${joined ? ` left join ${ctx.table("restricted")} r on r.${ctx.col("restricted", "entry")} = l.${c("id")}` : ""} where l.${c("table")} = ${PROBE_NAME}`;
41745
+ const entries = `from ${log} l${joined ? ` left join ${ctx.table("restricted")} r on r.${ctx.col("restricted", "entry")} = l.${c("id")}` : ""} where l.${c("table")} = ${probeName(index)}`;
41441
41746
  const side = (logical) => {
41442
41747
  if (joined) return ctx.has("restricted", logical) ? `r.${ctx.col("restricted", logical)}` : void 0;
41443
41748
  return ctx.has("log", logical) ? `l.${c(logical)}` : void 0;
@@ -41450,23 +41755,35 @@ rollback;`;
41450
41755
  }
41451
41756
  const after = side("new");
41452
41757
  if (table.redact.length > 0 && after !== void 0) checks.push(`select extensions.is((select count(*)::int ${entries} and l.${c("op")} <> 'delete' and exists (select 1 from unnest(${textArray$8(table.redact)}) k where ${after} ? k and ${after} ->> k is distinct from '[redacted]')), 0, ${sqlString(`entries for ${table.target} mask ${table.redact.join(", ")}`)});`);
41453
- return `begin;
41758
+ return {
41759
+ setup: probe(table, index),
41760
+ checks
41761
+ };
41762
+ }
41763
+ /**
41764
+ * One pgTAP file for every table in `audited`, with each table's assertion
41765
+ * names. Each table has its own numbered probe copy, dropped after its checks.
41766
+ */
41767
+ function auditTests(ctx, audited, restricted) {
41768
+ if (audited.length === 0) return [];
41769
+ const sections = audited.map((table, index) => auditTableSection(ctx, table, restricted, index));
41770
+ const total = sections.reduce((sum, each) => sum + each.checks.length, 0);
41771
+ const body = sections.map(({ setup, checks }, index) => [
41772
+ setup,
41773
+ ...checks,
41774
+ ...setup === "" ? [] : [`drop table pg_temp.${probeTable(index)};`]
41775
+ ].filter((part) => part !== "").join("\n")).join("\n\n");
41776
+ return [{
41777
+ name: "tables",
41778
+ sql: `begin;
41454
41779
  create extension if not exists pgtap with schema extensions;
41455
- select extensions.plan(${String(checks.length)});
41780
+ select extensions.plan(${String(total)});
41456
41781
 
41457
- ${probe(table)}
41458
-
41459
- ${checks.join("\n")}
41782
+ ${body}
41460
41783
 
41461
41784
  select * from extensions.finish();
41462
- rollback;`;
41463
- }
41464
- /** One pgTAP file per table in `audited`, named after the table. */
41465
- function auditTests(ctx, audited, restricted) {
41466
- return audited.map((table) => ({
41467
- name: table.target.toLowerCase().replaceAll(/[^a-z0-9]+/g, "_"),
41468
- sql: auditTableTest(ctx, table, restricted)
41469
- }));
41785
+ rollback;`
41786
+ }];
41470
41787
  }
41471
41788
  // src/sql/modules/audit-upgrades.ts
41472
41789
  /** The audit module's `upgrade` steps, from each installed version. */
@@ -41863,6 +42180,7 @@ function triggerFunction(ctx, tenantColumn, restricted) {
41863
42180
  ))
41864
42181
  into changed_values
41865
42182
  from unnest(coalesce(changed_columns, array(select jsonb_object_keys(coalesce(new_row, old_row))))) k;` : "";
42183
+ const memo = memoizedTenantLabel(ctx, insert.values);
41866
42184
  return `create or replace function better_supabase.audit_row_change()
41867
42185
  returns trigger
41868
42186
  language plpgsql
@@ -41881,17 +42199,19 @@ declare
41881
42199
  row_tenant ${ctx.idType};
41882
42200
  v_jwt jsonb := auth.jwt();
41883
42201
  v_headers jsonb := better_supabase.request_headers();
42202
+ v_integration boolean := better_supabase.import_run() is not null;
42203
+ v_label text;
41884
42204
  path_value text;
41885
42205
  path_step jsonb;
41886
42206
  begin
41887
42207
  -- An import run with imports.audit 'summary' audits one entry per entity at
41888
42208
  -- its end instead of one per row (ADR 0141).
41889
- if current_setting('better_supabase.import_audit', true) = 'summary' and better_supabase.import_run() is not null then
42209
+ if v_integration and current_setting('better_supabase.import_audit', true) = 'summary' then
41890
42210
  return null;
41891
42211
  end if;
41892
42212
  ${entrySql$1(ctx)}
41893
42213
  row_tenant := ${tenantValue};
41894
- ${tenantFallbackSql(ctx.idType)}
42214
+ ${tenantFallbackSql(ctx.idType)}${memo.sql}
41895
42215
  old_row := old_row - entry.ignore;
41896
42216
  new_row := new_row - entry.ignore;
41897
42217
  if tg_op = 'UPDATE' then
@@ -41907,7 +42227,7 @@ ${tenantFallbackSql(ctx.idType)}
41907
42227
  new_row := new_row || coalesce((select jsonb_object_agg(k, '"[redacted]"'::jsonb) from unnest(entry.redact) k where new_row ? k), '{}');${changedValues}
41908
42228
  insert into ${ctx.table("log")} (${insert.columns})
41909
42229
  values (
41910
- ${once(insert.values)}
42230
+ ${once(memo.values)}
41911
42231
  )
41912
42232
  returning ${ctx.col("log", "id")} into entry_id;${once(restrictedInsert(ctx, restricted, {
41913
42233
  old: "old_row",
@@ -41935,50 +42255,6 @@ function statementTrigger(ctx, tenantColumn, restricted) {
41935
42255
  grant: triggerGrant("better_supabase.audit_statement_change()")
41936
42256
  });
41937
42257
  }
41938
- /** `audit_event`'s argument types. */
41939
- const EVENT_ARGS = (id) => `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text, text, text, uuid, uuid, text`;
41940
- /** `audit_event`'s arguments, as the keys of an `audit_event_many` element. */
41941
- const EVENT_KEYS$1 = (id) => [
41942
- ["event_type", "text"],
41943
- ["category", "text"],
41944
- [
41945
- "outcome",
41946
- "text",
41947
- "'success'"
41948
- ],
41949
- ["source", "text"],
41950
- ["target_type", "text"],
41951
- ["record_id", "text"],
41952
- ["tenant", id],
41953
- [
41954
- "metadata",
41955
- "jsonb",
41956
- "'{}'"
41957
- ],
41958
- ["idempotency_key", "text"],
41959
- ["restricted", "jsonb"],
41960
- ["actor_id", "uuid"],
41961
- ["summary", "text"],
41962
- ["target_label", "text"],
41963
- ["correlation_id", "text"],
41964
- ["actor_kind", "text"],
41965
- ["actor_label", "text"],
41966
- ["ip", "inet"],
41967
- ["user_agent", "text"],
41968
- ["session_id", "text"],
41969
- ["request_id", "text"],
41970
- ["scope", "text"],
41971
- ["support_session", "uuid"],
41972
- ["impersonated_by", "uuid"],
41973
- ["impersonation_reason", "text"]
41974
- ];
41975
- const PREVIOUS_EVENT_ARGS = (id) => [
41976
- `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text`,
41977
- `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text`,
41978
- `text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text, text, text`
41979
- ];
41980
- /** `audit_event_trusted`'s signatures before the current one. */
41981
- const PREVIOUS_TRUSTED_ARGS = (id) => [`text, text, text, text, text, text, ${id}, jsonb, text, jsonb, uuid, text, text, text, text, text, inet, text, text, text, text`];
41982
42258
  function auditEvent(ctx, restricted) {
41983
42259
  const id = ctx.idType;
41984
42260
  const extra = metadataColumns$1(ctx);
@@ -42062,10 +42338,11 @@ set search_path = ''
42062
42338
  as $$
42063
42339
  declare
42064
42340
  existing text;
42341
+ v_integration boolean := better_supabase.import_run() is not null;
42065
42342
  entry_id ${log}.${c("id")}%type;${extra.length > 0 ? "\n entry_row jsonb;\n entry_columns text;" : ""}
42066
42343
  begin${noRestricted}
42067
42344
  -- imports.audit 'summary' (ADR 0141): the run audits per entity at its end.
42068
- if current_setting('better_supabase.import_audit', true) = 'summary' and better_supabase.import_run() is not null then
42345
+ if v_integration and current_setting('better_supabase.import_audit', true) = 'summary' then
42069
42346
  return null;
42070
42347
  end if;
42071
42348
  ${trusted ? "actor_id := coalesce(actor_id, auth.uid());" : `if not (${SERVICE_CALLER$1}) then
@@ -42088,7 +42365,7 @@ begin${noRestricted}
42088
42365
  return entry_id::text;
42089
42366
  end;
42090
42367
  $$;
42091
- `.replaceAll("audit_event.", `${name}.`);
42368
+ `.replaceAll("audit_event.", `${name}.`).replaceAll(INTEGRATION_TEST, "v_integration");
42092
42369
  return `-- Records a semantic app event (invoice.sent, member.invited) next to the
42093
42370
  -- row changes. A repeated idempotency_key returns the first entry's id.
42094
42371
  -- actor_id, actor_kind, actor_label, ip, user_agent, session_id, request_id
@@ -42192,6 +42469,7 @@ function auditSql$1(ctx, layout) {
42192
42469
  const tenantColumn = ctx.text("tenantColumn", layout.tenantColumn ?? "organization_id");
42193
42470
  return [
42194
42471
  SCHEMA$6,
42472
+ MEMO_FUNCTIONS.trim(),
42195
42473
  registry(ctx),
42196
42474
  requestIpSql(ctx),
42197
42475
  ctx.manages ? managedTables(ctx, restricted) : "",
@@ -99497,7 +99775,7 @@ begin
99497
99775
  ${ctx.hook("before_employee_create", [[ctx.idType, "create_employee.tenant"], ["jsonb", "create_employee.attrs"]])}
99498
99776
  begin
99499
99777
  v_status := ${status};
99500
- if v_status = 'offboarded' then
99778
+ if ${ctx.is("employees", "status", "v_status", ["offboarded"])} then
99501
99779
  ${fail$1("EMPLOYEE_STATUS_INVALID", "create the employee, then offboard them", "22023")}
99502
99780
  end if;
99503
99781
  insert into ${table} (${insertColumns.join(", ")}${extrasInsert.columns})
@@ -100595,7 +100873,16 @@ ${triggerGrant(`better_supabase.${guardName}()`)}
100595
100873
  drop trigger if exists ${guardName} on ${t("employees")};
100596
100874
  create trigger ${guardName} before insert or update of ${e("manager")} on ${t("employees")}
100597
100875
  for each row execute function better_supabase.${guardName}();
100598
- ${mirror}`;
100876
+ ${mirror}${approvalMemo(ctx, t("employees"))}`;
100877
+ }
100878
+ function approvalMemo(ctx, table) {
100879
+ if (!ctx.installed("approvals") || ctx.of("approvals").mode === "custom") return "";
100880
+ const approvals = ctx.of("approvals");
100881
+ return `
100882
+ drop trigger if exists ${approvals.trigger("approval_memo")} on ${table};
100883
+ create trigger ${approvals.trigger("approval_memo")} after insert or update or delete on ${table}
100884
+ for each statement execute function ${approvals.fn("approval_memo_bump")}();
100885
+ `;
100599
100886
  }
100600
100887
  function optionalKey(ctx, action) {
100601
100888
  const key = ctx.config.permissions[action];
@@ -100737,7 +101024,8 @@ const EMPLOYEES = {
100737
101024
  "outbox",
100738
101025
  "relations",
100739
101026
  "hiring",
100740
- "time-tracking"
101027
+ "time-tracking",
101028
+ "approvals"
100741
101029
  ],
100742
101030
  target: "schema",
100743
101031
  modes: ["managed", "custom"],
@@ -169324,10 +169612,10 @@ const PERIODS = {
169324
169612
  const PGTAP = {
169325
169613
  name: "pgtap",
169326
169614
  title: "pgTAP helpers",
169327
- description: "tests.create_user, tests.authenticate_as and catalog checks (every_table_has_rls, policies_use, no_anon_policies, every_table_audited, partitions_have_rls) for `supabase test db`. Written to supabase/tests, never to your schema.",
169615
+ description: "tests.create_user, tests.authenticate_as (by id or email), tests.authenticate_as_issued and catalog checks (every_table_has_rls, policies_use, no_anon_policies, every_table_audited, partitions_have_rls) for `supabase test db`. Written to supabase/tests, never to your schema.",
169328
169616
  requires: [],
169329
169617
  target: "test",
169330
- build: () => `-- Runs first (000_) and commits, so later test files can use the helpers.
169618
+ build: (_ctx, layout) => `-- Runs first (000_) and commits, so later test files can use the helpers.
169331
169619
  create extension if not exists pgtap with schema extensions;
169332
169620
  create schema if not exists tests;
169333
169621
  grant usage on schema tests to anon, authenticated, service_role;
@@ -169377,6 +169665,55 @@ begin
169377
169665
  end;
169378
169666
  $$;
169379
169667
 
169668
+ -- The same by email address: tests.authenticate_as('member@acme.test'). An
169669
+ -- untyped literal or parameter resolves to this overload, so a uuid string
169670
+ -- is taken as the user's id.
169671
+ create or replace function tests.authenticate_as(user_email text)
169672
+ returns void
169673
+ language plpgsql
169674
+ set search_path = ''
169675
+ as $$
169676
+ declare
169677
+ found_id uuid;
169678
+ begin
169679
+ if user_email ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' then
169680
+ perform tests.authenticate_as(user_email::uuid);
169681
+ return;
169682
+ end if;
169683
+ select u.id into found_id from auth.users u where u.email = user_email;
169684
+ if found_id is null then
169685
+ raise exception 'tests.authenticate_as: no user with email %', user_email;
169686
+ end if;
169687
+ perform tests.authenticate_as(found_id);
169688
+ end;
169689
+ $$;
169690
+
169691
+ -- Runs as this user with the claims your custom access token hook issues, as a
169692
+ -- real sign-in does. The hook defaults to auth.hook.custom_access_token of
169693
+ -- config.toml at the time of gen; pass another as 'public.my_hook'.
169694
+ create or replace function tests.authenticate_as_issued(user_id uuid, hook text default ${layout.customAccessTokenHook === void 0 ? "null" : sqlString(layout.customAccessTokenHook)})
169695
+ returns void
169696
+ language plpgsql
169697
+ set search_path = ''
169698
+ as $$
169699
+ declare
169700
+ issued jsonb;
169701
+ base_claims jsonb;
169702
+ begin
169703
+ if hook is null then
169704
+ raise exception 'tests.authenticate_as_issued: set auth.hook.custom_access_token in config.toml, or pass the hook';
169705
+ end if;
169706
+ select jsonb_build_object('sub', u.id, 'role', 'authenticated', 'email', u.email, 'aud', 'authenticated', 'app_metadata', u.raw_app_meta_data, 'user_metadata', u.raw_user_meta_data)
169707
+ into base_claims from auth.users u where u.id = authenticate_as_issued.user_id;
169708
+ if base_claims is null then
169709
+ raise exception 'tests.authenticate_as_issued: no user %', user_id;
169710
+ end if;
169711
+ execute format('select (%s(%L::jsonb)) -> ''claims''', hook, jsonb_build_object('user_id', user_id, 'claims', base_claims, 'authentication_method', 'password')::text) into issued;
169712
+ perform set_config('request.jwt.claims', issued::text, true);
169713
+ set local role authenticated;
169714
+ end;
169715
+ $$;
169716
+
169380
169717
  create or replace function tests.authenticate_as_anon()
169381
169718
  returns void
169382
169719
  language plpgsql
@@ -190540,12 +190877,14 @@ function isReadSetsRef(value) {
190540
190877
  * a read set (the function `public.rs_<name>`), or to `{ readSets, shell? }`,
190541
190878
  * where the caller picks one of the read sets per call.
190542
190879
  */
190543
- function subjectOf(name, subject) {
190544
- if (subject === void 0) return;
190880
+ function subjectOf(name, subject, fallback) {
190881
+ if (subject === void 0) return fallback;
190882
+ if (subject === false) return;
190545
190883
  if (typeof subject !== "string" || !FUNCTION_NAME.test(subject)) throw new TypeError(`${WHERE$4}.${name}.subject must name a function as schema.function`);
190546
190884
  return subject;
190547
190885
  }
190548
- function bootstrapFunctions(ctx) {
190886
+ function bootstrapFunctions(ctx, layout) {
190887
+ const fallback = layout.accessProvider?.functions.subject;
190549
190888
  const raw = ctx.option("bootstrap");
190550
190889
  if (raw === void 0) return [];
190551
190890
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new TypeError(`${WHERE$4} must map names to functions, e.g. { home: "app.home_data" } or { home: { readSet: "home" } }`);
@@ -190558,7 +190897,7 @@ function bootstrapFunctions(ctx) {
190558
190897
  name,
190559
190898
  fn: fn.shell,
190560
190899
  readSets: fn.readSets,
190561
- subject: subjectOf(name, fn.subject)
190900
+ subject: subjectOf(name, fn.subject, fallback)
190562
190901
  };
190563
190902
  }
190564
190903
  if (isReadSetRef(fn)) {
@@ -190567,14 +190906,15 @@ function bootstrapFunctions(ctx) {
190567
190906
  name,
190568
190907
  fn: `public.rs_${fn.readSet}`,
190569
190908
  readSets: [],
190570
- subject: subjectOf(name, fn.subject)
190909
+ subject: subjectOf(name, fn.subject, fallback)
190571
190910
  };
190572
190911
  }
190573
190912
  if (typeof fn !== "string" || !FUNCTION_NAME.test(fn)) throw new TypeError(`${WHERE$4}.${name} must name a function as schema.function, e.g. "app.home_data"`);
190574
190913
  return {
190575
190914
  name,
190576
190915
  fn,
190577
- readSets: []
190916
+ readSets: [],
190917
+ subject: fallback
190578
190918
  };
190579
190919
  });
190580
190920
  }
@@ -190594,7 +190934,7 @@ function hasVersionSource(ctx, layout) {
190594
190934
  * `token_authz_version` is the token's.
190595
190935
  */
190596
190936
  function bootstrapWrappers(ctx, layout) {
190597
- const functions = bootstrapFunctions(ctx);
190937
+ const functions = bootstrapFunctions(ctx, layout);
190598
190938
  if (functions.length === 0) return "";
190599
190939
  const live = hasVersionSource(ctx, layout) ? "to_jsonb(better_supabase.caller_authz_version())" : "auth.jwt() -> 'authz_ver'";
190600
190940
  return `
@@ -190911,6 +191251,30 @@ $$;
190911
191251
  revoke execute on function better_supabase.last_sign_ins(uuid[]) from public, anon, authenticated;
190912
191252
  grant execute on function better_supabase.last_sign_ins(uuid[]) to service_role;
190913
191253
 
191254
+ -- Deletes every session and refresh token of a user and returns how many
191255
+ -- sessions went. Only the service role calls this, over SQL or the Data API.
191256
+ create or replace function better_supabase.end_sessions(p_user uuid)
191257
+ returns int
191258
+ language plpgsql
191259
+ volatile
191260
+ security definer
191261
+ set search_path = ''
191262
+ as $$
191263
+ declare
191264
+ ended int;
191265
+ begin
191266
+ with gone as (
191267
+ delete from auth.sessions s where s.user_id = end_sessions.p_user returning s.id
191268
+ )
191269
+ select count(*)::int into ended from gone;
191270
+ delete from auth.refresh_tokens t where t.user_id = end_sessions.p_user::text;
191271
+ return ended;
191272
+ end;
191273
+ $$;
191274
+
191275
+ revoke execute on function better_supabase.end_sessions(uuid) from public, anon, authenticated;
191276
+ grant execute on function better_supabase.end_sessions(uuid) to service_role;
191277
+
190914
191278
  -- The caller's own unexpired sessions, most recently active first, with the
190915
191279
  -- one behind the current token marked.
190916
191280
  create or replace function better_supabase.list_my_sessions()
@@ -207700,31 +208064,6 @@ const ACTIVITY = {
207700
208064
  contract: contract$6,
207701
208065
  build: build$7
207702
208066
  };
207703
- // src/sql/memo.ts
207704
- /**
207705
- * A memo for one transaction, over a transaction-local setting. PostgREST runs
207706
- * one request in one transaction, so a policy helper can compute a value once
207707
- * and every later call in the statement reads it (ADR 0230). The empty string
207708
- * reads as unset.
207709
- */
207710
- const MEMO_FUNCTIONS = `
207711
- create or replace function better_supabase.memo_get(key text)
207712
- returns text
207713
- language sql
207714
- volatile
207715
- set search_path = ''
207716
- as $$
207717
- select nullif(pg_catalog.current_setting('better_supabase.memo.' || key, true), '')
207718
- $$;
207719
-
207720
- create or replace function better_supabase.memo_set(key text, value text)
207721
- returns text
207722
- language sql
207723
- volatile
207724
- set search_path = ''
207725
- as $$
207726
- select pg_catalog.set_config('better_supabase.memo.' || key, value, true)
207727
- $$;`;
207728
208067
  // src/sql/modules/updated-at.ts
207729
208068
  const UPDATED_AT = {
207730
208069
  name: "updated-at",
@@ -215603,9 +215942,9 @@ create table if not exists ${n.table("deliveries")} (
215603
215942
  ...n.partitioned ? [`primary key (${v("id")}, ${v("createdAt")})`] : []
215604
215943
  ].join(",\n ")}
215605
215944
  )${n.partitioned ? ` partition by range (${v("createdAt")});\n${defaultPartition(n.table("deliveries"), fallback)}` : ";"}
215606
- ${added(n, "deliveries", [["subject", "text"]])}create index if not exists webhook_deliveries_due_idx on ${n.table("deliveries")} (${v("availableAt")}, ${v("leasedUntil")}) where ${v("status")} in ('pending', 'retrying', 'delivering');
215945
+ ${added(n, "deliveries", [["subject", "text"]])}create index if not exists webhook_deliveries_due_idx on ${n.table("deliveries")} (${v("availableAt")}, ${v("leasedUntil")}) where ${v("status")} in (${n.status("pending")}, ${n.status("retrying")}, ${n.status("delivering")});
215607
215946
  create index if not exists webhook_deliveries_endpoint_idx on ${n.table("deliveries")} (${v("endpoint")}, ${v("createdAt")} desc);
215608
- create index if not exists webhook_deliveries_open_idx on ${n.table("deliveries")} (${v("endpoint")}) where ${v("status")} in ('pending', 'retrying');
215947
+ create index if not exists webhook_deliveries_open_idx on ${n.table("deliveries")} (${v("endpoint")}) where ${v("status")} in (${n.status("pending")}, ${n.status("retrying")});
215609
215948
  create index if not exists webhook_deliveries_finished_idx on ${n.table("deliveries")} (${v("createdAt")}) where ${v("status")} in (${n.status("succeeded")}, ${n.status("canceled")}, ${n.status("dead")});${n.has("deliveries", "tenant") ? `
215610
215949
  create index if not exists webhook_deliveries_tenant_created_idx on ${n.table("deliveries")} (${v("tenant")}, ${v("createdAt")} desc);` : ""}${n.has("deliveries", "event") ? `
215611
215950
  create ${n.partitioned ? "" : "unique "}index if not exists webhook_deliveries_endpoint_event_idx on ${n.table("deliveries")} (${v("endpoint")}, ${v("event")}) where ${v("event")} is not null;` : ""}