better-supabase 0.29.0 → 0.31.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 (208) hide show
  1. package/dist/{adapter-D4aNBxhm.js → adapter-BTbj5N9C.js} +2 -52
  2. package/dist/ai-sdk/agents/index.d.ts +2 -2
  3. package/dist/{app-tables-DekyKNQ8.d.ts → app-tables-B2mKMNRQ.d.ts} +1 -1
  4. package/dist/astro/index.js +2 -2
  5. package/dist/{authorization-C7nuWMuB.d.ts → authorization-DfEkyFt_.d.ts} +24 -3
  6. package/dist/{bind-DmUGUsBd.d.ts → bind-DAx0bMSi.d.ts} +2 -2
  7. package/dist/{block-env-DWtZsqhH.d.ts → block-env-Dz7Caxk0.d.ts} +3 -3
  8. package/dist/blocks/ai-chat/index.d.ts +3 -3
  9. package/dist/blocks/announcements/index.d.ts +3 -3
  10. package/dist/blocks/api-keys/index.d.ts +1 -1
  11. package/dist/blocks/attachments/index.d.ts +1 -1
  12. package/dist/blocks/audit/index.d.ts +2 -2
  13. package/dist/blocks/automations/index.d.ts +1 -1
  14. package/dist/blocks/billing/index.d.ts +1 -1
  15. package/dist/blocks/bookings/index.d.ts +1 -1
  16. package/dist/blocks/calendar/index.d.ts +7 -3
  17. package/dist/blocks/calendar/index.js +5 -1
  18. package/dist/blocks/comments/index.d.ts +4 -4
  19. package/dist/blocks/employees/index.js +1 -4
  20. package/dist/blocks/entitlements/index.d.ts +2 -2
  21. package/dist/blocks/forms/index.d.ts +1 -1
  22. package/dist/blocks/inbox/index.d.ts +4 -4
  23. package/dist/blocks/index.d.ts +1 -1
  24. package/dist/blocks/messaging/index.d.ts +4 -4
  25. package/dist/blocks/mfa/index.d.ts +1 -1
  26. package/dist/blocks/notifications/index.d.ts +3 -3
  27. package/dist/blocks/notifications/index.js +5 -43
  28. package/dist/blocks/onboarding/index.d.ts +1 -1
  29. package/dist/blocks/organizations/index.d.ts +34 -21
  30. package/dist/blocks/organizations/index.js +5 -1
  31. package/dist/blocks/permissions/index.d.ts +32 -3
  32. package/dist/blocks/permissions/index.js +23 -2
  33. package/dist/blocks/push/index.d.ts +10 -2
  34. package/dist/blocks/push/index.js +23 -7
  35. package/dist/blocks/reactions/index.d.ts +3 -3
  36. package/dist/blocks/saved-views/index.d.ts +1 -1
  37. package/dist/blocks/search/index.d.ts +2 -2
  38. package/dist/blocks/sessions/index.d.ts +1 -1
  39. package/dist/blocks/settings/index.d.ts +1 -1
  40. package/dist/blocks/subjects/index.d.ts +1 -1
  41. package/dist/blocks/tags/index.d.ts +1 -1
  42. package/dist/blocks/tasks/index.js +1 -1
  43. package/dist/blocks/teams/index.d.ts +7 -1
  44. package/dist/blocks/teams/index.js +8 -7
  45. package/dist/blocks/undo/index.d.ts +1 -1
  46. package/dist/blocks/usage/index.d.ts +1 -1
  47. package/dist/blocks/workflow-editor/index.d.ts +3 -3
  48. package/dist/blocks/workflows/index.d.ts +3 -3
  49. package/dist/cli/{add-BKkV99g9.js → add-B9wP0YGU.js} +2 -2
  50. package/dist/cli/{add-CrQ3jS7t.js → add-DjZXKd7X.js} +10 -10
  51. package/dist/cli/add-ZcEOEK23.js +1 -0
  52. package/dist/cli/{app-table-files-PnPOpuB4.js → app-table-files-mtvjHa48.js} +2 -2
  53. package/dist/cli/{backfill-DDDLhinm.js → backfill-Coshdvh_.js} +2 -2
  54. package/dist/cli/bin.js +1 -1
  55. package/dist/cli/{blocks-tRfYx_mh.js → blocks-BWCuA0nq.js} +2 -2
  56. package/dist/cli/{blocks-BCVcjvbm.js → blocks-hiSazThw.js} +1 -1
  57. package/dist/cli/{cache-DQZ09YOg.js → cache-x2wWAy0h.js} +1 -1
  58. package/dist/cli/{codemod-HKuwQmi_.js → codemod-BnjV7BpC.js} +210 -11
  59. package/dist/cli/{command-DIPmo0wh.js → command-CCAwhiOh.js} +6 -0
  60. package/dist/cli/{completion-DxPxMtyP.js → completion-BJaB84Pe.js} +2 -2
  61. package/dist/cli/{completion-DyLMSjOD.js → completion-BkUhs1ms.js} +1 -1
  62. package/dist/cli/{completion-FUgqm2-N.js → completion-DmUVsUVQ.js} +2 -2
  63. package/dist/cli/{config-BfapErxs.js → config-zId1jkLx.js} +1 -1
  64. package/dist/cli/{content-mapper-B0ehR7K-.js → content-mapper-DvOSOdTE.js} +2 -2
  65. package/dist/cli/{db-CWvH1_46.js → db-DXKyVEDF.js} +1 -1
  66. package/dist/cli/{doctor-CXJOhwLB.js → doctor-Ywy8oJEU.js} +76 -18
  67. package/dist/cli/env-CNjT_uOV.js +1 -0
  68. package/dist/cli/{env-BM242BCV.js → env-XMiKvhtV.js} +2 -2
  69. package/dist/cli/{gen-B7rw4j19.js → gen-B-FbQmG1.js} +14 -14
  70. package/dist/cli/index.d.ts +1 -1
  71. package/dist/cli/index.js +7 -7
  72. package/dist/cli/{init-C1bXXB_P.js → init-fb9e1BKX.js} +9 -9
  73. package/dist/cli/{keys-V-HcO-21.js → keys-ORiPz1sM.js} +1 -1
  74. package/dist/cli/{live-PpAh9pAc.js → live-DIt7TP-N.js} +2 -2
  75. package/dist/cli/{mcp-BRNAchdH.js → mcp-CVWwraga.js} +3 -3
  76. package/dist/cli/{metadata-dAAKb_kR.js → metadata-CannIjel.js} +3 -3
  77. package/dist/cli/{migrate-BWYXFnaW.js → migrate-Ht2TzIQF.js} +2 -2
  78. package/dist/cli/{migration-safety-DGQswWZy.js → migration-safety-nNyB05I-.js} +1 -1
  79. package/dist/cli/{migrations-Cqk-lJwu.js → migrations-bAd7dpk1.js} +2 -2
  80. package/dist/cli/{module-migration-8-hMiZtW.js → module-migration-CkNux8dr.js} +2 -2
  81. package/dist/cli/{moved-DNOtp9LA.js → moved-C3WyRHkA.js} +1 -1
  82. package/dist/cli/{parse-BPf3kGnc.js → parse-DjHbTaFI.js} +1 -1
  83. package/dist/cli/{powersync-BWQ-8T3G.js → powersync-B2v0tDwp.js} +100 -7
  84. package/dist/cli/powersync-D3mAQ6QE.js +1 -0
  85. package/dist/cli/{print-DSTnq5xz.js → print-CxQ0rBKT.js} +2 -2
  86. package/dist/cli/{providers-Cjf5iOp5.js → providers-DtI90lSw.js} +1 -1
  87. package/dist/cli/{remove-CwG8cPv1.js → remove-DYtE4IZ4.js} +6 -6
  88. package/dist/cli/{render-B18iAdsT.js → render-QGWfEoiB.js} +3 -3
  89. package/dist/cli/{run-CvPl8iQd.js → run-B5aMwErM.js} +3 -3
  90. package/dist/cli/{run-C2Yg5MWt.js → run-BNoJKf5I.js} +40 -39
  91. package/dist/cli/{run-Wx_2Acgv.js → run-DiYX1XEa.js} +8 -8
  92. package/dist/cli/{seed-CDnL4Tnc.js → seed-C-Hu2n_E.js} +1 -1
  93. package/dist/cli/seed-Cm-c0BDd.js +1 -0
  94. package/dist/cli/{shared-BHbtUOvh.js → shared-D_CFi5di.js} +1 -1
  95. package/dist/cli/{skills-DM3oeIxY.js → skills-D98y0bSB.js} +1 -1
  96. package/dist/cli/{snapshot-CXgsUPGj.js → snapshot-BlQ4DDcJ.js} +9 -4
  97. package/dist/cli/{source-B6aMAoEK.js → source-CelMBQMj.js} +1 -1
  98. package/dist/cli/{spec-EO0TP84d.js → spec-BxcoGE0h.js} +1 -1
  99. package/dist/cli/{spec-BcYic005.js → spec-iBx1LcYO.js} +3 -3
  100. package/dist/cli/{sql-layout-CkxDNVEH.js → sql-layout-Dp4Rottt.js} +2 -2
  101. package/dist/cli/{stack-ClESAZYf.js → stack-B2slzrYH.js} +1 -1
  102. package/dist/cli/{stack-env-6hS-WEmh.js → stack-env-3ziggrU3.js} +1 -1
  103. package/dist/cli/{sync-pq6gmlhG.js → sync-BnORI43S.js} +4 -4
  104. package/dist/cli/{table-dyKddjwo.js → table-D6HUECKI.js} +1 -1
  105. package/dist/cli/{upgrade-Dp9p7A69.js → upgrade-CR6-WmIc.js} +5 -5
  106. package/dist/cli/{upgrade-BoHb4h9P.js → upgrade-fz92aCnh.js} +3 -3
  107. package/dist/cli/{version-CQHFm-ak.js → version-Dz8ZlOuh.js} +1 -1
  108. package/dist/client/index.d.ts +5 -5
  109. package/dist/client/native/index.d.ts +4 -4
  110. package/dist/{composite-CBRbvn5j.js → composite-B4qB6k31.js} +2 -2
  111. package/dist/config/index.d.ts +2 -2
  112. package/dist/config/index.js +4 -4
  113. package/dist/{config-r7njjNgh.js → config-B7g-HDis.js} +3 -3
  114. package/dist/{config-bqKaPjst.js → config-R0m0fBiD.js} +1 -1
  115. package/dist/{context-B4TsE2gY.d.ts → context-DWWoP1wK.d.ts} +13 -1
  116. package/dist/{controller-CtwAsnVV.d.ts → controller-Br9dGKGe.d.ts} +1 -1
  117. package/dist/{controller-qG-B1eDn.js → controller-W97g2WGG.js} +1 -1
  118. package/dist/create/index.d.ts +3 -3
  119. package/dist/create/index.js +3 -3
  120. package/dist/create/lite/index.d.ts +3 -3
  121. package/dist/create/lite/index.js +3 -3
  122. package/dist/delivery-events-DbL8IHIY.js +53 -0
  123. package/dist/edge/index.js +3 -3
  124. package/dist/{entitlements-Bw3eYGKJ.d.ts → entitlements-CBjm2lvD.d.ts} +1 -1
  125. package/dist/eve/index.js +1 -1
  126. package/dist/expo/index.js +3 -2
  127. package/dist/{field-errors-DkzFduux.d.ts → field-errors-CEjsMAgd.d.ts} +4 -4
  128. package/dist/{framework-DYEUraqt.js → framework-CqiZk89W.js} +1 -1
  129. package/dist/hono/index.js +2 -2
  130. package/dist/{index-CB66nl14.d.ts → index-Clyd2Goi.d.ts} +1 -1
  131. package/dist/{index-Cw5gGSP8.d.ts → index-D98bQs8a.d.ts} +7 -7
  132. package/dist/{index-BNgpz_BV.d.ts → index-DIdPoQtO.d.ts} +2 -2
  133. package/dist/{index-BxckmAFc.d.ts → index-I8YLxKq8.d.ts} +2 -2
  134. package/dist/{index-CBQT_nXf.d.ts → index-eRBuKtMt.d.ts} +2 -2
  135. package/dist/{index-BM6NmKSc.d.ts → index-uIU65iEn.d.ts} +6 -6
  136. package/dist/{instances-C7qUTjhJ.js → instances-DY_ORk5g.js} +2 -0
  137. package/dist/mapper/bin.js +5 -5
  138. package/dist/mcp/index.d.ts +1 -1
  139. package/dist/mcp/index.js +1 -1
  140. package/dist/mcp/sdk/index.js +1 -1
  141. package/dist/next/index.d.ts +155 -13
  142. package/dist/next/index.js +245 -52
  143. package/dist/{operations-CqmQrTKw.d.ts → operations-hm1Isvvs.d.ts} +1 -1
  144. package/dist/{options-C4LuqmdG.js → options-CF6EVF_G.js} +3 -1
  145. package/dist/{options-COo7_3MX.js → options-DSCW40_5.js} +3 -1
  146. package/dist/orpc/index.js +2 -1
  147. package/dist/otel/index.js +4 -4
  148. package/dist/{ports-6LBgr1Aa.d.ts → ports-DOrPTJzl.d.ts} +1 -1
  149. package/dist/powersync/index.d.ts +204 -4
  150. package/dist/powersync/index.js +361 -4
  151. package/dist/preset/index.d.ts +3 -3
  152. package/dist/preset/index.js +3 -3
  153. package/dist/{preset-DCdEnJj9.js → preset-CXhpPmPV.js} +2 -2
  154. package/dist/{project-C4NA_van.js → project-DJ9Uo0sT.js} +5 -5
  155. package/dist/{push-token-BXsrJ7W9.d.ts → push-token-B4vcIU4s.d.ts} +1 -1
  156. package/dist/query/index.d.ts +1 -1
  157. package/dist/query/index.js +1 -1
  158. package/dist/react/index.d.ts +5 -5
  159. package/dist/react/index.js +1 -1
  160. package/dist/react/native/index.d.ts +1 -1
  161. package/dist/react/server.d.ts +5 -5
  162. package/dist/react/server.js +1 -1
  163. package/dist/{react-CcrQQl0_.js → react-mdVjpewL.js} +2 -2
  164. package/dist/react-router/index.js +2 -2
  165. package/dist/realtime/index.d.ts +3 -3
  166. package/dist/{record-type-DRbnlj5q.js → record-type-BEUyEsFx.js} +2 -2
  167. package/dist/records/index.d.ts +5 -5
  168. package/dist/records/index.js +3 -3
  169. package/dist/{replicas-Dyoh3CEg.js → refresh-DLBgnxjL.js} +51 -1
  170. package/dist/{resolved-names-iLBOUaib.js → resolved-names-kMRjmSIy.js} +1 -1
  171. package/dist/{runtime-CoKxZibd.js → runtime-LRJM7UqY.js} +19 -20
  172. package/dist/server/index.d.ts +3 -3
  173. package/dist/server/index.js +4 -4
  174. package/dist/sign-in-BzihC_8k.d.ts +50 -0
  175. package/dist/{sign-in-NO7LWlw4.js → sign-in-CuZ1Ag7O.js} +136 -26
  176. package/dist/solid/index.d.ts +5 -5
  177. package/dist/solid-start/index.js +2 -2
  178. package/dist/spec/index.js +1 -1
  179. package/dist/sql/index.d.ts +4 -4
  180. package/dist/sql/index.js +3 -3
  181. package/dist/{sql-CoBySj2F.js → sql-DHp0L7zK.js} +680 -333
  182. package/dist/ssr/index.d.ts +1 -1
  183. package/dist/svelte/index.d.ts +5 -5
  184. package/dist/sveltekit/index.js +2 -2
  185. package/dist/tanstack-start/index.js +2 -2
  186. package/dist/{tenant-Ded341Qz.d.ts → tenant-FfgNhd5x.d.ts} +1 -1
  187. package/dist/testing/index.d.ts +13 -4
  188. package/dist/testing/index.js +17 -15
  189. package/dist/{timeline-DvXtXq5q.d.ts → timeline-DqEoD8bb.d.ts} +1 -1
  190. package/dist/{timeline--VU3A1e4.js → timeline-Dz3hO2I6.js} +1 -1
  191. package/dist/{topic-XDdKzlrn.d.ts → topic-BaUElNw2.d.ts} +1 -1
  192. package/dist/{types-BFwB-E1j.d.ts → types-CMN0h_Ix.d.ts} +2 -2
  193. package/dist/vue/index.d.ts +5 -5
  194. package/dist/{watch-topic-DpN_GEoS.d.ts → watch-topic-BabDTZ-L.d.ts} +1 -1
  195. package/dist/workflow-sdk/world/index.js +2 -2
  196. package/dist/{workflow-sdk-CaEw822d.js → workflow-sdk-DJJkP0dT.js} +47 -8
  197. package/dist/yjs/index.d.ts +1 -1
  198. package/package.json +1 -1
  199. package/schemas/config-v1.json +10 -1
  200. package/schemas/doctor-report-v1.json +2 -0
  201. package/skills/better-supabase/references/ui-recipes.md +524 -295
  202. package/skills/better-supabase-api/references/powersync.md +16 -0
  203. package/skills/better-supabase-auth/SKILL.md +11 -1
  204. package/dist/cli/add-CwhrRJz5.js +0 -1
  205. package/dist/cli/env-uqfUbUzk.js +0 -1
  206. package/dist/cli/powersync-CbYxLsjv.js +0 -1
  207. package/dist/cli/seed-BOun22-k.js +0 -1
  208. package/dist/sign-in-CfwJAJJL.d.ts +0 -24
