@contractspec/lib.identity-rbac 3.7.17 → 3.7.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/browser/contracts/index.js +1 -1045
  2. package/dist/browser/contracts/organization.js +1 -655
  3. package/dist/browser/contracts/rbac.js +1 -599
  4. package/dist/browser/contracts/user.js +1 -235
  5. package/dist/browser/entities/index.js +1 -464
  6. package/dist/browser/entities/organization.js +1 -150
  7. package/dist/browser/entities/rbac.js +1 -124
  8. package/dist/browser/entities/user.js +1 -168
  9. package/dist/browser/events.js +1 -374
  10. package/dist/browser/identity-rbac.capability.js +1 -31
  11. package/dist/browser/identity-rbac.feature.js +1 -67
  12. package/dist/browser/index.js +1 -2099
  13. package/dist/browser/policies/engine.js +1 -154
  14. package/dist/browser/policies/index.js +1 -154
  15. package/dist/contracts/index.js +1 -1045
  16. package/dist/contracts/organization.js +1 -655
  17. package/dist/contracts/rbac.js +1 -599
  18. package/dist/contracts/user.js +1 -235
  19. package/dist/entities/index.js +1 -464
  20. package/dist/entities/organization.js +1 -150
  21. package/dist/entities/rbac.js +1 -124
  22. package/dist/entities/user.js +1 -168
  23. package/dist/events.js +1 -374
  24. package/dist/identity-rbac.capability.js +1 -31
  25. package/dist/identity-rbac.feature.js +1 -67
  26. package/dist/index.js +1 -2099
  27. package/dist/node/contracts/index.js +1 -1045
  28. package/dist/node/contracts/organization.js +1 -655
  29. package/dist/node/contracts/rbac.js +1 -599
  30. package/dist/node/contracts/user.js +1 -235
  31. package/dist/node/entities/index.js +1 -464
  32. package/dist/node/entities/organization.js +1 -150
  33. package/dist/node/entities/rbac.js +1 -124
  34. package/dist/node/entities/user.js +1 -168
  35. package/dist/node/events.js +1 -374
  36. package/dist/node/identity-rbac.capability.js +1 -31
  37. package/dist/node/identity-rbac.feature.js +1 -67
  38. package/dist/node/index.js +1 -2099
  39. package/dist/node/policies/engine.js +1 -154
  40. package/dist/node/policies/index.js +1 -154
  41. package/dist/policies/engine.js +1 -154
  42. package/dist/policies/index.js +1 -154
  43. package/package.json +5 -5
