@riffdb/better-auth 0.0.0-stage → 0.2.1

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 (226) hide show
  1. package/DESIGN.md +273 -0
  2. package/LICENSE-APACHE +201 -0
  3. package/LICENSE-MIT +27 -0
  4. package/README.md +323 -2
  5. package/dist/adapter.d.ts +34 -0
  6. package/dist/adapter.d.ts.map +1 -0
  7. package/dist/adapter.js +1600 -0
  8. package/dist/adapter.js.map +1 -0
  9. package/dist/generated/client.d.ts +2166 -0
  10. package/dist/generated/client.d.ts.map +1 -0
  11. package/dist/generated/client.js +2454 -0
  12. package/dist/generated/client.js.map +1 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +7 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/plugin-dispatch.d.ts +37 -0
  18. package/dist/plugin-dispatch.d.ts.map +1 -0
  19. package/dist/plugin-dispatch.js +293 -0
  20. package/dist/plugin-dispatch.js.map +1 -0
  21. package/dist/profile-contract.d.ts +63 -0
  22. package/dist/profile-contract.d.ts.map +1 -0
  23. package/dist/profile-contract.js +543 -0
  24. package/dist/profile-contract.js.map +1 -0
  25. package/dist/profile-plan.d.ts +69 -0
  26. package/dist/profile-plan.d.ts.map +1 -0
  27. package/dist/profile-plan.js +180 -0
  28. package/dist/profile-plan.js.map +1 -0
  29. package/dist/profile.d.ts +48 -0
  30. package/dist/profile.d.ts.map +1 -0
  31. package/dist/profile.js +132 -0
  32. package/dist/profile.js.map +1 -0
  33. package/dist/profiles/custom-fields/profile.d.ts +3 -0
  34. package/dist/profiles/custom-fields/profile.d.ts.map +1 -0
  35. package/dist/profiles/custom-fields/profile.js +475 -0
  36. package/dist/profiles/custom-fields/profile.js.map +1 -0
  37. package/dist/profiles/custom-fields/src/generated/client.d.ts +2710 -0
  38. package/dist/profiles/custom-fields/src/generated/client.d.ts.map +1 -0
  39. package/dist/profiles/custom-fields/src/generated/client.js +2663 -0
  40. package/dist/profiles/custom-fields/src/generated/client.js.map +1 -0
  41. package/dist/profiles/runtime/profile.d.ts +3 -0
  42. package/dist/profiles/runtime/profile.d.ts.map +1 -0
  43. package/dist/profiles/runtime/profile.js +1065 -0
  44. package/dist/profiles/runtime/profile.js.map +1 -0
  45. package/dist/profiles/runtime/src/generated/client.d.ts +4274 -0
  46. package/dist/profiles/runtime/src/generated/client.d.ts.map +1 -0
  47. package/dist/profiles/runtime/src/generated/client.js +4607 -0
  48. package/dist/profiles/runtime/src/generated/client.js.map +1 -0
  49. package/dist/runtime-materialize.d.ts +10 -0
  50. package/dist/runtime-materialize.d.ts.map +1 -0
  51. package/dist/runtime-materialize.js +344 -0
  52. package/dist/runtime-materialize.js.map +1 -0
  53. package/dist/runtime-profile.d.ts +34 -0
  54. package/dist/runtime-profile.d.ts.map +1 -0
  55. package/dist/runtime-profile.js +203 -0
  56. package/dist/runtime-profile.js.map +1 -0
  57. package/dist/testing.d.ts +11 -0
  58. package/dist/testing.d.ts.map +1 -0
  59. package/dist/testing.js +12 -0
  60. package/dist/testing.js.map +1 -0
  61. package/generated/go/client.go +2250 -0
  62. package/generated/mcp/tools.json +13922 -0
  63. package/generated/python/client.py +4454 -0
  64. package/generated/riffdb.application.exact.json +1 -0
  65. package/generated/riffdb.contract.bundle +0 -0
  66. package/generated/rust/client.rs +6524 -0
  67. package/package.json +83 -4
  68. package/profiles/custom-fields/generated/go/client.go +2578 -0
  69. package/profiles/custom-fields/generated/mcp/tools.json +15998 -0
  70. package/profiles/custom-fields/generated/python/client.py +5141 -0
  71. package/profiles/custom-fields/generated/riffdb.application.exact.json +1 -0
  72. package/profiles/custom-fields/generated/riffdb.contract.bundle +0 -0
  73. package/profiles/custom-fields/generated/rust/client.rs +7980 -0
  74. package/profiles/custom-fields/profile.ts +474 -0
  75. package/profiles/custom-fields/riffdb/contract.riff +568 -0
  76. package/profiles/custom-fields/riffdb/queries/admin_users_all_email_asc.riffq +24 -0
  77. package/profiles/custom-fields/riffdb/queries/admin_users_contains_asc.riffq +24 -0
  78. package/profiles/custom-fields/riffdb/queries/admin_users_contains_desc.riffq +24 -0
  79. package/profiles/custom-fields/riffdb/queries/admin_users_email_contains_created_desc.riffq +24 -0
  80. package/profiles/custom-fields/riffdb/queries/admin_users_email_contains_image_asc.riffq +24 -0
  81. package/profiles/custom-fields/riffdb/queries/admin_users_ends_with_asc.riffq +24 -0
  82. package/profiles/custom-fields/riffdb/queries/admin_users_ends_with_desc.riffq +24 -0
  83. package/profiles/custom-fields/riffdb/queries/admin_users_starts_with_asc.riffq +24 -0
  84. package/profiles/custom-fields/riffdb/queries/admin_users_starts_with_desc.riffq +24 -0
  85. package/profiles/custom-fields/riffdb/queries/find_account_by_id.riffq +24 -0
  86. package/profiles/custom-fields/riffdb/queries/find_account_by_provider.riffq +26 -0
  87. package/profiles/custom-fields/riffdb/queries/find_accounts_by_user_id.riffq +25 -0
  88. package/profiles/custom-fields/riffdb/queries/find_accounts_by_user_provider.riffq +27 -0
  89. package/profiles/custom-fields/riffdb/queries/find_active_sessions_by_user_id.riffq +23 -0
  90. package/profiles/custom-fields/riffdb/queries/find_credential_account.riffq +25 -0
  91. package/profiles/custom-fields/riffdb/queries/find_expired_verification_ids.riffq +17 -0
  92. package/profiles/custom-fields/riffdb/queries/find_latest_verification.riffq +20 -0
  93. package/profiles/custom-fields/riffdb/queries/find_session_by_id.riffq +20 -0
  94. package/profiles/custom-fields/riffdb/queries/find_session_by_token.riffq +20 -0
  95. package/profiles/custom-fields/riffdb/queries/find_sessions_by_token_set.riffq +20 -0
  96. package/profiles/custom-fields/riffdb/queries/find_sessions_by_user_id.riffq +21 -0
  97. package/profiles/custom-fields/riffdb/queries/find_user_by_email.riffq +16 -0
  98. package/profiles/custom-fields/riffdb/queries/find_user_by_id.riffq +15 -0
  99. package/profiles/custom-fields/riffdb/queries/find_verification_by_id.riffq +19 -0
  100. package/profiles/custom-fields/riffdb/queries/find_verifications_by_identifier.riffq +21 -0
  101. package/profiles/custom-fields/riffdb/queries/profile_account_with_user_by_provider.riffq +31 -0
  102. package/profiles/custom-fields/riffdb/queries/profile_session_with_user_by_id.riffq +14 -0
  103. package/profiles/custom-fields/riffdb/queries/profile_session_with_user_by_token.riffq +14 -0
  104. package/profiles/custom-fields/riffdb/queries/profile_sessions_with_users_by_token_set.riffq +25 -0
  105. package/profiles/custom-fields/riffdb/queries/profile_user_with_accounts_by_email.riffq +19 -0
  106. package/profiles/custom-fields/riffdb/queries/profile_user_with_accounts_by_id.riffq +19 -0
  107. package/profiles/custom-fields/riffdb.application.json +217 -0
  108. package/profiles/custom-fields/riffdb.application.lock.json +1 -0
  109. package/profiles/custom-fields/riffdb.toml +3 -0
  110. package/profiles/custom-fields/src/generated/client.ts +3096 -0
  111. package/profiles/organization-security/materialization.json +51 -0
  112. package/profiles/organization-security/riffdb/contract.riff +778 -0
  113. package/profiles/organization-security/riffdb/queries/find_account_by_id.riffq +18 -0
  114. package/profiles/organization-security/riffdb/queries/find_invitation_by_email.riffq +17 -0
  115. package/profiles/organization-security/riffdb/queries/find_invitation_by_id.riffq +18 -0
  116. package/profiles/organization-security/riffdb/queries/find_invitation_by_organization_id.riffq +17 -0
  117. package/profiles/organization-security/riffdb/queries/find_member_by_id.riffq +18 -0
  118. package/profiles/organization-security/riffdb/queries/find_member_by_user_id.riffq +17 -0
  119. package/profiles/organization-security/riffdb/queries/find_organization_by_id.riffq +16 -0
  120. package/profiles/organization-security/riffdb/queries/find_organization_by_slug.riffq +16 -0
  121. package/profiles/organization-security/riffdb/queries/find_session_by_id.riffq +18 -0
  122. package/profiles/organization-security/riffdb/queries/find_session_by_token.riffq +16 -0
  123. package/profiles/organization-security/riffdb/queries/find_team_by_id.riffq +18 -0
  124. package/profiles/organization-security/riffdb/queries/find_team_member_by_id.riffq +18 -0
  125. package/profiles/organization-security/riffdb/queries/find_team_member_by_membership_key.riffq +16 -0
  126. package/profiles/organization-security/riffdb/queries/find_team_member_by_team_id.riffq +17 -0
  127. package/profiles/organization-security/riffdb/queries/find_two_factor_by_id.riffq +18 -0
  128. package/profiles/organization-security/riffdb/queries/find_two_factor_by_secret.riffq +17 -0
  129. package/profiles/organization-security/riffdb/queries/find_user_by_email.riffq +16 -0
  130. package/profiles/organization-security/riffdb/queries/find_user_by_id.riffq +16 -0
  131. package/profiles/organization-security/riffdb/queries/find_verification_by_id.riffq +16 -0
  132. package/profiles/organization-security/riffdb/queries/find_verification_by_identifier.riffq +17 -0
  133. package/profiles/organization-security/riffdb.application.json +172 -0
  134. package/profiles/organization-security/riffdb.toml +7 -0
  135. package/profiles/organization-security.profile.json +980 -0
  136. package/profiles/runtime/generated/go/client.go +4511 -0
  137. package/profiles/runtime/generated/mcp/tools.json +30004 -0
  138. package/profiles/runtime/generated/python/client.py +9337 -0
  139. package/profiles/runtime/generated/riffdb.application.exact.json +1 -0
  140. package/profiles/runtime/generated/riffdb.contract.bundle +0 -0
  141. package/profiles/runtime/generated/rust/client.rs +13297 -0
  142. package/profiles/runtime/profile.ts +1064 -0
  143. package/profiles/runtime/riffdb/contract.riff +1053 -0
  144. package/profiles/runtime/riffdb/queries/admin_users_all_email_asc.riffq +24 -0
  145. package/profiles/runtime/riffdb/queries/admin_users_contains_asc.riffq +24 -0
  146. package/profiles/runtime/riffdb/queries/admin_users_contains_desc.riffq +24 -0
  147. package/profiles/runtime/riffdb/queries/admin_users_email_contains_created_desc.riffq +24 -0
  148. package/profiles/runtime/riffdb/queries/admin_users_email_contains_image_asc.riffq +24 -0
  149. package/profiles/runtime/riffdb/queries/admin_users_ends_with_asc.riffq +24 -0
  150. package/profiles/runtime/riffdb/queries/admin_users_ends_with_desc.riffq +24 -0
  151. package/profiles/runtime/riffdb/queries/admin_users_starts_with_asc.riffq +24 -0
  152. package/profiles/runtime/riffdb/queries/admin_users_starts_with_desc.riffq +24 -0
  153. package/profiles/runtime/riffdb/queries/find_account_by_id.riffq +24 -0
  154. package/profiles/runtime/riffdb/queries/find_account_by_provider.riffq +26 -0
  155. package/profiles/runtime/riffdb/queries/find_accounts_by_user_id.riffq +25 -0
  156. package/profiles/runtime/riffdb/queries/find_accounts_by_user_provider.riffq +27 -0
  157. package/profiles/runtime/riffdb/queries/find_active_sessions_by_user_id.riffq +23 -0
  158. package/profiles/runtime/riffdb/queries/find_credential_account.riffq +25 -0
  159. package/profiles/runtime/riffdb/queries/find_expired_verification_ids.riffq +17 -0
  160. package/profiles/runtime/riffdb/queries/find_latest_verification.riffq +20 -0
  161. package/profiles/runtime/riffdb/queries/find_session_by_id.riffq +20 -0
  162. package/profiles/runtime/riffdb/queries/find_session_by_token.riffq +20 -0
  163. package/profiles/runtime/riffdb/queries/find_sessions_by_token_set.riffq +20 -0
  164. package/profiles/runtime/riffdb/queries/find_sessions_by_user_id.riffq +21 -0
  165. package/profiles/runtime/riffdb/queries/find_user_by_email.riffq +16 -0
  166. package/profiles/runtime/riffdb/queries/find_user_by_id.riffq +15 -0
  167. package/profiles/runtime/riffdb/queries/find_verification_by_id.riffq +19 -0
  168. package/profiles/runtime/riffdb/queries/find_verifications_by_identifier.riffq +21 -0
  169. package/profiles/runtime/riffdb/queries/profile_account_with_user_by_provider.riffq +31 -0
  170. package/profiles/runtime/riffdb/queries/profile_invitation_by_email.riffq +17 -0
  171. package/profiles/runtime/riffdb/queries/profile_invitation_by_id.riffq +17 -0
  172. package/profiles/runtime/riffdb/queries/profile_invitation_by_organization_email_status.riffq +19 -0
  173. package/profiles/runtime/riffdb/queries/profile_invitation_by_organization_id.riffq +17 -0
  174. package/profiles/runtime/riffdb/queries/profile_invitation_by_organization_status.riffq +18 -0
  175. package/profiles/runtime/riffdb/queries/profile_member_by_id.riffq +27 -0
  176. package/profiles/runtime/riffdb/queries/profile_member_by_organization.riffq +20 -0
  177. package/profiles/runtime/riffdb/queries/profile_member_by_organization_created_at_asc.riffq +20 -0
  178. package/profiles/runtime/riffdb/queries/profile_member_by_organization_created_at_desc.riffq +20 -0
  179. package/profiles/runtime/riffdb/queries/profile_member_by_organization_role_asc.riffq +20 -0
  180. package/profiles/runtime/riffdb/queries/profile_member_by_organization_role_desc.riffq +20 -0
  181. package/profiles/runtime/riffdb/queries/profile_member_by_organization_user.riffq +28 -0
  182. package/profiles/runtime/riffdb/queries/profile_member_by_user.riffq +27 -0
  183. package/profiles/runtime/riffdb/queries/profile_organization_by_id.riffq +27 -0
  184. package/profiles/runtime/riffdb/queries/profile_organization_by_slug.riffq +27 -0
  185. package/profiles/runtime/riffdb/queries/profile_session_with_user_by_id.riffq +14 -0
  186. package/profiles/runtime/riffdb/queries/profile_session_with_user_by_token.riffq +14 -0
  187. package/profiles/runtime/riffdb/queries/profile_sessions_with_users_by_token_set.riffq +25 -0
  188. package/profiles/runtime/riffdb/queries/profile_two_factor_by_id.riffq +17 -0
  189. package/profiles/runtime/riffdb/queries/profile_two_factor_by_user.riffq +17 -0
  190. package/profiles/runtime/riffdb/queries/profile_user_with_accounts_by_email.riffq +19 -0
  191. package/profiles/runtime/riffdb/queries/profile_user_with_accounts_by_id.riffq +19 -0
  192. package/profiles/runtime/riffdb/queries/profile_users_by_id_set.riffq +8 -0
  193. package/profiles/runtime/riffdb.application.json +324 -0
  194. package/profiles/runtime/riffdb.application.lock.json +1 -0
  195. package/profiles/runtime/riffdb.toml +3 -0
  196. package/profiles/runtime/src/generated/client.ts +5186 -0
  197. package/riffdb/contract.riff +547 -0
  198. package/riffdb/queries/admin_users_all_email_asc.riffq +24 -0
  199. package/riffdb/queries/admin_users_contains_asc.riffq +24 -0
  200. package/riffdb/queries/admin_users_contains_desc.riffq +24 -0
  201. package/riffdb/queries/admin_users_email_contains_created_desc.riffq +24 -0
  202. package/riffdb/queries/admin_users_email_contains_image_asc.riffq +24 -0
  203. package/riffdb/queries/admin_users_ends_with_asc.riffq +24 -0
  204. package/riffdb/queries/admin_users_ends_with_desc.riffq +24 -0
  205. package/riffdb/queries/admin_users_starts_with_asc.riffq +24 -0
  206. package/riffdb/queries/admin_users_starts_with_desc.riffq +24 -0
  207. package/riffdb/queries/find_account_by_id.riffq +24 -0
  208. package/riffdb/queries/find_account_by_provider.riffq +26 -0
  209. package/riffdb/queries/find_accounts_by_user_id.riffq +25 -0
  210. package/riffdb/queries/find_accounts_by_user_provider.riffq +27 -0
  211. package/riffdb/queries/find_active_sessions_by_user_id.riffq +23 -0
  212. package/riffdb/queries/find_credential_account.riffq +25 -0
  213. package/riffdb/queries/find_expired_verification_ids.riffq +17 -0
  214. package/riffdb/queries/find_latest_verification.riffq +20 -0
  215. package/riffdb/queries/find_session_by_id.riffq +20 -0
  216. package/riffdb/queries/find_session_by_token.riffq +20 -0
  217. package/riffdb/queries/find_sessions_by_token_set.riffq +20 -0
  218. package/riffdb/queries/find_sessions_by_user_id.riffq +21 -0
  219. package/riffdb/queries/find_user_by_email.riffq +16 -0
  220. package/riffdb/queries/find_user_by_id.riffq +15 -0
  221. package/riffdb/queries/find_verification_by_id.riffq +19 -0
  222. package/riffdb/queries/find_verifications_by_identifier.riffq +21 -0
  223. package/riffdb.application.json +187 -0
  224. package/riffdb.application.lock.json +1 -0
  225. package/scripts/real-riffdb-runner.mjs +333 -0
  226. package/src/generated/client.ts +2746 -0
