better-supabase 0.18.3 → 0.19.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 (439) hide show
  1. package/dist/{ai-cache-Cu8j6aQQ.js → ai-cache-BuNbWEFI.js} +2 -2
  2. package/dist/{ai-files-CgFCRsnU.js → ai-files-DeMWQfzs.js} +2 -2
  3. package/dist/{ai-schedules-DzLh6BYI.d.ts → ai-schedules-B20M2SIi.d.ts} +1 -1
  4. package/dist/ai-sdk/agents/index.d.ts +2 -2
  5. package/dist/ai-sdk/batches/index.js +1 -1
  6. package/dist/ai-sdk/cache/index.js +1 -1
  7. package/dist/ai-sdk/files/index.js +2 -2
  8. package/dist/ai-sdk/mcp/index.js +1 -1
  9. package/dist/{api-B6zteBya.d.ts → api-BiOgjXn5.d.ts} +1 -1
  10. package/dist/{app-tables-atP-tZKZ.d.ts → app-tables-Q29TR4W9.d.ts} +1 -1
  11. package/dist/astro/index.d.ts +3 -3
  12. package/dist/{attachments-M-Dy79Ry.js → attachments-BTIwCuwm.js} +4 -4
  13. package/dist/{authorization-IiE__z2m.d.ts → authorization-08F77H2w.d.ts} +3 -0
  14. package/dist/{automations-B5P6vTvk.js → automations-EzXteupo.js} +2 -1
  15. package/dist/{automations-BYsz43AG.js → automations-jIIaT9EJ.js} +3 -3
  16. package/dist/better-result/index.d.ts +2 -2
  17. package/dist/{bind-pu5TLrla.d.ts → bind-wkfp7hgx.d.ts} +4 -4
  18. package/dist/{block-authors-BDV3y1SP.js → block-authors-D9hyCizs.js} +1 -1
  19. package/dist/{block-env-CA65ulTD.d.ts → block-env-D-zK3_Ta.d.ts} +4 -4
  20. package/dist/{block-helpers-CtBdjgO4.js → block-helpers-DnCtsKtv.js} +2 -83
  21. package/dist/{block-hooks-BfxX3682.js → block-hooks-DbIpkq7a.js} +1 -1
  22. package/dist/{block-subjects-BhDKK_j7.js → block-subjects-BRJO0IqO.js} +1 -1
  23. package/dist/block-transport-PNea4lfQ.js +84 -0
  24. package/dist/blocks/access-requests/index.d.ts +1 -1
  25. package/dist/blocks/access-requests/index.js +3 -2
  26. package/dist/blocks/activities/index.d.ts +1 -1
  27. package/dist/blocks/activities/index.js +3 -2
  28. package/dist/blocks/agents/index.d.ts +1 -1
  29. package/dist/blocks/agents/index.js +3 -2
  30. package/dist/blocks/ai-cache/index.d.ts +1 -1
  31. package/dist/blocks/ai-cache/index.js +2 -2
  32. package/dist/blocks/ai-chat/index.d.ts +4 -4
  33. package/dist/blocks/ai-chat/index.js +3 -2
  34. package/dist/blocks/ai-files/index.d.ts +1 -1
  35. package/dist/blocks/ai-files/index.js +2 -2
  36. package/dist/blocks/ai-keys/index.d.ts +1 -1
  37. package/dist/blocks/ai-keys/index.js +3 -2
  38. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  39. package/dist/blocks/ai-schedules/index.js +3 -2
  40. package/dist/blocks/announcements/index.d.ts +4 -4
  41. package/dist/blocks/announcements/index.js +3 -2
  42. package/dist/blocks/api-keys/index.d.ts +2 -2
  43. package/dist/blocks/api-keys/index.js +3 -2
  44. package/dist/blocks/approvals/index.d.ts +1 -1
  45. package/dist/blocks/approvals/index.js +4 -3
  46. package/dist/blocks/assets/index.d.ts +1 -1
  47. package/dist/blocks/assets/index.js +3 -2
  48. package/dist/blocks/assignment/index.d.ts +1 -1
  49. package/dist/blocks/assignment/index.js +4 -3
  50. package/dist/blocks/attachments/index.d.ts +2 -2
  51. package/dist/blocks/attachments/index.js +3 -2
  52. package/dist/blocks/audit/index.d.ts +5 -5
  53. package/dist/blocks/audit/index.js +5 -4
  54. package/dist/blocks/automations/index.d.ts +3 -3
  55. package/dist/blocks/automations/index.js +4 -4
  56. package/dist/blocks/billable-time/index.d.ts +1 -1
  57. package/dist/blocks/billable-time/index.js +4 -3
  58. package/dist/blocks/billing/index.d.ts +3 -3
  59. package/dist/blocks/billing/index.js +4 -3
  60. package/dist/blocks/bookings/index.d.ts +2 -2
  61. package/dist/blocks/bookings/index.js +3 -3
  62. package/dist/blocks/bulk/index.d.ts +1 -1
  63. package/dist/blocks/bulk/index.js +2 -2
  64. package/dist/blocks/calendar/index.d.ts +2 -2
  65. package/dist/blocks/calendar/index.js +2 -2
  66. package/dist/blocks/catalog/index.d.ts +1 -1
  67. package/dist/blocks/catalog/index.js +4 -3
  68. package/dist/blocks/channels/index.d.ts +1 -1
  69. package/dist/blocks/channels/index.js +3 -2
  70. package/dist/blocks/collections/index.d.ts +1 -1
  71. package/dist/blocks/collections/index.js +3 -2
  72. package/dist/blocks/comments/index.d.ts +5 -5
  73. package/dist/blocks/comments/index.js +6 -5
  74. package/dist/blocks/compliance/index.d.ts +1 -1
  75. package/dist/blocks/compliance/index.js +3 -2
  76. package/dist/blocks/connectors/index.d.ts +1 -1
  77. package/dist/blocks/connectors/index.js +3 -2
  78. package/dist/blocks/contacts/index.d.ts +1 -1
  79. package/dist/blocks/contacts/index.js +3 -2
  80. package/dist/blocks/content/index.d.ts +1 -1
  81. package/dist/blocks/content/index.js +3 -2
  82. package/dist/blocks/contracts/index.d.ts +1 -1
  83. package/dist/blocks/contracts/index.js +5 -4
  84. package/dist/blocks/courses/index.d.ts +1 -1
  85. package/dist/blocks/courses/index.js +3 -2
  86. package/dist/blocks/created-by/index.d.ts +1 -1
  87. package/dist/blocks/custom-fields/index.d.ts +1 -1
  88. package/dist/blocks/custom-fields/index.js +2 -2
  89. package/dist/blocks/data-lifecycle/index.d.ts +1 -1
  90. package/dist/blocks/data-lifecycle/index.js +3 -2
  91. package/dist/blocks/deals/index.d.ts +1 -1
  92. package/dist/blocks/deals/index.js +8 -7
  93. package/dist/blocks/dispatch/index.d.ts +1 -1
  94. package/dist/blocks/dispatch/index.js +4 -3
  95. package/dist/blocks/documents/index.d.ts +1 -1
  96. package/dist/blocks/documents/index.js +3 -2
  97. package/dist/blocks/domains/index.d.ts +1 -1
  98. package/dist/blocks/domains/index.js +4 -3
  99. package/dist/blocks/donations/index.d.ts +1 -1
  100. package/dist/blocks/donations/index.js +4 -3
  101. package/dist/blocks/drive/index.d.ts +1 -1
  102. package/dist/blocks/drive/index.js +4 -3
  103. package/dist/blocks/employees/index.d.ts +2 -2
  104. package/dist/blocks/employees/index.js +5 -4
  105. package/dist/blocks/enrichment/index.d.ts +1 -1
  106. package/dist/blocks/enrichment/index.js +3 -2
  107. package/dist/blocks/enrollments/index.d.ts +1 -1
  108. package/dist/blocks/enrollments/index.js +3 -2
  109. package/dist/blocks/entitlements/index.d.ts +3 -3
  110. package/dist/blocks/entitlements/index.js +2 -2
  111. package/dist/blocks/expenses/index.d.ts +1 -1
  112. package/dist/blocks/expenses/index.js +4 -3
  113. package/dist/blocks/field-history/index.d.ts +1 -1
  114. package/dist/blocks/field-history/index.js +3 -2
  115. package/dist/blocks/flags/index.d.ts +1 -1
  116. package/dist/blocks/flags/index.js +4 -3
  117. package/dist/blocks/forecasts/index.d.ts +1 -1
  118. package/dist/blocks/forecasts/index.js +6 -5
  119. package/dist/blocks/forms/index.d.ts +2 -2
  120. package/dist/blocks/forms/index.js +3 -2
  121. package/dist/blocks/goals/index.d.ts +1 -1
  122. package/dist/blocks/goals/index.js +4 -3
  123. package/dist/blocks/guests/index.d.ts +1 -1
  124. package/dist/blocks/guests/index.js +3 -2
  125. package/dist/blocks/hiring/index.d.ts +1 -1
  126. package/dist/blocks/hiring/index.js +4 -3
  127. package/dist/blocks/identities/index.d.ts +1 -1
  128. package/dist/blocks/identities/index.js +3 -2
  129. package/dist/blocks/imports/index.d.ts +1 -1
  130. package/dist/blocks/imports/index.js +2 -2
  131. package/dist/blocks/inbox/index.d.ts +5 -5
  132. package/dist/blocks/inbox/index.js +4 -3
  133. package/dist/blocks/incidents/index.d.ts +1 -1
  134. package/dist/blocks/incidents/index.js +3 -2
  135. package/dist/blocks/index.d.ts +2 -2
  136. package/dist/blocks/index.js +4 -4
  137. package/dist/blocks/inventory/index.d.ts +1 -1
  138. package/dist/blocks/inventory/index.js +3 -2
  139. package/dist/blocks/invoices/index.d.ts +2 -2
  140. package/dist/blocks/invoices/index.js +7 -6
  141. package/dist/blocks/knowledge/index.d.ts +1 -1
  142. package/dist/blocks/knowledge/index.js +2 -2
  143. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  144. package/dist/blocks/lead-scoring/index.js +5 -4
  145. package/dist/blocks/leases/index.d.ts +1 -1
  146. package/dist/blocks/leases/index.js +4 -3
  147. package/dist/blocks/leave/index.d.ts +1 -1
  148. package/dist/blocks/leave/index.js +3 -2
  149. package/dist/blocks/ledger/index.d.ts +1 -1
  150. package/dist/blocks/ledger/index.js +3 -2
  151. package/dist/blocks/mail-sync/index.d.ts +1 -1
  152. package/dist/blocks/mail-sync/index.js +3 -2
  153. package/dist/blocks/memberships/index.d.ts +1 -1
  154. package/dist/blocks/memory/index.d.ts +1 -1
  155. package/dist/blocks/memory/index.js +4 -3
  156. package/dist/blocks/messaging/index.d.ts +5 -5
  157. package/dist/blocks/messaging/index.js +5 -4
  158. package/dist/blocks/metrics/index.d.ts +1 -1
  159. package/dist/blocks/metrics/index.js +3 -2
  160. package/dist/blocks/mfa/index.d.ts +2 -2
  161. package/dist/blocks/moderation/index.d.ts +1 -1
  162. package/dist/blocks/moderation/index.js +3 -2
  163. package/dist/blocks/notifications/index.d.ts +4 -4
  164. package/dist/blocks/notifications/index.js +4 -3
  165. package/dist/blocks/numbering/index.d.ts +1 -1
  166. package/dist/blocks/numbering/index.js +2 -2
  167. package/dist/blocks/oauth-server/index.d.ts +1 -1
  168. package/dist/blocks/oauth-server/index.js +3 -2
  169. package/dist/blocks/onboarding/index.d.ts +2 -2
  170. package/dist/blocks/onboarding/index.js +3 -2
  171. package/dist/blocks/orders/index.d.ts +2 -2
  172. package/dist/blocks/orders/index.js +5 -4
  173. package/dist/blocks/organizations/index.d.ts +3 -3
  174. package/dist/blocks/organizations/index.js +3 -2
  175. package/dist/blocks/outbox/index.d.ts +1 -1
  176. package/dist/blocks/outbox/index.js +3 -2
  177. package/dist/blocks/passes/index.d.ts +1 -1
  178. package/dist/blocks/passes/index.js +5 -4
  179. package/dist/blocks/permissions/index.d.ts +3 -3
  180. package/dist/blocks/permissions/index.js +3 -2
  181. package/dist/blocks/pipelines/index.d.ts +1 -1
  182. package/dist/blocks/pipelines/index.js +4 -3
  183. package/dist/blocks/posts/index.d.ts +1 -1
  184. package/dist/blocks/posts/index.js +3 -2
  185. package/dist/blocks/profiles/index.d.ts +1 -1
  186. package/dist/blocks/profiles/index.js +3 -2
  187. package/dist/blocks/promotions/index.d.ts +1 -1
  188. package/dist/blocks/promotions/index.js +4 -3
  189. package/dist/blocks/push/index.d.ts +2 -2
  190. package/dist/blocks/push/index.js +3 -2
  191. package/dist/blocks/queue/index.d.ts +1 -1
  192. package/dist/blocks/queue/index.js +4 -3
  193. package/dist/blocks/quotes/index.d.ts +2 -2
  194. package/dist/blocks/quotes/index.js +7 -6
  195. package/dist/blocks/rank/index.d.ts +1 -1
  196. package/dist/blocks/rank/index.js +2 -2
  197. package/dist/blocks/reactions/index.d.ts +4 -4
  198. package/dist/blocks/reactions/index.js +4 -3
  199. package/dist/blocks/relations/index.d.ts +1 -1
  200. package/dist/blocks/relations/index.js +4 -4
  201. package/dist/blocks/reminders/index.d.ts +1 -1
  202. package/dist/blocks/reminders/index.js +4 -4
  203. package/dist/blocks/reviews/index.d.ts +1 -1
  204. package/dist/blocks/reviews/index.js +3 -2
  205. package/dist/blocks/saved-views/index.d.ts +3 -3
  206. package/dist/blocks/saved-views/index.js +2 -2
  207. package/dist/blocks/scores/index.d.ts +1 -1
  208. package/dist/blocks/scores/index.js +3 -3
  209. package/dist/blocks/search/index.d.ts +3 -3
  210. package/dist/blocks/search/index.js +3 -2
  211. package/dist/blocks/security-events/index.d.ts +1 -1
  212. package/dist/blocks/security-events/index.js +3 -2
  213. package/dist/blocks/segments/index.d.ts +1 -1
  214. package/dist/blocks/segments/index.js +4 -3
  215. package/dist/blocks/sequences/index.d.ts +1 -1
  216. package/dist/blocks/sequences/index.js +3 -2
  217. package/dist/blocks/service-accounts/index.d.ts +1 -1
  218. package/dist/blocks/service-accounts/index.js +3 -2
  219. package/dist/blocks/sessions/index.d.ts +2 -2
  220. package/dist/blocks/sessions/index.js +1 -1
  221. package/dist/blocks/settings/index.d.ts +2 -2
  222. package/dist/blocks/settings/index.js +3 -2
  223. package/dist/blocks/share-links/index.d.ts +1 -1
  224. package/dist/blocks/share-links/index.js +3 -3
  225. package/dist/blocks/shipments/index.d.ts +1 -1
  226. package/dist/blocks/shipments/index.js +5 -4
  227. package/dist/blocks/signatures/index.d.ts +1 -1
  228. package/dist/blocks/signatures/index.js +3 -2
  229. package/dist/blocks/signing-keys/index.d.ts +1 -1
  230. package/dist/blocks/signing-keys/index.js +2 -2
  231. package/dist/blocks/sla/index.d.ts +1 -1
  232. package/dist/blocks/sla/index.js +5 -4
  233. package/dist/blocks/sso/index.d.ts +1 -1
  234. package/dist/blocks/sso/index.js +3 -2
  235. package/dist/blocks/state-machine/index.d.ts +1 -1
  236. package/dist/blocks/state-machine/index.js +3 -3
  237. package/dist/blocks/subjects/index.d.ts +2 -2
  238. package/dist/blocks/subjects/index.js +4 -3
  239. package/dist/blocks/tags/index.d.ts +2 -2
  240. package/dist/blocks/tags/index.js +2 -2
  241. package/dist/blocks/tasks/index.d.ts +2 -2
  242. package/dist/blocks/tasks/index.js +3 -2
  243. package/dist/blocks/teams/index.d.ts +1 -1
  244. package/dist/blocks/teams/index.js +2 -2
  245. package/dist/blocks/templates/index.d.ts +1 -1
  246. package/dist/blocks/templates/index.js +3 -2
  247. package/dist/blocks/time-tracking/index.d.ts +1 -1
  248. package/dist/blocks/time-tracking/index.js +5 -4
  249. package/dist/blocks/timeline/index.d.ts +3 -3
  250. package/dist/blocks/timeline/index.js +4 -3
  251. package/dist/blocks/trash/index.d.ts +1 -1
  252. package/dist/blocks/trash/index.js +3 -2
  253. package/dist/blocks/undo/index.d.ts +2 -2
  254. package/dist/blocks/undo/index.js +2 -2
  255. package/dist/blocks/updated-at/index.d.ts +1 -1
  256. package/dist/blocks/usage/index.d.ts +2 -2
  257. package/dist/blocks/usage/index.js +3 -2
  258. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  259. package/dist/blocks/vercel-marketplace/index.js +3 -2
  260. package/dist/blocks/versions/index.d.ts +1 -1
  261. package/dist/blocks/versions/index.js +4 -3
  262. package/dist/blocks/waitlist/index.d.ts +1 -1
  263. package/dist/blocks/waitlist/index.js +3 -2
  264. package/dist/blocks/webhooks/index.d.ts +2 -2
  265. package/dist/blocks/webhooks/index.js +5 -4
  266. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  267. package/dist/blocks/workflow-editor/index.js +3 -2
  268. package/dist/blocks/workflows/index.d.ts +4 -4
  269. package/dist/blocks/workflows/index.js +3 -2
  270. package/dist/{build-QitPVzzO.js → build-D9lWi5bk.js} +1 -1
  271. package/dist/chat-sdk/index.js +2 -1
  272. package/dist/cli/add-Bcw12jts.js +1 -0
  273. package/dist/cli/{add-Ccca1h3C.js → add-D5HxanFm.js} +2 -2
  274. package/dist/cli/{add-Elh2S4Z8.js → add-Lr7uTZXQ.js} +11 -11
  275. package/dist/cli/{backfill-kq6M-ksU.js → backfill-Cl1zEel7.js} +3 -3
  276. package/dist/cli/bin.js +1 -1
  277. package/dist/cli/{blocks-CSOK4qqe.js → blocks-CsPua74J.js} +1 -1
  278. package/dist/cli/{blocks-vl6ydiEz.js → blocks-f0obMCxm.js} +1 -1
  279. package/dist/cli/{cache-DPRc-BzP.js → cache-tvTW5J9K.js} +1 -1
  280. package/dist/cli/{codemod-CoaS9hJu.js → codemod-CVzRWS3j.js} +1 -1
  281. package/dist/cli/{config-BJSqMi04.js → config-BH0goim0.js} +3 -2
  282. package/dist/cli/{config-BlfVh0IP.js → config-CTRzkX0H.js} +1 -1
  283. package/dist/cli/{content-mapper-DM2jgKpn.js → content-mapper-C0LJDmVL.js} +2 -2
  284. package/dist/cli/{db-DYU5hUcd.js → db-DCeyHS1y.js} +2 -2
  285. package/dist/cli/{doctor-CU08NDWh.js → doctor-q701Qif_.js} +16 -16
  286. package/dist/cli/{gen-DNwJl35g.js → gen--vu_c2RF.js} +14 -14
  287. package/dist/cli/index.d.ts +1 -1
  288. package/dist/cli/index.js +7 -7
  289. package/dist/cli/{init-B_CsBYPR.js → init-DGz5Hk9X.js} +6 -6
  290. package/dist/cli/{live-TQN9GSV4.js → live-sBPXy0VE.js} +2 -2
  291. package/dist/cli/{mcp-BfC4giv7.js → mcp-DY_YK_WV.js} +2 -2
  292. package/dist/cli/{metadata-DlISbZDp.js → metadata-CoPGFRMb.js} +3 -3
  293. package/dist/cli/{migration-safety-C8mh2xlK.js → migration-safety-Cn7OLHJm.js} +2 -2
  294. package/dist/cli/{migrations-D-0Sd9tO.js → migrations-CUIEmdnS.js} +1 -1
  295. package/dist/cli/{module-migration-Cl8hBBqw.js → module-migration-bWK0xO2_.js} +2 -2
  296. package/dist/cli/powersync-CG3Bp6FD.js +1 -0
  297. package/dist/cli/{powersync-CBCanSnb.js → powersync-DAM5JAmz.js} +2 -2
  298. package/dist/cli/{print-DImaK12W.js → print-Dnbk8J2y.js} +2 -2
  299. package/dist/cli/{remove-DeOze3-k.js → remove-DAVVPbWw.js} +5 -5
  300. package/dist/cli/{render-GFy-2cii.js → render-PJdiRcqF.js} +28 -5
  301. package/dist/cli/{run-D4XWCMl2.js → run-6F72J0AQ.js} +25 -25
  302. package/dist/cli/{run-DNpUCD8d.js → run-D7-FuY6e.js} +8 -8
  303. package/dist/cli/seed-CXJvTU5D.js +1 -0
  304. package/dist/cli/{seed-D9mt8bnW.js → seed-CdSxunFT.js} +2 -2
  305. package/dist/cli/{shared-DM_FKwqk.js → shared-9O58FYPm.js} +1 -1
  306. package/dist/cli/{snapshot-BnZCeU7E.js → snapshot-rTRe56PH.js} +3 -3
  307. package/dist/cli/{source-DZonA0x5.js → source-EHhEoKBD.js} +1 -1
  308. package/dist/cli/{source-args-DlckPVje.js → source-args-z-jkabmO.js} +1 -1
  309. package/dist/cli/{spec-DCO8EEnf.js → spec-CR4Y9kn8.js} +2 -2
  310. package/dist/cli/{spec-U6hCGGu_.js → spec-DqSbbTzD.js} +1 -1
  311. package/dist/cli/{sql-layout-VnkvENWw.js → sql-layout-BijeFLWv.js} +2 -2
  312. package/dist/cli/{sync-D-YWMzZI.js → sync-BAmWXRDR.js} +3 -3
  313. package/dist/cli/{upgrade-BGcDzVSu.js → upgrade-BKN6eSx-.js} +4 -4
  314. package/dist/cli/{upgrade-DKZ3QOEJ.js → upgrade-oaUd22Il.js} +2 -2
  315. package/dist/cli/{version-BatoE1Gj.js → version-BkEOr4WS.js} +1 -1
  316. package/dist/client/index.d.ts +5 -5
  317. package/dist/client/native/index.d.ts +4 -4
  318. package/dist/{codecs-TylXqU_I.js → codecs-BfmQSbM6.js} +2 -2
  319. package/dist/{composite-C-8A8qzi.d.ts → composite-COQJBDmG.d.ts} +3 -3
  320. package/dist/config/index.d.ts +2 -2
  321. package/dist/config/index.js +1 -1
  322. package/dist/{config-mbVyJwSc.js → config-D74JT0qL.js} +2 -1
  323. package/dist/{context-Cj-9gE6l.d.ts → context-BI1PPPkw.d.ts} +6 -3
  324. package/dist/{controller-BR7CZ1R9.d.ts → controller-DhT57SGq.d.ts} +1 -1
  325. package/dist/{conversion-BgtOfTaS.d.ts → conversion-DAV0hOJQ.d.ts} +1 -1
  326. package/dist/create/index.d.ts +2 -2
  327. package/dist/create/index.js +2 -2
  328. package/dist/{create-blocks-Bu4H5TXw.js → create-blocks-B-9HVf7m.js} +6 -4
  329. package/dist/credentials/index.js +2 -1
  330. package/dist/{deal-forecast-Bv52QMyX.js → deal-forecast-DikouYGj.js} +2 -2
  331. package/dist/{define-Cgru0_kF.d.ts → define-B_pxEy7d.d.ts} +2 -0
  332. package/dist/{define-DlUeKHce.js → define-Dt9DRqV_.js} +80 -4
  333. package/dist/{define-block-CJWiDWa5.d.ts → define-block-D4hZSb2G.d.ts} +2 -1
  334. package/dist/edge/index.d.ts +5 -5
  335. package/dist/{entitlements-DHcNt1aF.d.ts → entitlements-BhNzAcJR.d.ts} +1 -1
  336. package/dist/{entitlements-NZAE_vLj.js → entitlements-DBir2qwB.js} +2 -2
  337. package/dist/{executor-BWFfz0ik.d.ts → executor-D1UUQEGL.d.ts} +2 -2
  338. package/dist/expo/index.d.ts +2 -2
  339. package/dist/{field-errors-DkAemDoc.d.ts → field-errors-D7mzrKjR.d.ts} +6 -6
  340. package/dist/{fields-B0zaJAO3.js → fields--5a88KJe.js} +3 -2
  341. package/dist/{flags-BOdA_ETQ.js → flags-ClOQY-p5.js} +1 -1
  342. package/dist/flags-sdk/index.js +2 -2
  343. package/dist/{framework-x9Y4uB1q.d.ts → framework-BghlRbea.d.ts} +3 -3
  344. package/dist/hono/index.d.ts +4 -4
  345. package/dist/{index-DTbJAsrT.d.ts → index-B8iW3y2w.d.ts} +9 -9
  346. package/dist/{index-C6ruLtyx.d.ts → index-BJBwUM9l.d.ts} +3 -3
  347. package/dist/{index-C0t-vNIt.d.ts → index-BSXQlJt2.d.ts} +2 -2
  348. package/dist/{index-DZylLz7h.d.ts → index-Bc-EhTb-.d.ts} +3 -3
  349. package/dist/{index-DVYEoVMK.d.ts → index-DZ5VbYvy.d.ts} +1 -1
  350. package/dist/{index-DmbCyl6Z.d.ts → index-DsB7dy9R.d.ts} +3 -3
  351. package/dist/index.d.ts +1 -1
  352. package/dist/index.js +1 -1
  353. package/dist/instance-property-hRh88y_s.js +7 -0
  354. package/dist/{knowledge-BGbtxMP9.js → knowledge-CV6OSirC.js} +2 -2
  355. package/dist/list/index.d.ts +1 -1
  356. package/dist/{list-query-DxjuIHEL.d.ts → list-query-BIZBVEoF.d.ts} +1 -1
  357. package/dist/mapper/bin.js +6 -6
  358. package/dist/mcp/index.d.ts +4 -4
  359. package/dist/mcp/sdk/index.d.ts +2 -2
  360. package/dist/{money-codec-BzddguAQ.js → money-codec-uV5WbT60.js} +1 -1
  361. package/dist/next/index.d.ts +14 -14
  362. package/dist/next/index.js +2 -2
  363. package/dist/{operations-CAjMgNr9.d.ts → operations-DbNAgo7E.d.ts} +1 -1
  364. package/dist/{options-lsxJYfYx.js → options-BOqfYsM1.js} +2 -1
  365. package/dist/{options-Bc4xz5jQ.js → options-DZen3UiC.js} +2 -1
  366. package/dist/orpc/index.d.ts +4 -4
  367. package/dist/orpc/index.js +1 -1
  368. package/dist/otel/index.js +4 -4
  369. package/dist/{ports-g0H1Kzwr.d.ts → ports-Dwe0JqBI.d.ts} +1 -1
  370. package/dist/powersync/index.d.ts +3 -3
  371. package/dist/preset/index.d.ts +3 -3
  372. package/dist/{push-token-Cl2EihRc.d.ts → push-token-C0dwbMZF.d.ts} +1 -1
  373. package/dist/query/index.d.ts +1 -1
  374. package/dist/{rate-limit-Dt9vAY4E.js → rate-limit-BPuUWz4U.js} +3 -2
  375. package/dist/react/index.d.ts +5 -5
  376. package/dist/react/index.js +1 -1
  377. package/dist/react/native/index.d.ts +1 -1
  378. package/dist/react/server.d.ts +6 -6
  379. package/dist/react/server.js +1 -1
  380. package/dist/{react-zBTxLsV6.js → react-GgLZ66FU.js} +2 -2
  381. package/dist/react-router/index.d.ts +3 -3
  382. package/dist/realtime/index.d.ts +3 -3
  383. package/dist/realtime/index.js +2 -2
  384. package/dist/{record-form-zMwz0Ayt.d.ts → record-form-eiqGbx9J.d.ts} +1 -1
  385. package/dist/records/index.d.ts +7 -7
  386. package/dist/{resource-execute-CKBtGL8-.d.ts → resource-execute-CWfzJmUd.d.ts} +1 -1
  387. package/dist/{resource-types-8Q5Klkpa.d.ts → resource-types-BdGAUbKw.d.ts} +1 -1
  388. package/dist/{resources-DxpqenZA.d.ts → resources-EeQWFMR8.d.ts} +1 -1
  389. package/dist/{rows-Bm6sskji.js → rows-Bh9QemqN.js} +1 -1
  390. package/dist/{rows-BDLZStp4.js → rows-EGAbu7MG.js} +2 -2
  391. package/dist/{sales-lines-D-sf9PIB.js → sales-lines-CP4Z_LyE.js} +6 -4
  392. package/dist/{sales-lines-Bk4mbLH1.d.ts → sales-lines-KxxStRzU.d.ts} +1 -0
  393. package/dist/{sales-shared-DXGFJP4g.js → sales-shared-BKXXA5qV.js} +1 -1
  394. package/dist/{schemas-l2aF78zQ.js → schemas-BSTNfGsQ.js} +1 -1
  395. package/dist/{scores-CRp3vvQU.js → scores-CsgM-dw7.js} +2 -2
  396. package/dist/server/index.d.ts +7 -7
  397. package/dist/server/index.js +2 -2
  398. package/dist/{server-types-gR4Q1aM0.d.ts → server-types-rmq2QzsD.d.ts} +1 -1
  399. package/dist/{session-Fcft5A39.d.ts → session-CpwxyojG.d.ts} +1 -1
  400. package/dist/{signing-keys-wGKh4vtt.js → signing-keys-DqI-gB_C.js} +2 -2
  401. package/dist/solid/index.d.ts +6 -6
  402. package/dist/solid-start/index.d.ts +3 -3
  403. package/dist/spec/index.d.ts +1 -1
  404. package/dist/spec/index.js +1 -1
  405. package/dist/sql/index.d.ts +4 -4
  406. package/dist/sql/index.js +1 -1
  407. package/dist/{sql-B8usqPPx.js → sql-B0wb7XA5.js} +107 -64
  408. package/dist/sqlite/index.d.ts +1 -1
  409. package/dist/{sso-d2S4x_f9.js → sso-Co2TbnEy.js} +2 -2
  410. package/dist/ssr/index.d.ts +1 -1
  411. package/dist/storage/index.js +1 -1
  412. package/dist/streams/index.js +2 -1
  413. package/dist/{subject-readers-B-pQ9Mmo.js → subject-readers-F1xvRY-d.js} +1 -1
  414. package/dist/subject-type-BRnK7Av3.js +8 -0
  415. package/dist/svelte/index.d.ts +6 -6
  416. package/dist/sveltekit/index.d.ts +4 -4
  417. package/dist/{tags-sM-CH9Mn.d.ts → tags-CkO2erRP.d.ts} +1 -1
  418. package/dist/tanstack-db/index.d.ts +1 -1
  419. package/dist/tanstack-start/index.d.ts +3 -3
  420. package/dist/{tenant-DyoVYFfC.d.ts → tenant-BXNF10H5.d.ts} +1 -1
  421. package/dist/testing/index.d.ts +7 -7
  422. package/dist/testing/index.js +5 -5
  423. package/dist/{timeline-CMmo0R7g.d.ts → timeline-CHtoY7NO.d.ts} +3 -3
  424. package/dist/{topic-nQYxoTaU.d.ts → topic-BNkdk7qe.d.ts} +2 -2
  425. package/dist/{undo-BjCChCmH.js → undo-B3FQvuAd.js} +2 -2
  426. package/dist/{verify-DEqY__0N.d.ts → verify-CJxqZQdd.d.ts} +1 -1
  427. package/dist/vue/index.d.ts +6 -6
  428. package/dist/{watch-topic-UGSEWAqR.d.ts → watch-topic-wl74gws-.d.ts} +1 -1
  429. package/dist/workflow-sdk/world/index.js +1 -1
  430. package/dist/yjs/index.d.ts +1 -1
  431. package/dist/yjs/index.js +1 -1
  432. package/package.json +1 -1
  433. package/schemas/config-v1.json +22 -1
  434. package/dist/cli/add-BKybJ2e1.js +0 -1
  435. package/dist/cli/powersync-BEWwRqNy.js +0 -1
  436. package/dist/cli/seed-EPO6AvLG.js +0 -1
  437. package/dist/db-blocks-DJGbjIPz.js +0 -62
  438. package/dist/{sign-in-BLkRU3lc.js → sign-in-BTaRWS-L.js} +1 -1
  439. package/dist/{topic-J9I3yu6f.js → topic-DXbA-jwr.js} +1 -1