@@ -1,655 +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
- 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
- };
1
+ import{defineCommand as K,defineQuery as Z}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as k,SchemaModel as w}from"@contractspec/lib.schema";var F=["platform.identity-rbac"],B=new w({name:"UserProfile",description:"User profile information",fields:{id:{type:k.String_unsecure(),isOptional:!1},email:{type:k.EmailAddress(),isOptional:!1},emailVerified:{type:k.Boolean(),isOptional:!1},name:{type:k.String_unsecure(),isOptional:!0},firstName:{type:k.String_unsecure(),isOptional:!0},lastName:{type:k.String_unsecure(),isOptional:!0},locale:{type:k.String_unsecure(),isOptional:!0},timezone:{type:k.String_unsecure(),isOptional:!0},imageUrl:{type:k.URL(),isOptional:!0},role:{type:k.String_unsecure(),isOptional:!0},onboardingCompleted:{type:k.Boolean(),isOptional:!1},createdAt:{type:k.DateTime(),isOptional:!1}}}),$=new w({name:"CreateUserInput",description:"Input for creating a new user",fields:{email:{type:k.EmailAddress(),isOptional:!1},name:{type:k.String_unsecure(),isOptional:!0},firstName:{type:k.String_unsecure(),isOptional:!0},lastName:{type:k.String_unsecure(),isOptional:!0},password:{type:k.String_unsecure(),isOptional:!0}}}),A=new w({name:"UpdateUserInput",description:"Input for updating a user profile",fields:{name:{type:k.String_unsecure(),isOptional:!0},firstName:{type:k.String_unsecure(),isOptional:!0},lastName:{type:k.String_unsecure(),isOptional:!0},locale:{type:k.String_unsecure(),isOptional:!0},timezone:{type:k.String_unsecure(),isOptional:!0},imageUrl:{type:k.URL(),isOptional:!0}}}),G=new w({name:"DeleteUserInput",description:"Input for deleting a user",fields:{confirmEmail:{type:k.EmailAddress(),isOptional:!1}}}),V=new w({name:"SuccessResult",description:"Simple success result",fields:{success:{type:k.Boolean(),isOptional:!1}}}),D=new w({name:"UserDeletedPayload",description:"Payload for user deleted event",fields:{userId:{type:k.String_unsecure(),isOptional:!1}}}),L=new w({name:"ListUsersInput",description:"Input for listing users",fields:{limit:{type:k.Int_unsecure(),isOptional:!0},offset:{type:k.Int_unsecure(),isOptional:!0},search:{type:k.String_unsecure(),isOptional:!0}}}),Q=new w({name:"ListUsersOutput",description:"Output for listing users",fields:{users:{type:B,isOptional:!1,isArray:!0},total:{type:k.Int_unsecure(),isOptional:!1}}}),s=K({meta:{key:"identity.user.create",version:"1.0.0",stability:"stable",owners:[...F],tags:["identity","user","create"],description:"Create a new user account.",goal:"Register a new user in the system.",context:"Used during signup flows. May trigger email verification."},io:{input:$,output:B,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:B}],audit:["user.created"]}}),i=Z({meta:{key:"identity.user.me",version:"1.0.0",stability:"stable",owners:[...F],tags:["identity","user","profile"],description:"Get the current authenticated user profile.",goal:"Retrieve user profile for the authenticated session.",context:"Called on app load and after profile updates."},io:{input:null,output:B},policy:{auth:"user"}}),t=K({meta:{key:"identity.user.update",version:"1.0.0",stability:"stable",owners:[...F],tags:["identity","user","update"],description:"Update user profile information.",goal:"Allow users to update their profile.",context:"Self-service profile updates."},io:{input:A,output:B},policy:{auth:"user"},sideEffects:{emits:[{key:"user.updated",version:"1.0.0",when:"User profile is updated",payload:B}],audit:["user.updated"]}}),M=K({meta:{key:"identity.user.delete",version:"1.0.0",stability:"stable",owners:[...F],tags:["identity","user","delete"],description:"Delete user account and all associated data.",goal:"Allow users to delete their account (GDPR compliance).",context:"Self-service account deletion. Cascades to memberships, sessions, etc."},io:{input:G,output:V},policy:{auth:"user",escalate:"human_review"},sideEffects:{emits:[{key:"user.deleted",version:"1.0.0",when:"User account is deleted",payload:D}],audit:["user.deleted"]}}),T=Z({meta:{key:"identity.user.list",version:"1.0.0",stability:"stable",owners:[...F],tags:["identity","user","admin","list"],description:"List all users (admin only).",goal:"Allow admins to browse and manage users.",context:"Admin dashboard user management."},io:{input:L,output:Q},policy:{auth:"admin"}});import{defineCommand as J,defineQuery as Y}from"@contractspec/lib.contracts-spec";import{ScalarTypeEnum as j,SchemaModel as q}from"@contractspec/lib.schema";var x=["platform.identity-rbac"],H=new q({name:"Organization",description:"Organization details",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!0},logo:{type:j.URL(),isOptional:!0},description:{type:j.String_unsecure(),isOptional:!0},type:{type:j.String_unsecure(),isOptional:!1},onboardingCompleted:{type:j.Boolean(),isOptional:!1},createdAt:{type:j.DateTime(),isOptional:!1}}}),v=new q({name:"MemberUser",description:"Basic user info within a member",fields:{id:{type:j.String_unsecure(),isOptional:!1},email:{type:j.EmailAddress(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!0}}}),X=new q({name:"Member",description:"Organization member",fields:{id:{type:j.String_unsecure(),isOptional:!1},userId:{type:j.String_unsecure(),isOptional:!1},organizationId:{type:j.String_unsecure(),isOptional:!1},role:{type:j.String_unsecure(),isOptional:!1},createdAt:{type:j.DateTime(),isOptional:!1},user:{type:v,isOptional:!1}}}),_=new q({name:"Invitation",description:"Organization invitation",fields:{id:{type:j.String_unsecure(),isOptional:!1},email:{type:j.EmailAddress(),isOptional:!1},role:{type:j.String_unsecure(),isOptional:!0},status:{type:j.String_unsecure(),isOptional:!1},expiresAt:{type:j.DateTime(),isOptional:!0},createdAt:{type:j.DateTime(),isOptional:!1}}}),z=new q({name:"CreateOrgInput",description:"Input for creating an organization",fields:{name:{type:j.NonEmptyString(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!0},description:{type:j.String_unsecure(),isOptional:!0},type:{type:j.String_unsecure(),isOptional:!0}}}),P=new q({name:"GetOrgInput",description:"Input for getting an organization",fields:{orgId:{type:j.String_unsecure(),isOptional:!1}}}),g=new q({name:"UpdateOrgInput",description:"Input for updating an organization",fields:{orgId:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!0},slug:{type:j.String_unsecure(),isOptional:!0},logo:{type:j.URL(),isOptional:!0},description:{type:j.String_unsecure(),isOptional:!0}}}),C=new q({name:"InviteMemberInput",description:"Input for inviting a member",fields:{orgId:{type:j.String_unsecure(),isOptional:!1},email:{type:j.EmailAddress(),isOptional:!1},role:{type:j.String_unsecure(),isOptional:!1},teamId:{type:j.String_unsecure(),isOptional:!0}}}),b=new q({name:"AcceptInviteInput",description:"Input for accepting an invitation",fields:{invitationId:{type:j.String_unsecure(),isOptional:!1}}}),N=new q({name:"RemoveMemberInput",description:"Input for removing a member",fields:{orgId:{type:j.String_unsecure(),isOptional:!1},userId:{type:j.String_unsecure(),isOptional:!1}}}),W=new q({name:"MemberRemovedPayload",description:"Payload for member removed event",fields:{orgId:{type:j.String_unsecure(),isOptional:!1},userId:{type:j.String_unsecure(),isOptional:!1}}}),I=new q({name:"ListMembersInput",description:"Input for listing members",fields:{orgId:{type:j.String_unsecure(),isOptional:!1},limit:{type:j.Int_unsecure(),isOptional:!0},offset:{type:j.Int_unsecure(),isOptional:!0}}}),U=new q({name:"ListMembersOutput",description:"Output for listing members",fields:{members:{type:X,isOptional:!1,isArray:!0},total:{type:j.Int_unsecure(),isOptional:!1}}}),R=new q({name:"OrganizationWithRole",description:"Organization with user role",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!1},slug:{type:j.String_unsecure(),isOptional:!0},logo:{type:j.URL(),isOptional:!0},description:{type:j.String_unsecure(),isOptional:!0},type:{type:j.String_unsecure(),isOptional:!1},onboardingCompleted:{type:j.Boolean(),isOptional:!1},createdAt:{type:j.DateTime(),isOptional:!1},role:{type:j.String_unsecure(),isOptional:!1}}}),f=new q({name:"ListUserOrgsOutput",description:"Output for listing user organizations",fields:{organizations:{type:R,isOptional:!1,isArray:!0}}}),p=J({meta:{key:"identity.org.create",version:"1.0.0",stability:"stable",owners:[...x],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:z,output:H,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:H}],audit:["org.created"]}}),u=Y({meta:{key:"identity.org.get",version:"1.0.0",stability:"stable",owners:[...x],tags:["identity","org","get"],description:"Get organization details.",goal:"Retrieve organization information.",context:"Called when viewing organization settings or dashboard."},io:{input:P,output:H},policy:{auth:"user"}}),S=J({meta:{key:"identity.org.update",version:"1.0.0",stability:"stable",owners:[...x],tags:["identity","org","update"],description:"Update organization details.",goal:"Allow org admins to update organization settings.",context:"Organization settings page."},io:{input:g,output:H},policy:{auth:"user"},sideEffects:{emits:[{key:"org.updated",version:"1.0.0",when:"Organization is updated",payload:H}],audit:["org.updated"]}}),c=J({meta:{key:"identity.org.invite",version:"1.0.0",stability:"stable",owners:[...x],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:C,output:_,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:_}],audit:["org.invite.sent"]}}),m=J({meta:{key:"identity.org.invite.accept",version:"1.0.0",stability:"stable",owners:[...x],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:b,output:X,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:X}],audit:["org.member.added"]}}),r=J({meta:{key:"identity.org.member.remove",version:"1.0.0",stability:"stable",owners:[...x],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:V,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"]}}),n=Y({meta:{key:"identity.org.members.list",version:"1.0.0",stability:"stable",owners:[...x],tags:["identity","org","member","list"],description:"List organization members.",goal:"View all members of an organization.",context:"Team management page."},io:{input:I,output:U},policy:{auth:"user"}}),l=Y({meta:{key:"identity.org.list",version:"1.0.0",stability:"stable",owners:[...x],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:f},policy:{auth:"user"}});export{g as UpdateOrgInputModel,S as UpdateOrgContract,N as RemoveMemberInputModel,r as RemoveMemberContract,R as OrganizationWithRoleModel,H as OrganizationModel,v as MemberUserModel,W as MemberRemovedPayloadModel,X as MemberModel,f as ListUserOrgsOutputModel,l as ListUserOrgsContract,U as ListMembersOutputModel,I as ListMembersInputModel,n as ListMembersContract,C as InviteMemberInputModel,c as InviteMemberContract,_ as InvitationModel,P as GetOrgInputModel,u as GetOrgContract,z as CreateOrgInputModel,p as CreateOrgContract,b as AcceptInviteInputModel,m as AcceptInviteContract};