@@ -7,9 +7,9 @@ import { Ct as Events, W as InvitationEventData, Z as OrganizationEventData, o a
7
7
  import { r as BlockTemporalOptions } from "../../block-helpers-D5emQ2O6.js";
8
8
  import { a as dbTransport, i as RpcClient, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
9
9
  import { a as BlockTransportMiddleware, d as extendBlock, f as withBlockHooks, n as BlockHooks, p as wrapTransport } from "../../block-hooks-B8itxzEE.js";
10
- import { N as PlatformRolesOption } from "../../authorization-C7nuWMuB.js";
10
+ import { N as PlatformRolesOption } from "../../authorization-DfEkyFt_.js";
11
11
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
12
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
12
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
13
13
  //#region src/sql/modules/invitations-tables.d.ts
14
14
  declare const INVITATION_ERRORS: {
15
15
  readonly INVITATION_FORBIDDEN: "42501";
@@ -46,12 +46,17 @@ interface CreateOrganizationOptions {
46
46
  readonly ownerId?: string;
47
47
  }
48
48
  type SlugProblem = "invalid" | "reserved" | "taken";
49
- interface InviteRequest<I extends object = Record<never, never>> {
49
+ /**
50
+ * An invitation to send. `R` is the role union, `RoleName` from the generated
51
+ * blocks file or `RoleNames<typeof config>`, so an unknown role fails to
52
+ * compile; it defaults to `string`.
53
+ */
54
+ interface InviteRequest<I extends object = Record<never, never>, R extends string = string> {
50
55
  /** `null` invites to the platform (`blocks.permissions.model: 'catalog'`). */
51
56
  readonly organizationId: string | null;
52
57
  readonly email: string;
53
58
  /** A role name, or a role id or key under the catalog model. */
54
- readonly role: string;
59
+ readonly role: R;
55
60
  /** A Postgres interval such as `'3 days'`. Defaults to `options.validFor`. */
56
61
  readonly validFor?: string;
57
62
  /** Profile fields to fill in on sign-up. */
@@ -67,7 +72,8 @@ interface InviteRequest<I extends object = Record<never, never>> {
67
72
  * `blocks.invitations.options.onAccept`.
68
73
  */
69
74
  readonly onAccept?: {
70
- readonly roles?: readonly string[];
75
+ readonly roles?: readonly R[];
76
+ /** Team ids, which the config doesn't know. */
71
77
  readonly teams?: readonly string[];
72
78
  };
73
79
  }
@@ -169,7 +175,7 @@ interface OrganizationInvitationRow {
169
175
  readonly role: string;
170
176
  readonly expiresAt?: Temporal.Instant;
171
177
  }
172
- interface OrganizationsOptions<S extends StandardSchemaV1 | undefined = undefined, SI extends StandardSchemaV1 | undefined = undefined> extends BlockTemporalOptions {
178
+ interface OrganizationsOptions<S extends StandardSchemaV1 | undefined = undefined, SI extends StandardSchemaV1 | undefined = undefined, R extends string = string> extends BlockTemporalOptions {
173
179
  /**
174
180
  * A Standard Schema for the organization's extra columns
175
181
  * (`options.attributes` and `options.extraColumns`), keyed by database name.
@@ -187,7 +193,7 @@ interface OrganizationsOptions<S extends StandardSchemaV1 | undefined = undefine
187
193
  * `withBlockHooks` hooks around the methods, such as a seat limit on
188
194
  * `invite`.
189
195
  */
190
- readonly hooks?: NoInfer<BlockHooks<Organizations<FieldsOf<S>, FieldsOf<SI>>>>;
196
+ readonly hooks?: NoInfer<BlockHooks<Organizations<FieldsOf<S>, FieldsOf<SI>, R>>>;
191
197
  /** `sqlTransport(postgres.asUser(claims))` or `rpcTransport(supabase)`. */
192
198
  readonly transport: BlockTransport;
193
199
  /**
@@ -211,7 +217,7 @@ interface OrganizationsOptions<S extends StandardSchemaV1 | undefined = undefine
211
217
  * Runs before an invitation is created, after the database checks the caller
212
218
  * may invite. Return `false` to refuse (seat limits, plans).
213
219
  */
214
- readonly canInvite?: (request: InviteRequest<FieldsOf<SI>>) => boolean | Promise<boolean>;
220
+ readonly canInvite?: (request: InviteRequest<FieldsOf<SI>, R>) => boolean | Promise<boolean>;
215
221
  /**
216
222
  * Runs after an invitation is created or resent, to send the email. When it
217
223
  * throws, the call returns an error and the invitation stays open: call
@@ -234,9 +240,9 @@ type InvitationErrorHint = InvitationError;
234
240
  * The `organizations` and `invitations` SQL modules as typed calls. Each method
235
241
  * returns an `AsyncResult`; database errors carry the module's error code
236
242
  * (`ORGANIZATION_FORBIDDEN`, `INVITATION_EXPIRED`) as `hint`. `F` is the extra
237
- * fields `options.fields` describes.
243
+ * fields `options.fields` describes, `R` the roles `invite` takes.
238
244
  */
239
- interface Organizations<F extends object = Record<never, never>, I extends object = Record<never, never>> {
245
+ interface Organizations<F extends object = Record<never, never>, I extends object = Record<never, never>, R extends string = string> {
240
246
  create(attributes: OrganizationAttributes & Partial<F>, options?: CreateOrganizationOptions): AsyncResult<{
241
247
  readonly id: string;
242
248
  }>;
@@ -269,7 +275,7 @@ interface Organizations<F extends object = Record<never, never>, I extends objec
269
275
  mine(): AsyncResult<readonly (OrganizationMembership & F)[]>;
270
276
  members(organizationId: string): AsyncResult<readonly OrganizationMember[]>;
271
277
  invitations(organizationId: string): AsyncResult<readonly OrganizationInvitationRow[]>;
272
- invite(request: InviteRequest<I>): AsyncResult<InvitationSent<I>>;
278
+ invite(request: InviteRequest<I, R>): AsyncResult<InvitationSent<I>>;
273
279
  resendInvitation(invitationId: string, validFor?: string): AsyncResult<InvitationSent<I>>;
274
280
  /**
275
281
  * A new email, role or prefill for an open invitation, with the checks
@@ -299,8 +305,12 @@ interface Organizations<F extends object = Record<never, never>, I extends objec
299
305
  declineInvitationById(invitationId: string): AsyncResult<boolean>;
300
306
  myInvitations(): AsyncResult<readonly Invitation<I>[]>;
301
307
  }
302
- /** Calls the `organizations` and `invitations` block functions. */
303
- export declare function createOrganizations<S extends StandardSchemaV1 | undefined = undefined, SI extends StandardSchemaV1 | undefined = undefined>(options: OrganizationsOptions<S, SI>): Organizations<FieldsOf<S>, FieldsOf<SI>>;
308
+ /**
309
+ * Calls the `organizations` and `invitations` block functions. Pass the role
310
+ * union as `R` to type `invite`: `createOrganizations<undefined, undefined,
311
+ * RoleName>(options)`.
312
+ */
313
+ export declare function createOrganizations<S extends StandardSchemaV1 | undefined = undefined, SI extends StandardSchemaV1 | undefined = undefined, R extends string = string>(options: OrganizationsOptions<S, SI, R>): Organizations<FieldsOf<S>, FieldsOf<SI>, R>;
304
314
  //#endregion
305
315
  //#region src/blocks/organizations/events.d.ts
306
316
  /** The events of the `organizations` block: type to data. */
@@ -447,8 +457,11 @@ export declare function createMembersController<T extends {
447
457
  readonly userId: string;
448
458
  readonly role: string;
449
459
  } = OrganizationMember>(options: MembersControllerOptions<T>): MembersController<T>;
450
- /** What `invite` takes: the organization comes from the controller. */
451
- type InvitationDraft = Omit<InviteRequest, "organizationId">;
460
+ /**
461
+ * What `invite` takes: the organization comes from the controller. `R` is the
462
+ * role union, `string` by default.
463
+ */
464
+ type InvitationDraft<R extends string = string> = Omit<InviteRequest<Record<never, never>, R>, "organizationId">;
452
465
  /** An invitation change that committed, for `onChanged`. */
453
466
  type InvitationChange = {
454
467
  readonly kind: "invited";
@@ -461,8 +474,8 @@ type InvitationChange = {
461
474
  };
462
475
  interface InvitationsControllerOptions<T extends {
463
476
  readonly id: string;
464
- } = OrganizationInvitationRow> {
465
- readonly client: Pick<Organizations, "invite" | "revokeInvitation">;
477
+ } = OrganizationInvitationRow, R extends string = string> {
478
+ readonly client: Pick<Organizations<Record<never, never>, Record<never, never>, R>, "invite" | "revokeInvitation">;
466
479
  readonly auth: AuthPort;
467
480
  /** The organization; nothing loads or sends without one. */
468
481
  readonly organizationId: string | null;
@@ -490,19 +503,19 @@ interface InvitationsSnapshot<T> {
490
503
  readonly revoking: readonly string[];
491
504
  readonly error: DbError | undefined;
492
505
  }
493
- interface InvitationsActions {
506
+ interface InvitationsActions<R extends string = string> {
494
507
  /**
495
508
  * Invites `email` with `role`, then loads the list again; a failure is also
496
509
  * kept in `error`.
497
510
  */
498
- readonly invite: (draft: InvitationDraft) => Promise<Result<InvitationSent>>;
511
+ readonly invite: (draft: InvitationDraft<R>) => Promise<Result<InvitationSent>>;
499
512
  /** Revokes an open invitation; `false` when it was not open. */
500
513
  readonly revoke: (invitationId: string) => Promise<Result<boolean>>;
501
514
  /** Forgets `sent` and `error`, such as when the dialog closes. */
502
515
  readonly clear: () => void;
503
516
  readonly refresh: () => Promise<void>;
504
517
  }
505
- type InvitationsController<T> = Controller<InvitationsSnapshot<T>, InvitationsActions>;
518
+ type InvitationsController<T, R extends string = string> = Controller<InvitationsSnapshot<T>, InvitationsActions<R>>;
506
519
  /**
507
520
  * One organization's open invitations for an invite dialog: `invite` sends one
508
521
  * and keeps its token in `sent` for the accept link, `revoke` revokes one, and
@@ -510,6 +523,6 @@ type InvitationsController<T> = Controller<InvitationsSnapshot<T>, InvitationsAc
510
523
  */
511
524
  export declare function createInvitationsController<T extends {
512
525
  readonly id: string;
513
- } = OrganizationInvitationRow>(options: InvitationsControllerOptions<T>): InvitationsController<T>;
526
+ } = OrganizationInvitationRow, R extends string = string>(options: InvitationsControllerOptions<T, R>): InvitationsController<T, R>;
514
527
  //#endregion
515
528
  export { type BlockHooks, type BlockTransport, type BlockTransportMiddleware, type CreateOrganizationOptions, type Invitation, type InvitationChange, type InvitationChanges, type InvitationDraft, type InvitationErrorHint, type InvitationPreview, type InvitationSent, type InvitationStatus, type InvitationsActions, type InvitationsController, type InvitationsControllerOptions, type InvitationsSnapshot, type InviteRequest, type MemberChange, type MembersActions, type MembersController, type MembersControllerOptions, type MembersSnapshot, type OrganizationAttributes, type OrganizationInvitationRow, type OrganizationMember, type OrganizationMembership, type OrganizationRowSource, type OrganizationSource, type Organizations, type OrganizationsActions, type OrganizationsController, type OrganizationsControllerOptions, type OrganizationsEvents, type OrganizationsOptions, type OrganizationsSnapshot, type PlatformRolesOption, type RpcClient, type SlugProblem, type SwitchResult, dbTransport, extendBlock, rpcTransport, sqlTransport, withBlockHooks, wrapTransport };
@@ -113,7 +113,11 @@ const splitAttributes = (attributes) => {
113
113
  extra
114
114
  };
115
115
  };
116
- /** Calls the `organizations` and `invitations` block functions. */
116
+ /**
117
+ * Calls the `organizations` and `invitations` block functions. Pass the role
118
+ * union as `R` to type `invite`: `createOrganizations<undefined, undefined,
119
+ * RoleName>(options)`.
120
+ */
117
121
  function createOrganizations(options) {
118
122
  const client = organizationsClient(options);
119
123
  return withBlockHooks(client, options.hooks, {
@@ -4,8 +4,8 @@ import { n as BlockOptions, o as BlockTenant } from "../../block-helpers-D5emQ2O
4
4
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
5
5
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
6
6
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
7
- import { B as PermissionFlags, H as can, U as permissionFlags, V as PermissionSet, W as permissionMatches } from "../../index-BM6NmKSc.js";
8
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
7
+ import { B as PermissionFlags, H as can, U as permissionFlags, V as PermissionSet, W as permissionMatches } from "../../index-uIU65iEn.js";
8
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
9
9
  //#region src/blocks/permissions/permissions.d.ts
10
10
  interface PermissionsOptions extends BlockOptions {
11
11
  /** `withBlockHooks` hooks around the client's methods. */
@@ -17,6 +17,23 @@ interface PermissionsOptions extends BlockOptions {
17
17
  interface AccessCallOptions {
18
18
  readonly tenant?: BlockTenant;
19
19
  }
20
+ /** A per-tenant grant (`true`) or deny (`false`) of one key to a role. */
21
+ interface PermissionOverride {
22
+ readonly permission: string;
23
+ readonly granted: boolean;
24
+ }
25
+ /** A catalog role and its keys in one tenant, as `roles()` lists it. */
26
+ interface CatalogRole {
27
+ readonly id: string;
28
+ readonly key: string;
29
+ /** How many members of the tenant hold the role. */
30
+ readonly members: number;
31
+ /** The keys the catalog grants the role everywhere. */
32
+ readonly defaultPermissions: readonly string[];
33
+ /** The keys the role holds in this tenant, after its overrides. */
34
+ readonly permissions: readonly string[];
35
+ readonly overrides: readonly PermissionOverride[];
36
+ }
20
37
  /**
21
38
  * The caller's permissions in the block's tenant, through the access contract:
22
39
  * the roles or catalog model, the app's own functions, or the
@@ -37,6 +54,18 @@ interface Permissions<K extends string = string> {
37
54
  * "customers.write" }` resolves to `{ canEdit: true }`.
38
55
  */
39
56
  flags<const M extends Readonly<Record<string, K>>>(flags: M, options?: AccessCallOptions): AsyncResult<PermissionFlags<M>>;
57
+ /**
58
+ * The catalog's tenant roles with their keys in the tenant. Catalog model
59
+ * only; needs `members.read`.
60
+ */
61
+ roles(options?: AccessCallOptions): AsyncResult<readonly CatalogRole[]>;
62
+ /**
63
+ * Grants (`true`) or denies (`false`) `permission` to `role` (its key or id)
64
+ * in the tenant; `null` restores the role's default. Catalog model only;
65
+ * needs `roles.manage`, a role the caller could assign and a key the caller
66
+ * holds. Resolves to the role as it stands after the change.
67
+ */
68
+ setOverride(role: string, permission: K, granted: boolean | null, options?: AccessCallOptions): AsyncResult<CatalogRole>;
40
69
  }
41
70
  /**
42
71
  * The `access` module's `my_permissions` as typed calls. It acts in the block's
@@ -89,4 +118,4 @@ type PermissionsController = Controller<PermissionsSnapshot, PermissionsActions>
89
118
  */
90
119
  export declare function createPermissionsController<K extends string>(options: PermissionsControllerOptions<K>): PermissionsController;
91
120
  //#endregion
92
- export { type AccessCallOptions, type BlockTransport, type PermissionFlags, type PermissionSet, type PermissionSource, type Permissions, type PermissionsActions, type PermissionsController, type PermissionsControllerOptions, type PermissionsOptions, type PermissionsSnapshot, can, dbTransport, permissionFlags, permissionMatches, rpcTransport, sqlTransport };
121
+ export { type AccessCallOptions, type BlockTransport, type CatalogRole, type PermissionFlags, type PermissionOverride, type PermissionSet, type PermissionSource, type Permissions, type PermissionsActions, type PermissionsController, type PermissionsControllerOptions, type PermissionsOptions, type PermissionsSnapshot, can, dbTransport, permissionFlags, permissionMatches, rpcTransport, sqlTransport };
@@ -2,13 +2,27 @@ import { a as ok, t as AsyncResult } from "../../result-ntFBW2p2.js";
2
2
  import { t as permissionsSqlOptions } from "../../options-DM1qaMMQ.js";
3
3
  import { t as currentTenant } from "../../tenant-source-bqWpSr86.js";
4
4
  import { n as whileSignedIn, t as defineController } from "../../controller-BEliOBOv.js";
5
- import { U as rpcTransport, V as dbTransport, W as sqlTransport, o as blockCall } from "../../block-helpers-B0f0ZVb5.js";
5
+ import { A as recordsOf, I as stringsOf, L as textOf, O as recordOf, U as rpcTransport, V as dbTransport, W as sqlTransport, o as blockCall } from "../../block-helpers-B0f0ZVb5.js";
6
6
  import { r as withBlockHooks } from "../../block-hooks-DKtz0HRh.js";
7
7
  import { n as permissionFlags, r as permissionMatches, t as can } from "../../permissions-controller-BMsqIE5T.js";
8
8
  import { n as defineBlock } from "../../define-block-BGqOO8B3.js";
9
9
  import { t as requireOrganization } from "../../block-tenant-DHp7subc.js";
10
10
  //#region src/blocks/permissions/permissions.ts
11
11
  const keysOf = (value) => Array.isArray(value) ? value.filter((key) => typeof key === "string") : [];
12
+ function catalogRoleOf(value) {
13
+ const row = recordOf(value, "list_roles");
14
+ return {
15
+ id: textOf(row["id"]),
16
+ key: textOf(row["key"]),
17
+ members: Number(row["members"] ?? 0),
18
+ defaultPermissions: stringsOf(row["default_permissions"]),
19
+ permissions: stringsOf(row["permissions"]),
20
+ overrides: recordsOf(row["overrides"], "list_roles").map((entry) => ({
21
+ permission: textOf(entry["permission"]),
22
+ granted: entry["granted"] === true
23
+ }))
24
+ };
25
+ }
12
26
  /**
13
27
  * The `access` module's `my_permissions` as typed calls. It acts in the block's
14
28
  * `tenant`; `createBlocks` and `createBlockClient` pass the request's.
@@ -28,7 +42,14 @@ function createPermissions(options) {
28
42
  return withBlockHooks({
29
43
  permissions: (keys, perCall) => load(keys, perCall),
30
44
  can: (key, perCall) => load([key], perCall).map((set) => can(set, key)),
31
- flags: (flags, perCall) => load(Object.values(flags), perCall).map((set) => permissionFlags(set, flags))
45
+ flags: (flags, perCall) => load(Object.values(flags), perCall).map((set) => permissionFlags(set, flags)),
46
+ roles: (perCall) => requireOrganization(perCall?.tenant ?? options.tenant).andThen((tenant) => call("list_roles", { tenant }, (value) => recordsOf(value, "list_roles").map(catalogRoleOf))),
47
+ setOverride: (role, permission, granted, perCall) => requireOrganization(perCall?.tenant ?? options.tenant).andThen((tenant) => call("set_permission_override", {
48
+ tenant,
49
+ role,
50
+ permission,
51
+ granted
52
+ }, catalogRoleOf))
32
53
  }, options.hooks, {
33
54
  block: "permissions",
34
55
  ...options.logger ? { logger: options.logger } : {}
@@ -2,14 +2,15 @@
2
2
  import { T as ErrorMapper, t as AsyncResult } from "../../result-DZeA5KS6.js";
3
3
  import { t as StandardSchemaV1 } from "../../standard-DBV730sF.js";
4
4
  import { i as RowFields, r as FieldsOf } from "../../block-fields-BE7pInWZ.js";
5
- import { Ct as Events, Q as PushDeviceEventData } from "../../events-B2qbZps6.js";
5
+ import { Ft as RequestContext } from "../../types-CPl9uJ0G.js";
6
+ import { Ct as Events, Q as PushDeviceEventData, o as EventHub } from "../../events-B2qbZps6.js";
6
7
  import { n as Logger } from "../../logger-DWVYUmwi.js";
7
8
  import { r as BlockTemporalOptions } from "../../block-helpers-D5emQ2O6.js";
8
9
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
9
10
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
10
11
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
11
12
  import { n as NotificationMessage, t as NotificationChannel } from "../../channel-JcMd5lNP.js";
12
- import { t as ExpoNotificationsLike } from "../../push-token-BXsrJ7W9.js";
13
+ import { t as ExpoNotificationsLike } from "../../push-token-B4vcIU4s.js";
13
14
  //#region src/blocks/push/push.d.ts
14
15
  type PushPlatform = "ios" | "android" | "web";
15
16
  type PushProvider = "expo" | "fcm" | "apns" | "webpush";
@@ -60,6 +61,13 @@ interface PushDevicesOptions<S extends StandardSchemaV1 | undefined = undefined>
60
61
  readonly hooks?: NoInfer<BlockHooks<PushDevices<FieldsOf<S>>>>;
61
62
  /** Receives the errors `after` hooks throw. Default: `console`. */
62
63
  readonly logger?: Logger;
64
+ /**
65
+ * `betterSupabase.events`, for the `notification.delivered` and
66
+ * `notification.bounced` events `checkReceipts` records.
67
+ */
68
+ readonly events?: EventHub;
69
+ readonly actorId?: string;
70
+ readonly context?: RequestContext;
63
71
  }
64
72
  /** The `push` SQL module as typed calls. */
65
73
  interface PushDevices<F extends object = Record<never, never>> {
@@ -1,11 +1,13 @@
1
1
  import { t as temporal } from "../../temporal-required-DcLhnDhQ.js";
2
2
  import { t as pushSqlOptions } from "../../options-BR9xTHZW.js";
3
3
  import { n as event, t as defineEvents } from "../../event-map-CtPFhcOp.js";
4
+ import { r as blockEmitter } from "../../block-events-IWAyafO3.js";
4
5
  import { t as expoPushToken } from "../../push-token-D6REHMMw.js";
5
- import { A as recordsOf, L as textOf, M as run, U as rpcTransport, V as dbTransport, W as sqlTransport, k as recordOrEmpty, n as applyTemporal, o as blockCall } from "../../block-helpers-B0f0ZVb5.js";
6
+ import { A as recordsOf, L as textOf, M as run, U as rpcTransport, V as dbTransport, W as sqlTransport, b as nullableText, k as recordOrEmpty, n as applyTemporal, o as blockCall } from "../../block-helpers-B0f0ZVb5.js";
6
7
  import { r as withBlockHooks } from "../../block-hooks-DKtz0HRh.js";
7
8
  import { a as readAllFields, l as writeFields, n as blockFields, s as rowFields } from "../../block-fields-BjXgX_5c.js";
8
9
  import { n as defineBlock } from "../../define-block-BGqOO8B3.js";
10
+ import { n as emitDeliveryEvent, r as recordedDeliveryEventOf } from "../../delivery-events-DbL8IHIY.js";
9
11
  //#region src/blocks/push/push.ts
10
12
  const PLATFORMS = /* @__PURE__ */ new Set([
11
13
  "ios",
@@ -55,9 +57,20 @@ function uncheckedOf(value) {
55
57
  }));
56
58
  }
57
59
  const countOf = (value) => typeof value === "number" ? value : Number(value ?? 0);
60
+ function completedOf(value) {
61
+ const events = recordOrEmpty(value)["events"];
62
+ return { events: (Array.isArray(events) ? events : []).flatMap((event) => {
63
+ const recorded = recordedDeliveryEventOf(event);
64
+ return recorded === null ? [] : [{
65
+ recorded,
66
+ providerEventId: nullableText(recordOrEmpty(event)["provider_event_id"])
67
+ }];
68
+ }) };
69
+ }
58
70
  function createPush(options) {
59
71
  applyTemporal(options);
60
72
  const call = blockCall(options.transport, options.schema, options.mappers);
73
+ const emit = blockEmitter(options);
61
74
  const fields = blockFields(options.fields, "push device fields");
62
75
  const client = {
63
76
  register: (device) => writeFields(fields, device.fields, (checked) => call("register_push_device", {
@@ -87,12 +100,15 @@ function createPush(options) {
87
100
  older_than: (checks.olderThan ?? temporal().Duration.from({ minutes: 15 })).toString()
88
101
  }, uncheckedOf).orThrow();
89
102
  const result = await push.checkReceipts(tickets);
90
- if (result.receipts.length > 0) await call("complete_push_receipts", { receipts: result.receipts.map((receipt) => ({
91
- id: receipt.id,
92
- status: receipt.status,
93
- error: receipt.error ?? null,
94
- message: receipt.message ?? null
95
- })) }, countOf).orThrow();
103
+ if (result.receipts.length > 0) {
104
+ const completed = await call("complete_push_receipts", { receipts: result.receipts.map((receipt) => ({
105
+ id: receipt.id,
106
+ status: receipt.status,
107
+ error: receipt.error ?? null,
108
+ message: receipt.message ?? null
109
+ })) }, completedOf).orThrow();
110
+ for (const { recorded, providerEventId } of completed.events) emitDeliveryEvent(emit, recorded, "expo", providerEventId);
111
+ }
96
112
  return result;
97
113
  })
98
114
  };
@@ -7,9 +7,9 @@ import { a as BlockTenantOptions, r as BlockTemporalOptions } from "../../block-
7
7
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
8
8
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
9
9
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
10
- import { p as SubscriptionStatus } from "../../topic-XDdKzlrn.js";
11
- import { n as TopicPort } from "../../watch-topic-DpN_GEoS.js";
12
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
10
+ import { p as SubscriptionStatus } from "../../topic-BaUElNw2.js";
11
+ import { n as TopicPort } from "../../watch-topic-BabDTZ-L.js";
12
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
13
13
  //#region src/blocks/reactions/reactions.d.ts
14
14
  interface ReactionsOptions extends BlockTemporalOptions, BlockTenantOptions {
15
15
  readonly transport: BlockTransport;
@@ -7,7 +7,7 @@ import { t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
7
7
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
8
8
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
9
9
  import { p as ListQueryInput } from "../../list-query-BcU8NnNL.js";
10
- import { n as Controller } from "../../controller-CtwAsnVV.js";
10
+ import { n as Controller } from "../../controller-Br9dGKGe.js";
11
11
  import { t as RankNeighbors } from "../../rank-result-Bwe7igy-.js";
12
12
  //#region src/blocks/saved-views/saved-views.d.ts
13
13
  export declare const SAVED_VIEW_KINDS: readonly ["table", "board", "calendar", "timeline", "gantt"];
@@ -6,8 +6,8 @@ import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTrans
6
6
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
7
7
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
8
8
  import { i as EventSink } from "../../cloud-event-0pQ9vFNS.js";
9
- import { i as KeyboardPort } from "../../ports-6LBgr1Aa.js";
10
- import { n as Controller } from "../../controller-CtwAsnVV.js";
9
+ import { i as KeyboardPort } from "../../ports-DOrPTJzl.js";
10
+ import { n as Controller } from "../../controller-Br9dGKGe.js";
11
11
  //#region src/blocks/search/search.d.ts
12
12
  interface SearchOptions extends Pick<BlockOptions, "transport" | "service" | "schema" | "mappers"> {
13
13
  /** `withBlockHooks` hooks around the methods. */
@@ -1,7 +1,7 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { b as DbError, f as Result } from "../../result-DZeA5KS6.js";
3
3
  import { r as Block } from "../../define-block-DWVZSZv1.js";
4
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
4
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
5
5
  import { t as AuthReply } from "../../auth-reply-Dj124sbX.js";
6
6
  //#region src/blocks/sessions/client.d.ts
7
7
  /** An OAuth client as the Auth OAuth server describes it. */
@@ -5,7 +5,7 @@ import { n as BlockOptions } from "../../block-helpers-D5emQ2O6.js";
5
5
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
6
6
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
7
7
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
8
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
8
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
9
9
  import { StandardSchemaV1 } from "@standard-schema/spec";
10
10
  //#region src/blocks/settings/settings.d.ts
11
11
  /**
@@ -2,7 +2,7 @@ import { b as DbError } from "../../result-DZeA5KS6.js";
2
2
  import { $ as RecordRef } from "../../types-CPl9uJ0G.js";
3
3
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
4
4
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
5
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
5
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
6
6
  import { t as subjectKey } from "../../block-subjects-C1_9DkSA.js";
7
7
  import { c as Subjects, d as MY_WORK_KINDS, f as MyWorkKind, l as SubjectsOptions, n as MyWorkItem, o as ResolvedSubject, r as MyWorkOptions, s as SUBJECT_TITLES_LIMIT, t as MY_WORK_LIMIT, u as createSubjects } from "../../subjects-CiBNKy2y.js";
8
8
  //#region src/blocks/subjects/manifest.d.ts
@@ -7,7 +7,7 @@ import { n as Logger } from "../../logger-DWVYUmwi.js";
7
7
  import { n as BlockOptions } from "../../block-helpers-D5emQ2O6.js";
8
8
  import { n as BlockHooks } from "../../block-hooks-B8itxzEE.js";
9
9
  import { Sn as EntitySchema, c as BlockOf, ln as RecordBindingWrite, rn as RecordBinding } from "../../define-block-DWVZSZv1.js";
10
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
10
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
11
11
  import { t as RankNeighbors } from "../../rank-result-Bwe7igy-.js";
12
12
  //#region src/blocks/tags/tags.d.ts
13
13
  interface TagsOptions<S extends StandardSchemaV1 | undefined = undefined> extends BlockOptions {
@@ -2,7 +2,7 @@ import { n as dbError } from "../../errors-BVFgt8BZ.js";
2
2
  import { n as isRecord } from "../../guards-6F2bCtQR.js";
3
3
  import { t as temporal } from "../../temporal-required-DcLhnDhQ.js";
4
4
  import { a as ok, r as err, t as AsyncResult } from "../../result-ntFBW2p2.js";
5
- import { t as tasksSqlOptions } from "../../options-COo7_3MX.js";
5
+ import { t as tasksSqlOptions } from "../../options-DSCW40_5.js";
6
6
  import { a as stripTypePrefix } from "../../cloud-event-XsM53POL.js";
7
7
  import { n as event, t as defineEvents } from "../../event-map-CtPFhcOp.js";
8
8
  import { A as recordsOf, C as optionalInstant, L as textOf, O as recordOf, U as rpcTransport, V as dbTransport, W as sqlTransport, d as enumOrThrow, j as requiredInstant, n as applyTemporal, o as blockCall, w as optionalText } from "../../block-helpers-B0f0ZVb5.js";
@@ -19,11 +19,17 @@ interface TeamsOptions<S extends StandardSchemaV1 | undefined = undefined> exten
19
19
  /** Receives the errors `after` hooks throw. Default: `console`. */
20
20
  readonly logger?: Logger;
21
21
  }
22
+ type TeamStatus = "active" | "archived";
22
23
  /** A team. `F` types the extra columns the `fields` schema describes. */
23
24
  interface Team<F extends object = Record<never, never>> {
24
25
  readonly id: string;
25
26
  readonly name: string;
26
27
  readonly slug: string;
28
+ readonly description: string | null;
29
+ /** `archived` teams stay in `list` until `restore` or `delete`. */
30
+ readonly status: TeamStatus;
31
+ /** The members' user ids, oldest first. Empty on `create` and `update`. */
32
+ readonly memberIds: readonly string[];
27
33
  /** The extra columns, keyed by database name. */
28
34
  readonly fields: ExtraFields<F>;
29
35
  }
@@ -80,4 +86,4 @@ export declare const teamsEvents: Events<TeamsEvents>;
80
86
  /** The `teams` block's manifest (ADR 0029). */
81
87
  export declare const teamsBlock: BlockOf<"teams", typeof createTeams, TeamsEvents>;
82
88
  //#endregion
83
- export type { CreateTeamOptions, Team, Teams, TeamsEvents, TeamsOptions, UpdateTeamOptions };
89
+ export type { CreateTeamOptions, Team, TeamStatus, Teams, TeamsEvents, TeamsOptions, UpdateTeamOptions };
@@ -1,17 +1,21 @@
1
1
  import { n as isRecord } from "../../guards-6F2bCtQR.js";
2
2
  import { t as teamsSqlOptions } from "../../options-jsOCvLUz.js";
3
3
  import { n as event, t as defineEvents } from "../../event-map-CtPFhcOp.js";
4
- import { A as recordsOf, L as textOf, O as recordOf, n as applyTemporal, o as blockCall, w as optionalText } from "../../block-helpers-B0f0ZVb5.js";
4
+ import { A as recordsOf, I as stringsOf, L as textOf, O as recordOf, b as nullableText, n as applyTemporal, o as blockCall, w as optionalText, x as oneOf } from "../../block-helpers-B0f0ZVb5.js";
5
5
  import { r as withBlockHooks } from "../../block-hooks-DKtz0HRh.js";
6
6
  import { n as blockFields } from "../../block-fields-BjXgX_5c.js";
7
7
  import { n as defineBlock } from "../../define-block-BGqOO8B3.js";
8
8
  //#region src/blocks/teams/teams.ts
9
+ const TEAM_STATUSES = ["active", "archived"];
9
10
  function teamOf(value) {
10
11
  const row = recordOf(value, "team");
11
12
  return {
12
13
  id: textOf(row["id"]),
13
14
  name: optionalText(row["name"]) ?? "",
14
15
  slug: optionalText(row["slug"]) ?? "",
16
+ description: nullableText(row["description"]),
17
+ status: oneOf(row["status"], TEAM_STATUSES, "active"),
18
+ memberIds: stringsOf(row["member_ids"]),
15
19
  fields: isRecord(row["fields"]) ? row["fields"] : {}
16
20
  };
17
21
  }
@@ -29,7 +33,8 @@ function createTeams(options) {
29
33
  fields: checked
30
34
  }, (value) => ({
31
35
  ...teamOf(value),
32
- name
36
+ name,
37
+ description: description ?? null
33
38
  })).andThen(fields.row)),
34
39
  update: (id, name, description, extra, settings) => fields.args(extra).andThen((checked) => call("update_team", {
35
40
  team: id,
@@ -40,11 +45,7 @@ function createTeams(options) {
40
45
  ...settings.description === void 0 ? {} : { description: settings.description }
41
46
  } },
42
47
  fields: checked
43
- }, (value) => ({
44
- ...teamOf(value),
45
- name,
46
- slug: optionalText(recordOf(value, "team")["slug"]) ?? ""
47
- })).andThen(fields.row)),
48
+ }, teamOf).andThen(fields.row)),
48
49
  archive: (id) => call("archive_team", { team: id }, (value) => value === true),
49
50
  restore: (id) => call("restore_team", { team: id }, (value) => value === true),
50
51
  delete: (id) => call("delete_team", { team: id }, (value) => value === true),
@@ -1,6 +1,6 @@
1
1
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
2
2
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
3
- import { n as Controller } from "../../controller-CtwAsnVV.js";
3
+ import { n as Controller } from "../../controller-Br9dGKGe.js";
4
4
  import { a as UndoToken, c as undoToken, i as UndoOptions, n as Undo, o as createUndo, r as UndoCall, s as isUndoToken, t as UNDO_FUNCTIONS } from "../../undo-0HkWXASn.js";
5
5
  //#region src/blocks/undo/client.d.ts
6
6
  interface UndoEntry {
@@ -3,7 +3,7 @@ import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTrans
3
3
  import { n as StripeSource, t as StripeClient } from "../../stripe-X22LjuH-.js";
4
4
  import { _ as reportUsageToStripe, a as Usage, c as UsageEntry, d as UsageMeterInfo, f as UsageOptions, g as createUsage, h as UsageStatus, i as ReportUsageResult, l as UsageHistoryEntry, m as UsageRecorded, n as RecordUsageOptions, o as UsageBatchRecorded, p as UsagePeriod, r as ReportUsageOptions, s as UsageBreakdownEntry, t as PurgeUsageOptions, u as UsageHistoryOptions } from "../../usage-BkWAPkg2.js";
5
5
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
6
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
6
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
7
7
  //#region src/blocks/usage/manifest.d.ts
8
8
  /** The `usage` block's manifest (ADR 0029). */
9
9
  export declare const usageBlock: BlockOf<"usage", typeof createUsage>;
@@ -5,9 +5,9 @@ import { Ct as Events, gt as WorkflowEventData } from "../../events-B2qbZps6.js"
5
5
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
6
6
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
7
7
  import { g as Workflows, n as WorkflowRun } from "../../workflows-xL6t0TXx.js";
8
- import { p as SubscriptionStatus } from "../../topic-XDdKzlrn.js";
9
- import { n as TopicPort } from "../../watch-topic-DpN_GEoS.js";
10
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
8
+ import { p as SubscriptionStatus } from "../../topic-BaUElNw2.js";
9
+ import { n as TopicPort } from "../../watch-topic-BabDTZ-L.js";
10
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
11
11
  import { A as WorkflowVersionOwner, B as WorkflowGraphNode, C as WorkflowGrantPrincipal, D as WorkflowTrigger, E as WorkflowStepInfo, F as WorkflowFilterCondition, G as durationMs, H as WorkflowNodeKind, I as WorkflowFilterField, J as matchesFilter, K as evaluateCondition, L as WorkflowGraph, M as GraphScope, N as WorkflowCondition, O as WorkflowTriggerKind, P as WorkflowConditionOperator, R as WorkflowGraphDiff, S as WorkflowGrantAction, T as WorkflowNodeRunStatus, U as approved, V as WorkflowNodeCondition, W as diffGraphs, X as validateGraph, Y as topologicalOrder, _ as WorkflowCredential, a as CredentialInput, b as WorkflowDefinitionScope, c as GraphCompiler, d as RunInput, f as TestRunInput, g as WorkflowBuilderHooks, h as WorkflowAlert, i as BuilderStarter, j as WorkflowVersionStatus, k as WorkflowVersion, l as NodeRunRecord, m as VersionSaveOptions, n as BuilderOptions, o as DefinitionInput, p as TriggerInput, q as filterConditionOf, r as BuilderStartCall, s as GrantInput, t as AlertInput, u as PublishOptions, v as WorkflowDefinition, w as WorkflowNodeRun, x as WorkflowEditor, y as WorkflowDefinitionGrant, z as WorkflowGraphEdge } from "../../types-nspa5I-a.js";
12
12
  import { a as GraphSubject, c as graphRunFields, i as GraphStepCall, l as startNodeOf, n as GraphRunFields, o as approvalToken, r as GraphRuntime, s as executeGraph, t as GraphApprovalCall } from "../../executor-BlS0kCrN.js";
13
13
  //#region src/blocks/workflow-editor/workflow-editor.d.ts
@@ -3,9 +3,9 @@ import { Ct as Events, _t as WorkflowRunEventData } from "../../events-B2qbZps6.
3
3
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-9EUA3q_I.js";
4
4
  import { c as BlockOf } from "../../define-block-DWVZSZv1.js";
5
5
  import { _ as WorkflowsHooks, a as WorkflowRunStatus, c as WorkflowScheduleInput, d as WorkflowStartTicket, f as WorkflowStarter, g as Workflows, h as WorkflowTickResult, i as WorkflowRunRecord, l as WorkflowStartCall, m as WorkflowTickOptions, n as WorkflowRun, o as WorkflowRunsQuery, s as WorkflowSchedule, u as WorkflowStartRequest, v as WorkflowsOptions, y as createWorkflows } from "../../workflows-xL6t0TXx.js";
6
- import { p as SubscriptionStatus } from "../../topic-XDdKzlrn.js";
7
- import { n as TopicPort } from "../../watch-topic-DpN_GEoS.js";
8
- import { n as Controller, t as AuthPort } from "../../controller-CtwAsnVV.js";
6
+ import { p as SubscriptionStatus } from "../../topic-BaUElNw2.js";
7
+ import { n as TopicPort } from "../../watch-topic-BabDTZ-L.js";
8
+ import { n as Controller, t as AuthPort } from "../../controller-Br9dGKGe.js";
9
9
  //#region src/blocks/workflows/client.d.ts
10
10
  interface WorkflowRunsControllerOptions {
11
11
  readonly client: {
@@ -1,8 +1,8 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
- import { d as providerLabel, i as providerOwnsMemberships, r as layoutFor, t as MEMBERSHIP_CLAIM_MODULES } from "./providers-Cjf5iOp5.js";
2
+ import { d as providerLabel, i as providerOwnsMemberships, r as layoutFor, t as MEMBERSHIP_CLAIM_MODULES } from "./providers-DtI90lSw.js";
3
3
  import { r as applyPlan } from "./files-CX71yBm8.js";
4
4
  import { n as addBlocksToJson, s as keyText, t as addBlocksToConfig } from "./config-edit-CrWfk8s3.js";
5
- import { a as write, i as unlistedModuleFiles, r as nextStep } from "./sync-pq6gmlhG.js";
5
+ import { a as write, i as unlistedModuleFiles, r as nextStep } from "./sync-BnORI43S.js";
6
6
  import { basename, dirname } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { SQL_MODULES, resolveBlocks } from "better-supabase/sql";