@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.
- package/dist/browser/contracts/index.js +1 -1045
- package/dist/browser/contracts/organization.js +1 -655
- package/dist/browser/contracts/rbac.js +1 -599
- package/dist/browser/contracts/user.js +1 -235
- package/dist/browser/entities/index.js +1 -464
- package/dist/browser/entities/organization.js +1 -150
- package/dist/browser/entities/rbac.js +1 -124
- package/dist/browser/entities/user.js +1 -168
- package/dist/browser/events.js +1 -374
- package/dist/browser/identity-rbac.capability.js +1 -31
- package/dist/browser/identity-rbac.feature.js +1 -67
- package/dist/browser/index.js +1 -2099
- package/dist/browser/policies/engine.js +1 -154
- package/dist/browser/policies/index.js +1 -154
- package/dist/contracts/index.js +1 -1045
- package/dist/contracts/organization.js +1 -655
- package/dist/contracts/rbac.js +1 -599
- package/dist/contracts/user.js +1 -235
- package/dist/entities/index.js +1 -464
- package/dist/entities/organization.js +1 -150
- package/dist/entities/rbac.js +1 -124
- package/dist/entities/user.js +1 -168
- package/dist/events.js +1 -374
- package/dist/identity-rbac.capability.js +1 -31
- package/dist/identity-rbac.feature.js +1 -67
- package/dist/index.js +1 -2099
- package/dist/node/contracts/index.js +1 -1045
- package/dist/node/contracts/organization.js +1 -655
- package/dist/node/contracts/rbac.js +1 -599
- package/dist/node/contracts/user.js +1 -235
- package/dist/node/entities/index.js +1 -464
- package/dist/node/entities/organization.js +1 -150
- package/dist/node/entities/rbac.js +1 -124
- package/dist/node/entities/user.js +1 -168
- package/dist/node/events.js +1 -374
- package/dist/node/identity-rbac.capability.js +1 -31
- package/dist/node/identity-rbac.feature.js +1 -67
- package/dist/node/index.js +1 -2099
- package/dist/node/policies/engine.js +1 -154
- package/dist/node/policies/index.js +1 -154
- package/dist/policies/engine.js +1 -154
- package/dist/policies/index.js +1 -154
- package/package.json +5 -5
|
@@ -1,599 +1 @@
|
|
|
1
|
-
// src/contracts/user.ts
|
|
2
|
-
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
3
|
-
import { ScalarTypeEnum, SchemaModel } from "@contractspec/lib.schema";
|
|
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 { defineCommand as defineCommand2, defineQuery as defineQuery2 } from "@contractspec/lib.contracts-spec";
|
|
224
|
-
import { ScalarTypeEnum as ScalarTypeEnum2, SchemaModel as SchemaModel2 } from "@contractspec/lib.schema";
|
|
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
|
-
};
|
|
1
|
+
import{defineCommand as K,defineQuery as X}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as q,SchemaModel as x}from"@contractspec/lib.schema";var F=["platform.identity-rbac"],z=new x({name:"UserProfile",description:"User profile information",fields:{id:{type:q.String_unsecure(),isOptional:!1},email:{type:q.EmailAddress(),isOptional:!1},emailVerified:{type:q.Boolean(),isOptional:!1},name:{type:q.String_unsecure(),isOptional:!0},firstName:{type:q.String_unsecure(),isOptional:!0},lastName:{type:q.String_unsecure(),isOptional:!0},locale:{type:q.String_unsecure(),isOptional:!0},timezone:{type:q.String_unsecure(),isOptional:!0},imageUrl:{type:q.URL(),isOptional:!0},role:{type:q.String_unsecure(),isOptional:!0},onboardingCompleted:{type:q.Boolean(),isOptional:!1},createdAt:{type:q.DateTime(),isOptional:!1}}}),Z=new x({name:"CreateUserInput",description:"Input for creating a new user",fields:{email:{type:q.EmailAddress(),isOptional:!1},name:{type:q.String_unsecure(),isOptional:!0},firstName:{type:q.String_unsecure(),isOptional:!0},lastName:{type:q.String_unsecure(),isOptional:!0},password:{type:q.String_unsecure(),isOptional:!0}}}),_=new x({name:"UpdateUserInput",description:"Input for updating a user profile",fields:{name:{type:q.String_unsecure(),isOptional:!0},firstName:{type:q.String_unsecure(),isOptional:!0},lastName:{type:q.String_unsecure(),isOptional:!0},locale:{type:q.String_unsecure(),isOptional:!0},timezone:{type:q.String_unsecure(),isOptional:!0},imageUrl:{type:q.URL(),isOptional:!0}}}),$=new x({name:"DeleteUserInput",description:"Input for deleting a user",fields:{confirmEmail:{type:q.EmailAddress(),isOptional:!1}}}),J=new x({name:"SuccessResult",description:"Simple success result",fields:{success:{type:q.Boolean(),isOptional:!1}}}),v=new x({name:"UserDeletedPayload",description:"Payload for user deleted event",fields:{userId:{type:q.String_unsecure(),isOptional:!1}}}),A=new x({name:"ListUsersInput",description:"Input for listing users",fields:{limit:{type:q.Int_unsecure(),isOptional:!0},offset:{type:q.Int_unsecure(),isOptional:!0},search:{type:q.String_unsecure(),isOptional:!0}}}),k=new x({name:"ListUsersOutput",description:"Output for listing users",fields:{users:{type:z,isOptional:!1,isArray:!0},total:{type:q.Int_unsecure(),isOptional:!1}}}),f=K({meta:{key:"identity.user.create",version:"1.0.0",stability:"stable",owners:[...F],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:Z,output:z,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:z}],audit:["user.created"]}}),R=X({meta:{key:"identity.user.me",version:"1.0.0",stability:"stable",owners:[...F],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:z},policy:{auth:"user"}}),h=K({meta:{key:"identity.user.update",version:"1.0.0",stability:"stable",owners:[...F],tags:["identity","user","update"],description:"Update user profile information.",goal:"Allow users to update their profile.",context:"Self-service profile updates."},io:{input:_,output:z},policy:{auth:"user"},sideEffects:{emits:[{key:"user.updated",version:"1.0.0",when:"User profile is updated",payload:z}],audit:["user.updated"]}}),i=K({meta:{key:"identity.user.delete",version:"1.0.0",stability:"stable",owners:[...F],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:$,output:J},policy:{auth:"user",escalate:"human_review"},sideEffects:{emits:[{key:"user.deleted",version:"1.0.0",when:"User account is deleted",payload:v}],audit:["user.deleted"]}}),t=X({meta:{key:"identity.user.list",version:"1.0.0",stability:"stable",owners:[...F],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:A,output:k},policy:{auth:"admin"}});import{defineCommand as G,defineQuery as V}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as j,SchemaModel as w}from"@contractspec/lib.schema";var H=new w({name:"Role",description:"RBAC role definition",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!0},permissions:{type:j.String_unsecure(),isOptional:!1,isArray:!0},createdAt:{type:j.DateTime(),isOptional:!1}}}),Y=new w({name:"PolicyBinding",description:"Role assignment to a target",fields:{id:{type:j.String_unsecure(),isOptional:!1},roleId:{type:j.String_unsecure(),isOptional:!1},targetType:{type:j.String_unsecure(),isOptional:!1},targetId:{type:j.String_unsecure(),isOptional:!1},expiresAt:{type:j.DateTime(),isOptional:!0},createdAt:{type:j.DateTime(),isOptional:!1},role:{type:H,isOptional:!1}}}),B=new w({name:"PermissionCheckResult",description:"Result of a permission check",fields:{allowed:{type:j.Boolean(),isOptional:!1},reason:{type:j.String_unsecure(),isOptional:!0},matchedRole:{type:j.String_unsecure(),isOptional:!0}}}),D=new w({name:"CreateRoleInput",description:"Input for creating a role",fields:{name:{type:j.NonEmptyString(),isOptional:!1},description:{type:j.String_unsecure(),isOptional:!0},permissions:{type:j.String_unsecure(),isOptional:!1,isArray:!0}}}),b=new w({name:"UpdateRoleInput",description:"Input for updating a role",fields:{roleId:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!0},description:{type:j.String_unsecure(),isOptional:!0},permissions:{type:j.String_unsecure(),isOptional:!0,isArray:!0}}}),g=new w({name:"DeleteRoleInput",description:"Input for deleting a role",fields:{roleId:{type:j.String_unsecure(),isOptional:!1}}}),L=new w({name:"ListRolesOutput",description:"Output for listing roles",fields:{roles:{type:H,isOptional:!1,isArray:!0}}}),N=new w({name:"AssignRoleInput",description:"Input for assigning a role",fields:{roleId:{type:j.String_unsecure(),isOptional:!1},targetType:{type:j.String_unsecure(),isOptional:!1},targetId:{type:j.String_unsecure(),isOptional:!1},expiresAt:{type:j.DateTime(),isOptional:!0}}}),Q=new w({name:"RevokeRoleInput",description:"Input for revoking a role",fields:{bindingId:{type:j.String_unsecure(),isOptional:!1}}}),W=new w({name:"BindingIdPayload",description:"Payload with binding ID",fields:{bindingId:{type:j.String_unsecure(),isOptional:!1}}}),O=new w({name:"CheckPermissionInput",description:"Input for checking a permission",fields:{userId:{type:j.String_unsecure(),isOptional:!1},orgId:{type:j.String_unsecure(),isOptional:!0},permission:{type:j.String_unsecure(),isOptional:!1}}}),C=new w({name:"ListUserPermissionsInput",description:"Input for listing user permissions",fields:{userId:{type:j.String_unsecure(),isOptional:!1},orgId:{type:j.String_unsecure(),isOptional:!0}}}),I=new w({name:"ListUserPermissionsOutput",description:"Output for listing user permissions",fields:{permissions:{type:j.String_unsecure(),isOptional:!1,isArray:!0},roles:{type:H,isOptional:!1,isArray:!0}}}),y=G({meta:{key:"identity.rbac.role.create",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","role","create"],description:"Create a new role with permissions.",goal:"Allow admins to define custom roles.",context:"Role management in admin settings."},io:{input:D,output:H,errors:{ROLE_EXISTS:{description:"A role with this name already exists",http:409,gqlCode:"ROLE_EXISTS",when:"Role name is taken"}}},policy:{auth:"admin"},sideEffects:{audit:["role.created"]}}),d=G({meta:{key:"identity.rbac.role.update",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","role","update"],description:"Update an existing role.",goal:"Allow admins to modify role permissions.",context:"Role management in admin settings."},io:{input:b,output:H},policy:{auth:"admin"},sideEffects:{audit:["role.updated"]}}),p=G({meta:{key:"identity.rbac.role.delete",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","role","delete"],description:"Delete an existing role.",goal:"Allow admins to remove unused roles.",context:"Role management. Removes all policy bindings using this role."},io:{input:g,output:J,errors:{ROLE_IN_USE:{description:"Role is still assigned to users or organizations",http:409,gqlCode:"ROLE_IN_USE",when:"Role has active bindings"}}},policy:{auth:"admin"},sideEffects:{audit:["role.deleted"]}}),S=V({meta:{key:"identity.rbac.role.list",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","role","list"],description:"List all available roles.",goal:"Show available roles for assignment.",context:"Role assignment UI."},io:{input:null,output:L},policy:{auth:"user"}}),o=G({meta:{key:"identity.rbac.assign",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","assign"],description:"Assign a role to a user or organization.",goal:"Grant permissions via role assignment.",context:"User/org permission management."},io:{input:N,output:Y,errors:{ROLE_NOT_FOUND:{description:"The specified role does not exist",http:404,gqlCode:"ROLE_NOT_FOUND",when:"Role ID is invalid"},ALREADY_ASSIGNED:{description:"This role is already assigned to the target",http:409,gqlCode:"ALREADY_ASSIGNED",when:"Binding already exists"}}},policy:{auth:"admin"},sideEffects:{emits:[{key:"role.assigned",version:"1.0.0",when:"Role is assigned",payload:Y}],audit:["role.assigned"]}}),u=G({meta:{key:"identity.rbac.revoke",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","revoke"],description:"Revoke a role from a user or organization.",goal:"Remove permissions via role revocation.",context:"User/org permission management."},io:{input:Q,output:J,errors:{BINDING_NOT_FOUND:{description:"The policy binding does not exist",http:404,gqlCode:"BINDING_NOT_FOUND",when:"Binding ID is invalid"}}},policy:{auth:"admin"},sideEffects:{emits:[{key:"role.revoked",version:"1.0.0",when:"Role is revoked",payload:W}],audit:["role.revoked"]}}),r=V({meta:{key:"identity.rbac.check",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","check","permission"],description:"Check if a user has a specific permission.",goal:"Authorization check before sensitive operations.",context:"Called by other services to verify permissions."},io:{input:O,output:B},policy:{auth:"user"}}),m=V({meta:{key:"identity.rbac.permissions",version:"1.0.0",stability:"stable",owners:["@platform.identity-rbac"],tags:["identity","rbac","permissions","user"],description:"List all permissions for a user in a context.",goal:"Show what a user can do in an org.",context:"UI permission display, debugging."},io:{input:C,output:I},policy:{auth:"user"}});export{b as UpdateRoleInputModel,d as UpdateRoleContract,H as RoleModel,Q as RevokeRoleInputModel,u as RevokeRoleContract,Y as PolicyBindingModel,B as PermissionCheckResultModel,I as ListUserPermissionsOutputModel,C as ListUserPermissionsInputModel,m as ListUserPermissionsContract,L as ListRolesOutputModel,S as ListRolesContract,g as DeleteRoleInputModel,p as DeleteRoleContract,D as CreateRoleInputModel,y as CreateRoleContract,O as CheckPermissionInputModel,r as CheckPermissionContract,W as BindingIdPayloadModel,N as AssignRoleInputModel,o as AssignRoleContract};
|