@contractspec/lib.identity-rbac 3.7.17 → 3.7.18

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 (43) hide show
  1. package/dist/browser/contracts/index.js +1 -1045
  2. package/dist/browser/contracts/organization.js +1 -655
  3. package/dist/browser/contracts/rbac.js +1 -599
  4. package/dist/browser/contracts/user.js +1 -235
  5. package/dist/browser/entities/index.js +1 -464
  6. package/dist/browser/entities/organization.js +1 -150
  7. package/dist/browser/entities/rbac.js +1 -124
  8. package/dist/browser/entities/user.js +1 -168
  9. package/dist/browser/events.js +1 -374
  10. package/dist/browser/identity-rbac.capability.js +1 -31
  11. package/dist/browser/identity-rbac.feature.js +1 -67
  12. package/dist/browser/index.js +1 -2099
  13. package/dist/browser/policies/engine.js +1 -154
  14. package/dist/browser/policies/index.js +1 -154
  15. package/dist/contracts/index.js +1 -1045
  16. package/dist/contracts/organization.js +1 -655
  17. package/dist/contracts/rbac.js +1 -599
  18. package/dist/contracts/user.js +1 -235
  19. package/dist/entities/index.js +1 -464
  20. package/dist/entities/organization.js +1 -150
  21. package/dist/entities/rbac.js +1 -124
  22. package/dist/entities/user.js +1 -168
  23. package/dist/events.js +1 -374
  24. package/dist/identity-rbac.capability.js +1 -31
  25. package/dist/identity-rbac.feature.js +1 -67
  26. package/dist/index.js +1 -2099
  27. package/dist/node/contracts/index.js +1 -1045
  28. package/dist/node/contracts/organization.js +1 -655
  29. package/dist/node/contracts/rbac.js +1 -599
  30. package/dist/node/contracts/user.js +1 -235
  31. package/dist/node/entities/index.js +1 -464
  32. package/dist/node/entities/organization.js +1 -150
  33. package/dist/node/entities/rbac.js +1 -124
  34. package/dist/node/entities/user.js +1 -168
  35. package/dist/node/events.js +1 -374
  36. package/dist/node/identity-rbac.capability.js +1 -31
  37. package/dist/node/identity-rbac.feature.js +1 -67
  38. package/dist/node/index.js +1 -2099
  39. package/dist/node/policies/engine.js +1 -154
  40. package/dist/node/policies/index.js +1 -154
  41. package/dist/policies/engine.js +1 -154
  42. package/dist/policies/index.js +1 -154
  43. package/package.json +5 -5
@@ -1,236 +1,2 @@
1
1
  // @bun