@@ -2,6 +2,7 @@ import { n as isRecord } from "./guards-6F2bCtQR.js";
2
2
  import { d as temporalText } from "./temporal-DLZlWbOi.js";
3
3
  import { r as NEGATIVE, t as FILTER_OPERATORS } from "./filter-query-DMoKo82_.js";
4
4
  import { a as ok } from "./result-ntFBW2p2.js";
5
+ import { a as sqlString, i as sqlIdent } from "./template-Drgg3v2J.js";
5
6
  import { a as hasPlaceholder, l as splitPlaceholders, s as placeholderOf } from "./read-set-BnKnofIj.js";
6
7
  import { a as resolveNames, n as instancePrefix, o as resolveJsonSchema, r as isRenamedInstance, s as CONFIG_DEFAULTS } from "./instances-DDt7NdVl.js";
7
8
  import { t as DEFAULT_CLAIMS } from "./claims-Bp9My7XP.js";
@@ -9,7 +10,6 @@ import { o as tenantNames, r as composeNames } from "./entity-naming-Dtyq5sKE.js
9
10
  import { A as resolveBlock, D as BLOCK_SCOPES, _ as encryptedColumns, c as appTableEventKinds, g as columnsWithAccess, h as hasComputed, j as tenantNameOf, r as APP_RANK_COLUMN, t as APP_DELETED_AT_COLUMN, u as appTableVersions, v as hasColumnAccess, y as hiddenColumns } from "./app-tables-DyswUg6J.js";
