@contractspec/lib.identity-rbac 1.57.0 → 1.59.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 (82) hide show
  1. package/dist/browser/contracts/index.js +1045 -0
  2. package/dist/browser/contracts/organization.js +655 -0
  3. package/dist/browser/contracts/rbac.js +599 -0
  4. package/dist/browser/contracts/user.js +235 -0
  5. package/dist/browser/entities/index.js +464 -0
  6. package/dist/browser/entities/organization.js +150 -0
  7. package/dist/browser/entities/rbac.js +124 -0
  8. package/dist/browser/entities/user.js +168 -0
  9. package/dist/browser/events.js +374 -0
  10. package/dist/browser/identity-rbac.capability.js +28 -0
  11. package/dist/browser/identity-rbac.feature.js +67 -0
  12. package/dist/browser/index.js +2099 -0
  13. package/dist/browser/policies/engine.js +154 -0
  14. package/dist/browser/policies/index.js +154 -0
  15. package/dist/contracts/index.d.ts +4 -4
  16. package/dist/contracts/index.d.ts.map +1 -0
  17. package/dist/contracts/index.js +1045 -4
  18. package/dist/contracts/organization.d.ts +758 -764
  19. package/dist/contracts/organization.d.ts.map +1 -1
  20. package/dist/contracts/organization.js +653 -602
  21. package/dist/contracts/rbac.d.ts +517 -523
  22. package/dist/contracts/rbac.d.ts.map +1 -1
  23. package/dist/contracts/rbac.js +597 -481
  24. package/dist/contracts/user.d.ts +513 -519
  25. package/dist/contracts/user.d.ts.map +1 -1
  26. package/dist/contracts/user.js +222 -319
  27. package/dist/entities/index.d.ts +164 -169
  28. package/dist/entities/index.d.ts.map +1 -1
  29. package/dist/entities/index.js +462 -33
  30. package/dist/entities/organization.d.ts +58 -63
  31. package/dist/entities/organization.d.ts.map +1 -1
  32. package/dist/entities/organization.js +145 -145
  33. package/dist/entities/rbac.d.ts +62 -67
  34. package/dist/entities/rbac.d.ts.map +1 -1
  35. package/dist/entities/rbac.js +119 -132
  36. package/dist/entities/user.d.ts +66 -71
  37. package/dist/entities/user.d.ts.map +1 -1
  38. package/dist/entities/user.js +164 -189
  39. package/dist/events.d.ts +537 -543
  40. package/dist/events.d.ts.map +1 -1
  41. package/dist/events.js +343 -651
  42. package/dist/identity-rbac.capability.d.ts +2 -7
  43. package/dist/identity-rbac.capability.d.ts.map +1 -1
  44. package/dist/identity-rbac.capability.js +29 -29
  45. package/dist/identity-rbac.feature.d.ts +1 -6
  46. package/dist/identity-rbac.feature.d.ts.map +1 -1
  47. package/dist/identity-rbac.feature.js +66 -193
  48. package/dist/index.d.ts +6 -12
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +2100 -14
  51. package/dist/node/contracts/index.js +1045 -0
  52. package/dist/node/contracts/organization.js +655 -0
  53. package/dist/node/contracts/rbac.js +599 -0
  54. package/dist/node/contracts/user.js +235 -0
  55. package/dist/node/entities/index.js +464 -0
  56. package/dist/node/entities/organization.js +150 -0
  57. package/dist/node/entities/rbac.js +124 -0
  58. package/dist/node/entities/user.js +168 -0
  59. package/dist/node/events.js +374 -0
  60. package/dist/node/identity-rbac.capability.js +28 -0
  61. package/dist/node/identity-rbac.feature.js +67 -0
  62. package/dist/node/index.js +2099 -0
  63. package/dist/node/policies/engine.js +154 -0
  64. package/dist/node/policies/index.js +154 -0
  65. package/dist/policies/engine.d.ts +98 -101
  66. package/dist/policies/engine.d.ts.map +1 -1
  67. package/dist/policies/engine.js +151 -164
  68. package/dist/policies/index.d.ts +2 -2
  69. package/dist/policies/index.d.ts.map +1 -0
  70. package/dist/policies/index.js +154 -2
  71. package/package.json +149 -40
  72. package/dist/contracts/organization.js.map +0 -1
  73. package/dist/contracts/rbac.js.map +0 -1
  74. package/dist/contracts/user.js.map +0 -1
  75. package/dist/entities/index.js.map +0 -1
  76. package/dist/entities/organization.js.map +0 -1
  77. package/dist/entities/rbac.js.map +0 -1
  78. package/dist/entities/user.js.map +0 -1
  79. package/dist/events.js.map +0 -1
  80. package/dist/identity-rbac.capability.js.map +0 -1
  81. package/dist/identity-rbac.feature.js.map +0 -1
  82. package/dist/policies/engine.js.map +0 -1