@@ -0,0 +1,778 @@
1
+ contract BetterAuthOrganizationSecurity version 1 {
2
+ entity Account {
3
+ key (tenant_id: uuid, user_id: uuid, account_row_id: uuid)
4
+ field secret access_token: optional<string<2048>>
5
+ field secret access_token_expires_at: optional<timestamp>
6
+ field account_id: string<2048>
7
+ field created_at: timestamp
8
+ field secret id_token: optional<string<2048>>
9
+ field secret password: optional<string<2048>>
10
+ field provider_id: string<2048>
11
+ field secret refresh_token: optional<string<2048>>
12
+ field secret refresh_token_expires_at: optional<timestamp>
13
+ field scope: optional<string<2048>>
14
+ field updated_at: timestamp
15
+ field revision: u64
16
+ index by_parent (tenant_id, user_id, account_row_id)
17
+ reference account_parent (tenant_id, user_id) -> User(tenant_id, user_id)
18
+ delete_policy no_inbound
19
+ }
20
+
21
+ entity Invitation {
22
+ key (tenant_id: uuid, user_id: uuid, invitation_id: uuid)
23
+ field created_at: timestamp
24
+ field email: string<2048>
25
+ field expires_at: timestamp
26
+ field organization_id: uuid
27
+ field role: optional<string<2048>>
28
+ field status: string<2048>
29
+ field team_id: optional<string<2048>>
30
+ field revision: u64
31
+ index by_email (tenant_id, email, user_id, invitation_id)
32
+ index by_organization_id (tenant_id, organization_id, user_id, invitation_id)
33
+ index by_parent (tenant_id, user_id, invitation_id)
34
+ reference invitation_parent (tenant_id, user_id) -> User(tenant_id, user_id)
35
+ delete_policy no_inbound
36
+ }
37
+
38
+ entity Member {
39
+ key (tenant_id: uuid, organization_id: uuid, member_id: uuid)
40
+ field created_at: timestamp
41
+ field role: string<2048>
42
+ field user_id: uuid
43
+ field revision: u64
44
+ index by_user_id (tenant_id, user_id, organization_id, member_id)
45
+ index by_parent (tenant_id, organization_id, member_id)
46
+ reference member_parent (tenant_id, organization_id) -> Organization(tenant_id, organization_id)
47
+ delete_policy no_inbound
48
+ }
49
+
50
+ entity Organization {
51
+ key (tenant_id: uuid, organization_id: uuid)
52
+ field created_at: timestamp
53
+ field logo: optional<string<2048>>
54
+ field metadata: optional<string<2048>>
55
+ field name: string<2048>
56
+ field slug: string<2048>
57
+ field revision: u64
58
+ unique organization_slug (tenant_id, slug)
59
+ index by_slug (tenant_id, slug, organization_id)
60
+ delete_policy cascade {
61
+ relationship Member.member_parent using Member.by_parent maximum 32
62
+ relationship Team.team_parent using Team.by_parent maximum 32
63
+ }
64
+ }
65
+
66
+ entity Session {
67
+ key (tenant_id: uuid, user_id: uuid, session_id: uuid)
68
+ field active_organization_id: optional<string<2048>>
69
+ field active_team_id: optional<string<2048>>
70
+ field created_at: timestamp
71
+ field expires_at: timestamp
72
+ field ip_address: optional<string<2048>>
73
+ field secret token: string<2048>
74
+ field updated_at: timestamp
75
+ field user_agent: optional<string<2048>>
76
+ field revision: u64
77
+ unique session_token (tenant_id, token)
78
+ index by_token (tenant_id, token, user_id, session_id)
79
+ index by_parent (tenant_id, user_id, session_id)
80
+ reference session_parent (tenant_id, user_id) -> User(tenant_id, user_id)
81
+ delete_policy no_inbound
82
+ }
83
+
84
+ entity Team {
85
+ key (tenant_id: uuid, organization_id: uuid, team_id: uuid)
86
+ field created_at: timestamp
87
+ field secret member_count: i64
88
+ field name: string<2048>
89
+ field updated_at: optional<timestamp>
90
+ field revision: u64
91
+ index by_parent (tenant_id, organization_id, team_id)
92
+ reference team_parent (tenant_id, organization_id) -> Organization(tenant_id, organization_id)
93
+ delete_policy no_inbound
94
+ }
95
+
96
+ entity TeamMember {
97
+ key (tenant_id: uuid, user_id: uuid, team_member_id: uuid)
98
+ field created_at: optional<timestamp>
99
+ field secret membership_key: string<2048>
100
+ field team_id: uuid
101
+ field revision: u64
102
+ unique team_member_membership_key (tenant_id, membership_key)
103
+ index by_membership_key (tenant_id, membership_key, user_id, team_member_id)
104
+ index by_team_id (tenant_id, team_id, user_id, team_member_id)
105
+ index by_parent (tenant_id, user_id, team_member_id)
106
+ reference team_member_parent (tenant_id, user_id) -> User(tenant_id, user_id)
107
+ delete_policy no_inbound
108
+ }
109
+
110
+ entity TwoFactor {
111
+ key (tenant_id: uuid, user_id: uuid, two_factor_id: uuid)
112
+ field secret backup_codes: string<2048>
113
+ field secret failed_verification_count: optional<i64>
114
+ field secret locked_until: optional<timestamp>
115
+ field secret secret: string<2048>
116
+ field verified: optional<bool>
117
+ field revision: u64
118
+ index by_secret (tenant_id, secret, user_id, two_factor_id)
119
+ index by_parent (tenant_id, user_id, two_factor_id)
120
+ reference two_factor_parent (tenant_id, user_id) -> User(tenant_id, user_id)
121
+ delete_policy no_inbound
122
+ }
123
+
124
+ entity User {
125
+ key (tenant_id: uuid, user_id: uuid)
126
+ field created_at: timestamp
127
+ field email: string<2048>
128
+ field email_verified: bool
129
+ field image: optional<string<2048>>
130
+ field locale: optional<string<2048>>
131
+ field name: string<2048>
132
+ field two_factor_enabled: optional<bool>
133
+ field updated_at: timestamp
134
+ field revision: u64
135
+ unique user_email (tenant_id, email)
136
+ index by_email (tenant_id, email, user_id)
137
+ delete_policy cascade {
138
+ relationship Account.account_parent using Account.by_parent maximum 32
139
+ relationship Invitation.invitation_parent using Invitation.by_parent maximum 32
140
+ relationship Session.session_parent using Session.by_parent maximum 32
141
+ relationship TeamMember.team_member_parent using TeamMember.by_parent maximum 32
142
+ relationship TwoFactor.two_factor_parent using TwoFactor.by_parent maximum 32
143
+ }
144
+ }
145
+
146
+ entity Verification {
147
+ key (tenant_id: uuid, verification_id: uuid)
148
+ field created_at: timestamp
149
+ field expires_at: timestamp
150
+ field identifier: string<2048>
151
+ field updated_at: timestamp
152
+ field secret value: string<2048>
153
+ field revision: u64
154
+ index by_identifier (tenant_id, identifier, verification_id)
155
+ delete_policy no_inbound
156
+ }
157
+
158
+ aggregate OrganizationData {
159
+ root Organization
160
+ child Member
161
+ child Team
162
+ partition_by tenant_id
163
+ conflict_key (tenant_id, organization_id)
164
+ }
165
+
166
+ aggregate UserData {
167
+ root User
168
+ child Account
169
+ child Invitation
170
+ child Session
171
+ child TeamMember
172
+ child TwoFactor
173
+ partition_by tenant_id
174
+ conflict_key (tenant_id, user_id)
175
+ }
176
+
177
+ aggregate VerificationData {
178
+ root Verification
179
+ partition_by tenant_id
180
+ conflict_key (tenant_id, verification_id)
181
+ }
182
+
183
+ command CreateAccount {
184
+ input request_id: uuid
185
+ input tenant_id: uuid
186
+ input user_id: uuid
187
+ input account_row_id: uuid
188
+ input access_token: optional<string<2048>>
189
+ input access_token_expires_at: optional<timestamp>
190
+ input account_id: string<2048>
191
+ input created_at: timestamp
192
+ input id_token: optional<string<2048>>
193
+ input password: optional<string<2048>>
194
+ input provider_id: string<2048>
195
+ input refresh_token: optional<string<2048>>
196
+ input refresh_token_expires_at: optional<timestamp>
197
+ input scope: optional<string<2048>>
198
+ input updated_at: timestamp
199
+ idempotency_key request_id
200
+ read User(tenant_id, user_id) as user else AccountParentMissing {}
201
+ create Account(tenant_id, user_id, account_row_id) as account else AccountAlreadyExists {}
202
+ set account.access_token = access_token
203
+ set account.access_token_expires_at = access_token_expires_at
204
+ set account.account_id = account_id
205
+ set account.created_at = created_at
206
+ set account.id_token = id_token
207
+ set account.password = password
208
+ set account.provider_id = provider_id
209
+ set account.refresh_token = refresh_token
210
+ set account.refresh_token_expires_at = refresh_token_expires_at
211
+ set account.scope = scope
212
+ set account.updated_at = updated_at
213
+ set account.revision = 1
214
+ return AccountCreated {}
215
+ }
216
+
217
+ command UpdateAccount {
218
+ input request_id: uuid
219
+ input tenant_id: uuid
220
+ input user_id: uuid
221
+ input account_row_id: uuid
222
+ input expected_revision: u64
223
+ input access_token: optional<string<2048>>
224
+ input access_token_expires_at: optional<timestamp>
225
+ input account_id: string<2048>
226
+ input created_at: timestamp
227
+ input id_token: optional<string<2048>>
228
+ input password: optional<string<2048>>
229
+ input provider_id: string<2048>
230
+ input refresh_token: optional<string<2048>>
231
+ input refresh_token_expires_at: optional<timestamp>
232
+ input scope: optional<string<2048>>
233
+ input updated_at: timestamp
234
+ idempotency_key request_id
235
+ mutate Account(tenant_id, user_id, account_row_id) as account else AccountUpdateMissing {}
236
+ require current_revision: account.revision == expected_revision else AccountUpdateStale {}
237
+ set account.access_token = access_token checked_by current_revision
238
+ set account.access_token_expires_at = access_token_expires_at checked_by current_revision
239
+ set account.account_id = account_id checked_by current_revision
240
+ set account.created_at = created_at checked_by current_revision
241
+ set account.id_token = id_token checked_by current_revision
242
+ set account.password = password checked_by current_revision
243
+ set account.provider_id = provider_id checked_by current_revision
244
+ set account.refresh_token = refresh_token checked_by current_revision
245
+ set account.refresh_token_expires_at = refresh_token_expires_at checked_by current_revision
246
+ set account.scope = scope checked_by current_revision
247
+ set account.updated_at = updated_at checked_by current_revision
248
+ set account.revision = account.revision + 1
249
+ return AccountUpdated {}
250
+ }
251
+
252
+ bulk command DeleteAccount {
253
+ input request_id: uuid
254
+ input tenant_id: uuid
255
+ input user_id: uuid
256
+ input account_row_ids: list<uuid, 1..32>
257
+ idempotency_key request_id
258
+ for account_row_id in account_row_ids {
259
+ delete Account(tenant_id, user_id, account_row_id) as account else AccountMissing {}
260
+ }
261
+ return AccountDeleted {}
262
+ }
263
+
264
+ command CreateInvitation {
265
+ input request_id: uuid
266
+ input tenant_id: uuid
267
+ input user_id: uuid
268
+ input invitation_id: uuid
269
+ input created_at: timestamp
270
+ input email: string<2048>
271
+ input expires_at: timestamp
272
+ input organization_id: uuid
273
+ input role: optional<string<2048>>
274
+ input status: string<2048>
275
+ input team_id: optional<string<2048>>
276
+ idempotency_key request_id
277
+ read User(tenant_id, user_id) as user else InvitationParentMissing {}
278
+ create Invitation(tenant_id, user_id, invitation_id) as invitation else InvitationAlreadyExists {}
279
+ set invitation.created_at = created_at
280
+ set invitation.email = email
281
+ set invitation.expires_at = expires_at
282
+ set invitation.organization_id = organization_id
283
+ set invitation.role = role
284
+ set invitation.status = status
285
+ set invitation.team_id = team_id
286
+ set invitation.revision = 1
287
+ return InvitationCreated {}
288
+ }
289
+
290
+ command UpdateInvitation {
291
+ input request_id: uuid
292
+ input tenant_id: uuid
293
+ input user_id: uuid
294
+ input invitation_id: uuid
295
+ input expected_revision: u64
296
+ input created_at: timestamp
297
+ input email: string<2048>
298
+ input expires_at: timestamp
299
+ input organization_id: uuid
300
+ input role: optional<string<2048>>
301
+ input status: string<2048>
302
+ input team_id: optional<string<2048>>
303
+ idempotency_key request_id
304
+ mutate Invitation(tenant_id, user_id, invitation_id) as invitation else InvitationUpdateMissing {}
305
+ require current_revision: invitation.revision == expected_revision else InvitationUpdateStale {}
306
+ set invitation.created_at = created_at checked_by current_revision
307
+ set invitation.email = email checked_by current_revision
308
+ set invitation.expires_at = expires_at checked_by current_revision
309
+ set invitation.organization_id = organization_id checked_by current_revision
310
+ set invitation.role = role checked_by current_revision
311
+ set invitation.status = status checked_by current_revision
312
+ set invitation.team_id = team_id checked_by current_revision
313
+ set invitation.revision = invitation.revision + 1
314
+ return InvitationUpdated {}
315
+ }
316
+
317
+ bulk command DeleteInvitation {
318
+ input request_id: uuid
319
+ input tenant_id: uuid
320
+ input user_id: uuid
321
+ input invitation_ids: list<uuid, 1..32>
322
+ idempotency_key request_id
323
+ for invitation_id in invitation_ids {
324
+ delete Invitation(tenant_id, user_id, invitation_id) as invitation else InvitationMissing {}
325
+ }
326
+ return InvitationDeleted {}
327
+ }
328
+
329
+ command CreateMember {
330
+ input request_id: uuid
331
+ input tenant_id: uuid
332
+ input organization_id: uuid
333
+ input member_id: uuid
334
+ input created_at: timestamp
335
+ input role: string<2048>
336
+ input user_id: uuid
337
+ idempotency_key request_id
338
+ read Organization(tenant_id, organization_id) as organization else MemberParentMissing {}
339
+ create Member(tenant_id, organization_id, member_id) as member else MemberAlreadyExists {}
340
+ set member.created_at = created_at
341
+ set member.role = role
342
+ set member.user_id = user_id
343
+ set member.revision = 1
344
+ return MemberCreated {}
345
+ }
346
+
347
+ command UpdateMember {
348
+ input request_id: uuid
349
+ input tenant_id: uuid
350
+ input organization_id: uuid
351
+ input member_id: uuid
352
+ input expected_revision: u64
353
+ input created_at: timestamp
354
+ input role: string<2048>
355
+ input user_id: uuid
356
+ idempotency_key request_id
357
+ mutate Member(tenant_id, organization_id, member_id) as member else MemberUpdateMissing {}
358
+ require current_revision: member.revision == expected_revision else MemberUpdateStale {}
359
+ set member.created_at = created_at checked_by current_revision
360
+ set member.role = role checked_by current_revision
361
+ set member.user_id = user_id checked_by current_revision
362
+ set member.revision = member.revision + 1
363
+ return MemberUpdated {}
364
+ }
365
+
366
+ bulk command DeleteMember {
367
+ input request_id: uuid
368
+ input tenant_id: uuid
369
+ input organization_id: uuid
370
+ input member_ids: list<uuid, 1..32>
371
+ idempotency_key request_id
372
+ for member_id in member_ids {
373
+ delete Member(tenant_id, organization_id, member_id) as member else MemberMissing {}
374
+ }
375
+ return MemberDeleted {}
376
+ }
377
+
378
+ command CreateOrganization {
379
+ input request_id: uuid
380
+ input tenant_id: uuid
381
+ input organization_id: uuid
382
+ input created_at: timestamp
383
+ input logo: optional<string<2048>>
384
+ input metadata: optional<string<2048>>
385
+ input name: string<2048>
386
+ input slug: string<2048>
387
+ idempotency_key request_id
388
+ create Organization(tenant_id, organization_id) as organization else OrganizationAlreadyExists {}
389
+ set organization.created_at = created_at
390
+ set organization.logo = logo
391
+ set organization.metadata = metadata
392
+ set organization.name = name
393
+ set organization.slug = slug
394
+ set organization.revision = 1
395
+ return OrganizationCreated {}
396
+ }
397
+
398
+ command UpdateOrganization {
399
+ input request_id: uuid
400
+ input tenant_id: uuid
401
+ input organization_id: uuid
402
+ input expected_revision: u64
403
+ input created_at: timestamp
404
+ input logo: optional<string<2048>>
405
+ input metadata: optional<string<2048>>
406
+ input name: string<2048>
407
+ input slug: string<2048>
408
+ idempotency_key request_id
409
+ mutate Organization(tenant_id, organization_id) as organization else OrganizationUpdateMissing {}
410
+ require current_revision: organization.revision == expected_revision else OrganizationUpdateStale {}
411
+ set organization.created_at = created_at
412
+ set organization.logo = logo
413
+ set organization.metadata = metadata
414
+ set organization.name = name
415
+ set organization.slug = slug
416
+ set organization.revision = organization.revision + 1
417
+ return OrganizationUpdated {}
418
+ }
419
+
420
+ bulk command DeleteOrganization {
421
+ input request_id: uuid
422
+ input tenant_id: uuid
423
+ input organization_ids: list<uuid, 1..3>
424
+ idempotency_key request_id
425
+ for organization_id in organization_ids {
426
+ delete Organization(tenant_id, organization_id) as organization else OrganizationMissing {}
427
+ cascade OrganizationCascadeLimitExceeded {}
428
+ }
429
+ return OrganizationDeleted {}
430
+ }
431
+
432
+ command CreateSession {
433
+ input request_id: uuid
434
+ input tenant_id: uuid
435
+ input user_id: uuid
436
+ input session_id: uuid
437
+ input active_organization_id: optional<string<2048>>
438
+ input active_team_id: optional<string<2048>>
439
+ input created_at: timestamp
440
+ input expires_at: timestamp
441
+ input ip_address: optional<string<2048>>
442
+ input token: string<2048>
443
+ input updated_at: timestamp
444
+ input user_agent: optional<string<2048>>
445
+ idempotency_key request_id
446
+ read User(tenant_id, user_id) as user else SessionParentMissing {}
447
+ create Session(tenant_id, user_id, session_id) as session else SessionAlreadyExists {}
448
+ set session.active_organization_id = active_organization_id
449
+ set session.active_team_id = active_team_id
450
+ set session.created_at = created_at
451
+ set session.expires_at = expires_at
452
+ set session.ip_address = ip_address
453
+ set session.token = token
454
+ set session.updated_at = updated_at
455
+ set session.user_agent = user_agent
456
+ set session.revision = 1
457
+ return SessionCreated {}
458
+ }
459
+
460
+ command UpdateSession {
461
+ input request_id: uuid
462
+ input tenant_id: uuid
463
+ input user_id: uuid
464
+ input session_id: uuid
465
+ input expected_revision: u64
466
+ input active_organization_id: optional<string<2048>>
467
+ input active_team_id: optional<string<2048>>
468
+ input created_at: timestamp
469
+ input expires_at: timestamp
470
+ input ip_address: optional<string<2048>>
471
+ input token: string<2048>
472
+ input updated_at: timestamp
473
+ input user_agent: optional<string<2048>>
474
+ idempotency_key request_id
475
+ mutate Session(tenant_id, user_id, session_id) as session else SessionUpdateMissing {}
476
+ require current_revision: session.revision == expected_revision else SessionUpdateStale {}
477
+ set session.active_organization_id = active_organization_id checked_by current_revision
478
+ set session.active_team_id = active_team_id checked_by current_revision
479
+ set session.created_at = created_at checked_by current_revision
480
+ set session.expires_at = expires_at checked_by current_revision
481
+ set session.ip_address = ip_address checked_by current_revision
482
+ set session.token = token checked_by current_revision
483
+ set session.updated_at = updated_at checked_by current_revision
484
+ set session.user_agent = user_agent checked_by current_revision
485
+ set session.revision = session.revision + 1
486
+ return SessionUpdated {}
487
+ }
488
+
489
+ bulk command DeleteSession {
490
+ input request_id: uuid
491
+ input tenant_id: uuid
492
+ input user_id: uuid
493
+ input session_ids: list<uuid, 1..32>
494
+ idempotency_key request_id
495
+ for session_id in session_ids {
496
+ delete Session(tenant_id, user_id, session_id) as session else SessionMissing {}
497
+ }
498
+ return SessionDeleted {}
499
+ }
500
+
501
+ command CreateTeam {
502
+ input request_id: uuid
503
+ input tenant_id: uuid
504
+ input organization_id: uuid
505
+ input team_id: uuid
506
+ input created_at: timestamp
507
+ input member_count: i64
508
+ input name: string<2048>
509
+ input updated_at: optional<timestamp>
510
+ idempotency_key request_id
511
+ read Organization(tenant_id, organization_id) as organization else TeamParentMissing {}
512
+ create Team(tenant_id, organization_id, team_id) as team else TeamAlreadyExists {}
513
+ set team.created_at = created_at
514
+ set team.member_count = member_count
515
+ set team.name = name
516
+ set team.updated_at = updated_at
517
+ set team.revision = 1
518
+ return TeamCreated {}
519
+ }
520
+
521
+ command UpdateTeam {
522
+ input request_id: uuid
523
+ input tenant_id: uuid
524
+ input organization_id: uuid
525
+ input team_id: uuid
526
+ input expected_revision: u64
527
+ input created_at: timestamp
528
+ input member_count: i64
529
+ input name: string<2048>
530
+ input updated_at: optional<timestamp>
531
+ idempotency_key request_id
532
+ mutate Team(tenant_id, organization_id, team_id) as team else TeamUpdateMissing {}
533
+ require current_revision: team.revision == expected_revision else TeamUpdateStale {}
534
+ set team.created_at = created_at checked_by current_revision
535
+ set team.member_count = member_count checked_by current_revision
536
+ set team.name = name checked_by current_revision
537
+ set team.updated_at = updated_at checked_by current_revision
538
+ set team.revision = team.revision + 1
539
+ return TeamUpdated {}
540
+ }
541
+
542
+ bulk command DeleteTeam {
543
+ input request_id: uuid
544
+ input tenant_id: uuid
545
+ input organization_id: uuid
546
+ input team_ids: list<uuid, 1..32>
547
+ idempotency_key request_id
548
+ for team_id in team_ids {
549
+ delete Team(tenant_id, organization_id, team_id) as team else TeamMissing {}
550
+ }
551
+ return TeamDeleted {}
552
+ }
553
+
554
+ command CreateTeamMember {
555
+ input request_id: uuid
556
+ input tenant_id: uuid
557
+ input user_id: uuid
558
+ input team_member_id: uuid
559
+ input created_at: optional<timestamp>
560
+ input membership_key: string<2048>
561
+ input team_id: uuid
562
+ idempotency_key request_id
563
+ read User(tenant_id, user_id) as user else TeamMemberParentMissing {}
564
+ create TeamMember(tenant_id, user_id, team_member_id) as team_member else TeamMemberAlreadyExists {}
565
+ set team_member.created_at = created_at
566
+ set team_member.membership_key = membership_key
567
+ set team_member.team_id = team_id
568
+ set team_member.revision = 1
569
+ return TeamMemberCreated {}
570
+ }
571
+
572
+ command UpdateTeamMember {
573
+ input request_id: uuid
574
+ input tenant_id: uuid
575
+ input user_id: uuid
576
+ input team_member_id: uuid
577
+ input expected_revision: u64
578
+ input created_at: optional<timestamp>
579
+ input membership_key: string<2048>
580
+ input team_id: uuid
581
+ idempotency_key request_id
582
+ mutate TeamMember(tenant_id, user_id, team_member_id) as team_member else TeamMemberUpdateMissing {}
583
+ require current_revision: team_member.revision == expected_revision else TeamMemberUpdateStale {}
584
+ set team_member.created_at = created_at checked_by current_revision
585
+ set team_member.membership_key = membership_key checked_by current_revision
586
+ set team_member.team_id = team_id checked_by current_revision
587
+ set team_member.revision = team_member.revision + 1
588
+ return TeamMemberUpdated {}
589
+ }
590
+
591
+ bulk command DeleteTeamMember {
592
+ input request_id: uuid
593
+ input tenant_id: uuid
594
+ input user_id: uuid
595
+ input team_member_ids: list<uuid, 1..32>
596
+ idempotency_key request_id
597
+ for team_member_id in team_member_ids {
598
+ delete TeamMember(tenant_id, user_id, team_member_id) as team_member else TeamMemberMissing {}
599
+ }
600
+ return TeamMemberDeleted {}
601
+ }
602
+
603
+ command CreateTwoFactor {
604
+ input request_id: uuid
605
+ input tenant_id: uuid
606
+ input user_id: uuid
607
+ input two_factor_id: uuid
608
+ input backup_codes: string<2048>
609
+ input failed_verification_count: optional<i64>
610
+ input locked_until: optional<timestamp>
611
+ input secret: string<2048>
612
+ input verified: optional<bool>
613
+ idempotency_key request_id
614
+ read User(tenant_id, user_id) as user else TwoFactorParentMissing {}
615
+ create TwoFactor(tenant_id, user_id, two_factor_id) as two_factor else TwoFactorAlreadyExists {}
616
+ set two_factor.backup_codes = backup_codes
617
+ set two_factor.failed_verification_count = failed_verification_count
618
+ set two_factor.locked_until = locked_until
619
+ set two_factor.secret = secret
620
+ set two_factor.verified = verified
621
+ set two_factor.revision = 1
622
+ return TwoFactorCreated {}
623
+ }
624
+
625
+ command UpdateTwoFactor {
626
+ input request_id: uuid
627
+ input tenant_id: uuid
628
+ input user_id: uuid
629
+ input two_factor_id: uuid
630
+ input expected_revision: u64
631
+ input backup_codes: string<2048>
632
+ input failed_verification_count: optional<i64>
633
+ input locked_until: optional<timestamp>
634
+ input secret: string<2048>
635
+ input verified: optional<bool>
636
+ idempotency_key request_id
637
+ mutate TwoFactor(tenant_id, user_id, two_factor_id) as two_factor else TwoFactorUpdateMissing {}
638
+ require current_revision: two_factor.revision == expected_revision else TwoFactorUpdateStale {}
639
+ set two_factor.backup_codes = backup_codes checked_by current_revision
640
+ set two_factor.failed_verification_count = failed_verification_count checked_by current_revision
641
+ set two_factor.locked_until = locked_until checked_by current_revision
642
+ set two_factor.secret = secret checked_by current_revision
643
+ set two_factor.verified = verified checked_by current_revision
644
+ set two_factor.revision = two_factor.revision + 1
645
+ return TwoFactorUpdated {}
646
+ }
647
+
648
+ bulk command DeleteTwoFactor {
649
+ input request_id: uuid
650
+ input tenant_id: uuid
651
+ input user_id: uuid
652
+ input two_factor_ids: list<uuid, 1..32>
653
+ idempotency_key request_id
654
+ for two_factor_id in two_factor_ids {
655
+ delete TwoFactor(tenant_id, user_id, two_factor_id) as two_factor else TwoFactorMissing {}
656
+ }
657
+ return TwoFactorDeleted {}
658
+ }
659
+
660
+ command CreateUser {
661
+ input request_id: uuid
662
+ input tenant_id: uuid
663
+ input user_id: uuid
664
+ input created_at: timestamp
665
+ input email: string<2048>
666
+ input email_verified: bool
667
+ input image: optional<string<2048>>
668
+ input locale: optional<string<2048>>
669
+ input name: string<2048>
670
+ input two_factor_enabled: optional<bool>
671
+ input updated_at: timestamp
672
+ idempotency_key request_id
673
+ create User(tenant_id, user_id) as user else UserAlreadyExists {}
674
+ set user.created_at = created_at
675
+ set user.email = email
676
+ set user.email_verified = email_verified
677
+ set user.image = image
678
+ set user.locale = locale
679
+ set user.name = name
680
+ set user.two_factor_enabled = two_factor_enabled
681
+ set user.updated_at = updated_at
682
+ set user.revision = 1
683
+ return UserCreated {}
684
+ }
685
+
686
+ command UpdateUser {
687
+ input request_id: uuid
688
+ input tenant_id: uuid
689
+ input user_id: uuid
690
+ input expected_revision: u64
691
+ input created_at: timestamp
692
+ input email: string<2048>
693
+ input email_verified: bool
694
+ input image: optional<string<2048>>
695
+ input locale: optional<string<2048>>
696
+ input name: string<2048>
697
+ input two_factor_enabled: optional<bool>
698
+ input updated_at: timestamp
699
+ idempotency_key request_id
700
+ mutate User(tenant_id, user_id) as user else UserUpdateMissing {}
701
+ require current_revision: user.revision == expected_revision else UserUpdateStale {}
702
+ set user.created_at = created_at
703
+ set user.email = email
704
+ set user.email_verified = email_verified
705
+ set user.image = image
706
+ set user.locale = locale
707
+ set user.name = name
708
+ set user.two_factor_enabled = two_factor_enabled
709
+ set user.updated_at = updated_at
710
+ set user.revision = user.revision + 1
711
+ return UserUpdated {}
712
+ }
713
+
714
+ bulk command DeleteUser {
715
+ input request_id: uuid
716
+ input tenant_id: uuid
717
+ input user_ids: list<uuid, 1..1>
718
+ idempotency_key request_id
719
+ for user_id in user_ids {
720
+ delete User(tenant_id, user_id) as user else UserMissing {}
721
+ cascade UserCascadeLimitExceeded {}
722
+ }
723
+ return UserDeleted {}
724
+ }
725
+
726
+ command CreateVerification {
727
+ input request_id: uuid
728
+ input tenant_id: uuid
729
+ input verification_id: uuid
730
+ input created_at: timestamp
731
+ input expires_at: timestamp
732
+ input identifier: string<2048>
733
+ input updated_at: timestamp
734
+ input value: string<2048>
735
+ idempotency_key request_id
736
+ create Verification(tenant_id, verification_id) as verification else VerificationAlreadyExists {}
737
+ set verification.created_at = created_at
738
+ set verification.expires_at = expires_at
739
+ set verification.identifier = identifier
740
+ set verification.updated_at = updated_at
741
+ set verification.value = value
742
+ set verification.revision = 1
743
+ return VerificationCreated {}
744
+ }
745
+
746
+ command UpdateVerification {
747
+ input request_id: uuid
748
+ input tenant_id: uuid
749
+ input verification_id: uuid
750
+ input expected_revision: u64
751
+ input created_at: timestamp
752
+ input expires_at: timestamp
753
+ input identifier: string<2048>
754
+ input updated_at: timestamp
755
+ input value: string<2048>
756
+ idempotency_key request_id
757
+ mutate Verification(tenant_id, verification_id) as verification else VerificationUpdateMissing {}
758
+ require current_revision: verification.revision == expected_revision else VerificationUpdateStale {}
759
+ set verification.created_at = created_at
760
+ set verification.expires_at = expires_at
761
+ set verification.identifier = identifier
762
+ set verification.updated_at = updated_at
763
+ set verification.value = value
764
+ set verification.revision = verification.revision + 1
765
+ return VerificationUpdated {}
766
+ }
767
+
768
+ bulk command DeleteVerification {
769
+ input request_id: uuid
770
+ input tenant_id: uuid
771
+ input verification_ids: list<uuid, 1..32>
772
+ idempotency_key request_id
773
+ for verification_id in verification_ids {
774
+ delete Verification(tenant_id, verification_id) as verification else VerificationMissing {}
775
+ }
776
+ return VerificationDeleted {}
777
+ }
778
+ }