10
11
  import { a as RATING_BOUNDS, n as CUSTOM_FIELD_TYPES, r as FIELD_FORMATS, t as CUSTOM_FIELD_FORM_TYPES } from "./field-formats-C6QKA3UR.js";
11
12
  import { t as isSqlType } from "./sql-type-iUSZpaUu.js";
12
- import { a as sqlString, i as sqlIdent } from "./template-Drgg3v2J.js";
13
13
  import { i as fillTemplate, l as templatePlaceholders } from "./access-sql-CNIgUqWf.js";
14
14
  import { t as MAX_BATCH } from "./batch-limit-DKVQDz4o.js";
15
15
  import { $ as quotedTable, A as addNotNullCheck, B as extraFieldsArg, C as SCHEMA$5, D as addCheck, E as activeMembership, F as defaultPartitionName, G as lockTable, H as fail$1, I as disabledHelpers, J as membershipSuspended, K as memberAddedRecord, L as disabledHelpersNeedLaterTables, M as columnRef, N as columnsObject, O as addExtraColumns, P as defaultPartition, Q as pageSize, R as dropExpiredPartitions, S as PARTITION_VARIABLES, T as accessDefinesDisabledHelpers, U as jsonSchemaChecks, V as extraFieldsJson, W as jwtClaim, X as organizationMissing, Y as notNullCheckName, Z as ownRowPolicies, _ as rolesOf, at as revokeTable, b as MONTHLY_PARTITIONS, c as accessModel, ct as serviceOnly$1, d as moduleOperations, dt as splitTable$1, et as raise$1, f as modulePermission, ft as triggerGrant, g as roleScopeIs, gt as writeExtraColumns, h as roleNames, ht as withExtraFields, it as replaceColumnCheck, j as batchFunction, k as addForeignKey, l as hasPlatformRoles, lt as sha256Hex$1, m as providerPlatformRoles, mt as userGrant, n as WORKFLOW_SDK_WORLD, nt as registerPartitions, o as MODULE_PERMISSION_SCOPES, ot as schemaPreamble, p as modulePermissionKey, pt as updatedAt, q as membershipDisabledAt, rt as renameSql, s as OPERATIONS, st as serviceGrant, tt as recordTrigger, u as isOperationModule$1, ut as shortHash, v as tenantScope, w as SERVICE_CALLER$1, x as NOTHING, y as EQUIVALENT_TRIGGERS, z as ensureCheck } from "./workflow-sdk-DELaQEp3.js";