2
- // src/contracts/user.ts
3
- import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
4
- import { ScalarTypeEnum, SchemaModel } from "@contractspec/lib.schema";
5
- var OWNERS = ["platform.identity-rbac"];
6
- var UserProfileModel = new SchemaModel({
7
- name: "UserProfile",
8
- description: "User profile information",
9
- fields: {
10
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
- email: { type: ScalarTypeEnum.EmailAddress(), isOptional: false },
12
- emailVerified: { type: ScalarTypeEnum.Boolean(), isOptional: false },
13
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
14
- firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
15
- lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
16
- locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
17
- timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
- imageUrl: { type: ScalarTypeEnum.URL(), isOptional: true },
19
- role: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
20
- onboardingCompleted: { type: ScalarTypeEnum.Boolean(), isOptional: false },
21
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
22
- }
23
- });
24
- var CreateUserInputModel = new SchemaModel({
25
- name: "CreateUserInput",
26
- description: "Input for creating a new user",
27
- fields: {
28
- email: { type: ScalarTypeEnum.EmailAddress(), isOptional: false },
29
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
30
- firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
31
- lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
32
- password: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
33
- }
34
- });
35
- var UpdateUserInputModel = new SchemaModel({
36
- name: "UpdateUserInput",
37
- description: "Input for updating a user profile",
38
- fields: {
39
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
40
- firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
41
- lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
42
- locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
43
- timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
44
- imageUrl: { type: ScalarTypeEnum.URL(), isOptional: true }
45
- }
46
- });
47
- var DeleteUserInputModel = new SchemaModel({
48
- name: "DeleteUserInput",
49
- description: "Input for deleting a user",
50
- fields: {
51
- confirmEmail: { type: ScalarTypeEnum.EmailAddress(), isOptional: false }
52
- }
53
- });
54
- var SuccessResultModel = new SchemaModel({
55
- name: "SuccessResult",
56
- description: "Simple success result",
57
- fields: {
58
- success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
59
- }
60
- });
61
- var UserDeletedPayloadModel = new SchemaModel({
62
- name: "UserDeletedPayload",
63
- description: "Payload for user deleted event",
64
- fields: {
65
- userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
66
- }
67
- });
68
- var ListUsersInputModel = new SchemaModel({
69
- name: "ListUsersInput",
70
- description: "Input for listing users",
71
- fields: {
72
- limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
73
- offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
74
- search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
75
- }
76
- });
77
- var ListUsersOutputModel = new SchemaModel({
78
- name: "ListUsersOutput",
79
- description: "Output for listing users",
80
- fields: {
81
- users: { type: UserProfileModel, isOptional: false, isArray: true },
82
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
83
- }
84
- });
85
- var CreateUserContract = defineCommand({
86
- meta: {
87
- key: "identity.user.create",
88
- version: "1.0.0",
89
- stability: "stable",
90
- owners: [...OWNERS],
91
- tags: ["identity", "user", "create"],
92
- description: "Create a new user account.",
93
- goal: "Register a new user in the system.",
94
- context: "Used during signup flows. May trigger email verification."
95
- },
96
- io: {
97
- input: CreateUserInputModel,
98
- output: UserProfileModel,
99
- errors: {
100
- EMAIL_EXISTS: {
101
- description: "A user with this email already exists",
102
- http: 409,
103
- gqlCode: "EMAIL_EXISTS",
104
- when: "Email is already registered"
105
- }
106
- }
107
- },
108
- policy: {
109
- auth: "anonymous"
110
- },
111
- sideEffects: {
112
- emits: [
113
- {
114
- key: "user.created",
115
- version: "1.0.0",
116
- when: "User is successfully created",
117
- payload: UserProfileModel
118
- }
119
- ],
120
- audit: ["user.created"]
121
- }
122
- });
123
- var GetCurrentUserContract = defineQuery({
124
- meta: {
125
- key: "identity.user.me",
126
- version: "1.0.0",
127
- stability: "stable",
128
- owners: [...OWNERS],
129
- tags: ["identity", "user", "profile"],
130
- description: "Get the current authenticated user profile.",
131
- goal: "Retrieve user profile for the authenticated session.",
132
- context: "Called on app load and after profile updates."
133
- },
134
- io: {
135
- input: null,
136
- output: UserProfileModel
137
- },
138
- policy: {
139
- auth: "user"
140
- }
141
- });
142
- var UpdateUserContract = defineCommand({
143
- meta: {
144
- key: "identity.user.update",
145
- version: "1.0.0",
146
- stability: "stable",
147
- owners: [...OWNERS],
148
- tags: ["identity", "user", "update"],
149
- description: "Update user profile information.",
150
- goal: "Allow users to update their profile.",
151
- context: "Self-service profile updates."
152
- },
153
- io: {
154
- input: UpdateUserInputModel,
155
- output: UserProfileModel
156
- },
157
- policy: {
158
- auth: "user"
159
- },
160
- sideEffects: {
161
- emits: [
162
- {
163
- key: "user.updated",
164
- version: "1.0.0",
165
- when: "User profile is updated",
166
- payload: UserProfileModel
167
- }
168
- ],
169
- audit: ["user.updated"]
170
- }
171
- });
172
- var DeleteUserContract = defineCommand({
173
- meta: {
174
- key: "identity.user.delete",
175
- version: "1.0.0",
176
- stability: "stable",
177
- owners: [...OWNERS],
178
- tags: ["identity", "user", "delete"],
179
- description: "Delete user account and all associated data.",
180
- goal: "Allow users to delete their account (GDPR compliance).",
181
- context: "Self-service account deletion. Cascades to memberships, sessions, etc."
182
- },
183
- io: {
184
- input: DeleteUserInputModel,
185
- output: SuccessResultModel
186
- },
187
- policy: {
188
- auth: "user",
189
- escalate: "human_review"
190
- },
191
- sideEffects: {
192
- emits: [
193
- {
194
- key: "user.deleted",
195
- version: "1.0.0",
196
- when: "User account is deleted",
197
- payload: UserDeletedPayloadModel
198
- }
199
- ],
200
- audit: ["user.deleted"]
201
- }
202
- });
203
- var ListUsersContract = defineQuery({
204
- meta: {
205
- key: "identity.user.list",
206
- version: "1.0.0",
207
- stability: "stable",
208
- owners: [...OWNERS],
209
- tags: ["identity", "user", "admin", "list"],
210
- description: "List all users (admin only).",
211
- goal: "Allow admins to browse and manage users.",
212
- context: "Admin dashboard user management."
213
- },
214
- io: {
215
- input: ListUsersInputModel,
216
- output: ListUsersOutputModel
217
- },
218
- policy: {
219
- auth: "admin"
220
- }
221
- });
222
- export {
223
- UserProfileModel,
224
- UserDeletedPayloadModel,
225
- UpdateUserInputModel,
226
- UpdateUserContract,
227
- SuccessResultModel,
228
- ListUsersOutputModel,
229
- ListUsersInputModel,
230
- ListUsersContract,
231
- GetCurrentUserContract,
232
- DeleteUserInputModel,
233
- DeleteUserContract,
234
- CreateUserInputModel,
235
- CreateUserContract
236
- };
2
+ import{defineCommand as v,defineQuery as w}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as g,SchemaModel as j}from"@contractspec/lib.schema";var q=["platform.identity-rbac"],k=new j({name:"UserProfile",description:"User profile information",fields:{id:{type:g.String_unsecure(),isOptional:!1},email:{type:g.EmailAddress(),isOptional:!1},emailVerified:{type:g.Boolean(),isOptional:!1},name:{type:g.String_unsecure(),isOptional:!0},firstName:{type:g.String_unsecure(),isOptional:!0},lastName:{type:g.String_unsecure(),isOptional:!0},locale:{type:g.String_unsecure(),isOptional:!0},timezone:{type:g.String_unsecure(),isOptional:!0},imageUrl:{type:g.URL(),isOptional:!0},role:{type:g.String_unsecure(),isOptional:!0},onboardingCompleted:{type:g.Boolean(),isOptional:!1},createdAt:{type:g.DateTime(),isOptional:!1}}}),x=new j({name:"CreateUserInput",description:"Input for creating a new user",fields:{email:{type:g.EmailAddress(),isOptional:!1},name:{type:g.String_unsecure(),isOptional:!0},firstName:{type:g.String_unsecure(),isOptional:!0},lastName:{type:g.String_unsecure(),isOptional:!0},password:{type:g.String_unsecure(),isOptional:!0}}}),z=new j({name:"UpdateUserInput",description:"Input for updating a user profile",fields:{name:{type:g.String_unsecure(),isOptional:!0},firstName:{type:g.String_unsecure(),isOptional:!0},lastName:{type:g.String_unsecure(),isOptional:!0},locale:{type:g.String_unsecure(),isOptional:!0},timezone:{type:g.String_unsecure(),isOptional:!0},imageUrl:{type:g.URL(),isOptional:!0}}}),A=new j({name:"DeleteUserInput",description:"Input for deleting a user",fields:{confirmEmail:{type:g.EmailAddress(),isOptional:!1}}}),B=new j({name:"SuccessResult",description:"Simple success result",fields:{success:{type:g.Boolean(),isOptional:!1}}}),F=new j({name:"UserDeletedPayload",description:"Payload for user deleted event",fields:{userId:{type:g.String_unsecure(),isOptional:!1}}}),G=new j({name:"ListUsersInput",description:"Input for listing users",fields:{limit:{type:g.Int_unsecure(),isOptional:!0},offset:{type:g.Int_unsecure(),isOptional:!0},search:{type:g.String_unsecure(),isOptional:!0}}}),H=new j({name:"ListUsersOutput",description:"Output for listing users",fields:{users:{type:k,isOptional:!1,isArray:!0},total:{type:g.Int_unsecure(),isOptional:!1}}}),V=v({meta:{key:"identity.user.create",version:"1.0.0",stability:"stable",owners:[...q],tags:["identity","user","create"],description:"Create a new user account.",goal:"Register a new user in the system.",context:"Used during signup flows. May trigger email verification."},io:{input:x,output:k,errors:{EMAIL_EXISTS:{description:"A user with this email already exists",http:409,gqlCode:"EMAIL_EXISTS",when:"Email is already registered"}}},policy:{auth:"anonymous"},sideEffects:{emits:[{key:"user.created",version:"1.0.0",when:"User is successfully created",payload:k}],audit:["user.created"]}}),X=w({meta:{key:"identity.user.me",version:"1.0.0",stability:"stable",owners:[...q],tags:["identity","user","profile"],description:"Get the current authenticated user profile.",goal:"Retrieve user profile for the authenticated session.",context:"Called on app load and after profile updates."},io:{input:null,output:k},policy:{auth:"user"}}),Y=v({meta:{key:"identity.user.update",version:"1.0.0",stability:"stable",owners:[...q],tags:["identity","user","update"],description:"Update user profile information.",goal:"Allow users to update their profile.",context:"Self-service profile updates."},io:{input:z,output:k},policy:{auth:"user"},sideEffects:{emits:[{key:"user.updated",version:"1.0.0",when:"User profile is updated",payload:k}],audit:["user.updated"]}}),Z=v({meta:{key:"identity.user.delete",version:"1.0.0",stability:"stable",owners:[...q],tags:["identity","user","delete"],description:"Delete user account and all associated data.",goal:"Allow users to delete their account (GDPR compliance).",context:"Self-service account deletion. Cascades to memberships, sessions, etc."},io:{input:A,output:B},policy:{auth:"user",escalate:"human_review"},sideEffects:{emits:[{key:"user.deleted",version:"1.0.0",when:"User account is deleted",payload:F}],audit:["user.deleted"]}}),_=w({meta:{key:"identity.user.list",version:"1.0.0",stability:"stable",owners:[...q],tags:["identity","user","admin","list"],description:"List all users (admin only).",goal:"Allow admins to browse and manage users.",context:"Admin dashboard user management."},io:{input:G,output:H},policy:{auth:"admin"}});export{k as UserProfileModel,F as UserDeletedPayloadModel,z as UpdateUserInputModel,Y as UpdateUserContract,B as SuccessResultModel,H as ListUsersOutputModel,G as ListUsersInputModel,_ as ListUsersContract,X as GetCurrentUserContract,A as DeleteUserInputModel,Z as DeleteUserContract,x as CreateUserInputModel,V as CreateUserContract};