@@ -1,194 +1,169 @@
1
+ // @bun
2
+ // src/entities/user.ts
1
3
  import { defineEntity, field, index } from "@contractspec/lib.schema";
2
-
3
- //#region src/entities/user.ts
4
- /**
5
- * User entity - core user profile and authentication.
6
- */
7
- const UserEntity = defineEntity({
8
- name: "User",
9
- description: "A user of the platform. Users hold core profile information and authenticate via Account records.",
10
- schema: "lssm_sigil",
11
- map: "user",
12
- fields: {
13
- id: field.id({ description: "Unique user identifier" }),
14
- email: field.email({
15
- isUnique: true,
16
- description: "User email address"
17
- }),
18
- emailVerified: field.boolean({
19
- default: false,
20
- description: "Whether email has been verified"
21
- }),
22
- name: field.string({
23
- isOptional: true,
24
- description: "Display name"
25
- }),
26
- firstName: field.string({
27
- isOptional: true,
28
- description: "First name"
29
- }),
30
- lastName: field.string({
31
- isOptional: true,
32
- description: "Last name"
33
- }),
34
- locale: field.string({
35
- isOptional: true,
36
- description: "User locale (e.g., \"en-US\")"
37
- }),
38
- timezone: field.string({
39
- isOptional: true,
40
- description: "Olson timezone (e.g., \"Europe/Paris\")"
41
- }),
42
- imageUrl: field.url({
43
- isOptional: true,
44
- description: "URL of avatar or profile picture"
45
- }),
46
- image: field.string({
47
- isOptional: true,
48
- description: "Legacy image field"
49
- }),
50
- metadata: field.json({
51
- isOptional: true,
52
- description: "Arbitrary user metadata"
53
- }),
54
- onboardingCompleted: field.boolean({
55
- default: false,
56
- description: "Whether onboarding is complete"
57
- }),
58
- onboardingStep: field.string({
59
- isOptional: true,
60
- description: "Current onboarding step"
61
- }),
62
- whitelistedAt: field.dateTime({
63
- isOptional: true,
64
- description: "When user was whitelisted"
65
- }),
66
- role: field.string({
67
- isOptional: true,
68
- default: "\"user\"",
69
- description: "User role (user, admin)"
70
- }),
71
- banned: field.boolean({
72
- default: false,
73
- description: "Whether user is banned"
74
- }),
75
- banReason: field.string({
76
- isOptional: true,
77
- description: "Reason for ban"
78
- }),
79
- banExpires: field.dateTime({
80
- isOptional: true,
81
- description: "When ban expires"
82
- }),
83
- phoneNumber: field.string({
84
- isOptional: true,
85
- isUnique: true,
86
- description: "Phone number"
87
- }),
88
- phoneNumberVerified: field.boolean({
89
- default: false,
90
- description: "Whether phone is verified"
91
- }),
92
- createdAt: field.createdAt(),
93
- updatedAt: field.updatedAt(),
94
- sessions: field.hasMany("Session"),
95
- accounts: field.hasMany("Account"),
96
- memberships: field.hasMany("Member"),
97
- invitations: field.hasMany("Invitation"),
98
- teamMemberships: field.hasMany("TeamMember"),
99
- policyBindings: field.hasMany("PolicyBinding"),
100
- apiKeys: field.hasMany("ApiKey"),
101
- passkeys: field.hasMany("Passkey")
102
- }
4
+ var UserEntity = defineEntity({
5
+ name: "User",
6
+ description: "A user of the platform. Users hold core profile information and authenticate via Account records.",
7
+ schema: "lssm_sigil",
8
+ map: "user",
9
+ fields: {
10
+ id: field.id({ description: "Unique user identifier" }),
11
+ email: field.email({ isUnique: true, description: "User email address" }),
12
+ emailVerified: field.boolean({
13
+ default: false,
14
+ description: "Whether email has been verified"
15
+ }),
16
+ name: field.string({ isOptional: true, description: "Display name" }),
17
+ firstName: field.string({ isOptional: true, description: "First name" }),
18
+ lastName: field.string({ isOptional: true, description: "Last name" }),
19
+ locale: field.string({
20
+ isOptional: true,
21
+ description: 'User locale (e.g., "en-US")'
22
+ }),
23
+ timezone: field.string({
24
+ isOptional: true,
25
+ description: 'Olson timezone (e.g., "Europe/Paris")'
26
+ }),
27
+ imageUrl: field.url({
28
+ isOptional: true,
29
+ description: "URL of avatar or profile picture"
30
+ }),
31
+ image: field.string({
32
+ isOptional: true,
33
+ description: "Legacy image field"
34
+ }),
35
+ metadata: field.json({
36
+ isOptional: true,
37
+ description: "Arbitrary user metadata"
38
+ }),
39
+ onboardingCompleted: field.boolean({
40
+ default: false,
41
+ description: "Whether onboarding is complete"
42
+ }),
43
+ onboardingStep: field.string({
44
+ isOptional: true,
45
+ description: "Current onboarding step"
46
+ }),
47
+ whitelistedAt: field.dateTime({
48
+ isOptional: true,
49
+ description: "When user was whitelisted"
50
+ }),
51
+ role: field.string({
52
+ isOptional: true,
53
+ default: '"user"',
54
+ description: "User role (user, admin)"
55
+ }),
56
+ banned: field.boolean({
57
+ default: false,
58
+ description: "Whether user is banned"
59
+ }),
60
+ banReason: field.string({
61
+ isOptional: true,
62
+ description: "Reason for ban"
63
+ }),
64
+ banExpires: field.dateTime({
65
+ isOptional: true,
66
+ description: "When ban expires"
67
+ }),
68
+ phoneNumber: field.string({
69
+ isOptional: true,
70
+ isUnique: true,
71
+ description: "Phone number"
72
+ }),
73
+ phoneNumberVerified: field.boolean({
74
+ default: false,
75
+ description: "Whether phone is verified"
76
+ }),
77
+ createdAt: field.createdAt(),
78
+ updatedAt: field.updatedAt(),
79
+ sessions: field.hasMany("Session"),
80
+ accounts: field.hasMany("Account"),
81
+ memberships: field.hasMany("Member"),
82
+ invitations: field.hasMany("Invitation"),
83
+ teamMemberships: field.hasMany("TeamMember"),
84
+ policyBindings: field.hasMany("PolicyBinding"),
85
+ apiKeys: field.hasMany("ApiKey"),
86
+ passkeys: field.hasMany("Passkey")
87
+ }
103
88
  });
104
- /**
105
- * Session entity - login sessions.
106
- */
107
- const SessionEntity = defineEntity({
108
- name: "Session",
109
- description: "Represents a login session (e.g., web session or API token).",
110
- schema: "lssm_sigil",
111
- map: "session",
112
- fields: {
113
- id: field.id(),
114
- userId: field.foreignKey(),
115
- expiresAt: field.dateTime({ description: "Session expiration time" }),
116
- token: field.string({
117
- isUnique: true,
118
- description: "Session token"
119
- }),
120
- ipAddress: field.string({
121
- isOptional: true,
122
- description: "Client IP address"
123
- }),
124
- userAgent: field.string({
125
- isOptional: true,
126
- description: "Client user agent"
127
- }),
128
- impersonatedBy: field.string({
129
- isOptional: true,
130
- description: "Admin impersonating this session"
131
- }),
132
- activeOrganizationId: field.string({
133
- isOptional: true,
134
- description: "Active org context"
135
- }),
136
- activeTeamId: field.string({
137
- isOptional: true,
138
- description: "Active team context"
139
- }),
140
- createdAt: field.createdAt(),
141
- updatedAt: field.updatedAt(),
142
- user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
143
- }
89
+ var SessionEntity = defineEntity({
90
+ name: "Session",
91
+ description: "Represents a login session (e.g., web session or API token).",
92
+ schema: "lssm_sigil",
93
+ map: "session",
94
+ fields: {
95
+ id: field.id(),
96
+ userId: field.foreignKey(),
97
+ expiresAt: field.dateTime({ description: "Session expiration time" }),
98
+ token: field.string({ isUnique: true, description: "Session token" }),
99
+ ipAddress: field.string({
100
+ isOptional: true,
101
+ description: "Client IP address"
102
+ }),
103
+ userAgent: field.string({
104
+ isOptional: true,
105
+ description: "Client user agent"
106
+ }),
107
+ impersonatedBy: field.string({
108
+ isOptional: true,
109
+ description: "Admin impersonating this session"
110
+ }),
111
+ activeOrganizationId: field.string({
112
+ isOptional: true,
113
+ description: "Active org context"
114
+ }),
115
+ activeTeamId: field.string({
116
+ isOptional: true,
117
+ description: "Active team context"
118
+ }),
119
+ createdAt: field.createdAt(),
120
+ updatedAt: field.updatedAt(),
121
+ user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
122
+ }
144
123
  });
145
- /**
146
- * Account entity - external authentication accounts.
147
- */
148
- const AccountEntity = defineEntity({
149
- name: "Account",
150
- description: "External authentication accounts (OAuth, password, etc.).",
151
- schema: "lssm_sigil",
152
- map: "account",
153
- fields: {
154
- id: field.id(),
155
- accountId: field.string({ description: "Account ID from provider" }),
156
- providerId: field.string({ description: "Provider identifier" }),
157
- userId: field.foreignKey(),
158
- accessToken: field.string({ isOptional: true }),
159
- refreshToken: field.string({ isOptional: true }),
160
- idToken: field.string({ isOptional: true }),
161
- accessTokenExpiresAt: field.dateTime({ isOptional: true }),
162
- refreshTokenExpiresAt: field.dateTime({ isOptional: true }),
163
- scope: field.string({ isOptional: true }),
164
- password: field.string({
165
- isOptional: true,
166
- description: "Hashed password for password providers"
167
- }),
168
- createdAt: field.createdAt(),
169
- updatedAt: field.updatedAt(),
170
- user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
171
- },
172
- indexes: [index.unique(["accountId", "providerId"])]
124
+ var AccountEntity = defineEntity({
125
+ name: "Account",
126
+ description: "External authentication accounts (OAuth, password, etc.).",
127
+ schema: "lssm_sigil",
128
+ map: "account",
129
+ fields: {
130
+ id: field.id(),
131
+ accountId: field.string({ description: "Account ID from provider" }),
132
+ providerId: field.string({ description: "Provider identifier" }),
133
+ userId: field.foreignKey(),
134
+ accessToken: field.string({ isOptional: true }),
135
+ refreshToken: field.string({ isOptional: true }),
136
+ idToken: field.string({ isOptional: true }),
137
+ accessTokenExpiresAt: field.dateTime({ isOptional: true }),
138
+ refreshTokenExpiresAt: field.dateTime({ isOptional: true }),
139
+ scope: field.string({ isOptional: true }),
140
+ password: field.string({
141
+ isOptional: true,
142
+ description: "Hashed password for password providers"
143
+ }),
144
+ createdAt: field.createdAt(),
145
+ updatedAt: field.updatedAt(),
146
+ user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
147
+ },
148
+ indexes: [index.unique(["accountId", "providerId"])]
173
149
  });
174
- /**
175
- * Verification entity - email/phone verification tokens.
176
- */
177
- const VerificationEntity = defineEntity({
178
- name: "Verification",
179
- description: "Verification tokens for email/phone confirmation.",
180
- schema: "lssm_sigil",
181
- map: "verification",
182
- fields: {
183
- id: field.uuid(),
184
- identifier: field.string({ description: "Email or phone being verified" }),
185
- value: field.string({ description: "Verification code/token" }),
186
- expiresAt: field.dateTime({ description: "Token expiration" }),
187
- createdAt: field.createdAt(),
188
- updatedAt: field.updatedAt()
189
- }
150
+ var VerificationEntity = defineEntity({
151
+ name: "Verification",
152
+ description: "Verification tokens for email/phone confirmation.",
153
+ schema: "lssm_sigil",
154
+ map: "verification",
155
+ fields: {
156
+ id: field.uuid(),
157
+ identifier: field.string({ description: "Email or phone being verified" }),
158
+ value: field.string({ description: "Verification code/token" }),
159
+ expiresAt: field.dateTime({ description: "Token expiration" }),
160
+ createdAt: field.createdAt(),
161
+ updatedAt: field.updatedAt()
162
+ }
190
163
  });
191
-
192
- //#endregion
193
- export { AccountEntity, SessionEntity, UserEntity, VerificationEntity };
194
- //# sourceMappingURL=user.js.map
164
+ export {
165
+ VerificationEntity,
166
+ UserEntity,
167
+ SessionEntity,
168
+ AccountEntity
169
+ };