better-supabase 0.61.1 → 0.63.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 (534) hide show
  1. package/dist/{account-parts-DtC5voD1.d.ts → account-parts-C3mte2Y7.d.ts} +1 -1
  2. package/dist/{activities-BMQuBkrQ.d.ts → activities-DFL2uhTK.d.ts} +1 -1
  3. package/dist/{adapter-base-DGiRWzEo.js → adapter-base-DXF0tNJJ.js} +1 -1
  4. package/dist/{agents-NaSREeo_.d.ts → agents-Bceu5a4z.d.ts} +1 -1
  5. package/dist/{agents-3wTmHYZr.d.ts → agents-C8BwEXD0.d.ts} +6 -6
  6. package/dist/{ai-cache-CKOJ9cLZ.d.ts → ai-cache-Dnj5iteF.d.ts} +1 -1
  7. package/dist/{ai-chat-C8FEgeTd.d.ts → ai-chat-CVmnJZcP.d.ts} +1 -1
  8. package/dist/{ai-schedules-CtxaSWA1.d.ts → ai-schedules-j51dDzm3.d.ts} +2 -2
  9. package/dist/ai-sdk/agents/index.d.ts +2 -2
  10. package/dist/ai-sdk/batches/index.d.ts +1 -1
  11. package/dist/ai-sdk/cache/index.d.ts +1 -1
  12. package/dist/ai-sdk/chat/index.d.ts +2 -2
  13. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  14. package/dist/ai-sdk/index.d.ts +5 -5
  15. package/dist/ai-sdk/memory/index.d.ts +3 -3
  16. package/dist/ai-sdk/workflow/index.d.ts +4 -4
  17. package/dist/{api-Dq7hOzxh.js → api-CKdssE3U.js} +1 -1
  18. package/dist/{api-pGkHTqH6.d.ts → api-D4gZPhMd.d.ts} +1 -1
  19. package/dist/{app-tables-BHoeMC9w.d.ts → app-tables-Br5Khxij.d.ts} +1 -1
  20. package/dist/{assistant-BQAjAXDe.d.ts → assistant-JXmSCGyW.d.ts} +2 -2
  21. package/dist/astro/index.d.ts +3 -3
  22. package/dist/astro/index.js +3 -3
  23. package/dist/{audit-actions-DC-AtyWB.d.ts → audit-actions-be1sy-Vh.d.ts} +1 -0
  24. package/dist/{authorization-glyinWcf.d.ts → authorization-k0Y3L701.d.ts} +1 -1
  25. package/dist/better-result/index.d.ts +2 -2
  26. package/dist/{bind-B-NW7-Fd.d.ts → bind-CuRPlZYY.d.ts} +4 -4
  27. package/dist/{block-env-BN4cyqTj.d.ts → block-env-hdFBj6FQ.d.ts} +4 -4
  28. package/dist/{block-tables-CkbJsNys.d.ts → block-tables-1XNfpOPP.d.ts} +1 -1
  29. package/dist/blocks/access-requests/index.d.ts +1 -1
  30. package/dist/blocks/accounting/index.d.ts +1 -1
  31. package/dist/blocks/acknowledgements/index.d.ts +1 -1
  32. package/dist/blocks/activities/index.d.ts +3 -3
  33. package/dist/blocks/advisories/index.d.ts +1 -1
  34. package/dist/blocks/agent-checkout/index.d.ts +2 -2
  35. package/dist/blocks/agents/index.d.ts +3 -3
  36. package/dist/blocks/ai-cache/index.d.ts +2 -2
  37. package/dist/blocks/ai-chat/index.d.ts +3 -3
  38. package/dist/blocks/ai-evals/index.d.ts +1 -1
  39. package/dist/blocks/ai-files/index.d.ts +1 -1
  40. package/dist/blocks/ai-guardrails/index.d.ts +1 -1
  41. package/dist/blocks/ai-keys/index.d.ts +1 -1
  42. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  43. package/dist/blocks/announcements/index.d.ts +4 -4
  44. package/dist/blocks/api-keys/index.d.ts +1 -1
  45. package/dist/blocks/appraisals/index.d.ts +1 -1
  46. package/dist/blocks/approvals/index.d.ts +1 -1
  47. package/dist/blocks/assets/index.d.ts +2 -2
  48. package/dist/blocks/assignment/index.d.ts +1 -1
  49. package/dist/blocks/attachments/index.d.ts +6 -6
  50. package/dist/blocks/audit/index.d.ts +2 -2
  51. package/dist/blocks/automations/index.d.ts +3 -3
  52. package/dist/blocks/banking/index.d.ts +1 -1
  53. package/dist/blocks/billable-time/index.d.ts +1 -1
  54. package/dist/blocks/billing/index.d.ts +3 -3
  55. package/dist/blocks/bookings/index.d.ts +3 -3
  56. package/dist/blocks/bulk-actions/index.d.ts +2 -2
  57. package/dist/blocks/calendar/index.d.ts +3 -3
  58. package/dist/blocks/care/index.d.ts +27 -27
  59. package/dist/blocks/care-plans/index.d.ts +3 -3
  60. package/dist/blocks/cases/index.d.ts +3 -3
  61. package/dist/blocks/catalog/index.d.ts +2 -2
  62. package/dist/blocks/channels/index.d.ts +1 -1
  63. package/dist/blocks/clinical-decision-support/index.d.ts +1 -1
  64. package/dist/blocks/cms/index.d.ts +5 -5
  65. package/dist/blocks/collaboration/index.d.ts +6 -6
  66. package/dist/blocks/collections/index.d.ts +1 -1
  67. package/dist/blocks/comments/index.d.ts +2 -2
  68. package/dist/blocks/commerce/index.d.ts +6 -6
  69. package/dist/blocks/commissions/index.d.ts +1 -1
  70. package/dist/blocks/compliance/index.d.ts +1 -1
  71. package/dist/blocks/connectors/index.d.ts +1 -1
  72. package/dist/blocks/consents/index.d.ts +2 -2
  73. package/dist/blocks/contacts/index.d.ts +2 -2
  74. package/dist/blocks/content/index.d.ts +2 -2
  75. package/dist/blocks/contracts/index.d.ts +1 -1
  76. package/dist/blocks/courses/index.d.ts +2 -2
  77. package/dist/blocks/created-by/index.d.ts +2 -2
  78. package/dist/blocks/crm/index.d.ts +17 -17
  79. package/dist/blocks/crm/index.js +1 -1
  80. package/dist/blocks/custom-fields/index.d.ts +1 -1
  81. package/dist/blocks/dam/index.d.ts +2 -2
  82. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  83. package/dist/blocks/deadlines/index.d.ts +1 -1
  84. package/dist/blocks/deals/index.d.ts +1 -1
  85. package/dist/blocks/dispatch/index.d.ts +2 -2
  86. package/dist/blocks/document-templates/index.d.ts +2 -2
  87. package/dist/blocks/documents/index.d.ts +1 -1
  88. package/dist/blocks/domains/index.d.ts +1 -1
  89. package/dist/blocks/donations/index.d.ts +1 -1
  90. package/dist/blocks/drive/index.d.ts +5 -5
  91. package/dist/blocks/e-prescribing/index.d.ts +1 -1
  92. package/dist/blocks/employees/index.d.ts +1 -1
  93. package/dist/blocks/enrichment/index.d.ts +1 -1
  94. package/dist/blocks/enrollments/index.d.ts +2 -2
  95. package/dist/blocks/entitlements/index.d.ts +3 -3
  96. package/dist/blocks/events/index.d.ts +4 -4
  97. package/dist/blocks/expenses/index.d.ts +1 -1
  98. package/dist/blocks/field-history/index.d.ts +1 -1
  99. package/dist/blocks/filespace/index.d.ts +8 -8
  100. package/dist/blocks/finance/index.d.ts +5 -5
  101. package/dist/blocks/flags/index.d.ts +1 -1
  102. package/dist/blocks/forecasts/index.d.ts +1 -1
  103. package/dist/blocks/forms/index.d.ts +3 -3
  104. package/dist/blocks/funding/index.d.ts +2 -2
  105. package/dist/blocks/goals/index.d.ts +1 -1
  106. package/dist/blocks/governance/index.d.ts +4 -4
  107. package/dist/blocks/guests/index.d.ts +1 -1
  108. package/dist/blocks/hiring/index.d.ts +1 -1
  109. package/dist/blocks/identities/index.d.ts +1 -1
  110. package/dist/blocks/imports/index.d.ts +2 -2
  111. package/dist/blocks/inbox/index.d.ts +6 -6
  112. package/dist/blocks/incidents/index.d.ts +1 -1
  113. package/dist/blocks/index.d.ts +5 -5
  114. package/dist/blocks/inspections/index.d.ts +2 -2
  115. package/dist/blocks/inventory/index.d.ts +1 -1
  116. package/dist/blocks/invoices/index.d.ts +1 -1
  117. package/dist/blocks/knowledge/index.d.ts +2 -2
  118. package/dist/blocks/lead-scoring/index.d.ts +2 -2
  119. package/dist/blocks/learning/index.d.ts +3 -3
  120. package/dist/blocks/leases/index.d.ts +1 -1
  121. package/dist/blocks/leave/index.d.ts +1 -1
  122. package/dist/blocks/ledger/index.d.ts +1 -1
  123. package/dist/blocks/legal-entities/index.d.ts +2 -2
  124. package/dist/blocks/lims/index.d.ts +2 -2
  125. package/dist/blocks/mail-sync/index.d.ts +3 -3
  126. package/dist/blocks/maintenance/index.d.ts +2 -2
  127. package/dist/blocks/manufacturing/index.d.ts +2 -2
  128. package/dist/blocks/medications/index.d.ts +1 -1
  129. package/dist/blocks/meetings/index.d.ts +3 -3
  130. package/dist/blocks/memberships/index.d.ts +2 -2
  131. package/dist/blocks/memory/index.d.ts +3 -3
  132. package/dist/blocks/messaging/index.d.ts +5 -5
  133. package/dist/blocks/metrics/index.d.ts +2 -2
  134. package/dist/blocks/mfa/index.d.ts +2 -2
  135. package/dist/blocks/moderation/index.d.ts +2 -2
  136. package/dist/blocks/notifications/index.d.ts +6 -6
  137. package/dist/blocks/notifications/index.js +1 -1
  138. package/dist/blocks/numbering/index.d.ts +1 -1
  139. package/dist/blocks/oauth-server/index.d.ts +1 -1
  140. package/dist/blocks/observations/index.d.ts +2 -2
  141. package/dist/blocks/onboarding/index.d.ts +2 -2
  142. package/dist/blocks/option-sets/index.d.ts +2 -2
  143. package/dist/blocks/orders/index.d.ts +2 -2
  144. package/dist/blocks/organizations/index.d.ts +2 -2
  145. package/dist/blocks/outbox/index.d.ts +1 -1
  146. package/dist/blocks/passes/index.d.ts +2 -2
  147. package/dist/blocks/payroll-export/index.d.ts +2 -2
  148. package/dist/blocks/people/index.d.ts +7 -7
  149. package/dist/blocks/periods/index.d.ts +1 -1
  150. package/dist/blocks/permissions/index.d.ts +3 -3
  151. package/dist/blocks/pipelines/index.d.ts +2 -2
  152. package/dist/blocks/posts/index.d.ts +2 -2
  153. package/dist/blocks/procurement/index.d.ts +5 -5
  154. package/dist/blocks/profiles/index.d.ts +1 -1
  155. package/dist/blocks/projects/index.d.ts +7 -7
  156. package/dist/blocks/promotions/index.d.ts +1 -1
  157. package/dist/blocks/prompts/index.d.ts +1 -1
  158. package/dist/blocks/push/index.d.ts +2 -2
  159. package/dist/blocks/qualifications/index.d.ts +2 -2
  160. package/dist/blocks/queue/index.d.ts +3 -3
  161. package/dist/blocks/queue/index.js +1 -1
  162. package/dist/blocks/quotes/index.d.ts +1 -1
  163. package/dist/blocks/rank/index.d.ts +2 -2
  164. package/dist/blocks/reactions/index.d.ts +4 -4
  165. package/dist/blocks/recruiting/index.d.ts +4 -4
  166. package/dist/blocks/referrals/index.d.ts +1 -1
  167. package/dist/blocks/relations/index.d.ts +1 -1
  168. package/dist/blocks/reminders/index.d.ts +1 -1
  169. package/dist/blocks/reviews/index.d.ts +1 -1
  170. package/dist/blocks/rfqs/index.d.ts +2 -2
  171. package/dist/blocks/risks/index.d.ts +2 -2
  172. package/dist/blocks/saas/index.d.ts +12 -12
  173. package/dist/blocks/saas/index.js +1 -1
  174. package/dist/blocks/sales/index.d.ts +1 -1
  175. package/dist/blocks/saved-views/index.d.ts +3 -3
  176. package/dist/blocks/scheduling/index.d.ts +5 -5
  177. package/dist/blocks/scores/index.d.ts +2 -2
  178. package/dist/blocks/search/index.d.ts +3 -3
  179. package/dist/blocks/security-events/index.d.ts +1 -1
  180. package/dist/blocks/segments/index.d.ts +2 -2
  181. package/dist/blocks/sequences/index.d.ts +3 -3
  182. package/dist/blocks/service/index.d.ts +7 -7
  183. package/dist/blocks/service-accounts/index.d.ts +1 -1
  184. package/dist/blocks/sessions/index.d.ts +2 -2
  185. package/dist/blocks/settings/index.d.ts +2 -2
  186. package/dist/blocks/share-links/index.d.ts +1 -1
  187. package/dist/blocks/shifts/index.d.ts +2 -2
  188. package/dist/blocks/shipments/index.d.ts +1 -1
  189. package/dist/blocks/signatures/index.d.ts +2 -2
  190. package/dist/blocks/signing-keys/index.d.ts +1 -1
  191. package/dist/blocks/sla/index.d.ts +1 -1
  192. package/dist/blocks/sso/index.d.ts +1 -1
  193. package/dist/blocks/state-machine/index.d.ts +1 -1
  194. package/dist/blocks/subjects/index.d.ts +2 -2
  195. package/dist/blocks/support/index.d.ts +5 -5
  196. package/dist/blocks/tags/index.d.ts +2 -2
  197. package/dist/blocks/tasks/index.d.ts +2 -2
  198. package/dist/blocks/tax/index.d.ts +2 -2
  199. package/dist/blocks/teams/index.d.ts +1 -1
  200. package/dist/blocks/templates/index.d.ts +2 -2
  201. package/dist/blocks/tills/index.d.ts +1 -1
  202. package/dist/blocks/time-entries/index.d.ts +2 -2
  203. package/dist/blocks/timeline/index.d.ts +1 -1
  204. package/dist/blocks/trash/index.d.ts +1 -1
  205. package/dist/blocks/undo/index.d.ts +2 -2
  206. package/dist/blocks/updated-at/index.d.ts +2 -2
  207. package/dist/blocks/usage/index.d.ts +3 -3
  208. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  209. package/dist/blocks/versions/index.d.ts +1 -1
  210. package/dist/blocks/waitlist/index.d.ts +1 -1
  211. package/dist/blocks/warehouse/index.d.ts +1 -1
  212. package/dist/blocks/warranty/index.d.ts +1 -1
  213. package/dist/blocks/webhooks/index.d.ts +4 -4
  214. package/dist/blocks/webhooks/index.js +5 -2
  215. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  216. package/dist/blocks/workflows/index.d.ts +4 -4
  217. package/dist/{blocks-D4ngpPJ_.d.ts → blocks-C2F_SycJ.d.ts} +12 -6
  218. package/dist/{bookings-6dC83XE6.d.ts → bookings-DIQGDex_.d.ts} +1 -1
  219. package/dist/{build-Ds53XOWu.js → build-Rr77NMoY.js} +1 -1
  220. package/dist/{cache-tags-UWvxDMDO.d.ts → cache-tags-THgO4say.d.ts} +1 -1
  221. package/dist/claims/index.d.ts +5 -5
  222. package/dist/{claims-source-D-4CztOl.d.ts → claims-source-fUk4pR24.d.ts} +1 -1
  223. package/dist/cli/add-BF3e5Ll7.js +1 -0
  224. package/dist/cli/{add-BegIE-Rb.js → add-BZwvXVWj.js} +2 -2
  225. package/dist/cli/{add-BufF64Hx.js → add-C0CrFxHw.js} +11 -11
  226. package/dist/cli/{app-table-files-RdOXXDCt.js → app-table-files-C5DZPmHI.js} +4 -4
  227. package/dist/cli/{app-tables-CK-U5_ZN.js → app-tables-BzBFYoMr.js} +2 -2
  228. package/dist/cli/{backfill-CT6yncRM.js → backfill-BEp8YZZN.js} +3 -3
  229. package/dist/cli/bin.js +1 -1
  230. package/dist/cli/{blocks-Q7wC6dj7.js → blocks-GHzRHitY.js} +1 -1
  231. package/dist/cli/{blocks-CVadF4-D.js → blocks-OMAjC_Wi.js} +1 -1
  232. package/dist/cli/{cache-BKwYvrrJ.js → cache-CcAahoyu.js} +1 -1
  233. package/dist/cli/{codemod-BzEKQMSK.js → codemod-Cf0oYaKz.js} +5 -5
  234. package/dist/cli/{codemod-naming-BpWNTsvf.js → codemod-naming-B776pVSk.js} +1 -1
  235. package/dist/cli/{column-renames-7IG0Gcf3.js → column-renames-CeK8sWiT.js} +2 -2
  236. package/dist/cli/{config-DX58lDf7.js → config-By5EbpdJ.js} +1 -1
  237. package/dist/cli/{config-CoW6aoul.js → config-D4AVoIh5.js} +1 -1
  238. package/dist/cli/{content-mapper-BUWZw8Yr.js → content-mapper-Do10cbVT.js} +1 -1
  239. package/dist/cli/{db-CZ9qHsDs.js → db-C4up7wFU.js} +2 -2
  240. package/dist/cli/{dev-BRQUcr0M.js → dev-CJPEc2gr.js} +5 -5
  241. package/dist/cli/{doctor-auNf55mF.js → doctor-BEUg9HWw.js} +20 -20
  242. package/dist/cli/{emit-CxD5qNz7.js → emit-T1WamIdk.js} +2 -2
  243. package/dist/cli/{gen-B8K-GHgH.js → gen-DJ2_PQ72.js} +5 -5
  244. package/dist/cli/{gen-tasks-oTH8W-xH.js → gen-tasks-Yrk8s8md.js} +11 -11
  245. package/dist/cli/index.d.ts +1 -1
  246. package/dist/cli/index.js +8 -8
  247. package/dist/cli/{init-lNqq_JHu.js → init-BvbU-jDh.js} +9 -9
  248. package/dist/cli/{live-Dbt0gFSL.js → live-DIsnNTKQ.js} +2 -2
  249. package/dist/cli/{mcp-Bs3746MS.js → mcp-C_wxYL1p.js} +2 -2
  250. package/dist/cli/{memo-backend-BAduTvxg.js → memo-backend-vEs4WDSK.js} +1 -1
  251. package/dist/cli/{metadata-IpEhOh60.js → metadata-BAYbcHhK.js} +4 -4
  252. package/dist/cli/{migrate-CaEzxtNU.js → migrate-B5MSSoqe.js} +1 -1
  253. package/dist/cli/{migration-safety-B473uP9G.js → migration-safety-Dnt9Czmf.js} +2 -2
  254. package/dist/cli/{module-migration-BMmyFP2c.js → module-migration-CEQY0Jql.js} +1 -1
  255. package/dist/cli/{partition-C9ta6Kld.js → partition-DT-YczYz.js} +3 -3
  256. package/dist/cli/powersync-BT_Dwh2S.js +1 -0
  257. package/dist/cli/{powersync-DNUSeMtj.js → powersync-_8c5mLfZ.js} +4 -4
  258. package/dist/cli/{print-84kAnn1u.js → print-DEwSsdxn.js} +2 -2
  259. package/dist/cli/{providers-BgyVs06M.js → providers-QkAQXJCS.js} +1 -1
  260. package/dist/cli/{prune-workflows-D96eYjdj.js → prune-workflows-WfJvfrQe.js} +3 -3
  261. package/dist/cli/{remove-Y62Mu1VK.js → remove-BP7juqYl.js} +6 -6
  262. package/dist/cli/{render-cache-CHTWh5Rl.js → render-cache-BiTkqTAJ.js} +1 -1
  263. package/dist/cli/{render-Div4K_TT.js → render-dx7vrczW.js} +5 -5
  264. package/dist/cli/{run-Dx-CrkU_.js → run-CPdlEmjh.js} +35 -35
  265. package/dist/cli/{run-BkbVZBeG.js → run-s73OXa6p.js} +7 -7
  266. package/dist/cli/seed-B3MrC1Qe.js +1 -0
  267. package/dist/cli/{seed-pDWlnzyK.js → seed-BufZFJ_Q.js} +2 -2
  268. package/dist/cli/{shared-B0zV1qW9.js → shared-CAw3LIDZ.js} +1 -1
  269. package/dist/cli/{source-So9SSLFc.js → source-BFIiz5Gd.js} +1 -1
  270. package/dist/cli/{source-args-D5BSEgUG.js → source-args-CvgOHwlj.js} +1 -1
  271. package/dist/cli/{spec-BiLpXtjI.js → spec-3PdgIg4q.js} +1 -1
  272. package/dist/cli/{spec-BA3jaJaL.js → spec-wHDGnKHu.js} +2 -2
  273. package/dist/cli/{sql-layout-BH9MeAY3.js → sql-layout-DTEum7p9.js} +3 -3
  274. package/dist/cli/{squash-CZJcKsks.js → squash-BApxsAu3.js} +1 -1
  275. package/dist/cli/{sync-Csq5olpt.js → sync--2h-BD99.js} +4 -4
  276. package/dist/cli/{upgrade-MfDU8Z5K.js → upgrade-DuqWpRkE.js} +5 -5
  277. package/dist/cli/{upgrade-DBE7LYrq.js → upgrade-QCfkwN9R.js} +5 -5
  278. package/dist/cli/{verify-O5zxWWuE.js → verify-CR7f21Ri.js} +2 -2
  279. package/dist/cli/{version-ljacjTnk.js → version-B_O3ame2.js} +1 -1
  280. package/dist/client/index.d.ts +5 -5
  281. package/dist/client/index.js +1 -1
  282. package/dist/client/native/index.d.ts +5 -5
  283. package/dist/client/native/index.js +2 -2
  284. package/dist/{composite-CxojRRUF.d.ts → composite-BInEW9vs.d.ts} +3 -3
  285. package/dist/{composite-Bxpd7oru.js → composite-C13UCNgm.js} +1 -1
  286. package/dist/{composite-reads-CK-Y5b6M.d.ts → composite-reads-C942bzhw.d.ts} +1 -1
  287. package/dist/config/index.d.ts +4 -4
  288. package/dist/config/index.js +4 -4
  289. package/dist/{config-cisS43w5.js → config-1kAVpZc_.js} +3 -3
  290. package/dist/{config-a_CzEbpi.js → config-L5_4kg24.js} +1 -1
  291. package/dist/{context-m-t6Kr9_.d.ts → context-DtyeoCvj.d.ts} +4 -4
  292. package/dist/contract/index.d.ts +4 -4
  293. package/dist/{controller-zwQFyrOG.d.ts → controller-D6ZUjfhv.d.ts} +1 -1
  294. package/dist/{conversion-b6htac73.d.ts → conversion-BiAEs9ja.d.ts} +1 -1
  295. package/dist/create/index.d.ts +4 -4
  296. package/dist/create/index.js +3 -3
  297. package/dist/create/lite/index.d.ts +3 -3
  298. package/dist/create/lite/index.js +4 -4
  299. package/dist/{db-blocks-_jJICfjp.d.ts → db-blocks-BQkHb77X.d.ts} +3 -3
  300. package/dist/{define-block-DQvTGOGv.d.ts → define-block-DpnCxELV.d.ts} +2 -2
  301. package/dist/{define-runtime-DsFTahQB.js → define-runtime-BbNPkt-5.js} +17 -1
  302. package/dist/{define-runtime-full-B_cMkyCk.js → define-runtime-full-gpz09qAj.js} +16 -3
  303. package/dist/{delete-account-BQDeafVT.d.ts → delete-account-DKGAVT94.d.ts} +1 -1
  304. package/dist/{drive-DaEK5ZxU.d.ts → drive-_xuMA2xw.d.ts} +1 -1
  305. package/dist/edge/index.d.ts +5 -5
  306. package/dist/edge/index.js +4 -4
  307. package/dist/{embeddings-BriQ4hQ1.d.ts → embeddings-BhTNerJ8.d.ts} +2 -2
  308. package/dist/{entitlements-D4ob6MfK.d.ts → entitlements-Djh4bBdj.d.ts} +2 -2
  309. package/dist/eve/index.d.ts +3 -3
  310. package/dist/{eve-D-hvUFYE.d.ts → eve-DCA-YKQZ.d.ts} +2 -2
  311. package/dist/{executor-D24_D6dr.js → executor-DABWqMfV.js} +1 -1
  312. package/dist/{executor-nx2Q8Xdy.d.ts → executor-h098g0vY.d.ts} +2 -2
  313. package/dist/expo/index.d.ts +2 -2
  314. package/dist/expo/index.js +3 -3
  315. package/dist/{extract-W4zb3wIh.d.ts → extract-DZznUgzb.d.ts} +3 -3
  316. package/dist/{extras-ByEPERCR.d.ts → extras-Cb1ZUvNK.d.ts} +1 -1
  317. package/dist/{field-errors-pj0uOXSg.d.ts → field-errors-DSEpFDCa.d.ts} +6 -6
  318. package/dist/{former-permission-keys-D8FbWktT.js → former-permission-keys-FPrqQHXf.js} +1 -1
  319. package/dist/{framework-pfJvMQy3.js → framework-BQgHM3zD.js} +1 -1
  320. package/dist/{framework-BYx1ke3r.d.ts → framework-CEMVz7JS.d.ts} +3 -3
  321. package/dist/{gateway-eFh5pEIu.d.ts → gateway-oivw0R3W.d.ts} +3 -3
  322. package/dist/generators/factories/index.d.ts +1 -1
  323. package/dist/generators/factories/index.js +1 -1
  324. package/dist/generators/index.d.ts +2 -2
  325. package/dist/generators/json-schema/index.d.ts +2 -2
  326. package/dist/generators/json-schema/index.js +1 -1
  327. package/dist/generators/nuqs/index.d.ts +1 -1
  328. package/dist/generators/nuqs/index.js +1 -1
  329. package/dist/generators/standard-schema/index.d.ts +1 -1
  330. package/dist/generators/standard-schema/index.js +1 -1
  331. package/dist/generators/valibot/index.d.ts +1 -1
  332. package/dist/generators/valibot/index.js +1 -1
  333. package/dist/generators/zod/index.d.ts +1 -1
  334. package/dist/generators/zod/index.js +1 -1
  335. package/dist/hono/index.d.ts +4 -4
  336. package/dist/hono/index.js +3 -3
  337. package/dist/{index-Bu4YwWl0.d.ts → index-1aGCqU0F.d.ts} +1 -1
  338. package/dist/{index-SZ8qGIVO.d.ts → index-B2NJNoRd.d.ts} +9 -9
  339. package/dist/{index-IrsC8TLH.d.ts → index-BAccIXQt.d.ts} +2 -2
  340. package/dist/{index-BpQxfGSO.d.ts → index-BDq77p1R.d.ts} +2 -2
  341. package/dist/{index-DYh76mE_.d.ts → index-BEVvxkvW.d.ts} +2 -2
  342. package/dist/{index-C37Wq488.d.ts → index-BIOLHETk.d.ts} +1 -1
  343. package/dist/{index-DlUd0CTA.d.ts → index-BKD8Lkn9.d.ts} +7 -7
  344. package/dist/{index-CDX9U_CH.d.ts → index-BREewNqU.d.ts} +1 -1
  345. package/dist/{index-BZCCv04g.d.ts → index-BeJMACah.d.ts} +2 -2
  346. package/dist/{index-DW_S9n3h.d.ts → index-BiX0gNGQ.d.ts} +2 -2
  347. package/dist/{index-Crm9IjfQ.d.ts → index-Bt5jJrzR.d.ts} +1 -1
  348. package/dist/{index-BVuN7_fC.d.ts → index-Bx9qRuof.d.ts} +1 -1
  349. package/dist/{index-DsNwQRWG.d.ts → index-C-h2MrvD.d.ts} +1 -1
  350. package/dist/{index-DCqy0ESb.d.ts → index-C8H6hpAP.d.ts} +2 -2
  351. package/dist/{index-BfnBjZpy.d.ts → index-CaE6XZnq.d.ts} +3 -3
  352. package/dist/{index-CQGi7Jnn.d.ts → index-CbKxPo6t.d.ts} +2 -2
  353. package/dist/{index-CxX_Bgfa.d.ts → index-CjmtqiRE.d.ts} +1 -1
  354. package/dist/{index-CWTWbIz_.d.ts → index-CmHvVWGd.d.ts} +1 -1
  355. package/dist/{index-SWDnWdWw.d.ts → index-CygaT0GH.d.ts} +1 -1
  356. package/dist/{index-D_0l5hHh.d.ts → index-D-LxyjmH.d.ts} +3 -3
  357. package/dist/{index-DpoUltRu.d.ts → index-D9fhYtnp.d.ts} +2 -2
  358. package/dist/{index-WoE9Z_V-.d.ts → index-DAYCCmVC.d.ts} +1 -1
  359. package/dist/{index-DyV6z0Q_.d.ts → index-DEHVn5Ma.d.ts} +2 -2
  360. package/dist/{index-ByCXNZ2j.d.ts → index-DIwhnfIi.d.ts} +2 -2
  361. package/dist/{index-Bb_il0ub.d.ts → index-DUDYFfnG.d.ts} +2 -2
  362. package/dist/{index-CriIH7di.d.ts → index-DVmqH-jI.d.ts} +4 -4
  363. package/dist/{index-BomyYKtC.d.ts → index-Dga-eftL.d.ts} +5 -5
  364. package/dist/{index-CjoB5SrD.d.ts → index-DitpSLYH.d.ts} +3 -3
  365. package/dist/{index-BYDpdZxq.d.ts → index-Dsb6-otF.d.ts} +1 -1
  366. package/dist/{index-BLPzvJ5v.d.ts → index-DtGyj0RU.d.ts} +4 -4
  367. package/dist/{index-r_SO6mVm.d.ts → index-RGXgZmyg.d.ts} +3 -3
  368. package/dist/{index-46tesKqa.d.ts → index-S6WKucTU.d.ts} +1 -1
  369. package/dist/{index-ClqA-t45.d.ts → index-TkkZfmGg.d.ts} +1 -1
  370. package/dist/{index-CxZV8RJE.d.ts → index-_IFPpPG9.d.ts} +1 -1
  371. package/dist/{index-Dea13gIz.d.ts → index-bFOgwrCN.d.ts} +4 -4
  372. package/dist/{index-Dyhkn8FU.d.ts → index-jJ7Q-AYO.d.ts} +2 -2
  373. package/dist/{index-DeI4h1N1.d.ts → index-vOUlkC2o.d.ts} +1 -1
  374. package/dist/index.d.ts +1 -1
  375. package/dist/{instances-07Lopbd1.js → instances-PZAWgQEX.js} +2 -1
  376. package/dist/{json-schema-CChz-Csz.js → json-schema-CNrq6b9q.js} +1 -1
  377. package/dist/{knowledge-C7RZqwQu.d.ts → knowledge-CSWQouuC.d.ts} +1 -1
  378. package/dist/list/export/index.d.ts +1 -1
  379. package/dist/list/index.d.ts +1 -1
  380. package/dist/list/order/index.d.ts +2 -2
  381. package/dist/{list-query-B6lXbY0T.d.ts → list-query-0IoIyFnQ.d.ts} +1 -1
  382. package/dist/{manifest-NuYSYeQT.d.ts → manifest-4K_pRDrE.d.ts} +1 -1
  383. package/dist/{manifest-CWFhOuFW.d.ts → manifest-4ZM88myP.d.ts} +1 -1
  384. package/dist/{manifest-CtL5JmoY.d.ts → manifest-4zuq-I0U.d.ts} +1 -1
  385. package/dist/{manifest-wXk0ZLhO.d.ts → manifest-B-5cqXlx.d.ts} +1 -1
  386. package/dist/{manifest-cJ3rQXtl.d.ts → manifest-B11QNHpO.d.ts} +4 -4
  387. package/dist/{manifest-Cl2U3bic.d.ts → manifest-B1R3o592.d.ts} +1 -1
  388. package/dist/{manifest-DsINyvTh.d.ts → manifest-B1bfLbzz.d.ts} +1 -1
  389. package/dist/{manifest-xlpYSpLJ.d.ts → manifest-B5y82qsH.d.ts} +2 -2
  390. package/dist/{manifest-DoZXpoG_.d.ts → manifest-B9FkI5Za.d.ts} +1 -1
  391. package/dist/{manifest-Bj8bumDU.d.ts → manifest-BBQmMfq7.d.ts} +1 -1
  392. package/dist/{manifest-CYO44YUb.d.ts → manifest-BFc_Zpzf.d.ts} +1 -1
  393. package/dist/{manifest-DftU8SXo.d.ts → manifest-BGBYLCP-.d.ts} +1 -1
  394. package/dist/{manifest-BEQWkGmf.d.ts → manifest-BLVRM4WX.d.ts} +1 -1
  395. package/dist/{manifest-eaGk_4rq.d.ts → manifest-BLkOEccx.d.ts} +1 -1
  396. package/dist/{manifest-_zu02ImE.d.ts → manifest-BND77-ps.d.ts} +2 -2
  397. package/dist/{manifest-FVkgBS-K.d.ts → manifest-BQYkGxek.d.ts} +1 -1
  398. package/dist/{manifest-Dp9ZtoFo.d.ts → manifest-BTZI-Jq1.d.ts} +2 -2
  399. package/dist/{manifest-NkuGL5p2.d.ts → manifest-BYHJvkqX.d.ts} +1 -1
  400. package/dist/{manifest-B0pan6cS.d.ts → manifest-B__S-85Q.d.ts} +1 -1
  401. package/dist/{manifest-YtnGn7F9.d.ts → manifest-Bgc-jWOV.d.ts} +1 -1
  402. package/dist/{manifest-DUPKC2rO.d.ts → manifest-BsuYq-pZ.d.ts} +1 -1
  403. package/dist/{manifest-BRvnB8C0.d.ts → manifest-ByfZrxkk.d.ts} +1 -1
  404. package/dist/{manifest-DfC1XBrV.d.ts → manifest-C0-rnYge.d.ts} +1 -1
  405. package/dist/{manifest-tP62uJrR.d.ts → manifest-C02JeWGr.d.ts} +1 -1
  406. package/dist/{manifest-Cv7Mji7w.d.ts → manifest-C3-OpYr0.d.ts} +1 -1
  407. package/dist/{manifest-BZPruG-S.d.ts → manifest-C3qUn0ka.d.ts} +1 -1
  408. package/dist/{manifest-Dim5U8TQ.d.ts → manifest-C46GM61W.d.ts} +1 -1
  409. package/dist/{manifest-DOtSiMt5.d.ts → manifest-C9Cs9rtL.d.ts} +1 -1
  410. package/dist/{manifest-CS8I2fku.d.ts → manifest-CE4rGv9r.d.ts} +1 -1
  411. package/dist/{manifest-BaIG9QRj.d.ts → manifest-CGnYiIs8.d.ts} +1 -1
  412. package/dist/{manifest-N5wuAzq4.d.ts → manifest-CKbJBLaW.d.ts} +3 -3
  413. package/dist/{manifest-x_fSttX7.d.ts → manifest-CQ1Xpja6.d.ts} +1 -1
  414. package/dist/{manifest-BKiaRgiZ.d.ts → manifest-CRe-o25G.d.ts} +2 -2
  415. package/dist/{manifest-ubm80xCr.d.ts → manifest-Ca6Rm4u6.d.ts} +1 -1
  416. package/dist/{manifest-TG95ksdH.d.ts → manifest-Cf8__tMA.d.ts} +17 -4
  417. package/dist/{manifest-Dg2BCyzg.d.ts → manifest-CrO5Gwed.d.ts} +1 -1
  418. package/dist/{manifest-CumC7hH5.d.ts → manifest-CzErrA0R.d.ts} +1 -1
  419. package/dist/{manifest-CiF1Sb29.d.ts → manifest-D-IfkyQg.d.ts} +1 -1
  420. package/dist/{manifest-D48Fi0bR.d.ts → manifest-DCIvxvg9.d.ts} +1 -1
  421. package/dist/{manifest-CnVa_nHw.d.ts → manifest-DEf81vUp.d.ts} +1 -1
  422. package/dist/{manifest-CMn61uKN.d.ts → manifest-DF6MWZld.d.ts} +1 -1
  423. package/dist/{manifest-Ccc0ZZup.d.ts → manifest-DFRP7LFo.d.ts} +1 -1
  424. package/dist/{manifest-BpgNJhYN.d.ts → manifest-DH1wX47F.d.ts} +1 -1
  425. package/dist/{manifest-2sJavyD8.d.ts → manifest-DIsc4u7U.d.ts} +1 -1
  426. package/dist/{manifest-BBcaI1P8.js → manifest-DVuGZaJS.js} +20 -6
  427. package/dist/{manifest-4S1YGIS3.d.ts → manifest-DWS1Hszm.d.ts} +1 -1
  428. package/dist/{manifest-BzXqieUD.d.ts → manifest-DYMvHTJ4.d.ts} +1 -1
  429. package/dist/{manifest-dOFbx7Iv.d.ts → manifest-D_RJDjHz.d.ts} +2 -2
  430. package/dist/{manifest-CF3BUmbe.d.ts → manifest-D_u0Uhd9.d.ts} +1 -1
  431. package/dist/{manifest-Bf6Rzatq.d.ts → manifest-DgVrJNgv.d.ts} +1 -1
  432. package/dist/{manifest-C95ET4CL.d.ts → manifest-DiJKbgrM.d.ts} +1 -1
  433. package/dist/{manifest-5i2UwyQr.d.ts → manifest-DpW-TJwu.d.ts} +1 -1
  434. package/dist/{manifest-BxvFH1G_.d.ts → manifest-DySuHx51.d.ts} +2 -2
  435. package/dist/{manifest-C2hpeEBF.d.ts → manifest-IWiafJCj.d.ts} +1 -1
  436. package/dist/{manifest-DwBFwxFo.d.ts → manifest-MIOw1h6u.d.ts} +1 -1
  437. package/dist/{manifest-Bfu-Cu0f.d.ts → manifest-Qa7Oz8op.d.ts} +3 -3
  438. package/dist/{manifest-DiXINLQQ.d.ts → manifest-YV2wB81I.d.ts} +1 -1
  439. package/dist/{manifest-CzDKrwRf.js → manifest-_xHwNjlQ.js} +13 -9
  440. package/dist/{manifest-DucB6ix_.d.ts → manifest-iwcDpOkG.d.ts} +1 -1
  441. package/dist/{manifest-CA5EhKZ9.d.ts → manifest-nsV6ZrZ7.d.ts} +1 -1
  442. package/dist/{manifest-DZyxhWcb.d.ts → manifest-rB3i09ej.d.ts} +1 -1
  443. package/dist/{manifest-BMilYLsh.d.ts → manifest-rk3V9E0p.d.ts} +1 -1
  444. package/dist/{manifest-CXdJUJjX.d.ts → manifest-uAf9hw_t.d.ts} +1 -1
  445. package/dist/{manifest-DpFy7git.d.ts → manifest-z_JoPdSA.d.ts} +2 -2
  446. package/dist/mapper/bin.js +6 -6
  447. package/dist/mcp/index.d.ts +2 -2
  448. package/dist/mcp/index.js +1 -1
  449. package/dist/mcp/sdk/index.d.ts +2 -2
  450. package/dist/mcp/sdk/index.js +1 -1
  451. package/dist/{mcp-B4bvacl4.js → mcp-CQi0RwZj.js} +3 -3
  452. package/dist/next/index.d.ts +12 -12
  453. package/dist/next/index.js +2 -2
  454. package/dist/next/proxy/index.d.ts +3 -3
  455. package/dist/{operations-D4zxY2TL.d.ts → operations-C4vxakMi.d.ts} +1 -1
  456. package/dist/{orders-BCR5H9Tz.d.ts → orders-DtiIfGI_.d.ts} +1 -1
  457. package/dist/orpc/index.d.ts +4 -4
  458. package/dist/orpc/index.js +2 -2
  459. package/dist/otel/index.js +5 -5
  460. package/dist/{permissions-BkUcXwtV.d.ts → permissions-CP5Cwz8h.d.ts} +1 -1
  461. package/dist/{ports-DD-pDkHu.d.ts → ports-B1QMhbn5.d.ts} +1 -1
  462. package/dist/{ports-BBowiGiD.js → ports-ClJbgoyt.js} +1 -1
  463. package/dist/powersync/index.d.ts +4 -4
  464. package/dist/powersync/index.js +1 -1
  465. package/dist/preset/index.d.ts +4 -4
  466. package/dist/preset/index.js +3 -3
  467. package/dist/{preset-ZZ4H2s92.js → preset-BcwGsW_B.js} +2 -2
  468. package/dist/{preview-GUvVjUxf.d.ts → preview-ByZwgNq9.d.ts} +3 -3
  469. package/dist/{project-wJ3jYipI.js → project-DYyr_iyu.js} +5 -5
  470. package/dist/{push-token-C8MoiM7E.d.ts → push-token-BAcQAeb8.d.ts} +1 -1
  471. package/dist/query/index.d.ts +1 -1
  472. package/dist/rate-limit/index.d.ts +1 -1
  473. package/dist/{rate-limit-Ddv4xmsH.d.ts → rate-limit-TxSt-_59.d.ts} +1 -1
  474. package/dist/react/index.d.ts +5 -5
  475. package/dist/react/native/index.d.ts +1 -1
  476. package/dist/react/server.d.ts +6 -6
  477. package/dist/react-router/index.d.ts +3 -3
  478. package/dist/react-router/index.js +3 -3
  479. package/dist/realtime/index.d.ts +3 -3
  480. package/dist/{record-form-CbFN-AdD.d.ts → record-form-53Hzv9d9.d.ts} +1 -1
  481. package/dist/records/index.d.ts +7 -7
  482. package/dist/{resource-execute-BQx_Pmeu.d.ts → resource-execute-H-XO83hu.d.ts} +1 -1
  483. package/dist/{resource-types-lBguZ_8J.d.ts → resource-types-D4IZrOCo.d.ts} +1 -1
  484. package/dist/{resources-CWfoS1er.d.ts → resources-B5k-hJW_.d.ts} +1 -1
  485. package/dist/{sandboxes-BjvFi1Wh.d.ts → sandboxes-BJy3k0km.d.ts} +1 -1
  486. package/dist/server/account/index.d.ts +2 -2
  487. package/dist/server/accounts/index.d.ts +1 -1
  488. package/dist/server/index.d.ts +13 -13
  489. package/dist/server/index.js +4 -4
  490. package/dist/{server-af58-Q51.js → server-B0T944J9.js} +1 -1
  491. package/dist/{server-types-By5oBsDZ.d.ts → server-types-Bax89ShV.d.ts} +2 -2
  492. package/dist/{session-D5IrTUwv.d.ts → session-DitGLCxF.d.ts} +1 -1
  493. package/dist/{sign-in-TNX4Pj9E.d.ts → sign-in-DbXRH5zh.d.ts} +10 -10
  494. package/dist/{signers-DB0S8YhO.d.ts → signers-FVeDbZxq.d.ts} +5 -1
  495. package/dist/solid/index.d.ts +6 -6
  496. package/dist/solid-start/index.d.ts +3 -3
  497. package/dist/solid-start/index.js +3 -3
  498. package/dist/spec/index.d.ts +1 -1
  499. package/dist/spec/index.js +2 -2
  500. package/dist/sql/index.d.ts +6 -6
  501. package/dist/sql/index.js +2 -2
  502. package/dist/{sql-CP1j2jfo.js → sql-DPpcMNUF.js} +387 -136
  503. package/dist/sqlite/index.d.ts +1 -1
  504. package/dist/sqlite/index.js +1 -1
  505. package/dist/ssr/index.d.ts +1 -1
  506. package/dist/svelte/index.d.ts +6 -6
  507. package/dist/sveltekit/index.d.ts +4 -4
  508. package/dist/sveltekit/index.js +3 -3
  509. package/dist/{tags-Csj8VfA7.d.ts → tags-C3z-ntLF.d.ts} +1 -1
  510. package/dist/tanstack-db/index.d.ts +1 -1
  511. package/dist/tanstack-start/index.d.ts +3 -3
  512. package/dist/tanstack-start/index.js +3 -3
  513. package/dist/{tenant-CVRFoaDM.d.ts → tenant-tAtS31r8.d.ts} +1 -1
  514. package/dist/testing/index.d.ts +12 -12
  515. package/dist/testing/index.js +3 -3
  516. package/dist/{timeline-T1qkzVdR.d.ts → timeline-BoKhn-Ei.d.ts} +3 -3
  517. package/dist/{topic-DytYYyP3.d.ts → topic-BdTuoZRL.d.ts} +2 -2
  518. package/dist/{types-Cikitezb.d.ts → types-BderwMCG.d.ts} +1 -1
  519. package/dist/{types-Cge5o3f5.d.ts → types-D4wgpab9.d.ts} +2 -2
  520. package/dist/{types-CID74uQG.d.ts → types-DerSPnBG.d.ts} +3 -1
  521. package/dist/{usage-CrTrlxoi.d.ts → usage-BMaJFesv.d.ts} +1 -1
  522. package/dist/vercel-sandbox/index.d.ts +1 -1
  523. package/dist/{verify-dg8Q3iRY.d.ts → verify-B4daVDDR.d.ts} +1 -1
  524. package/dist/{version-BFYCXhul.js → version-CTxJCxwz.js} +1 -1
  525. package/dist/vue/index.d.ts +6 -6
  526. package/dist/{watch-topic-DT31uYqF.d.ts → watch-topic-BjkFSiGe.d.ts} +1 -1
  527. package/dist/webmcp/index.d.ts +1 -1
  528. package/dist/webmcp/index.js +1 -1
  529. package/dist/yjs/index.d.ts +1 -1
  530. package/package.json +1 -1
  531. package/schemas/config-v1.json +40 -2
  532. package/dist/cli/add-BXNrz9sN.js +0 -1
  533. package/dist/cli/powersync-BLXxgdbk.js +0 -1
  534. package/dist/cli/seed-B6_MBFd2.js +0 -1