@@ -45,7 +45,7 @@ import { t as coursesSqlOptions } from "./options-rnKlqYEr.js";
45
45
  import { t as createdBySqlOptions } from "./options-C87u6eSa.js";
46
46
  import { t as customFieldsSqlOptions } from "./options-D32-YxnO.js";
47
47
  import { t as dataLifecycleSqlOptions } from "./options-Dpy-Ruo-.js";
48
- import { t as dealsSqlOptions } from "./options-Bc4xz5jQ.js";
48
+ import { t as dealsSqlOptions } from "./options-DZen3UiC.js";
49
49
  import { n as WORK_ORDER_STATUSES, r as dispatchSqlOptions, t as WORK_ORDER_PRIORITIES } from "./statuses-Alll5Ip6.js";
50
50
  import { t as documentsSqlOptions } from "./options-DWwL5Kaz.js";
51
51
  import { t as domainsSqlOptions } from "./options-LqUXTpML.js";
@@ -62,7 +62,7 @@ import { t as identitiesSqlOptions } from "./options-DcnBNYmV.js";
62
62
  import { r as inboxSqlOptions, t as CONVERSATION_TO_TASK } from "./automations-BKjJpktQ.js";
63
63
  import { t as incidentsSqlOptions } from "./options-DUMUsvml.js";
64
64
  import { t as inventorySqlOptions } from "./options-CFjGxfa8.js";
65
- import { t as invoicesSqlOptions } from "./options-lsxJYfYx.js";
65
+ import { t as invoicesSqlOptions } from "./options-BOqfYsM1.js";
66
66
  import { t as knowledgeSqlOptions } from "./options-Dcaql09y.js";
67
67
  import { t as leadScoringSqlOptions } from "./options-BfPsL7E2.js";
68
68
  import { t as leasesSqlOptions } from "./options-MsloEAIB.js";
@@ -88,7 +88,7 @@ import { t as profilesSqlOptions } from "./options-hynwKWuf.js";
88
88
  import { t as promotionsSqlOptions } from "./options-9dSU5RML.js";
89
89
  import { t as pushSqlOptions } from "./options-BR9xTHZW.js";
90
90
  import { n as rateLimitSqlOptions, r as webhookInboxSqlOptions, t as queueSqlOptions } from "./options-B2Kz_tCx.js";
91
- import { n as QUOTE_TO_ORDER, r as quotesSqlOptions } from "./automations-B5P6vTvk.js";
91
+ import { n as QUOTE_TO_ORDER, r as quotesSqlOptions } from "./automations-EzXteupo.js";
92
92
  import { t as reactionsSqlOptions } from "./options-BtjkzIVh.js";
93
93
  import { t as relationsSqlOptions } from "./options-BQunK6_Y.js";
94
94
  import { t as remindersSqlOptions } from "./options-p49DFg3H.js";
@@ -123,6 +123,7 @@ import { t as waitlistSqlOptions } from "./options-DKoQoRCy.js";
123
123
  import { n as webhooksOutSqlOptions, t as webhooksInSqlOptions } from "./options-D96dScev.js";
124
124
  import { t as workflowEditorSqlOptions } from "./options-DFpyP1bg.js";
125
125
  import { t as GUEST_ACTIONS } from "./guest-actions-B7zdhfnh.js";
126
+ import { n as SUBJECT_TYPE_SQL_PATTERN, r as subjectTypeIdent, t as SUBJECT_TYPE_PATTERN } from "./subject-type-BRnK7Av3.js";
126
127
  import { t as AI_MESSAGE_PART_TYPES } from "./ai-message-DfaP8sis.js";
127
128
  import { a as rankKeys, n as RANK_REBALANCE_QUEUE, t as RANK_ALPHABET } from "./rank-keys-DcPMt_Jk.js";
128
129
  import { t as FINAL_RUN_STATES$1 } from "./run-state-CgBKzYMW.js";
@@ -1806,6 +1807,21 @@ values (${values.join(", ")})
1806
1807
  on conflict (${d("key")}) do update set ${UPDATED.map((column) => `${d(column)} = excluded.${d(column)}`).join(", ")}, ${d("updatedAt")} = now();`;
1807
1808
  }
1808
1809
  //#endregion
1810
+ //#region src/sql/extra-columns.ts
1811
+ const EXTRA_COLUMN = /^[a-z_][a-z0-9_]*$/;
1812
+ function checkedExtraColumns(at, value, taken) {
1813
+ return Object.entries(value).map(([name, type]) => {
1814
+ if (!EXTRA_COLUMN.test(name) || name.length > 63) throw new TypeError(`${at}: "${name}" is not a valid column name`);
1815
+ if (taken.has(name)) throw new TypeError(`${at}.${name} shadows a column the module already returns`);
1816
+ if (typeof type !== "string" || !isSqlType(type)) throw new TypeError(`${at}.${name} must be a SQL type such as "text not null default 'en'"`);
1817
+ return {
1818
+ name,
1819
+ ident: sqlIdent(name),
1820
+ type
1821
+ };
1822
+ });
1823
+ }
1824
+ //#endregion
1809
1825
  //#region src/sql/scope.ts
1810
1826
  const CALLER = "(select auth.uid())";
1811
1827
  const SIGNED_IN = `(${CALLER} is not null)`;
@@ -1871,6 +1887,15 @@ function moduleScope(source) {
1871
1887
  }
1872
1888
  }
1873
1889
  //#endregion
1890
+ //#region src/sql/tenant-column.ts
1891
+ const DEFAULT_TENANT_COLUMN = "tenant_id";
1892
+ function blockColumnName(where, columns, name, tenantColumn, rename) {
1893
+ if (name !== DEFAULT_TENANT_COLUMN || tenantColumn === void 0) return rename(name);
1894
+ const clash = Object.entries(columns).find(([, other]) => rename(other) === tenantColumn);
1895
+ if (clash !== void 0) throw new TypeError(`sql.tenantColumn: "${tenantColumn}" is the name of ${where.table}.${clash[0]} in the ${where.module} module. Choose another name, or map blocks.${where.module}.columns.${where.table}.tenant.`);
1896
+ return tenantColumn;
1897
+ }
1898
+ //#endregion
1874
1899
  //#region src/sql/context.ts
1875
1900
  /** The scope id types SQL modules render. */
1876
1901
  const MODULE_ID_TYPES = [
@@ -1924,7 +1949,6 @@ const FIXED_FUNCTIONS = { memberships: /* @__PURE__ */ new Set([
1924
1949
  "organization_member_role",
1925
1950
  "organization_member_roles"
1926
1951
  ]) };
1927
- const EXTRA_COLUMN = /^[a-z_][a-z0-9_]*$/;
1928
1952
  const IDENT$10 = /^[A-Za-z_][A-Za-z0-9_$]*$/;
1929
1953
  function splitTable(value, schema) {
1930
1954
  const dot = value.indexOf(".");
@@ -2043,11 +2067,16 @@ function createModuleContext(module, namesOf, source = {}) {
2043
2067
  checkIdent(`${where}.tables.${logical}`, parts.name);
2044
2068
  return parts;
2045
2069
  };
2070
+ const tenantColumn = source.tenantColumn;
2071
+ if (tenantColumn !== void 0) checkIdent("sql.tenantColumn", tenantColumn);
2046
2072
  const column = (table, logical) => {
2047
2073
  const known = names.tables[table];
2048
2074
  if (!known || !(logical in known.columns)) throw new TypeError(`Module "${module}" has no column "${table}.${logical}"`);
2049
2075
  const mapped = config.columns[table]?.[logical];
2050
- return mapped === void 0 ? naming.rename(known.columns[logical]) : mapped;
2076
+ return mapped === void 0 ? blockColumnName({
2077
+ module,
2078
+ table
2079
+ }, known.columns, known.columns[logical], tenantColumn, (name) => naming.rename(name)) : mapped;
2051
2080
  };
2052
2081
  const requiredColumn = (table, logical) => {
2053
2082
  const name = column(table, logical);
@@ -2236,24 +2265,14 @@ function createModuleContext(module, namesOf, source = {}) {
2236
2265
  if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) throw new TypeError(`${where}.options.${name} must be a string array`);
2237
2266
  return value;
2238
2267
  },
2239
- extraColumns(table, reserved = []) {
2240
- const value = option("extraColumns");
2268
+ extraColumns(table, reserved = [], key = "extraColumns") {
2269
+ const value = option(key);
2241
2270
  if (value === void 0) return [];
2242
- const at = `${where}.options.extraColumns`;
2271
+ const at = `${where}.options.${key}`;
2243
2272
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${at} must be an object`);
2244
2273
  const known = names.tables[table];
