@contractspec/lib.identity-rbac 1.57.0 → 1.58.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
@@ -0,0 +1,599 @@
1
+ // src/contracts/user.ts
2
+ import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
3
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
4
+ var OWNERS = ["platform.identity-rbac"];
5
+ var UserProfileModel = new SchemaModel({
6
+ name: "UserProfile",
7
+ description: "User profile information",
8
+ fields: {
9
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ email: { type: ScalarTypeEnum.EmailAddress(), isOptional: false },
11
+ emailVerified: { type: ScalarTypeEnum.Boolean(), isOptional: false },
12
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
13
+ firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
14
+ lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
15
+ locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
16
+ timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
17
+ imageUrl: { type: ScalarTypeEnum.URL(), isOptional: true },
18
+ role: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ onboardingCompleted: { type: ScalarTypeEnum.Boolean(), isOptional: false },
20
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
21
+ }
22
+ });
23
+ var CreateUserInputModel = new SchemaModel({
24
+ name: "CreateUserInput",
25
+ description: "Input for creating a new user",
26
+ fields: {
27
+ email: { type: ScalarTypeEnum.EmailAddress(), isOptional: false },
28
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
29
+ firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
30
+ lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
31
+ password: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
32
+ }
33
+ });
34
+ var UpdateUserInputModel = new SchemaModel({
35
+ name: "UpdateUserInput",
36
+ description: "Input for updating a user profile",
37
+ fields: {
38
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
39
+ firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
40
+ lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
41
+ locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
42
+ timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
43
+ imageUrl: { type: ScalarTypeEnum.URL(), isOptional: true }
44
+ }
45
+ });
46
+ var DeleteUserInputModel = new SchemaModel({
47
+ name: "DeleteUserInput",
48
+ description: "Input for deleting a user",
49
+ fields: {
50
+ confirmEmail: { type: ScalarTypeEnum.EmailAddress(), isOptional: false }
51
+ }
52
+ });
53
+ var SuccessResultModel = new SchemaModel({
54
+ name: "SuccessResult",
55
+ description: "Simple success result",
56
+ fields: {
57
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
58
+ }
59
+ });
60
+ var UserDeletedPayloadModel = new SchemaModel({
61
+ name: "UserDeletedPayload",
62
+ description: "Payload for user deleted event",
63
+ fields: {
64
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
65
+ }
66
+ });
67
+ var ListUsersInputModel = new SchemaModel({
68
+ name: "ListUsersInput",
69
+ description: "Input for listing users",
70
+ fields: {
71
+ limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
72
+ offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
73
+ search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
74
+ }
75
+ });
76
+ var ListUsersOutputModel = new SchemaModel({
77
+ name: "ListUsersOutput",
78
+ description: "Output for listing users",
79
+ fields: {
80
+ users: { type: UserProfileModel, isOptional: false, isArray: true },
81
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
82
+ }
83
+ });
84
+ var CreateUserContract = defineCommand({
85
+ meta: {
86
+ key: "identity.user.create",
87
+ version: "1.0.0",
88
+ stability: "stable",
89
+ owners: [...OWNERS],
90
+ tags: ["identity", "user", "create"],
91
+ description: "Create a new user account.",
92
+ goal: "Register a new user in the system.",
93
+ context: "Used during signup flows. May trigger email verification."
94
+ },
95
+ io: {
96
+ input: CreateUserInputModel,
97
+ output: UserProfileModel,
98
+ errors: {
99
+ EMAIL_EXISTS: {
100
+ description: "A user with this email already exists",
101
+ http: 409,
102
+ gqlCode: "EMAIL_EXISTS",
103
+ when: "Email is already registered"
104
+ }
105
+ }
106
+ },
107
+ policy: {
108
+ auth: "anonymous"
109
+ },
110
+ sideEffects: {
111
+ emits: [
112
+ {
113
+ key: "user.created",
114
+ version: "1.0.0",
115
+ when: "User is successfully created",
116
+ payload: UserProfileModel
117
+ }
118
+ ],
119
+ audit: ["user.created"]
120
+ }
121
+ });
122
+ var GetCurrentUserContract = defineQuery({
123
+ meta: {
124
+ key: "identity.user.me",
125
+ version: "1.0.0",
126
+ stability: "stable",
127
+ owners: [...OWNERS],
128
+ tags: ["identity", "user", "profile"],
129
+ description: "Get the current authenticated user profile.",
130
+ goal: "Retrieve user profile for the authenticated session.",
131
+ context: "Called on app load and after profile updates."
132
+ },
133
+ io: {
134
+ input: null,
135
+ output: UserProfileModel
136
+ },
137
+ policy: {
138
+ auth: "user"
139
+ }
140
+ });
141
+ var UpdateUserContract = defineCommand({
142
+ meta: {
143
+ key: "identity.user.update",
144
+ version: "1.0.0",
145
+ stability: "stable",
146
+ owners: [...OWNERS],
147
+ tags: ["identity", "user", "update"],
148
+ description: "Update user profile information.",
149
+ goal: "Allow users to update their profile.",
150
+ context: "Self-service profile updates."
151
+ },
152
+ io: {
153
+ input: UpdateUserInputModel,
154
+ output: UserProfileModel
155
+ },
156
+ policy: {
157
+ auth: "user"
158
+ },
159
+ sideEffects: {
160
+ emits: [
161
+ {
162
+ key: "user.updated",
163
+ version: "1.0.0",
164
+ when: "User profile is updated",
165
+ payload: UserProfileModel
166
+ }
167
+ ],
168
+ audit: ["user.updated"]
169
+ }
170
+ });
171
+ var DeleteUserContract = defineCommand({
172
+ meta: {
173
+ key: "identity.user.delete",
174
+ version: "1.0.0",
175
+ stability: "stable",
176
+ owners: [...OWNERS],
177
+ tags: ["identity", "user", "delete"],
178
+ description: "Delete user account and all associated data.",
179
+ goal: "Allow users to delete their account (GDPR compliance).",
180
+ context: "Self-service account deletion. Cascades to memberships, sessions, etc."
181
+ },
182
+ io: {
183
+ input: DeleteUserInputModel,
184
+ output: SuccessResultModel
185
+ },
186
+ policy: {
187
+ auth: "user",
188
+ escalate: "human_review"
189
+ },
190
+ sideEffects: {
191
+ emits: [
192
+ {
193
+ key: "user.deleted",
194
+ version: "1.0.0",
195
+ when: "User account is deleted",
196
+ payload: UserDeletedPayloadModel
197
+ }
198
+ ],
199
+ audit: ["user.deleted"]
200
+ }
201
+ });
202
+ var ListUsersContract = defineQuery({
203
+ meta: {
204
+ key: "identity.user.list",
205
+ version: "1.0.0",
206
+ stability: "stable",
207
+ owners: [...OWNERS],
208
+ tags: ["identity", "user", "admin", "list"],
209
+ description: "List all users (admin only).",
210
+ goal: "Allow admins to browse and manage users.",
211
+ context: "Admin dashboard user management."
212
+ },
213
+ io: {
214
+ input: ListUsersInputModel,
215
+ output: ListUsersOutputModel
216
+ },
217
+ policy: {
218
+ auth: "admin"
219
+ }
220
+ });
221
+
222
+ // src/contracts/rbac.ts
223
+ import { SchemaModel as SchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
224
+ import { defineCommand as defineCommand2, defineQuery as defineQuery2 } from "@contractspec/lib.contracts";
225
+ var RoleModel = new SchemaModel2({
226
+ name: "Role",
227
+ description: "RBAC role definition",
228
+ fields: {
229
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
230
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
231
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
232
+ permissions: {
233
+ type: ScalarTypeEnum2.String_unsecure(),
234
+ isOptional: false,
235
+ isArray: true
236
+ },
237
+ createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
238
+ }
239
+ });
240
+ var PolicyBindingModel = new SchemaModel2({
241
+ name: "PolicyBinding",
242
+ description: "Role assignment to a target",
243
+ fields: {
244
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
245
+ roleId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
246
+ targetType: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
247
+ targetId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
248
+ expiresAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
249
+ createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
250
+ role: { type: RoleModel, isOptional: false }
251
+ }
252
+ });
253
+ var PermissionCheckResultModel = new SchemaModel2({
254
+ name: "PermissionCheckResult",
255
+ description: "Result of a permission check",
256
+ fields: {
257
+ allowed: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
258
+ reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
259
+ matchedRole: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
260
+ }
261
+ });
262
+ var CreateRoleInputModel = new SchemaModel2({
263
+ name: "CreateRoleInput",
264
+ description: "Input for creating a role",
265
+ fields: {
266
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
267
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
268
+ permissions: {
269
+ type: ScalarTypeEnum2.String_unsecure(),
270
+ isOptional: false,
271
+ isArray: true
272
+ }
273
+ }
274
+ });
275
+ var UpdateRoleInputModel = new SchemaModel2({
276
+ name: "UpdateRoleInput",
277
+ description: "Input for updating a role",
278
+ fields: {
279
+ roleId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
280
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
281
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
282
+ permissions: {
283
+ type: ScalarTypeEnum2.String_unsecure(),
284
+ isOptional: true,
285
+ isArray: true
286
+ }
287
+ }
288
+ });
289
+ var DeleteRoleInputModel = new SchemaModel2({
290
+ name: "DeleteRoleInput",
291
+ description: "Input for deleting a role",
292
+ fields: {
293
+ roleId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
294
+ }
295
+ });
296
+ var ListRolesOutputModel = new SchemaModel2({
297
+ name: "ListRolesOutput",
298
+ description: "Output for listing roles",
299
+ fields: {
300
+ roles: { type: RoleModel, isOptional: false, isArray: true }
301
+ }
302
+ });
303
+ var AssignRoleInputModel = new SchemaModel2({
304
+ name: "AssignRoleInput",
305
+ description: "Input for assigning a role",
306
+ fields: {
307
+ roleId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
308
+ targetType: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
309
+ targetId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
310
+ expiresAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
311
+ }
312
+ });
313
+ var RevokeRoleInputModel = new SchemaModel2({
314
+ name: "RevokeRoleInput",
315
+ description: "Input for revoking a role",
316
+ fields: {
317
+ bindingId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
318
+ }
319
+ });
320
+ var BindingIdPayloadModel = new SchemaModel2({
321
+ name: "BindingIdPayload",
322
+ description: "Payload with binding ID",
323
+ fields: {
324
+ bindingId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
325
+ }
326
+ });
327
+ var CheckPermissionInputModel = new SchemaModel2({
328
+ name: "CheckPermissionInput",
329
+ description: "Input for checking a permission",
330
+ fields: {
331
+ userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
332
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
333
+ permission: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
334
+ }
335
+ });
336
+ var ListUserPermissionsInputModel = new SchemaModel2({
337
+ name: "ListUserPermissionsInput",
338
+ description: "Input for listing user permissions",
339
+ fields: {
340
+ userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
341
+ orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
342
+ }
343
+ });
344
+ var ListUserPermissionsOutputModel = new SchemaModel2({
345
+ name: "ListUserPermissionsOutput",
346
+ description: "Output for listing user permissions",
347
+ fields: {
348
+ permissions: {
349
+ type: ScalarTypeEnum2.String_unsecure(),
350
+ isOptional: false,
351
+ isArray: true
352
+ },
353
+ roles: { type: RoleModel, isOptional: false, isArray: true }
354
+ }
355
+ });
356
+ var CreateRoleContract = defineCommand2({
357
+ meta: {
358
+ key: "identity.rbac.role.create",
359
+ version: "1.0.0",
360
+ stability: "stable",
361
+ owners: ["@platform.identity-rbac"],
362
+ tags: ["identity", "rbac", "role", "create"],
363
+ description: "Create a new role with permissions.",
364
+ goal: "Allow admins to define custom roles.",
365
+ context: "Role management in admin settings."
366
+ },
367
+ io: {
368
+ input: CreateRoleInputModel,
369
+ output: RoleModel,
370
+ errors: {
371
+ ROLE_EXISTS: {
372
+ description: "A role with this name already exists",
373
+ http: 409,
374
+ gqlCode: "ROLE_EXISTS",
375
+ when: "Role name is taken"
376
+ }
377
+ }
378
+ },
379
+ policy: {
380
+ auth: "admin"
381
+ },
382
+ sideEffects: {
383
+ audit: ["role.created"]
384
+ }
385
+ });
386
+ var UpdateRoleContract = defineCommand2({
387
+ meta: {
388
+ key: "identity.rbac.role.update",
389
+ version: "1.0.0",
390
+ stability: "stable",
391
+ owners: ["@platform.identity-rbac"],
392
+ tags: ["identity", "rbac", "role", "update"],
393
+ description: "Update an existing role.",
394
+ goal: "Allow admins to modify role permissions.",
395
+ context: "Role management in admin settings."
396
+ },
397
+ io: {
398
+ input: UpdateRoleInputModel,
399
+ output: RoleModel
400
+ },
401
+ policy: {
402
+ auth: "admin"
403
+ },
404
+ sideEffects: {
405
+ audit: ["role.updated"]
406
+ }
407
+ });
408
+ var DeleteRoleContract = defineCommand2({
409
+ meta: {
410
+ key: "identity.rbac.role.delete",
411
+ version: "1.0.0",
412
+ stability: "stable",
413
+ owners: ["@platform.identity-rbac"],
414
+ tags: ["identity", "rbac", "role", "delete"],
415
+ description: "Delete an existing role.",
416
+ goal: "Allow admins to remove unused roles.",
417
+ context: "Role management. Removes all policy bindings using this role."
418
+ },
419
+ io: {
420
+ input: DeleteRoleInputModel,
421
+ output: SuccessResultModel,
422
+ errors: {
423
+ ROLE_IN_USE: {
424
+ description: "Role is still assigned to users or organizations",
425
+ http: 409,
426
+ gqlCode: "ROLE_IN_USE",
427
+ when: "Role has active bindings"
428
+ }
429
+ }
430
+ },
431
+ policy: {
432
+ auth: "admin"
433
+ },
434
+ sideEffects: {
435
+ audit: ["role.deleted"]
436
+ }
437
+ });
438
+ var ListRolesContract = defineQuery2({
439
+ meta: {
440
+ key: "identity.rbac.role.list",
441
+ version: "1.0.0",
442
+ stability: "stable",
443
+ owners: ["@platform.identity-rbac"],
444
+ tags: ["identity", "rbac", "role", "list"],
445
+ description: "List all available roles.",
446
+ goal: "Show available roles for assignment.",
447
+ context: "Role assignment UI."
448
+ },
449
+ io: {
450
+ input: null,
451
+ output: ListRolesOutputModel
452
+ },
453
+ policy: {
454
+ auth: "user"
455
+ }
456
+ });
457
+ var AssignRoleContract = defineCommand2({
458
+ meta: {
459
+ key: "identity.rbac.assign",
460
+ version: "1.0.0",
461
+ stability: "stable",
462
+ owners: ["@platform.identity-rbac"],
463
+ tags: ["identity", "rbac", "assign"],
464
+ description: "Assign a role to a user or organization.",
465
+ goal: "Grant permissions via role assignment.",
466
+ context: "User/org permission management."
467
+ },
468
+ io: {
469
+ input: AssignRoleInputModel,
470
+ output: PolicyBindingModel,
471
+ errors: {
472
+ ROLE_NOT_FOUND: {
473
+ description: "The specified role does not exist",
474
+ http: 404,
475
+ gqlCode: "ROLE_NOT_FOUND",
476
+ when: "Role ID is invalid"
477
+ },
478
+ ALREADY_ASSIGNED: {
479
+ description: "This role is already assigned to the target",
480
+ http: 409,
481
+ gqlCode: "ALREADY_ASSIGNED",
482
+ when: "Binding already exists"
483
+ }
484
+ }
485
+ },
486
+ policy: {
487
+ auth: "admin"
488
+ },
489
+ sideEffects: {
490
+ emits: [
491
+ {
492
+ key: "role.assigned",
493
+ version: "1.0.0",
494
+ when: "Role is assigned",
495
+ payload: PolicyBindingModel
496
+ }
497
+ ],
498
+ audit: ["role.assigned"]
499
+ }
500
+ });
501
+ var RevokeRoleContract = defineCommand2({
502
+ meta: {
503
+ key: "identity.rbac.revoke",
504
+ version: "1.0.0",
505
+ stability: "stable",
506
+ owners: ["@platform.identity-rbac"],
507
+ tags: ["identity", "rbac", "revoke"],
508
+ description: "Revoke a role from a user or organization.",
509
+ goal: "Remove permissions via role revocation.",
510
+ context: "User/org permission management."
511
+ },
512
+ io: {
513
+ input: RevokeRoleInputModel,
514
+ output: SuccessResultModel,
515
+ errors: {
516
+ BINDING_NOT_FOUND: {
517
+ description: "The policy binding does not exist",
518
+ http: 404,
519
+ gqlCode: "BINDING_NOT_FOUND",
520
+ when: "Binding ID is invalid"
521
+ }
522
+ }
523
+ },
524
+ policy: {
525
+ auth: "admin"
526
+ },
527
+ sideEffects: {
528
+ emits: [
529
+ {
530
+ key: "role.revoked",
531
+ version: "1.0.0",
532
+ when: "Role is revoked",
533
+ payload: BindingIdPayloadModel
534
+ }
535
+ ],
536
+ audit: ["role.revoked"]
537
+ }
538
+ });
539
+ var CheckPermissionContract = defineQuery2({
540
+ meta: {
541
+ key: "identity.rbac.check",
542
+ version: "1.0.0",
543
+ stability: "stable",
544
+ owners: ["@platform.identity-rbac"],
545
+ tags: ["identity", "rbac", "check", "permission"],
546
+ description: "Check if a user has a specific permission.",
547
+ goal: "Authorization check before sensitive operations.",
548
+ context: "Called by other services to verify permissions."
549
+ },
550
+ io: {
551
+ input: CheckPermissionInputModel,
552
+ output: PermissionCheckResultModel
553
+ },
554
+ policy: {
555
+ auth: "user"
556
+ }
557
+ });
558
+ var ListUserPermissionsContract = defineQuery2({
559
+ meta: {
560
+ key: "identity.rbac.permissions",
561
+ version: "1.0.0",
562
+ stability: "stable",
563
+ owners: ["@platform.identity-rbac"],
564
+ tags: ["identity", "rbac", "permissions", "user"],
565
+ description: "List all permissions for a user in a context.",
566
+ goal: "Show what a user can do in an org.",
567
+ context: "UI permission display, debugging."
568
+ },
569
+ io: {
570
+ input: ListUserPermissionsInputModel,
571
+ output: ListUserPermissionsOutputModel
572
+ },
573
+ policy: {
574
+ auth: "user"
575
+ }
576
+ });
577
+ export {
578
+ UpdateRoleInputModel,
579
+ UpdateRoleContract,
580
+ RoleModel,
581
+ RevokeRoleInputModel,
582
+ RevokeRoleContract,
583
+ PolicyBindingModel,
584
+ PermissionCheckResultModel,
585
+ ListUserPermissionsOutputModel,
586
+ ListUserPermissionsInputModel,
587
+ ListUserPermissionsContract,
588
+ ListRolesOutputModel,
589
+ ListRolesContract,
590
+ DeleteRoleInputModel,
591
+ DeleteRoleContract,
592
+ CreateRoleInputModel,
593
+ CreateRoleContract,
594
+ CheckPermissionInputModel,
595
+ CheckPermissionContract,
596
+ BindingIdPayloadModel,
597
+ AssignRoleInputModel,
598
+ AssignRoleContract
599
+ };