@@ -3,10 +3,10 @@ import { a as hasPlaceholder, f as isFunctionSpec, l as splitPlaceholders, r as
3
3
  import { a as ok } from "./result-DijoXEFG.js";
4
4
  import { n as isRecord$1, t as isList } from "./guards-CsRa6v57.js";
5
5
  import { t as SPEC_PINS } from "./spec-pins-Dlz8OVqi.js";
6
- import { _ as CONFIG_DEFAULTS, d as blockColumnName, f as checkTenantEntry, g as resolveJsonSchema, h as clientFunctions, l as installedBlockSubjects, m as resolveNames, n as checkFormerPermissionKeys, p as entityType, r as renames } from "./former-permission-keys-D8FbWktT.js";
6
+ import { _ as CONFIG_DEFAULTS, d as blockColumnName, f as checkTenantEntry, g as resolveJsonSchema, h as clientFunctions, l as installedBlockSubjects, m as resolveNames, n as checkFormerPermissionKeys, p as entityType, r as renames } from "./former-permission-keys-FPrqQHXf.js";
7
7
  import { t as DEFAULT_CLAIMS } from "./claims-CX-ar1vt.js";
8
8
  import { o as tenantNames, r as composeNames } from "./entity-naming-CUsC8bC1.js";
9
- import { B as resolveBlock, C as columnsWithAccess, E as hiddenColumns, I as PRESET_CATALOG, L as BLOCK_SCOPES, N as createdFromLink, P as link, S as hasComputed, T as hasColumnAccess, V as tenantNameOf, a as isRenamedInstance, g as appTableVersions, i as instancePrefix, l as APP_RANK_COLUMN, m as appTableEventKinds, s as APP_DELETED_AT_COLUMN, w as encryptedColumns, y as lookupColumn } from "./instances-07Lopbd1.js";
9
+ import { B as resolveBlock, C as columnsWithAccess, E as hiddenColumns, I as PRESET_CATALOG, L as BLOCK_SCOPES, N as createdFromLink, P as link, S as hasComputed, T as hasColumnAccess, V as tenantNameOf, a as isRenamedInstance, g as appTableVersions, i as instancePrefix, l as APP_RANK_COLUMN, m as appTableEventKinds, s as APP_DELETED_AT_COLUMN, w as encryptedColumns, y as lookupColumn } from "./instances-PZAWgQEX.js";
10
10
  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";
11
11
  import { a as sqlString, i as sqlIdent$1 } from "./template-CpYN7hZX.js";
12
12
  import { a as LEGACY_OPTION, n as blockOptions, r as option, t as NO_OPTIONS } from "./options-Bfd-k6yw.js";
@@ -167,7 +167,7 @@ import { n as WARRANTY_STATUSES } from "./warranty-values-BJo_g1F1.js";
167
167
  import { n as WORKFLOW_SDK_WORLD } from "./workflow-sdk-IPsOMGEC.js";
168
168
  import { s as permissionMatches$1 } from "./delegation-CnCIKysL.js";
169
169
  import { n as quoteIdent, t as compileSql } from "./sql-DqCwJ2qB.js";
170
- import { t as provideConnectionRuntime } from "./define-runtime-full-B_cMkyCk.js";
170
+ import { t as provideConnectionRuntime } from "./define-runtime-full-gpz09qAj.js";
171
171
  // src/sql/api-schema.ts
172
172
  /** The roles PostgREST runs a request as. */
173
173
  const API_ROLES = /* @__PURE__ */ new Set([
@@ -497,7 +497,7 @@ const IDENT$14 = String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`;
497
497
  const TRIGGER$4 = /* @__PURE__ */ new RegExp(String.raw`\bcreate\s+(?:or\s+replace\s+)?(?:constraint\s+)?trigger\s+"?bsb?_audit"?\s+after\s+[\s\S]*?\bon\s+(${IDENT$14}(?:\s*\.\s*${IDENT$14})?)\s+(?:(?:not\s+)?deferrable(?:\s+initially\s+(?:deferred|immediate))?\s+)?for\s+each\s+row\s+(?:when\s*\([\s\S]*?\)\s+)?execute\s+(?:function|procedure)\s+better_supabase\s*\.\s*audit_row_change\s*\(`, "gi");
498
498
  const TABLE_NAME$7 = String.raw`${IDENT$14}(?:\s*\.\s*${IDENT$14})?`;
499
499
  const DROP$1 = /* @__PURE__ */ new RegExp(String.raw`\bdrop\s+table\s+(?:if\s+exists\s+)?(${TABLE_NAME$7}(?:\s*,\s*${TABLE_NAME$7})*)`, "gi");
500
- const names$10 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
500
+ const names$11 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
501
501
  function triggerRegistration(target, args) {
502
502
  const text = args.length === 0 ? "{}" : literal$4(args[0]);
503
503
  if (text === void 0) return;
@@ -510,8 +510,8 @@ function triggerRegistration(target, args) {
510
510
  if (typeof settings !== "object" || settings === null) return;
511
511
  return {
512
512
  target: qualifiedName$1(target.replaceAll(/\s+/g, "")),
513
- ignore: "ignore" in settings ? names$10(settings.ignore) : [],
514
- redact: "redact" in settings ? names$10(settings.redact) : []
513
+ ignore: "ignore" in settings ? names$11(settings.ignore) : [],
514
+ redact: "redact" in settings ? names$11(settings.redact) : []
515
515
  };
516
516
  }
517
517
  /**
@@ -2486,6 +2486,13 @@ function createModuleContext(module, namesOf, source = {}) {
2486
2486
  ...subject === void 0 ? {} : { subject }
2487
2487
  };
2488
2488
  };
2489
+ for (const type of Object.keys(config.eventPayload)) if (names.events && !Object.hasOwn(names.events, type)) throw new TypeError(`${where}.events.payload names "${type}", which module "${module}" doesn't record`);
2490
+ const withPayload = (event, type) => {
2491
+ const added = Object.entries(config.eventPayload[type] ?? {});
2492
+ if (added.length === 0) return event.payload;
2493
+ if (event.row === void 0) throw new TypeError(`${where}.events.payload names "${type}", which module "${module}" records without a row`);
2494
+ return `(${event.payload} || jsonb_build_object(${added.map(([key, column]) => `${sqlString(key)}, ${event.row}.${sqlIdent$1(column)}`).join(", ")}))`;
2495
+ };
2489
2496
  const outbox = (checked) => {
2490
2497
  checkEvent(checked);
2491
2498
  const event = renamed(checked);
@@ -2495,7 +2502,7 @@ function createModuleContext(module, namesOf, source = {}) {
2495
2502
  if (typeof template !== "string") throw new TypeError("blocks.outbox.options.blockSource must be a string");
2496
2503
  return `perform ${sqlIdent$1(outboxConfig.schema)}.emit_event(${[
2497
2504
  sqlString(event.type),
2498
- event.payload,
2505
+ withPayload(event, checked.type),
2499
2506
  event.subject ?? "null",
2500
2507
  event.tenant === void 0 ? "null" : `(${event.tenant})::text`,
2501
2508
  event.key ?? "null",
@@ -13219,7 +13226,7 @@ const NOTE_OPTIONS = [
13219
13226
  "lockAfterHours",
13220
13227
  "lockTypes"
13221
13228
  ];
13222
- function names$9(ctx, option, fallback) {
13229
+ function names$10(ctx, option, fallback) {
13223
13230
  const list = ctx.list(option, fallback);
13224
13231
  if (list.some((item) => !NAME$9.test(item))) throw new TypeError(`blocks.activities.options.${option} must be a list of lowercase names`);
13225
13232
  return list;
@@ -13229,8 +13236,8 @@ function noteRules(ctx) {
13229
13236
  const on = (column) => ctx.has("activities", column);
13230
13237
  const e = (column) => ctx.col("activities", column);
13231
13238
  const l = (column) => ctx.col("links", column);
13232
- const categories = names$9(ctx, "noteCategories", NOTE_CATEGORIES);
13233
- const lockTypes = names$9(ctx, "lockTypes", LOCK_TYPES);
13239
+ const categories = names$10(ctx, "noteCategories", NOTE_CATEGORIES);
13240
+ const lockTypes = names$10(ctx, "lockTypes", LOCK_TYPES);
13234
13241
  const hours = ctx.number("lockAfterHours", 24);
13235
13242
  if (!Number.isInteger(hours) || hours < 0 || hours > MAX_LOCK_HOURS) throw new TypeError(`blocks.activities.options.lockAfterHours must be a whole number of hours from 0 to ${MAX_LOCK_HOURS}`);
13236
13243
  if (on("restrictedRoles") && !on("audience")) throw new TypeError("blocks.activities.columns.activities.restrictedRoles needs audience");
@@ -37926,7 +37933,7 @@ const NAMES$130 = {
37926
37933
  }
37927
37934
  }
37928
37935
  };
37929
- function names$8(ctx) {
37936
+ function names$9(ctx) {
37930
37937
  const keys = moduleOperations("assignment");
37931
37938
  return {
37932
37939
  fn: (name) => ctx.fn(name),
@@ -38285,7 +38292,7 @@ ${userGrant(`${fn("assignment_history")}(${ctx.idType}, text, text, integer)`)}
38285
38292
  `;
38286
38293
  }
38287
38294
  function build$134(ctx) {
38288
- const n = names$8(ctx);
38295
+ const n = names$9(ctx);
38289
38296
  return `${schemaPreamble(ctx)}
38290
38297
  -- Assignment: queues of members that pick an owner for new records, by
38291
38298
  -- round robin or weight, within a territory of rule conditions.
@@ -49018,6 +49025,7 @@ function taskFunctions(ctx, n) {
49018
49025
  payload: `jsonb_build_object('organizationId', ${alias}.${w("tenant")}, 'taskId', ${alias}.${w("id")}, 'subjectType', ${item}, 'subjectId', ${alias}.${w("id")}::text, 'title', ${alias}.${w("title")}${extra})`,
49019
49026
  subject: `'tasks/' || ${alias}.${w("id")}::text`,
49020
49027
  tenant: `${alias}.${w("tenant")}::text`,
49028
+ row: alias,
49021
49029
  audit: false,
49022
49030
  ...n.templates ? { live: `${alias}.${w("template")} is null` } : {}
49023
49031
  });
@@ -50324,6 +50332,7 @@ ${ctx.has("items", "progress") ? ` if ${state(`new.${w("state")}`, ["comple
50324
50332
  end if;
50325
50333
  ` : ""} ${ctx.record({
50326
50334
  type: "task.closed",
50335
+ row: "new",
50327
50336
  payload: payload(`, 'state', new.${w("state")}, 'closeReason', new.${w("closeReason")}`),
50328
50337
  subject,
50329
50338
  tenant,
@@ -50335,6 +50344,7 @@ ${ctx.has("items", "progress") ? ` if ${state(`new.${w("state")}`, ["comple
50335
50344
  new.${w("closeReason")} := null;
50336
50345
  ${ctx.record({
50337
50346
  type: "task.reopened",
50347
+ row: "new",
50338
50348
  payload: payload(""),
50339
50349
  subject,
50340
50350
  tenant,
@@ -93732,7 +93742,7 @@ const NAMES$99 = {
93732
93742
  }
93733
93743
  };
93734
93744
  const NAME$5 = /^[a-z][a-z0-9_]{0,62}$/;
93735
- function names$7(ctx, option, fallback) {
93745
+ function names$8(ctx, option, fallback) {
93736
93746
  const list = ctx.list(option, fallback);
93737
93747
  if (list.length === 0 || list.some((item) => !NAME$5.test(item))) throw new TypeError(`blocks.deals.options.${option} must be a non-empty list of lowercase names`);
93738
93748
  return `${sqlString(`{${list.join(",")}}`)}::text[]`;
@@ -93994,12 +94004,12 @@ function build$102(ctx, layout) {
93994
94004
  write: ctx.permission("write", keys.write),
93995
94005
  manage: ctx.permission("manage", keys.manage),
93996
94006
  readAll,
93997
- motions: names$7(ctx, "motions", [
94007
+ motions: names$8(ctx, "motions", [
93998
94008
  "new_logo",
93999
94009
  "expansion",
94000
94010
  "renewal"
94001
94011
  ]),
94002
- priorities: names$7(ctx, "priorities", [
94012
+ priorities: names$8(ctx, "priorities", [
94003
94013
  "hot",
94004
94014
  "warm",
94005
94015
  "cold"
@@ -107608,7 +107618,7 @@ const NAMES$91 = {
107608
107618
  } }
107609
107619
  };
107610
107620
  const DOMAIN$1 = String.raw`^[a-z0-9.-]+\.[a-z]{2,}$`;
107611
- function names$6(ctx) {
107621
+ function names$7(ctx) {
107612
107622
  const keys = moduleOperations("enrichment");
107613
107623
  const parties = ctx.of("contacts");
107614
107624
  return {
@@ -107889,7 +107899,7 @@ ${serviceGrant(`${fn("enrichment_due")}(text, integer, interval, text)`)}
107889
107899
  `;
107890
107900
  }
107891
107901
  function build$93(ctx) {
107892
- const n = names$6(ctx);
107902
+ const n = names$7(ctx);
107893
107903
  return `${schemaPreamble(ctx)}
107894
107904
  -- Enrichment: what a provider returned for a company or a person, one result
107895
107905
  -- per provider, and the empty columns a match filled.
@@ -112873,7 +112883,7 @@ const NAMES$86 = {
112873
112883
  }
112874
112884
  }
112875
112885
  };
112876
- function names$5(ctx) {
112886
+ function names$6(ctx) {
112877
112887
  const keys = moduleOperations("forecasts");
112878
112888
  const deals = ctx.of("deals");
112879
112889
  const pipelines = ctx.of("pipelines");
@@ -113146,7 +113156,7 @@ ${userGrant(`${fn("forecast_changes")}(uuid, uuid)`)}
113146
113156
  `;
113147
113157
  }
113148
113158
  function build$88(ctx) {
113149
- const n = names$5(ctx);
113159
+ const n = names$6(ctx);
113150
113160
  return `${schemaPreamble(ctx)}
113151
113161
  -- Forecasts: snapshots of the forecast call over time, with the deals each
113152
113162
  -- one counted, and what changed between two of them.
@@ -146671,7 +146681,7 @@ const NAMES$70 = {
146671
146681
  }
146672
146682
  } }
146673
146683
  };
146674
- function names$4(ctx) {
146684
+ function names$5(ctx) {
146675
146685
  const parties = ctx.of("contacts");
146676
146686
  const scores = ctx.of("scores");
146677
146687
  const keys = moduleOperations("scores");
@@ -146972,7 +146982,7 @@ create trigger ${trigger}
146972
146982
  function build$71(ctx) {
146973
146983
  if (ctx.mode === "custom") return "";
146974
146984
  if (!ctx.of("scores").manages || !ctx.of("contacts").manages) throw new TypeError("lead-scoring needs the scores and parties modules in managed mode");
146975
- const n = names$4(ctx);
146985
+ const n = names$5(ctx);
146976
146986
  return `${schemaPreamble(ctx)}
146977
146987
  ${ctx.manages ? tables$29(ctx, n) : ""}
146978
146988
  ${functions$6(ctx, n)}
@@ -153017,7 +153027,7 @@ const NAMES$66 = {
153017
153027
  }
153018
153028
  };
153019
153029
  const TYPE$2 = /^[a-z][a-z0-9_]{0,62}$/;
153020
- function names$3(ctx) {
153030
+ function names$4(ctx) {
153021
153031
  const keys = moduleOperations("mail-sync");
153022
153032
  const activityType = ctx.text("activityType", "email");
153023
153033
  if (!TYPE$2.test(activityType)) throw new TypeError("blocks.mail-sync.options.activityType must be a lowercase activity type");
@@ -153201,7 +153211,7 @@ ${renderPolicy(policy$1({
153201
153211
  `;
153202
153212
  }
153203
153213
  function build$66(ctx) {
153204
- const n = names$3(ctx);
153214
+ const n = names$4(ctx);
153205
153215
  return `${schemaPreamble(ctx)}
153206
153216
  -- Gmail, Outlook and other mailboxes synced per member: threads and messages
153207
153217
  -- linked to the people and companies they involve, logged as activities.
@@ -165897,6 +165907,155 @@ $$;
165897
165907
  revoke execute on function ${fn}(interval, integer) from public, anon, authenticated;
165898
165908
  grant execute on function ${fn}(interval, integer) to service_role;`;
165899
165909
  }
165910
+ function names$3(n) {
165911
+ const e = (logical) => n.col("events", logical);
165912
+ const r = (logical) => n.col("recipients", logical);
165913
+ const resolved = n.has("recipients", "resolvedAt");
165914
+ const subjectType = n.has("events", "subjectType");
165915
+ return {
165916
+ e,
165917
+ r,
165918
+ resolved,
165919
+ subjectType,
165920
+ subjects: subjectType && n.has("events", "subjectId")
165921
+ };
165922
+ }
165923
+ function orders(n) {
165924
+ const { e, r, resolved } = names$3(n);
165925
+ const statusRank = resolved ? `case when rc.${r("resolvedAt")} is not null then 2 when rc.${r("readAt")} is null then 0 else 1 end` : `case when rc.${r("readAt")} is null then 0 else 1 end`;
165926
+ const newest = `rc.${r("createdAt")} desc, rc.${r("id")} desc`;
165927
+ return [
165928
+ ["newest", newest],
165929
+ ["oldest", `rc.${r("createdAt")}, rc.${r("id")}`],
165930
+ ["type", `ev.${e("type")} collate "C", ${newest}`],
165931
+ ["type_desc", `ev.${e("type")} collate "C" desc, ${newest}`],
165932
+ ...n.has("events", "subjectLabel") ? [["subject", `lower(coalesce(ev.${e("subjectLabel")}, '')) collate "C", ${newest}`], ["subject_desc", `lower(coalesce(ev.${e("subjectLabel")}, '')) collate "C" desc, ${newest}`]] : [["subject", newest], ["subject_desc", newest]],
165933
+ ["status", `${statusRank}, ${newest}`],
165934
+ ["status_desc", `${statusRank} desc, ${newest}`]
165935
+ ];
165936
+ }
165937
+ function pageFilters(n) {
165938
+ const { e, r, resolved, subjectType, subjects } = names$3(n);
165939
+ const fn = "notification_page";
165940
+ const flag = (key, column) => `case (g ->> '${key}')::boolean when true then 'rc.${column} is not null' when false then 'rc.${column} is null' end`;
165941
+ const list = (key, sql) => `case when g ? '${key}' then format(${sqlString(sql)}, array(select jsonb_array_elements_text(g -> '${key}'))) end`;
165942
+ const groups = [
165943
+ list("types", `ev.${e("type")} = any(%L::text[])`),
165944
+ list("exclude_types", `ev.${e("type")} <> all(%L::text[])`),
165945
+ ...subjectType ? [list("subject_types", `ev.${e("subjectType")} = any(%L::text[])`)] : [],
165946
+ flag("read", r("readAt")),
165947
+ ...resolved ? [flag("resolved", r("resolvedAt"))] : []
165948
+ ];
165949
+ return `
165950
+ if ${fn}.exclude_types is not null then
165951
+ v_where := v_where || $q$ and ev.${e("type")} <> all($11)$q$;
165952
+ end if;${subjects ? `
165953
+ if ${fn}.subject_ids is not null then
165954
+ v_where := v_where || $q$ and ev.${e("subjectId")} = any($12)$q$;
165955
+ end if;` : ""}
165956
+ if ${fn}.any_of is not null then
165957
+ if jsonb_typeof(${fn}.any_of) <> 'array'
165958
+ or exists (select 1 from jsonb_array_elements(${fn}.any_of) g where jsonb_typeof(g) <> 'object') then
165959
+ raise exception 'any_of is an array of filter objects' using errcode = '22023';
165960
+ end if;
165961
+ select coalesce(string_agg('(' || concat_ws(' and ', 'true', ${groups.join(", ")}) || ')', ' or '), 'false')
165962
+ into v_any
165963
+ from jsonb_array_elements(${fn}.any_of) g;
165964
+ v_where := v_where || ' and (' || v_any || ')';
165965
+ end if;`;
165966
+ }
165967
+ function notificationPage(ctx, n, parts) {
165968
+ const { e, r } = names$3(n);
165969
+ const id = ctx.idType;
165970
+ const list = orders(n);
165971
+ return `create or replace function ${ctx.fn("notification_page")}(
165972
+ tenant ${id} default null,
165973
+ status text default 'all',
165974
+ types text[] default null,
165975
+ subject_types text[] default null,
165976
+ search text default null,
165977
+ max_items integer default 50,
165978
+ skip integer default 0,
165979
+ read boolean default null,
165980
+ resolved boolean default null,
165981
+ dismissed boolean default false,
165982
+ before timestamptz default null,
165983
+ before_id uuid default null,
165984
+ total_cap integer default 10000,
165985
+ exclude_types text[] default null,
165986
+ subject_ids text[] default null,
165987
+ any_of jsonb default null,
165988
+ order_by text default 'newest'
165989
+ )
165990
+ returns jsonb
165991
+ language plpgsql
165992
+ stable
165993
+ security definer
165994
+ set search_path = ''
165995
+ as $$
165996
+ declare
165997
+ v_where text;
165998
+ v_any text;
165999
+ v_limit integer := ${pageSize("notification_page.max_items", 50, 500)};
166000
+ v_order text;
166001
+ v_items jsonb;
166002
+ v_total bigint;
166003
+ v_args_cap integer := notification_page.total_cap;
166004
+ begin
166005
+ v_order := case coalesce(notification_page.order_by, 'newest')
166006
+ ${list.map(([name, sql]) => ` when ${sqlString(name)} then ${sqlString(sql)}`).join("\n")}
166007
+ end;
166008
+ if v_order is null then
166009
+ raise exception 'order_by is one of ${list.map(([name]) => name).join(", ")}, not %', notification_page.order_by using errcode = '22023';
166010
+ end if;
166011
+ if notification_page.before is not null and coalesce(notification_page.order_by, 'newest') <> 'newest' then
166012
+ raise exception 'before pages the newest order; page another order with skip' using errcode = '22023';
166013
+ end if;
166014
+ ${parts.where}
166015
+ -- One row more than the page says whether another page exists, and the
166016
+ -- total stops counting at total_cap (null counts every row), so a large
166017
+ -- inbox never counts all of it. Pass before and before_id to page by key
166018
+ -- instead of skip.
166019
+ execute $q$select coalesce(jsonb_agg(p.item order by p.n), '[]')
166020
+ from (
166021
+ select row_number() over () as n, q.item
166022
+ from (
166023
+ select ${itemJson(n)} as item
166024
+ from ${n.table("recipients")} rc
166025
+ join ${n.table("events")} ev on ev.${e("id")} = rc.${r("event")}
166026
+ where $q$ || v_where || $q$
166027
+ order by $q$ || v_order || $q$
166028
+ offset $13
166029
+ limit $14 + 1
166030
+ ) q
166031
+ ) p$q$
166032
+ into v_items
166033
+ using auth.uid(), notification_page.tenant, notification_page.types, notification_page.subject_types,
166034
+ ${parts.search}, notification_page.read, notification_page.resolved, notification_page.dismissed,
166035
+ notification_page.before, coalesce(notification_page.before_id, '00000000-0000-0000-0000-000000000000'::uuid),
166036
+ notification_page.exclude_types, notification_page.subject_ids,
166037
+ greatest(coalesce(notification_page.skip, 0), 0), v_limit;
166038
+ execute $q$select count(*) from (
166039
+ select 1 from ${n.table("recipients")} rc
166040
+ join ${n.table("events")} ev on ev.${e("id")} = rc.${r("event")}
166041
+ where $q$ || v_where || case when v_args_cap is null then '' else format(' limit %s', greatest(v_args_cap, 1)) end || $q$
166042
+ ) c$q$
166043
+ into v_total
166044
+ using auth.uid(), notification_page.tenant, notification_page.types, notification_page.subject_types,
166045
+ ${parts.search}, notification_page.read, notification_page.resolved, notification_page.dismissed,
166046
+ notification_page.before, coalesce(notification_page.before_id, '00000000-0000-0000-0000-000000000000'::uuid),
166047
+ notification_page.exclude_types, notification_page.subject_ids;
166048
+ return jsonb_build_object(
166049
+ 'items', coalesce((select jsonb_agg(x.value order by x.ordinality) from jsonb_array_elements(v_items) with ordinality x(value, ordinality) where x.ordinality <= v_limit), '[]'),
166050
+ 'hasMore', jsonb_array_length(v_items) > v_limit,
166051
+ 'limit', v_limit,
166052
+ 'total', v_total,
166053
+ 'totalCapped', v_args_cap is not null and v_total >= v_args_cap
166054
+ );
166055
+ end;
166056
+ $$;
166057
+ `;
166058
+ }
165900
166059
  // src/sql/modules/notifications-readers.ts
165901
166060
  function readers$1(ctx, n) {
165902
166061
  const id = ctx.idType;
@@ -166319,6 +166478,18 @@ function inbox(ctx, n) {
166319
166478
  const subjects = subjectType && n.has("events", "subjectId");
166320
166479
  const settled = resolved ? `(rc.${r("resolvedAt")} is not null or rc.${r("dismissedAt")} is not null)` : `rc.${r("dismissedAt")} is not null`;
166321
166480
  const haystack = ["summary", "subjectLabel"].filter((logical) => n.has("events", logical)).map((logical) => `ev.${e(logical)}`);
166481
+ const actorSearch = (() => {
166482
+ if (!ctx.installed("profiles") || !n.has("events", "actor")) return "";
166483
+ const profiles = ctx.of("profiles");
166484
+ const p = (logical) => profiles.col("profiles", logical);
166485
+ const names = [
166486
+ "username",
166487
+ "fullName",
166488
+ "firstName",
166489
+ "lastName"
166490
+ ].filter((logical) => profiles.has("profiles", logical)).map((logical) => `pr.${p(logical)}`);
166491
+ return names.length === 0 ? "" : ` or exists (select 1 from ${profiles.table("profiles")} pr where pr.${p("key")} = ev.${e("actor")} and concat_ws(' ', ${names.join(", ")}) ilike $5)`;
166492
+ })();
166322
166493
  const dynamicWhere = (fn, cursor) => {
166323
166494
  const hasTenant = n.has("recipients", "tenant");
166324
166495
  const haystackSql = [...haystack, `ev.${e("type")}`].join(", ");
@@ -166350,7 +166521,7 @@ function inbox(ctx, n) {
166350
166521
  v_where := v_where || $q$ and ev.${e("subjectType")} = any($4)$q$;
166351
166522
  end if;` : ""}
166352
166523
  if btrim(coalesce(${fn}.search, '')) <> '' then
166353
- v_where := v_where || $q$ and concat_ws(' ', ${haystackSql}) ilike $5$q$;
166524
+ v_where := v_where || $q$ and (concat_ws(' ', ${haystackSql}) ilike $5${actorSearch})$q$;
166354
166525
  end if;
166355
166526
  case coalesce(${fn}.status, 'all')
166356
166527
  when 'unread' then v_where := v_where || $q$ and rc.${r("readAt")} is null$q$;
@@ -166371,6 +166542,7 @@ drop function if exists ${ctx.fn("list_notifications")}(${id}, text, text[], tim
166371
166542
  drop function if exists ${ctx.fn("list_notifications")}(${id}, text, text[], timestamptz, integer, uuid, text[], text);
166372
166543
  drop function if exists ${ctx.fn("notification_page")}(${id}, text, text[], text[], text, integer, integer);
166373
166544
  drop function if exists ${ctx.fn("notification_page")}(${id}, text, text[], text[], text, integer, integer, boolean, boolean, boolean);
166545
+ drop function if exists ${ctx.fn("notification_page")}(${id}, text, text[], text[], text, integer, integer, boolean, boolean, boolean, timestamptz, uuid, integer);
166374
166546
  drop function if exists ${ctx.fn("notification_counts")}(${id}, text[]);
166375
166547
  ${integerMutations(ctx)}
166376
166548
  -- The signed-in user's notifications, newest first, without dismissed ones.
@@ -166413,77 +166585,15 @@ ${dynamicWhere("list_notifications", true)}
166413
166585
  using auth.uid(), list_notifications.tenant, list_notifications.types, list_notifications.subject_types,
166414
166586
  ${searchPattern("list_notifications")}, list_notifications.read, list_notifications.resolved, list_notifications.dismissed,
166415
166587
  list_notifications.before, coalesce(list_notifications.before_id, '00000000-0000-0000-0000-000000000000'::uuid),
166416
- least(coalesce(list_notifications.max_items, 50), 200);
166588
+ least(coalesce(list_notifications.max_items, 50), ${String(500)});
166417
166589
  return result;
166418
166590
  end;
166419
166591
  $$;
166420
166592
 
166421
- create or replace function ${ctx.fn("notification_page")}(
166422
- tenant ${id} default null,
166423
- status text default 'all',
166424
- types text[] default null,
166425
- subject_types text[] default null,
166426
- search text default null,
166427
- max_items integer default 50,
166428
- skip integer default 0,
166429
- read boolean default null,
166430
- resolved boolean default null,
166431
- dismissed boolean default false,
166432
- before timestamptz default null,
166433
- before_id uuid default null,
166434
- total_cap integer default 10000
166435
- )
166436
- returns jsonb
166437
- language plpgsql
166438
- stable
166439
- security definer
166440
- set search_path = ''
166441
- as $$
166442
- declare
166443
- v_where text;
166444
- v_limit integer := ${pageSize("notification_page.max_items", 50, 200)};
166445
- v_items jsonb;
166446
- v_total bigint;
166447
- v_args_cap integer := notification_page.total_cap;
166448
- begin
166449
- ${dynamicWhere("notification_page", true)}
166450
- -- One row more than the page says whether an older page exists, and the
166451
- -- total stops counting at total_cap (null counts every row), so a large
166452
- -- inbox never counts all of it. Pass before and before_id to page by key
166453
- -- instead of skip.
166454
- execute $q$select coalesce(jsonb_agg(p.item order by p.created_at desc, p.id desc), '[]')
166455
- from (
166456
- select ${itemJson(n)} as item, rc.${r("createdAt")} as created_at, rc.${r("id")} as id
166457
- from ${n.table("recipients")} rc
166458
- join ${n.table("events")} ev on ev.${e("id")} = rc.${r("event")}
166459
- where $q$ || v_where || $q$
166460
- order by rc.${r("createdAt")} desc, rc.${r("id")} desc
166461
- offset $11
166462
- limit $12 + 1
166463
- ) p$q$
166464
- into v_items
166465
- using auth.uid(), notification_page.tenant, notification_page.types, notification_page.subject_types,
166466
- ${searchPattern("notification_page")}, notification_page.read, notification_page.resolved, notification_page.dismissed,
166467
- notification_page.before, coalesce(notification_page.before_id, '00000000-0000-0000-0000-000000000000'::uuid),
166468
- greatest(coalesce(notification_page.skip, 0), 0), v_limit;
166469
- execute $q$select count(*) from (
166470
- select 1 from ${n.table("recipients")} rc
166471
- join ${n.table("events")} ev on ev.${e("id")} = rc.${r("event")}
166472
- where $q$ || v_where || case when v_args_cap is null then '' else format(' limit %s', greatest(v_args_cap, 1)) end || $q$
166473
- ) c$q$
166474
- into v_total
166475
- using auth.uid(), notification_page.tenant, notification_page.types, notification_page.subject_types,
166476
- ${searchPattern("notification_page")}, notification_page.read, notification_page.resolved, notification_page.dismissed,
166477
- notification_page.before, coalesce(notification_page.before_id, '00000000-0000-0000-0000-000000000000'::uuid);
166478
- return jsonb_build_object(
166479
- 'items', coalesce((select jsonb_agg(x.value order by x.ordinality) from jsonb_array_elements(v_items) with ordinality x(value, ordinality) where x.ordinality <= v_limit), '[]'),
166480
- 'hasMore', jsonb_array_length(v_items) > v_limit,
166481
- 'total', v_total,
166482
- 'totalCapped', v_args_cap is not null and v_total >= v_args_cap
166483
- );
166484
- end;
166485
- $$;
166486
-
166593
+ ${notificationPage(ctx, n, {
166594
+ where: `${dynamicWhere("notification_page", true)}${pageFilters(n)}`,
166595
+ search: searchPattern("notification_page")
166596
+ })}
166487
166597
  -- Unread and, for the types in actionable, unresolved counts. Each count stops
166488
166598
  -- at cap (default 100, null counts every row), so a badge reads at most cap
166489
166599
  -- rows through the unread index however large the inbox is.
@@ -166598,7 +166708,7 @@ as $$
166598
166708
  $$;`];
166599
166709
  const grants = [
166600
166710
  `list_notifications(${id}, text, text[], timestamptz, integer, uuid, text[], text, boolean, boolean, boolean)`,
166601
- `notification_page(${id}, text, text[], text[], text, integer, integer, boolean, boolean, boolean, timestamptz, uuid, integer)`,
166711
+ `notification_page(${id}, text, text[], text[], text, integer, integer, boolean, boolean, boolean, timestamptz, uuid, integer, text[], text[], jsonb, text)`,
166602
166712
  `notification_counts(${id}, text[], integer)`,
166603
166713
  `mark_notifications_unread(uuid[], ${id})`,
166604
166714
  `mark_notifications_read(uuid[], ${id})`,
@@ -167519,7 +167629,7 @@ function contract$50(ctx) {
167519
167629
  },
167520
167630
  {
167521
167631
  name: "notification_page",
167522
- args: argTypes("{id} text text[] text[] text integer integer boolean boolean boolean timestamptz uuid integer"),
167632
+ args: argTypes("{id} text text[] text[] text integer integer boolean boolean boolean timestamptz uuid integer text[] text[] jsonb text"),
167523
167633
  returns: "jsonb"
167524
167634
  },
167525
167635
  {
@@ -167638,7 +167748,7 @@ const NOTIFICATIONS = {
167638
167748
  providerFunctions: ["idsWithFor"],
167639
167749
  target: "schema",
167640
167750
  modes: ["managed", "custom"],
167641
- version: 10,
167751
+ version: 11,
167642
167752
  names: NAMES$58,
167643
167753
  contract: contract$50,
167644
167754
  upgrades: [
@@ -167690,6 +167800,11 @@ const NOTIFICATIONS = {
167690
167800
  from: 9,
167691
167801
  description: "Preferences gain a cadence (immediate, daily, weekly or off); a daily or weekly delivery is held, run_notification_digests (the digest_run job) folds held deliveries into notification_digests, and claim_notification_digests and complete_notification_digest are the sender's pair. set_notification_cadence is new. A notification may name a consent_purpose that the consents block checks.",
167692
167802
  sql: (ctx) => digestUpgrade(ctx)
167803
+ },
167804
+ {
167805
+ from: 10,
167806
+ description: "notification_page sorts by order_by (newest, oldest, type, subject or status, each with a _desc form), filters on exclude_types, subject_ids and any_of groups, and returns the limit it applied; list_notifications and notification_page match search on the actor's name and return up to 500 items.",
167807
+ sql: (ctx) => `drop function if exists ${ctx.fn("notification_page")}(${ctx.idType}, text, text[], text[], text, integer, integer, boolean, boolean, boolean, timestamptz, uuid, integer);`
167693
167808
  }
167694
167809
  ],
167695
167810
  build: build$57,
@@ -177344,6 +177459,19 @@ as $$
177344
177459
  returning ${n.k("cursor")}
177345
177460
  $$;
177346
177461
 
177462
+ create or replace function ${ctx.fn("outbox_has_work")}()
177463
+ returns boolean
177464
+ language sql
177465
+ stable
177466
+ set search_path = ''
177467
+ as $$
177468
+ select exists (
177469
+ select 1 from ${n.c} c
177470
+ where (c.${n.k("retryAt")} is null or c.${n.k("retryAt")} <= now())
177471
+ and exists (select 1 from ${n.t} e where ${key("e")} > ${cursor("c")})
177472
+ )
177473
+ $$;
177474
+
177347
177475
  -- Deletes a consumer and its cursor, so purge_outbox no longer waits for it.
177348
177476
  create or replace function ${ctx.fn("outbox_unregister")}(consumer text)
177349
177477
  returns boolean
@@ -177627,7 +177755,8 @@ ${service("outbox_ack", "text, text, bigint")}
177627
177755
  ${service("outbox_fail", "text, text, bigint, text, integer, interval")}
177628
177756
  ${service("outbox_dead_letters", "text, integer")}
177629
177757
  ${service("outbox_history", "text, text, bigint, integer")}
177630
- ${service("purge_outbox", "interval, integer, interval")}`;
177758
+ ${service("purge_outbox", "interval, integer, interval")}
177759
+ ${service("outbox_has_work", "")}`;
177631
177760
  }
177632
177761
  function tracking(ctx) {
177633
177762
  const trigger = ctx.trigger("outbox_events");
@@ -177698,7 +177827,7 @@ const OUTBOX = {
177698
177827
  requires: [],
177699
177828
  target: "schema",
177700
177829
  modes: ["managed", "custom"],
177701
- version: 5,
177830
+ version: 6,
177702
177831
  integrates: ["data-lifecycle"],
177703
177832
  names: NAMES$51,
177704
177833
  upgrades: [
@@ -177721,6 +177850,11 @@ const OUTBOX = {
177721
177850
  from: 4,
177722
177851
  description: "outbox_row_event() is no longer executable by API roles. options.partitioned partitions a new events table by month on created_at, with a sequence for the position, and applies to new tables only.",
177723
177852
  sql: () => ""
177853
+ },
177854
+ {
177855
+ from: 5,
177856
+ description: "outbox_has_work() says whether a consumer has events after its cursor, as the probe of the relay schedule.",
177857
+ sql: () => ""
177724
177858
  }
177725
177859
  ],
177726
177860
  contract: () => [
@@ -185665,7 +185799,8 @@ drop function if exists better_supabase.purge_job_archive(text, interval, intege
185665
185799
  -- schedule_job before schedules had a tenant.
185666
185800
  drop function if exists better_supabase.schedule_job(text, text, text, jsonb, text, timestamptz);
185667
185801
  -- claim_due_schedules returns first_after now; create or replace can't change a return type.
185668
- drop function if exists better_supabase.claim_due_schedules(integer, integer);`;
185802
+ drop function if exists better_supabase.claim_due_schedules(integer, integer);
185803
+ drop function if exists better_supabase.schedule_job(text, text, text, jsonb, text, timestamptz, text);`;
185669
185804
  /**
185670
185805
  * Opens purge_job_archive: nothing goes while a legal hold covers the archive,
185671
185806
  * and a data-lifecycle retention policy replaces both intervals.
@@ -186060,6 +186195,30 @@ begin
186060
186195
  return retried;
186061
186196
  end;
186062
186197
  $$;`;
186198
+ const PROBE_CHECK = ` if probe is not null and not exists (
186199
+ select 1 from pg_catalog.pg_proc p
186200
+ where p.oid = pg_catalog.to_regprocedure(probe || '()') and p.prorettype = 'boolean'::regtype
186201
+ ) then
186202
+ raise exception 'The probe % is not a function without arguments that returns boolean', probe using errcode = '22023';
186203
+ end if;`;
186204
+ const SCHEDULE_HAS_WORK = `create or replace function better_supabase.schedule_has_work(probe text)
186205
+ returns boolean
186206
+ language plpgsql
186207
+ set search_path = ''
186208
+ as $$
186209
+ declare
186210
+ v_probe regprocedure := pg_catalog.to_regprocedure(probe || '()');
186211
+ v_work boolean;
186212
+ begin
186213
+ if v_probe is null then
186214
+ return true;
186215
+ end if;
186216
+ execute format('select %s()', v_probe::oid::regproc) into v_work;
186217
+ return coalesce(v_work, true);
186218
+ exception when others then
186219
+ return true;
186220
+ end;
186221
+ $$;`;
186063
186222
  const ensureQueue = (backend) => backend === "pgmq" ? "\n perform better_supabase.ensure_job_queue(queue);" : "";
186064
186223
  const PG_CRON = (backend) => `-- Recurring jobs with pg_cron, in cron.timezone (UTC unless the project changed it):
186065
186224
  -- select better_supabase.schedule_job('nightly-digest', '0 3 * * *', 'emails', '{"kind": "digest"}');
@@ -186072,7 +186231,8 @@ create or replace function better_supabase.schedule_job(
186072
186231
  payload jsonb default '{}',
186073
186232
  timezone text default 'UTC',
186074
186233
  next_run timestamptz default null,
186075
- tenant text default null
186234
+ tenant text default null,
186235
+ probe text default null
186076
186236
  )
186077
186237
  returns bigint
186078
186238
  language plpgsql
@@ -186094,9 +186254,11 @@ begin
186094
186254
  if timezone <> 'UTC' then
186095
186255
  raise exception 'pg_cron runs schedules in cron.timezone, not %; set blocks.queue.options.scheduler to "drain" for per-schedule time zones', timezone;
186096
186256
  end if;${ensureQueue(backend)}
186257
+ ${PROBE_CHECK}
186097
186258
  execute format('select %s($1::text, $2::text, $3::text)', v_schedule::oid::regproc)
186098
186259
  into v_id
186099
- using job_name, schedule, format('select better_supabase.enqueue_job(%L, %L::jsonb)', queue, payload::text);
186260
+ using job_name, schedule, format('select better_supabase.enqueue_job(%L, %L::jsonb)', queue, payload::text)
186261
+ || case when probe is null then '' else format(' where better_supabase.schedule_has_work(%L)', probe) end;
186100
186262
  return v_id;
186101
186263
  end;
186102
186264
  $$;
@@ -186143,7 +186305,7 @@ $$;
186143
186305
  -- pg_cron's jobs whose name starts with name_prefix. pg_cron keeps no queue,
186144
186306
  -- payload, tenant or next run, so those are null.
186145
186307
  create or replace function better_supabase.list_schedules(name_prefix text default null, for_tenant text default null)
186146
- returns table (job_name text, schedule text, timezone text, queue text, tenant text, next_run timestamptz, last_run timestamptz, lock_expires_at timestamptz, created_at timestamptz, payload jsonb)
186308
+ returns table (job_name text, schedule text, timezone text, queue text, tenant text, next_run timestamptz, last_run timestamptz, lock_expires_at timestamptz, created_at timestamptz, payload jsonb, probe text)
186147
186309
  language plpgsql
186148
186310
  stable
186149
186311
  security definer
@@ -186156,7 +186318,7 @@ begin
186156
186318
  return;
186157
186319
  end if;
186158
186320
  return query execute format(
186159
- 'select j.jobname::text, j.schedule::text, ''UTC''::text, null::text, null::text, null::timestamptz, null::timestamptz, null::timestamptz, null::timestamptz, null::jsonb
186321
+ 'select j.jobname::text, j.schedule::text, ''UTC''::text, null::text, null::text, null::timestamptz, null::timestamptz, null::timestamptz, null::timestamptz, null::jsonb, null::text
186160
186322
  from %s j where $1 is null or starts_with(j.jobname, $1) order by j.jobname', v_jobs)
186161
186323
  using name_prefix;
186162
186324
  end;
@@ -186197,7 +186359,8 @@ create table if not exists ${schedules} (
186197
186359
  -- The tenant a schedule runs for, so a tenant's schedules can be listed and
186198
186360
  -- removed together (unschedule_tenant).
186199
186361
  alter table ${schedules} add column if not exists ${c("tenant")} text;
186200
- alter table ${schedules} add column if not exists ${c("firstAfter")} timestamptz;${legacy}${jobNameKey}
186362
+ alter table ${schedules} add column if not exists ${c("firstAfter")} timestamptz;
186363
+ alter table ${schedules} add column if not exists ${c("probe")} text;${legacy}${jobNameKey}
186201
186364
  create index if not exists ${index("due_idx")} on ${schedules} (${c("nextRun")});
186202
186365
  create index if not exists ${index("tenant_idx")} on ${schedules} (${c("tenant")}) where ${c("tenant")} is not null;
186203
186366
  alter table ${schedules} enable row level security;
@@ -186214,7 +186377,8 @@ create or replace function better_supabase.schedule_job(
186214
186377
  payload jsonb default '{}',
186215
186378
  timezone text default 'UTC',
186216
186379
  next_run timestamptz default null,
186217
- tenant text default null
186380
+ tenant text default null,
186381
+ probe text default null
186218
186382
  )
186219
186383
  returns bigint
186220
186384
  language plpgsql
@@ -186223,6 +186387,7 @@ set search_path = ''
186223
186387
  as $$
186224
186388
  #variable_conflict use_column
186225
186389
  begin
186390
+ ${PROBE_CHECK}
186226
186391
  if not exists (select 1 from pg_catalog.pg_timezone_names z where z.name = timezone) then
186227
186392
  raise exception 'Unknown time zone %', timezone;
186228
186393
  end if;
@@ -186230,9 +186395,9 @@ begin
186230
186395
  raise exception 'Invalid schedule %: expected five cron fields, a macro such as @daily, or an interval such as 5 minutes', schedule
186231
186396
  using errcode = '22023';
186232
186397
  end if;
186233
- insert into ${schedules} as s (${c("jobName")}, ${c("schedule")}, ${c("timezone")}, ${c("queue")}, ${c("payload")}, ${c("nextRun")}, ${c("firstAfter")}, ${c("tenant")})
186398
+ insert into ${schedules} as s (${c("jobName")}, ${c("schedule")}, ${c("timezone")}, ${c("queue")}, ${c("payload")}, ${c("nextRun")}, ${c("firstAfter")}, ${c("tenant")}, ${c("probe")})
186234
186399
  values (job_name, schedule, timezone, queue, payload, date_trunc('milliseconds', next_run),
186235
- case when next_run is null then date_trunc('milliseconds', now()) end, tenant)
186400
+ case when next_run is null then date_trunc('milliseconds', now()) end, tenant, probe)
186236
186401
  on conflict (${c("jobName")}) do update
186237
186402
  set ${c("schedule")} = excluded.${c("schedule")},
186238
186403
  ${c("timezone")} = excluded.${c("timezone")},
@@ -186249,6 +186414,7 @@ begin
186249
186414
  else excluded.${c("firstAfter")}
186250
186415
  end,
186251
186416
  ${c("tenant")} = excluded.${c("tenant")},
186417
+ ${c("probe")} = excluded.${c("probe")},
186252
186418
  ${c("lockedUntil")} = null;
186253
186419
  return null;
186254
186420
  end;
@@ -186257,13 +186423,13 @@ $$;
186257
186423
  -- Schedules whose name starts with name_prefix and that run for for_tenant (either
186258
186424
  -- filter null: all), for a product page that shows the next run.
186259
186425
  create or replace function better_supabase.list_schedules(name_prefix text default null, for_tenant text default null)
186260
- returns table (job_name text, schedule text, timezone text, queue text, tenant text, next_run timestamptz, last_run timestamptz, lock_expires_at timestamptz, created_at timestamptz, payload jsonb)
186426
+ returns table (job_name text, schedule text, timezone text, queue text, tenant text, next_run timestamptz, last_run timestamptz, lock_expires_at timestamptz, created_at timestamptz, payload jsonb, probe text)
186261
186427
  language sql
186262
186428
  stable
186263
186429
  security definer
186264
186430
  set search_path = ''
186265
186431
  as $$
186266
- select s.${c("jobName")}, s.${c("schedule")}, s.${c("timezone")}, s.${c("queue")}, s.${c("tenant")}, s.${c("nextRun")}, s.${c("lastRun")}, s.${c("lockedUntil")}, s.${c("createdAt")}, s.${c("payload")}
186432
+ select s.${c("jobName")}, s.${c("schedule")}, s.${c("timezone")}, s.${c("queue")}, s.${c("tenant")}, s.${c("nextRun")}, s.${c("lastRun")}, s.${c("lockedUntil")}, s.${c("createdAt")}, s.${c("payload")}, s.${c("probe")}
186267
186433
  from ${schedules} s
186268
186434
  where (list_schedules.name_prefix is null or starts_with(s.${c("jobName")}, list_schedules.name_prefix))
186269
186435
  and (list_schedules.for_tenant is null or s.${c("tenant")} = list_schedules.for_tenant)
@@ -186307,7 +186473,7 @@ as $$
186307
186473
  begin
186308
186474
  return query
186309
186475
  with due as (
186310
- select s.${c("jobName")} as job_name
186476
+ select s.${c("jobName")} as job_name, s.${c("nextRun")} is null as first, s.${c("probe")} as probe
186311
186477
  from ${schedules} s
186312
186478
  where (s.${c("nextRun")} is null or s.${c("nextRun")} <= clock_timestamp())
186313
186479
  and (s.${c("lockedUntil")} is null or s.${c("lockedUntil")} < clock_timestamp())
@@ -186319,6 +186485,7 @@ begin
186319
186485
  set ${c("lockedUntil")} = clock_timestamp() + make_interval(secs => lease)
186320
186486
  from due
186321
186487
  where s.${c("jobName")} = due.job_name
186488
+ and (due.first or due.probe is null or better_supabase.schedule_has_work(due.probe))
186322
186489
  returning s.${c("jobName")}, s.${c("schedule")}, s.${c("timezone")}, s.${c("queue")}, s.${c("payload")}, s.${c("nextRun")}, s.${c("firstAfter")};
186323
186490
  end;
186324
186491
  $$;
@@ -186358,7 +186525,8 @@ const GRANTS = (backend) => serviceOnly$1([
186358
186525
  "complete_job(text, bigint, integer)",
186359
186526
  "fail_job(text, bigint, integer, text, integer)",
186360
186527
  "extend_job_lease(text, bigint, integer, integer)",
186361
- "schedule_job(text, text, text, jsonb, text, timestamptz, text)",
186528
+ "schedule_job(text, text, text, jsonb, text, timestamptz, text, text)",
186529
+ "schedule_has_work(text)",
186362
186530
  "unschedule_job(text)",
186363
186531
  "list_schedules(text, text)",
186364
186532
  "unschedule_tenant(text)",
@@ -186390,7 +186558,8 @@ const NAMES$42 = {
186390
186558
  lockedUntil: "lock_expires_at",
186391
186559
  createdAt: "created_at",
186392
186560
  tenant: "tenant",
186393
- firstAfter: "first_after"
186561
+ firstAfter: "first_after",
186562
+ probe: "probe"
186394
186563
  }
186395
186564
  }
186396
186565
  }
@@ -186402,6 +186571,7 @@ function jobsSql(ctx) {
186402
186571
  schemaPreamble(ctx),
186403
186572
  LEGACY,
186404
186573
  backend === "pgmq" ? pgmq(archiveGuard(ctx)) : table$1(ctx, archiveGuard(ctx)),
186574
+ SCHEDULE_HAS_WORK,
186405
186575
  scheduler === "pg_cron" ? PG_CRON(backend) : drain(ctx),
186406
186576
  leasesSql(ctx),
186407
186577
  GRANTS(backend)
@@ -186414,10 +186584,15 @@ const JOBS = {
186414
186584
  requires: ["housekeeping"],
186415
186585
  integrates: ["data-lifecycle"],
186416
186586
  target: "schema",
186417
- version: 11,
186587
+ version: 12,
186418
186588
  names: NAMES$42,
186419
186589
  data: (ctx) => jobsBackend(ctx) === "pgmq" ? "-- Indexes the queues that existed before the module.\nselect better_supabase.index_job_queue(q.queue_name) from pgmq.list_queues() q;" : "",
186420
186590
  upgrades: [
186591
+ {
186592
+ from: 11,
186593
+ description: "A schedule can name a probe, a function without arguments that returns whether there is work; a due schedule whose probe returns false stays due and enqueues nothing until it does. list_schedules returns the probe.",
186594
+ sql: () => ["drop function if exists better_supabase.schedule_job(text, text, text, jsonb, text, timestamptz, text);", "drop function if exists better_supabase.list_schedules(text, text);"].join("\n")
186595
+ },
186421
186596
  {
186422
186597
  from: 10,
186423
186598
  description: "ready_job_queues answers which queues have a claimable message, and list_schedules returns each schedule's payload.",
@@ -220514,7 +220689,35 @@ stable
220514
220689
  security definer
220515
220690
  set search_path = ''
220516
220691
  as $$
220517
- ${hasCounter("reported") ? ` select coalesce(jsonb_agg(jsonb_build_object(
220692
+ ${hasCounter("reported") ? ` with c as materialized (
220693
+ select * from ${counters} c
220694
+ where c.${cc("value")} > c.${cc("reported")}
220695
+ and c.${cc("meter")} <> all (coalesce(unreported_usage.skip_meters, '{}'))
220696
+ and c.${cc("tenant")} <> all (coalesce(unreported_usage.skip_tenants, '{}'))
220697
+ order by c.${cc("day")}
220698
+ limit max_rows
220699
+ ),
220700
+ tenants as materialized (
220701
+ select t.tenant${entitled ? `, ${ctx.entitlements("t.tenant")}::text[] as entitled` : ""}${planKeys === "" ? "" : ", better_supabase.tenant_plans(t.tenant)::text[] as plans"}
220702
+ from (select distinct c.${cc("tenant")} as tenant from c) t
220703
+ ),
220704
+ quota as materialized (
220705
+ select distinct on (p.tenant, p.meter) p.tenant, p.meter, q.${qc("limit")} as quota_limit, ${quotaPeriod("q")} as period
220706
+ from (select distinct c.${cc("tenant")} as tenant, c.${cc("meter")} as meter from c) p
220707
+ join tenants t on t.tenant = p.tenant
220708
+ join ${quotas} q on q.${qc("meter")} = p.meter
220709
+ and (q.${qc("tenant")} = p.tenant or (q.${qc("tenant")} is null and (q.${qc("plan")} = '*'${entitled ? ` or q.${qc("plan")} = any (t.entitled)` : ""}${planKeys === "" ? "" : ` or q.${qc("plan")} = any (t.plans)`})))
220710
+ order by p.tenant, p.meter, (q.${qc("tenant")} is not null) desc, q.${qc("limit")} desc nulls first
220711
+ ),
220712
+ win as materialized (
220713
+ select d.tenant, d.period, d.day, ${fn("usage_window_start")}(d.tenant, d.period, d.day) as since
220714
+ from (
220715
+ select distinct c.${cc("tenant")} as tenant, q.period, c.${cc("day")} as day
220716
+ from c
220717
+ left join quota q on q.tenant = c.${cc("tenant")} and q.meter = c.${cc("meter")}
220718
+ ) d
220719
+ )
220720
+ select coalesce(jsonb_agg(jsonb_build_object(
220518
220721
  'organization_id', c.${cc("tenant")},
220519
220722
  'meter', c.${cc("meter")},
220520
220723
  'day', c.${cc("day")},
@@ -220530,18 +220733,9 @@ ${hasCounter("reported") ? ` select coalesce(jsonb_agg(jsonb_build_object(
220530
220733
  and o.${cc("day")} >= w.since
220531
220734
  )
220532
220735
  ) order by c.${cc("day")}, c.${cc("meter")}), '[]'::jsonb)
220533
- from (
220534
- select * from ${counters} c
220535
- where c.${cc("value")} > c.${cc("reported")}
220536
- and c.${cc("meter")} <> all (coalesce(unreported_usage.skip_meters, '{}'))
220537
- and c.${cc("tenant")} <> all (coalesce(unreported_usage.skip_tenants, '{}'))
220538
- order by c.${cc("day")}
220539
- limit max_rows
220540
- ) c
220541
- left join lateral ${fn("usage_quota")}(c.${cc("tenant")}, c.${cc("meter")}) q on true
220542
- cross join lateral (
220543
- select ${fn("usage_window_start")}(c.${cc("tenant")}, q.period, c.${cc("day")}) as since
220544
- ) w` : " select '[]'::jsonb"}
220736
+ from c
220737
+ left join quota q on q.tenant = c.${cc("tenant")} and q.meter = c.${cc("meter")}
220738
+ join win w on w.tenant = c.${cc("tenant")} and w.period is not distinct from q.period and w.day = c.${cc("day")}` : " select '[]'::jsonb"}
220545
220739
  $$;
220546
220740
 
220547
220741
  -- Marks a counter as reported up to value; never moves it backwards.
@@ -225448,6 +225642,19 @@ ${receive}
225448
225642
  end;
225449
225643
  $$;
225450
225644
 
225645
+ create or replace function better_supabase.webhook_inbox_has_work()
225646
+ returns boolean
225647
+ language sql
225648
+ stable
225649
+ set search_path = ''
225650
+ as $$
225651
+ select exists (
225652
+ select 1 from ${t} c
225653
+ where (c.${c("status")} = 'pending' and c.${c("availableAt")} <= now())
225654
+ or (c.${c("status")} = 'processing' and c.${c("lockedUntil")} < now())
225655
+ )
225656
+ $$;
225657
+
225451
225658
  -- The claimed messages, a jsonb array. A message whose lease ran out on its
225452
225659
  -- last attempt lost its worker (fail_webhook marks it dead otherwise), so the
225453
225660
  -- claim marks it dead.
@@ -225638,6 +225845,7 @@ $$;
225638
225845
  ${serviceOnly$1([
225639
225846
  `receive_webhook(text, text, text, jsonb, jsonb, text, integer${extra.type})`,
225640
225847
  "claim_webhooks(text, text, integer, interval)",
225848
+ "webhook_inbox_has_work()",
225641
225849
  "complete_webhook(bigint, text, integer)",
225642
225850
  "fail_webhook(bigint, text, text, interval, integer, boolean)",
225643
225851
  "extend_webhook(bigint, text, integer, interval)",
@@ -225676,7 +225884,7 @@ const WEBHOOK_INBOX = {
225676
225884
  ]
225677
225885
  } }
225678
225886
  },
225679
- version: 9,
225887
+ version: 10,
225680
225888
  upgrades: [
225681
225889
  {
225682
225890
  from: 1,
@@ -225721,6 +225929,11 @@ const WEBHOOK_INBOX = {
225721
225929
  from: 8,
225722
225930
  description: "fail_webhook takes permanent, which marks the message dead without further attempts.",
225723
225931
  sql: () => "drop function if exists better_supabase.fail_webhook(bigint, text, text, interval, integer);"
225932
+ },
225933
+ {
225934
+ from: 9,
225935
+ description: "webhook_inbox_has_work() says whether a message is ready to claim, as the probe of the inbox schedule.",
225936
+ sql: () => ""
225724
225937
  }
225725
225938
  ],
225726
225939
  build: webhookInboxSql
@@ -225922,6 +226135,9 @@ ${renderPolicy(policy$1({
225922
226135
  ["created_by", read("e", "createdBy")],
225923
226136
  ["created_at", read("e", "createdAt")]
225924
226137
  ];
226138
+ const created = read("e", "createdAt", e("id"));
226139
+ const newest = "list_incoming_webhooks.newest_first";
226140
+ const order = `case when ${newest} then ${created} end desc, case when ${newest} then ${e("id")} end desc, ${created}, ${e("id")}`;
225925
226141
  const subjectFilter = subjectColumns ? `
225926
226142
  and (list_incoming_webhooks.subject_type is null or ${e("subjectType")} = list_incoming_webhooks.subject_type)
225927
226143
  and (list_incoming_webhooks.subject_id is null or ${e("subjectId")} = list_incoming_webhooks.subject_id)` : `
@@ -226027,22 +226243,29 @@ $$;
226027
226243
  revoke execute on function ${ctx.fn("incoming_webhook_subject_readable")}(text, text, ${id}) from public, anon;
226028
226244
  grant execute on function ${ctx.fn("incoming_webhook_subject_readable")}(text, text, ${id}) to authenticated, service_role;
226029
226245
  ${readPolicy}
226246
+ drop function if exists ${ctx.fn("list_incoming_webhooks")}(${id}, text, text);
226030
226247
  -- A tenant's endpoints, or one subject's, without secrets; runs as the caller.
226031
- create or replace function ${ctx.fn("list_incoming_webhooks")}(tenant ${id}, subject_type text default null, subject_id text default null)
226248
+ create or replace function ${ctx.fn("list_incoming_webhooks")}(tenant ${id}, subject_type text default null, subject_id text default null, page_size integer default null, skip integer default 0, newest_first boolean default false)
226032
226249
  returns jsonb
226033
226250
  language sql
226034
226251
  stable
226035
226252
  security invoker
226036
226253
  set search_path = ''
226037
226254
  as $$
226038
- select coalesce(jsonb_agg(jsonb_build_object(
226039
- ${listed.map(([name, value]) => `'${name}', ${value}`).join(",\n ")}
226040
- ) order by ${read("e", "createdAt", e("id"))}), '[]'::jsonb)
226041
- from ${t} e
226042
- where ${e("tenant")} = list_incoming_webhooks.tenant${subjectFilter}
226255
+ select coalesce(jsonb_agg(page.item order by page.n), '[]'::jsonb)
226256
+ from (
226257
+ select jsonb_build_object(
226258
+ ${listed.map(([name, value]) => `'${name}', ${value}`).join(",\n ")}
226259
+ ) as item, row_number() over (order by ${order}) as n
226260
+ from ${t} e
226261
+ where ${e("tenant")} = list_incoming_webhooks.tenant${subjectFilter}
226262
+ order by ${order}
226263
+ limit case when list_incoming_webhooks.page_size is null then null else ${pageSize("list_incoming_webhooks.page_size", 50, 500)} end
226264
+ offset greatest(coalesce(list_incoming_webhooks.skip, 0), 0)
226265
+ ) page
226043
226266
  $$;
226044
- revoke execute on function ${ctx.fn("list_incoming_webhooks")}(${id}, text, text) from public, anon;
226045
- grant execute on function ${ctx.fn("list_incoming_webhooks")}(${id}, text, text) to authenticated, service_role;
226267
+ revoke execute on function ${ctx.fn("list_incoming_webhooks")}(${id}, text, text, integer, integer, boolean) from public, anon;
226268
+ grant execute on function ${ctx.fn("list_incoming_webhooks")}(${id}, text, text, integer, integer, boolean) to authenticated, service_role;
226046
226269
  ${cascades}
226047
226270
  drop function if exists ${ctx.fn("create_incoming_webhook")}(${id}, text, text, jsonb, text);
226048
226271
  -- Creates an endpoint and returns it with its token (and the signing secret
@@ -226378,7 +226601,7 @@ const WEBHOOKS_IN = {
226378
226601
  } },
226379
226602
  options: ["maxBodyBytes", "secretStorage"]
226380
226603
  },
226381
- version: 4,
226604
+ version: 5,
226382
226605
  upgrades: [
226383
226606
  {
226384
226607
  from: 1,
@@ -226400,6 +226623,11 @@ where e.secret is not null and e.secret_id is null;`;
226400
226623
  from: 3,
226401
226624
  description: "Adopt mode over an app's endpoints table; incoming_webhook_by_token returns the endpoint's metadata for destinations.",
226402
226625
  sql: () => ""
226626
+ },
226627
+ {
226628
+ from: 4,
226629
+ description: "list_incoming_webhooks pages with page_size and skip, and newest_first lists the newest endpoints first.",
226630
+ sql: () => ""
226403
226631
  }
226404
226632
  ],
226405
226633
  contract: () => [
@@ -226437,7 +226665,10 @@ where e.secret is not null and e.secret_id is null;`;
226437
226665
  args: [
226438
226666
  "{id}",
226439
226667
  "text",
226440
- "text"
226668
+ "text",
226669
+ "integer",
226670
+ "integer",
226671
+ "boolean"
226441
226672
  ],
226442
226673
  returns: "jsonb"
226443
226674
  },
@@ -226764,7 +226995,22 @@ function claim(ctx, n) {
226764
226995
  n.has("deliveries", "processedAt") ? `, ${v("processedAt")} = now()` : "",
226765
226996
  touched(n, "deliveries")
226766
226997
  ].join("");
226998
+ const probe = ctx.fn("webhook_deliveries_has_work");
226767
226999
  return `
227000
+ create or replace function ${probe}()
227001
+ returns boolean
227002
+ language sql
227003
+ stable
227004
+ set search_path = ''
227005
+ as $$
227006
+ select exists (
227007
+ select 1 from ${n.table("deliveries")} v
227008
+ where v.${v("status")} in (${n.status("pending")}, ${n.status("retrying")}, ${n.status("delivering")})
227009
+ and v.${v("availableAt")} <= now()
227010
+ and (v.${v("leasedUntil")} is null or v.${v("leasedUntil")} <= now())
227011
+ )
227012
+ $$;
227013
+ ${grants(probe, "", false)}
226768
227014
  drop function if exists ${fn}(integer, interval);
226769
227015
  -- Leases due deliveries to one worker and counts the attempt, so a worker
226770
227016
  -- that dies mid-send still uses one up. The attempt is the lease token that
@@ -227823,7 +228069,7 @@ const WEBHOOKS_OUT = {
227823
228069
  providerFunctions: ["idsWithFor"],
227824
228070
  target: "schema",
227825
228071
  modes: ["managed", "custom"],
227826
- version: 6,
228072
+ version: 7,
227827
228073
  names: NAMES$2,
227828
228074
  contract: contract$1,
227829
228075
  upgrades: [
@@ -227854,6 +228100,11 @@ const WEBHOOKS_OUT = {
227854
228100
  from: 5,
227855
228101
  description: "create_webhook_endpoint, update_webhook_endpoint, list_webhook_endpoints and delete_webhook_endpoint manage a tenant's endpoints behind the module's manage and view permissions.",
227856
228102
  sql: () => ""
228103
+ },
228104
+ {
228105
+ from: 6,
228106
+ description: "webhook_deliveries_has_work() says whether a delivery is due, as the probe of the delivery schedule.",
228107
+ sql: () => ""
227857
228108
  }
227858
228109
  ],
227859
228110
  build: build$2