@contractspec/lib.identity-rbac 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/contracts/index.js +1045 -0
- package/dist/browser/contracts/organization.js +655 -0
- package/dist/browser/contracts/rbac.js +599 -0
- package/dist/browser/contracts/user.js +235 -0
- package/dist/browser/entities/index.js +464 -0
- package/dist/browser/entities/organization.js +150 -0
- package/dist/browser/entities/rbac.js +124 -0
- package/dist/browser/entities/user.js +168 -0
- package/dist/browser/events.js +374 -0
- package/dist/browser/identity-rbac.capability.js +28 -0
- package/dist/browser/identity-rbac.feature.js +67 -0
- package/dist/browser/index.js +2099 -0
- package/dist/browser/policies/engine.js +154 -0
- package/dist/browser/policies/index.js +154 -0
- package/dist/contracts/index.d.ts +4 -4
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +1045 -4
- package/dist/contracts/organization.d.ts +758 -764
- package/dist/contracts/organization.d.ts.map +1 -1
- package/dist/contracts/organization.js +653 -602
- package/dist/contracts/rbac.d.ts +517 -523
- package/dist/contracts/rbac.d.ts.map +1 -1
- package/dist/contracts/rbac.js +597 -481
- package/dist/contracts/user.d.ts +513 -519
- package/dist/contracts/user.d.ts.map +1 -1
- package/dist/contracts/user.js +222 -319
- package/dist/entities/index.d.ts +164 -169
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +462 -33
- package/dist/entities/organization.d.ts +58 -63
- package/dist/entities/organization.d.ts.map +1 -1
- package/dist/entities/organization.js +145 -145
- package/dist/entities/rbac.d.ts +62 -67
- package/dist/entities/rbac.d.ts.map +1 -1
- package/dist/entities/rbac.js +119 -132
- package/dist/entities/user.d.ts +66 -71
- package/dist/entities/user.d.ts.map +1 -1
- package/dist/entities/user.js +164 -189
- package/dist/events.d.ts +537 -543
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +343 -651
- package/dist/identity-rbac.capability.d.ts +2 -7
- package/dist/identity-rbac.capability.d.ts.map +1 -1
- package/dist/identity-rbac.capability.js +29 -29
- package/dist/identity-rbac.feature.d.ts +1 -6
- package/dist/identity-rbac.feature.d.ts.map +1 -1
- package/dist/identity-rbac.feature.js +66 -193
- package/dist/index.d.ts +6 -12
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2100 -14
- package/dist/node/contracts/index.js +1045 -0
- package/dist/node/contracts/organization.js +655 -0
- package/dist/node/contracts/rbac.js +599 -0
- package/dist/node/contracts/user.js +235 -0
- package/dist/node/entities/index.js +464 -0
- package/dist/node/entities/organization.js +150 -0
- package/dist/node/entities/rbac.js +124 -0
- package/dist/node/entities/user.js +168 -0
- package/dist/node/events.js +374 -0
- package/dist/node/identity-rbac.capability.js +28 -0
- package/dist/node/identity-rbac.feature.js +67 -0
- package/dist/node/index.js +2099 -0
- package/dist/node/policies/engine.js +154 -0
- package/dist/node/policies/index.js +154 -0
- package/dist/policies/engine.d.ts +98 -101
- package/dist/policies/engine.d.ts.map +1 -1
- package/dist/policies/engine.js +151 -164
- package/dist/policies/index.d.ts +2 -2
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +154 -2
- package/package.json +149 -40
- package/dist/contracts/organization.js.map +0 -1
- package/dist/contracts/rbac.js.map +0 -1
- package/dist/contracts/user.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/organization.js.map +0 -1
- package/dist/entities/rbac.js.map +0 -1
- package/dist/entities/user.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/identity-rbac.capability.js.map +0 -1
- package/dist/identity-rbac.feature.js.map +0 -1
- package/dist/policies/engine.js.map +0 -1
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
// src/contracts/user.ts
|
|
2
|
+
import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
|
|
4
|
+
var OWNERS = ["platform.identity-rbac"];
|
|
5
|
+
var UserProfileModel = new SchemaModel({
|
|
6
|
+
name: "UserProfile",
|
|
7
|
+
description: "User profile information",
|
|
8
|
+
fields: {
|
|
9
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
email: { type: ScalarTypeEnum.EmailAddress(), isOptional: false },
|
|
11
|
+
emailVerified: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
12
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
13
|
+
firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
14
|
+
lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
15
|
+
locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
16
|
+
timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
17
|
+
imageUrl: { type: ScalarTypeEnum.URL(), isOptional: true },
|
|
18
|
+
role: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
19
|
+
onboardingCompleted: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
20
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var CreateUserInputModel = new SchemaModel({
|
|
24
|
+
name: "CreateUserInput",
|
|
25
|
+
description: "Input for creating a new user",
|
|
26
|
+
fields: {
|
|
27
|
+
email: { type: ScalarTypeEnum.EmailAddress(), isOptional: false },
|
|
28
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
29
|
+
firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
30
|
+
lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
31
|
+
password: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var UpdateUserInputModel = new SchemaModel({
|
|
35
|
+
name: "UpdateUserInput",
|
|
36
|
+
description: "Input for updating a user profile",
|
|
37
|
+
fields: {
|
|
38
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
39
|
+
firstName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
40
|
+
lastName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
41
|
+
locale: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
42
|
+
timezone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
43
|
+
imageUrl: { type: ScalarTypeEnum.URL(), isOptional: true }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var DeleteUserInputModel = new SchemaModel({
|
|
47
|
+
name: "DeleteUserInput",
|
|
48
|
+
description: "Input for deleting a user",
|
|
49
|
+
fields: {
|
|
50
|
+
confirmEmail: { type: ScalarTypeEnum.EmailAddress(), isOptional: false }
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
var SuccessResultModel = new SchemaModel({
|
|
54
|
+
name: "SuccessResult",
|
|
55
|
+
description: "Simple success result",
|
|
56
|
+
fields: {
|
|
57
|
+
success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var UserDeletedPayloadModel = new SchemaModel({
|
|
61
|
+
name: "UserDeletedPayload",
|
|
62
|
+
description: "Payload for user deleted event",
|
|
63
|
+
fields: {
|
|
64
|
+
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
var ListUsersInputModel = new SchemaModel({
|
|
68
|
+
name: "ListUsersInput",
|
|
69
|
+
description: "Input for listing users",
|
|
70
|
+
fields: {
|
|
71
|
+
limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
72
|
+
offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
73
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
var ListUsersOutputModel = new SchemaModel({
|
|
77
|
+
name: "ListUsersOutput",
|
|
78
|
+
description: "Output for listing users",
|
|
79
|
+
fields: {
|
|
80
|
+
users: { type: UserProfileModel, isOptional: false, isArray: true },
|
|
81
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var CreateUserContract = defineCommand({
|
|
85
|
+
meta: {
|
|
86
|
+
key: "identity.user.create",
|
|
87
|
+
version: "1.0.0",
|
|
88
|
+
stability: "stable",
|
|
89
|
+
owners: [...OWNERS],
|
|
90
|
+
tags: ["identity", "user", "create"],
|
|
91
|
+
description: "Create a new user account.",
|
|
92
|
+
goal: "Register a new user in the system.",
|
|
93
|
+
context: "Used during signup flows. May trigger email verification."
|
|
94
|
+
},
|
|
95
|
+
io: {
|
|
96
|
+
input: CreateUserInputModel,
|
|
97
|
+
output: UserProfileModel,
|
|
98
|
+
errors: {
|
|
99
|
+
EMAIL_EXISTS: {
|
|
100
|
+
description: "A user with this email already exists",
|
|
101
|
+
http: 409,
|
|
102
|
+
gqlCode: "EMAIL_EXISTS",
|
|
103
|
+
when: "Email is already registered"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
policy: {
|
|
108
|
+
auth: "anonymous"
|
|
109
|
+
},
|
|
110
|
+
sideEffects: {
|
|
111
|
+
emits: [
|
|
112
|
+
{
|
|
113
|
+
key: "user.created",
|
|
114
|
+
version: "1.0.0",
|
|
115
|
+
when: "User is successfully created",
|
|
116
|
+
payload: UserProfileModel
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
audit: ["user.created"]
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
var GetCurrentUserContract = defineQuery({
|
|
123
|
+
meta: {
|
|
124
|
+
key: "identity.user.me",
|
|
125
|
+
version: "1.0.0",
|
|
126
|
+
stability: "stable",
|
|
127
|
+
owners: [...OWNERS],
|
|
128
|
+
tags: ["identity", "user", "profile"],
|
|
129
|
+
description: "Get the current authenticated user profile.",
|
|
130
|
+
goal: "Retrieve user profile for the authenticated session.",
|
|
131
|
+
context: "Called on app load and after profile updates."
|
|
132
|
+
},
|
|
133
|
+
io: {
|
|
134
|
+
input: null,
|
|
135
|
+
output: UserProfileModel
|
|
136
|
+
},
|
|
137
|
+
policy: {
|
|
138
|
+
auth: "user"
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
var UpdateUserContract = defineCommand({
|
|
142
|
+
meta: {
|
|
143
|
+
key: "identity.user.update",
|
|
144
|
+
version: "1.0.0",
|
|
145
|
+
stability: "stable",
|
|
146
|
+
owners: [...OWNERS],
|
|
147
|
+
tags: ["identity", "user", "update"],
|
|
148
|
+
description: "Update user profile information.",
|
|
149
|
+
goal: "Allow users to update their profile.",
|
|
150
|
+
context: "Self-service profile updates."
|
|
151
|
+
},
|
|
152
|
+
io: {
|
|
153
|
+
input: UpdateUserInputModel,
|
|
154
|
+
output: UserProfileModel
|
|
155
|
+
},
|
|
156
|
+
policy: {
|
|
157
|
+
auth: "user"
|
|
158
|
+
},
|
|
159
|
+
sideEffects: {
|
|
160
|
+
emits: [
|
|
161
|
+
{
|
|
162
|
+
key: "user.updated",
|
|
163
|
+
version: "1.0.0",
|
|
164
|
+
when: "User profile is updated",
|
|
165
|
+
payload: UserProfileModel
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
audit: ["user.updated"]
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
var DeleteUserContract = defineCommand({
|
|
172
|
+
meta: {
|
|
173
|
+
key: "identity.user.delete",
|
|
174
|
+
version: "1.0.0",
|
|
175
|
+
stability: "stable",
|
|
176
|
+
owners: [...OWNERS],
|
|
177
|
+
tags: ["identity", "user", "delete"],
|
|
178
|
+
description: "Delete user account and all associated data.",
|
|
179
|
+
goal: "Allow users to delete their account (GDPR compliance).",
|
|
180
|
+
context: "Self-service account deletion. Cascades to memberships, sessions, etc."
|
|
181
|
+
},
|
|
182
|
+
io: {
|
|
183
|
+
input: DeleteUserInputModel,
|
|
184
|
+
output: SuccessResultModel
|
|
185
|
+
},
|
|
186
|
+
policy: {
|
|
187
|
+
auth: "user",
|
|
188
|
+
escalate: "human_review"
|
|
189
|
+
},
|
|
190
|
+
sideEffects: {
|
|
191
|
+
emits: [
|
|
192
|
+
{
|
|
193
|
+
key: "user.deleted",
|
|
194
|
+
version: "1.0.0",
|
|
195
|
+
when: "User account is deleted",
|
|
196
|
+
payload: UserDeletedPayloadModel
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
audit: ["user.deleted"]
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
var ListUsersContract = defineQuery({
|
|
203
|
+
meta: {
|
|
204
|
+
key: "identity.user.list",
|
|
205
|
+
version: "1.0.0",
|
|
206
|
+
stability: "stable",
|
|
207
|
+
owners: [...OWNERS],
|
|
208
|
+
tags: ["identity", "user", "admin", "list"],
|
|
209
|
+
description: "List all users (admin only).",
|
|
210
|
+
goal: "Allow admins to browse and manage users.",
|
|
211
|
+
context: "Admin dashboard user management."
|
|
212
|
+
},
|
|
213
|
+
io: {
|
|
214
|
+
input: ListUsersInputModel,
|
|
215
|
+
output: ListUsersOutputModel
|
|
216
|
+
},
|
|
217
|
+
policy: {
|
|
218
|
+
auth: "admin"
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/contracts/organization.ts
|
|
223
|
+
import { ScalarTypeEnum as ScalarTypeEnum2, SchemaModel as SchemaModel2 } from "@contractspec/lib.schema";
|
|
224
|
+
import { defineCommand as defineCommand2, defineQuery as defineQuery2 } from "@contractspec/lib.contracts";
|
|
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
|
+
export {
|
|
632
|
+
UpdateOrgInputModel,
|
|
633
|
+
UpdateOrgContract,
|
|
634
|
+
RemoveMemberInputModel,
|
|
635
|
+
RemoveMemberContract,
|
|
636
|
+
OrganizationWithRoleModel,
|
|
637
|
+
OrganizationModel,
|
|
638
|
+
MemberUserModel,
|
|
639
|
+
MemberRemovedPayloadModel,
|
|
640
|
+
MemberModel,
|
|
641
|
+
ListUserOrgsOutputModel,
|
|
642
|
+
ListUserOrgsContract,
|
|
643
|
+
ListMembersOutputModel,
|
|
644
|
+
ListMembersInputModel,
|
|
645
|
+
ListMembersContract,
|
|
646
|
+
InviteMemberInputModel,
|
|
647
|
+
InviteMemberContract,
|
|
648
|
+
InvitationModel,
|
|
649
|
+
GetOrgInputModel,
|
|
650
|
+
GetOrgContract,
|
|
651
|
+
CreateOrgInputModel,
|
|
652
|
+
CreateOrgContract,
|
|
653
|
+
AcceptInviteInputModel,
|
|
654
|
+
AcceptInviteContract
|
|
655
|
+
};
|