2245
2274
  if (!known) throw new TypeError(`Module "${module}" has no table "${table}"`);
2246
- const taken = /* @__PURE__ */ new Set([...reserved, ...Object.keys(known.columns).filter((logical) => !known.yieldsToExtra?.includes(logical)).flatMap((logical) => column(table, logical) ?? [])]);
2247
- return Object.entries(value).map(([name, type]) => {
2248
- if (!EXTRA_COLUMN.test(name) || name.length > 63) throw new TypeError(`${at}: "${name}" is not a valid column name`);
2249
- if (taken.has(name)) throw new TypeError(`${at}.${name} shadows a column the module already returns`);
2250
- if (typeof type !== "string" || !isSqlType(type)) throw new TypeError(`${at}.${name} must be a SQL type such as "text not null default 'en'"`);
2251
- return {
2252
- name,
2253
- ident: sqlIdent(name),
2254
- type
2255
- };
2256
- });
2275
+ return checkedExtraColumns(at, value, /* @__PURE__ */ new Set([...reserved, ...Object.keys(known.columns).filter((logical) => !known.yieldsToExtra?.includes(logical)).flatMap((logical) => column(table, logical) ?? [])]));
2257
2276
  },
2258
2277
  hook(name, args) {
2259
2278
  const target = hookTarget(name);
@@ -2532,6 +2551,7 @@ function moduleContext(name, layout = {}, installed, instance) {
2532
2551
  ...instance === void 0 || instance === name ? {} : { instance },
2533
2552
  contributors: (block) => contributorsOf(block, layout, installed),
2534
2553
  ...layout.scope ? { scope: layout.scope } : {},
2554
+ ...layout.blockTenantColumn ? { tenantColumn: layout.blockTenantColumn } : {},
2535
2555
  ...providerIdType(layout),
2536
2556
  ...providerGuests(layout),
2537
2557
  integrations(module) {
@@ -4220,7 +4240,7 @@ const ACCESS_REQUESTS = {
4220
4240
  };
4221
4241
  //#endregion
4222
4242
  //#region src/sql/subject-registry.ts
4223
- const TYPE$5 = /^[a-z][a-z0-9_]{0,62}$/;
4243
+ const TYPE$5 = SUBJECT_TYPE_PATTERN;
4224
4244
  const COLUMN$6 = /^[a-z_][a-z0-9_]{0,62}$/;
4225
4245
  const ID_TYPE$2 = /^[a-z][a-z0-9_ ]{0,62}$/;
4226
4246
  const ACTION = /^[a-z][a-z0-9_.-]{0,62}$/;
@@ -4236,9 +4256,15 @@ function column$1(where, value) {
4236
4256
  * `blocks.memberships.names.organization: workspace`).
4237
4257
  */
4238
4258
  function registeredSubjects(subjects, naming = tenantNames()) {
4259
+ const idents = /* @__PURE__ */ new Map();
4260
+ for (const type of Object.keys(subjects)) {
4261
+ const other = idents.get(subjectTypeIdent(type));
4262
+ if (other !== void 0) throw new TypeError(`subjects.${type}: "${type}" and "${other}" name the same SQL objects. Keep one of them.`);
4263
+ idents.set(subjectTypeIdent(type), type);
4264
+ }
4239
4265
  return Object.entries(subjects).map(([type, entry]) => {
4240
4266
  const where = `subjects.${type}`;
4241
- if (!TYPE$5.test(type)) throw new TypeError(`${where}: a subject type is lowercase letters, digits and underscores`);
4267
+ if (!TYPE$5.test(type)) throw new TypeError(`${where}: a subject type is lowercase letters, digits, hyphens and underscores, starting with a letter`);
4242
4268
  let schema;
4243
4269
  let table;
4244
4270
  try {
@@ -6255,8 +6281,6 @@ function uniqueContributions(generic, contributions, key) {
6255
6281
  }
6256
6282
  //#endregion
6257
6283
  //#region src/sql/subjects.ts
6258
- const SUBJECT_TYPE$2 = /^[a-z][a-z0-9_]{0,62}$/;
6259
- const HYPHENATED_SUBJECT_TYPE = /^[a-z][a-z0-9_-]{0,62}$/;
6260
6284
  const BASE_KEYS = /* @__PURE__ */ new Set([
6261
6285
  "table",
6262
6286
  "id",
@@ -6333,9 +6357,8 @@ function withAlways(ctx, raw, extraKeys, always) {
6333
6357
  function subjectsOption(ctx, extraKeys = [], allow = {}) {
6334
6358
  const where = `blocks.${ctx.instance}.on`;
6335
6359
  const raw = withAlways(ctx, rawSubjects(ctx, where, extraKeys, allow), extraKeys, allow.always);
6336
- const hyphens = allow.hyphens === true;
6337
6360
  return Object.entries(raw).map(([type, entry]) => {
6338
- if (!(hyphens ? HYPHENATED_SUBJECT_TYPE : SUBJECT_TYPE$2).test(type)) throw new TypeError(`${where}: "${type}" must be lowercase letters, digits${hyphens ? ", hyphens" : ""} and underscores`);
6361
+ if (!SUBJECT_TYPE_PATTERN.test(type)) throw new TypeError(`${where}: "${type}" must be lowercase letters, digits, hyphens and underscores`);
6339
6362
  if (!isRecord(entry) || typeof entry["table"] !== "string") throw new TypeError(`${where}.${type} needs a table`);
6340
6363
  for (const key of Object.keys(entry)) if (!BASE_KEYS.has(key) && !extraKeys.includes(key)) throw new TypeError(`${where}.${type}.${key} is not an option. Options: ${[...BASE_KEYS, ...extraKeys].join(", ")}`);
6341
6364
  const text = (key) => {
@@ -8168,7 +8191,7 @@ security invoker
8168
8191
  set search_path = ''
8169
8192
  as $$
8170
8193
  declare
8171
- v_parts text[] := regexp_match(subject_presence_allowed.topic, '^${PRESENCE_TOPIC_PREFIX}:([a-z][a-z0-9_]{0,62}):([^:]{1,200})$');
8194
+ v_parts text[] := regexp_match(subject_presence_allowed.topic, '^${PRESENCE_TOPIC_PREFIX}:([a-z][a-z0-9_-]{0,62}):([^:]{1,200})$');
8172
8195
  begin
8173
8196
  if v_parts is null then
8174
8197
  return false;
@@ -11470,7 +11493,7 @@ function blockSubjects(ctx) {
11470
11493
  function subjectCheck(ctx) {
11471
11494
  const blocks = blockSubjects(ctx);
11472
11495
  const owned = new Set(blocks.map(([type]) => type));
11473
- const registered = subjectsOption(ctx, [], { hyphens: true }).filter(([type]) => !owned.has(type));
11496
+ const registered = subjectsOption(ctx).filter(([type]) => !owned.has(type));
11474
11497
  const others = registered.length === 0 ? "null" : subjectReadable(ctx, registered, SUBJECT_ARGS).replace(/else false\s+end$/, "else null\n end");
11475
11498
  const check = blocks.length === 0 ? others : `case ${SUBJECT_ARGS.type}
11476
11499
  ${blocks.map(([type, sql]) => ` when ${sqlString(type)} then ${sql}`).join("\n")}
@@ -16525,7 +16548,7 @@ begin
16525
16548
  if v_row.${s("status")} = 'retired' then
16526
16549
  ${fail$1("ASSETS_RETIRED", "a retired asset can't be assigned", "55000")}
16527
16550
  end if;
16528
- if coalesce(assign_asset.assignee_type, '') !~ '^[a-z][a-z0-9_]{0,62}$' or coalesce(assign_asset.assignee_id, '') = '' then
16551
+ if coalesce(assign_asset.assignee_type, '') !~ '^[a-z][a-z0-9_-]{0,62}$' or coalesce(assign_asset.assignee_id, '') = '' then
16529
16552
  ${invalid("ASSETS_ASSIGNEE_INVALID", "an assignee needs a lowercase type and an id")}
16530
16553
  end if;
16531
16554
  if assign_asset.assignee_type = 'member' and (
@@ -17005,7 +17028,7 @@ create table if not exists ${assets} (
17005
17028
  ${s("name")} text not null check (length(${s("name")}) between 1 and 200),${ctx.has("assets", "tag") ? "\n -- The asset tag, unique per organization." : ""}${column("assets", "tag", (tag) => `${tag} text check (${tag} is null or length(${tag}) between 1 and 100)`)}${column("assets", "serial", (serial) => `${serial} text check (${serial} is null or length(${serial}) <= 200)`)}
17006
17029
  ${s("status")} text not null default 'active' check (${s("status")} in ('active', 'maintenance', 'retired')),
17007
17030
  -- member (a user id) or a subject type such as party, with its id.
17008
- ${s("assigneeType")} text check (${s("assigneeType")} is null or ${s("assigneeType")} ~ '^[a-z][a-z0-9_]{0,62}$'),
17031
+ ${s("assigneeType")} text check (${s("assigneeType")} is null or ${s("assigneeType")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
17009
17032
  ${s("assigneeId")} text,${tracked ? `\n -- Where a moving asset (a vehicle) was last seen.\n ${coordinates(s("latitude"), s("longitude"))}` : ""}${postgis && tracked ? `\n ${pointColumn(s("latitude"), s("longitude"))}` : ""}${object("assets", "metadata")}${column("assets", "retiredAt", (retired) => `${retired} timestamptz`)}${column("assets", "createdBy", (createdBy) => `${createdBy} uuid`)}
17010
17033
  ${s("createdAt")} timestamptz not null default now(),
17011
17034
  ${s("updatedAt")} timestamptz not null default now()${constraints([
@@ -17235,7 +17258,7 @@ function tables$34(ctx, n) {
17235
17258
  ${q("id")} uuid primary key default gen_random_uuid(),
17236
17259
  ${q("tenant")} ${ctx.idType} not null,
17237
17260
  ${q("name")} text not null check (length(${q("name")}) between 1 and 200),
17238
- ${q("subjectType")} text not null check (${q("subjectType")} ~ '^[a-z][a-z0-9_]{0,62}$'),
17261
+ ${q("subjectType")} text not null check (${q("subjectType")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
17239
17262
  ${q("strategy")} text not null default 'round_robin' check (${q("strategy")} in ('round_robin', 'weighted')),
17240
17263
  ${q("conditions")} jsonb check (${q("conditions")} is null or jsonb_typeof(${q("conditions")}) = 'object'),
17241
17264
  ${q("rank")} integer not null default 0,
@@ -17334,7 +17357,7 @@ begin
17334
17357
  end if;
17335
17358
  end if;
17336
17359
  v_type := coalesce(queue ->> 'subjectType', v_old.${q("subjectType")});
17337
- if v_type is null or v_type !~ '^[a-z][a-z0-9_]{0,62}$' then
17360
+ if v_type is null or v_type !~ '^[a-z][a-z0-9_-]{0,62}$' then
17338
17361
  ${fail$1("ASSIGNMENT_INVALID", "A queue needs a subject type", "22023")}
17339
17362
  end if;
17340
17363
  v_conditions := case when queue ? 'conditions' then nullif(queue -> 'conditions', 'null'::jsonb) else v_old.${q("conditions")} end;
@@ -18777,7 +18800,7 @@ end;`;
18777
18800
  create table if not exists ${t} (
18778
18801
  ${c("id")} uuid primary key default gen_random_uuid(),
18779
18802
  ${c("tenant")} ${id} not null,
18780
- ${c("subjectType")} text check (${c("subjectType")} ~ '^[a-z][a-z0-9_]{0,62}$'),
18803
+ ${c("subjectType")} text check (${c("subjectType")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
18781
18804
  ${c("subjectId")} text check (length(${c("subjectId")}) between 1 and 200),
18782
18805
  ${c("bucket")} text not null default ${bucketLiteral},
18783
18806
  ${c("path")} text generated always as (${pathExpression(ctx, tenantless.length > 0)}) stored,
@@ -22459,7 +22482,7 @@ const NAMES$96 = {
22459
22482
  }
22460
22483
  }
22461
22484
  };
22462
- const SUBJECT_TYPE = "^[a-z][a-z0-9_]{0,62}$";
22485
+ const SUBJECT_TYPE = SUBJECT_TYPE_SQL_PATTERN;
22463
22486
  const TRIGGER$1 = "^[a-z][a-z0-9_]*([.:][a-z0-9_]+)*$";
22464
22487
  const ACTION_KIND = "^[a-z][a-z0-9_]*([.][a-z0-9_]+)*$";
22465
22488
  const FIELD_ID = "^[A-Za-z_][A-Za-z0-9_]*([.][A-Za-z_][A-Za-z0-9_]*)*$";
@@ -44704,6 +44727,7 @@ const TOTAL_COLUMNS = {
44704
44727
  function lineTableSpec(name) {
44705
44728
  return {
44706
44729
  name,
44730
+ app: {},
44707
44731
  lifecycle: {
44708
44732
  tenant: "tenant",
44709
44733
  export: true
@@ -44711,6 +44735,15 @@ function lineTableSpec(name) {
44711
44735
  columns: LINE_COLUMNS
44712
44736
  };
44713
44737
  }
44738
+ const LINE_KEYS = [
44739
+ "unitAmount",
44740
+ "product",
44741
+ "fields"
44742
+ ];
44743
+ function lineExtraColumns(ctx, lines = "lines") {
44744
+ return ctx.extraColumns(lines, LINE_KEYS, "lineExtraColumns");
44745
+ }
44746
+ const lineFieldsJson = (alias, extras = []) => extraFieldsJson(alias, extras);
44714
44747
  /**
44715
44748
  * The line table, its totals trigger and `set_<name>(record, lines)`.
44716
44749
  *
@@ -44729,6 +44762,7 @@ function lineItemsSql(ctx, items, options) {
44729
44762
  const list = `round(l.${c("quantity")} * l.${c("unitAmount")})`;
44730
44763
  const discount = `round(${list} * l.${c("discountBps")} / 10000.0)`;
44731
44764
  const tax = `round((${list} - ${discount}) * l.${c("taxRateBps")} / 10000.0)`;
44765
+ const extras = items.extras ?? [];
44732
44766
  return `${ctx.manages ? `create table if not exists ${t} (
44733
44767
  ${c("id")} uuid primary key default gen_random_uuid(),
44734
44768
  ${c("tenant")} ${ctx.idType} not null,
@@ -44745,7 +44779,7 @@ function lineItemsSql(ctx, items, options) {
44745
44779
  ${c("createdAt")} timestamptz not null default now(),
44746
44780
  check ((${c("productType")} is null) = (${c("productId")} is null))
44747
44781
  );
44748
- create index if not exists ${sqlIdent(`${ctx.tableName(items.lines).name}_parent_idx`)} on ${t} (${c("parent")}, ${c("position")});
44782
+ create index if not exists ${sqlIdent(`${ctx.tableName(items.lines).name}_parent_idx`)} on ${t} (${c("parent")}, ${c("position")});${addExtraColumns(t, extras)}
44749
44783
  ${lockTable(t, { read: true })}
44750
44784
  drop policy if exists ${sqlIdent(`${ctx.tableName(items.lines).name}_read`)} on ${t};
44751
44785
  create policy ${sqlIdent(`${ctx.tableName(items.lines).name}_read`)} on ${t} for select to authenticated
@@ -44830,7 +44864,7 @@ as $$
44830
44864
  declare
44831
44865
  v_parent uuid := ${options.setter}.parent;
44832
44866
  v_tenant ${ctx.idType};
44833
- v_currency text;
44867
+ v_currency text;${extras.length === 0 ? "" : "\n v_line record;"}
44834
44868
  begin
44835
44869
  select x.${pc("tenant")}, x.${pc("currency")} into v_tenant, v_currency from ${p} x where x.${pc("id")} = v_parent${items.frozen === void 0 ? "" : ` and not (${items.frozen.replaceAll("p.", "x.")})`};
44836
44870
  if v_tenant is null then
@@ -44853,7 +44887,9 @@ begin
44853
44887
  from jsonb_array_elements(coalesce(${options.setter}.lines, '[]')) with ordinality x;
44854
44888
  exception when check_violation or not_null_violation or invalid_text_representation or numeric_value_out_of_range then
44855
44889
  ${fail$1("LINES_INVALID", "every line needs a description, a positive quantity and a unit amount", "22023")}
44856
- end;
44890
+ end;${extras.length === 0 ? "" : `
44891
+ for v_line in select x.value -> 'fields' as fields, x.ordinality::integer as position from jsonb_array_elements(coalesce(${options.setter}.lines, '[]')) with ordinality x where jsonb_typeof(x.value -> 'fields') = 'object' loop${writeExtraColumns(t, extras, "v_line.fields", `x.${c("parent")} = v_parent and x.${c("position")} = v_line.position`).replaceAll("\n", "\n ")}
44892
+ end loop;`}
44857
44893
  perform ${recount}(v_parent);
44858
44894
  return (select jsonb_build_object(
44859
44895
  'listTotal', x.${pc("listTotal")}::text, 'discountTotal', x.${pc("discountTotal")}::text,
@@ -45465,7 +45501,8 @@ ${lineItemsSql(ctx, {
45465
45501
  lines: "lines",
45466
45502
  parent: "deals",
45467
45503
  frozen: `p.${d("locked")}`,
45468
- afterTotals: `${d("amount")} = case when x.${d("amountSource")} = 'line_items' then v_list - v_discount else x.${d("amount")} end`
45504
+ afterTotals: `${d("amount")} = case when x.${d("amountSource")} = 'line_items' then v_list - v_discount else x.${d("amount")} end`,
45505
+ extras: n.lineExtras
45469
45506
  }, {
45470
45507
  setter: "set_deal_lines",
45471
45508
  guard: `if not exists (select 1 from ${t("deals")} x where x.${d("id")} = v_parent and ${editable("x")}) then
@@ -45666,7 +45703,8 @@ const NAMES$77 = {
45666
45703
  "priorities",
45667
45704
  "prefix",
45668
45705
  "readAll",
45669
- "extraColumns"
45706
+ "extraColumns",
45707
+ "lineExtraColumns"
45670
45708
  ],
45671
45709
  tables: {
45672
45710
  deals: {
@@ -46004,7 +46042,8 @@ function build$78(ctx) {
46004
46042
  contact: ctx.text("contact", "person"),
46005
46043
  prefix: ctx.text("prefix", "DEAL-"),
46006
46044
  service: "(auth.role() = 'service_role')",
46007
- extras: ctx.extraColumns("deals", ["contacts", "members"])
46045
+ extras: ctx.extraColumns("deals", ["contacts", "members"]),
46046
+ lineExtras: lineExtraColumns(ctx)
46008
46047
  };
46009
46048
  return `${schemaPreamble(ctx)}
46010
46049
  -- Deals on pipelines: an amount in minor units, a company and contacts, a
@@ -52346,7 +52385,7 @@ function quoteFunctions(ctx, n) {
52346
52385
  end if;`;
52347
52386
  const editable = (alias) => `(${n.service} or ${ctx.scope.can(`${alias}.${q("tenant")}`, n.write)})`;
52348
52387
  const open = (alias) => `${alias}.${q("status")} in ('draft', 'changes_requested')`;
52349
- const lines = (alias) => `coalesce((select jsonb_agg(jsonb_build_object('description', ql.${l("description")}, 'quantity', ql.${l("quantity")}, 'unitAmount', ql.${l("unitAmount")}::text, 'discountBps', ql.${l("discountBps")}, 'taxRateBps', ql.${l("taxRateBps")}, 'taxCode', ql.${l("taxCode")}, 'product', case when ql.${l("productType")} is null then null else jsonb_build_object('type', ql.${l("productType")}, 'id', ql.${l("productId")}) end) order by ql.${l("position")}) from ${t("lines")} ql where ql.${l("parent")} = ${alias}.${q("id")}), '[]'::jsonb)`;
52388
+ const lines = (alias) => `coalesce((select jsonb_agg(jsonb_build_object('description', ql.${l("description")}, 'quantity', ql.${l("quantity")}, 'unitAmount', ql.${l("unitAmount")}::text, 'discountBps', ql.${l("discountBps")}, 'taxRateBps', ql.${l("taxRateBps")}, 'taxCode', ql.${l("taxCode")}, 'product', case when ql.${l("productType")} is null then null else jsonb_build_object('type', ql.${l("productType")}, 'id', ql.${l("productId")}) end${lineFieldsJson("ql", n.lineExtras)}) order by ql.${l("position")}) from ${t("lines")} ql where ql.${l("parent")} = ${alias}.${q("id")}), '[]'::jsonb)`;
52350
52389
  const int8 = ["number", ...Object.keys(TOTAL_COLUMNS)].map(q);
52351
52390
  const row = (alias) => `(to_jsonb(${alias}) - ${sqlString(q("tokenHash").replaceAll("\"", ""))}) || ${int8Text(alias, int8)} || jsonb_build_object('lines', ${lines(alias)}${n.extras.length === 0 ? "" : `, 'fields', ${columnsObject(alias, n.extras.map((extra) => extra.name))}`})`;
52352
52391
  const record = (type, alias, extra = "") => ctx.record({
@@ -52550,7 +52589,8 @@ ${userGrant(`${fn("update_quote")}(uuid, jsonb)`)}
52550
52589
  ${lineItemsSql(ctx, {
52551
52590
  lines: "lines",
52552
52591
  parent: "quotes",
52553
- frozen: `not (${open("p")})`
52592
+ frozen: `not (${open("p")})`,
52593
+ extras: n.lineExtras
52554
52594
  }, {
52555
52595
  setter: "set_quote_lines",
52556
52596
  guard: `if not exists (select 1 from ${t("quotes")} x where x.${q("id")} = v_parent and ${editable("x")}) then
@@ -56530,7 +56570,7 @@ function historyBindings(ctx) {
56530
56570
  }
56531
56571
  function bindingTrigger$1(ctx, binding, c) {
56532
56572
  const type = binding.subject.type;
56533
- const name = `bsb_field_history_${type}`;
56573
+ const name = `bsb_field_history_${subjectTypeIdent(type)}`;
56534
56574
  const watched = binding.fields.map(sqlIdent).join(", ");
56535
56575
  const values = binding.fields.map((field) => `(${sqlString(field)}, to_jsonb(old.${sqlIdent(field)}), to_jsonb(new.${sqlIdent(field)}))`).join(",\n ");
56536
56576
  return `
@@ -71522,7 +71562,7 @@ function invoiceFunctions(ctx, n) {
71522
71562
  const row = (alias) => `to_jsonb(${alias}) || ${int8Text(alias, int8)} || jsonb_build_object(
71523
71563
  'balance', ${balance(alias)}::text,
71524
71564
  'overdue', ${alias}.${i("status")} in ('issued', 'partially_paid') and ${alias}.${i("dueOn")} < current_date,
71525
- 'lines', coalesce((select jsonb_agg(jsonb_build_object('description', il.${l("description")}, 'quantity', il.${l("quantity")}, 'unitAmount', il.${l("unitAmount")}::text, 'discountBps', il.${l("discountBps")}, 'taxRateBps', il.${l("taxRateBps")}, 'taxCode', il.${l("taxCode")}) order by il.${l("position")}) from ${t("lines")} il where il.${l("parent")} = ${alias}.${i("id")}), '[]'::jsonb),
71565
+ 'lines', coalesce((select jsonb_agg(jsonb_build_object('description', il.${l("description")}, 'quantity', il.${l("quantity")}, 'unitAmount', il.${l("unitAmount")}::text, 'discountBps', il.${l("discountBps")}, 'taxRateBps', il.${l("taxRateBps")}, 'taxCode', il.${l("taxCode")}${lineFieldsJson("il", n.lineExtras)}) order by il.${l("position")}) from ${t("lines")} il where il.${l("parent")} = ${alias}.${i("id")}), '[]'::jsonb),
71526
71566
  'payments', ${ledger.payments(alias)})`;
71527
71567
  const record = (type, alias, extra = "", audit = false) => ctx.record({
71528
71568
  type,
@@ -71680,7 +71720,8 @@ ${userGrant(`${fn("create_invoice")}(${ctx.idType}, jsonb, jsonb)`)}
71680
71720
  ${lineItemsSql(ctx, {
71681
71721
  lines: "lines",
71682
71722
  parent: "invoices",
71683
- frozen: `p.${i("status")} <> 'draft'`
71723
+ frozen: `p.${i("status")} <> 'draft'`,
71724
+ extras: n.lineExtras
71684
71725
  }, {
71685
71726
  setter: "set_invoice_lines",
71686
71727
  guard: `if not exists (select 1 from ${t("invoices")} x where x.${i("id")} = v_parent and ${can("x", n.write)}) then
@@ -72035,7 +72076,8 @@ const NAMES$54 = {
72035
72076
  "prefix",
72036
72077
  "creditPrefix",
72037
72078
  "termsDays",
72038
- "extraColumns"
72079
+ "extraColumns",
72080
+ "lineExtraColumns"
72039
72081
  ],
72040
72082
  tables: {
72041
72083
  invoices: {
@@ -72167,7 +72209,8 @@ function build$54(ctx) {
72167
72209
  "payments",
72168
72210
  "balance",
72169
72211
  "overdue"
72170
- ])
72212
+ ]),
72213
+ lineExtras: lineExtraColumns(ctx)
72171
72214
  };
72172
72215
  return `${schemaPreamble(ctx)}
72173
72216
  -- Invoices an organization sends its own customers: drafts with lines, a
@@ -78093,7 +78136,7 @@ as $$
78093
78136
  ), '[]'::jsonb),
78094
78137
  'subjects', coalesce((
78095
78138
  select jsonb_agg(distinct jsonb_build_object('type', m[1], 'id', m[2]))
78096
- from regexp_matches(parse_mentions.body, '@\\[[^\\]\\n]{1,100}\\]\\(subject:([a-z][a-z0-9_]{0,62})/([^)\\s]{1,200})\\)', 'g') m
78139
+ from regexp_matches(parse_mentions.body, '@\\[[^\\]\\n]{1,100}\\]\\(subject:([a-z][a-z0-9_-]{0,62})/([^)\\s]{1,200})\\)', 'g') m
78097
78140
  ), '[]'::jsonb),
78098
78141
  'scope', case
78099
78142
  when parse_mentions.body ~ '(^|[^\\w@])@channel\\M' then 'channel'
@@ -83340,10 +83383,7 @@ $$;`;
83340
83383
  * with the tenant column.
83341
83384
  */
83342
83385
  function subjectCleanup(ctx, n) {
83343
- const subjects = subjectsOption(ctx, [], {
83344
- tenantless: true,
83345
- hyphens: true
83346
- });
83386
+ const subjects = subjectsOption(ctx, [], { tenantless: true });
83347
83387
  if (!subjects.some(([, subject]) => subject.cascade)) return "";
83348
83388
  if (!n.has("events", "subjectType") || !n.has("events", "subjectId")) throw new TypeError("blocks.notifications.on with cascade needs the subjectType and subjectId columns of the events table");
83349
83389
  const tables = ctx.hasTable("subscriptions") ? ["events", "subscriptions"] : ["events"];
@@ -91388,7 +91428,7 @@ function stageTrigger(ctx, names, binding) {
91388
91428
  const amount = binding.amount === void 0 ? "null" : `new.${col(binding.amount)}`;
91389
91429
  const currency = binding.currency === void 0 ? "null" : `new.${col(binding.currency)}`;
91390
91430
  const entered = binding.enteredAt === void 0 ? "" : `\n new.${col(binding.enteredAt)} := now();`;
91391
- const name = `bsb_pipeline_${binding.type}`;
91431
+ const name = `bsb_pipeline_${subjectTypeIdent(binding.type)}`;
91392
91432
  const transitions = ctx.hasTable("transitions") ? `
91393
91433
  if tg_op = 'UPDATE' and old.${stage} is not null
91394
91434
  and exists (select 1 from ${t("transitions")} x where x.${c("transitions", "pipeline")} = new.${pipeline})
@@ -91506,7 +91546,7 @@ ${statusTrigger(names, binding)}`;
91506
91546
  * separate update so a state-machine trigger on the status column runs.
91507
91547
  */
91508
91548
  function statusTrigger(names, binding) {
91509
- const name = `bsb_pipeline_status_${binding.type}`;
91549
+ const name = `bsb_pipeline_status_${subjectTypeIdent(binding.type)}`;
91510
91550
  const subject = binding.subject;
91511
91551
  if (binding.status === void 0) return `drop trigger if exists ${name} on ${subject.qualified};
91512
91552
  drop function if exists better_supabase.${name}();`;
@@ -95918,7 +95958,8 @@ const NAMES$33 = {
95918
95958
  "contact",
95919
95959
  "prefix",
95920
95960
  "validDays",
95921
- "extraColumns"
95961
+ "extraColumns",
95962
+ "lineExtraColumns"
95922
95963
  ],
95923
95964
  tables: {
95924
95965
  quotes: {
@@ -96041,7 +96082,8 @@ function build$33(ctx) {
96041
96082
  "lines",
96042
96083
  "token",
96043
96084
  "fields"
96044
- ])
96085
+ ]),
96086
+ lineExtras: lineExtraColumns(ctx)
96045
96087
  };
96046
96088
  return `${schemaPreamble(ctx)}
96047
96089
  -- Quotes: line items and totals, a revision chain, sending with a public
@@ -100539,7 +100581,7 @@ begin
100539
100581
  if v_name is null or length(v_name) > 200 then
100540
100582
  ${invalid("a score model needs a name of at most 200 characters")}
100541
100583
  end if;
100542
- if v_subject_type is null or v_subject_type !~ '^[a-z][a-z0-9_]{0,62}$' then
100584
+ if v_subject_type is null or v_subject_type !~ '^[a-z][a-z0-9_-]{0,62}$' then
100543
100585
  ${invalid("a score model needs a subject type")}
100544
100586
  end if;
100545
100587
  if jsonb_typeof(v_rules) is distinct from 'array' or jsonb_array_length(v_rules) > ${maxRules} then
@@ -100986,7 +101028,7 @@ function build$26(ctx) {
100986
101028
  ${m("key")} text not null check (${m("key")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
100987
101029
  ${m("name")} text not null check (length(${m("name")}) between 1 and 200),
100988
101030
  ${m("description")} text check (${m("description")} is null or length(${m("description")}) <= 2000),
100989
- ${m("subjectType")} text not null check (${m("subjectType")} ~ '^[a-z][a-z0-9_]{0,62}$'),
101031
+ ${m("subjectType")} text not null check (${m("subjectType")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
100990
101032
  -- [{ id, label, conditions, points }]: a filter tree over the rules field
100991
101033
  -- catalog and the points a match adds.
100992
101034
  ${jsonArray(m("rules"))},
@@ -102518,7 +102560,7 @@ function tables$4(ctx, n) {
102518
102560
  ${s("tenant")} ${ctx.idType} not null,
102519
102561
  ${s("name")} text not null check (length(${s("name")}) between 1 and 200),
102520
102562
  ${s("description")} text check (length(${s("description")}) <= 2000),
102521
- ${s("subjectType")} text not null check (${s("subjectType")} ~ '^[a-z][a-z0-9_]{0,62}$'),
102563
+ ${s("subjectType")} text not null check (${s("subjectType")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
102522
102564
  ${s("conditions")} jsonb not null check (jsonb_typeof(${s("conditions")}) = 'object'),
102523
102565
  ${s("memberCount")} integer not null default 0,
102524
102566
  ${s("refreshedAt")} timestamptz,
@@ -103546,7 +103588,7 @@ begin
103546
103588
  if jsonb_typeof(v_attrs) <> 'object' then
103547
103589
  ${q.invalid("attrs must be an object")}
103548
103590
  end if;
103549
- if enroll_in_sequence.subject_type is null or enroll_in_sequence.subject_type !~ '^[a-z][a-z0-9_]{0,62}$' then
103591
+ if enroll_in_sequence.subject_type is null or enroll_in_sequence.subject_type !~ '^[a-z][a-z0-9_-]{0,62}$' then
103550
103592
  ${q.invalid("subject_type: use lowercase letters, digits or _")}
103551
103593
  end if;
103552
103594
  if enroll_in_sequence.subject_id is null or length(enroll_in_sequence.subject_id) not between 1 and 200 then
@@ -104069,7 +104111,7 @@ create table if not exists ${members} (
104069
104111
  ${r("enrollment")} uuid primary key references ${q.enrollments} (${q.e("id")}) on delete cascade,
104070
104112
  ${r("tenant")} ${ctx.idType} not null,
104071
104113
  ${r("sequence")} uuid not null references ${sequences} (${s("id")}) on delete cascade,
104072
- ${r("subjectType")} text not null check (${r("subjectType")} ~ '^[a-z][a-z0-9_]{0,62}$'),
104114
+ ${r("subjectType")} text not null check (${r("subjectType")} ~ '^[a-z][a-z0-9_-]{0,62}$'),
104073
104115
  ${r("subjectId")} text not null check (length(${r("subjectId")}) between 1 and 200),
104074
104116
  ${r("address")} text check (${r("address")} is null or (length(${r("address")}) <= 320 and ${r("address")} ~ '^[^@[:space:]]+@[^@[:space:]]+$')),
104075
104117
  ${r("name")} text check (${r("name")} is null or length(${r("name")}) <= 200),
@@ -108582,7 +108624,7 @@ function bindings(ctx) {
108582
108624
  const textArray$1 = (items) => `${sqlString(`{${items.map((item) => `"${item.replaceAll("\"", "\\\"")}"`).join(",")}}`)}::text[]`;
108583
108625
  function bindingTrigger(binding, fn) {
108584
108626
  const type = binding.subject.type;
108585
- const name = `bsb_sla_${type}`;
108627
+ const name = `bsb_sla_${subjectTypeIdent(type)}`;
108586
108628
  const status = sqlIdent(binding.status);
108587
108629
  const priority = binding.priority === void 0 ? "null" : `new.${sqlIdent(binding.priority)}::text`;
108588
108630
  const id = `new.${binding.subject.id}::text`;
@@ -120063,13 +120105,13 @@ create table if not exists ${t} (
120063
120105
  last_received_at timestamptz,
120064
120106
  last_status integer,
120065
120107
  metadata jsonb not null default '{}',
120066
- subject_type text check (subject_type ~ '^[a-z][a-z0-9_]{0,62}$'),
120108
+ subject_type text check (subject_type ~ '^[a-z][a-z0-9_-]{0,62}$'),
120067
120109
  subject_id text check (length(subject_id) between 1 and 200),
120068
120110
  created_by uuid references auth.users (id) on delete set null,
120069
120111
  created_at timestamptz not null default now(),
120070
120112
  updated_at timestamptz not null default now()
120071
120113
  );
120072
- alter table ${t} add column if not exists subject_type text check (subject_type ~ '^[a-z][a-z0-9_]{0,62}$');
120114
+ alter table ${t} add column if not exists subject_type text check (subject_type ~ '^[a-z][a-z0-9_-]{0,62}$');
120073
120115
  alter table ${t} add column if not exists subject_id text check (length(subject_id) between 1 and 200);
120074
120116
  alter table ${t} add column if not exists secret_id uuid;
120075
120117
  alter table ${t} drop constraint if exists incoming_webhooks_verify_check;
@@ -128443,6 +128485,7 @@ function moduleLayout(config, testsDir = config.sql.testsDir, readSets = [], ent
128443
128485
  modules: config.blocks,
128444
128486
  instances: config.instances,
128445
128487
  ...config.sql.scope === void 0 ? {} : { scope: config.sql.scope },
128488
+ ...config.sql.tenantColumn === void 0 ? {} : { blockTenantColumn: config.sql.tenantColumn },
128446
128489
  subjects: config.subjects,
128447
128490
  appTables: config.appTables,
128448
128491
  vectorSearch: config.vectorSearch,
@@ -1,6 +1,6 @@
1
1
  import { Bt as Executor } from "../types-DFdg_4yN.js";
2
2
  import { c as LocalTablesOption, n as DataEngine, s as LiveEngineOptions } from "../data-engine-BWoz9lED.js";
3
- import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-BWFfz0ik.js";
3
+ import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-D1UUQEGL.js";
4
4
  //#region src/sqlite/engine.d.ts
5
5
  /** A SQLite database that may report which tables changed. */
6
6
  interface ChangingSqliteDatabase extends SqliteDatabaseLike {
@@ -1,8 +1,8 @@
1
1
  import { n as dbError } from "./errors-BVFgt8BZ.js";
2
2
  import { n as isRecord } from "./guards-6F2bCtQR.js";
3
3
  import { a as ok, r as err, t as AsyncResult } from "./result-ntFBW2p2.js";
4
- import { C as optionalText, D as recordOf, F as stringsOf, I as textOf, R as toInstant, S as optionalInstant, f as errorText, k as recordsOf, n as applyTemporal, o as blockCall } from "./block-helpers-CtBdjgO4.js";
5
- import { r as withBlockHooks } from "./block-hooks-BfxX3682.js";
4
+ import { C as optionalText, D as recordOf, F as stringsOf, I as textOf, R as toInstant, S as optionalInstant, f as errorText, k as recordsOf, n as applyTemporal, o as blockCall } from "./block-helpers-DnCtsKtv.js";
5
+ import { r as withBlockHooks } from "./block-hooks-DbIpkq7a.js";
6
6
  //#region src/blocks/sso/sso.ts
7
7
  function recordOfDomain(value) {
8
8
  const row = recordOf(value, "organization_domains.record");
@@ -1,6 +1,6 @@
1
1
  import { C as readSession, D as writeSession, E as sessionEncoding, S as pruneSessionChunks, T as sessionCookieName, _ as StoredSession, a as ResolveAuthOptions, b as clearSessionAtScopes, d as CookieOptions, f as CookieRecord, g as SessionEncoding, h as DEFAULT_SESSION_ENCODING, l as resolveAuth, m as CookieWrite, n as AuthResolver, p as CookieScope, r as AuthState, t as AuthResolution, u as AUTH_CACHE_HEADERS, v as WriteSessionOptions, w as serializeCookie, x as parseCookies, y as applyCookieWrites } from "../resolve-CXX6DHv3.js";
2
2
  import { n as toSession, t as AuthSession } from "../view-DyFdMCqg.js";
3
- import { r as MembershipClaim } from "../entitlements-DHcNt1aF.js";
3
+ import { r as MembershipClaim } from "../entitlements-BhNzAcJR.js";
4
4
  import { n as RefreshOutcome, r as refreshSession, t as RefreshOptions } from "../refresh-DT_ICaK-.js";
5
5
  import { a as sessionStatus, i as clearSessionCookies, n as SessionStatus, o as authContext, r as SessionStatusOptions, t as ClearSessionCookiesOptions } from "../ended-gUsMZVNg.js";
6
6
  export { AUTH_CACHE_HEADERS, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type ClearSessionCookiesOptions, type CookieOptions, type CookieRecord, type CookieScope, type CookieWrite, DEFAULT_SESSION_ENCODING, type MembershipClaim, type RefreshOptions, type RefreshOutcome, type ResolveAuthOptions, type SessionEncoding, type SessionStatus, type SessionStatusOptions, type StoredSession, type WriteSessionOptions, applyCookieWrites, authContext, clearSessionAtScopes, clearSessionCookies, parseCookies, pruneSessionChunks, readSession, refreshSession, resolveAuth, serializeCookie, sessionCookieName, sessionEncoding, sessionStatus, toSession, writeSession };
@@ -3,10 +3,10 @@ import { n as dbError } from "../errors-BVFgt8BZ.js";
3
3
  import { c as optionalTemporal, n as isInstant } from "../temporal-DLZlWbOi.js";
4
4
  import { n as temporalMissing } from "../temporal-required-Dy0GGD8E.js";
5
5
  import { a as ok, r as err, s as toDbError, t as AsyncResult } from "../result-ntFBW2p2.js";
6
+ import { a as sqlString, i as sqlIdent, n as parseTemplate, r as slug, t as claimSql } from "../template-Drgg3v2J.js";
6
7
  import { a as spansAllTenants } from "../plugin-AKwwe2gF.js";
7
8
  import { n as decodeJwtPayload } from "../base64-B9Wlsdj7.js";
8
9
  import { a as tenantClaimPaths, o as tenantFrom, s as tenantPathsFor } from "../claims-Bp9My7XP.js";
9
- import { a as sqlString, i as sqlIdent, n as parseTemplate, r as slug, t as claimSql } from "../template-Drgg3v2J.js";
10
10
  import { r as accessCheck } from "../access-sql-CNIgUqWf.js";
11
11
  import { t as fromStorageError } from "../errors-CyxMxzlu.js";
12
12
  import { a as ttlSeconds, i as TTL, r as transformFor, t as checkVariants } from "../variants-Cy--Ub-a.js";
@@ -1,5 +1,6 @@
1
1
  import { n as isRecord } from "../guards-6F2bCtQR.js";
2
- import { B as dbTransport, D as recordOf, F as stringsOf, H as rpcTransport, M as seconds, U as sqlTransport, o as blockCall } from "../block-helpers-CtBdjgO4.js";
2
+ import { i as sqlTransport, r as rpcTransport, t as dbTransport } from "../block-transport-PNea4lfQ.js";
3
+ import { D as recordOf, F as stringsOf, M as seconds, o as blockCall } from "../block-helpers-DnCtsKtv.js";
3
4
  import { n as teeToStore, r as writeToStore, t as resumeFromStore } from "../tee-V97_v1ZS.js";
4
5
  import { t as pollingRead } from "../store-McN-2esd.js";
5
6
  //#region src/streams/postgres.ts
@@ -1,4 +1,4 @@
1
- import "./block-helpers-CtBdjgO4.js";
1
+ import "./block-helpers-DnCtsKtv.js";
2
2
  //#region src/core/subject-readers.ts
3
3
  /**
4
4
  * A registered subject's type and id, from `subjects/<type>/<id>` or
@@ -0,0 +1,8 @@
1
+ //#region src/core/subject-type.ts
2
+ const SUBJECT_TYPE_PATTERN = /^[a-z][a-z0-9_-]{0,62}$/;
3
+ const SUBJECT_TYPE_SQL_PATTERN = "^[a-z][a-z0-9_-]{0,62}$";
4
+ function subjectTypeIdent(type) {
5
+ return type.replaceAll("-", "_");
6
+ }
7
+ //#endregion
8
+ export { SUBJECT_TYPE_SQL_PATTERN as n, subjectTypeIdent as r, SUBJECT_TYPE_PATTERN as t };