better-supabase 0.30.0 → 0.32.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 (1688) hide show
  1. package/dist/access-sql-Dao1C0fz.js +383 -0
  2. package/dist/actor-B5b0i1Fs.js +149 -0
  3. package/dist/actor-DseNR02I.d.ts +104 -0
  4. package/dist/adapter-CPPN80mx.js +2231 -0
  5. package/dist/agents-BEiBtYmh.d.ts +115 -0
  6. package/dist/ai-cache-D9D36eh4.js +86 -0
  7. package/dist/ai-cache-FMYzw7lW.d.ts +80 -0
  8. package/dist/ai-chat-B_P--Ie2.d.ts +532 -0
  9. package/dist/ai-files-DCMVGSds.js +337 -0
  10. package/dist/ai-message-cnroprVB.js +13 -0
  11. package/dist/ai-schedules-D_q1iclL.d.ts +164 -0
  12. package/dist/ai-sdk/agents/index.d.ts +8 -12
  13. package/dist/ai-sdk/agents/index.js +10 -12
  14. package/dist/ai-sdk/batches/index.d.ts +12 -7
  15. package/dist/ai-sdk/batches/index.js +16 -9
  16. package/dist/ai-sdk/cache/index.d.ts +2 -4
  17. package/dist/ai-sdk/cache/index.js +3 -4
  18. package/dist/ai-sdk/chat/index.d.ts +77 -2
  19. package/dist/ai-sdk/chat/index.js +179 -28
  20. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  21. package/dist/ai-sdk/embeddings/index.js +1 -1
  22. package/dist/ai-sdk/files/index.d.ts +3 -5
  23. package/dist/ai-sdk/files/index.js +5 -6
  24. package/dist/ai-sdk/index.d.ts +75 -21
  25. package/dist/ai-sdk/index.js +112 -66
  26. package/dist/ai-sdk/mcp/index.d.ts +28 -13
  27. package/dist/ai-sdk/mcp/index.js +56 -17
  28. package/dist/ai-sdk/memory/index.d.ts +3 -5
  29. package/dist/ai-sdk/memory/index.js +3 -4
  30. package/dist/ai-sdk/react/index.d.ts +2 -2
  31. package/dist/ai-sdk/react/index.js +3 -1
  32. package/dist/ai-sdk/react/server.d.ts +7 -4
  33. package/dist/ai-sdk/react/server.js +10 -3
  34. package/dist/ai-sdk/workflow/index.d.ts +12 -13
  35. package/dist/ai-sdk/workflow/index.js +17 -17
  36. package/dist/ai-sdk/workflow/react/index.d.ts +1 -3
  37. package/dist/ai-sdk/workflow/react/index.js +3 -3
  38. package/dist/ai-sdk/workflow/react/server.d.ts +1 -3
  39. package/dist/ai-sdk/workflow/react/server.js +1 -2
  40. package/dist/anchors-sCLvYj-8.d.ts +36 -0
  41. package/dist/api-CwzVbbw4.d.ts +483 -0
  42. package/dist/api-keys-u2sXB-CZ.d.ts +211 -0
  43. package/dist/api-wwix_K5c.js +691 -0
  44. package/dist/app-tables-DomvYx5b.d.ts +26 -0
  45. package/dist/approvals-Da4uAANx.js +166 -0
  46. package/dist/approvals-idpuhILk.d.ts +127 -0
  47. package/dist/assistant-CMKsaeJd.d.ts +209 -0
  48. package/dist/astro/index.d.ts +8 -10
  49. package/dist/astro/index.js +8 -9
  50. package/dist/attachments-BWtUQgsL.js +375 -0
  51. package/dist/attributes-BZNkR2z2.js +51 -0
  52. package/dist/auth-link-BmJsQG4a.js +117 -0
  53. package/dist/auth-link-DRjtI1Ky.d.ts +102 -0
  54. package/dist/auth-module-CVo86UKh.js +50 -0
  55. package/dist/auth-reply-BMPJQssh.d.ts +9 -0
  56. package/dist/auth-reply-Cnwn3I_q.js +30 -0
  57. package/dist/auth-wFlGgwTZ.js +19 -0
  58. package/dist/authorization-CYu_UKX4.d.ts +3723 -0
  59. package/dist/authorization-hooks-CldgvzBZ.d.ts +219 -0
  60. package/dist/authorizer-AswD5q6g.d.ts +116 -0
  61. package/dist/authorizer-D6po_XZA.js +171 -0
  62. package/dist/automation-acq3iK9y.js +74 -0
  63. package/dist/automations-BfH8GJqv.js +27 -0
  64. package/dist/automations-Bw5cX7oj.js +29 -0
  65. package/dist/automations-CCc5RUw-.js +31 -0
  66. package/dist/automations-Dou1t3lt.js +313 -0
  67. package/dist/availability-CebEOfMN.d.ts +236 -0
  68. package/dist/base64-CVyKHBBw.js +41 -0
  69. package/dist/batch-limit-DqQ3d6op.js +4 -0
  70. package/dist/before-route-Ra3OhI2x.js +29 -0
  71. package/dist/better-result/index.d.ts +4 -6
  72. package/dist/better-result/index.js +2 -3
  73. package/dist/bind-8LYVJE5W.d.ts +102 -0
  74. package/dist/block-authors-C5z3tGVu.d.ts +10 -0
  75. package/dist/block-authors-DCQ4zl8e.js +13 -0
  76. package/dist/block-env-BsLgZL2l.d.ts +30 -0
  77. package/dist/block-event-listener-DCi7c89M.js +15 -0
  78. package/dist/block-events-Bp6GPIBN.js +82 -0
  79. package/dist/block-fields-Bjcv6_zc.js +139 -0
  80. package/dist/block-fields-Puv5m5D3.d.ts +56 -0
  81. package/dist/block-helpers-I7UzjNEf.js +435 -0
  82. package/dist/block-helpers-JxiD1iw4.d.ts +56 -0
  83. package/dist/block-hooks-CJP5kGEa.d.ts +115 -0
  84. package/dist/block-hooks-CadxQ9-_.js +129 -0
  85. package/dist/block-method-DIbWG4Mj.js +20 -0
  86. package/dist/block-method-QSaPsL2P.d.ts +12 -0
  87. package/dist/block-subjects-SyJwfgrX.d.ts +4 -0
  88. package/dist/block-subjects-cRlVtKDO.js +54 -0
  89. package/dist/block-tenant-Bun03JuO.js +13 -0
  90. package/dist/block-transport-Bbf1ZZre.d.ts +67 -0
  91. package/dist/blocks/access-requests/index.d.ts +9 -15
  92. package/dist/blocks/access-requests/index.js +11 -14
  93. package/dist/blocks/activities/index.d.ts +13 -21
  94. package/dist/blocks/activities/index.js +16 -21
  95. package/dist/blocks/agents/index.d.ts +4 -8
  96. package/dist/blocks/agents/index.js +11 -14
  97. package/dist/blocks/ai-cache/index.d.ts +3 -5
  98. package/dist/blocks/ai-cache/index.js +5 -6
  99. package/dist/blocks/ai-chat/index.d.ts +10 -19
  100. package/dist/blocks/ai-chat/index.js +20 -28
  101. package/dist/blocks/ai-files/index.d.ts +5 -9
  102. package/dist/blocks/ai-files/index.js +5 -6
  103. package/dist/blocks/ai-keys/index.d.ts +4 -10
  104. package/dist/blocks/ai-keys/index.js +14 -18
  105. package/dist/blocks/ai-schedules/index.d.ts +3 -5
  106. package/dist/blocks/ai-schedules/index.js +14 -16
  107. package/dist/blocks/announcements/index.d.ts +12 -20
  108. package/dist/blocks/announcements/index.js +12 -16
  109. package/dist/blocks/api-keys/index.d.ts +8 -16
  110. package/dist/blocks/api-keys/index.js +17 -22
  111. package/dist/blocks/approvals/index.d.ts +4 -8
  112. package/dist/blocks/approvals/index.js +7 -173
  113. package/dist/blocks/assets/index.d.ts +9 -17
  114. package/dist/blocks/assets/index.js +13 -17
  115. package/dist/blocks/assignment/index.d.ts +9 -17
  116. package/dist/blocks/assignment/index.js +10 -14
  117. package/dist/blocks/attachments/index.d.ts +6 -18
  118. package/dist/blocks/attachments/index.js +19 -24
  119. package/dist/blocks/audit/index.d.ts +15 -31
  120. package/dist/blocks/audit/index.js +27 -35
  121. package/dist/blocks/automations/index.d.ts +14 -26
  122. package/dist/blocks/automations/index.js +18 -23
  123. package/dist/blocks/billable-time/index.d.ts +9 -19
  124. package/dist/blocks/billable-time/index.js +15 -20
  125. package/dist/blocks/billing/index.d.ts +12 -22
  126. package/dist/blocks/billing/index.js +19 -24
  127. package/dist/blocks/bookings/index.d.ts +8 -18
  128. package/dist/blocks/bookings/index.js +17 -23
  129. package/dist/blocks/bulk/index.d.ts +6 -12
  130. package/dist/blocks/bulk/index.js +10 -13
  131. package/dist/blocks/calendar/index.d.ts +18 -24
  132. package/dist/blocks/calendar/index.js +39 -32
  133. package/dist/blocks/catalog/index.d.ts +12 -20
  134. package/dist/blocks/catalog/index.js +17 -21
  135. package/dist/blocks/channels/index.d.ts +9 -17
  136. package/dist/blocks/channels/index.js +11 -15
  137. package/dist/blocks/collections/index.d.ts +11 -17
  138. package/dist/blocks/collections/index.js +13 -16
  139. package/dist/blocks/comments/index.d.ts +16 -26
  140. package/dist/blocks/comments/index.js +21 -26
  141. package/dist/blocks/compliance/index.d.ts +9 -17
  142. package/dist/blocks/compliance/index.js +13 -17
  143. package/dist/blocks/connectors/index.d.ts +4 -8
  144. package/dist/blocks/connectors/index.js +13 -16
  145. package/dist/blocks/contacts/index.d.ts +10 -18
  146. package/dist/blocks/contacts/index.js +12 -16
  147. package/dist/blocks/content/index.d.ts +8 -16
  148. package/dist/blocks/content/index.js +13 -17
  149. package/dist/blocks/contracts/index.d.ts +11 -21
  150. package/dist/blocks/contracts/index.js +17 -22
  151. package/dist/blocks/courses/index.d.ts +11 -21
  152. package/dist/blocks/courses/index.js +17 -22
  153. package/dist/blocks/created-by/index.d.ts +3 -7
  154. package/dist/blocks/created-by/index.js +4 -5
  155. package/dist/blocks/custom-fields/index.d.ts +10 -16
  156. package/dist/blocks/custom-fields/index.js +13 -16
  157. package/dist/blocks/data-lifecycle/index.d.ts +10 -26
  158. package/dist/blocks/data-lifecycle/index.js +17 -23
  159. package/dist/blocks/deals/index.d.ts +12 -20
  160. package/dist/blocks/deals/index.js +18 -22
  161. package/dist/blocks/dispatch/index.d.ts +11 -23
  162. package/dist/blocks/dispatch/index.js +19 -24
  163. package/dist/blocks/documents/index.d.ts +4 -8
  164. package/dist/blocks/documents/index.js +9 -12
  165. package/dist/blocks/domains/index.d.ts +8 -14
  166. package/dist/blocks/domains/index.js +12 -15
  167. package/dist/blocks/donations/index.d.ts +13 -23
  168. package/dist/blocks/donations/index.js +21 -26
  169. package/dist/blocks/drive/index.d.ts +116 -20
  170. package/dist/blocks/drive/index.js +138 -26
  171. package/dist/blocks/employees/index.d.ts +13 -23
  172. package/dist/blocks/employees/index.js +19 -27
  173. package/dist/blocks/enrichment/index.d.ts +8 -16
  174. package/dist/blocks/enrichment/index.js +11 -15
  175. package/dist/blocks/enrollments/index.d.ts +9 -17
  176. package/dist/blocks/enrollments/index.js +13 -17
  177. package/dist/blocks/entitlements/index.d.ts +8 -14
  178. package/dist/blocks/entitlements/index.js +8 -11
  179. package/dist/blocks/expenses/index.d.ts +22 -19
  180. package/dist/blocks/expenses/index.js +25 -23
  181. package/dist/blocks/field-history/index.d.ts +6 -10
  182. package/dist/blocks/field-history/index.js +5 -7
  183. package/dist/blocks/flags/index.d.ts +49 -20
  184. package/dist/blocks/flags/index.js +65 -19
  185. package/dist/blocks/forecasts/index.d.ts +10 -16
  186. package/dist/blocks/forecasts/index.js +11 -14
  187. package/dist/blocks/forms/index.d.ts +11 -25
  188. package/dist/blocks/forms/index.js +17 -24
  189. package/dist/blocks/goals/index.d.ts +8 -12
  190. package/dist/blocks/goals/index.js +9 -11
  191. package/dist/blocks/guests/index.d.ts +9 -19
  192. package/dist/blocks/guests/index.js +14 -19
  193. package/dist/blocks/hiring/index.d.ts +10 -18
  194. package/dist/blocks/hiring/index.js +12 -15
  195. package/dist/blocks/identities/index.d.ts +7 -11
  196. package/dist/blocks/identities/index.js +7 -9
  197. package/dist/blocks/imports/index.d.ts +8 -18
  198. package/dist/blocks/imports/index.js +11 -16
  199. package/dist/blocks/inbox/index.d.ts +11 -21
  200. package/dist/blocks/inbox/index.js +26 -23
  201. package/dist/blocks/incidents/index.d.ts +9 -17
  202. package/dist/blocks/incidents/index.js +14 -18
  203. package/dist/blocks/index.d.ts +14 -20
  204. package/dist/blocks/index.js +17 -20
  205. package/dist/blocks/inventory/index.d.ts +11 -17
  206. package/dist/blocks/inventory/index.js +12 -15
  207. package/dist/blocks/invoices/index.d.ts +34 -21
  208. package/dist/blocks/invoices/index.js +31 -18
  209. package/dist/blocks/knowledge/index.d.ts +3 -5
  210. package/dist/blocks/knowledge/index.js +5 -6
  211. package/dist/blocks/lead-scoring/index.d.ts +10 -14
  212. package/dist/blocks/lead-scoring/index.js +11 -13
  213. package/dist/blocks/leases/index.d.ts +11 -21
  214. package/dist/blocks/leases/index.js +20 -25
  215. package/dist/blocks/leave/index.d.ts +50 -17
  216. package/dist/blocks/leave/index.js +35 -14
  217. package/dist/blocks/ledger/index.d.ts +9 -17
  218. package/dist/blocks/ledger/index.js +13 -17
  219. package/dist/blocks/mail-sync/index.d.ts +6 -12
  220. package/dist/blocks/mail-sync/index.js +26 -25
  221. package/dist/blocks/memberships/index.d.ts +5 -9
  222. package/dist/blocks/memberships/index.js +4 -5
  223. package/dist/blocks/memory/index.d.ts +4 -8
  224. package/dist/blocks/memory/index.js +12 -15
  225. package/dist/blocks/messaging/index.d.ts +14 -24
  226. package/dist/blocks/messaging/index.js +19 -24
  227. package/dist/blocks/metrics/index.d.ts +9 -17
  228. package/dist/blocks/metrics/index.js +14 -18
  229. package/dist/blocks/mfa/index.d.ts +5 -9
  230. package/dist/blocks/mfa/index.js +7 -9
  231. package/dist/blocks/moderation/index.d.ts +9 -17
  232. package/dist/blocks/moderation/index.js +13 -17
  233. package/dist/blocks/notifications/index.d.ts +18 -34
  234. package/dist/blocks/notifications/index.js +36 -84
  235. package/dist/blocks/numbering/index.d.ts +6 -12
  236. package/dist/blocks/numbering/index.js +8 -11
  237. package/dist/blocks/oauth-server/index.d.ts +7 -13
  238. package/dist/blocks/oauth-server/index.js +12 -15
  239. package/dist/blocks/onboarding/index.d.ts +7 -13
  240. package/dist/blocks/onboarding/index.js +8 -11
  241. package/dist/blocks/orders/index.d.ts +17 -29
  242. package/dist/blocks/orders/index.js +22 -28
  243. package/dist/blocks/organizations/index.d.ts +43 -40
  244. package/dist/blocks/organizations/index.js +21 -20
  245. package/dist/blocks/outbox/index.d.ts +4 -6
  246. package/dist/blocks/outbox/index.js +11 -13
  247. package/dist/blocks/passes/index.d.ts +12 -22
  248. package/dist/blocks/passes/index.js +20 -25
  249. package/dist/blocks/permissions/index.d.ts +74 -15
  250. package/dist/blocks/permissions/index.js +119 -18
  251. package/dist/blocks/pipelines/index.d.ts +12 -18
  252. package/dist/blocks/pipelines/index.js +12 -15
  253. package/dist/blocks/posts/index.d.ts +10 -18
  254. package/dist/blocks/posts/index.js +15 -19
  255. package/dist/blocks/profiles/index.d.ts +8 -12
  256. package/dist/blocks/profiles/index.js +9 -11
  257. package/dist/blocks/promotions/index.d.ts +11 -17
  258. package/dist/blocks/promotions/index.js +13 -16
  259. package/dist/blocks/push/index.d.ts +19 -17
  260. package/dist/blocks/push/index.js +33 -20
  261. package/dist/blocks/queue/index.d.ts +187 -39
  262. package/dist/blocks/queue/index.js +226 -60
  263. package/dist/blocks/quotes/index.d.ts +13 -21
  264. package/dist/blocks/quotes/index.js +14 -17
  265. package/dist/blocks/rank/index.d.ts +7 -13
  266. package/dist/blocks/rank/index.js +8 -10
  267. package/dist/blocks/reactions/index.d.ts +11 -19
  268. package/dist/blocks/reactions/index.js +13 -17
  269. package/dist/blocks/relations/index.d.ts +11 -21
  270. package/dist/blocks/relations/index.js +18 -23
  271. package/dist/blocks/reminders/index.d.ts +12 -22
  272. package/dist/blocks/reminders/index.js +21 -25
  273. package/dist/blocks/reviews/index.d.ts +9 -15
  274. package/dist/blocks/reviews/index.js +11 -14
  275. package/dist/blocks/saved-views/index.d.ts +11 -21
  276. package/dist/blocks/saved-views/index.js +16 -21
  277. package/dist/blocks/scores/index.d.ts +6 -12
  278. package/dist/blocks/scores/index.js +10 -13
  279. package/dist/blocks/search/index.d.ts +9 -19
  280. package/dist/blocks/search/index.js +15 -19
  281. package/dist/blocks/security-events/index.d.ts +10 -24
  282. package/dist/blocks/security-events/index.js +17 -23
  283. package/dist/blocks/segments/index.d.ts +10 -18
  284. package/dist/blocks/segments/index.js +11 -15
  285. package/dist/blocks/sequences/index.d.ts +9 -17
  286. package/dist/blocks/sequences/index.js +15 -19
  287. package/dist/blocks/service-accounts/index.d.ts +9 -15
  288. package/dist/blocks/service-accounts/index.js +11 -14
  289. package/dist/blocks/sessions/index.d.ts +4 -8
  290. package/dist/blocks/sessions/index.js +9 -11
  291. package/dist/blocks/settings/index.d.ts +8 -16
  292. package/dist/blocks/settings/index.js +14 -18
  293. package/dist/blocks/share-links/index.d.ts +9 -17
  294. package/dist/blocks/share-links/index.js +16 -20
  295. package/dist/blocks/shipments/index.d.ts +14 -24
  296. package/dist/blocks/shipments/index.js +25 -31
  297. package/dist/blocks/signatures/index.d.ts +10 -16
  298. package/dist/blocks/signatures/index.js +10 -13
  299. package/dist/blocks/signing-keys/index.d.ts +5 -9
  300. package/dist/blocks/signing-keys/index.js +8 -10
  301. package/dist/blocks/sla/index.d.ts +11 -19
  302. package/dist/blocks/sla/index.js +17 -21
  303. package/dist/blocks/sso/index.d.ts +7 -19
  304. package/dist/blocks/sso/index.js +14 -21
  305. package/dist/blocks/state-machine/index.d.ts +7 -13
  306. package/dist/blocks/state-machine/index.js +9 -12
  307. package/dist/blocks/subjects/index.d.ts +7 -11
  308. package/dist/blocks/subjects/index.js +12 -14
  309. package/dist/blocks/tags/index.d.ts +11 -21
  310. package/dist/blocks/tags/index.js +20 -25
  311. package/dist/blocks/tasks/index.d.ts +13 -27
  312. package/dist/blocks/tasks/index.js +22 -29
  313. package/dist/blocks/teams/index.d.ts +15 -15
  314. package/dist/blocks/teams/index.js +17 -19
  315. package/dist/blocks/templates/index.d.ts +12 -22
  316. package/dist/blocks/templates/index.js +16 -21
  317. package/dist/blocks/time-tracking/index.d.ts +31 -25
  318. package/dist/blocks/time-tracking/index.js +29 -29
  319. package/dist/blocks/timeline/index.d.ts +10 -14
  320. package/dist/blocks/timeline/index.js +11 -13
  321. package/dist/blocks/trash/index.d.ts +10 -18
  322. package/dist/blocks/trash/index.js +11 -14
  323. package/dist/blocks/undo/index.d.ts +4 -8
  324. package/dist/blocks/undo/index.js +6 -8
  325. package/dist/blocks/updated-at/index.d.ts +3 -7
  326. package/dist/blocks/updated-at/index.js +4 -5
  327. package/dist/blocks/usage/index.d.ts +6 -10
  328. package/dist/blocks/usage/index.js +10 -13
  329. package/dist/blocks/vercel-marketplace/index.d.ts +9 -17
  330. package/dist/blocks/vercel-marketplace/index.js +17 -21
  331. package/dist/blocks/versions/index.d.ts +10 -20
  332. package/dist/blocks/versions/index.js +17 -22
  333. package/dist/blocks/waitlist/index.d.ts +10 -16
  334. package/dist/blocks/waitlist/index.js +11 -14
  335. package/dist/blocks/webhooks/index.d.ts +16 -34
  336. package/dist/blocks/webhooks/index.js +33 -44
  337. package/dist/blocks/workflow-editor/index.d.ts +13 -21
  338. package/dist/blocks/workflow-editor/index.js +21 -27
  339. package/dist/blocks/workflows/index.d.ts +8 -14
  340. package/dist/blocks/workflows/index.js +14 -18
  341. package/dist/bookings-DG443336.d.ts +285 -0
  342. package/dist/bucket-Clq5xINQ.d.ts +693 -0
  343. package/dist/build-Ckxct2EX.js +2065 -0
  344. package/dist/build-D1-V9dd8.js +732 -0
  345. package/dist/carrier-D2b_028L.d.ts +165 -0
  346. package/dist/casing-DQzG9ANZ.js +15 -0
  347. package/dist/channel-B_kufDZy.d.ts +101 -0
  348. package/dist/channels-BxeTTtCY.js +113 -0
  349. package/dist/chat-sdk/index.d.ts +174 -41
  350. package/dist/chat-sdk/index.js +425 -83
  351. package/dist/claims-DRmafYVK.js +90 -0
  352. package/dist/claims-DouHL7ZL.js +62 -0
  353. package/dist/cli/_format-Ba0DoWjl.js +99 -0
  354. package/dist/cli/add-ChoHyBhz.js +1222 -0
  355. package/dist/cli/add-DlYL-1mF.js +1 -0
  356. package/dist/cli/add-fzRPyIED.js +98 -0
  357. package/dist/cli/agent-59XWXsRi.js +184 -0
  358. package/dist/cli/app-table-files-C0OtdUVu.js +343 -0
  359. package/dist/cli/arazzo-1.0-D3OaSeZw.js +531 -0
  360. package/dist/cli/arazzo-1.1-DaT2KAkP.js +704 -0
  361. package/dist/cli/args-_ZVgRBkx.js +26 -0
  362. package/dist/cli/asyncapi-3.0.0-Ca-UwtUW.js +5592 -0
  363. package/dist/cli/asyncapi-3.1.0-DUxf5zNu.js +5832 -0
  364. package/dist/cli/backfill-Dq2XMXf9.js +292 -0
  365. package/dist/cli/bin.js +5 -5
  366. package/dist/cli/blocks-CCzp0eAH.js +155 -0
  367. package/dist/cli/blocks-DVhJOzFj.js +1 -0
  368. package/dist/cli/cache-CoC-1i1O.js +643 -0
  369. package/dist/cli/codemod-block-renames-Dt3X1Wvg.js +238 -0
  370. package/dist/cli/codemod-pyf6HmS9.js +2883 -0
  371. package/dist/cli/command-BpZ4AuhR.js +1021 -0
  372. package/dist/cli/compare-yl4sSwVn.js +8 -0
  373. package/dist/cli/completion-B08Q0xB3.js +29 -0
  374. package/dist/cli/completion-CwL7e93t.js +210 -0
  375. package/dist/cli/completion-DHTT6rjI.js +1 -0
  376. package/dist/cli/config-D-Upz3jV.js +46 -0
  377. package/dist/cli/config-D0m2rQqk.js +1 -0
  378. package/dist/cli/config-Dyl3iX3u.js +2029 -0
  379. package/dist/cli/config-edit-C6sQ1MqT.js +619 -0
  380. package/dist/cli/config-group-D4JWh4kG.js +388 -0
  381. package/dist/cli/content-mapper-ChSVT9Tq.js +181 -0
  382. package/dist/cli/db-B8zfxjl2.js +77 -0
  383. package/dist/cli/db-dFzhcozO.js +246 -0
  384. package/dist/cli/detect-BcUDaO8I.js +83 -0
  385. package/dist/cli/dist-CYnD1kyT.js +128 -0
  386. package/dist/cli/dist-MKwjiW2w.js +1114 -0
  387. package/dist/cli/doctor-BKZsztFV.js +4647 -0
  388. package/dist/cli/env-BAJn6wCA.js +142 -0
  389. package/dist/cli/env-BCuUsWOh.js +1109 -0
  390. package/dist/cli/env-D70ihdbB.js +1 -0
  391. package/dist/cli/env-UN6PJFX6.js +1 -0
  392. package/dist/cli/errors-DcJ_PayO.js +97 -0
  393. package/dist/cli/exec-CXBufciC.js +461 -0
  394. package/dist/cli/fastest-levenshtein-B_QF6At5.js +119 -0
  395. package/dist/cli/files-DQayErI8.js +999 -0
  396. package/dist/cli/fresh-import-CdO2oQaQ.js +39 -0
  397. package/dist/cli/gen-BN_eh6rE.js +390 -0
  398. package/dist/cli/guards-DxwRG0Uv.js +7 -0
  399. package/dist/cli/in-stack-diff-huI7fGMX.js +185 -0
  400. package/dist/cli/index.d.ts +1 -53
  401. package/dist/cli/index.js +10 -11
  402. package/dist/cli/init-CaDDt8F6.js +556 -0
  403. package/dist/cli/io-CQzy8PEZ.js +36 -0
  404. package/dist/cli/json5-DhsZB2va.js +784 -0
  405. package/dist/cli/jsonc-DU9Clnrz.js +1 -0
  406. package/dist/cli/jsonc-u_UiXFxs.js +43 -0
  407. package/dist/cli/keys-CxajkV_7.js +105 -0
  408. package/dist/cli/legacy-prefix-D8Jfku6I.js +153 -0
  409. package/dist/cli/live-KU41LMGE.js +339 -0
  410. package/dist/cli/mcp-C_m-TpLJ.js +240 -0
  411. package/dist/cli/metadata-Bq4ra7zo.js +149 -0
  412. package/dist/cli/migrate-DHG2Qz_K.js +45 -0
  413. package/dist/cli/migration-safety-STVbiKhz.js +925 -0
  414. package/dist/cli/migrations-O1QZoMiH.js +116 -0
  415. package/dist/cli/module-migration-DB9ntWM-.js +118 -0
  416. package/dist/cli/moved-BAFPdJz_.js +253 -0
  417. package/dist/cli/ohash-imLR_J5Y.js +276 -0
  418. package/dist/cli/openapi-3.0-BJiTNq_x.js +927 -0
  419. package/dist/cli/openapi-3.1-BcWCoii2.js +869 -0
  420. package/dist/cli/openapi-3.2-MXPkeoTk.js +1030 -0
  421. package/dist/cli/orphans-CPcR85QN.js +27 -0
  422. package/dist/cli/parse-BueItuNJ.js +181 -0
  423. package/dist/cli/powersync-CN3QPF2K.js +375 -0
  424. package/dist/cli/powersync-DfeGl5N1.js +1 -0
  425. package/dist/cli/preset-BQnjDCSR.js +100 -0
  426. package/dist/cli/print-DG7TRCi8.js +66 -0
  427. package/dist/cli/prompts-D9b6uf21.js +1133 -0
  428. package/dist/cli/providers-DpfoF3VC.js +298 -0
  429. package/dist/cli/prune-workflows-DcNJUS1m.js +153 -0
  430. package/dist/cli/redact--zOGdWzo.js +37 -0
  431. package/dist/cli/remove-BpfYqP45.js +237 -0
  432. package/dist/cli/render-Q7jnLn_C.js +2213 -0
  433. package/dist/cli/rolldown-runtime-DegdyBIC.js +25 -0
  434. package/dist/cli/run-9NfabanB.js +703 -0
  435. package/dist/cli/run-D6K-qQIX.js +1450 -0
  436. package/dist/cli/run-dY9uOC3W.js +62 -0
  437. package/dist/cli/seed-B4H0Lco9.js +187 -0
  438. package/dist/cli/seed-BIB6-WPa.js +1 -0
  439. package/dist/cli/shared-PrvYREVy.js +150 -0
  440. package/dist/cli/shell-C1U618XA.js +9 -0
  441. package/dist/cli/skills-jZThjL3B.js +120 -0
  442. package/dist/cli/snapshot-UfJsqfys.js +728 -0
  443. package/dist/cli/source-F3YTVvFo.js +317 -0
  444. package/dist/cli/source-args-DJMrW_jW.js +58 -0
  445. package/dist/cli/spec-DsLQuJKp.js +7449 -0
  446. package/dist/cli/spec-HQOBVbEO.js +1 -0
  447. package/dist/cli/sql-layout-CZ66pY8j.js +260 -0
  448. package/dist/cli/stack-147NqctC.js +134 -0
  449. package/dist/cli/stack-env-BQhbUFa7.js +92 -0
  450. package/dist/cli/stack-status-Mxgqb3I4.js +45 -0
  451. package/dist/cli/stacks-C5YL6Un9.js +230 -0
  452. package/dist/cli/style-B5-nByxb.js +34 -0
  453. package/dist/cli/supabase-toml-B6-eEV5p.js +1155 -0
  454. package/dist/cli/sync-B12wbtFd.js +318 -0
  455. package/dist/cli/table-D9FbJS8h.js +88 -0
  456. package/dist/cli/toml-VX0BsvYq.js +422 -0
  457. package/dist/cli/topics-Cdg0V7Tt.js +29 -0
  458. package/dist/cli/trace-D3TNqWBg.js +6 -0
  459. package/dist/cli/upgrade-AgUXFDo6.js +270 -0
  460. package/dist/cli/upgrade-C20z49De.js +40 -0
  461. package/dist/cli/validate-C_WTnX1U.js +7426 -0
  462. package/dist/cli/version-DEUWW8cv.js +3 -0
  463. package/dist/cli/yaml-JsusTbcC.js +2250 -0
  464. package/dist/client/index.d.ts +7 -7
  465. package/dist/client/index.js +9 -12
  466. package/dist/client/native/index.d.ts +7 -23
  467. package/dist/client/native/index.js +15 -22
  468. package/dist/client-BLor58Je.js +290 -0
  469. package/dist/clone-H_gCsL29.js +32 -0
  470. package/dist/cloud-event-CLvsaPqH.js +62 -0
  471. package/dist/cloud-event-bcaMqEbN.d.ts +62 -0
  472. package/dist/codecs-B1VO2BGL.d.ts +220 -0
  473. package/dist/codecs-B9v5Y5HH.js +357 -0
  474. package/dist/commerce/index.d.ts +5 -13
  475. package/dist/commerce/index.js +13 -16
  476. package/dist/compiler-CWishtY2.d.ts +12 -0
  477. package/dist/compose-BRBlPSEY.js +52 -0
  478. package/dist/composite-BZMkWNOQ.js +125 -0
  479. package/dist/composite-ClLWZIwX.d.ts +79 -0
  480. package/dist/config/index.d.ts +6 -6
  481. package/dist/config/index.js +7 -7
  482. package/dist/config-BhExAhNK.js +1102 -0
  483. package/dist/config-MDRA2sre.js +1672 -0
  484. package/dist/connectors-BImAu75R.d.ts +145 -0
  485. package/dist/context-DSevnLrT.js +40 -0
  486. package/dist/context-DcxfrCml.d.ts +4267 -0
  487. package/dist/controller-BJmh7gFm.js +78 -0
  488. package/dist/controller-D_UJBaEU.d.ts +50 -0
  489. package/dist/controller-y1kSMuCU.js +72 -0
  490. package/dist/conversion-7U1WeLxK.d.ts +84 -0
  491. package/dist/conversion-Bj9j3KnG.js +76 -0
  492. package/dist/cookie-DDkqvqe4.d.ts +3 -0
  493. package/dist/cookie-DJI6xXJ9.js +4 -0
  494. package/dist/cors-9SDsndtb.d.ts +13 -0
  495. package/dist/cors-DrDFLMNn.js +23 -0
  496. package/dist/create/index.d.ts +4 -28
  497. package/dist/create/index.js +9 -15
  498. package/dist/create/lite/index.d.ts +5 -25
  499. package/dist/create/lite/index.js +14 -24
  500. package/dist/create/oauth/index.d.ts +1 -1
  501. package/dist/create/oauth/index.js +1 -2
  502. package/dist/create/supabase/index.d.ts +2 -4
  503. package/dist/create/supabase/index.js +3 -6
  504. package/dist/create-blocks-D7q1boXV.js +367 -0
  505. package/dist/credentials/index.d.ts +6 -10
  506. package/dist/credentials/index.js +11 -12
  507. package/dist/cron-BD8VrQQl.js +147 -0
  508. package/dist/cron-route-DSITg1yC.js +23 -0
  509. package/dist/csv-Bwn9insJ.js +88 -0
  510. package/dist/csv-Dd1iKsk-.d.ts +26 -0
  511. package/dist/data-engine-B-D6bdyx.d.ts +269 -0
  512. package/dist/data-engine-BbqQwso_.js +174 -0
  513. package/dist/data-hooks-BToeAcQ_.js +277 -0
  514. package/dist/db-exception-Dv18UZ-I.js +30 -0
  515. package/dist/deal-forecast-CN_BEy9s.d.ts +21 -0
  516. package/dist/deal-forecast-DsVFoMkJ.js +38 -0
  517. package/dist/define-3RbqoF1S.d.ts +1242 -0
  518. package/dist/define-B6D55cO0.js +2073 -0
  519. package/dist/define-block-22Jv4U_-.js +63 -0
  520. package/dist/define-block-B_i9VPcc.d.ts +1669 -0
  521. package/dist/delegation-BRHHXERz.js +152 -0
  522. package/dist/delivery-CWcbh87x.d.ts +69 -0
  523. package/dist/delivery-SmPHu2_H.js +28 -0
  524. package/dist/delivery-events-0mAEuscm.js +52 -0
  525. package/dist/documents-6ov2gWh3.d.ts +150 -0
  526. package/dist/edge/index.d.ts +17 -23
  527. package/dist/edge/index.js +18 -22
  528. package/dist/elysia/index.d.ts +2 -6
  529. package/dist/elysia/index.js +4 -6
  530. package/dist/email-BRm6wMWQ.d.ts +40 -0
  531. package/dist/embeddings--v4BJdUL.js +127 -0
  532. package/dist/embeddings-K0lH--nt.d.ts +76 -0
  533. package/dist/ended-CCoE7XXY.d.ts +22 -0
  534. package/dist/entitlements-XwpuBbKN.d.ts +52 -0
  535. package/dist/entitlements-sLoj3M6Y.js +44 -0
  536. package/dist/entity-naming-BES3pkQI.js +130 -0
  537. package/dist/entity-schema-DEIz0I8i.js +38 -0
  538. package/dist/env/index.d.ts +1 -1
  539. package/dist/env/index.js +1 -2
  540. package/dist/envelope-DAtaFJue.js +89 -0
  541. package/dist/errors-B7tCfCvX.js +327 -0
  542. package/dist/errors-BdjHv5SV.js +43 -0
  543. package/dist/errors-D3-4c-XF.js +102 -0
  544. package/dist/escape-like-CK6L7gkj.d.ts +26 -0
  545. package/dist/escape-like-gxNXs145.js +6 -0
  546. package/dist/eve/index.d.ts +247 -16
  547. package/dist/eve/index.js +334 -26
  548. package/dist/eve-Cf-QRGij.d.ts +213 -0
  549. package/dist/event-calendar-DUtFyRrv.d.ts +63 -0
  550. package/dist/event-map-DxfsFgQT.js +18 -0
  551. package/dist/events/index.d.ts +3 -3
  552. package/dist/events/index.js +7 -8
  553. package/dist/events-BRKIxVQD.js +25 -0
  554. package/dist/events-CfDdOwqg.d.ts +850 -0
  555. package/dist/events-Da482tiF.js +81 -0
  556. package/dist/executor-BDMqPbVU.js +482 -0
  557. package/dist/executor-C0_TT717.js +840 -0
  558. package/dist/executor-CAhykadW.d.ts +168 -0
  559. package/dist/executor-CbDX34I9.d.ts +99 -0
  560. package/dist/executor-Dc4Pl44u.js +207 -0
  561. package/dist/executor-ynEwaUZy.d.ts +35 -0
  562. package/dist/expo/index.d.ts +5 -9
  563. package/dist/expo/index.js +10 -11
  564. package/dist/extension-DQ9-oOVC.js +58 -0
  565. package/dist/extension-LgaDPMJs.js +120 -0
  566. package/dist/extension-WdHd5uqI.js +102 -0
  567. package/dist/extension-rdpYvpyN.js +52 -0
  568. package/dist/extension-shared-DJb_PfD4.js +59 -0
  569. package/dist/extra-Dz9n5y1s.js +9 -0
  570. package/dist/field-errors-tQr-anYL.d.ts +208 -0
  571. package/dist/field-formats-Cap-V7UP.js +101 -0
  572. package/dist/field-formats-DVukMbRa.d.ts +36 -0
  573. package/dist/fields-AKKMirg_.d.ts +76 -0
  574. package/dist/fields-BBcdKD-S.js +107 -0
  575. package/dist/filter-evaluate-Bhq99aEN.d.ts +35 -0
  576. package/dist/filter-evaluate-D_LLfdtE.js +216 -0
  577. package/dist/filter-query-B7A4l2xn.d.ts +131 -0
  578. package/dist/filter-query-Ds7Z6lgZ.js +565 -0
  579. package/dist/flags-B5B4mkZV.d.ts +315 -0
  580. package/dist/flags-D0npSE-5.js +361 -0
  581. package/dist/flags-sdk/index.d.ts +217 -28
  582. package/dist/flags-sdk/index.js +255 -35
  583. package/dist/form-definition-8cCCt5zj.js +362 -0
  584. package/dist/form-definition-BN8shngm.d.ts +117 -0
  585. package/dist/format-BT0Z3V54.d.ts +77 -0
  586. package/dist/framework-B1h-uquj.js +57 -0
  587. package/dist/framework-CyDn_SXR.d.ts +45 -0
  588. package/dist/function-contract-Bf6llTkE.js +7 -0
  589. package/dist/function-contract-DgDBYbXu.d.ts +25 -0
  590. package/dist/gateway-Cg_MgGen.d.ts +120 -0
  591. package/dist/gateway-options-DQGQzdkD.js +26 -0
  592. package/dist/gateway-options-Mut8jih_.d.ts +27 -0
  593. package/dist/guards-CsRa6v57.js +11 -0
  594. package/dist/guest-actions-CEwttioE.js +8 -0
  595. package/dist/guest-actions-DfHHp98H.d.ts +3 -0
  596. package/dist/h3/index.d.ts +2 -6
  597. package/dist/h3/index.js +4 -6
  598. package/dist/h3/v1/index.d.ts +3 -5
  599. package/dist/h3/v1/index.js +4 -5
  600. package/dist/history-6KiVNWdH.js +269 -0
  601. package/dist/hmac-DNcfpmI9.js +22 -0
  602. package/dist/hono/index.d.ts +14 -19
  603. package/dist/hono/index.js +14 -16
  604. package/dist/http-BDC1IvBX.js +27 -0
  605. package/dist/http-BRUI3qim.js +140 -0
  606. package/dist/http-D4lH1xqY.js +39 -0
  607. package/dist/image-url-bsGeybeg.js +83 -0
  608. package/dist/impersonation-BOCJcsmS.d.ts +26 -0
  609. package/dist/impersonation-D-quM36V.js +61 -0
  610. package/dist/inbox-BmSA9K01.d.ts +326 -0
  611. package/dist/index-8w4OB5En.d.ts +102 -0
  612. package/dist/index-B2871MHr.d.ts +234 -0
  613. package/dist/index-B5_J-MaK.d.ts +152 -0
  614. package/dist/index-BWR29Vvw.d.ts +76 -0
  615. package/dist/index-CRrBZtKm.d.ts +326 -0
  616. package/dist/index-CTpEQvIv.d.ts +291 -0
  617. package/dist/index-D2BGCjIz.d.ts +570 -0
  618. package/dist/index-D66_dYVi.d.ts +667 -0
  619. package/dist/index-Dj4VKpYZ.d.ts +49 -0
  620. package/dist/index-DzBFdI9I.d.ts +145 -0
  621. package/dist/index-lazpPVr0.d.ts +402 -0
  622. package/dist/index-xCpjvDVm.d.ts +637 -0
  623. package/dist/index.d.ts +13 -41
  624. package/dist/index.js +29 -34
  625. package/dist/instance-property-BlH7QSDl.js +6 -0
  626. package/dist/instances-D31jrmKh.js +16636 -0
  627. package/dist/invalidate-DAB9CaPm.d.ts +19 -0
  628. package/dist/iso4217-oKsif_hW.js +175 -0
  629. package/dist/json-O5vFw243.js +21 -0
  630. package/dist/json-schema-D9eVL_xi.js +884 -0
  631. package/dist/jwks-cache-IZaiICAV.js +48 -0
  632. package/dist/jws-B8p0ppgh.js +204 -0
  633. package/dist/jws-CxgTsbgG.d.ts +64 -0
  634. package/dist/kit-CJKo0soh.d.ts +92 -0
  635. package/dist/kit-CVZDd1X9.js +132 -0
  636. package/dist/knowledge-BUwbpS8I.d.ts +215 -0
  637. package/dist/knowledge-DdZzUTQ-.js +299 -0
  638. package/dist/lint/index.d.ts +1 -5
  639. package/dist/lint/index.js +8 -10
  640. package/dist/list/index.d.ts +3 -3
  641. package/dist/list/index.js +3 -3
  642. package/dist/list-query-CZ-K5aHX.d.ts +220 -0
  643. package/dist/list-query-D-tgs1eY.js +558 -0
  644. package/dist/live-BVi3q4bX.js +277 -0
  645. package/dist/logger-0LfhvwE4.d.ts +16 -0
  646. package/dist/logger-BkF8ukXV.js +20 -0
  647. package/dist/lookup-upE-e1zw.js +17 -0
  648. package/dist/management-DtX4ic1F.d.ts +55 -0
  649. package/dist/mapper/bin.js +13 -17
  650. package/dist/mcp/index.d.ts +8 -18
  651. package/dist/mcp/index.js +24 -29
  652. package/dist/mcp/sdk/index.d.ts +7 -11
  653. package/dist/mcp/sdk/index.js +12 -14
  654. package/dist/message-Cc4bkdNw.d.ts +97 -0
  655. package/dist/messages-CRk1g6oe.js +512 -0
  656. package/dist/messaging-DMhtGxVv.d.ts +295 -0
  657. package/dist/methods-BjfDv4Gy.js +9 -0
  658. package/dist/metric-definition-2KQYeUZ1.d.ts +67 -0
  659. package/dist/metric-definition-D4H6IQT7.js +116 -0
  660. package/dist/mfa-CM5r904M.d.ts +34 -0
  661. package/dist/model-Lxa_mOzB.d.ts +338 -0
  662. package/dist/model-messages-BcrkjsPE.js +205 -0
  663. package/dist/model-messages-CGSUU450.d.ts +32 -0
  664. package/dist/money-BgpAd7d3.d.ts +89 -0
  665. package/dist/money-DH--bbYr.js +196 -0
  666. package/dist/money-codec-SKPm8FPw.js +40 -0
  667. package/dist/my-work-kinds-DNPq3ccL.js +10 -0
  668. package/dist/nestjs/index.d.ts +3 -5
  669. package/dist/nestjs/index.js +5 -6
  670. package/dist/next/client/index.d.ts +1 -5
  671. package/dist/next/client/index.js +2 -4
  672. package/dist/next/image/index.d.ts +1 -3
  673. package/dist/next/image/index.js +2 -3
  674. package/dist/next/index.d.ts +149 -92
  675. package/dist/next/index.js +167 -114
  676. package/dist/node/index.d.ts +3 -3
  677. package/dist/node/index.js +6 -7
  678. package/dist/node-headers-C3FExlg9.js +54 -0
  679. package/dist/node-headers-TnS4T7V_.d.ts +25 -0
  680. package/dist/nuxt/index.d.ts +0 -2
  681. package/dist/nuxt/index.js +1 -2
  682. package/dist/operations-BNFbWv1t.js +28 -0
  683. package/dist/operations-D51ONRvR.d.ts +4 -0
  684. package/dist/optional-peer-5SOYr3lL.js +31 -0
  685. package/dist/options--rohtkkC.js +4 -0
  686. package/dist/options-1iHDmlZ5.js +8 -0
  687. package/dist/options-2QJXZPPS.js +4 -0
  688. package/dist/options-B-JqrC61.d.ts +8 -0
  689. package/dist/options-B3xH2JvJ.js +8 -0
  690. package/dist/options-B4sTqDrt.js +4 -0
  691. package/dist/options-B56njigZ.js +19 -0
  692. package/dist/options-B5A3UmKY.d.ts +17 -0
  693. package/dist/options-B6m9gYRH.d.ts +11 -0
  694. package/dist/options-B7Pl708M.js +8 -0
  695. package/dist/options-B7YrdiUc.js +11 -0
  696. package/dist/options-B8c2_hIB.js +9 -0
  697. package/dist/options-B9w_Y08G.d.ts +6 -0
  698. package/dist/options-BDF60ouf.js +4 -0
  699. package/dist/options-BDMPjyrI.js +4 -0
  700. package/dist/options-BHdHuY5r.js +14 -0
  701. package/dist/options-BLMeCbtT.js +31 -0
  702. package/dist/options-BLQePOPy.d.ts +8 -0
  703. package/dist/options-BLn1PFyu.js +4 -0
  704. package/dist/options-BMO-FnOT.js +7 -0
  705. package/dist/options-BNRvoEkj.js +4 -0
  706. package/dist/options-BPQOiVx2.js +7 -0
  707. package/dist/options-BSTJmfX4.js +10 -0
  708. package/dist/options-BTRH26MJ.js +9 -0
  709. package/dist/options-BTaQszYn.js +9 -0
  710. package/dist/options-BYo7hMHK.js +10 -0
  711. package/dist/options-B_bxCZYM.js +7 -0
  712. package/dist/options-BaBaVWS-.js +10 -0
  713. package/dist/options-BamaRO-q.d.ts +12 -0
  714. package/dist/options-BcBdiPSZ.js +7 -0
  715. package/dist/options-BfY4pyQE.js +23 -0
  716. package/dist/options-BgCS5ODi.js +9 -0
  717. package/dist/options-Bi96Lzuf.js +9 -0
  718. package/dist/options-BjEsSoFp.js +17 -0
  719. package/dist/options-Bkx8vwip.js +4 -0
  720. package/dist/options-BmFSI07A.js +4 -0
  721. package/dist/options-BmwDdKwE.js +7 -0
  722. package/dist/options-Bn3NjXfn.js +7 -0
  723. package/dist/options-BqK4xV67.js +13 -0
  724. package/dist/options-Bs2dC-at.js +11 -0
  725. package/dist/options-BvttpM1M.js +4 -0
  726. package/dist/options-Bwrwb8do.d.ts +10 -0
  727. package/dist/options-BxdqA2Ex.js +19 -0
  728. package/dist/options-BzxR82Tu.js +9 -0
  729. package/dist/options-C-NFS6e3.js +13 -0
  730. package/dist/options-C13-dVMH.js +7 -0
  731. package/dist/options-C1RIyAe1.js +7 -0
  732. package/dist/options-C1kZ3qLd.js +8 -0
  733. package/dist/options-C2RjdunU.js +27 -0
  734. package/dist/options-C4kpi6HE.js +8 -0
  735. package/dist/options-C5MfwOAO.js +8 -0
  736. package/dist/options-C5fKQ3EJ.d.ts +10 -0
  737. package/dist/options-CJR59q8s.js +17 -0
  738. package/dist/options-CJVYQue3.d.ts +10 -0
  739. package/dist/options-CLy7CcMn.js +8 -0
  740. package/dist/options-COfEYic3.js +8 -0
  741. package/dist/options-CRwTY_q2.d.ts +58 -0
  742. package/dist/options-CcW7h8mv.js +9 -0
  743. package/dist/options-Ceu2j1vv.js +7 -0
  744. package/dist/options-CgBKgmI8.js +7 -0
  745. package/dist/options-CgMiQGOF.js +9 -0
  746. package/dist/options-CptvcSmF.js +11 -0
  747. package/dist/options-CsLUAt04.js +8 -0
  748. package/dist/options-CtyjhSGk.js +15 -0
  749. package/dist/options-CuPWezcV.js +7 -0
  750. package/dist/options-CyDOOWlk.js +7 -0
  751. package/dist/options-CyYZvdSy.js +10 -0
  752. package/dist/options-CzIPn0fF.js +4 -0
  753. package/dist/options-CzWjw2HY.js +10 -0
  754. package/dist/options-CztbWdz9.js +4 -0
  755. package/dist/options-D4LuPM8a.js +4 -0
  756. package/dist/options-D4dxMGHF.js +7 -0
  757. package/dist/options-D5a9CHgP.js +7 -0
  758. package/dist/options-D6tpMRvp.d.ts +13 -0
  759. package/dist/options-D848Os4l.js +10 -0
  760. package/dist/options-DCZPW5gR.d.ts +15 -0
  761. package/dist/options-DFSHZFLN.js +4 -0
  762. package/dist/options-DFemc2im.js +9 -0
  763. package/dist/options-DFgHHwzD.js +12 -0
  764. package/dist/options-DNZ9r_Vo.d.ts +8 -0
  765. package/dist/options-DP7NwQPZ.js +4 -0
  766. package/dist/options-DPQaafyc.js +7 -0
  767. package/dist/options-DQkhhBLy.js +4 -0
  768. package/dist/options-DTTz33na.js +9 -0
  769. package/dist/options-DToWdVqW.js +4 -0
  770. package/dist/options-DUNUGuhM.js +4 -0
  771. package/dist/options-DWgpi5ns.js +7 -0
  772. package/dist/options-DeamnVOY.d.ts +12 -0
  773. package/dist/options-Dg7eK-_J.d.ts +8 -0
  774. package/dist/options-DiIlMZpc.js +8 -0
  775. package/dist/options-DjFbIRgV.js +16 -0
  776. package/dist/options-DjtCYRWb.js +4 -0
  777. package/dist/options-Dk6D88Zx.d.ts +6 -0
  778. package/dist/options-DpwRG4tO.js +8 -0
  779. package/dist/options-DvgKdZ2K.js +9 -0
  780. package/dist/options-DwIoRvic.js +4 -0
  781. package/dist/options-GwwLsKf5.js +8 -0
  782. package/dist/options-I1ZHfDP0.d.ts +58 -0
  783. package/dist/options-Itq7QYoW.js +20 -0
  784. package/dist/options-JnPEVbBJ.js +17 -0
  785. package/dist/options-Jwux4JDX.js +7 -0
  786. package/dist/options-Lg76d-cV.js +7 -0
  787. package/dist/options-Lh6uxepF.d.ts +24 -0
  788. package/dist/options-Oki2W_c3.js +4 -0
  789. package/dist/options-PM7IaIFP.js +10 -0
  790. package/dist/options-PTLBl6QT.js +7 -0
  791. package/dist/options-PheFo4JY.js +10 -0
  792. package/dist/options-SlC_jZ7y.js +4 -0
  793. package/dist/options-Sq4bYbf5.js +13 -0
  794. package/dist/options-XiD_Y3oK.js +14 -0
  795. package/dist/options-Z-bd_H1E.js +88 -0
  796. package/dist/options-ax_ssX_m.js +4 -0
  797. package/dist/options-bNB8_nlW.js +23 -0
  798. package/dist/options-eIEk0vqV.js +4 -0
  799. package/dist/options-eLIedotm.js +7 -0
  800. package/dist/options-jg0FMHA5.js +4 -0
  801. package/dist/options-mypVYaqR.js +9 -0
  802. package/dist/options-ompJjxkV.js +4 -0
  803. package/dist/options-pbc4H8_A.js +7 -0
  804. package/dist/options-uUGi0Phf.d.ts +14 -0
  805. package/dist/options-yRwYr4up.js +4 -0
  806. package/dist/options-z2Zhi97E.js +9 -0
  807. package/dist/options-zYV6M0vr.js +8 -0
  808. package/dist/orpc/index.d.ts +13 -19
  809. package/dist/orpc/index.js +20 -22
  810. package/dist/otel/index.d.ts +4 -6
  811. package/dist/otel/index.js +8 -10
  812. package/dist/outbox-C44Aa94K.d.ts +197 -0
  813. package/dist/payments-B4JchZuJ.js +15 -0
  814. package/dist/payments-BBGSGRQ7.d.ts +112 -0
  815. package/dist/permissions-B9aZZ9LR.js +43 -0
  816. package/dist/permissions-controller-B4uI5IPH.js +33 -0
  817. package/dist/pg-error-D92B6jlF.js +25 -0
  818. package/dist/plugin-Ca2qBiFZ.js +47 -0
  819. package/dist/pool-Bji4lnQM.d.ts +121 -0
  820. package/dist/pool-errors-JrZie6u3.js +26 -0
  821. package/dist/ports-C-hdygkZ.js +150 -0
  822. package/dist/ports-zFqRNXVJ.d.ts +87 -0
  823. package/dist/postgres/index.d.ts +5 -11
  824. package/dist/postgres/index.js +7 -9
  825. package/dist/postgrest-2WjRrtmX.d.ts +51 -0
  826. package/dist/postgrest-executor-lf8Mt4J0.js +1064 -0
  827. package/dist/powersync/index.d.ts +203 -21
  828. package/dist/powersync/index.js +369 -22
  829. package/dist/preset/index.d.ts +3 -3
  830. package/dist/preset/index.js +3 -3
  831. package/dist/preset-om2rbdYw.js +1038 -0
  832. package/dist/problem-C0SVHhd3.js +161 -0
  833. package/dist/problem-NGBjN-TO.d.ts +77 -0
  834. package/dist/project-oNHntJ6T.js +1749 -0
  835. package/dist/provider-B6qpleR9.js +56 -0
  836. package/dist/provider-CH8McX3b.d.ts +142 -0
  837. package/dist/providers-C9sBIBYE.js +62 -0
  838. package/dist/push-token-CO28k46S.js +15 -0
  839. package/dist/push-token-a3Ev1U3L.d.ts +22 -0
  840. package/dist/queries-BLrxg_GL.js +238 -0
  841. package/dist/query/index.d.ts +3 -3
  842. package/dist/query/index.js +11 -15
  843. package/dist/range-BN3kpJAE.d.ts +6 -0
  844. package/dist/range-Nrh_qtb_.js +6 -0
  845. package/dist/rank-keys-CEBzd9Xa.js +59 -0
  846. package/dist/rank-result-B_xLQCBV.d.ts +12 -0
  847. package/dist/rank-result-DzaTKKhH.js +17 -0
  848. package/dist/rate-limit-C89Yzwd9.d.ts +48 -0
  849. package/dist/rate-limit-CRhlLFhP.js +380 -0
  850. package/dist/rate-limit-DXJbLVg0.js +48 -0
  851. package/dist/ratelimit-headers-CpB-cDD6.js +61 -0
  852. package/dist/react/index.d.ts +11 -11
  853. package/dist/react/index.js +6 -6
  854. package/dist/react/native/index.d.ts +3 -5
  855. package/dist/react/native/index.js +5 -5
  856. package/dist/react/server.d.ts +13 -15
  857. package/dist/react/server.js +9 -10
  858. package/dist/react/session.d.ts +4 -6
  859. package/dist/react/session.js +2 -3
  860. package/dist/react-C40oomj7.js +1006 -0
  861. package/dist/react-CqOVutZj.js +80 -0
  862. package/dist/react-router/index.d.ts +8 -12
  863. package/dist/react-router/index.js +9 -11
  864. package/dist/read-set-DEDoIHMM.js +198 -0
  865. package/dist/realtime/index.d.ts +7 -7
  866. package/dist/realtime/index.js +6 -7
  867. package/dist/realtime-status-CocmAOPv.js +10 -0
  868. package/dist/realtime-status-D3oUx3o4.d.ts +6 -0
  869. package/dist/record-bindings-jTZw-GVe.js +25 -0
  870. package/dist/record-form-DCIui2Ol.d.ts +80 -0
  871. package/dist/record-type-oQxekQTX.js +219 -0
  872. package/dist/recordings-Dlpq8jUG.d.ts +117 -0
  873. package/dist/records/index.d.ts +10 -14
  874. package/dist/records/index.js +13 -16
  875. package/dist/refresh-B8t_KE3s.js +142 -0
  876. package/dist/refresh-BK9epzeC.d.ts +52 -0
  877. package/dist/refusal-DEuFVi4s.d.ts +30 -0
  878. package/dist/refusal-DhX7Xpfp.js +63 -0
  879. package/dist/relay-CllqA-lV.js +248 -0
  880. package/dist/resolve-DVOtYTAc.d.ts +287 -0
  881. package/dist/resolve-FW8oeXvh.js +927 -0
  882. package/dist/resolved-names-DYYyh35i.js +130 -0
  883. package/dist/resource-BfsTJnxZ.d.ts +119 -0
  884. package/dist/resource-Cn6Bn-_o.js +517 -0
  885. package/dist/resource-DQ4kIBpa.js +104 -0
  886. package/dist/resource-execute-DQRS7PFt.d.ts +13 -0
  887. package/dist/resource-schemas-Bq0g2RCQ.js +81 -0
  888. package/dist/resource-types-DF6KDAZM.d.ts +155 -0
  889. package/dist/resources-B0Vy7_wv.js +63 -0
  890. package/dist/resources-CeY53FiJ.d.ts +5 -0
  891. package/dist/respond-C2qvP1wv.js +106 -0
  892. package/dist/respond-CkwkvFdZ.d.ts +108 -0
  893. package/dist/result-8xza7w5W.js +145 -0
  894. package/dist/result-DTOQRyGY.d.ts +347 -0
  895. package/dist/rows-Ce8dsmfM.js +79 -0
  896. package/dist/rows-D-RqIsRz.js +38 -0
  897. package/dist/rrule-BLpe2449.js +289 -0
  898. package/dist/run-keys-BnzqxtYc.d.ts +59 -0
  899. package/dist/run-state-D0Tbl-nM.d.ts +11 -0
  900. package/dist/run-state-DGiyDQxH.js +12 -0
  901. package/dist/run-watch-DJk4Q603.js +52 -0
  902. package/dist/runtime-qslVrC9l.js +43 -0
  903. package/dist/sales-lines-Bde9cV5F.d.ts +36 -0
  904. package/dist/sales-lines-axwWhnLk.js +44 -0
  905. package/dist/sales-shared-CY3s_wBx.js +21 -0
  906. package/dist/sandboxes-DDWuD9fh.d.ts +85 -0
  907. package/dist/schemas-CpoEiAeT.js +213 -0
  908. package/dist/scope-dD_OAgRU.js +89 -0
  909. package/dist/scores-Bql-ABl0.d.ts +172 -0
  910. package/dist/scores-Bvk_JgXL.js +176 -0
  911. package/dist/search-DtbkD0h0.js +8 -0
  912. package/dist/server/index.d.ts +35 -69
  913. package/dist/server/index.js +51 -59
  914. package/dist/server-types-C3p3jUqr.d.ts +583 -0
  915. package/dist/session-BOch2y2z.d.ts +96 -0
  916. package/dist/session-status-DRBRnZHx.d.ts +80 -0
  917. package/dist/shared-Bmcnxwie.js +16 -0
  918. package/dist/shared-Ci1g9nl4.js +90 -0
  919. package/dist/shared-DsBcvj6q.d.ts +9 -0
  920. package/dist/sign-in-BmigClRh.js +730 -0
  921. package/dist/sign-in-C9pZE1kM.d.ts +53 -0
  922. package/dist/sign-in-CXOg2Dwb.js +399 -0
  923. package/dist/sign-in-Dxyi4aKu.d.ts +83 -0
  924. package/dist/signatures-CBn7w4VR.js +144 -0
  925. package/dist/signatures-jPr9JXyw.d.ts +41 -0
  926. package/dist/signers-Cz5ZhTHH.d.ts +380 -0
  927. package/dist/signing-keys-BC5_hJN5.js +163 -0
  928. package/dist/signing-keys-DS-rIVzz.d.ts +117 -0
  929. package/dist/simplify-BzThKn5b.js +82 -0
  930. package/dist/solid/index.d.ts +12 -22
  931. package/dist/solid/index.js +10 -16
  932. package/dist/solid-start/index.d.ts +7 -9
  933. package/dist/solid-start/index.js +8 -9
  934. package/dist/spec/index.d.ts +6 -48
  935. package/dist/spec/index.js +23 -39
  936. package/dist/spec-6Vr7sc0Z.js +123 -0
  937. package/dist/spec-pins-CuQ2anBw.d.ts +125 -0
  938. package/dist/spec-pins-FKUzgF6K.js +61 -0
  939. package/dist/sql/index.d.ts +4 -4
  940. package/dist/sql/index.js +4 -4
  941. package/dist/sql-BPV51R3A.js +140626 -0
  942. package/dist/sql-C1K5JALb.js +420 -0
  943. package/dist/sql-type-XWMeZRAl.js +33 -0
  944. package/dist/sqlite/index.d.ts +3 -9
  945. package/dist/sqlite/index.js +5 -8
  946. package/dist/sso-BEvNf1oW.d.ts +159 -0
  947. package/dist/sso-CRnaFJh0.js +216 -0
  948. package/dist/ssr/index.d.ts +5 -5
  949. package/dist/ssr/index.js +3 -3
  950. package/dist/standard-BD2aOUsf.js +24 -0
  951. package/dist/standard-DRX6Ch1j.d.ts +5 -0
  952. package/dist/stats-BTJgRMEp.js +82 -0
  953. package/dist/statuses-BTrQ5H4S.js +27 -0
  954. package/dist/statuses-Bv-0XoYC.js +27 -0
  955. package/dist/storage/index.d.ts +3 -3
  956. package/dist/storage/index.js +27 -40
  957. package/dist/storage-api-COQr77e8.js +9 -0
  958. package/dist/store-CKKzmsWB.js +68 -0
  959. package/dist/store-c7QxUHX-.d.ts +81 -0
  960. package/dist/streams/index.d.ts +3 -7
  961. package/dist/streams/index.js +5 -6
  962. package/dist/streams/redis/index.d.ts +1 -3
  963. package/dist/streams/redis/index.js +6 -7
  964. package/dist/stripe/index.d.ts +1 -3
  965. package/dist/stripe/index.js +3 -4
  966. package/dist/stripe-Bl-sjnl6.d.ts +154 -0
  967. package/dist/stripe-DKRwRWew.js +31 -0
  968. package/dist/subject-readers-BARV5rNp.js +48 -0
  969. package/dist/subject-readers-DWkVSbFr.d.ts +19 -0
  970. package/dist/subject-type-BarjdHZV.js +7 -0
  971. package/dist/subjects-BGwLJ3IB.d.ts +148 -0
  972. package/dist/subjects-vci6Wufh.d.ts +86 -0
  973. package/dist/subscribers-C57054Pc.js +32 -0
  974. package/dist/summaries-CUemsYwV.d.ts +67 -0
  975. package/dist/supabase-mcp-DY32eoax.d.ts +44 -0
  976. package/dist/supabase-mcp-QvebHckf.js +27 -0
  977. package/dist/support-rZbdU35s.d.ts +351 -0
  978. package/dist/support-view-CvDEgyGY.js +17 -0
  979. package/dist/support-view-WY4Y-A40.d.ts +15 -0
  980. package/dist/svelte/index.d.ts +11 -21
  981. package/dist/svelte/index.js +9 -15
  982. package/dist/sveltekit/index.d.ts +10 -14
  983. package/dist/sveltekit/index.js +12 -14
  984. package/dist/table-schema-CwXg7oBz.d.ts +77 -0
  985. package/dist/table-schema-D-ss9ozY.js +291 -0
  986. package/dist/tables-BSiVuKKx.js +72 -0
  987. package/dist/tags-BVLELhOf.d.ts +28 -0
  988. package/dist/tags-CW-KvjdL.js +38 -0
  989. package/dist/tanstack-db/index.d.ts +4 -8
  990. package/dist/tanstack-db/index.js +4 -6
  991. package/dist/tanstack-start/index.d.ts +8 -12
  992. package/dist/tanstack-start/index.js +8 -10
  993. package/dist/tax-BD9dN1rx.d.ts +168 -0
  994. package/dist/tax-BwckP5dv.js +139 -0
  995. package/dist/tee-CVOMhEX-.js +100 -0
  996. package/dist/template-CNq9xcfx.js +125 -0
  997. package/dist/temporal-DKTdGK9i.js +94 -0
  998. package/dist/temporal-required-w_2u4EDp.js +19 -0
  999. package/dist/tenant-BR7fvPj7.js +26 -0
  1000. package/dist/tenant-RKvGBB-U.d.ts +15 -0
  1001. package/dist/tenant-source-46lMuMEn.js +7 -0
  1002. package/dist/testing/index.d.ts +87 -124
  1003. package/dist/testing/index.js +158 -128
  1004. package/dist/timeline-Bs-FGMIJ.js +49 -0
  1005. package/dist/timeline-Ck8OFuAN.d.ts +147 -0
  1006. package/dist/timing-B6yHayKA.js +94 -0
  1007. package/dist/topic-BBBCVLyS.js +640 -0
  1008. package/dist/topic-Dr8VYE4D.d.ts +411 -0
  1009. package/dist/transport-CS4cVH4S.js +30 -0
  1010. package/dist/ttl-cache-C5S0L2wx.js +31 -0
  1011. package/dist/types-BiedVwz_.d.ts +192 -0
  1012. package/dist/types-CCmW3MqI.d.ts +449 -0
  1013. package/dist/types-CL-z0A4K.d.ts +660 -0
  1014. package/dist/types-CvlJNzX4.d.ts +215 -0
  1015. package/dist/types-D9FY9qSJ.d.ts +247 -0
  1016. package/dist/types-DWZubmwk.d.ts +648 -0
  1017. package/dist/types-DnrJ_crV.js +28 -0
  1018. package/dist/types-Pv5WPfIC.d.ts +175 -0
  1019. package/dist/types-WZUVlTXs.d.ts +907 -0
  1020. package/dist/undo-BdoEJ6Ot.d.ts +44 -0
  1021. package/dist/undo-Dki6Ujak.js +43 -0
  1022. package/dist/upload-claim-Bo2mpBz4.js +32 -0
  1023. package/dist/usage-D27Uw426.d.ts +230 -0
  1024. package/dist/user-change-Ngy8z1fZ.js +133 -0
  1025. package/dist/variants-BaMleC56.js +51 -0
  1026. package/dist/vault-Dx0LaNMX.d.ts +60 -0
  1027. package/dist/vercel-connect/index.d.ts +194 -20
  1028. package/dist/vercel-connect/index.js +265 -33
  1029. package/dist/vercel-sandbox/index.d.ts +166 -0
  1030. package/dist/vercel-sandbox/index.js +171 -0
  1031. package/dist/verify-DY_j4GPZ.js +129 -0
  1032. package/dist/verify-DnL0Fgu0.d.ts +144 -0
  1033. package/dist/view-DmEZA1fL.d.ts +95 -0
  1034. package/dist/view-YnesSUEa.js +244 -0
  1035. package/dist/vue/index.d.ts +12 -22
  1036. package/dist/vue/index.js +10 -16
  1037. package/dist/watch-topic-BB7T05sc.d.ts +29 -0
  1038. package/dist/watch-topic-C2KxpeaB.js +56 -0
  1039. package/dist/wire-DIoLA8VL.js +90 -0
  1040. package/dist/wiring-DJBSLdyF.js +12 -0
  1041. package/dist/workflow-sdk/builder/index.d.ts +12 -14
  1042. package/dist/workflow-sdk/builder/index.js +12 -11
  1043. package/dist/workflow-sdk/index.d.ts +62 -6
  1044. package/dist/workflow-sdk/index.js +75 -10
  1045. package/dist/workflow-sdk/world/index.d.ts +13 -20
  1046. package/dist/workflow-sdk/world/index.js +115 -26
  1047. package/dist/workflow-sdk-BL3wzkdp.js +2749 -0
  1048. package/dist/workflow-sdk-D5zRSwxh.js +302 -0
  1049. package/dist/workflow-sdk-DMpVSMB7.d.ts +171 -0
  1050. package/dist/workflows-DKTw2PZo.d.ts +256 -0
  1051. package/dist/yjs/index.d.ts +3 -5
  1052. package/dist/yjs/index.js +6 -7
  1053. package/package.json +45 -31
  1054. package/schemas/config-v1.json +66 -4
  1055. package/schemas/doctor-report-v1.json +1 -0
  1056. package/schemas/snapshot-v2.json +7 -0
  1057. package/skills/better-supabase/SKILL.md +4 -4
  1058. package/skills/better-supabase/references/block-extensions.md +2 -2
  1059. package/skills/better-supabase/references/troubleshooting.md +1 -1
  1060. package/skills/better-supabase/references/ui-recipes.md +591 -325
  1061. package/skills/better-supabase-api/SKILL.md +1 -1
  1062. package/skills/better-supabase-api/references/adapters.md +3 -3
  1063. package/skills/better-supabase-api/references/ai.md +8 -0
  1064. package/skills/better-supabase-api/references/powersync.md +16 -0
  1065. package/skills/better-supabase-auth/SKILL.md +22 -19
  1066. package/skills/better-supabase-auth/references/authorization-providers.md +1 -1
  1067. package/dist/access-sql-CTDNuxRv.js +0 -385
  1068. package/dist/actor-CoveJgya.d.ts +0 -106
  1069. package/dist/actor-go7p9-CJ.js +0 -150
  1070. package/dist/adapter-D4aNBxhm.js +0 -2301
  1071. package/dist/agents-CM_cCtcr.d.ts +0 -117
  1072. package/dist/ai-cache-BFRKxgZ4.js +0 -87
  1073. package/dist/ai-cache-BTGqckta.d.ts +0 -82
  1074. package/dist/ai-chat-B7_vQvxU.d.ts +0 -619
  1075. package/dist/ai-files-m_2z3rH1.js +0 -339
  1076. package/dist/ai-message-DfaP8sis.js +0 -14
  1077. package/dist/ai-schedules-CZEfo-_M.d.ts +0 -166
  1078. package/dist/anchors-7F34QyHa.d.ts +0 -40
  1079. package/dist/api-3C0AWFeP.js +0 -696
  1080. package/dist/api-59rv5hL6.d.ts +0 -495
  1081. package/dist/api-keys-JE-aykZE.d.ts +0 -213
  1082. package/dist/app-tables-yyVncXEt.d.ts +0 -28
  1083. package/dist/approvals-BfEafAzt.d.ts +0 -129
  1084. package/dist/assistant-B49qATbj.d.ts +0 -157
  1085. package/dist/attachments-BXbLnNxm.js +0 -376
  1086. package/dist/attributes-Bzf51_nc.js +0 -47
  1087. package/dist/auth-DyF_LRxd.js +0 -20
  1088. package/dist/auth-link-B4NL84XU.d.ts +0 -104
  1089. package/dist/auth-link-D3-bU6yz.js +0 -118
  1090. package/dist/auth-module-BbmX-N4L.js +0 -52
  1091. package/dist/auth-reply-Dj124sbX.d.ts +0 -11
  1092. package/dist/auth-reply-tlXB2FQ9.js +0 -31
  1093. package/dist/authorization-CDU9tYA_.d.ts +0 -3860
  1094. package/dist/authorization-hooks-BWhkMZfH.d.ts +0 -221
  1095. package/dist/authorizer-B6X09otb.d.ts +0 -118
  1096. package/dist/authorizer-BGhXaDmo.js +0 -172
  1097. package/dist/automation-D41DXyvT.js +0 -75
  1098. package/dist/automations-8L3NEuoq.js +0 -29
  1099. package/dist/automations-BKjJpktQ.js +0 -33
  1100. package/dist/automations-BMuqwZZn.js +0 -314
  1101. package/dist/automations-EzXteupo.js +0 -31
  1102. package/dist/availability-BdeKCHpl.d.ts +0 -236
  1103. package/dist/base64-B9Wlsdj7.js +0 -42
  1104. package/dist/batch-limit-DKVQDz4o.js +0 -5
  1105. package/dist/before-route-B23K2zYU.js +0 -30
  1106. package/dist/bind-p7asfI6H.d.ts +0 -104
  1107. package/dist/block-authors-Bw3zdzgl.js +0 -14
  1108. package/dist/block-authors-DzXLUiIq.d.ts +0 -12
  1109. package/dist/block-env-B8wG3xeh.d.ts +0 -32
  1110. package/dist/block-event-listener-Bu6G0TFH.js +0 -16
  1111. package/dist/block-events-IWAyafO3.js +0 -83
  1112. package/dist/block-fields-BE7pInWZ.d.ts +0 -58
  1113. package/dist/block-fields-BjXgX_5c.js +0 -140
  1114. package/dist/block-helpers-B0f0ZVb5.js +0 -437
  1115. package/dist/block-helpers-D5emQ2O6.d.ts +0 -62
  1116. package/dist/block-hooks-B8itxzEE.d.ts +0 -117
  1117. package/dist/block-hooks-DKtz0HRh.js +0 -130
  1118. package/dist/block-method-C9hWdHom.js +0 -21
  1119. package/dist/block-method-CiVa2G-J.d.ts +0 -14
  1120. package/dist/block-subjects-C1_9DkSA.d.ts +0 -6
  1121. package/dist/block-subjects-DFSuFY1a.js +0 -55
  1122. package/dist/block-tenant-DHp7subc.js +0 -14
  1123. package/dist/block-transport-9EUA3q_I.d.ts +0 -69
  1124. package/dist/bookings-xsmM2TA_.d.ts +0 -289
  1125. package/dist/bucket-SvRQwYS4.d.ts +0 -705
  1126. package/dist/build-CH2N3Yf0.js +0 -2073
  1127. package/dist/build-DbIRFcHQ.js +0 -735
  1128. package/dist/carrier-KzeYXVrW.d.ts +0 -169
  1129. package/dist/casing-DdFWEtqr.js +0 -16
  1130. package/dist/channel-JcMd5lNP.d.ts +0 -105
  1131. package/dist/channels-CfcFPuo_.js +0 -114
  1132. package/dist/claims-Bp9My7XP.js +0 -88
  1133. package/dist/claims-DTy6R6my.js +0 -63
  1134. package/dist/cli/_format-Cax5EsM9.js +0 -101
  1135. package/dist/cli/add-BdhGOwkB.js +0 -1
  1136. package/dist/cli/add-D4w-Axib.js +0 -1231
  1137. package/dist/cli/add-Dggyehsy.js +0 -99
  1138. package/dist/cli/agent-CbuPvI2x.js +0 -185
  1139. package/dist/cli/app-table-files-CiGuwLkO.js +0 -346
  1140. package/dist/cli/arazzo-1.0-BalU61-_.js +0 -532
  1141. package/dist/cli/arazzo-1.1-Bnfasbun.js +0 -705
  1142. package/dist/cli/args-UEwg0l-N.js +0 -27
  1143. package/dist/cli/asyncapi-3.0.0-C78dBjR6.js +0 -5593
  1144. package/dist/cli/asyncapi-3.1.0-g-7aIfV1.js +0 -5833
  1145. package/dist/cli/backfill-DjVjXW_P.js +0 -293
  1146. package/dist/cli/blocks-Bbmb6W_F.js +0 -1
  1147. package/dist/cli/blocks-jRL9K1R8.js +0 -156
  1148. package/dist/cli/cache-BuoIFlUJ.js +0 -607
  1149. package/dist/cli/codemod-DRavXBCb.js +0 -2435
  1150. package/dist/cli/codemod-block-renames-BuSaTE_G.js +0 -239
  1151. package/dist/cli/command-DIPmo0wh.js +0 -997
  1152. package/dist/cli/compare-BmIWVEui.js +0 -9
  1153. package/dist/cli/completion-DxPxMtyP.js +0 -211
  1154. package/dist/cli/completion-DyLMSjOD.js +0 -1
  1155. package/dist/cli/completion-FUgqm2-N.js +0 -30
  1156. package/dist/cli/config-BfapErxs.js +0 -47
  1157. package/dist/cli/config-Cskysxp-.js +0 -2000
  1158. package/dist/cli/config-Df5cXWNN.js +0 -1
  1159. package/dist/cli/config-edit-CrWfk8s3.js +0 -621
  1160. package/dist/cli/config-group-CP-B9uRt.js +0 -390
  1161. package/dist/cli/content-mapper-BCtyfKXl.js +0 -182
  1162. package/dist/cli/db-CQCLx7cx.js +0 -78
  1163. package/dist/cli/db-CWvH1_46.js +0 -247
  1164. package/dist/cli/detect-D9JaAX20.js +0 -84
  1165. package/dist/cli/dist-D_VbPAMR.js +0 -129
  1166. package/dist/cli/dist-DuiMMRbJ.js +0 -1112
  1167. package/dist/cli/doctor-Di2ZekfN.js +0 -4659
  1168. package/dist/cli/env-B2CbnbzD.js +0 -143
  1169. package/dist/cli/env-BK0xKMeU.js +0 -1113
  1170. package/dist/cli/env-Bat6ogep.js +0 -1
  1171. package/dist/cli/env-CynGCICL.js +0 -1
  1172. package/dist/cli/errors-BTe6A15O.js +0 -98
  1173. package/dist/cli/exec-Ca5s-ygi.js +0 -463
  1174. package/dist/cli/fastest-levenshtein-dhRRvrM2.js +0 -120
  1175. package/dist/cli/files-CX71yBm8.js +0 -1010
  1176. package/dist/cli/fresh-import-DzgsGHkX.js +0 -40
  1177. package/dist/cli/gen-STKC9vkK.js +0 -394
  1178. package/dist/cli/guards-CUlDNYZs.js +0 -8
  1179. package/dist/cli/in-stack-diff-Cp-tVPj2.js +0 -186
  1180. package/dist/cli/init-DW6_nIwj.js +0 -559
  1181. package/dist/cli/io-DH1kcmmP.js +0 -37
  1182. package/dist/cli/json5-ChRycquj.js +0 -787
  1183. package/dist/cli/jsonc-C8M0EhHB.js +0 -1
  1184. package/dist/cli/jsonc-D5Fu67jw.js +0 -45
  1185. package/dist/cli/keys-V-HcO-21.js +0 -106
  1186. package/dist/cli/legacy-prefix-R7UChFFl.js +0 -154
  1187. package/dist/cli/live-0G4Plw3K.js +0 -341
  1188. package/dist/cli/mcp-flKS8iU5.js +0 -241
  1189. package/dist/cli/metadata-VARUbXEe.js +0 -150
  1190. package/dist/cli/migrate-Bkq07XcT.js +0 -46
  1191. package/dist/cli/migration-safety-BfVeza5j.js +0 -928
  1192. package/dist/cli/migrations-BCq7Zs2E.js +0 -117
  1193. package/dist/cli/module-migration-lbeUrsYv.js +0 -119
  1194. package/dist/cli/moved-DNOtp9LA.js +0 -254
  1195. package/dist/cli/ohash-BjQY1cBb.js +0 -277
  1196. package/dist/cli/openapi-3.0-t7xwkuRH.js +0 -928
  1197. package/dist/cli/openapi-3.1-CVze7tBS.js +0 -870
  1198. package/dist/cli/openapi-3.2-CFoMYM01.js +0 -1031
  1199. package/dist/cli/orphans-BAboqyVM.js +0 -28
  1200. package/dist/cli/parse-BPf3kGnc.js +0 -182
  1201. package/dist/cli/powersync-B15CfH5Y.js +0 -284
  1202. package/dist/cli/powersync-DnBsDchT.js +0 -1
  1203. package/dist/cli/preset-BwmIfFnh.js +0 -101
  1204. package/dist/cli/print-DjxpBRnv.js +0 -68
  1205. package/dist/cli/prompts-jqnr94b9.js +0 -1140
  1206. package/dist/cli/providers-dyxcHQY3.js +0 -301
  1207. package/dist/cli/redact-KGAk2Ul9.js +0 -38
  1208. package/dist/cli/remove-BLq5gbal.js +0 -239
  1209. package/dist/cli/render-CizUf3RW.js +0 -2225
  1210. package/dist/cli/rolldown-runtime-kJ_i4yPo.js +0 -26
  1211. package/dist/cli/run-ChEjR7yw.js +0 -63
  1212. package/dist/cli/run-ChOY6s4o.js +0 -1459
  1213. package/dist/cli/run-MwM__teL.js +0 -705
  1214. package/dist/cli/seed-BOun22-k.js +0 -1
  1215. package/dist/cli/seed-CDnL4Tnc.js +0 -188
  1216. package/dist/cli/shared-DV5wIv-7.js +0 -151
  1217. package/dist/cli/shell-Btv_4Yhe.js +0 -10
  1218. package/dist/cli/skills-DM3oeIxY.js +0 -121
  1219. package/dist/cli/snapshot-B5LXkVMC.js +0 -729
  1220. package/dist/cli/source-BoLNG_2A.js +0 -320
  1221. package/dist/cli/source-args-v8ljFDfc.js +0 -59
  1222. package/dist/cli/spec-D6QeE2Zx.js +0 -1
  1223. package/dist/cli/spec-Dz-PGCaM.js +0 -7530
  1224. package/dist/cli/sql-layout-zo02f3Dm.js +0 -261
  1225. package/dist/cli/stack-ClESAZYf.js +0 -135
  1226. package/dist/cli/stack-env-3ziggrU3.js +0 -93
  1227. package/dist/cli/stack-status-BkkYRlXG.js +0 -46
  1228. package/dist/cli/stacks-CiDBH1dB.js +0 -232
  1229. package/dist/cli/style-Bm2X5JrN.js +0 -35
  1230. package/dist/cli/supabase-toml-CncmQbO0.js +0 -1164
  1231. package/dist/cli/sync-m-oZ_SyI.js +0 -322
  1232. package/dist/cli/table-dyKddjwo.js +0 -89
  1233. package/dist/cli/toml-DB-MNnFs.js +0 -424
  1234. package/dist/cli/topics-BpdnYmWb.js +0 -30
  1235. package/dist/cli/trace-VbdO6bcN.js +0 -7
  1236. package/dist/cli/upgrade-C9sgVZ5z.js +0 -272
  1237. package/dist/cli/upgrade-WwEJaX3i.js +0 -41
  1238. package/dist/cli/validate-B3lF3-jB.js +0 -7522
  1239. package/dist/cli/version-D2BQuqta.js +0 -4
  1240. package/dist/cli/yaml-CYCbJ6et.js +0 -2252
  1241. package/dist/client-C_mlji5R.js +0 -288
  1242. package/dist/clone-CkG0-hlI.js +0 -33
  1243. package/dist/cloud-event-0pQ9vFNS.d.ts +0 -64
  1244. package/dist/cloud-event-XsM53POL.js +0 -63
  1245. package/dist/codecs-CMWlhHZ0.d.ts +0 -222
  1246. package/dist/codecs-CSUFGrdP.js +0 -358
  1247. package/dist/compiler-BEeVWXPS.d.ts +0 -14
  1248. package/dist/compose-DKW0Tr3e.js +0 -53
  1249. package/dist/composite-BJ9s-IJJ.d.ts +0 -83
  1250. package/dist/composite-CBRbvn5j.js +0 -130
  1251. package/dist/config-bqKaPjst.js +0 -1679
  1252. package/dist/config-r7njjNgh.js +0 -1111
  1253. package/dist/connectors-uC5baoFV.d.ts +0 -147
  1254. package/dist/context-DBicfUNz.js +0 -41
  1255. package/dist/context-nbYYjv7U.d.ts +0 -4344
  1256. package/dist/controller-BEliOBOv.js +0 -79
  1257. package/dist/controller-TRocodqG.d.ts +0 -52
  1258. package/dist/controller-qG-B1eDn.js +0 -73
  1259. package/dist/conversion-Dq1S7xzE.js +0 -77
  1260. package/dist/conversion-g8HzH9My.d.ts +0 -86
  1261. package/dist/cors-h_v7TPxl.js +0 -24
  1262. package/dist/cors-kLq6VM06.d.ts +0 -15
  1263. package/dist/create-blocks-BfrDUSM6.js +0 -370
  1264. package/dist/cron-DdT4ti8a.js +0 -148
  1265. package/dist/cron-route-FjKgRvTY.js +0 -24
  1266. package/dist/csv-2rXGPNtP.js +0 -89
  1267. package/dist/csv-DhHQS2x_.d.ts +0 -28
  1268. package/dist/data-engine-D1BkmBoR.js +0 -173
  1269. package/dist/data-engine-rvbR2C4F.d.ts +0 -273
  1270. package/dist/data-hooks-CdcZfVS1.js +0 -280
  1271. package/dist/db-exception-Lngc1W49.js +0 -31
  1272. package/dist/deal-forecast-CKBnRodz.js +0 -39
  1273. package/dist/deal-forecast-LwO-Z4_C.d.ts +0 -23
  1274. package/dist/define-D-dLADd5.js +0 -2084
  1275. package/dist/define-D8_9X5fZ.d.ts +0 -1263
  1276. package/dist/define-block-BGqOO8B3.js +0 -64
  1277. package/dist/define-block-DWVZSZv1.d.ts +0 -1687
  1278. package/dist/delegation-C7eWP2r8.d.ts +0 -14
  1279. package/dist/delegation-DGOIiT8k.js +0 -153
  1280. package/dist/delivery-Bm0jxmzI.js +0 -29
  1281. package/dist/delivery-n6lZGuGx.d.ts +0 -71
  1282. package/dist/documents-BbwYyynk.d.ts +0 -152
  1283. package/dist/email-B3YxEzwC.d.ts +0 -42
  1284. package/dist/embeddings-I3s5sTDt.d.ts +0 -78
  1285. package/dist/embeddings-vVzseUw0.js +0 -128
  1286. package/dist/ended-EZzN9QTM.d.ts +0 -26
  1287. package/dist/entitlements-B1i1-wfe.d.ts +0 -54
  1288. package/dist/entitlements-tGL6-69B.js +0 -45
  1289. package/dist/entity-naming-Dtyq5sKE.js +0 -131
  1290. package/dist/entity-schema-B1YmMtP8.js +0 -39
  1291. package/dist/envelope-DEI2iX-d.js +0 -90
  1292. package/dist/errors-BVFgt8BZ.js +0 -328
  1293. package/dist/errors-CyxMxzlu.js +0 -44
  1294. package/dist/escape-like-DHfx6jRr.js +0 -7
  1295. package/dist/escape-like-PReMbEEU.d.ts +0 -30
  1296. package/dist/eve-BfhVFV33.d.ts +0 -157
  1297. package/dist/event-calendar-DVLs2wUO.d.ts +0 -65
  1298. package/dist/event-map-CtPFhcOp.js +0 -19
  1299. package/dist/events-B2qbZps6.d.ts +0 -854
  1300. package/dist/events-D6IZ5CE8.js +0 -82
  1301. package/dist/events-DuLhzjP6.js +0 -26
  1302. package/dist/executor-BfirBzOr.d.ts +0 -174
  1303. package/dist/executor-BlS0kCrN.d.ts +0 -104
  1304. package/dist/executor-C2Ne-Scm.js +0 -208
  1305. package/dist/executor-DXQIx4sW.d.ts +0 -37
  1306. package/dist/executor-DqIci3Jb.js +0 -486
  1307. package/dist/executor-WolvKszH.js +0 -843
  1308. package/dist/extension-DTaHjwdc.js +0 -59
  1309. package/dist/extension-DeAd_MqI.js +0 -121
  1310. package/dist/extension-DzCc0IOd.js +0 -103
  1311. package/dist/extension-mGylYROs.js +0 -53
  1312. package/dist/extension-shared-Djm8mGHD.js +0 -60
  1313. package/dist/extra-CGQ2_q3S.js +0 -10
  1314. package/dist/field-errors-tJvehEFc.d.ts +0 -216
  1315. package/dist/field-formats-C6QKA3UR.js +0 -102
  1316. package/dist/field-formats-CAFNkKSN.d.ts +0 -38
  1317. package/dist/fields-BBm49w-E.js +0 -108
  1318. package/dist/fields-snbaZ14h.d.ts +0 -78
  1319. package/dist/filter-evaluate-BRpNiNPG.d.ts +0 -37
  1320. package/dist/filter-evaluate-lCToXzZI.js +0 -217
  1321. package/dist/filter-query-CQ6d5GnQ.js +0 -566
  1322. package/dist/filter-query-DBt7OKuH.d.ts +0 -133
  1323. package/dist/flags-DDKTThrO.d.ts +0 -246
  1324. package/dist/flags-DF_SCqp5.js +0 -279
  1325. package/dist/form-definition-BTpM_tz1.js +0 -363
  1326. package/dist/form-definition-BjEtH8BT.d.ts +0 -119
  1327. package/dist/format-u-65igKI.d.ts +0 -79
  1328. package/dist/framework-DVYTtQXA.d.ts +0 -47
  1329. package/dist/framework-DYEUraqt.js +0 -58
  1330. package/dist/function-contract-DxFNOmsm.d.ts +0 -27
  1331. package/dist/function-contract-pEmsaUIf.js +0 -8
  1332. package/dist/gateway-Ve7cByEr.d.ts +0 -115
  1333. package/dist/gateway-options-BlVCqgb8.d.ts +0 -29
  1334. package/dist/gateway-options-Cl74B7k6.js +0 -27
  1335. package/dist/guards-6F2bCtQR.js +0 -12
  1336. package/dist/guest-actions-1T1DeS5Y.d.ts +0 -5
  1337. package/dist/guest-actions-B7zdhfnh.js +0 -9
  1338. package/dist/history-GH1HJWQV.js +0 -271
  1339. package/dist/hmac-B3CTTlfv.js +0 -23
  1340. package/dist/http-7-UvHjQe.js +0 -28
  1341. package/dist/http-BjjojWg3.js +0 -40
  1342. package/dist/http-DzbloBR-.js +0 -141
  1343. package/dist/image-url-_d7xYsXK.js +0 -84
  1344. package/dist/impersonation-DM3oWNoD.js +0 -62
  1345. package/dist/impersonation-YTa9dZUv.d.ts +0 -28
  1346. package/dist/inbox-c8B86Trp.d.ts +0 -321
  1347. package/dist/index-8US7qlvW.d.ts +0 -158
  1348. package/dist/index-B4wttiLh.d.ts +0 -407
  1349. package/dist/index-BKrxynq9.d.ts +0 -240
  1350. package/dist/index-BM6NmKSc.d.ts +0 -588
  1351. package/dist/index-BkzXwuIN.d.ts +0 -338
  1352. package/dist/index-CWAQRWY8.d.ts +0 -729
  1353. package/dist/index-Cxsnd-OL.d.ts +0 -305
  1354. package/dist/index-DbyDZZlc.d.ts +0 -53
  1355. package/dist/index-NRMMhhEi.d.ts +0 -104
  1356. package/dist/index-X2fkPUwb.d.ts +0 -51
  1357. package/dist/index-pZn6S_iq.d.ts +0 -149
  1358. package/dist/index-zsgNmE8m.d.ts +0 -665
  1359. package/dist/instance-property-hRh88y_s.js +0 -7
  1360. package/dist/instances-C7qUTjhJ.js +0 -16603
  1361. package/dist/invalidate-DMp4eqfF.d.ts +0 -21
  1362. package/dist/iso4217-B-durg_y.js +0 -176
  1363. package/dist/json-DaByVJpw.js +0 -22
  1364. package/dist/json-schema-DHJxiizN.js +0 -888
  1365. package/dist/jwks-cache-DEsKI0hJ.js +0 -49
  1366. package/dist/jws-D0toeQlA.d.ts +0 -66
  1367. package/dist/jws-DOgHJKHb.js +0 -205
  1368. package/dist/kit-B8yWCRN7.d.ts +0 -94
  1369. package/dist/kit-Bcd9wYCV.js +0 -133
  1370. package/dist/knowledge-CsLPACGJ.d.ts +0 -217
  1371. package/dist/knowledge-tCrrU99q.js +0 -300
  1372. package/dist/list-query-BcU8NnNL.d.ts +0 -222
  1373. package/dist/list-query-BnpA2BDg.js +0 -559
  1374. package/dist/live-C21DgbsD.js +0 -275
  1375. package/dist/logger-DWVYUmwi.d.ts +0 -18
  1376. package/dist/logger-glM28NVN.js +0 -21
  1377. package/dist/lookup-BaP5bI27.js +0 -18
  1378. package/dist/management-wtecfrNf.d.ts +0 -57
  1379. package/dist/message-Bg4TKA12.d.ts +0 -99
  1380. package/dist/messages-ecPW_nOv.js +0 -492
  1381. package/dist/messaging-DQP09JsY.d.ts +0 -297
  1382. package/dist/methods-Cund9ZBe.js +0 -11
  1383. package/dist/metric-definition-BjxVn4R5.js +0 -117
  1384. package/dist/metric-definition-EAYI1r2n.d.ts +0 -69
  1385. package/dist/mfa-oIOYTpvc.d.ts +0 -36
  1386. package/dist/model-hwpvole9.d.ts +0 -340
  1387. package/dist/model-messages-CkZSDDHP.js +0 -206
  1388. package/dist/model-messages-DrR4lZ_c.d.ts +0 -34
  1389. package/dist/money-BNRdJQzA.d.ts +0 -91
  1390. package/dist/money-BZl985O-.js +0 -197
  1391. package/dist/money-codec-BJuS2zEW.js +0 -41
  1392. package/dist/my-work-kinds-BU3SlA-6.js +0 -11
  1393. package/dist/node-headers-BPtMP4_V.d.ts +0 -27
  1394. package/dist/node-headers-C71zNQHe.js +0 -55
  1395. package/dist/operations-CB9atU2e.d.ts +0 -6
  1396. package/dist/operations-DVHRHvv6.js +0 -29
  1397. package/dist/optional-peer-C1NbBRJm.js +0 -32
  1398. package/dist/options-3OYOU56e.js +0 -11
  1399. package/dist/options-56zYYXxc.js +0 -10
  1400. package/dist/options-5WvWOkAm.d.ts +0 -26
  1401. package/dist/options-62woPFn3.js +0 -12
  1402. package/dist/options-7ixoOoap.js +0 -10
  1403. package/dist/options-9dSU5RML.js +0 -5
  1404. package/dist/options-B0YZtAkb.d.ts +0 -15
  1405. package/dist/options-B2Kz_tCx.js +0 -10
  1406. package/dist/options-B5E2MGIz.js +0 -15
  1407. package/dist/options-B685YSzQ.js +0 -5
  1408. package/dist/options-B692WoK6.js +0 -9
  1409. package/dist/options-BHU1wc74.js +0 -5
  1410. package/dist/options-BHy0Z5Zd.js +0 -5
  1411. package/dist/options-BJtdsK7b.js +0 -8
  1412. package/dist/options-BKBy5wM_.js +0 -16
  1413. package/dist/options-BKDxrPvE.js +0 -5
  1414. package/dist/options-BLfymS4s.js +0 -5
  1415. package/dist/options-BOCRbzh3.js +0 -5
  1416. package/dist/options-BOqfYsM1.js +0 -13
  1417. package/dist/options-BQWJqwHO.js +0 -9
  1418. package/dist/options-BQunK6_Y.js +0 -8
  1419. package/dist/options-BQyrZjwM.js +0 -28
  1420. package/dist/options-BR9xTHZW.js +0 -5
  1421. package/dist/options-BRUdd5jY.js +0 -8
  1422. package/dist/options-BSsYXjhC.js +0 -9
  1423. package/dist/options-BTmaRzx2.d.ts +0 -60
  1424. package/dist/options-BUCQYAeJ.d.ts +0 -10
  1425. package/dist/options-B_NrjVDt.d.ts +0 -12
  1426. package/dist/options-BawzwlmC.js +0 -11
  1427. package/dist/options-BbLDAp7G.d.ts +0 -10
  1428. package/dist/options-BfPsL7E2.js +0 -9
  1429. package/dist/options-Bfmwwc78.js +0 -8
  1430. package/dist/options-BhsdveDk.js +0 -21
  1431. package/dist/options-BomoTH-8.js +0 -5
  1432. package/dist/options-BtjkzIVh.js +0 -8
  1433. package/dist/options-Bvi9bl4H.js +0 -5
  1434. package/dist/options-BwKNmaJo.js +0 -5
  1435. package/dist/options-BxpLtyk-.js +0 -18
  1436. package/dist/options-BzB2QxL3.js +0 -5
  1437. package/dist/options-C078wBP0.js +0 -5
  1438. package/dist/options-C3AdsFJ6.js +0 -9
  1439. package/dist/options-C7C5OhmL.d.ts +0 -8
  1440. package/dist/options-C87u6eSa.js +0 -10
  1441. package/dist/options-CBAEGxwS.js +0 -8
  1442. package/dist/options-CDSCkYxu.d.ts +0 -14
  1443. package/dist/options-CDUr8zzX.js +0 -8
  1444. package/dist/options-CFjGxfa8.js +0 -5
  1445. package/dist/options-CI6P0xhV.js +0 -10
  1446. package/dist/options-CJFMK9A_.js +0 -8
  1447. package/dist/options-CLpgx7en.js +0 -10
  1448. package/dist/options-COo7_3MX.js +0 -10
  1449. package/dist/options-CSCXNYJO.d.ts +0 -8
  1450. package/dist/options-CTXHj9zr.js +0 -16
  1451. package/dist/options-CTl8T88w.js +0 -11
  1452. package/dist/options-CUIOOv4z.js +0 -15
  1453. package/dist/options-CZDmtsbV.js +0 -8
  1454. package/dist/options-CZTscdPB.js +0 -5
  1455. package/dist/options-CZdKndeo.js +0 -9
  1456. package/dist/options-C_7g9TTq.d.ts +0 -12
  1457. package/dist/options-Cb2FOFj5.js +0 -5
  1458. package/dist/options-CbOstLa7.js +0 -5
  1459. package/dist/options-CcXgWlvm.js +0 -24
  1460. package/dist/options-CfVPctAw.js +0 -89
  1461. package/dist/options-Cjgaf8ub.js +0 -8
  1462. package/dist/options-CoSPgWKy.js +0 -9
  1463. package/dist/options-CpZ2HlSU.js +0 -32
  1464. package/dist/options-CsSe8Nba.js +0 -8
  1465. package/dist/options-CsvJR-r2.js +0 -9
  1466. package/dist/options-Cucv6sWP.js +0 -12
  1467. package/dist/options-CyjL9lTf.js +0 -5
  1468. package/dist/options-D-OOO9V2.d.ts +0 -10
  1469. package/dist/options-D0Y6ZMe8.js +0 -5
  1470. package/dist/options-D0bzZx9a.d.ts +0 -10
  1471. package/dist/options-D0sj5abR.js +0 -9
  1472. package/dist/options-D1hSuf50.d.ts +0 -12
  1473. package/dist/options-D610Fa6T.js +0 -5
  1474. package/dist/options-D96dScev.js +0 -24
  1475. package/dist/options-DFpyP1bg.js +0 -5
  1476. package/dist/options-DJEcS4DX.js +0 -5
  1477. package/dist/options-DJbN3bi9.js +0 -11
  1478. package/dist/options-DKoQoRCy.js +0 -13
  1479. package/dist/options-DM1qaMMQ.js +0 -9
  1480. package/dist/options-DNgSwhsm.js +0 -11
  1481. package/dist/options-DOIwzRXL.js +0 -16
  1482. package/dist/options-DRIgHh4O.d.ts +0 -16
  1483. package/dist/options-DRrZmJyI.js +0 -8
  1484. package/dist/options-DUMUsvml.js +0 -5
  1485. package/dist/options-DWwL5Kaz.js +0 -9
  1486. package/dist/options-DZHZYlpD.js +0 -10
  1487. package/dist/options-DZLkeqWn.js +0 -9
  1488. package/dist/options-DZRpXKQE.js +0 -5
  1489. package/dist/options-DZen3UiC.js +0 -14
  1490. package/dist/options-D_9Vxx7f.js +0 -8
  1491. package/dist/options-DcHl59RC.js +0 -11
  1492. package/dist/options-Dcaql09y.js +0 -11
  1493. package/dist/options-DcnBNYmV.js +0 -8
  1494. package/dist/options-DdpM-fiP.js +0 -9
  1495. package/dist/options-DhoLMknl.js +0 -10
  1496. package/dist/options-DlohRAYd.d.ts +0 -13
  1497. package/dist/options-Dpy-Ruo-.js +0 -14
  1498. package/dist/options-DsVuVRH3.d.ts +0 -17
  1499. package/dist/options-DtAJxfHS.js +0 -8
  1500. package/dist/options-Dz9Yo52Z.js +0 -8
  1501. package/dist/options-HnfETSHr.d.ts +0 -19
  1502. package/dist/options-LqUXTpML.js +0 -8
  1503. package/dist/options-MsloEAIB.js +0 -5
  1504. package/dist/options-P2FxqYpd.js +0 -17
  1505. package/dist/options-_1gAIMq7.d.ts +0 -60
  1506. package/dist/options-aT89JqlB.js +0 -5
  1507. package/dist/options-cVKZu9b0.js +0 -9
  1508. package/dist/options-eTepQ1rZ.js +0 -15
  1509. package/dist/options-fkShrmGQ.js +0 -8
  1510. package/dist/options-gUvfr3no.js +0 -11
  1511. package/dist/options-hynwKWuf.js +0 -20
  1512. package/dist/options-jsOCvLUz.js +0 -10
  1513. package/dist/options-o5wCw8H7.d.ts +0 -14
  1514. package/dist/options-p49DFg3H.js +0 -8
  1515. package/dist/options-pYNpXKcg.js +0 -8
  1516. package/dist/options-qtETCHzW.js +0 -10
  1517. package/dist/options-rnKlqYEr.js +0 -5
  1518. package/dist/options-sU_zGkiV.js +0 -10
  1519. package/dist/options-xq4MXG1M.js +0 -5
  1520. package/dist/options-zzlznRA7.js +0 -10
  1521. package/dist/outbox-BZ712Z3X.d.ts +0 -199
  1522. package/dist/payments-BXvabJOw.js +0 -16
  1523. package/dist/payments-BYcN34Fp.d.ts +0 -114
  1524. package/dist/permissions-controller-BMsqIE5T.js +0 -34
  1525. package/dist/pg-error-B5QLDcbG.js +0 -26
  1526. package/dist/plugin-AKwwe2gF.js +0 -48
  1527. package/dist/pool-DDR1ndk7.d.ts +0 -123
  1528. package/dist/pool-errors-JUBcGrre.js +0 -27
  1529. package/dist/ports-DvpNseap.js +0 -152
  1530. package/dist/ports-hpbyMySO.d.ts +0 -89
  1531. package/dist/postgrest-AJc8hnJU.d.ts +0 -53
  1532. package/dist/postgrest-executor-B_Uezhrm.js +0 -1068
  1533. package/dist/preset-DCdEnJj9.js +0 -1042
  1534. package/dist/problem-Bf0cJ7tk.js +0 -162
  1535. package/dist/problem-DNwN8iGz.d.ts +0 -79
  1536. package/dist/project-B32wb5J6.js +0 -1760
  1537. package/dist/provider-B6g7rBZX.js +0 -57
  1538. package/dist/provider-CWjzAIX9.d.ts +0 -112
  1539. package/dist/push-token-D6REHMMw.js +0 -16
  1540. package/dist/push-token-DQ1ycFPU.d.ts +0 -24
  1541. package/dist/queries-BWYYS9um.js +0 -239
  1542. package/dist/range-DwpWe8e7.js +0 -7
  1543. package/dist/range-p5V4rBhZ.d.ts +0 -8
  1544. package/dist/rank-keys-DcPMt_Jk.js +0 -60
  1545. package/dist/rank-result-BBJIK-k_.js +0 -18
  1546. package/dist/rank-result-Bwe7igy-.d.ts +0 -14
  1547. package/dist/rate-limit-BWKGlhTM.js +0 -49
  1548. package/dist/rate-limit-Bztf32cl.d.ts +0 -50
  1549. package/dist/rate-limit-fZ_d8gSE.js +0 -380
  1550. package/dist/ratelimit-headers-kEcXyO3H.js +0 -62
  1551. package/dist/react-BKCnIuZs.js +0 -79
  1552. package/dist/react-CcrQQl0_.js +0 -1016
  1553. package/dist/read-set-B1sDib5O.js +0 -199
  1554. package/dist/realtime-status-BhNkb-Ow.d.ts +0 -8
  1555. package/dist/realtime-status-asHvhiOh.js +0 -11
  1556. package/dist/record-bindings-Z51mGfhB.js +0 -26
  1557. package/dist/record-form-CubgBrtI.d.ts +0 -82
  1558. package/dist/record-type-DRbnlj5q.js +0 -221
  1559. package/dist/recordings-DeZYx-Kv.d.ts +0 -119
  1560. package/dist/refresh-D02Pbf5B.d.ts +0 -54
  1561. package/dist/refusal-B0VmlAxF.d.ts +0 -32
  1562. package/dist/refusal-DDlInPff.js +0 -64
  1563. package/dist/relay-CIKcAVjf.js +0 -248
  1564. package/dist/replicas-Dyoh3CEg.js +0 -94
  1565. package/dist/resolve-B0mW2m7f.js +0 -932
  1566. package/dist/resolve-CtX6T0c0.d.ts +0 -288
  1567. package/dist/resolved-names-iLBOUaib.js +0 -133
  1568. package/dist/resource-BUJcZKiW.js +0 -520
  1569. package/dist/resource-DvgXqZB_.js +0 -105
  1570. package/dist/resource-WxN0IsvB.d.ts +0 -123
  1571. package/dist/resource-execute-BzqR8DdD.d.ts +0 -15
  1572. package/dist/resource-schemas-up6bKOUi.js +0 -82
  1573. package/dist/resource-types-BVbHgTPg.d.ts +0 -157
  1574. package/dist/resources-BSbRa0Ab.d.ts +0 -7
  1575. package/dist/resources-jb3R6rEa.js +0 -64
  1576. package/dist/respond-CZMWbUs3.js +0 -107
  1577. package/dist/respond-Dzu_-EPH.d.ts +0 -112
  1578. package/dist/result-DZeA5KS6.d.ts +0 -351
  1579. package/dist/result-ntFBW2p2.js +0 -146
  1580. package/dist/rows-BdqXmiB-.js +0 -80
  1581. package/dist/rows-jijHLVE_.js +0 -39
  1582. package/dist/rrule-C9Ot6ax8.js +0 -290
  1583. package/dist/run-state-BMCD_1Lt.d.ts +0 -13
  1584. package/dist/run-state-CgBKzYMW.js +0 -13
  1585. package/dist/run-watch-B-LoK5m1.js +0 -53
  1586. package/dist/runtime-CoKxZibd.js +0 -45
  1587. package/dist/sales-lines-BsmrNHe9.d.ts +0 -38
  1588. package/dist/sales-lines-DO7oRu1o.js +0 -45
  1589. package/dist/sales-shared-BuTA8JK7.js +0 -22
  1590. package/dist/schemas-CLOTvdsC.js +0 -216
  1591. package/dist/scope-DgWjuXUw.js +0 -90
  1592. package/dist/scores-Y8TvyJi1.d.ts +0 -174
  1593. package/dist/scores-bY2Is0kx.js +0 -177
  1594. package/dist/search-Cn_DGluL.js +0 -9
  1595. package/dist/server-types-BkTIxW_H.d.ts +0 -597
  1596. package/dist/session-BOzx2qHC.d.ts +0 -100
  1597. package/dist/session-status-BP8eYVnA.d.ts +0 -82
  1598. package/dist/shared-BeHTi8Fu.js +0 -17
  1599. package/dist/shared-Bf-I13Ht.js +0 -91
  1600. package/dist/shared-CRRfQAKG.d.ts +0 -11
  1601. package/dist/sign-in-BzihC_8k.d.ts +0 -50
  1602. package/dist/sign-in-CmPK1AgM.js +0 -402
  1603. package/dist/sign-in-Cyj3ZlFX.js +0 -703
  1604. package/dist/sign-in-D54FLMQy.d.ts +0 -55
  1605. package/dist/signatures-CX1b4WHa.js +0 -145
  1606. package/dist/signatures-Dkx9OE8j.d.ts +0 -43
  1607. package/dist/signers-ZmxO1I05.d.ts +0 -390
  1608. package/dist/signing-keys-CWtpMask.js +0 -164
  1609. package/dist/signing-keys-udgP7Aod.d.ts +0 -119
  1610. package/dist/simplify-DDO0j0LI.js +0 -83
  1611. package/dist/spec-BMvCCNnd.js +0 -124
  1612. package/dist/spec-pins-BZkKfwY8.d.ts +0 -127
  1613. package/dist/spec-pins-D3zDek-u.js +0 -62
  1614. package/dist/sql-CYt7EhH0.js +0 -421
  1615. package/dist/sql-CyeDg3Yh.js +0 -138146
  1616. package/dist/sql-type-iUSZpaUu.js +0 -34
  1617. package/dist/sso-CkU_4mtK.d.ts +0 -161
  1618. package/dist/sso-DdDpJQzw.js +0 -217
  1619. package/dist/standard-BA3mLh6w.js +0 -25
  1620. package/dist/standard-DBV730sF.d.ts +0 -7
  1621. package/dist/stats-BHl1-zj9.js +0 -83
  1622. package/dist/statuses-Alll5Ip6.js +0 -29
  1623. package/dist/statuses-zRcc2TeZ.js +0 -28
  1624. package/dist/storage-api-Dg78Wqsg.js +0 -10
  1625. package/dist/store-CpheI-lN.d.ts +0 -83
  1626. package/dist/store-McN-2esd.js +0 -69
  1627. package/dist/stripe-BJUfp5jM.js +0 -32
  1628. package/dist/stripe-X22LjuH-.d.ts +0 -156
  1629. package/dist/subject-readers-CB5Te02u.d.ts +0 -21
  1630. package/dist/subject-readers-VHcrWhmq.js +0 -49
  1631. package/dist/subject-type-BRnK7Av3.js +0 -8
  1632. package/dist/subjects-BYCL-6hA.d.ts +0 -145
  1633. package/dist/subjects-CiBNKy2y.d.ts +0 -90
  1634. package/dist/subscribers-BvZxcd63.js +0 -33
  1635. package/dist/summaries-8jQTELIX.d.ts +0 -69
  1636. package/dist/supabase-mcp-Dz9DgrKP.js +0 -28
  1637. package/dist/supabase-mcp-Z4vtsuoO.d.ts +0 -46
  1638. package/dist/support-BxyPOFk4.d.ts +0 -357
  1639. package/dist/support-view-g4YLBeqX.js +0 -18
  1640. package/dist/support-view-nqUWKHEs.d.ts +0 -17
  1641. package/dist/table-schema-BlF6k62Q.d.ts +0 -81
  1642. package/dist/table-schema-C80xItaV.js +0 -293
  1643. package/dist/tables-Cb-3_VWc.js +0 -73
  1644. package/dist/tags-CIZTqtlY.js +0 -39
  1645. package/dist/tags-Cm48BsOa.d.ts +0 -30
  1646. package/dist/tax-BkCNWWMc.js +0 -140
  1647. package/dist/tax-DPShHual.d.ts +0 -170
  1648. package/dist/tee-V97_v1ZS.js +0 -101
  1649. package/dist/template-Drgg3v2J.js +0 -126
  1650. package/dist/temporal-Dbo0fLzc.js +0 -95
  1651. package/dist/temporal-required-DcLhnDhQ.js +0 -20
  1652. package/dist/tenant-BgIiMQpo.js +0 -27
  1653. package/dist/tenant-C9YE_kqK.d.ts +0 -17
  1654. package/dist/tenant-source-bqWpSr86.js +0 -8
  1655. package/dist/timeline--VU3A1e4.js +0 -50
  1656. package/dist/timeline-DvXtXq5q.d.ts +0 -151
  1657. package/dist/timing-dypS0nxW.js +0 -95
  1658. package/dist/topic-DnsNG4Kj.js +0 -643
  1659. package/dist/topic-breZqx_4.d.ts +0 -415
  1660. package/dist/ttl-cache-Bhr9swjT.js +0 -32
  1661. package/dist/types-B-D6fYx2.d.ts +0 -194
  1662. package/dist/types-C3I7S51U.d.ts +0 -461
  1663. package/dist/types-CK2X2wCB.d.ts +0 -618
  1664. package/dist/types-CPl9uJ0G.d.ts +0 -912
  1665. package/dist/types-CwQgFo8c.d.ts +0 -177
  1666. package/dist/types-DMihLukJ.d.ts +0 -251
  1667. package/dist/types-R6syp1el.js +0 -29
  1668. package/dist/types-iCyZ3lMx.d.ts +0 -217
  1669. package/dist/types-nspa5I-a.d.ts +0 -664
  1670. package/dist/undo-0HkWXASn.d.ts +0 -46
  1671. package/dist/undo-BbftL9-4.js +0 -44
  1672. package/dist/upload-claim-B1ZU8ydB.js +0 -33
  1673. package/dist/usage-BkWAPkg2.d.ts +0 -232
  1674. package/dist/user-change-DgWC6RRC.js +0 -135
  1675. package/dist/variants-Cy--Ub-a.js +0 -53
  1676. package/dist/vault-BkdPmL7f.d.ts +0 -62
  1677. package/dist/verify-41mZmspj.d.ts +0 -146
  1678. package/dist/verify-7EucfCnv.js +0 -130
  1679. package/dist/view-C8Ve14ja.js +0 -247
  1680. package/dist/view-C8_xvD-j.d.ts +0 -97
  1681. package/dist/watch-topic-CuaWfCuv.js +0 -57
  1682. package/dist/watch-topic-ItO3dz8m.d.ts +0 -31
  1683. package/dist/wire-ChYn1g21.js +0 -91
  1684. package/dist/wiring-CDNuQoJJ.js +0 -13
  1685. package/dist/workflow-sdk-BWPsdzVK.js +0 -2534
  1686. package/dist/workflow-sdk-Cf0LAOFF.js +0 -242
  1687. package/dist/workflow-sdk-rg3IbCZC.d.ts +0 -163
  1688. package/dist/workflows-xL6t0TXx.d.ts +0 -258
