@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,1045 +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/organization.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 OWNERS2 = ["platform.identity-rbac"];
|
|
226
|
-
var OrganizationModel = new SchemaModel2({
|
|
227
|
-
name: "Organization",
|
|
228
|
-
description: "Organization details",
|
|
229
|
-
fields: {
|
|
230
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
231
|
-
name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
232
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
233
|
-
logo: { type: ScalarTypeEnum2.URL(), isOptional: true },
|
|
234
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
235
|
-
type: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
236
|
-
onboardingCompleted: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
237
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
var MemberUserModel = new SchemaModel2({
|
|
241
|
-
name: "MemberUser",
|
|
242
|
-
description: "Basic user info within a member",
|
|
243
|
-
fields: {
|
|
244
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
245
|
-
email: { type: ScalarTypeEnum2.EmailAddress(), isOptional: false },
|
|
246
|
-
name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
var MemberModel = new SchemaModel2({
|
|
250
|
-
name: "Member",
|
|
251
|
-
description: "Organization member",
|
|
252
|
-
fields: {
|
|
253
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
254
|
-
userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
255
|
-
organizationId: {
|
|
256
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
257
|
-
isOptional: false
|
|
258
|
-
},
|
|
259
|
-
role: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
260
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
261
|
-
user: { type: MemberUserModel, isOptional: false }
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
var InvitationModel = new SchemaModel2({
|
|
265
|
-
name: "Invitation",
|
|
266
|
-
description: "Organization invitation",
|
|
267
|
-
fields: {
|
|
268
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
269
|
-
email: { type: ScalarTypeEnum2.EmailAddress(), isOptional: false },
|
|
270
|
-
role: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
271
|
-
status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
272
|
-
expiresAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
|
|
273
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
var CreateOrgInputModel = new SchemaModel2({
|
|
277
|
-
name: "CreateOrgInput",
|
|
278
|
-
description: "Input for creating an organization",
|
|
279
|
-
fields: {
|
|
280
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
281
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
282
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
283
|
-
type: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
var GetOrgInputModel = new SchemaModel2({
|
|
287
|
-
name: "GetOrgInput",
|
|
288
|
-
description: "Input for getting an organization",
|
|
289
|
-
fields: {
|
|
290
|
-
orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
var UpdateOrgInputModel = new SchemaModel2({
|
|
294
|
-
name: "UpdateOrgInput",
|
|
295
|
-
description: "Input for updating an organization",
|
|
296
|
-
fields: {
|
|
297
|
-
orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
298
|
-
name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
299
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
300
|
-
logo: { type: ScalarTypeEnum2.URL(), isOptional: true },
|
|
301
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
var InviteMemberInputModel = new SchemaModel2({
|
|
305
|
-
name: "InviteMemberInput",
|
|
306
|
-
description: "Input for inviting a member",
|
|
307
|
-
fields: {
|
|
308
|
-
orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
309
|
-
email: { type: ScalarTypeEnum2.EmailAddress(), isOptional: false },
|
|
310
|
-
role: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
311
|
-
teamId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
var AcceptInviteInputModel = new SchemaModel2({
|
|
315
|
-
name: "AcceptInviteInput",
|
|
316
|
-
description: "Input for accepting an invitation",
|
|
317
|
-
fields: {
|
|
318
|
-
invitationId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
var RemoveMemberInputModel = new SchemaModel2({
|
|
322
|
-
name: "RemoveMemberInput",
|
|
323
|
-
description: "Input for removing a member",
|
|
324
|
-
fields: {
|
|
325
|
-
orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
326
|
-
userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
var MemberRemovedPayloadModel = new SchemaModel2({
|
|
330
|
-
name: "MemberRemovedPayload",
|
|
331
|
-
description: "Payload for member removed event",
|
|
332
|
-
fields: {
|
|
333
|
-
orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
334
|
-
userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
var ListMembersInputModel = new SchemaModel2({
|
|
338
|
-
name: "ListMembersInput",
|
|
339
|
-
description: "Input for listing members",
|
|
340
|
-
fields: {
|
|
341
|
-
orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
342
|
-
limit: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
343
|
-
offset: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true }
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
var ListMembersOutputModel = new SchemaModel2({
|
|
347
|
-
name: "ListMembersOutput",
|
|
348
|
-
description: "Output for listing members",
|
|
349
|
-
fields: {
|
|
350
|
-
members: { type: MemberModel, isOptional: false, isArray: true },
|
|
351
|
-
total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false }
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
var OrganizationWithRoleModel = new SchemaModel2({
|
|
355
|
-
name: "OrganizationWithRole",
|
|
356
|
-
description: "Organization with user role",
|
|
357
|
-
fields: {
|
|
358
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
359
|
-
name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
360
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
361
|
-
logo: { type: ScalarTypeEnum2.URL(), isOptional: true },
|
|
362
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
363
|
-
type: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
364
|
-
onboardingCompleted: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
365
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
366
|
-
role: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
var ListUserOrgsOutputModel = new SchemaModel2({
|
|
370
|
-
name: "ListUserOrgsOutput",
|
|
371
|
-
description: "Output for listing user organizations",
|
|
372
|
-
fields: {
|
|
373
|
-
organizations: {
|
|
374
|
-
type: OrganizationWithRoleModel,
|
|
375
|
-
isOptional: false,
|
|
376
|
-
isArray: true
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
var CreateOrgContract = defineCommand2({
|
|
381
|
-
meta: {
|
|
382
|
-
key: "identity.org.create",
|
|
383
|
-
version: "1.0.0",
|
|
384
|
-
stability: "stable",
|
|
385
|
-
owners: [...OWNERS2],
|
|
386
|
-
tags: ["identity", "org", "create"],
|
|
387
|
-
description: "Create a new organization.",
|
|
388
|
-
goal: "Allow users to create new organizations/workspaces.",
|
|
389
|
-
context: "Called during onboarding or when creating additional workspaces."
|
|
390
|
-
},
|
|
391
|
-
io: {
|
|
392
|
-
input: CreateOrgInputModel,
|
|
393
|
-
output: OrganizationModel,
|
|
394
|
-
errors: {
|
|
395
|
-
SLUG_EXISTS: {
|
|
396
|
-
description: "An organization with this slug already exists",
|
|
397
|
-
http: 409,
|
|
398
|
-
gqlCode: "SLUG_EXISTS",
|
|
399
|
-
when: "Slug is already taken"
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
|
-
policy: {
|
|
404
|
-
auth: "user"
|
|
405
|
-
},
|
|
406
|
-
sideEffects: {
|
|
407
|
-
emits: [
|
|
408
|
-
{
|
|
409
|
-
key: "org.created",
|
|
410
|
-
version: "1.0.0",
|
|
411
|
-
when: "Organization is created",
|
|
412
|
-
payload: OrganizationModel
|
|
413
|
-
}
|
|
414
|
-
],
|
|
415
|
-
audit: ["org.created"]
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
var GetOrgContract = defineQuery2({
|
|
419
|
-
meta: {
|
|
420
|
-
key: "identity.org.get",
|
|
421
|
-
version: "1.0.0",
|
|
422
|
-
stability: "stable",
|
|
423
|
-
owners: [...OWNERS2],
|
|
424
|
-
tags: ["identity", "org", "get"],
|
|
425
|
-
description: "Get organization details.",
|
|
426
|
-
goal: "Retrieve organization information.",
|
|
427
|
-
context: "Called when viewing organization settings or dashboard."
|
|
428
|
-
},
|
|
429
|
-
io: {
|
|
430
|
-
input: GetOrgInputModel,
|
|
431
|
-
output: OrganizationModel
|
|
432
|
-
},
|
|
433
|
-
policy: {
|
|
434
|
-
auth: "user"
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
var UpdateOrgContract = defineCommand2({
|
|
438
|
-
meta: {
|
|
439
|
-
key: "identity.org.update",
|
|
440
|
-
version: "1.0.0",
|
|
441
|
-
stability: "stable",
|
|
442
|
-
owners: [...OWNERS2],
|
|
443
|
-
tags: ["identity", "org", "update"],
|
|
444
|
-
description: "Update organization details.",
|
|
445
|
-
goal: "Allow org admins to update organization settings.",
|
|
446
|
-
context: "Organization settings page."
|
|
447
|
-
},
|
|
448
|
-
io: {
|
|
449
|
-
input: UpdateOrgInputModel,
|
|
450
|
-
output: OrganizationModel
|
|
451
|
-
},
|
|
452
|
-
policy: {
|
|
453
|
-
auth: "user"
|
|
454
|
-
},
|
|
455
|
-
sideEffects: {
|
|
456
|
-
emits: [
|
|
457
|
-
{
|
|
458
|
-
key: "org.updated",
|
|
459
|
-
version: "1.0.0",
|
|
460
|
-
when: "Organization is updated",
|
|
461
|
-
payload: OrganizationModel
|
|
462
|
-
}
|
|
463
|
-
],
|
|
464
|
-
audit: ["org.updated"]
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
var InviteMemberContract = defineCommand2({
|
|
468
|
-
meta: {
|
|
469
|
-
key: "identity.org.invite",
|
|
470
|
-
version: "1.0.0",
|
|
471
|
-
stability: "stable",
|
|
472
|
-
owners: [...OWNERS2],
|
|
473
|
-
tags: ["identity", "org", "invite", "member"],
|
|
474
|
-
description: "Invite a user to join the organization.",
|
|
475
|
-
goal: "Allow org admins to invite new members.",
|
|
476
|
-
context: "Team management. Sends invitation email."
|
|
477
|
-
},
|
|
478
|
-
io: {
|
|
479
|
-
input: InviteMemberInputModel,
|
|
480
|
-
output: InvitationModel,
|
|
481
|
-
errors: {
|
|
482
|
-
ALREADY_MEMBER: {
|
|
483
|
-
description: "User is already a member of this organization",
|
|
484
|
-
http: 409,
|
|
485
|
-
gqlCode: "ALREADY_MEMBER",
|
|
486
|
-
when: "Invitee is already a member"
|
|
487
|
-
},
|
|
488
|
-
INVITE_PENDING: {
|
|
489
|
-
description: "An invitation for this email is already pending",
|
|
490
|
-
http: 409,
|
|
491
|
-
gqlCode: "INVITE_PENDING",
|
|
492
|
-
when: "Active invitation exists"
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
policy: {
|
|
497
|
-
auth: "user"
|
|
498
|
-
},
|
|
499
|
-
sideEffects: {
|
|
500
|
-
emits: [
|
|
501
|
-
{
|
|
502
|
-
key: "org.invite.sent",
|
|
503
|
-
version: "1.0.0",
|
|
504
|
-
when: "Invitation is sent",
|
|
505
|
-
payload: InvitationModel
|
|
506
|
-
}
|
|
507
|
-
],
|
|
508
|
-
audit: ["org.invite.sent"]
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
var AcceptInviteContract = defineCommand2({
|
|
512
|
-
meta: {
|
|
513
|
-
key: "identity.org.invite.accept",
|
|
514
|
-
version: "1.0.0",
|
|
515
|
-
stability: "stable",
|
|
516
|
-
owners: [...OWNERS2],
|
|
517
|
-
tags: ["identity", "org", "invite", "accept"],
|
|
518
|
-
description: "Accept an organization invitation.",
|
|
519
|
-
goal: "Allow users to join organizations via invitation.",
|
|
520
|
-
context: "Called from invitation email link."
|
|
521
|
-
},
|
|
522
|
-
io: {
|
|
523
|
-
input: AcceptInviteInputModel,
|
|
524
|
-
output: MemberModel,
|
|
525
|
-
errors: {
|
|
526
|
-
INVITE_EXPIRED: {
|
|
527
|
-
description: "The invitation has expired",
|
|
528
|
-
http: 410,
|
|
529
|
-
gqlCode: "INVITE_EXPIRED",
|
|
530
|
-
when: "Invitation is past expiry date"
|
|
531
|
-
},
|
|
532
|
-
INVITE_USED: {
|
|
533
|
-
description: "The invitation has already been used",
|
|
534
|
-
http: 409,
|
|
535
|
-
gqlCode: "INVITE_USED",
|
|
536
|
-
when: "Invitation was already accepted"
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
},
|
|
540
|
-
policy: {
|
|
541
|
-
auth: "user"
|
|
542
|
-
},
|
|
543
|
-
sideEffects: {
|
|
544
|
-
emits: [
|
|
545
|
-
{
|
|
546
|
-
key: "org.member.added",
|
|
547
|
-
version: "1.0.0",
|
|
548
|
-
when: "Member joins org",
|
|
549
|
-
payload: MemberModel
|
|
550
|
-
}
|
|
551
|
-
],
|
|
552
|
-
audit: ["org.member.added"]
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
var RemoveMemberContract = defineCommand2({
|
|
556
|
-
meta: {
|
|
557
|
-
key: "identity.org.member.remove",
|
|
558
|
-
version: "1.0.0",
|
|
559
|
-
stability: "stable",
|
|
560
|
-
owners: [...OWNERS2],
|
|
561
|
-
tags: ["identity", "org", "member", "remove"],
|
|
562
|
-
description: "Remove a member from the organization.",
|
|
563
|
-
goal: "Allow org admins to remove members.",
|
|
564
|
-
context: "Team management."
|
|
565
|
-
},
|
|
566
|
-
io: {
|
|
567
|
-
input: RemoveMemberInputModel,
|
|
568
|
-
output: SuccessResultModel,
|
|
569
|
-
errors: {
|
|
570
|
-
CANNOT_REMOVE_OWNER: {
|
|
571
|
-
description: "Cannot remove the organization owner",
|
|
572
|
-
http: 403,
|
|
573
|
-
gqlCode: "CANNOT_REMOVE_OWNER",
|
|
574
|
-
when: "Target is the org owner"
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
policy: {
|
|
579
|
-
auth: "user"
|
|
580
|
-
},
|
|
581
|
-
sideEffects: {
|
|
582
|
-
emits: [
|
|
583
|
-
{
|
|
584
|
-
key: "org.member.removed",
|
|
585
|
-
version: "1.0.0",
|
|
586
|
-
when: "Member is removed",
|
|
587
|
-
payload: MemberRemovedPayloadModel
|
|
588
|
-
}
|
|
589
|
-
],
|
|
590
|
-
audit: ["org.member.removed"]
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
var ListMembersContract = defineQuery2({
|
|
594
|
-
meta: {
|
|
595
|
-
key: "identity.org.members.list",
|
|
596
|
-
version: "1.0.0",
|
|
597
|
-
stability: "stable",
|
|
598
|
-
owners: [...OWNERS2],
|
|
599
|
-
tags: ["identity", "org", "member", "list"],
|
|
600
|
-
description: "List organization members.",
|
|
601
|
-
goal: "View all members of an organization.",
|
|
602
|
-
context: "Team management page."
|
|
603
|
-
},
|
|
604
|
-
io: {
|
|
605
|
-
input: ListMembersInputModel,
|
|
606
|
-
output: ListMembersOutputModel
|
|
607
|
-
},
|
|
608
|
-
policy: {
|
|
609
|
-
auth: "user"
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
var ListUserOrgsContract = defineQuery2({
|
|
613
|
-
meta: {
|
|
614
|
-
key: "identity.org.list",
|
|
615
|
-
version: "1.0.0",
|
|
616
|
-
stability: "stable",
|
|
617
|
-
owners: [...OWNERS2],
|
|
618
|
-
tags: ["identity", "org", "list"],
|
|
619
|
-
description: "List organizations the current user belongs to.",
|
|
620
|
-
goal: "Show user their organizations for workspace switching.",
|
|
621
|
-
context: "Workspace switcher, org selection."
|
|
622
|
-
},
|
|
623
|
-
io: {
|
|
624
|
-
input: null,
|
|
625
|
-
output: ListUserOrgsOutputModel
|
|
626
|
-
},
|
|
627
|
-
policy: {
|
|
628
|
-
auth: "user"
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// src/contracts/rbac.ts
|
|
633
|
-
import { defineCommand as defineCommand3, defineQuery as defineQuery3 } from "@contractspec/lib.contracts-spec";
|
|
634
|
-
import { ScalarTypeEnum as ScalarTypeEnum3, SchemaModel as SchemaModel3 } from "@contractspec/lib.schema";
|
|
635
|
-
var RoleModel = new SchemaModel3({
|
|
636
|
-
name: "Role",
|
|
637
|
-
description: "RBAC role definition",
|
|
638
|
-
fields: {
|
|
639
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
640
|
-
name: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
641
|
-
description: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
642
|
-
permissions: {
|
|
643
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
644
|
-
isOptional: false,
|
|
645
|
-
isArray: true
|
|
646
|
-
},
|
|
647
|
-
createdAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
var PolicyBindingModel = new SchemaModel3({
|
|
651
|
-
name: "PolicyBinding",
|
|
652
|
-
description: "Role assignment to a target",
|
|
653
|
-
fields: {
|
|
654
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
655
|
-
roleId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
656
|
-
targetType: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
657
|
-
targetId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
658
|
-
expiresAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
659
|
-
createdAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false },
|
|
660
|
-
role: { type: RoleModel, isOptional: false }
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
var PermissionCheckResultModel = new SchemaModel3({
|
|
664
|
-
name: "PermissionCheckResult",
|
|
665
|
-
description: "Result of a permission check",
|
|
666
|
-
fields: {
|
|
667
|
-
allowed: { type: ScalarTypeEnum3.Boolean(), isOptional: false },
|
|
668
|
-
reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
669
|
-
matchedRole: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
670
|
-
}
|
|
671
|
-
});
|
|
672
|
-
var CreateRoleInputModel = new SchemaModel3({
|
|
673
|
-
name: "CreateRoleInput",
|
|
674
|
-
description: "Input for creating a role",
|
|
675
|
-
fields: {
|
|
676
|
-
name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
|
|
677
|
-
description: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
678
|
-
permissions: {
|
|
679
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
680
|
-
isOptional: false,
|
|
681
|
-
isArray: true
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
var UpdateRoleInputModel = new SchemaModel3({
|
|
686
|
-
name: "UpdateRoleInput",
|
|
687
|
-
description: "Input for updating a role",
|
|
688
|
-
fields: {
|
|
689
|
-
roleId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
690
|
-
name: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
691
|
-
description: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
692
|
-
permissions: {
|
|
693
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
694
|
-
isOptional: true,
|
|
695
|
-
isArray: true
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
});
|
|
699
|
-
var DeleteRoleInputModel = new SchemaModel3({
|
|
700
|
-
name: "DeleteRoleInput",
|
|
701
|
-
description: "Input for deleting a role",
|
|
702
|
-
fields: {
|
|
703
|
-
roleId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
var ListRolesOutputModel = new SchemaModel3({
|
|
707
|
-
name: "ListRolesOutput",
|
|
708
|
-
description: "Output for listing roles",
|
|
709
|
-
fields: {
|
|
710
|
-
roles: { type: RoleModel, isOptional: false, isArray: true }
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
var AssignRoleInputModel = new SchemaModel3({
|
|
714
|
-
name: "AssignRoleInput",
|
|
715
|
-
description: "Input for assigning a role",
|
|
716
|
-
fields: {
|
|
717
|
-
roleId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
718
|
-
targetType: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
719
|
-
targetId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
720
|
-
expiresAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true }
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
var RevokeRoleInputModel = new SchemaModel3({
|
|
724
|
-
name: "RevokeRoleInput",
|
|
725
|
-
description: "Input for revoking a role",
|
|
726
|
-
fields: {
|
|
727
|
-
bindingId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
var BindingIdPayloadModel = new SchemaModel3({
|
|
731
|
-
name: "BindingIdPayload",
|
|
732
|
-
description: "Payload with binding ID",
|
|
733
|
-
fields: {
|
|
734
|
-
bindingId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
|
-
var CheckPermissionInputModel = new SchemaModel3({
|
|
738
|
-
name: "CheckPermissionInput",
|
|
739
|
-
description: "Input for checking a permission",
|
|
740
|
-
fields: {
|
|
741
|
-
userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
742
|
-
orgId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
743
|
-
permission: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
var ListUserPermissionsInputModel = new SchemaModel3({
|
|
747
|
-
name: "ListUserPermissionsInput",
|
|
748
|
-
description: "Input for listing user permissions",
|
|
749
|
-
fields: {
|
|
750
|
-
userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
751
|
-
orgId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
var ListUserPermissionsOutputModel = new SchemaModel3({
|
|
755
|
-
name: "ListUserPermissionsOutput",
|
|
756
|
-
description: "Output for listing user permissions",
|
|
757
|
-
fields: {
|
|
758
|
-
permissions: {
|
|
759
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
760
|
-
isOptional: false,
|
|
761
|
-
isArray: true
|
|
762
|
-
},
|
|
763
|
-
roles: { type: RoleModel, isOptional: false, isArray: true }
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
var CreateRoleContract = defineCommand3({
|
|
767
|
-
meta: {
|
|
768
|
-
key: "identity.rbac.role.create",
|
|
769
|
-
version: "1.0.0",
|
|
770
|
-
stability: "stable",
|
|
771
|
-
owners: ["@platform.identity-rbac"],
|
|
772
|
-
tags: ["identity", "rbac", "role", "create"],
|
|
773
|
-
description: "Create a new role with permissions.",
|
|
774
|
-
goal: "Allow admins to define custom roles.",
|
|
775
|
-
context: "Role management in admin settings."
|
|
776
|
-
},
|
|
777
|
-
io: {
|
|
778
|
-
input: CreateRoleInputModel,
|
|
779
|
-
output: RoleModel,
|
|
780
|
-
errors: {
|
|
781
|
-
ROLE_EXISTS: {
|
|
782
|
-
description: "A role with this name already exists",
|
|
783
|
-
http: 409,
|
|
784
|
-
gqlCode: "ROLE_EXISTS",
|
|
785
|
-
when: "Role name is taken"
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
},
|
|
789
|
-
policy: {
|
|
790
|
-
auth: "admin"
|
|
791
|
-
},
|
|
792
|
-
sideEffects: {
|
|
793
|
-
audit: ["role.created"]
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
var UpdateRoleContract = defineCommand3({
|
|
797
|
-
meta: {
|
|
798
|
-
key: "identity.rbac.role.update",
|
|
799
|
-
version: "1.0.0",
|
|
800
|
-
stability: "stable",
|
|
801
|
-
owners: ["@platform.identity-rbac"],
|
|
802
|
-
tags: ["identity", "rbac", "role", "update"],
|
|
803
|
-
description: "Update an existing role.",
|
|
804
|
-
goal: "Allow admins to modify role permissions.",
|
|
805
|
-
context: "Role management in admin settings."
|
|
806
|
-
},
|
|
807
|
-
io: {
|
|
808
|
-
input: UpdateRoleInputModel,
|
|
809
|
-
output: RoleModel
|
|
810
|
-
},
|
|
811
|
-
policy: {
|
|
812
|
-
auth: "admin"
|
|
813
|
-
},
|
|
814
|
-
sideEffects: {
|
|
815
|
-
audit: ["role.updated"]
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
var DeleteRoleContract = defineCommand3({
|
|
819
|
-
meta: {
|
|
820
|
-
key: "identity.rbac.role.delete",
|
|
821
|
-
version: "1.0.0",
|
|
822
|
-
stability: "stable",
|
|
823
|
-
owners: ["@platform.identity-rbac"],
|
|
824
|
-
tags: ["identity", "rbac", "role", "delete"],
|
|
825
|
-
description: "Delete an existing role.",
|
|
826
|
-
goal: "Allow admins to remove unused roles.",
|
|
827
|
-
context: "Role management. Removes all policy bindings using this role."
|
|
828
|
-
},
|
|
829
|
-
io: {
|
|
830
|
-
input: DeleteRoleInputModel,
|
|
831
|
-
output: SuccessResultModel,
|
|
832
|
-
errors: {
|
|
833
|
-
ROLE_IN_USE: {
|
|
834
|
-
description: "Role is still assigned to users or organizations",
|
|
835
|
-
http: 409,
|
|
836
|
-
gqlCode: "ROLE_IN_USE",
|
|
837
|
-
when: "Role has active bindings"
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
policy: {
|
|
842
|
-
auth: "admin"
|
|
843
|
-
},
|
|
844
|
-
sideEffects: {
|
|
845
|
-
audit: ["role.deleted"]
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
var ListRolesContract = defineQuery3({
|
|
849
|
-
meta: {
|
|
850
|
-
key: "identity.rbac.role.list",
|
|
851
|
-
version: "1.0.0",
|
|
852
|
-
stability: "stable",
|
|
853
|
-
owners: ["@platform.identity-rbac"],
|
|
854
|
-
tags: ["identity", "rbac", "role", "list"],
|
|
855
|
-
description: "List all available roles.",
|
|
856
|
-
goal: "Show available roles for assignment.",
|
|
857
|
-
context: "Role assignment UI."
|
|
858
|
-
},
|
|
859
|
-
io: {
|
|
860
|
-
input: null,
|
|
861
|
-
output: ListRolesOutputModel
|
|
862
|
-
},
|
|
863
|
-
policy: {
|
|
864
|
-
auth: "user"
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
var AssignRoleContract = defineCommand3({
|
|
868
|
-
meta: {
|
|
869
|
-
key: "identity.rbac.assign",
|
|
870
|
-
version: "1.0.0",
|
|
871
|
-
stability: "stable",
|
|
872
|
-
owners: ["@platform.identity-rbac"],
|
|
873
|
-
tags: ["identity", "rbac", "assign"],
|
|
874
|
-
description: "Assign a role to a user or organization.",
|
|
875
|
-
goal: "Grant permissions via role assignment.",
|
|
876
|
-
context: "User/org permission management."
|
|
877
|
-
},
|
|
878
|
-
io: {
|
|
879
|
-
input: AssignRoleInputModel,
|
|
880
|
-
output: PolicyBindingModel,
|
|
881
|
-
errors: {
|
|
882
|
-
ROLE_NOT_FOUND: {
|
|
883
|
-
description: "The specified role does not exist",
|
|
884
|
-
http: 404,
|
|
885
|
-
gqlCode: "ROLE_NOT_FOUND",
|
|
886
|
-
when: "Role ID is invalid"
|
|
887
|
-
},
|
|
888
|
-
ALREADY_ASSIGNED: {
|
|
889
|
-
description: "This role is already assigned to the target",
|
|
890
|
-
http: 409,
|
|
891
|
-
gqlCode: "ALREADY_ASSIGNED",
|
|
892
|
-
when: "Binding already exists"
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
},
|
|
896
|
-
policy: {
|
|
897
|
-
auth: "admin"
|
|
898
|
-
},
|
|
899
|
-
sideEffects: {
|
|
900
|
-
emits: [
|
|
901
|
-
{
|
|
902
|
-
key: "role.assigned",
|
|
903
|
-
version: "1.0.0",
|
|
904
|
-
when: "Role is assigned",
|
|
905
|
-
payload: PolicyBindingModel
|
|
906
|
-
}
|
|
907
|
-
],
|
|
908
|
-
audit: ["role.assigned"]
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
var RevokeRoleContract = defineCommand3({
|
|
912
|
-
meta: {
|
|
913
|
-
key: "identity.rbac.revoke",
|
|
914
|
-
version: "1.0.0",
|
|
915
|
-
stability: "stable",
|
|
916
|
-
owners: ["@platform.identity-rbac"],
|
|
917
|
-
tags: ["identity", "rbac", "revoke"],
|
|
918
|
-
description: "Revoke a role from a user or organization.",
|
|
919
|
-
goal: "Remove permissions via role revocation.",
|
|
920
|
-
context: "User/org permission management."
|
|
921
|
-
},
|
|
922
|
-
io: {
|
|
923
|
-
input: RevokeRoleInputModel,
|
|
924
|
-
output: SuccessResultModel,
|
|
925
|
-
errors: {
|
|
926
|
-
BINDING_NOT_FOUND: {
|
|
927
|
-
description: "The policy binding does not exist",
|
|
928
|
-
http: 404,
|
|
929
|
-
gqlCode: "BINDING_NOT_FOUND",
|
|
930
|
-
when: "Binding ID is invalid"
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
},
|
|
934
|
-
policy: {
|
|
935
|
-
auth: "admin"
|
|
936
|
-
},
|
|
937
|
-
sideEffects: {
|
|
938
|
-
emits: [
|
|
939
|
-
{
|
|
940
|
-
key: "role.revoked",
|
|
941
|
-
version: "1.0.0",
|
|
942
|
-
when: "Role is revoked",
|
|
943
|
-
payload: BindingIdPayloadModel
|
|
944
|
-
}
|
|
945
|
-
],
|
|
946
|
-
audit: ["role.revoked"]
|
|
947
|
-
}
|
|
948
|
-
});
|
|
949
|
-
var CheckPermissionContract = defineQuery3({
|
|
950
|
-
meta: {
|
|
951
|
-
key: "identity.rbac.check",
|
|
952
|
-
version: "1.0.0",
|
|
953
|
-
stability: "stable",
|
|
954
|
-
owners: ["@platform.identity-rbac"],
|
|
955
|
-
tags: ["identity", "rbac", "check", "permission"],
|
|
956
|
-
description: "Check if a user has a specific permission.",
|
|
957
|
-
goal: "Authorization check before sensitive operations.",
|
|
958
|
-
context: "Called by other services to verify permissions."
|
|
959
|
-
},
|
|
960
|
-
io: {
|
|
961
|
-
input: CheckPermissionInputModel,
|
|
962
|
-
output: PermissionCheckResultModel
|
|
963
|
-
},
|
|
964
|
-
policy: {
|
|
965
|
-
auth: "user"
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
var ListUserPermissionsContract = defineQuery3({
|
|
969
|
-
meta: {
|
|
970
|
-
key: "identity.rbac.permissions",
|
|
971
|
-
version: "1.0.0",
|
|
972
|
-
stability: "stable",
|
|
973
|
-
owners: ["@platform.identity-rbac"],
|
|
974
|
-
tags: ["identity", "rbac", "permissions", "user"],
|
|
975
|
-
description: "List all permissions for a user in a context.",
|
|
976
|
-
goal: "Show what a user can do in an org.",
|
|
977
|
-
context: "UI permission display, debugging."
|
|
978
|
-
},
|
|
979
|
-
io: {
|
|
980
|
-
input: ListUserPermissionsInputModel,
|
|
981
|
-
output: ListUserPermissionsOutputModel
|
|
982
|
-
},
|
|
983
|
-
policy: {
|
|
984
|
-
auth: "user"
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
export {
|
|
988
|
-
UserProfileModel,
|
|
989
|
-
UserDeletedPayloadModel,
|
|
990
|
-
UpdateUserInputModel,
|
|
991
|
-
UpdateUserContract,
|
|
992
|
-
UpdateRoleInputModel,
|
|
993
|
-
UpdateRoleContract,
|
|
994
|
-
UpdateOrgInputModel,
|
|
995
|
-
UpdateOrgContract,
|
|
996
|
-
SuccessResultModel,
|
|
997
|
-
RoleModel,
|
|
998
|
-
RevokeRoleInputModel,
|
|
999
|
-
RevokeRoleContract,
|
|
1000
|
-
RemoveMemberInputModel,
|
|
1001
|
-
RemoveMemberContract,
|
|
1002
|
-
PolicyBindingModel,
|
|
1003
|
-
PermissionCheckResultModel,
|
|
1004
|
-
OrganizationWithRoleModel,
|
|
1005
|
-
OrganizationModel,
|
|
1006
|
-
MemberUserModel,
|
|
1007
|
-
MemberRemovedPayloadModel,
|
|
1008
|
-
MemberModel,
|
|
1009
|
-
ListUsersOutputModel,
|
|
1010
|
-
ListUsersInputModel,
|
|
1011
|
-
ListUsersContract,
|
|
1012
|
-
ListUserPermissionsOutputModel,
|
|
1013
|
-
ListUserPermissionsInputModel,
|
|
1014
|
-
ListUserPermissionsContract,
|
|
1015
|
-
ListUserOrgsOutputModel,
|
|
1016
|
-
ListUserOrgsContract,
|
|
1017
|
-
ListRolesOutputModel,
|
|
1018
|
-
ListRolesContract,
|
|
1019
|
-
ListMembersOutputModel,
|
|
1020
|
-
ListMembersInputModel,
|
|
1021
|
-
ListMembersContract,
|
|
1022
|
-
InviteMemberInputModel,
|
|
1023
|
-
InviteMemberContract,
|
|
1024
|
-
InvitationModel,
|
|
1025
|
-
GetOrgInputModel,
|
|
1026
|
-
GetOrgContract,
|
|
1027
|
-
GetCurrentUserContract,
|
|
1028
|
-
DeleteUserInputModel,
|
|
1029
|
-
DeleteUserContract,
|
|
1030
|
-
DeleteRoleInputModel,
|
|
1031
|
-
DeleteRoleContract,
|
|
1032
|
-
CreateUserInputModel,
|
|
1033
|
-
CreateUserContract,
|
|
1034
|
-
CreateRoleInputModel,
|
|
1035
|
-
CreateRoleContract,
|
|
1036
|
-
CreateOrgInputModel,
|
|
1037
|
-
CreateOrgContract,
|
|
1038
|
-
CheckPermissionInputModel,
|
|
1039
|
-
CheckPermissionContract,
|
|
1040
|
-
BindingIdPayloadModel,
|
|
1041
|
-
AssignRoleInputModel,
|
|
1042
|
-
AssignRoleContract,
|
|
1043
|
-
AcceptInviteInputModel,
|
|
1044
|
-
AcceptInviteContract
|
|
1045
|
-
};
|
|
1
|
+
import{defineCommand as F,defineQuery as X}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as U,SchemaModel as x}from"@contractspec/lib.schema";var I=["platform.identity-rbac"],A=new x({name:"UserProfile",description:"User profile information",fields:{id:{type:U.String_unsecure(),isOptional:!1},email:{type:U.EmailAddress(),isOptional:!1},emailVerified:{type:U.Boolean(),isOptional:!1},name:{type:U.String_unsecure(),isOptional:!0},firstName:{type:U.String_unsecure(),isOptional:!0},lastName:{type:U.String_unsecure(),isOptional:!0},locale:{type:U.String_unsecure(),isOptional:!0},timezone:{type:U.String_unsecure(),isOptional:!0},imageUrl:{type:U.URL(),isOptional:!0},role:{type:U.String_unsecure(),isOptional:!0},onboardingCompleted:{type:U.Boolean(),isOptional:!1},createdAt:{type:U.DateTime(),isOptional:!1}}}),Y=new x({name:"CreateUserInput",description:"Input for creating a new user",fields:{email:{type:U.EmailAddress(),isOptional:!1},name:{type:U.String_unsecure(),isOptional:!0},firstName:{type:U.String_unsecure(),isOptional:!0},lastName:{type:U.String_unsecure(),isOptional:!0},password:{type:U.String_unsecure(),isOptional:!0}}}),Z=new x({name:"UpdateUserInput",description:"Input for updating a user profile",fields:{name:{type:U.String_unsecure(),isOptional:!0},firstName:{type:U.String_unsecure(),isOptional:!0},lastName:{type:U.String_unsecure(),isOptional:!0},locale:{type:U.String_unsecure(),isOptional:!0},timezone:{type:U.String_unsecure(),isOptional:!0},imageUrl:{type:U.URL(),isOptional:!0}}}),_=new x({name:"DeleteUserInput",description:"Input for deleting a user",fields:{confirmEmail:{type:U.EmailAddress(),isOptional:!1}}}),D=new x({name:"SuccessResult",description:"Simple success result",fields:{success:{type:U.Boolean(),isOptional:!1}}}),$=new x({name:"UserDeletedPayload",description:"Payload for user deleted event",fields:{userId:{type:U.String_unsecure(),isOptional:!1}}}),B=new x({name:"ListUsersInput",description:"Input for listing users",fields:{limit:{type:U.Int_unsecure(),isOptional:!0},offset:{type:U.Int_unsecure(),isOptional:!0},search:{type:U.String_unsecure(),isOptional:!0}}}),z=new x({name:"ListUsersOutput",description:"Output for listing users",fields:{users:{type:A,isOptional:!1,isArray:!0},total:{type:U.Int_unsecure(),isOptional:!1}}}),m=F({meta:{key:"identity.user.create",version:"1.0.0",stability:"stable",owners:[...I],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:Y,output:A,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:A}],audit:["user.created"]}}),l=X({meta:{key:"identity.user.me",version:"1.0.0",stability:"stable",owners:[...I],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:A},policy:{auth:"user"}}),e=F({meta:{key:"identity.user.update",version:"1.0.0",stability:"stable",owners:[...I],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:A},policy:{auth:"user"},sideEffects:{emits:[{key:"user.updated",version:"1.0.0",when:"User profile is updated",payload:A}],audit:["user.updated"]}}),a=F({meta:{key:"identity.user.delete",version:"1.0.0",stability:"stable",owners:[...I],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:D},policy:{auth:"user",escalate:"human_review"},sideEffects:{emits:[{key:"user.deleted",version:"1.0.0",when:"User account is deleted",payload:$}],audit:["user.deleted"]}}),tt=X({meta:{key:"identity.user.list",version:"1.0.0",stability:"stable",owners:[...I],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:B,output:z},policy:{auth:"admin"}});import{defineCommand as j,defineQuery as J}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as t,SchemaModel as L}from"@contractspec/lib.schema";var k=["platform.identity-rbac"],G=new L({name:"Organization",description:"Organization details",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.String_unsecure(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!0},logo:{type:t.URL(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0},type:{type:t.String_unsecure(),isOptional:!1},onboardingCompleted:{type:t.Boolean(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1}}}),P=new L({name:"MemberUser",description:"Basic user info within a member",fields:{id:{type:t.String_unsecure(),isOptional:!1},email:{type:t.EmailAddress(),isOptional:!1},name:{type:t.String_unsecure(),isOptional:!0}}}),w=new L({name:"Member",description:"Organization member",fields:{id:{type:t.String_unsecure(),isOptional:!1},userId:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},role:{type:t.String_unsecure(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1},user:{type:P,isOptional:!1}}}),H=new L({name:"Invitation",description:"Organization invitation",fields:{id:{type:t.String_unsecure(),isOptional:!1},email:{type:t.EmailAddress(),isOptional:!1},role:{type:t.String_unsecure(),isOptional:!0},status:{type:t.String_unsecure(),isOptional:!1},expiresAt:{type:t.DateTime(),isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1}}}),b=new L({name:"CreateOrgInput",description:"Input for creating an organization",fields:{name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0},type:{type:t.String_unsecure(),isOptional:!0}}}),s=new L({name:"GetOrgInput",description:"Input for getting an organization",fields:{orgId:{type:t.String_unsecure(),isOptional:!1}}}),Q=new L({name:"UpdateOrgInput",description:"Input for updating an organization",fields:{orgId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.String_unsecure(),isOptional:!0},slug:{type:t.String_unsecure(),isOptional:!0},logo:{type:t.URL(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0}}}),O=new L({name:"InviteMemberInput",description:"Input for inviting a member",fields:{orgId:{type:t.String_unsecure(),isOptional:!1},email:{type:t.EmailAddress(),isOptional:!1},role:{type:t.String_unsecure(),isOptional:!1},teamId:{type:t.String_unsecure(),isOptional:!0}}}),R=new L({name:"AcceptInviteInput",description:"Input for accepting an invitation",fields:{invitationId:{type:t.String_unsecure(),isOptional:!1}}}),N=new L({name:"RemoveMemberInput",description:"Input for removing a member",fields:{orgId:{type:t.String_unsecure(),isOptional:!1},userId:{type:t.String_unsecure(),isOptional:!1}}}),W=new L({name:"MemberRemovedPayload",description:"Payload for member removed event",fields:{orgId:{type:t.String_unsecure(),isOptional:!1},userId:{type:t.String_unsecure(),isOptional:!1}}}),f=new L({name:"ListMembersInput",description:"Input for listing members",fields:{orgId:{type:t.String_unsecure(),isOptional:!1},limit:{type:t.Int_unsecure(),isOptional:!0},offset:{type:t.Int_unsecure(),isOptional:!0}}}),i=new L({name:"ListMembersOutput",description:"Output for listing members",fields:{members:{type:w,isOptional:!1,isArray:!0},total:{type:t.Int_unsecure(),isOptional:!1}}}),h=new L({name:"OrganizationWithRole",description:"Organization with user role",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.String_unsecure(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!0},logo:{type:t.URL(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0},type:{type:t.String_unsecure(),isOptional:!1},onboardingCompleted:{type:t.Boolean(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1},role:{type:t.String_unsecure(),isOptional:!1}}}),o=new L({name:"ListUserOrgsOutput",description:"Output for listing user organizations",fields:{organizations:{type:h,isOptional:!1,isArray:!0}}}),Ct=j({meta:{key:"identity.org.create",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","create"],description:"Create a new organization.",goal:"Allow users to create new organizations/workspaces.",context:"Called during onboarding or when creating additional workspaces."},io:{input:b,output:G,errors:{SLUG_EXISTS:{description:"An organization with this slug already exists",http:409,gqlCode:"SLUG_EXISTS",when:"Slug is already taken"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"org.created",version:"1.0.0",when:"Organization is created",payload:G}],audit:["org.created"]}}),Ut=J({meta:{key:"identity.org.get",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","get"],description:"Get organization details.",goal:"Retrieve organization information.",context:"Called when viewing organization settings or dashboard."},io:{input:s,output:G},policy:{auth:"user"}}),Lt=j({meta:{key:"identity.org.update",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","update"],description:"Update organization details.",goal:"Allow org admins to update organization settings.",context:"Organization settings page."},io:{input:Q,output:G},policy:{auth:"user"},sideEffects:{emits:[{key:"org.updated",version:"1.0.0",when:"Organization is updated",payload:G}],audit:["org.updated"]}}),vt=j({meta:{key:"identity.org.invite",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","invite","member"],description:"Invite a user to join the organization.",goal:"Allow org admins to invite new members.",context:"Team management. Sends invitation email."},io:{input:O,output:H,errors:{ALREADY_MEMBER:{description:"User is already a member of this organization",http:409,gqlCode:"ALREADY_MEMBER",when:"Invitee is already a member"},INVITE_PENDING:{description:"An invitation for this email is already pending",http:409,gqlCode:"INVITE_PENDING",when:"Active invitation exists"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"org.invite.sent",version:"1.0.0",when:"Invitation is sent",payload:H}],audit:["org.invite.sent"]}}),xt=j({meta:{key:"identity.org.invite.accept",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","invite","accept"],description:"Accept an organization invitation.",goal:"Allow users to join organizations via invitation.",context:"Called from invitation email link."},io:{input:R,output:w,errors:{INVITE_EXPIRED:{description:"The invitation has expired",http:410,gqlCode:"INVITE_EXPIRED",when:"Invitation is past expiry date"},INVITE_USED:{description:"The invitation has already been used",http:409,gqlCode:"INVITE_USED",when:"Invitation was already accepted"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"org.member.added",version:"1.0.0",when:"Member joins org",payload:w}],audit:["org.member.added"]}}),kt=j({meta:{key:"identity.org.member.remove",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","member","remove"],description:"Remove a member from the organization.",goal:"Allow org admins to remove members.",context:"Team management."},io:{input:N,output:D,errors:{CANNOT_REMOVE_OWNER:{description:"Cannot remove the organization owner",http:403,gqlCode:"CANNOT_REMOVE_OWNER",when:"Target is the org owner"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"org.member.removed",version:"1.0.0",when:"Member is removed",payload:W}],audit:["org.member.removed"]}}),At=J({meta:{key:"identity.org.members.list",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","member","list"],description:"List organization members.",goal:"View all members of an organization.",context:"Team management page."},io:{input:f,output:i},policy:{auth:"user"}}),Dt=J({meta:{key:"identity.org.list",version:"1.0.0",stability:"stable",owners:[...k],tags:["identity","org","list"],description:"List organizations the current user belongs to.",goal:"Show user their organizations for workspace switching.",context:"Workspace switcher, org selection."},io:{input:null,output:o},policy:{auth:"user"}});import{defineCommand as q,defineQuery as V}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as C,SchemaModel as v}from"@contractspec/lib.schema";var g=new v({name:"Role",description:"RBAC role definition",fields:{id:{type:C.String_unsecure(),isOptional:!1},name:{type:C.String_unsecure(),isOptional:!1},description:{type:C.String_unsecure(),isOptional:!0},permissions:{type:C.String_unsecure(),isOptional:!1,isArray:!0},createdAt:{type:C.DateTime(),isOptional:!1}}}),K=new v({name:"PolicyBinding",description:"Role assignment to a target",fields:{id:{type:C.String_unsecure(),isOptional:!1},roleId:{type:C.String_unsecure(),isOptional:!1},targetType:{type:C.String_unsecure(),isOptional:!1},targetId:{type:C.String_unsecure(),isOptional:!1},expiresAt:{type:C.DateTime(),isOptional:!0},createdAt:{type:C.DateTime(),isOptional:!1},role:{type:g,isOptional:!1}}}),M=new v({name:"PermissionCheckResult",description:"Result of a permission check",fields:{allowed:{type:C.Boolean(),isOptional:!1},reason:{type:C.String_unsecure(),isOptional:!0},matchedRole:{type:C.String_unsecure(),isOptional:!0}}}),d=new v({name:"CreateRoleInput",description:"Input for creating a role",fields:{name:{type:C.NonEmptyString(),isOptional:!1},description:{type:C.String_unsecure(),isOptional:!0},permissions:{type:C.String_unsecure(),isOptional:!1,isArray:!0}}}),r=new v({name:"UpdateRoleInput",description:"Input for updating a role",fields:{roleId:{type:C.String_unsecure(),isOptional:!1},name:{type:C.String_unsecure(),isOptional:!0},description:{type:C.String_unsecure(),isOptional:!0},permissions:{type:C.String_unsecure(),isOptional:!0,isArray:!0}}}),T=new v({name:"DeleteRoleInput",description:"Input for deleting a role",fields:{roleId:{type:C.String_unsecure(),isOptional:!1}}}),p=new v({name:"ListRolesOutput",description:"Output for listing roles",fields:{roles:{type:g,isOptional:!1,isArray:!0}}}),y=new v({name:"AssignRoleInput",description:"Input for assigning a role",fields:{roleId:{type:C.String_unsecure(),isOptional:!1},targetType:{type:C.String_unsecure(),isOptional:!1},targetId:{type:C.String_unsecure(),isOptional:!1},expiresAt:{type:C.DateTime(),isOptional:!0}}}),E=new v({name:"RevokeRoleInput",description:"Input for revoking a role",fields:{bindingId:{type:C.String_unsecure(),isOptional:!1}}}),u=new v({name:"BindingIdPayload",description:"Payload with binding ID",fields:{bindingId:{type:C.String_unsecure(),isOptional:!1}}}),n=new v({name:"CheckPermissionInput",description:"Input for checking a permission",fields:{userId:{type:C.String_unsecure(),isOptional:!1},orgId:{type:C.String_unsecure(),isOptional:!0},permission:{type:C.String_unsecure(),isOptional:!1}}}),c=new v({name:"ListUserPermissionsInput",description:"Input for listing user permissions",fields:{userId:{type:C.String_unsecure(),isOptional:!1},orgId:{type:C.String_unsecure(),isOptional:!0}}}),S=new v({name:"ListUserPermissionsOutput",description:"Output for listing user permissions",fields:{permissions:{type:C.String_unsecure(),isOptional:!1,isArray:!0},roles:{type:g,isOptional:!1,isArray:!0}}}),Gt=q({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:g,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"]}}),gt=q({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:r,output:g},policy:{auth:"admin"},sideEffects:{audit:["role.updated"]}}),It=q({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:T,output:D,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"]}}),jt=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:p},policy:{auth:"user"}}),qt=q({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:y,output:K,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:K}],audit:["role.assigned"]}}),wt=q({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:E,output:D,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:u}],audit:["role.revoked"]}}),Ft=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:n,output:M},policy:{auth:"user"}}),Ht=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:S},policy:{auth:"user"}});export{A as UserProfileModel,$ as UserDeletedPayloadModel,Z as UpdateUserInputModel,e as UpdateUserContract,r as UpdateRoleInputModel,gt as UpdateRoleContract,Q as UpdateOrgInputModel,Lt as UpdateOrgContract,D as SuccessResultModel,g as RoleModel,E as RevokeRoleInputModel,wt as RevokeRoleContract,N as RemoveMemberInputModel,kt as RemoveMemberContract,K as PolicyBindingModel,M as PermissionCheckResultModel,h as OrganizationWithRoleModel,G as OrganizationModel,P as MemberUserModel,W as MemberRemovedPayloadModel,w as MemberModel,z as ListUsersOutputModel,B as ListUsersInputModel,tt as ListUsersContract,S as ListUserPermissionsOutputModel,c as ListUserPermissionsInputModel,Ht as ListUserPermissionsContract,o as ListUserOrgsOutputModel,Dt as ListUserOrgsContract,p as ListRolesOutputModel,jt as ListRolesContract,i as ListMembersOutputModel,f as ListMembersInputModel,At as ListMembersContract,O as InviteMemberInputModel,vt as InviteMemberContract,H as InvitationModel,s as GetOrgInputModel,Ut as GetOrgContract,l as GetCurrentUserContract,_ as DeleteUserInputModel,a as DeleteUserContract,T as DeleteRoleInputModel,It as DeleteRoleContract,Y as CreateUserInputModel,m as CreateUserContract,d as CreateRoleInputModel,Gt as CreateRoleContract,b as CreateOrgInputModel,Ct as CreateOrgContract,n as CheckPermissionInputModel,Ft as CheckPermissionContract,u as BindingIdPayloadModel,y as AssignRoleInputModel,qt as AssignRoleContract,R as AcceptInviteInputModel,xt as AcceptInviteContract};
|