@@ -0,0 +1,2749 @@
1
+ import { a as sqlString, i as sqlIdent } from "./template-CNq9xcfx.js";
2
+ import "./batch-limit-DqQ3d6op.js";
3
+ // src/sql/shared.ts
4
+ /**
5
+ * What `record` and the other statement helpers return when there is nothing to
6
+ * do.
7
+ */
8
+ const NOTHING = "null;";
9
+ /**
10
+ * `alter table ... add column if not exists` for each extra column of a managed
11
+ * table.
12
+ */
13
+ const addExtraColumns = (table, columns) => columns.map((column) => `\nalter table ${table} add column if not exists ${column.ident} ${column.type};`).join("");
14
+ /**
15
+ * A `jsonb` object of `columns` of row `alias`, keyed by column name, so reads
16
+ * return extra columns without exposing the rest of the row.
17
+ */
18
+ const columnsObject = (alias, columns) => `jsonb_build_object(${columns.map((name) => `${sqlString(name)}, ${alias}.${sqlIdent(name)}`).join(", ")})`;
19
+ /**
20
+ * `, 'fields', jsonb_build_object(...)` of the extra columns of row `alias`,
21
+ * for a read built with `jsonb_build_object`; empty without any.
22
+ */
23
+ const extraFieldsJson = (alias, extras) => extras.length === 0 ? "" : `, 'fields', ${columnsObject(alias, extras.map((extra) => extra.name))}`;
24
+ /**
25
+ * PL/pgSQL that copies the extra columns from `source`, a `jsonb` object keyed
26
+ * by column name, onto the rows of `table` (alias `x`) that `where` matches. A
27
+ * key `source` leaves out keeps the column's value, so it runs after an insert
28
+ * (the defaults stay) and on a partial update. Empty without extra columns.
29
+ */
30
+ const writeExtraColumns = (table, extras, source, where, into) => extras.length === 0 ? "" : `
31
+ update ${table} x set ${extras.map((extra) => `${extra.ident} = case when ${source} ? ${sqlString(extra.name)} then r.${extra.ident} else x.${extra.ident} end`).join(", ")}
32
+ from jsonb_populate_record(null::${table}, (select coalesce(jsonb_object_agg(e.key, e.value), '{}') from jsonb_each(${source}) e where e.key in (${extras.map((extra) => sqlString(extra.name)).join(", ")}))) r
33
+ where ${where}${into === void 0 ? "" : `\n returning x.* into ${into}`};`;
34
+ /**
35
+ * The `default` expression of an `extraColumns` type, such as `'en'` in `text
36
+ * not null default 'en'`, or undefined without one.
37
+ */
38
+ function extraColumnDefault(type) {
39
+ let quoted = false;
40
+ let depth = 0;
41
+ let start;
42
+ for (let index = 0; index < type.length; index += 1) {
43
+ const char = type.charAt(index);
44
+ if (char === "'") quoted = !quoted;
45
+ if (quoted) continue;
46
+ depth += char === "(" ? 1 : char === ")" ? -1 : 0;
47
+ if (depth !== 0 || !/\s/u.test(type.charAt(index - 1) || " ")) continue;
48
+ const rest = type.slice(index);
49
+ if (start === void 0) {
50
+ const match = /^default\s+/iu.exec(rest);
51
+ start = match === null ? void 0 : index + match[0].length;
52
+ } else if (CONSTRAINT_WORD.test(rest)) return type.slice(start, index).trim();
53
+ }
54
+ return start === void 0 ? void 0 : type.slice(start).trim();
55
+ }
56
+ const CONSTRAINT_WORD = /^(?:not\s+null|null|check|references|unique|primary\s+key|constraint|generated|collate)\b/iu;
57
+ /**
58
+ * The extra columns an insert sets itself: every one, read from `source` (a
59
+ * `jsonb` object keyed by column name), and the column's `default` when
60
+ * `source` leaves its key out. Writing them in the insert keeps a check across
61
+ * columns, or a `not null` column without a default, from failing before the
62
+ * update `writeExtraColumns` runs. `columns` and `values` are `, a, b` lists
63
+ * for the insert; both are empty without extra columns.
64
+ */
65
+ const insertExtraColumns = (table, extras, source) => {
66
+ const value = (extra) => {
67
+ const read = `(jsonb_populate_record(null::${table}, jsonb_build_object(${sqlString(extra.name)}, ${source} -> ${sqlString(extra.name)}))).${extra.ident}`;
68
+ const fallback = extraColumnDefault(extra.type);
69
+ return fallback === void 0 ? read : `case when ${source} ? ${sqlString(extra.name)} then ${read} else ${fallback} end`;
70
+ };
71
+ return {
72
+ columns: extras.map((extra) => `, ${extra.ident}`).join(""),
73
+ values: extras.map((extra) => `, ${value(extra)}`).join("")
74
+ };
75
+ };
76
+ /**
77
+ * `json` (a `jsonb` expression of row `alias`) with the extra columns under
78
+ * `fields`, or `json` itself without any.
79
+ */
80
+ const withExtraFields = (json, alias, extras) => extras.length === 0 ? json : `(${json} || jsonb_build_object('fields', ${columnsObject(alias, extras.map((extra) => extra.name))}))`;
81
+ /** The `fields jsonb` parameter for `columns`; see `ExtraFieldsArg`. */
82
+ function extraFieldsArg(columns) {
83
+ const on = columns.length > 0;
84
+ return {
85
+ param: on ? ", fields jsonb default null" : "",
86
+ type: on ? ", jsonb" : "",
87
+ contract: on ? ["jsonb"] : [],
88
+ drop: (fn, types) => `drop function if exists ${fn}(${on ? types : [types, "jsonb"].filter((type) => type !== "").join(", ")});`
89
+ };
90
+ }
91
+ /** Takes the default grants on later objects in a schema from every client role. */
92
+ const revokeDefaults = (schema) => `alter default privileges in schema ${schema} revoke all on tables from public, anon, authenticated;
93
+ alter default privileges in schema ${schema} revoke all on sequences from public, anon, authenticated;
94
+ alter default privileges in schema ${schema} revoke all on functions from public, anon, authenticated;`;
95
+ const SCHEMA = `create schema if not exists better_supabase;
96
+ grant usage on schema better_supabase to anon, authenticated, service_role;`;
97
+ /**
98
+ * A SQL condition true for the service role and for a direct admin connection
99
+ * (no JWT, a privileged session user), which may act for others.
100
+ */
101
+ const SERVICE_CALLER = "coalesce(nullif((select auth.jwt()) ->> 'role', ''), session_user::text) in ('service_role', 'postgres', 'supabase_admin')";
102
+ /**
103
+ * The `organization.member_added` record for a module that adds a member, so
104
+ * every module writes the same payload. Each value is a SQL expression.
105
+ */
106
+ function memberAddedRecord(ctx, member) {
107
+ return ctx.record({
108
+ type: "organization.member_added",
109
+ payload: `jsonb_build_object('organizationId', ${member.tenant}::text, 'userId', ${member.user}, 'role', ${member.role})`,
110
+ subject: `'organizations/' || ${member.tenant}::text`,
111
+ tenant: member.tenant,
112
+ audit: {
113
+ category: "membership",
114
+ targetType: "user",
115
+ recordId: `${member.user}::text`
116
+ }
117
+ });
118
+ }
119
+ /**
120
+ * Creates the module's schema when it isn't `better_supabase`, then the module
121
+ * schema.
122
+ */
123
+ function schemaPreamble(ctx) {
124
+ if (ctx.schemaName === "better_supabase") return SCHEMA;
125
+ return `${SCHEMA}
126
+ create schema if not exists ${ctx.schema};
127
+ grant usage on schema ${ctx.schema} to anon, authenticated, service_role;
128
+ ${revokeDefaults(ctx.schema)}`;
129
+ }
130
+ /** A claim from the top level of the token, then `app_metadata`. */
131
+ function jwtClaim(name) {
132
+ return `coalesce(auth.jwt() ->> ${sqlString(name)}, auth.jwt() -> 'app_metadata' ->> ${sqlString(name)})`;
133
+ }
134
+ /** `table` or `schema.table` as `[schema, table]`, in `public` without a schema. */
135
+ function splitTable(name) {
136
+ const parts = name.split(".");
137
+ if (parts.length > 2 || parts.some((part) => part.length === 0)) throw new TypeError(`"${name}" must be "table" or "schema.table"`);
138
+ return parts.length === 2 ? [parts[0], parts[1]] : ["public", parts[0]];
139
+ }
140
+ /** `table` or `schema.table`, quoted. */
141
+ function quotedTable(name) {
142
+ const [schema, table] = splitTable(name);
143
+ return `${sqlIdent(schema)}.${sqlIdent(table)}`;
144
+ }
145
+ /** `schema.table.column` split into its quoted table and column. */
146
+ function columnRef(where, value) {
147
+ const parts = value.split(".");
148
+ if (parts.length !== 3 || parts.some((part) => part.length === 0)) throw new TypeError(`${where} must be "schema.table.column", got "${value}"`);
149
+ const [schema, table, column] = parts;
150
+ return {
151
+ table: `${sqlIdent(schema)}.${sqlIdent(table)}`,
152
+ column: sqlIdent(column)
153
+ };
154
+ }
155
+ const QUOTED_IDENT = /^"(.*)"$/s;
156
+ /**
157
+ * Replaces the check constraints on one column of a table a module created
158
+ * earlier: `create table if not exists` never changes an inline check, and its
159
+ * generated name follows the table's configured name. For upgrade steps.
160
+ * `column` is a quoted identifier; the catalog stores the bare name.
161
+ */
162
+ function replaceColumnCheck(check) {
163
+ const column = QUOTED_IDENT.exec(check.column)?.[1]?.replaceAll("\"\"", "\"") ?? check.column;
164
+ return `do $$
165
+ declare
166
+ v_name name;
167
+ begin
168
+ for v_name in
169
+ select c.conname from pg_catalog.pg_constraint c
170
+ join pg_catalog.pg_attribute a on a.attrelid = c.conrelid and a.attnum = c.conkey[1]
171
+ where c.conrelid = ${sqlString(check.table)}::regclass and c.contype = 'c'
172
+ and cardinality(c.conkey) = 1 and a.attname = ${sqlString(column)}
173
+ loop
174
+ execute format('alter table %s drop constraint %I', ${sqlString(check.table)}, v_name);
175
+ end loop;
176
+ end;
177
+ $$;
178
+ alter table ${check.table} add constraint ${sqlIdent(check.name)} check (${check.expression});`;
179
+ }
180
+ /**
181
+ * Adds a foreign key to a table a module created earlier, once: `create table
182
+ * if not exists` can't add it to a table that already exists, and the
183
+ * referenced table can come from a module that renders later. Existing rows
184
+ * without a match leave the key unvalidated, with a warning.
185
+ */
186
+ function addForeignKey(fk) {
187
+ return `do $$
188
+ begin
189
+ if not exists (
190
+ select 1 from pg_constraint
191
+ where conrelid = ${sqlString(fk.table)}::regclass and conname = ${sqlString(fk.name)}
192
+ ) then
193
+ alter table ${fk.table} add constraint ${sqlIdent(fk.name)}
194
+ foreign key (${fk.column}) references ${fk.references} on delete ${fk.onDelete} not valid;
195
+ begin
196
+ alter table ${fk.table} validate constraint ${sqlIdent(fk.name)};
197
+ exception when foreign_key_violation then
198
+ raise warning '% has rows without a match, so only new rows are checked. Delete them, then run: alter table % validate constraint %',
199
+ ${sqlString(fk.table)}, ${sqlString(fk.table)}, ${sqlString(fk.name)};
200
+ end;
201
+ end if;
202
+ end;
203
+ $$;`;
204
+ }
205
+ /**
206
+ * Adds a check constraint to a table a module created earlier, once, for the
207
+ * same reason as `addForeignKey`. Existing rows that fail it leave the check
208
+ * unvalidated, with a warning, so an upgrade never stops on old data.
209
+ */
210
+ function addCheck(check) {
211
+ return `do $$
212
+ begin
213
+ if not exists (
214
+ select 1 from pg_constraint
215
+ where conrelid = ${sqlString(check.table)}::regclass and conname = ${sqlString(check.name)}
216
+ ) then
217
+ alter table ${check.table} add constraint ${sqlIdent(check.name)}
218
+ check (${check.expression}) not valid;
219
+ begin
220
+ alter table ${check.table} validate constraint ${sqlIdent(check.name)};
221
+ exception when check_violation then
222
+ raise warning '% has rows that fail %, so only new rows are checked. Fix them, then run: alter table % validate constraint %',
223
+ ${sqlString(check.table)}, ${sqlString(check.name)}, ${sqlString(check.table)}, ${sqlString(check.name)};
224
+ end;
225
+ end if;
226
+ end;
227
+ $$;`;
228
+ }
229
+ const lastName = (name) => (name.match(/"(?:[^"]|"")*"|[^."]+/gu)?.at(-1) ?? name).replace(/^"(.*)"$/su, "$1").replaceAll("\"\"", "\"");
230
+ /**
231
+ * The name `addNotNullCheck` gives the check on `column` of `table`, both
232
+ * quoted or bare, the table with or without its schema:
233
+ * `<table>_<column>_not_null`, shortened with a hash past 63 bytes.
234
+ */
235
+ function notNullCheckName(table, column) {
236
+ const name = `${lastName(table)}_${lastName(column)}_not_null`;
237
+ return name.length <= 63 ? name : `${name.slice(0, 54)}_${shortHash(name)}`;
238
+ }
239
+ /**
240
+ * The expand step for a column added nullable to a table that already has rows:
241
+ * adds `check (<column> is not null) not valid` once, without scanning the
242
+ * table. Postgres checks it on every insert and update from then on, so add it
243
+ * after `better-supabase db backfill` filled the column, or updates to rows
244
+ * that are still null fail. `doctor --fix` validates it once no row is null
245
+ * (BS236), and then `set not null` needs no scan. `table` and `column` are
246
+ * quoted identifiers, the table schema-qualified.
247
+ */
248
+ function addNotNullCheck(check) {
249
+ const name = check.name ?? notNullCheckName(check.table, check.column);
250
+ return `do $$
251
+ begin
252
+ if not exists (
253
+ select 1 from pg_constraint
254
+ where conrelid = ${sqlString(check.table)}::regclass and conname = ${sqlString(name)}
255
+ ) then
256
+ alter table ${check.table} add constraint ${sqlIdent(name)}
257
+ check (${check.column} is not null) not valid;
258
+ end if;
259
+ end;
260
+ $$;`;
261
+ }
262
+ /**
263
+ * An `updated_at` column on a managed table, kept current by the `updated-at`
264
+ * module's `set_updated_at()` (the module must require it).
265
+ */
266
+ function updatedAt(table, column) {
267
+ return `alter table ${table} add column if not exists ${column} timestamptz not null default now();
268
+ drop trigger if exists bsb_updated_at on ${table};
269
+ create trigger bsb_updated_at before update on ${table}
270
+ for each row execute function better_supabase.set_updated_at(${sqlString(column.replaceAll("\"", ""))});`;
271
+ }
272
+ function renameSql(renames) {
273
+ const schema = sqlString(renames.schema);
274
+ const q = (name) => `${sqlIdent(renames.schema)}.${sqlIdent(name)}`;
275
+ const lines = [];
276
+ let table = renames.table;
277
+ for (const [from, to] of renames.tables ?? []) {
278
+ lines.push(` if to_regclass(${sqlString(`${renames.schema}.${from}`)}) is not null
279
+ and (select c.relkind from pg_class c where c.oid = to_regclass(${sqlString(`${renames.schema}.${from}`)})) in ('r', 'p')
280
+ and to_regclass(${sqlString(`${renames.schema}.${to}`)}) is null then
281
+ alter table ${q(from)} rename to ${sqlIdent(to)};
282
+ end if;`);
283
+ if (from === table) table = to;
284
+ }
285
+ for (const [from, to] of renames.columns ?? []) lines.push(` if exists (select 1 from information_schema.columns c
286
+ where c.table_schema = ${schema} and c.table_name = ${sqlString(table)} and c.column_name = ${sqlString(from)})
287
+ and not exists (select 1 from information_schema.columns c
288
+ where c.table_schema = ${schema} and c.table_name = ${sqlString(table)} and c.column_name = ${sqlString(to)}) then
289
+ alter table ${q(table)} rename column ${sqlIdent(from)} to ${sqlIdent(to)};
290
+ end if;`);
291
+ for (const [from, to] of renames.indexes ?? []) lines.push(` if to_regclass(${sqlString(`${renames.schema}.${from}`)}) is not null
292
+ and to_regclass(${sqlString(`${renames.schema}.${to}`)}) is null then
293
+ alter index ${q(from)} rename to ${sqlIdent(to)};
294
+ end if;`);
295
+ for (const [from, to, args] of renames.functions ?? []) lines.push(` if to_regprocedure(${sqlString(`${renames.schema}.${from}(${args})`)}) is not null
296
+ and to_regprocedure(${sqlString(`${renames.schema}.${to}(${args})`)}) is null then
297
+ alter function ${q(from)}(${args}) rename to ${sqlIdent(to)};
298
+ end if;`);
299
+ if (lines.length === 0) return "";
300
+ return `do $$
301
+ begin
302
+ ${lines.join("\n")}
303
+ end;
304
+ $$;`;
305
+ }
306
+ /**
307
+ * A SQL condition true when `organization` names no row of the installed
308
+ * organizations table. False without the organizations module.
309
+ */
310
+ function organizationMissing(ctx, organization) {
311
+ if (!ctx.installed("organizations")) return "false";
312
+ const organizations = ctx.of("organizations");
313
+ return `not exists (select 1 from ${organizations.table("organizations")} o where o.${organizations.col("organizations", "id")} = ${organization})`;
314
+ }
315
+ function membershipDisabledAt(ctx) {
316
+ if (ctx.module !== "memberships" && !ctx.installed("memberships")) return;
317
+ const tenant = ctx.module === "memberships" ? ctx : ctx.of("memberships");
318
+ if (!tenant.has("memberships", "disabledAt")) return;
319
+ if (!tenant.owns("memberships") && typeof tenant.config.columns["memberships"]?.["disabledAt"] !== "string") return;
320
+ return tenant.col("memberships", "disabledAt");
321
+ }
322
+ function activeMembership(ctx, alias) {
323
+ const column = membershipDisabledAt(ctx);
324
+ return column === void 0 ? "" : ` and ${alias}.${column} is null`;
325
+ }
326
+ function membershipSuspended(ctx, tenant, user) {
327
+ const column = membershipDisabledAt(ctx);
328
+ if (column === void 0) return;
329
+ const t = ctx.module === "memberships" ? ctx : ctx.of("memberships");
330
+ return `exists (select 1 from ${t.table("memberships")} sm where sm.${t.col("memberships", "tenant")} = ${tenant} and sm.${t.col("memberships", "user")} = ${user} and sm.${column} is not null)`;
331
+ }
332
+ /**
333
+ * `tenant_disabled(id)` and `user_disabled(uuid)` from
334
+ * `blocks.permissions.disabled`. Without a column they return false, so callers
335
+ * don't need to know whether it is configured.
336
+ */
337
+ function disabledHelpers(ctx) {
338
+ const disabled = ctx.modules.permissions?.disabled ?? {};
339
+ const id = ctx.idType;
340
+ const organizations = managedOrganizations(ctx);
341
+ let tenantCheck = "false";
342
+ if (disabled.tenant !== void 0) tenantCheck = disabledCheck("blocks.permissions.disabled.tenant", disabled.tenant, {
343
+ key: "\"id\"",
344
+ alias: "t",
345
+ value: "tenant_disabled.tenant"
346
+ });
347
+ else if (organizations) tenantCheck = `exists (select 1 from ${organizations.table} t where t.${organizations.id} = tenant_disabled.tenant and (${organizations.flags.map((column) => `t.${column} is not null`).join(" or ")}))`;
348
+ const userCheck = disabled.user === void 0 ? "false" : disabledCheck("blocks.permissions.disabled.user", disabled.user, {
349
+ key: sqlIdent(disabled.userKey ?? "id"),
350
+ alias: "u",
351
+ value: "user_disabled.user_id"
352
+ });
353
+ return `
354
+ -- Disabled tenants and users get no permissions and no membership claims
355
+ -- (blocks.permissions.disabled; with the managed organizations module, its
356
+ -- disabled_at and deleted_at columns).
357
+ create or replace function better_supabase.tenant_disabled(tenant ${id})
358
+ returns boolean
359
+ language sql
360
+ stable
361
+ security definer
362
+ set search_path = ''
363
+ as $$
364
+ select ${tenantCheck}
365
+ $$;
366
+
367
+ create or replace function better_supabase.user_disabled(user_id uuid)
368
+ returns boolean
369
+ language sql
370
+ stable
371
+ security definer
372
+ set search_path = ''
373
+ as $$
374
+ select ${userCheck}
375
+ $$;
376
+
377
+ revoke execute on function better_supabase.tenant_disabled(${id}) from public, anon, authenticated;
378
+ revoke execute on function better_supabase.user_disabled(uuid) from public, anon, authenticated;
379
+ grant execute on function better_supabase.tenant_disabled(${id}) to service_role, supabase_auth_admin;
380
+ grant execute on function better_supabase.user_disabled(uuid) to service_role, supabase_auth_admin;`;
381
+ }
382
+ /**
383
+ * Whether `disabledHelpers` reads the managed organizations table, which a
384
+ * later file creates: the caller turns `check_function_bodies` off around it.
385
+ */
386
+ /**
387
+ * The condition that `value` is disabled: a set column (`schema.table.column`,
388
+ * matched on `key`), or no active row (an authorization provider's suspension
389
+ * row, where a missing row counts as disabled).
390
+ */
391
+ function disabledCheck(where, config, match) {
392
+ const { alias: d, value } = match;
393
+ if (typeof config === "string") {
394
+ const ref = columnRef(where, config);
395
+ return `exists (select 1 from ${ref.table} ${d} where ${d}.${match.key} = ${value} and ${d}.${ref.column} is not null)`;
396
+ }
397
+ const parts = config.table.split(".");
398
+ if (parts.length !== 2 || parts.some((part) => part.length === 0)) throw new TypeError(`${where}.table must be "schema.table", got "${config.table}"`);
399
+ const active = [`${d}.${sqlIdent(config.id)} = ${value}`];
400
+ if (config.disabledAt !== void 0) active.push(`${d}.${sqlIdent(config.disabledAt)} is null`);
401
+ if (config.status !== void 0) {
402
+ if (!config.active || config.active.length === 0) throw new TypeError(`${where}.status needs the active values in active`);
403
+ active.push(`${d}.${sqlIdent(config.status)}::text in (${config.active.map(sqlString).join(", ")})`);
404
+ }
405
+ if (config.disabledAt === void 0 && config.status === void 0) throw new TypeError(`${where} needs disabledAt, status or both`);
406
+ return `not exists (select 1 from ${parts.map((part) => sqlIdent(part)).join(".")} ${d} where ${active.join(" and ")})`;
407
+ }
408
+ /**
409
+ * Whether the `access` module's file defines `tenant_disabled` and
410
+ * `user_disabled`: it does whenever it is installed (or configured) outside
411
+ * custom mode, and the `tenant` module's file then leaves them out, so each
412
+ * function is defined in one file.
413
+ */
414
+ function accessDefinesDisabledHelpers(ctx) {
415
+ const access = ctx.modules.permissions;
416
+ if (!ctx.installed("permissions") && access === void 0) return false;
417
+ return (access?.mode ?? "managed") !== "custom";
418
+ }
419
+ function disabledHelpersNeedLaterTables(ctx) {
420
+ return !ctx.modules.permissions?.disabled?.tenant && managedOrganizations(ctx) !== void 0;
421
+ }
422
+ /**
423
+ * The managed organizations table and its disabling columns, when installed and
424
+ * managed.
425
+ */
426
+ function managedOrganizations(ctx) {
427
+ if (!ctx.installed("organizations")) return;
428
+ const organizations = ctx.of("organizations");
429
+ if (!organizations.owns("organizations")) return;
430
+ const flags = ["disabledAt", "deletedAt"].filter((logical) => organizations.has("organizations", logical)).map((logical) => organizations.col("organizations", logical));
431
+ if (flags.length === 0) return;
432
+ return {
433
+ table: organizations.table("organizations"),
434
+ id: organizations.col("organizations", "id"),
435
+ flags
436
+ };
437
+ }
438
+ /**
439
+ * Another row trigger on `target` whose function name matches `pattern` does
440
+ * the module trigger's job twice. `track_*` warns about it, or drops it with
441
+ * `replace_trigger => true`.
442
+ */
443
+ const EQUIVALENT_TRIGGERS = `
444
+ create or replace function better_supabase.replace_equivalent_triggers(
445
+ target regclass,
446
+ module_trigger text,
447
+ pattern text,
448
+ replace_trigger boolean
449
+ )
450
+ returns void
451
+ language plpgsql
452
+ set search_path = ''
453
+ as $$
454
+ declare
455
+ found record;
456
+ begin
457
+ for found in
458
+ select t.tgname as name, p.proname as fn
459
+ from pg_catalog.pg_trigger t
460
+ join pg_catalog.pg_proc p on p.oid = t.tgfoid
461
+ where t.tgrelid = replace_equivalent_triggers.target
462
+ and not t.tgisinternal
463
+ and t.tgname <> replace_equivalent_triggers.module_trigger
464
+ and p.proname ~* replace_equivalent_triggers.pattern
465
+ loop
466
+ if replace_trigger then
467
+ execute format('drop trigger %I on %s', found.name, target);
468
+ else
469
+ raise warning '% already has trigger % (%), which does what % does. Pass replace_trigger => true to drop it.',
470
+ target, found.name, found.fn, module_trigger;
471
+ end if;
472
+ end loop;
473
+ end;
474
+ $$;
475
+ revoke execute on function better_supabase.replace_equivalent_triggers(regclass, text, text, boolean) from public, anon, authenticated;`;
476
+ /** FNV-1a, as 8 hex digits: a stable suffix that keeps two names apart. */
477
+ function shortHash(text) {
478
+ let hash = 2166136261;
479
+ for (let index = 0; index < text.length; index += 1) {
480
+ hash ^= text.codePointAt(index) ?? 0;
481
+ hash = Math.imul(hash, 16777619) >>> 0;
482
+ }
483
+ return hash.toString(16).padStart(8, "0");
484
+ }
485
+ /**
486
+ * Adds CHECK `name` on `table` (quoted) unless a re-run finds it already
487
+ * checking `expression`: the constraint comment records a hash of the
488
+ * expression, so an unchanged check skips the table scan under ACCESS
489
+ * EXCLUSIVE. `notValid` leaves existing rows unchecked.
490
+ */
491
+ function ensureCheck(table, name, expression, options = {}) {
492
+ const marker = sqlString(`better-supabase check ${shortHash(`${expression}|${options.notValid === true}`)}`);
493
+ const constraint = sqlIdent(name);
494
+ return `do $$
495
+ begin
496
+ if coalesce(obj_description((
497
+ select c.oid from pg_catalog.pg_constraint c
498
+ where c.conrelid = ${sqlString(table)}::regclass and c.conname = ${sqlString(name)}
499
+ ), 'pg_constraint'), '') <> ${marker} then
500
+ alter table ${table} drop constraint if exists ${constraint};
501
+ alter table ${table} add constraint ${constraint} check (${expression})${options.notValid === true ? " not valid" : ""};
502
+ comment on constraint ${constraint} on ${table} is ${marker};
503
+ end if;
504
+ end;
505
+ $$;`;
506
+ }
507
+ /**
508
+ * The constraint and trigger name of a check. A key that sanitizing or the
509
+ * 63-byte limit would change (`notify.email`, `notify-email`, a long key) gets
510
+ * a hash of the key, so two keys never share a name and drop each other's
511
+ * check.
512
+ */
513
+ function jsonCheckName(check) {
514
+ const base = `bsb_json_${check.column}`;
515
+ if (!check.where) return base.slice(0, 63);
516
+ const key = check.where.value;
517
+ const clean = key.replaceAll(/[^a-z0-9_]/gi, "_");
518
+ const plain = `${base}_${clean}`;
519
+ if (clean === key && plain.length <= 63) return plain;
520
+ return `${plain.slice(0, 54)}_${shortHash(key)}`;
521
+ }
522
+ function jsonSchemaChecks(checks) {
523
+ if (checks.length === 0) return "";
524
+ return `\n-- config.json schemas
525
+ -- Each check is added not valid and validated separately. On a large table,
526
+ -- move the validate statements to a later migration: adding a not valid check
527
+ -- blocks writes only briefly, and validating takes a lock that lets writes
528
+ -- continue. The trigger of the same name reports which part of the schema failed.
529
+ ${checks.map((check) => {
530
+ const target = quotedTable(check.table);
531
+ const name = sqlIdent(jsonCheckName(check));
532
+ const schemaText = sqlString(JSON.stringify(check.schema));
533
+ const matches = `extensions.jsonb_matches_schema(${schemaText}::json, ${sqlIdent(check.column)})`;
534
+ const columns = check.where ? `${sqlIdent(check.column)}, ${sqlIdent(check.where.column)}` : sqlIdent(check.column);
535
+ const args = [
536
+ sqlString(check.column),
537
+ schemaText,
538
+ ...check.where ? [sqlString(check.where.column), sqlString(check.where.value)] : []
539
+ ].join(", ");
540
+ return [
541
+ `alter table ${target} drop constraint if exists ${name};`,
542
+ `alter table ${target} add constraint ${name}`,
543
+ ` check (${check.where ? `${sqlIdent(check.where.column)} <> ${sqlString(check.where.value)} or ` : ""}${matches}) not valid;`,
544
+ `alter table ${target} validate constraint ${name};`,
545
+ `drop trigger if exists ${name} on ${target};`,
546
+ `create trigger ${name} before insert or update of ${columns} on ${target}`,
547
+ ` for each row execute function better_supabase.check_json_schema(${args});`
548
+ ].join("\n");
549
+ }).join("\n\n")}\n`;
550
+ }
551
+ /** SQL that takes every privilege on a table from `anon` and `authenticated`. */
552
+ const revokeTable = (table) => `revoke all on ${table} from public, anon, authenticated;`;
553
+ /**
554
+ * One policy per command for rows `authenticated` owns. A permissive `for all`
555
+ * policy would also grant writes on its own, so the read-only actor check
556
+ * (which wraps only insert, update and delete policies) could never refuse
557
+ * them. `legacy` is the name of the `for all` policy this replaces.
558
+ */
559
+ function ownRowPolicies(options) {
560
+ const { table, legacy, name, using, check } = options;
561
+ const create = (command, body) => `drop policy if exists ${sqlIdent(name(command))} on ${table};
562
+ create policy ${sqlIdent(name(command))} on ${table} ${body};`;
563
+ return [
564
+ `drop policy if exists ${sqlIdent(legacy)} on ${table};`,
565
+ create("read", `for select to authenticated using (${using})`),
566
+ create("insert", `for insert to authenticated with check (${check})`),
567
+ create("update", `for update to authenticated using (${using}) with check (${check})`),
568
+ create("delete", `for delete to authenticated using (${using})`)
569
+ ].join("\n");
570
+ }
571
+ /**
572
+ * SQL that turns on RLS for a table the module manages, takes it from `anon`
573
+ * and `authenticated` and gives it to the service role. `read` grants `select`
574
+ * back to `authenticated`, for tables its policies expose.
575
+ */
576
+ const lockTable = (table, options = {}) => `alter table ${table} enable row level security;
577
+ ${revokeTable(table)}
578
+ ${options.read ? `grant select on ${table} to authenticated;\n` : ""}grant all on ${table} to service_role;`;
579
+ /**
580
+ * Monthly range partitions for any table created `partition by range` on a
581
+ * timestamptz column: a registry, `ensure_partitions(parent, months_ahead)`,
582
+ * which creates `<parent>_pYYYYMM` for this month and the next ones (UTC
583
+ * bounds) with RLS on and the client roles revoked, `maintain_partitions()` for
584
+ * every registered table, and `expired_partitions(parent, cutoff)`, the
585
+ * partitions wholly before `cutoff`. A table that isn't partitioned (one
586
+ * created before the option) is left alone.
587
+ */
588
+ const MONTHLY_PARTITIONS = `create table if not exists better_supabase.partitioned_tables (
589
+ parent regclass primary key,
590
+ months_ahead integer not null default 3 check (months_ahead between 1 and 24)
591
+ );
592
+ ${lockTable("better_supabase.partitioned_tables")}
593
+
594
+ create or replace function better_supabase.ensure_partitions(parent regclass, months_ahead integer default 3)
595
+ returns integer
596
+ language plpgsql
597
+ security definer
598
+ set search_path = ''
599
+ as $$
600
+ declare
601
+ v_schema text;
602
+ v_name text;
603
+ v_month timestamp := date_trunc('month', now() at time zone 'UTC');
604
+ v_part text;
605
+ v_made integer := 0;
606
+ begin
607
+ select n.nspname, c.relname into v_schema, v_name
608
+ from pg_catalog.pg_class c join pg_catalog.pg_namespace n on n.oid = c.relnamespace
609
+ where c.oid = parent and c.relkind = 'p';
610
+ if v_name is null then
611
+ return 0;
612
+ end if;
613
+ for i in 0..months_ahead loop
614
+ v_part := v_name || '_p' || to_char(v_month + make_interval(months => i), 'YYYYMM');
615
+ continue when pg_catalog.to_regclass(format('%I.%I', v_schema, v_part)) is not null;
616
+ begin
617
+ execute format(
618
+ 'create table %I.%I partition of %s for values from (%L) to (%L)',
619
+ v_schema, v_part, parent,
620
+ (v_month + make_interval(months => i)) at time zone 'UTC',
621
+ (v_month + make_interval(months => i + 1)) at time zone 'UTC'
622
+ );
623
+ exception when check_violation then
624
+ -- The default partition already holds rows of that month.
625
+ raise notice '% not created: the default partition has rows in its range', v_part;
626
+ continue;
627
+ end;
628
+ execute format('alter table %I.%I enable row level security', v_schema, v_part);
629
+ execute format('revoke all on %I.%I from public, anon, authenticated', v_schema, v_part);
630
+ v_made := v_made + 1;
631
+ end loop;
632
+ return v_made;
633
+ end;
634
+ $$;
635
+
636
+ create or replace function better_supabase.maintain_partitions()
637
+ returns integer
638
+ language plpgsql
639
+ security definer
640
+ set search_path = ''
641
+ as $$
642
+ declare
643
+ v_made integer := 0;
644
+ v_table record;
645
+ begin
646
+ for v_table in select t.parent, t.months_ahead from better_supabase.partitioned_tables t loop
647
+ v_made := v_made + better_supabase.ensure_partitions(v_table.parent, v_table.months_ahead);
648
+ end loop;
649
+ return v_made;
650
+ end;
651
+ $$;
652
+
653
+ create or replace function better_supabase.expired_partitions(parent regclass, cutoff timestamptz)
654
+ returns setof regclass
655
+ language sql
656
+ stable
657
+ security definer
658
+ set search_path = ''
659
+ as $$
660
+ select c.oid::regclass
661
+ from pg_catalog.pg_inherits i
662
+ join pg_catalog.pg_class c on c.oid = i.inhrelid
663
+ where i.inhparent = parent
664
+ and c.relname ~ '_p[0-9]{6}$'
665
+ and cutoff is not null
666
+ and (to_date(right(c.relname, 6), 'YYYYMM')::timestamp + interval '1 month') at time zone 'UTC' <= cutoff
667
+ order by c.relname
668
+ $$;
669
+ revoke execute on function better_supabase.ensure_partitions(regclass, integer) from public, anon, authenticated;
670
+ revoke execute on function better_supabase.maintain_partitions() from public, anon, authenticated;
671
+ revoke execute on function better_supabase.expired_partitions(regclass, timestamptz) from public, anon, authenticated;
672
+ grant execute on function better_supabase.maintain_partitions() to service_role;`;
673
+ /**
674
+ * SQL that registers a partitioned table for `maintain_partitions()` and
675
+ * creates its first partitions.
676
+ */
677
+ const registerPartitions = (table, monthsAhead = 3) => `insert into better_supabase.partitioned_tables (parent, months_ahead)
678
+ select ${sqlString(table)}::regclass, ${monthsAhead}
679
+ where exists (select 1 from pg_catalog.pg_class c where c.oid = ${sqlString(table)}::regclass and c.relkind = 'p')
680
+ on conflict (parent) do nothing;
681
+ select better_supabase.ensure_partitions(${sqlString(table)}::regclass, ${monthsAhead});`;
682
+ /**
683
+ * The quoted name of a table's default partition: `<name>_default` in its
684
+ * schema.
685
+ */
686
+ const defaultPartitionName = (table) => `${sqlIdent(table.schema)}.${sqlIdent(`${table.name}_default`)}`;
687
+ /**
688
+ * SQL that gives a partitioned `table` its `fallback` default partition, for
689
+ * rows outside the monthly ones. A table created unpartitioned is skipped.
690
+ */
691
+ const defaultPartition = (table, fallback) => `do $$
692
+ begin
693
+ if (select c.relkind from pg_catalog.pg_class c where c.oid = ${sqlString(table)}::regclass) = 'p' then
694
+ create table if not exists ${fallback} partition of ${table} default;
695
+ alter table ${fallback} enable row level security;
696
+ revoke all on ${fallback} from public, anon, authenticated;
697
+ end if;
698
+ end;
699
+ $$;`;
700
+ /**
701
+ * A security definer function that runs `call` once per element of a jsonb
702
+ * array, so a sink sends a whole batch in one round trip. Every element keeps
703
+ * the single-row function's checks and gets its own savepoint: it returns
704
+ * `{"<result>": value}` or `{"error": {code, message, hint}}`, in order, and
705
+ * one bad event never rolls back the others. More than `max` elements fail with
706
+ * 22023 before any is written. The caller adds the grants.
707
+ */
708
+ function batchFunction(options) {
709
+ const max = options.max ?? 1e3;
710
+ const value = ([name, type, fallback]) => {
711
+ const raw = type === "jsonb" ? `nullif(batch_event -> ${sqlString(name)}, 'null'::jsonb)` : type === "text" ? `batch_event ->> ${sqlString(name)}` : `(batch_event ->> ${sqlString(name)})::${type}`;
712
+ return fallback === void 0 ? raw : `coalesce(${raw}, ${fallback})`;
713
+ };
714
+ return `create or replace function ${options.name}(events jsonb)
715
+ returns jsonb
716
+ language plpgsql
717
+ security definer
718
+ set search_path = ''
719
+ as $$
720
+ declare
721
+ batch_event jsonb;
722
+ results jsonb := '[]';
723
+ batch_result ${options.returns};
724
+ failed_state text;
725
+ failed_message text;
726
+ failed_hint text;
727
+ begin
728
+ if pg_catalog.jsonb_typeof(events) is distinct from 'array' then
729
+ raise exception '${options.name.replace(/^.*\./, "")} takes a jsonb array of events'
730
+ using errcode = '22023', hint = ${sqlString(`${options.hint}_NOT_ARRAY`)};
731
+ end if;
732
+ if pg_catalog.jsonb_array_length(events) > ${max} then
733
+ raise exception '${options.name.replace(/^.*\./, "")} got % events, more than ${max}', pg_catalog.jsonb_array_length(events)
734
+ using errcode = '22023', hint = ${sqlString(`${options.hint}_TOO_LARGE`)};
735
+ end if;
736
+ for batch_event in select e from pg_catalog.jsonb_array_elements(events) e loop
737
+ begin
738
+ batch_result := ${options.call}(
739
+ ${typeof options.args === "string" ? ` ${options.args} => batch_event` : options.args.map((arg) => ` ${arg[0]} => ${value(arg)}`).join(",\n")}
740
+ );
741
+ results := results || pg_catalog.jsonb_build_array(pg_catalog.jsonb_build_object(${sqlString(options.result)}, batch_result));
742
+ exception when others then
743
+ get stacked diagnostics
744
+ failed_state = returned_sqlstate,
745
+ failed_message = message_text,
746
+ failed_hint = pg_exception_hint;
747
+ results := results || pg_catalog.jsonb_build_array(pg_catalog.jsonb_build_object(
748
+ 'error', pg_catalog.jsonb_build_object('code', failed_state, 'message', failed_message, 'hint', nullif(failed_hint, ''))
749
+ ));
750
+ end;
751
+ end loop;
752
+ return results;
753
+ end;
754
+ $$;`;
755
+ }
756
+ /** The PL/pgSQL variables `dropExpiredPartitions` uses, for a `declare` block. */
757
+ const PARTITION_VARIABLES = `
758
+ v_part regclass;
759
+ v_part_rows integer;
760
+ v_part_busy boolean;`;
761
+ /**
762
+ * PL/pgSQL that drops each monthly partition of `table` wholly before `cutoff`
763
+ * (null drops none, as `ctx.cutoff` returns under a legal hold) and adds its
764
+ * rows to `purged`. A partition with a row that matches `busy` (a condition
765
+ * over `p`, with `$1`.. bound to `using`) stays for the row deletes, so a purge
766
+ * never drops a row it would keep. Declare `PARTITION_VARIABLES` first.
767
+ */
768
+ function dropExpiredPartitions(options) {
769
+ const indent = options.indent ?? " ";
770
+ const literal = (sql) => sql.replaceAll("'", "''");
771
+ const busy = options.busy === void 0 ? "" : `
772
+ ${indent} execute format('select exists (select 1 from %s p where ${literal(options.busy).replaceAll("%", "%%")})', v_part) into v_part_busy${options.using && options.using.length > 0 ? ` using ${options.using.join(", ")}` : ""};
773
+ ${indent} continue when v_part_busy;`;
774
+ return `for v_part in
775
+ ${indent} select p from better_supabase.expired_partitions(${sqlString(options.table)}::regclass, ${options.cutoff}) p
776
+ ${indent}loop${busy}
777
+ ${indent} execute format('select count(*)::integer from %s', v_part) into v_part_rows;
778
+ ${indent} execute format('drop table %s', v_part);
779
+ ${indent} ${options.purged} := ${options.purged} + v_part_rows;
780
+ ${indent}end loop;`;
781
+ }
782
+ /** SQL that grants a function to signed-in users and the service role. */
783
+ const userGrant = (signature) => `revoke execute on function ${signature} from public, anon;
784
+ grant execute on function ${signature} to authenticated, service_role;`;
785
+ /** SQL that grants a function to the service role only. */
786
+ const serviceGrant = (signature) => `revoke execute on function ${signature} from public, anon, authenticated;
787
+ grant execute on function ${signature} to service_role;`;
788
+ /**
789
+ * SQL that revokes a trigger function from every API role. Postgres checks
790
+ * `execute` only when the trigger is created, never when it fires, so the
791
+ * trigger keeps working while the function can't be called through RPC.
792
+ */
793
+ const triggerGrant = (signature) => `revoke execute on function ${signature} from public, anon, authenticated;`;
794
+ /**
795
+ * `serviceGrant` for each function in `schema` (as SQL, e.g. `ctx.schema`), one
796
+ * statement per function, so `blocks.<module>.api` sees the grants and writes
797
+ * an entry point for each.
798
+ */
799
+ function serviceOnly(signatures, schema = "better_supabase") {
800
+ return signatures.map((signature) => serviceGrant(`${schema}.${signature}`)).join("\n");
801
+ }
802
+ /**
803
+ * `raise exception` with an errcode and, when given, a hint the TypeScript side
804
+ * maps. Sites that put `using` on its own line, raise without an errcode or
805
+ * compute the hint stay inline: this one-line form would change SQL apps have
806
+ * generated.
807
+ */
808
+ const raise = (message, errcode, hint, ...args) => `raise exception ${sqlString(message)}${args.map((arg) => `, ${arg}`).join("")} using errcode = '${errcode}'${hint === void 0 ? "" : `, hint = '${hint}'`};`;
809
+ /**
810
+ * `raise` for a module function: the hint first, the errcode defaulting to
811
+ * insufficient privilege.
812
+ */
813
+ const fail = (code, message, errcode = "42501") => raise(message, errcode, code);
814
+ /** The hex SHA-256 of a `text` expression, as tokens and codes are stored. */
815
+ const sha256Hex = (value) => `encode(extensions.digest(${value}, 'sha256'), 'hex')`;
816
+ /** A page size: `value`, or `fallback` when null, clamped to `min`..`max`. */
817
+ const pageSize = (value, fallback, max, min = 1) => `least(greatest(coalesce(${value}, ${String(fallback)}), ${String(min)}), ${String(max)})`;
818
+ /**
819
+ * A row trigger that records writes to a table that callers change through
820
+ * `security invoker` functions or policies, which can't call `emit_event` or
821
+ * `audit_event` themselves. `written` and `removed` are `ctx.record` statements
822
+ * over `v_row`, the new row (or the old one on delete). When both are `null;`
823
+ * the trigger and its function are dropped.
824
+ */
825
+ function recordTrigger(ctx, options) {
826
+ const fn = ctx.fn(options.name);
827
+ const trigger = ctx.trigger(options.name);
828
+ if (options.written === "null;" && options.removed === "null;") return `drop trigger if exists ${trigger} on ${options.table};
829
+ drop function if exists ${fn}();`;
830
+ return `create or replace function ${fn}()
831
+ returns trigger
832
+ language plpgsql
833
+ security definer
834
+ set search_path = ''
835
+ as $$
836
+ declare
837
+ v_row ${options.table};
838
+ begin
839
+ if tg_op = 'DELETE' then
840
+ v_row := old;
841
+ ${options.removed}
842
+ else
843
+ v_row := new;
844
+ ${options.written}
845
+ end if;
846
+ return null;
847
+ end;
848
+ $$;
849
+ revoke execute on function ${fn}() from public, anon, authenticated;
850
+ drop trigger if exists ${trigger} on ${options.table};
851
+ create trigger ${trigger} after insert or update or delete on ${options.table}
852
+ for each row execute function ${fn}();`;
853
+ }
854
+ // src/sql/modules/permissions-model.ts
855
+ /**
856
+ * The `roles` model's defaults. Module actions name these keys (see
857
+ * `OPERATIONS`); `*` grants everything and `prefix.*` a prefix.
858
+ */
859
+ const DEFAULT_ROLES = {
860
+ owner: ["*"],
861
+ admin: [
862
+ "organization.read",
863
+ "organization.update",
864
+ "members.*",
865
+ "audit.read",
866
+ "audit.revert",
867
+ "webhooks.*",
868
+ "notifications.*",
869
+ "billing.*",
870
+ "api_keys.*",
871
+ "settings.*",
872
+ "usage.*",
873
+ "activity.read",
874
+ "attachments.*",
875
+ "organization.export",
876
+ "onboarding.*",
877
+ "inbox.*",
878
+ "ai_chat.*",
879
+ "ai.*",
880
+ "tags.*",
881
+ "teams.*",
882
+ "custom_fields.*",
883
+ "share_links.*",
884
+ "reminders.*",
885
+ "imports.*",
886
+ "views.*",
887
+ "relations.*",
888
+ "bulk.*",
889
+ "search.*",
890
+ "metrics.*",
891
+ "calendar.*",
892
+ "bookings.*",
893
+ "versions.*",
894
+ "trash.*",
895
+ "reactions.*",
896
+ "approvals.*",
897
+ "access_requests.*",
898
+ "documents.*",
899
+ "drive.*",
900
+ "forms.*",
901
+ "signatures.*",
902
+ "templates.*",
903
+ "time_tracking.*",
904
+ "service_principals.*",
905
+ "pipelines.*",
906
+ "parties.*",
907
+ "engagements.*",
908
+ "deals.*",
909
+ "work_items.*",
910
+ "quotes.*",
911
+ "invoices.*",
912
+ "sla.*",
913
+ "targets.*",
914
+ "hiring.*",
915
+ "employees.*",
916
+ "collections.*",
917
+ "messages.*",
918
+ "channels.*",
919
+ "mail.*",
920
+ "segments.*",
921
+ "assignment.*",
922
+ "enrichment.*",
923
+ "forecasts.*",
924
+ "history.*",
925
+ "domains.*",
926
+ "rules.*",
927
+ "reviews.*",
928
+ "leave.*",
929
+ "ledger.*",
930
+ "assets.*",
931
+ "scores.*",
932
+ "moderation.*",
933
+ "enrollments.*",
934
+ "guests.*",
935
+ "passes.*",
936
+ "billable_time.*",
937
+ "leases.*",
938
+ "expenses.*",
939
+ "donations.*",
940
+ "dispatch.*",
941
+ "shipments.*",
942
+ "contracts.*",
943
+ "controls.*",
944
+ "incidents.*",
945
+ "courses.*",
946
+ "sequences.*",
947
+ "posts.*",
948
+ "content.*"
949
+ ],
950
+ member: [
951
+ "organization.read",
952
+ "members.read",
953
+ "notifications.read",
954
+ "api_keys.own",
955
+ "settings.read",
956
+ "activity.read",
957
+ "attachments.read",
958
+ "attachments.upload",
959
+ "onboarding.read",
960
+ "inbox.read",
961
+ "inbox.reply",
962
+ "ai_chat.read",
963
+ "ai_chat.create",
964
+ "ai_chat.share",
965
+ "ai.read",
966
+ "ai.create",
967
+ "ai.share",
968
+ "custom_fields.read",
969
+ "teams.read",
970
+ "tags.read",
971
+ "tags.apply",
972
+ "share_links.read",
973
+ "reminders.read",
974
+ "views.read",
975
+ "relations.read",
976
+ "bulk.run",
977
+ "search.read",
978
+ "metrics.read",
979
+ "calendar.read",
980
+ "calendar.write",
981
+ "bookings.read",
982
+ "bookings.create",
983
+ "versions.read",
984
+ "versions.create",
985
+ "versions.restore",
986
+ "trash.read",
987
+ "trash.create",
988
+ "trash.restore",
989
+ "reactions.read",
990
+ "reactions.create",
991
+ "approvals.read",
992
+ "approvals.request",
993
+ "access_requests.create",
994
+ "documents.read",
995
+ "documents.write",
996
+ "documents.suggest",
997
+ "drive.read",
998
+ "drive.create",
999
+ "forms.read",
1000
+ "forms.submit",
1001
+ "signatures.read",
1002
+ "signatures.request",
1003
+ "templates.read",
1004
+ "templates.apply",
1005
+ "time_tracking.track",
1006
+ "leave.request",
1007
+ "pipelines.read",
1008
+ "parties.read",
1009
+ "parties.write",
1010
+ "engagements.read",
1011
+ "engagements.write",
1012
+ "deals.read",
1013
+ "deals.write",
1014
+ "work_items.read",
1015
+ "work_items.write",
1016
+ "quotes.read",
1017
+ "quotes.write",
1018
+ "invoices.read",
1019
+ "sla.read",
1020
+ "targets.read",
1021
+ "employees.read",
1022
+ "collections.read",
1023
+ "collections.write",
1024
+ "domains.read",
1025
+ "rules.read",
1026
+ "assets.read",
1027
+ "scores.read",
1028
+ "moderation.report",
1029
+ "enrollments.read",
1030
+ "leases.maintain",
1031
+ "expenses.submit",
1032
+ "dispatch.read",
1033
+ "dispatch.work",
1034
+ "shipments.read",
1035
+ "contracts.read",
1036
+ "contracts.write",
1037
+ "controls.read",
1038
+ "controls.collect",
1039
+ "controls.acknowledge",
1040
+ "incidents.read",
1041
+ "incidents.write",
1042
+ "courses.read",
1043
+ "sequences.read",
1044
+ "sequences.enroll",
1045
+ "posts.read",
1046
+ "posts.write",
1047
+ "content.read",
1048
+ "content.write",
1049
+ "messages.read",
1050
+ "messages.send",
1051
+ "channels.create",
1052
+ "mail.read",
1053
+ "mail.connect",
1054
+ "mail.send",
1055
+ "segments.read",
1056
+ "assignment.read",
1057
+ "enrichment.read",
1058
+ "forecasts.read",
1059
+ "history.read"
1060
+ ],
1061
+ viewer: ["organization.read"]
1062
+ };
1063
+ /** Actions a module checks only when `blocks.<module>.permissions` names a key. */
1064
+ const OPTIONAL_MODULE_PERMISSIONS = {
1065
+ organizations: {
1066
+ create: "platform",
1067
+ updatePlatform: "platform",
1068
+ deletePlatform: "platform",
1069
+ updateRolePlatform: "platform",
1070
+ removeMemberPlatform: "platform"
1071
+ },
1072
+ audit: { reveal: "tenant" },
1073
+ "data-lifecycle": { deletePlatform: "platform" },
1074
+ tags: {
1075
+ create: "tenant",
1076
+ update: "tenant",
1077
+ delete: "tenant"
1078
+ },
1079
+ tasks: {
1080
+ create: "tenant",
1081
+ delete: "tenant"
1082
+ },
1083
+ calendar: {
1084
+ create: "tenant",
1085
+ update: "tenant",
1086
+ delete: "tenant"
1087
+ },
1088
+ employees: {
1089
+ create: "tenant",
1090
+ contractsRead: "tenant",
1091
+ contractsWrite: "tenant",
1092
+ privateDetailsWrite: "tenant"
1093
+ },
1094
+ hiring: {
1095
+ create: "tenant",
1096
+ jobsCreate: "tenant",
1097
+ jobsUpdate: "tenant",
1098
+ score: "tenant"
1099
+ },
1100
+ teams: {
1101
+ create: "tenant",
1102
+ update: "tenant",
1103
+ delete: "tenant",
1104
+ members: "tenant"
1105
+ }
1106
+ };
1107
+ /**
1108
+ * The permission key each operation checks by default, keyed
1109
+ * `<module>.<action>`. `blocks.<name>.permissions` renames a key per module,
1110
+ * `authorization.operations` overrides it for a provider, and the access
1111
+ * module's `operation_permission(op)` answers the result in SQL. Keys are
1112
+ * `<area>.<verb>`, with `read` for viewing; platform-wide actions use the
1113
+ * `platform` area or a key that `is_platform()` checks. The AI blocks other
1114
+ * than ai-chat check `ai.*` keys.
1115
+ */
1116
+ const OPERATIONS = {
1117
+ "organizations.update": "organization.update",
1118
+ "organizations.delete": "organization.delete",
1119
+ "organizations.listMembers": "members.read",
1120
+ "organizations.removeMember": "members.remove",
1121
+ "organizations.suspendMember": "members.remove",
1122
+ "organizations.updateRole": "members.update_role",
1123
+ "organizations.transferOwnership": "organization.transfer_ownership",
1124
+ "invitations.invite": "members.invite",
1125
+ "invitations.revoke": "members.invite",
1126
+ "invitations.view": "members.invite",
1127
+ "invitations.invitePlatform": "platform.invite",
1128
+ "audit.view": "audit.read",
1129
+ "audit.viewAll": "audit.read",
1130
+ "audit.revert": "audit.revert",
1131
+ "impersonation.start": "support.start",
1132
+ "impersonation.view": "support.read",
1133
+ "impersonation.revoke": "support.revoke",
1134
+ "notifications.send": "notifications.send",
1135
+ "notifications.read": "notifications.read",
1136
+ "webhooks-out.manage": "webhooks.manage",
1137
+ "webhooks-out.view": "webhooks.read",
1138
+ "webhooks-in.create": "webhooks.manage",
1139
+ "webhooks-in.update": "webhooks.manage",
1140
+ "webhooks-in.delete": "webhooks.manage",
1141
+ "webhooks-in.view": "webhooks.read",
1142
+ "api-keys.manage": "api_keys.manage",
1143
+ "api-keys.own": "api_keys.own",
1144
+ "settings.read": "settings.read",
1145
+ "settings.update": "settings.update",
1146
+ "settings.platform": "settings.manage",
1147
+ "usage.read": "usage.read",
1148
+ "usage.record": "usage.record",
1149
+ "billing.read": "billing.read",
1150
+ "billing.manage": "billing.manage",
1151
+ "billing.viewAll": "billing.read",
1152
+ "comments.read": "messages.read",
1153
+ "comments.create": "messages.send",
1154
+ "comments.moderate": "messages.moderate",
1155
+ "timeline.read": "activity.read",
1156
+ "data-lifecycle.export": "organization.export",
1157
+ "data-lifecycle.delete": "organization.delete",
1158
+ "data-lifecycle.cancelDelete": "organization.delete",
1159
+ "attachments.read": "attachments.read",
1160
+ "attachments.upload": "attachments.upload",
1161
+ "attachments.manage": "attachments.manage",
1162
+ "sso.manage": "sso.manage",
1163
+ "onboarding.read": "onboarding.read",
1164
+ "onboarding.complete": "onboarding.complete",
1165
+ "announcements.manage": "announcements.manage",
1166
+ "waitlist.manage": "waitlist.manage",
1167
+ "waitlist.invite": "members.invite",
1168
+ "flags.manage": "flags.manage",
1169
+ "workflows.read": "workflow.read",
1170
+ "workflows.run": "workflow.run",
1171
+ "workflows.admin": "workflow.admin",
1172
+ "workflow-editor.read": "workflow.read",
1173
+ "workflow-editor.run": "workflow.run",
1174
+ "workflow-editor.edit": "workflow.edit",
1175
+ "workflow-editor.publish": "workflow.publish",
1176
+ "workflow-editor.admin": "workflow.admin",
1177
+ "inbox.read": "inbox.read",
1178
+ "inbox.reply": "inbox.reply",
1179
+ "inbox.assign": "inbox.assign",
1180
+ "inbox.manage": "inbox.manage",
1181
+ "ai-chat.read": "ai_chat.read",
1182
+ "ai-chat.create": "ai_chat.create",
1183
+ "ai-chat.share": "ai_chat.share",
1184
+ "ai-chat.moderate": "ai_chat.moderate",
1185
+ "ai-chat.admin": "ai_chat.admin",
1186
+ "ai-files.upload": "ai.create",
1187
+ "ai-files.manage": "ai.admin",
1188
+ "knowledge.read": "ai.read",
1189
+ "knowledge.write": "ai.create",
1190
+ "knowledge.manage": "ai.admin",
1191
+ "memory.read": "ai.read",
1192
+ "memory.manage": "ai.admin",
1193
+ "agents.read": "ai.read",
1194
+ "agents.create": "ai.create",
1195
+ "agents.publish": "ai.share",
1196
+ "agents.moderate": "ai.moderate",
1197
+ "connectors.read": "ai.read",
1198
+ "connectors.use": "ai.create",
1199
+ "connectors.manage": "ai.admin",
1200
+ "ai-schedules.create": "ai.create",
1201
+ "ai-schedules.manage": "ai.admin",
1202
+ "ai-keys.use": "ai.create",
1203
+ "ai-keys.manage": "ai.admin",
1204
+ "numbering.assign": "number_sequences.assign",
1205
+ "teams.manage": "teams.manage",
1206
+ "teams.read": "teams.read",
1207
+ "permissions.listRoles": "members.read",
1208
+ "permissions.setOverride": "roles.manage",
1209
+ "tags.manage": "tags.manage",
1210
+ "tags.read": "tags.read",
1211
+ "tags.apply": "tags.apply",
1212
+ "catalog.manage": "catalog.manage",
1213
+ "catalog.read": "catalog.read",
1214
+ "inventory.manage": "inventory.manage",
1215
+ "inventory.read": "inventory.read",
1216
+ "inventory.reserve": "inventory.reserve",
1217
+ "inventory.purchase": "inventory.purchase",
1218
+ "orders.manage": "orders.manage",
1219
+ "orders.read": "orders.read",
1220
+ "orders.prepare": "orders.prepare",
1221
+ "promotions.manage": "promotions.manage",
1222
+ "promotions.read": "promotions.read",
1223
+ "custom-fields.manage": "custom_fields.manage",
1224
+ "custom-fields.read": "custom_fields.read",
1225
+ "custom-fields.sensitive": "custom_fields.sensitive.read",
1226
+ "share-links.create": "share_links.create",
1227
+ "share-links.read": "share_links.read",
1228
+ "reminders.manage": "reminders.manage",
1229
+ "reminders.read": "reminders.read",
1230
+ "imports.manage": "imports.manage",
1231
+ "saved-views.read": "views.read",
1232
+ "saved-views.share": "views.share",
1233
+ "relations.read": "relations.read",
1234
+ "relations.manage": "relations.manage",
1235
+ "bulk.run": "bulk.run",
1236
+ "search.read": "search.read",
1237
+ "metrics.read": "metrics.read",
1238
+ "metrics.manage": "metrics.manage",
1239
+ "calendar.manage": "calendar.manage",
1240
+ "calendar.write": "calendar.write",
1241
+ "calendar.read": "calendar.read",
1242
+ "bookings.manage": "bookings.manage",
1243
+ "bookings.create": "bookings.create",
1244
+ "bookings.read": "bookings.read",
1245
+ "versions.read": "versions.read",
1246
+ "versions.create": "versions.create",
1247
+ "versions.restore": "versions.restore",
1248
+ "versions.manage": "versions.manage",
1249
+ "trash.read": "trash.read",
1250
+ "trash.create": "trash.create",
1251
+ "trash.restore": "trash.restore",
1252
+ "trash.manage": "trash.manage",
1253
+ "reactions.read": "reactions.read",
1254
+ "reactions.create": "reactions.create",
1255
+ "reactions.manage": "reactions.manage",
1256
+ "approvals.read": "approvals.read",
1257
+ "approvals.request": "approvals.request",
1258
+ "approvals.manage": "approvals.manage",
1259
+ "access-requests.read": "access_requests.read",
1260
+ "access-requests.create": "access_requests.create",
1261
+ "access-requests.manage": "access_requests.manage",
1262
+ "documents.read": "documents.read",
1263
+ "documents.write": "documents.write",
1264
+ "documents.suggest": "documents.suggest",
1265
+ "documents.manage": "documents.manage",
1266
+ "drive.read": "drive.read",
1267
+ "drive.create": "drive.create",
1268
+ "drive.manage": "drive.manage",
1269
+ "forms.read": "forms.read",
1270
+ "forms.manage": "forms.manage",
1271
+ "forms.submit": "forms.submit",
1272
+ "forms.review": "forms.review",
1273
+ "signatures.read": "signatures.read",
1274
+ "signatures.request": "signatures.request",
1275
+ "signatures.manage": "signatures.manage",
1276
+ "templates.read": "templates.read",
1277
+ "templates.apply": "templates.apply",
1278
+ "templates.manage": "templates.manage",
1279
+ "time-tracking.read": "time_tracking.read",
1280
+ "time-tracking.track": "time_tracking.track",
1281
+ "time-tracking.approve": "time_tracking.approve",
1282
+ "time-tracking.manage": "time_tracking.manage",
1283
+ "service-accounts.read": "service_principals.read",
1284
+ "service-accounts.manage": "service_principals.manage",
1285
+ "pipelines.read": "pipelines.read",
1286
+ "pipelines.manage": "pipelines.manage",
1287
+ "contacts.read": "parties.read",
1288
+ "contacts.write": "parties.write",
1289
+ "contacts.manage": "parties.manage",
1290
+ "activities.read": "engagements.read",
1291
+ "activities.write": "engagements.write",
1292
+ "activities.manage": "engagements.manage",
1293
+ "deals.read": "deals.read",
1294
+ "deals.write": "deals.write",
1295
+ "deals.manage": "deals.manage",
1296
+ "tasks.read": "work_items.read",
1297
+ "tasks.write": "work_items.write",
1298
+ "tasks.manage": "work_items.manage",
1299
+ "quotes.read": "quotes.read",
1300
+ "quotes.write": "quotes.write",
1301
+ "quotes.manage": "quotes.manage",
1302
+ "invoices.read": "invoices.read",
1303
+ "invoices.write": "invoices.write",
1304
+ "invoices.manage": "invoices.manage",
1305
+ "sla.read": "sla.read",
1306
+ "sla.manage": "sla.manage",
1307
+ "goals.read": "targets.read",
1308
+ "goals.manage": "targets.manage",
1309
+ "hiring.read": "hiring.read",
1310
+ "hiring.write": "hiring.write",
1311
+ "hiring.manage": "hiring.manage",
1312
+ "employees.read": "employees.read",
1313
+ "employees.write": "employees.write",
1314
+ "employees.viewSensitive": "employees.view_sensitive",
1315
+ "collections.read": "collections.read",
1316
+ "collections.write": "collections.write",
1317
+ "collections.share": "collections.share",
1318
+ "domains.read": "domains.read",
1319
+ "domains.manage": "domains.manage",
1320
+ "automations.read": "rules.read",
1321
+ "automations.edit": "rules.edit",
1322
+ "automations.publish": "rules.publish",
1323
+ "automations.admin": "rules.admin",
1324
+ "reviews.manage": "reviews.manage",
1325
+ "leave.request": "leave.request",
1326
+ "leave.read": "leave.read",
1327
+ "leave.approve": "leave.approve",
1328
+ "leave.manage": "leave.manage",
1329
+ "ledger.read": "ledger.read",
1330
+ "ledger.manage": "ledger.manage",
1331
+ "ledger.post": "ledger.post",
1332
+ "assets.read": "assets.read",
1333
+ "assets.manage": "assets.manage",
1334
+ "assets.assign": "assets.assign",
1335
+ "scores.read": "scores.read",
1336
+ "scores.manage": "scores.manage",
1337
+ "scores.compute": "scores.compute",
1338
+ "moderation.read": "moderation.read",
1339
+ "moderation.report": "moderation.report",
1340
+ "moderation.manage": "moderation.manage",
1341
+ "moderation.ban": "moderation.ban",
1342
+ "enrollments.read": "enrollments.read",
1343
+ "enrollments.enroll": "enrollments.enroll",
1344
+ "enrollments.manage": "enrollments.manage",
1345
+ "guests.read": "guests.read",
1346
+ "guests.manage": "guests.manage",
1347
+ "passes.read": "passes.read",
1348
+ "passes.manage": "passes.manage",
1349
+ "passes.checkIn": "passes.check_in",
1350
+ "billable-time.read": "billable_time.read",
1351
+ "billable-time.manage": "billable_time.manage",
1352
+ "billable-time.invoice": "billable_time.invoice",
1353
+ "leases.read": "leases.read",
1354
+ "leases.manage": "leases.manage",
1355
+ "leases.maintain": "leases.maintain",
1356
+ "expenses.read": "expenses.read",
1357
+ "expenses.submit": "expenses.submit",
1358
+ "expenses.approve": "expenses.approve",
1359
+ "expenses.manage": "expenses.manage",
1360
+ "donations.read": "donations.read",
1361
+ "donations.manage": "donations.manage",
1362
+ "dispatch.read": "dispatch.read",
1363
+ "dispatch.manage": "dispatch.manage",
1364
+ "dispatch.work": "dispatch.work",
1365
+ "shipments.read": "shipments.read",
1366
+ "shipments.manage": "shipments.manage",
1367
+ "contracts.read": "contracts.read",
1368
+ "contracts.write": "contracts.write",
1369
+ "contracts.manage": "contracts.manage",
1370
+ "compliance.read": "controls.read",
1371
+ "compliance.manage": "controls.manage",
1372
+ "compliance.collect": "controls.collect",
1373
+ "compliance.acknowledge": "controls.acknowledge",
1374
+ "incidents.read": "incidents.read",
1375
+ "incidents.write": "incidents.write",
1376
+ "incidents.manage": "incidents.manage",
1377
+ "courses.read": "courses.read",
1378
+ "courses.enroll": "courses.enroll",
1379
+ "courses.manage": "courses.manage",
1380
+ "sequences.read": "sequences.read",
1381
+ "sequences.enroll": "sequences.enroll",
1382
+ "sequences.manage": "sequences.manage",
1383
+ "posts.read": "posts.read",
1384
+ "posts.write": "posts.write",
1385
+ "posts.moderate": "posts.moderate",
1386
+ "posts.manage": "posts.manage",
1387
+ "content.read": "content.read",
1388
+ "content.write": "content.write",
1389
+ "content.publish": "content.publish",
1390
+ "messaging.read": "messages.read",
1391
+ "messaging.send": "messages.send",
1392
+ "messaging.moderate": "messages.moderate",
1393
+ "channels.read": "messages.read",
1394
+ "channels.create": "channels.create",
1395
+ "channels.manage": "channels.manage",
1396
+ "mail-sync.read": "mail.read",
1397
+ "mail-sync.connect": "mail.connect",
1398
+ "mail-sync.send": "mail.send",
1399
+ "mail-sync.manage": "mail.manage",
1400
+ "segments.read": "segments.read",
1401
+ "segments.edit": "segments.edit",
1402
+ "assignment.read": "assignment.read",
1403
+ "assignment.manage": "assignment.manage",
1404
+ "assignment.assign": "assignment.assign",
1405
+ "enrichment.read": "enrichment.read",
1406
+ "enrichment.run": "enrichment.run",
1407
+ "forecasts.read": "forecasts.read",
1408
+ "forecasts.snapshot": "forecasts.snapshot",
1409
+ "field-history.read": "history.read"
1410
+ };
1411
+ const operationsByModule = /* @__PURE__ */ new Map();
1412
+ for (const [name, key] of Object.entries(OPERATIONS)) {
1413
+ const dot = name.indexOf(".");
1414
+ const module = name.slice(0, dot);
1415
+ const actions = operationsByModule.get(module) ?? {};
1416
+ actions[name.slice(dot + 1)] = key;
1417
+ operationsByModule.set(module, actions);
1418
+ }
1419
+ /** `module`'s default keys by action, from `OPERATIONS`. */
1420
+ function moduleOperations(module) {
1421
+ return operationsByModule.get(module) ?? {};
1422
+ }
1423
+ /** Whether `name` is a module with actions in `OPERATIONS`. */
1424
+ const isOperationModule = (name) => operationsByModule.has(name);
1425
+ /**
1426
+ * Where each module action checks its key: `tenant` through `member_can`, `can`
1427
+ * or `tenant_ids_with` (a provider's `idsWith`), and `platform` through
1428
+ * `is_platform` or `platform_can` (a provider's `isPlatform`).
1429
+ */
1430
+ const MODULE_PERMISSION_SCOPES = {
1431
+ organizations: {
1432
+ update: "tenant",
1433
+ delete: "tenant",
1434
+ listMembers: "tenant",
1435
+ removeMember: "tenant",
1436
+ suspendMember: "tenant",
1437
+ updateRole: "tenant",
1438
+ transferOwnership: "tenant"
1439
+ },
1440
+ invitations: {
1441
+ invite: "tenant",
1442
+ revoke: "tenant",
1443
+ view: "tenant",
1444
+ invitePlatform: "platform"
1445
+ },
1446
+ audit: {
1447
+ view: "tenant",
1448
+ viewAll: "platform",
1449
+ revert: "tenant"
1450
+ },
1451
+ impersonation: {
1452
+ start: "platform",
1453
+ view: "platform",
1454
+ revoke: "platform"
1455
+ },
1456
+ notifications: {
1457
+ send: "tenant",
1458
+ read: "tenant"
1459
+ },
1460
+ "webhooks-out": {
1461
+ manage: "tenant",
1462
+ view: "tenant"
1463
+ },
1464
+ "webhooks-in": {
1465
+ create: "tenant",
1466
+ update: "tenant",
1467
+ delete: "tenant",
1468
+ view: "tenant"
1469
+ },
1470
+ "api-keys": {
1471
+ manage: "tenant",
1472
+ own: "tenant"
1473
+ },
1474
+ settings: {
1475
+ read: "tenant",
1476
+ update: "tenant",
1477
+ platform: "platform"
1478
+ },
1479
+ usage: {
1480
+ read: "tenant",
1481
+ record: "tenant"
1482
+ },
1483
+ billing: {
1484
+ read: "tenant",
1485
+ manage: "tenant",
1486
+ viewAll: "platform"
1487
+ },
1488
+ comments: {
1489
+ read: "tenant",
1490
+ create: "tenant",
1491
+ moderate: "tenant"
1492
+ },
1493
+ timeline: { read: "tenant" },
1494
+ attachments: {
1495
+ read: "tenant",
1496
+ upload: "tenant",
1497
+ manage: "tenant"
1498
+ },
1499
+ "data-lifecycle": {
1500
+ export: "tenant",
1501
+ delete: "tenant",
1502
+ cancelDelete: "tenant"
1503
+ },
1504
+ sso: { manage: "tenant" },
1505
+ onboarding: {
1506
+ read: "tenant",
1507
+ complete: "tenant"
1508
+ },
1509
+ announcements: { manage: "platform" },
1510
+ waitlist: {
1511
+ manage: "platform",
1512
+ invite: "tenant"
1513
+ },
1514
+ flags: { manage: "platform" },
1515
+ workflows: {
1516
+ read: "tenant",
1517
+ run: "tenant",
1518
+ admin: "tenant"
1519
+ },
1520
+ "workflow-editor": {
1521
+ read: "tenant",
1522
+ run: "tenant",
1523
+ edit: "tenant",
1524
+ publish: "tenant",
1525
+ admin: "tenant"
1526
+ },
1527
+ inbox: {
1528
+ read: "tenant",
1529
+ reply: "tenant",
1530
+ assign: "tenant",
1531
+ manage: "tenant"
1532
+ },
1533
+ "ai-chat": {
1534
+ read: "tenant",
1535
+ create: "tenant",
1536
+ share: "tenant",
1537
+ moderate: "tenant",
1538
+ admin: "tenant"
1539
+ },
1540
+ "ai-files": {
1541
+ upload: "tenant",
1542
+ manage: "tenant"
1543
+ },
1544
+ knowledge: {
1545
+ read: "tenant",
1546
+ write: "tenant",
1547
+ manage: "tenant"
1548
+ },
1549
+ memory: {
1550
+ read: "tenant",
1551
+ manage: "tenant"
1552
+ },
1553
+ agents: {
1554
+ read: "tenant",
1555
+ create: "tenant",
1556
+ publish: "tenant",
1557
+ moderate: "tenant"
1558
+ },
1559
+ connectors: {
1560
+ read: "tenant",
1561
+ use: "tenant",
1562
+ manage: "tenant"
1563
+ },
1564
+ "ai-schedules": {
1565
+ create: "tenant",
1566
+ manage: "tenant"
1567
+ },
1568
+ "ai-keys": {
1569
+ use: "tenant",
1570
+ manage: "tenant"
1571
+ },
1572
+ numbering: { assign: "tenant" },
1573
+ teams: {
1574
+ manage: "tenant",
1575
+ read: "tenant"
1576
+ },
1577
+ permissions: {
1578
+ listRoles: "tenant",
1579
+ setOverride: "tenant"
1580
+ },
1581
+ tags: {
1582
+ manage: "tenant",
1583
+ read: "tenant",
1584
+ apply: "tenant"
1585
+ },
1586
+ catalog: {
1587
+ manage: "tenant",
1588
+ read: "tenant"
1589
+ },
1590
+ inventory: {
1591
+ manage: "tenant",
1592
+ read: "tenant",
1593
+ reserve: "tenant",
1594
+ purchase: "tenant"
1595
+ },
1596
+ orders: {
1597
+ manage: "tenant",
1598
+ read: "tenant",
1599
+ prepare: "tenant"
1600
+ },
1601
+ promotions: {
1602
+ manage: "tenant",
1603
+ read: "tenant"
1604
+ },
1605
+ "custom-fields": {
1606
+ manage: "tenant",
1607
+ read: "tenant",
1608
+ sensitive: "tenant"
1609
+ },
1610
+ "share-links": {
1611
+ create: "tenant",
1612
+ read: "tenant"
1613
+ },
1614
+ reminders: {
1615
+ manage: "tenant",
1616
+ read: "tenant"
1617
+ },
1618
+ imports: { manage: "tenant" },
1619
+ "saved-views": {
1620
+ read: "tenant",
1621
+ share: "tenant"
1622
+ },
1623
+ relations: {
1624
+ read: "tenant",
1625
+ manage: "tenant"
1626
+ },
1627
+ bulk: { run: "tenant" },
1628
+ search: { read: "tenant" },
1629
+ metrics: {
1630
+ read: "tenant",
1631
+ manage: "tenant"
1632
+ },
1633
+ calendar: {
1634
+ manage: "tenant",
1635
+ write: "tenant",
1636
+ read: "tenant"
1637
+ },
1638
+ bookings: {
1639
+ manage: "tenant",
1640
+ create: "tenant",
1641
+ read: "tenant"
1642
+ },
1643
+ versions: {
1644
+ read: "tenant",
1645
+ create: "tenant",
1646
+ restore: "tenant",
1647
+ manage: "tenant"
1648
+ },
1649
+ trash: {
1650
+ read: "tenant",
1651
+ create: "tenant",
1652
+ restore: "tenant",
1653
+ manage: "tenant"
1654
+ },
1655
+ reactions: {
1656
+ read: "tenant",
1657
+ create: "tenant",
1658
+ manage: "tenant"
1659
+ },
1660
+ approvals: {
1661
+ read: "tenant",
1662
+ request: "tenant",
1663
+ manage: "tenant"
1664
+ },
1665
+ "access-requests": {
1666
+ read: "tenant",
1667
+ create: "tenant",
1668
+ manage: "tenant"
1669
+ },
1670
+ documents: {
1671
+ read: "tenant",
1672
+ write: "tenant",
1673
+ suggest: "tenant",
1674
+ manage: "tenant"
1675
+ },
1676
+ drive: {
1677
+ read: "tenant",
1678
+ create: "tenant",
1679
+ manage: "tenant"
1680
+ },
1681
+ forms: {
1682
+ read: "tenant",
1683
+ manage: "tenant",
1684
+ submit: "tenant",
1685
+ review: "tenant"
1686
+ },
1687
+ signatures: {
1688
+ read: "tenant",
1689
+ request: "tenant",
1690
+ manage: "tenant"
1691
+ },
1692
+ templates: {
1693
+ read: "tenant",
1694
+ apply: "tenant",
1695
+ manage: "tenant"
1696
+ },
1697
+ "time-tracking": {
1698
+ read: "tenant",
1699
+ track: "tenant",
1700
+ approve: "tenant",
1701
+ manage: "tenant"
1702
+ },
1703
+ "service-accounts": {
1704
+ read: "tenant",
1705
+ manage: "tenant"
1706
+ },
1707
+ pipelines: {
1708
+ read: "tenant",
1709
+ manage: "tenant"
1710
+ },
1711
+ contacts: {
1712
+ read: "tenant",
1713
+ write: "tenant",
1714
+ manage: "tenant"
1715
+ },
1716
+ activities: {
1717
+ read: "tenant",
1718
+ write: "tenant",
1719
+ manage: "tenant"
1720
+ },
1721
+ deals: {
1722
+ read: "tenant",
1723
+ write: "tenant",
1724
+ manage: "tenant"
1725
+ },
1726
+ tasks: {
1727
+ read: "tenant",
1728
+ write: "tenant",
1729
+ manage: "tenant"
1730
+ },
1731
+ quotes: {
1732
+ read: "tenant",
1733
+ write: "tenant",
1734
+ manage: "tenant"
1735
+ },
1736
+ invoices: {
1737
+ read: "tenant",
1738
+ write: "tenant",
1739
+ manage: "tenant"
1740
+ },
1741
+ sla: {
1742
+ read: "tenant",
1743
+ manage: "tenant"
1744
+ },
1745
+ goals: {
1746
+ read: "tenant",
1747
+ manage: "tenant"
1748
+ },
1749
+ hiring: {
1750
+ read: "tenant",
1751
+ write: "tenant",
1752
+ manage: "tenant"
1753
+ },
1754
+ employees: {
1755
+ read: "tenant",
1756
+ write: "tenant",
1757
+ viewSensitive: "tenant"
1758
+ },
1759
+ collections: {
1760
+ read: "tenant",
1761
+ write: "tenant",
1762
+ share: "tenant"
1763
+ },
1764
+ domains: {
1765
+ read: "tenant",
1766
+ manage: "tenant"
1767
+ },
1768
+ automations: {
1769
+ read: "tenant",
1770
+ edit: "tenant",
1771
+ publish: "tenant",
1772
+ admin: "tenant"
1773
+ },
1774
+ reviews: { manage: "tenant" },
1775
+ leave: {
1776
+ request: "tenant",
1777
+ read: "tenant",
1778
+ approve: "tenant",
1779
+ manage: "tenant"
1780
+ },
1781
+ ledger: {
1782
+ read: "tenant",
1783
+ manage: "tenant",
1784
+ post: "tenant"
1785
+ },
1786
+ assets: {
1787
+ read: "tenant",
1788
+ manage: "tenant",
1789
+ assign: "tenant"
1790
+ },
1791
+ scores: {
1792
+ read: "tenant",
1793
+ manage: "tenant",
1794
+ compute: "tenant"
1795
+ },
1796
+ moderation: {
1797
+ read: "tenant",
1798
+ report: "tenant",
1799
+ manage: "tenant",
1800
+ ban: "tenant"
1801
+ },
1802
+ enrollments: {
1803
+ read: "tenant",
1804
+ enroll: "tenant",
1805
+ manage: "tenant"
1806
+ },
1807
+ guests: {
1808
+ read: "tenant",
1809
+ manage: "tenant"
1810
+ },
1811
+ passes: {
1812
+ read: "tenant",
1813
+ manage: "tenant",
1814
+ checkIn: "tenant"
1815
+ },
1816
+ "billable-time": {
1817
+ read: "tenant",
1818
+ manage: "tenant",
1819
+ invoice: "tenant"
1820
+ },
1821
+ leases: {
1822
+ read: "tenant",
1823
+ manage: "tenant",
1824
+ maintain: "tenant"
1825
+ },
1826
+ expenses: {
1827
+ read: "tenant",
1828
+ submit: "tenant",
1829
+ approve: "tenant",
1830
+ manage: "tenant"
1831
+ },
1832
+ donations: {
1833
+ read: "tenant",
1834
+ manage: "tenant"
1835
+ },
1836
+ dispatch: {
1837
+ read: "tenant",
1838
+ manage: "tenant",
1839
+ work: "tenant"
1840
+ },
1841
+ shipments: {
1842
+ read: "tenant",
1843
+ manage: "tenant"
1844
+ },
1845
+ contracts: {
1846
+ read: "tenant",
1847
+ write: "tenant",
1848
+ manage: "tenant"
1849
+ },
1850
+ compliance: {
1851
+ read: "tenant",
1852
+ manage: "tenant",
1853
+ collect: "tenant",
1854
+ acknowledge: "tenant"
1855
+ },
1856
+ incidents: {
1857
+ read: "tenant",
1858
+ write: "tenant",
1859
+ manage: "tenant"
1860
+ },
1861
+ courses: {
1862
+ read: "tenant",
1863
+ enroll: "tenant",
1864
+ manage: "tenant"
1865
+ },
1866
+ sequences: {
1867
+ read: "tenant",
1868
+ enroll: "tenant",
1869
+ manage: "tenant"
1870
+ },
1871
+ posts: {
1872
+ read: "tenant",
1873
+ write: "tenant",
1874
+ moderate: "tenant",
1875
+ manage: "tenant"
1876
+ },
1877
+ messaging: {
1878
+ read: "tenant",
1879
+ send: "tenant",
1880
+ moderate: "tenant"
1881
+ },
1882
+ channels: {
1883
+ read: "tenant",
1884
+ create: "tenant",
1885
+ manage: "tenant"
1886
+ },
1887
+ "mail-sync": {
1888
+ read: "tenant",
1889
+ connect: "tenant",
1890
+ send: "tenant",
1891
+ manage: "tenant"
1892
+ },
1893
+ segments: {
1894
+ read: "tenant",
1895
+ edit: "tenant"
1896
+ },
1897
+ assignment: {
1898
+ read: "tenant",
1899
+ manage: "tenant",
1900
+ assign: "tenant"
1901
+ },
1902
+ enrichment: {
1903
+ read: "tenant",
1904
+ run: "tenant"
1905
+ },
1906
+ forecasts: {
1907
+ read: "tenant",
1908
+ snapshot: "tenant"
1909
+ },
1910
+ "field-history": { read: "tenant" },
1911
+ content: {
1912
+ read: "tenant",
1913
+ write: "tenant",
1914
+ publish: "tenant"
1915
+ }
1916
+ };
1917
+ function accessModel(ctx) {
1918
+ return ctx.modules.permissions?.model ?? "roles";
1919
+ }
1920
+ /**
1921
+ * `blocks.permissions.roles`, or the default roles with their keys renamed
1922
+ * after the blocks' entities (`work_items.*` becomes `tasks.*`).
1923
+ */
1924
+ function rolesOf(ctx) {
1925
+ const configured = ctx.modules.permissions?.roles;
1926
+ if (configured !== void 0) return configured;
1927
+ const naming = ctx.blockNaming();
1928
+ const instances = ctx.instanceNamings().filter((each) => each.renamed);
1929
+ return naming.renamed || instances.length > 0 ? Object.fromEntries(Object.entries(DEFAULT_ROLES).map(([role, keys]) => [role, [...new Set(keys.flatMap((key) => [naming.rename(key), ...instances.map((each) => each.rename(key))]))]])) : DEFAULT_ROLES;
1930
+ }
1931
+ const roleNames = (ctx) => Object.keys(rolesOf(ctx));
1932
+ /**
1933
+ * The scope name tenants use in `can(scope, id, permission)`
1934
+ * (`blocks.permissions.options.scope`, default `organization`). `tenant` is
1935
+ * accepted too.
1936
+ */
1937
+ const tenantScope = (ctx) => ctx.of("permissions").text("scope", "organization");
1938
+ const isPlain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1939
+ const quotedRef = (where, table, column) => {
1940
+ const parts = `${table}.${column}`.split(".");
1941
+ if (parts.length !== 3 || parts.some((part) => !/^[A-Za-z_][A-Za-z0-9_$]*$/.test(part))) throw new TypeError(`${where}: "${table}" must be "schema.table" and "${column}" a column`);
1942
+ return {
1943
+ table: `${sqlIdent(parts[0])}.${sqlIdent(parts[1])}`,
1944
+ column: sqlIdent(parts[2])
1945
+ };
1946
+ };
1947
+ /** The `provider` model's platform role table, or `undefined` without one. */
1948
+ function providerPlatformRoles(ctx) {
1949
+ if (accessModel(ctx) !== "provider" || !ctx.installed("invitations")) return;
1950
+ const value = ctx.of("invitations").option("platformRoles");
1951
+ if (value === void 0) return;
1952
+ const where = "blocks.invitations.options.platformRoles";
1953
+ if (!isPlain(value) || typeof value["table"] !== "string" || typeof value["user"] !== "string" || typeof value["role"] !== "string" || value["canAssign"] !== void 0 && typeof value["canAssign"] !== "string" || value["canAssignFor"] !== void 0 && (typeof value["canAssignFor"] !== "string" || !value["canAssignFor"].includes("{user}"))) throw new TypeError(`${where} must be { table: "schema.table", user: "<user column>", role: "<role column>", through?: { table, id, column }, canAssign?: "<SQL template>", canAssignFor?: "<SQL template with {user}>" }`);
1954
+ const user = quotedRef(where, value["table"], value["user"]);
1955
+ const role = quotedRef(where, value["table"], value["role"]);
1956
+ const through = value["through"];
1957
+ let lookup;
1958
+ if (through !== void 0) {
1959
+ if (!isPlain(through) || typeof through["table"] !== "string" || typeof through["id"] !== "string" || typeof through["column"] !== "string" || through["where"] !== void 0 && (typeof through["where"] !== "string" || !through["where"].includes("{row}"))) throw new TypeError(`${where}.through must be { table: "schema.table", id: "<key column>", column: "<role name column>", where?: "<condition on {row}>" }`);
1960
+ const id = quotedRef(`${where}.through`, through["table"], through["id"]);
1961
+ lookup = {
1962
+ table: id.table,
1963
+ id: id.column,
1964
+ column: quotedRef(`${where}.through`, through["table"], through["column"]).column,
1965
+ ...typeof through["where"] === "string" ? { where: through["where"] } : {}
1966
+ };
1967
+ }
1968
+ return {
1969
+ table: user.table,
1970
+ user: user.column,
1971
+ role: role.column,
1972
+ ...lookup ? { through: lookup } : {},
1973
+ ...typeof value["canAssign"] === "string" ? { canAssign: value["canAssign"] } : {},
1974
+ ...typeof value["canAssignFor"] === "string" ? { canAssignFor: value["canAssignFor"] } : {}
1975
+ };
1976
+ }
1977
+ /** Whether the catalog has platform roles, and so platform invitations. */
1978
+ function hasPlatformRoles(ctx) {
1979
+ if (providerPlatformRoles(ctx)) return true;
1980
+ return accessModel(ctx) === "catalog" && ctx.of("permissions").hasTable("platformAssignments");
1981
+ }
1982
+ /**
1983
+ * Whether catalog role row `alias` is a tenant or a platform role, or
1984
+ * `undefined` when roles carry no scope. Managed catalogs have a `scope`
1985
+ * column; an adopted one maps `roles.scope` and names its values in
1986
+ * `blocks.permissions.options.tenantRoleScope` and `platformRoleScope`.
1987
+ */
1988
+ function roleScopeIs(ctx, alias, scope) {
1989
+ if (accessModel(ctx) !== "catalog") return;
1990
+ const access = ctx.of("permissions");
1991
+ if (!access.owns("roles") && typeof access.config.columns["roles"]?.["scope"] !== "string") return;
1992
+ const value = scope === "tenant" ? access.text("tenantRoleScope", "tenant") : access.text("platformRoleScope", "platform");
1993
+ return `${alias}.${access.col("roles", "scope")}::text = ${sqlString(value)}`;
1994
+ }
1995
+ const MODULE_PERMISSION_SHORTHANDS = {
1996
+ organizations: { suspendMember: "removeMember" },
1997
+ invitations: {
1998
+ revoke: "invite",
1999
+ view: "invite"
2000
+ },
2001
+ audit: { viewAll: "view" },
2002
+ billing: { viewAll: "read" },
2003
+ waitlist: { invite: {
2004
+ module: "invitations",
2005
+ action: "invite"
2006
+ } },
2007
+ "webhooks-in": {
2008
+ create: "manage",
2009
+ update: "manage",
2010
+ delete: "manage"
2011
+ }
2012
+ };
2013
+ function modulePermissionKey(ctx, action, fallback) {
2014
+ const shorthand = MODULE_PERMISSION_SHORTHANDS[ctx.module]?.[action];
2015
+ if (shorthand === void 0) return ctx.permissionKey(action, fallback);
2016
+ const target = typeof shorthand === "string" ? modulePermissionKey(ctx, shorthand, fallback) : modulePermissionKey(ctx.of(shorthand.module), shorthand.action, fallback);
2017
+ return ctx.permissionKey(action, target);
2018
+ }
2019
+ const modulePermission = (ctx, action, fallback) => sqlString(modulePermissionKey(ctx, action, fallback));
2020
+ // src/sql/modules/workflow-sdk-world-ddl.generated.ts
2021
+ /** The `@workflow/world-postgres` version the DDL below was generated from. */
2022
+ const WORLD_POSTGRES_VERSION = "5.0.4";
2023
+ /** The `workflow` schema after every migration above, as idempotent DDL. */
2024
+ const WORLD_POSTGRES_DDL = `create schema if not exists workflow;
2025
+
2026
+ do $$ begin
2027
+ create type workflow.status as enum ('pending', 'running', 'completed', 'failed', 'cancelled');
2028
+ exception when duplicate_object then null;
2029
+ end $$;
2030
+
2031
+ do $$ begin
2032
+ create type workflow.step_status as enum ('pending', 'running', 'completed', 'failed', 'cancelled');
2033
+ exception when duplicate_object then null;
2034
+ end $$;
2035
+
2036
+ do $$ begin
2037
+ create type workflow.wait_status as enum ('waiting', 'completed');
2038
+ exception when duplicate_object then null;
2039
+ end $$;
2040
+
2041
+ create table if not exists workflow.workflow_event_slots (
2042
+ "run_id" character varying not null,
2043
+ "seq_in_band" integer not null default 1,
2044
+ constraint "workflow_event_slots_pkey" PRIMARY KEY (run_id)
2045
+ );
2046
+
2047
+ alter table workflow.workflow_event_slots
2048
+ add column if not exists "run_id" character varying not null,
2049
+ add column if not exists "seq_in_band" integer not null default 1;
2050
+
2051
+ create table if not exists workflow.workflow_events (
2052
+ "id" character varying not null,
2053
+ "type" character varying not null,
2054
+ "correlation_id" character varying,
2055
+ "created_at" timestamp without time zone not null default now(),
2056
+ "run_id" character varying not null,
2057
+ "payload" jsonb,
2058
+ "payload_cbor" bytea,
2059
+ "spec_version" integer,
2060
+ "resume_id" character varying,
2061
+ "resume_payload_digest" character varying,
2062
+ constraint "workflow_events_run_id_id_pk" PRIMARY KEY (run_id, id)
2063
+ );
2064
+
2065
+ alter table workflow.workflow_events
2066
+ add column if not exists "id" character varying not null,
2067
+ add column if not exists "type" character varying not null,
2068
+ add column if not exists "correlation_id" character varying,
2069
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2070
+ add column if not exists "run_id" character varying not null,
2071
+ add column if not exists "payload" jsonb,
2072
+ add column if not exists "payload_cbor" bytea,
2073
+ add column if not exists "spec_version" integer,
2074
+ add column if not exists "resume_id" character varying,
2075
+ add column if not exists "resume_payload_digest" character varying;
2076
+
2077
+ create index if not exists workflow_events_correlation_id_index ON workflow.workflow_events USING btree (correlation_id);
2078
+
2079
+ create unique index if not exists workflow_events_entity_creation_unique ON workflow.workflow_events USING btree (run_id, correlation_id, type) WHERE ((type)::text = ANY ((ARRAY['step_created'::character varying, 'hook_created'::character varying, 'wait_created'::character varying, 'attr_set'::character varying])::text[]));
2080
+
2081
+ create unique index if not exists workflow_events_hook_resume_unique ON workflow.workflow_events USING btree (run_id, resume_id) WHERE (((type)::text = 'hook_received'::text) AND (resume_id IS NOT NULL));
2082
+
2083
+ create table if not exists workflow.workflow_hooks (
2084
+ "run_id" character varying not null,
2085
+ "hook_id" character varying not null,
2086
+ "token" character varying not null,
2087
+ "owner_id" character varying not null,
2088
+ "project_id" character varying not null,
2089
+ "environment" character varying not null,
2090
+ "created_at" timestamp without time zone not null default now(),
2091
+ "metadata" jsonb,
2092
+ "metadata_cbor" bytea,
2093
+ "spec_version" integer,
2094
+ "is_webhook" boolean default true,
2095
+ "is_system" boolean default false,
2096
+ "resume_context" bytea,
2097
+ "token_retention_until" timestamp with time zone,
2098
+ "claimed_from" bytea,
2099
+ constraint "workflow_hooks_pkey" PRIMARY KEY (hook_id)
2100
+ );
2101
+
2102
+ alter table workflow.workflow_hooks
2103
+ add column if not exists "run_id" character varying not null,
2104
+ add column if not exists "hook_id" character varying not null,
2105
+ add column if not exists "token" character varying not null,
2106
+ add column if not exists "owner_id" character varying not null,
2107
+ add column if not exists "project_id" character varying not null,
2108
+ add column if not exists "environment" character varying not null,
2109
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2110
+ add column if not exists "metadata" jsonb,
2111
+ add column if not exists "metadata_cbor" bytea,
2112
+ add column if not exists "spec_version" integer,
2113
+ add column if not exists "is_webhook" boolean default true,
2114
+ add column if not exists "is_system" boolean default false,
2115
+ add column if not exists "resume_context" bytea,
2116
+ add column if not exists "token_retention_until" timestamp with time zone,
2117
+ add column if not exists "claimed_from" bytea;
2118
+
2119
+ create index if not exists workflow_hooks_run_id_index ON workflow.workflow_hooks USING btree (run_id);
2120
+
2121
+ create index if not exists workflow_hooks_token_index ON workflow.workflow_hooks USING btree (token);
2122
+
2123
+ create table if not exists workflow.workflow_invocations (
2124
+ "sequence" bigserial,
2125
+ "run_id" character varying not null,
2126
+ "request_id" character varying not null,
2127
+ "payload" bytea,
2128
+ "fingerprint" character varying,
2129
+ "result" bytea,
2130
+ "created_at" timestamp without time zone not null default now(),
2131
+ "responded_at" timestamp without time zone,
2132
+ "expired_at" timestamp without time zone,
2133
+ "result_version" integer not null default 0,
2134
+ constraint "workflow_invocations_pkey" PRIMARY KEY (run_id, request_id)
2135
+ );
2136
+
2137
+ alter table workflow.workflow_invocations
2138
+ add column if not exists "sequence" bigserial,
2139
+ add column if not exists "run_id" character varying not null,
2140
+ add column if not exists "request_id" character varying not null,
2141
+ add column if not exists "payload" bytea,
2142
+ add column if not exists "fingerprint" character varying,
2143
+ add column if not exists "result" bytea,
2144
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2145
+ add column if not exists "responded_at" timestamp without time zone,
2146
+ add column if not exists "expired_at" timestamp without time zone,
2147
+ add column if not exists "result_version" integer not null default 0;
2148
+
2149
+ create index if not exists workflow_invocations_pending ON workflow.workflow_invocations USING btree (run_id, sequence) WHERE (responded_at IS NULL);
2150
+
2151
+ create table if not exists workflow.workflow_runs (
2152
+ "id" character varying not null,
2153
+ "output" jsonb,
2154
+ "deployment_id" character varying not null,
2155
+ "status" workflow.status not null,
2156
+ "name" character varying not null,
2157
+ "execution_context" jsonb,
2158
+ "input" jsonb,
2159
+ "error" text,
2160
+ "created_at" timestamp without time zone not null default now(),
2161
+ "updated_at" timestamp without time zone not null default now(),
2162
+ "completed_at" timestamp without time zone,
2163
+ "started_at" timestamp without time zone,
2164
+ "output_cbor" bytea,
2165
+ "execution_context_cbor" bytea,
2166
+ "input_cbor" bytea,
2167
+ "expired_at" timestamp without time zone,
2168
+ "spec_version" character varying,
2169
+ "error_cbor" bytea,
2170
+ "error_code" character varying,
2171
+ "attributes" jsonb not null default '{}'::jsonb,
2172
+ "encryption_public_key" character varying,
2173
+ "dynamic_workflow_code_cbor" bytea,
2174
+ constraint "workflow_runs_pkey" PRIMARY KEY (id)
2175
+ );
2176
+
2177
+ alter table workflow.workflow_runs
2178
+ add column if not exists "id" character varying not null,
2179
+ add column if not exists "output" jsonb,
2180
+ add column if not exists "deployment_id" character varying not null,
2181
+ add column if not exists "status" workflow.status not null,
2182
+ add column if not exists "name" character varying not null,
2183
+ add column if not exists "execution_context" jsonb,
2184
+ add column if not exists "input" jsonb,
2185
+ add column if not exists "error" text,
2186
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2187
+ add column if not exists "updated_at" timestamp without time zone not null default now(),
2188
+ add column if not exists "completed_at" timestamp without time zone,
2189
+ add column if not exists "started_at" timestamp without time zone,
2190
+ add column if not exists "output_cbor" bytea,
2191
+ add column if not exists "execution_context_cbor" bytea,
2192
+ add column if not exists "input_cbor" bytea,
2193
+ add column if not exists "expired_at" timestamp without time zone,
2194
+ add column if not exists "spec_version" character varying,
2195
+ add column if not exists "error_cbor" bytea,
2196
+ add column if not exists "error_code" character varying,
2197
+ add column if not exists "attributes" jsonb not null default '{}'::jsonb,
2198
+ add column if not exists "encryption_public_key" character varying,
2199
+ add column if not exists "dynamic_workflow_code_cbor" bytea;
2200
+
2201
+ create index if not exists workflow_runs_name_index ON workflow.workflow_runs USING btree (name);
2202
+
2203
+ create index if not exists workflow_runs_status_index ON workflow.workflow_runs USING btree (status);
2204
+
2205
+ create table if not exists workflow.workflow_snapshots (
2206
+ "run_id" character varying not null,
2207
+ "data" bytea not null,
2208
+ "events_cursor" character varying,
2209
+ "created_at" timestamp without time zone not null default now(),
2210
+ constraint "workflow_snapshots_pkey" PRIMARY KEY (run_id)
2211
+ );
2212
+
2213
+ alter table workflow.workflow_snapshots
2214
+ add column if not exists "run_id" character varying not null,
2215
+ add column if not exists "data" bytea not null,
2216
+ add column if not exists "events_cursor" character varying,
2217
+ add column if not exists "created_at" timestamp without time zone not null default now();
2218
+
2219
+ create table if not exists workflow.workflow_steps (
2220
+ "run_id" character varying not null,
2221
+ "step_id" character varying not null,
2222
+ "step_name" character varying not null,
2223
+ "status" workflow.step_status not null,
2224
+ "input" jsonb,
2225
+ "output" jsonb,
2226
+ "error" text,
2227
+ "attempt" integer not null,
2228
+ "started_at" timestamp without time zone,
2229
+ "completed_at" timestamp without time zone,
2230
+ "created_at" timestamp without time zone not null default now(),
2231
+ "updated_at" timestamp without time zone not null default now(),
2232
+ "retry_after" timestamp without time zone,
2233
+ "input_cbor" bytea,
2234
+ "output_cbor" bytea,
2235
+ "error_cbor" bytea,
2236
+ "spec_version" integer,
2237
+ constraint "workflow_steps_pkey" PRIMARY KEY (step_id)
2238
+ );
2239
+
2240
+ alter table workflow.workflow_steps
2241
+ add column if not exists "run_id" character varying not null,
2242
+ add column if not exists "step_id" character varying not null,
2243
+ add column if not exists "step_name" character varying not null,
2244
+ add column if not exists "status" workflow.step_status not null,
2245
+ add column if not exists "input" jsonb,
2246
+ add column if not exists "output" jsonb,
2247
+ add column if not exists "error" text,
2248
+ add column if not exists "attempt" integer not null,
2249
+ add column if not exists "started_at" timestamp without time zone,
2250
+ add column if not exists "completed_at" timestamp without time zone,
2251
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2252
+ add column if not exists "updated_at" timestamp without time zone not null default now(),
2253
+ add column if not exists "retry_after" timestamp without time zone,
2254
+ add column if not exists "input_cbor" bytea,
2255
+ add column if not exists "output_cbor" bytea,
2256
+ add column if not exists "error_cbor" bytea,
2257
+ add column if not exists "spec_version" integer;
2258
+
2259
+ create index if not exists workflow_steps_run_id_index ON workflow.workflow_steps USING btree (run_id);
2260
+
2261
+ create index if not exists workflow_steps_status_index ON workflow.workflow_steps USING btree (status);
2262
+
2263
+ create table if not exists workflow.workflow_stream_chunks (
2264
+ "id" character varying not null,
2265
+ "stream_id" character varying not null,
2266
+ "data" bytea not null,
2267
+ "created_at" timestamp without time zone not null default now(),
2268
+ "eof" boolean not null,
2269
+ "run_id" character varying,
2270
+ constraint "workflow_stream_chunks_stream_id_id_pk" PRIMARY KEY (stream_id, id)
2271
+ );
2272
+
2273
+ alter table workflow.workflow_stream_chunks
2274
+ add column if not exists "id" character varying not null,
2275
+ add column if not exists "stream_id" character varying not null,
2276
+ add column if not exists "data" bytea not null,
2277
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2278
+ add column if not exists "eof" boolean not null,
2279
+ add column if not exists "run_id" character varying;
2280
+
2281
+ create index if not exists workflow_stream_chunks_run_id_index ON workflow.workflow_stream_chunks USING btree (run_id);
2282
+
2283
+ create table if not exists workflow.workflow_waits (
2284
+ "wait_id" character varying not null,
2285
+ "run_id" character varying not null,
2286
+ "status" workflow.wait_status not null,
2287
+ "resume_at" timestamp without time zone,
2288
+ "completed_at" timestamp without time zone,
2289
+ "created_at" timestamp without time zone not null default now(),
2290
+ "updated_at" timestamp without time zone not null default now(),
2291
+ "spec_version" integer,
2292
+ constraint "workflow_waits_pkey" PRIMARY KEY (wait_id)
2293
+ );
2294
+
2295
+ alter table workflow.workflow_waits
2296
+ add column if not exists "wait_id" character varying not null,
2297
+ add column if not exists "run_id" character varying not null,
2298
+ add column if not exists "status" workflow.wait_status not null,
2299
+ add column if not exists "resume_at" timestamp without time zone,
2300
+ add column if not exists "completed_at" timestamp without time zone,
2301
+ add column if not exists "created_at" timestamp without time zone not null default now(),
2302
+ add column if not exists "updated_at" timestamp without time zone not null default now(),
2303
+ add column if not exists "spec_version" integer;
2304
+
2305
+ create index if not exists workflow_waits_run_id_index ON workflow.workflow_waits USING btree (run_id);
2306
+ `;
2307
+ // src/sql/modules/workflow-sdk.ts
2308
+ /** The Vault secret names the pg_net dispatcher reads. */
2309
+ const WORKFLOW_VAULT_SECRETS = {
2310
+ flowUrl: "workflow_flow_url",
2311
+ deliverySecret: "workflow_delivery_secret",
2312
+ encryptionKey: "workflow_encryption_key"
2313
+ };
2314
+ const WORKFLOW_DELIVERY_QUEUE = "workflow_deliveries";
2315
+ function deliveryModeOf(ctx) {
2316
+ const mode = ctx.text("delivery", "poll");
2317
+ if (mode !== "poll" && mode !== "pg_net") throw new TypeError(`blocks["workflow-sdk"].options.delivery must be "poll" or "pg_net", got "${mode}"`);
2318
+ return mode;
2319
+ }
2320
+ const IDENT = /^[a-z_][a-z0-9_]{0,40}$/;
2321
+ function deliveryQueueOf(ctx) {
2322
+ const queue = ctx.text("queue", WORKFLOW_DELIVERY_QUEUE);
2323
+ if (!IDENT.test(queue)) throw new TypeError(`blocks["workflow-sdk"].options.queue: "${queue}" is not a queue name`);
2324
+ return queue;
2325
+ }
2326
+ const PRINCIPAL_KINDS = "'user', 'service_principal', 'system', 'external'";
2327
+ /** The functions only the service role calls, with their argument types. */
2328
+ const SERVICE_FUNCTIONS = [
2329
+ ["workflow_claim_run_key", "text, interval"],
2330
+ ["workflow_set_run_key", "text, text"],
2331
+ ["workflow_release_run_key", "text"],
2332
+ ["workflow_purge_runs", "interval, text[], integer"],
2333
+ ["workflow_open_hooks", "text, text, integer"]
2334
+ ];
2335
+ function build(ctx) {
2336
+ if (ctx.mode === "custom") return "";
2337
+ const fn = (name) => ctx.fn(name);
2338
+ const workflows = ctx.of("workflows");
2339
+ const record = workflows.fn("record_workflow_run");
2340
+ const runKey = workflows.permission("run", OPERATIONS["workflows.run"]);
2341
+ const claimJobs = ctx.of("queue").fn("claim_jobs");
2342
+ const id = ctx.idType;
2343
+ const queue = sqlString(deliveryQueueOf(ctx));
2344
+ const batch = Math.max(1, Math.trunc(ctx.number("batch", 20)));
2345
+ const timeout = Math.max(1e3, Math.trunc(ctx.number("timeout", 3e4)));
2346
+ const lease = Math.ceil(timeout / 1e3) + 30;
2347
+ const mirror = ctx.trigger("workflow_sdk_runs_mirror");
2348
+ return `${schemaPreamble(ctx)}
2349
+ -- The Workflow SDK World's tables (@workflow/world-postgres ${WORLD_POSTGRES_VERSION}).
2350
+ -- Only the service role reads them: the app reads runs from workflow_runs in
2351
+ -- the workflows module.
2352
+ ${WORLD_POSTGRES_DDL}
2353
+
2354
+ -- One row per start idempotency key: startFor claims the key before it starts
2355
+ -- a run, so two concurrent starts with one key start one run. run_id is null
2356
+ -- while the start that claimed it is still running.
2357
+ create table if not exists workflow.workflow_run_keys (
2358
+ key text primary key check (length(key) between 1 and 500),
2359
+ run_id character varying,
2360
+ claimed_at timestamptz not null default now()
2361
+ );
2362
+ create index if not exists workflow_run_keys_run_id_idx on workflow.workflow_run_keys (run_id);
2363
+ revoke all on schema workflow from public, anon, authenticated;
2364
+ grant usage on schema workflow to service_role;
2365
+ do $$
2366
+ declare
2367
+ t record;
2368
+ begin
2369
+ for t in select c.relname from pg_catalog.pg_class c
2370
+ join pg_catalog.pg_namespace n on n.oid = c.relnamespace
2371
+ where n.nspname = 'workflow' and c.relkind = 'r'
2372
+ loop
2373
+ execute format('alter table workflow.%I enable row level security', t.relname);
2374
+ execute format('revoke all on workflow.%I from public, anon, authenticated', t.relname);
2375
+ execute format('grant all on workflow.%I to service_role', t.relname);
2376
+ end loop;
2377
+ end;
2378
+ $$;
2379
+ grant usage, select on all sequences in schema workflow to service_role;
2380
+ create index if not exists workflow_runs_attributes_idx on workflow.workflow_runs using gin (attributes jsonb_path_ops);
2381
+
2382
+ -- Copies each World run into workflow_runs: its tenant and actor come from
2383
+ -- the bsb.tenant and bsb.actor attributes that startFor sets. A run with an
2384
+ -- actor keeps its tenant only when the actor holds workflow.run there; a
2385
+ -- run without one, or one with bsb.principal_kind (a runAs start, whose
2386
+ -- actor is the user who triggered it), was started by the server, which is
2387
+ -- trusted. bsb.subject
2388
+ -- (type/id), bsb.principal_kind, bsb.principal, bsb.mode and bsb.trigger_node
2389
+ -- fill the run's subject, principal, mode and trigger node.
2390
+ create or replace function ${fn("workflow_sdk_mirror_run")}()
2391
+ returns trigger
2392
+ language plpgsql
2393
+ security definer
2394
+ set search_path = ''
2395
+ as $$
2396
+ declare
2397
+ v_tenant ${id};
2398
+ v_actor uuid;
2399
+ v_subject text;
2400
+ v_subject_type text;
2401
+ v_subject_id text;
2402
+ v_principal_kind text;
2403
+ v_mode text;
2404
+ begin
2405
+ begin
2406
+ v_tenant := (new.attributes ->> 'bsb.tenant')::${id};
2407
+ exception when others then
2408
+ v_tenant := null;
2409
+ end;
2410
+ begin
2411
+ v_actor := (new.attributes ->> 'bsb.actor')::uuid;
2412
+ exception when others then
2413
+ v_actor := null;
2414
+ end;
2415
+ v_principal_kind := new.attributes ->> 'bsb.principal_kind';
2416
+ if v_principal_kind is not null and v_principal_kind not in (${PRINCIPAL_KINDS}) then
2417
+ v_principal_kind := null;
2418
+ end if;
2419
+ if v_tenant is not null and v_actor is not null and v_principal_kind is null
2420
+ and not ${ctx.scope.canUser("v_actor", "v_tenant", runKey)} then
2421
+ v_tenant := null;
2422
+ end if;
2423
+ v_subject := new.attributes ->> 'bsb.subject';
2424
+ if v_subject is not null and position('/' in v_subject) between 2 and 101
2425
+ and length(v_subject) - position('/' in v_subject) between 1 and 200 then
2426
+ v_subject_type := left(v_subject, position('/' in v_subject) - 1);
2427
+ v_subject_id := substr(v_subject, position('/' in v_subject) + 1);
2428
+ end if;
2429
+ v_mode := case when new.attributes ->> 'bsb.mode' = 'test' then 'test' else 'live' end;
2430
+ perform ${record}(
2431
+ 'workflow-sdk',
2432
+ new.id,
2433
+ new.name,
2434
+ case new.status::text when 'pending' then 'queued' else new.status::text end,
2435
+ v_tenant,
2436
+ v_actor,
2437
+ coalesce(new.attributes, '{}'::jsonb) - 'bsb.tenant' - 'bsb.actor' - 'bsb.subject' - 'bsb.principal_kind' - 'bsb.principal' - 'bsb.mode' - 'bsb.trigger_node',
2438
+ case when new.status::text = 'failed' then coalesce(new.error_code, left(new.error, 4000)) end,
2439
+ new.started_at at time zone 'UTC',
2440
+ new.completed_at at time zone 'UTC',
2441
+ v_subject_type,
2442
+ v_subject_id,
2443
+ v_principal_kind,
2444
+ case when v_principal_kind is null then null else nullif(left(new.attributes ->> 'bsb.principal', 200), '') end,
2445
+ v_mode,
2446
+ nullif(left(new.attributes ->> 'bsb.trigger_node', 100), '')
2447
+ );
2448
+ return null;
2449
+ end;
2450
+ $$;
2451
+ revoke execute on function ${fn("workflow_sdk_mirror_run")}() from public, anon, authenticated;
2452
+ drop trigger if exists ${mirror} on workflow.workflow_runs;
2453
+ create trigger ${mirror} after insert or update of status, attributes, error on workflow.workflow_runs
2454
+ for each row execute function ${fn("workflow_sdk_mirror_run")}();
2455
+
2456
+ -- pg_net delivery: posts up to batch due messages to the flow route in the
2457
+ -- Vault secret ${WORKFLOW_VAULT_SECRETS.flowUrl}, signed with ${WORKFLOW_VAULT_SECRETS.deliverySecret}
2458
+ -- (x-bsb-signature: t=<unix>,v1=hex(hmac_sha256(t.job.body))). The body is
2459
+ -- the stored message; the route completes or fails the job, so a delivery
2460
+ -- whose response is lost runs again after the lease.
2461
+ create or replace function ${fn("dispatch_workflow_deliveries")}(batch integer default ${String(batch)})
2462
+ returns integer
2463
+ language plpgsql
2464
+ security definer
2465
+ set search_path = ''
2466
+ as $$
2467
+ declare
2468
+ v_url text;
2469
+ v_secret text;
2470
+ v_job record;
2471
+ v_body jsonb;
2472
+ v_t text;
2473
+ v_job_header text;
2474
+ v_count integer := 0;
2475
+ -- pg_net is optional: http_post is looked up, not named, so plpgsql_check
2476
+ -- (supabase db lint) passes without the extension.
2477
+ v_post regprocedure := pg_catalog.to_regprocedure('net.http_post(text, jsonb, jsonb, jsonb, integer)');
2478
+ begin
2479
+ if v_post is null then
2480
+ raise exception 'dispatch_workflow_deliveries needs pg_net: create extension pg_net, or deliver with the poll mode';
2481
+ end if;
2482
+ select ds.decrypted_secret into v_url from vault.decrypted_secrets ds where ds.name = ${sqlString(WORKFLOW_VAULT_SECRETS.flowUrl)};
2483
+ select ds.decrypted_secret into v_secret from vault.decrypted_secrets ds where ds.name = ${sqlString(WORKFLOW_VAULT_SECRETS.deliverySecret)};
2484
+ if v_url is null or v_secret is null then
2485
+ raise exception 'Set the Vault secrets ${WORKFLOW_VAULT_SECRETS.flowUrl} and ${WORKFLOW_VAULT_SECRETS.deliverySecret} before dispatching' using hint = 'WORKFLOW_DELIVERY_UNCONFIGURED';
2486
+ end if;
2487
+ for v_job in select * from ${claimJobs}(${queue}, ${String(lease)}, greatest(coalesce(batch, ${String(batch)}), 1)) loop
2488
+ v_body := coalesce(v_job.message -> 'payload', '{}'::jsonb);
2489
+ v_t := floor(extract(epoch from now()))::bigint::text;
2490
+ v_job_header := ${queue} || ':' || v_job.id::text || ':' || v_job.attempts::text;
2491
+ execute format('select %s(url := $1, body := $2, headers := $3, timeout_milliseconds := $4)', v_post::oid::regproc)
2492
+ using v_url, v_body, jsonb_build_object(
2493
+ 'content-type', 'application/json',
2494
+ 'x-bsb-job', v_job_header,
2495
+ 'x-bsb-signature', 't=' || v_t || ',v1=' || encode(extensions.hmac(v_t || '.' || v_job_header || '.' || v_body::text, v_secret, 'sha256'), 'hex')
2496
+ ), ${String(timeout)};
2497
+ v_count := v_count + 1;
2498
+ end loop;
2499
+ return v_count;
2500
+ end;
2501
+ $$;
2502
+ revoke execute on function ${fn("dispatch_workflow_deliveries")}(integer) from public, anon, authenticated;
2503
+ grant execute on function ${fn("dispatch_workflow_deliveries")}(integer) to service_role;
2504
+
2505
+ -- Claims a start key: claimed is true when this caller may start the run,
2506
+ -- either because the key is new or because the start that claimed it left no
2507
+ -- run for stale_after. Otherwise run_id is the run of the earlier start (null
2508
+ -- while that start is still running).
2509
+ create or replace function ${fn("workflow_claim_run_key")}(run_key text, stale_after interval default '5 minutes')
2510
+ returns table (claimed boolean, run_id text)
2511
+ language plpgsql
2512
+ security definer
2513
+ set search_path = ''
2514
+ as $$
2515
+ #variable_conflict use_column
2516
+ begin
2517
+ return query
2518
+ insert into workflow.workflow_run_keys as k (key) values (run_key)
2519
+ on conflict (key) do update set claimed_at = now()
2520
+ where k.run_id is null and k.claimed_at < now() - coalesce(stale_after, interval '5 minutes')
2521
+ returning true, k.run_id::text;
2522
+ if not found then
2523
+ return query select false, k.run_id::text from workflow.workflow_run_keys k where k.key = run_key;
2524
+ end if;
2525
+ end;
2526
+ $$;
2527
+
2528
+ -- Records the run a claimed key started.
2529
+ create or replace function ${fn("workflow_set_run_key")}(run_key text, run text)
2530
+ returns void
2531
+ language sql
2532
+ security definer
2533
+ set search_path = ''
2534
+ as $$
2535
+ update workflow.workflow_run_keys set run_id = run, claimed_at = now() where key = run_key;
2536
+ $$;
2537
+
2538
+ -- Frees a key whose start failed before it created a run.
2539
+ create or replace function ${fn("workflow_release_run_key")}(run_key text)
2540
+ returns void
2541
+ language sql
2542
+ security definer
2543
+ set search_path = ''
2544
+ as $$
2545
+ delete from workflow.workflow_run_keys where key = run_key and run_id is null;
2546
+ $$;
2547
+
2548
+ -- Deletes up to batch terminal runs that ended more than older_than ago, with
2549
+ -- their events, steps, waits, streams, snapshots and invocations; hooks whose
2550
+ -- token is still reserved (token_retention_until) stay, so a token can't be
2551
+ -- reused. The copies in workflow_runs follow purge_workflow_runs instead.
2552
+ create or replace function ${fn("workflow_purge_runs")}(
2553
+ older_than interval default '30 days',
2554
+ statuses text[] default array['completed', 'failed', 'cancelled'],
2555
+ batch integer default 500
2556
+ )
2557
+ returns integer
2558
+ language plpgsql
2559
+ security definer
2560
+ set search_path = ''
2561
+ as $$
2562
+ declare
2563
+ v_statuses text[] := coalesce(statuses, array['completed', 'failed', 'cancelled']);
2564
+ v_ids text[];
2565
+ v_count integer;
2566
+ begin
2567
+ if exists (select 1 from unnest(v_statuses) s where s not in ('completed', 'failed', 'cancelled')) then
2568
+ raise exception 'workflow_purge_runs deletes only completed, failed or cancelled runs'
2569
+ using errcode = '22023', hint = 'WORKFLOW_PURGE_STATUS';
2570
+ end if;
2571
+ select coalesce(array_agg(x.id), '{}') into v_ids from (
2572
+ select r.id from workflow.workflow_runs r
2573
+ where r.status::text = any (v_statuses)
2574
+ and coalesce(r.completed_at, r.updated_at) < (now() at time zone 'UTC') - coalesce(older_than, interval '30 days')
2575
+ order by coalesce(r.completed_at, r.updated_at)
2576
+ limit least(greatest(coalesce(batch, 500), 1), 10000)
2577
+ for update skip locked
2578
+ ) x;
2579
+ if cardinality(v_ids) = 0 then
2580
+ return 0;
2581
+ end if;
2582
+ delete from workflow.workflow_events where run_id = any (v_ids);
2583
+ delete from workflow.workflow_event_slots where run_id = any (v_ids);
2584
+ delete from workflow.workflow_steps where run_id = any (v_ids);
2585
+ delete from workflow.workflow_waits where run_id = any (v_ids);
2586
+ delete from workflow.workflow_stream_chunks where run_id = any (v_ids);
2587
+ delete from workflow.workflow_snapshots where run_id = any (v_ids);
2588
+ delete from workflow.workflow_invocations where run_id = any (v_ids);
2589
+ delete from workflow.workflow_hooks
2590
+ where run_id = any (v_ids) and (token_retention_until is null or token_retention_until < now());
2591
+ delete from workflow.workflow_run_keys where run_id = any (v_ids);
2592
+ delete from workflow.workflow_runs where id = any (v_ids);
2593
+ get diagnostics v_count = row_count;
2594
+ return v_count;
2595
+ end;
2596
+ $$;
2597
+
2598
+ -- The hooks of pending and running runs, newest first: what a run waits on.
2599
+ -- The token is left out; the app that created a hook knows it.
2600
+ create or replace function ${fn("workflow_open_hooks")}(
2601
+ tenant text default null,
2602
+ workflow_name text default null,
2603
+ max integer default 50
2604
+ )
2605
+ returns table (
2606
+ hook_id text,
2607
+ run_id text,
2608
+ workflow text,
2609
+ tenant_id text,
2610
+ actor_id text,
2611
+ metadata jsonb,
2612
+ created_at timestamptz
2613
+ )
2614
+ language sql
2615
+ stable
2616
+ security definer
2617
+ set search_path = ''
2618
+ as $$
2619
+ select h.hook_id::text, h.run_id::text, r.name::text,
2620
+ r.attributes ->> 'bsb.tenant', r.attributes ->> 'bsb.actor',
2621
+ h.metadata, h.created_at at time zone 'UTC'
2622
+ from workflow.workflow_hooks h
2623
+ join workflow.workflow_runs r on r.id = h.run_id
2624
+ where r.status::text in ('pending', 'running')
2625
+ and not coalesce(h.is_system, false)
2626
+ and (workflow_open_hooks.tenant is null or r.attributes ->> 'bsb.tenant' = workflow_open_hooks.tenant)
2627
+ and (workflow_open_hooks.workflow_name is null or r.name = workflow_open_hooks.workflow_name)
2628
+ order by h.created_at desc
2629
+ limit least(greatest(coalesce(workflow_open_hooks.max, 50), 1), 500);
2630
+ $$;
2631
+ ${SERVICE_FUNCTIONS.map(([name, args]) => `revoke execute on function ${fn(name)}(${args}) from public, anon, authenticated;
2632
+ grant execute on function ${fn(name)}(${args}) to service_role;`).join("\n")}`;
2633
+ }
2634
+ const RETENTION = /^\d{1,4} (?:day|days|hour|hours)$/u;
2635
+ function retentionOf(ctx) {
2636
+ const retention = ctx.text("retention", "");
2637
+ if (retention === "") return;
2638
+ if (!RETENTION.test(retention)) throw new TypeError(`blocks["workflow-sdk"].options.retention must look like "30 days" or "12 hours", got "${retention}"`);
2639
+ return retention;
2640
+ }
2641
+ function cronJob(name, schedule, command, notice) {
2642
+ return `do $$
2643
+ begin
2644
+ if pg_catalog.to_regnamespace('cron') is not null then
2645
+ perform cron.schedule(${sqlString(name)}, ${sqlString(schedule)}, ${sqlString(command)});
2646
+ else
2647
+ raise notice ${sqlString(notice)};
2648
+ end if;
2649
+ end;
2650
+ $$;`;
2651
+ }
2652
+ function data(ctx) {
2653
+ if (ctx.mode === "custom") return "";
2654
+ const parts = [];
2655
+ if (deliveryModeOf(ctx) === "pg_net") {
2656
+ const schedule = ctx.text("schedule", "1 seconds");
2657
+ const dispatch = ctx.fn("dispatch_workflow_deliveries");
2658
+ parts.push(`-- Delivers workflow messages through pg_net every ${schedule} when pg_cron is installed.
2659
+ ${cronJob("better-supabase-workflow-deliveries", schedule, `select ${dispatch}()`, `pg_cron is not installed: call ${dispatch}() on a schedule to deliver workflow messages`)}`);
2660
+ }
2661
+ const retention = retentionOf(ctx);
2662
+ if (retention !== void 0) {
2663
+ const purge = ctx.fn("workflow_purge_runs");
2664
+ parts.push(`-- Deletes the World's runs that ended more than ${retention} ago, every hour.
2665
+ ${cronJob("better-supabase-workflow-purge", "17 * * * *", `select ${purge}(interval ${sqlString(retention)})`, `pg_cron is not installed: run better-supabase db prune-workflows on a schedule to delete old workflow runs`)}`);
2666
+ }
2667
+ return parts.join("\n\n");
2668
+ }
2669
+ function contract() {
2670
+ return [
2671
+ {
2672
+ name: "dispatch_workflow_deliveries",
2673
+ args: ["integer"],
2674
+ returns: "integer"
2675
+ },
2676
+ {
2677
+ name: "workflow_claim_run_key",
2678
+ args: ["text", "interval"],
2679
+ returns: "record"
2680
+ },
2681
+ {
2682
+ name: "workflow_set_run_key",
2683
+ args: ["text", "text"],
2684
+ returns: "void"
2685
+ },
2686
+ {
2687
+ name: "workflow_release_run_key",
2688
+ args: ["text"],
2689
+ returns: "void"
2690
+ },
2691
+ {
2692
+ name: "workflow_purge_runs",
2693
+ args: [
2694
+ "interval",
2695
+ "text[]",
2696
+ "integer"
2697
+ ],
2698
+ returns: "integer"
2699
+ },
2700
+ {
2701
+ name: "workflow_open_hooks",
2702
+ args: [
2703
+ "text",
2704
+ "text",
2705
+ "integer"
2706
+ ],
2707
+ returns: "record"
2708
+ }
2709
+ ];
2710
+ }
2711
+ const WORKFLOW_SDK_WORLD = {
2712
+ name: "workflow-sdk",
2713
+ scopes: ["tenant"],
2714
+ title: "Workflow SDK World",
2715
+ description: `The tables of the Workflow SDK World (@workflow/world-postgres ${WORLD_POSTGRES_VERSION}) in the workflow schema, closed to the API roles; a trigger that copies each run into workflow_runs, a pg_net dispatcher for the delivery queue on a pg_cron schedule, start idempotency keys, a list of the hooks open runs wait on and a purge of ended runs.`,
2716
+ requires: [
2717
+ "workflows",
2718
+ "queue",
2719
+ "permissions"
2720
+ ],
2721
+ providerFunctions: ["idsWithFor"],
2722
+ target: "schema",
2723
+ modes: ["managed", "custom"],
2724
+ version: 3,
2725
+ upgrades: [{
2726
+ from: 1,
2727
+ description: "The run trigger fills subject, principal, mode and trigger node from the bsb.subject, bsb.principal_kind, bsb.principal, bsb.mode and bsb.trigger_node attributes, and a runAs start keeps bsb.actor as the user who triggered it.",
2728
+ sql: () => ""
2729
+ }, {
2730
+ from: 2,
2731
+ description: "workflow.workflow_run_keys holds start idempotency keys (workflow_claim_run_key, workflow_set_run_key, workflow_release_run_key); workflow_open_hooks lists the hooks open runs wait on; workflow_purge_runs deletes ended runs, hourly when the retention option is set.",
2732
+ sql: () => ""
2733
+ }],
2734
+ names: {
2735
+ tables: {},
2736
+ options: [
2737
+ "delivery",
2738
+ "queue",
2739
+ "batch",
2740
+ "timeout",
2741
+ "schedule",
2742
+ "retention"
2743
+ ]
2744
+ },
2745
+ contract,
2746
+ build,
2747
+ data
2748
+ };
2749
+ export { ownRowPolicies as $, addForeignKey as A, ensureCheck as B, PARTITION_VARIABLES as C, activeMembership as D, accessDefinesDisabledHelpers as E, defaultPartition as F, jsonSchemaChecks as G, extraFieldsJson as H, defaultPartitionName as I, memberAddedRecord as J, jwtClaim as K, disabledHelpers as L, batchFunction as M, columnRef as N, addCheck as O, columnsObject as P, organizationMissing as Q, disabledHelpersNeedLaterTables as R, NOTHING as S, SERVICE_CALLER as T, fail as U, extraFieldsArg as V, insertExtraColumns as W, membershipSuspended as X, membershipDisabledAt as Y, notNullCheckName as Z, roleScopeIs as _, withExtraFields as _t, DEFAULT_ROLES as a, renameSql as at, EQUIVALENT_TRIGGERS as b, OPTIONAL_MODULE_PERMISSIONS as c, schemaPreamble as ct, isOperationModule as d, sha256Hex as dt, pageSize as et, moduleOperations as f, shortHash as ft, roleNames as g, userGrant as gt, providerPlatformRoles as h, updatedAt as ht, WORLD_POSTGRES_VERSION as i, registerPartitions as it, addNotNullCheck as j, addExtraColumns as k, accessModel as l, serviceGrant as lt, modulePermissionKey as m, triggerGrant as mt, WORKFLOW_SDK_WORLD as n, raise as nt, MODULE_PERMISSION_SCOPES as o, replaceColumnCheck as ot, modulePermission as p, splitTable as pt, lockTable as q, WORKFLOW_VAULT_SECRETS as r, recordTrigger as rt, OPERATIONS as s, revokeTable as st, WORKFLOW_DELIVERY_QUEUE as t, quotedTable as tt, hasPlatformRoles as u, serviceOnly as ut, rolesOf as v, writeExtraColumns as vt, SCHEMA as w, MONTHLY_PARTITIONS as x, tenantScope as y, dropExpiredPartitions as z };