@contractspec/lib.identity-rbac 3.7.6 → 3.7.10

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/README.md CHANGED
@@ -1,102 +1,74 @@
1
1
  # @contractspec/lib.identity-rbac
2
2
 
3
- Website: https://contractspec.io/
3
+ Website: https://contractspec.io
4
4
 
5
+ **Identity, Organizations, and RBAC module for ContractSpec applications.**
5
6
 
6
- Identity, Organizations, and Role-Based Access Control (RBAC) module for ContractSpec applications.
7
+ ## What It Provides
7
8
 
8
- ## Purpose
9
-
10
- Provides a reusable identity and authorization foundation for multi-tenant, multi-role applications. This module follows the spec-first approach where entity definitions generate database schemas.
11
-
12
- ## Features
13
-
14
- - **User Management**: User profiles, authentication accounts, sessions
15
- - **Organizations**: Multi-tenant organization support with slugs, metadata
16
- - **Memberships**: Role-based organization membership (owner, admin, member)
17
- - **RBAC**: Roles, permissions, and policy bindings
18
- - **Teams**: Optional team grouping within organizations
19
- - **Events**: Domain events for user/org lifecycle changes
9
+ - **Layer**: lib.
10
+ - **Consumers**: bundles, apps.
11
+ - `src/contracts/` contains contract specs, operations, entities, and registry exports.
12
+ - Related ContractSpec packages include `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
13
+ - `src/contracts/` contains contract specs, operations, entities, and registry exports.
20
14
 
21
15
  ## Installation
22
16
 
23
- ```bash
24
- bun add @contractspec/lib.identity-rbac
25
- ```
26
-
27
- ## Usage
28
-
29
- ### Entity Specs (for schema generation)
30
-
31
- ```typescript
32
- import { UserEntity, OrganizationEntity, MemberEntity } from '@contractspec/lib.identity-rbac/entities';
33
-
34
- // Use in schema composition
35
- const contribution = {
36
- moduleId: '@contractspec/lib.identity-rbac',
37
- entities: [UserEntity, OrganizationEntity, MemberEntity, ...],
38
- };
39
- ```
40
-
41
- ### Contracts (for API generation)
42
-
43
- ```typescript
44
- import {
45
- CreateUserContract,
46
- InviteToOrgContract,
47
- AssignRoleContract
48
- } from '@contractspec/lib.identity-rbac/contracts';
49
- ```
17
+ `npm install @contractspec/lib.identity-rbac`
50
18
 
51
- ### Policies (for authorization)
19
+ or
52
20
 
53
- ```typescript
54
- import { RBACPolicyEngine, Permission } from '@contractspec/lib.identity-rbac/policies';
21
+ `bun add @contractspec/lib.identity-rbac`
55
22
 
56
- const engine = new RBACPolicyEngine();
57
- const canManage = await engine.checkPermission({
58
- userId: 'user-123',
59
- orgId: 'org-456',
60
- permission: Permission.MANAGE_MEMBERS,
61
- });
62
- ```
63
-
64
- ### Events
65
-
66
- ```typescript
67
- import { UserCreatedEvent, OrgMemberAddedEvent } from '@contractspec/lib.identity-rbac/events';
68
-
69
- bus.subscribe(UserCreatedEvent, async (event) => {
70
- // Handle user creation
71
- });
72
- ```
73
-
74
- ## Entity Overview
75
-
76
- | Entity | Description |
77
- |--------|-------------|
78
- | User | Platform user with profile and auth |
79
- | Organization | Tenant/company grouping |
80
- | Member | User's membership in an organization |
81
- | Role | Named set of permissions |
82
- | Permission | Atomic access right |
83
- | PolicyBinding | Binds roles to principals |
84
- | Team | Optional team within organization |
85
-
86
- ## Schemas
87
-
88
- All entities are defined in the `lssm_sigil` PostgreSQL schema for isolation.
89
-
90
- ## Events
91
-
92
- | Event | Trigger |
93
- |-------|---------|
94
- | user.created | New user registered |
95
- | user.updated | User profile changed |
96
- | user.deleted | User account removed |
97
- | org.created | New organization created |
98
- | org.member.added | User joined organization |
99
- | org.member.removed | User left organization |
100
- | role.assigned | Role assigned to user/org |
101
- | role.revoked | Role removed from user/org |
23
+ ## Usage
102
24
 
25
+ Import the root entrypoint from `@contractspec/lib.identity-rbac`, or choose a documented subpath when you only need one part of the package surface.
26
+
27
+ ## Architecture
28
+
29
+ - `src/contracts/` contains contract specs, operations, entities, and registry exports.
30
+ - `src/entities/` contains domain entities and value objects.
31
+ - `src/events.ts` is package-level event definitions.
32
+ - `src/identity-rbac.capability.ts` defines a capability surface.
33
+ - `src/identity-rbac.feature.ts` defines a feature entrypoint.
34
+ - `src/index.ts` is the root public barrel and package entrypoint.
35
+ - `src/policies` is part of the package's public or composition surface.
36
+
37
+ ## Public Entry Points
38
+
39
+ - Export `.` resolves through `./src/index.ts`.
40
+ - Export `./contracts` resolves through `./src/contracts/index.ts`.
41
+ - Export `./contracts/organization` resolves through `./src/contracts/organization.ts`.
42
+ - Export `./contracts/rbac` resolves through `./src/contracts/rbac.ts`.
43
+ - Export `./contracts/user` resolves through `./src/contracts/user.ts`.
44
+ - Export `./entities` resolves through `./src/entities/index.ts`.
45
+ - Export `./entities/organization` resolves through `./src/entities/organization.ts`.
46
+ - Export `./entities/rbac` resolves through `./src/entities/rbac.ts`.
47
+ - Export `./entities/user` resolves through `./src/entities/user.ts`.
48
+ - Export `./events` resolves through `./src/events.ts`.
49
+ - The package publishes 14 total export subpaths; keep docs aligned with `package.json`.
50
+
51
+ ## Local Commands
52
+
53
+ - `bun run dev` — contractspec-bun-build dev
54
+ - `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
55
+ - `bun run lint` — bun lint:fix
56
+ - `bun run lint:check` — biome check .
57
+ - `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
58
+ - `bun run typecheck` — tsc --noEmit
59
+ - `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
60
+ - `bun run publish:pkg:canary` — bun publish:pkg --tag canary
61
+ - `bun run clean` — rimraf dist .turbo
62
+ - `bun run build:bundle` — contractspec-bun-build transpile
63
+ - `bun run build:types` — contractspec-bun-build types
64
+ - `bun run prebuild` — contractspec-bun-build prebuild
65
+
66
+ ## Recent Updates
67
+
68
+ - Replace eslint+prettier by biomejs to optimize speed.
69
+
70
+ ## Notes
71
+
72
+ - **Security-critical** — RBAC policies control access across the platform.
73
+ - Role and permission schemas must stay backward-compatible; removals are breaking.
74
+ - Capability contract is public API; policy evaluation must be deterministic.
@@ -1,6 +1,6 @@
1
1
  // src/contracts/user.ts
2
- import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
3
2
  import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
3
+ import { ScalarTypeEnum, SchemaModel } from "@contractspec/lib.schema";
4
4
  var OWNERS = ["platform.identity-rbac"];
5
5
  var UserProfileModel = new SchemaModel({
6
6
  name: "UserProfile",
@@ -220,8 +220,8 @@ var ListUsersContract = defineQuery({
220
220
  });
221
221
 
222
222
  // src/contracts/organization.ts
223
- import { ScalarTypeEnum as ScalarTypeEnum2, SchemaModel as SchemaModel2 } from "@contractspec/lib.schema";
224
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
225
  var OWNERS2 = ["platform.identity-rbac"];
226
226
  var OrganizationModel = new SchemaModel2({
227
227
  name: "Organization",
@@ -630,8 +630,8 @@ var ListUserOrgsContract = defineQuery2({
630
630
  });
631
631
 
632
632
  // src/contracts/rbac.ts
633
- import { SchemaModel as SchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
634
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
635
  var RoleModel = new SchemaModel3({
636
636
  name: "Role",
637
637
  description: "RBAC role definition",
@@ -1,6 +1,6 @@
1
1
  // src/contracts/user.ts
2
- import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
3
2
  import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
3
+ import { ScalarTypeEnum, SchemaModel } from "@contractspec/lib.schema";
4
4
  var OWNERS = ["platform.identity-rbac"];
5
5
  var UserProfileModel = new SchemaModel({
6
6
  name: "UserProfile",
@@ -220,8 +220,8 @@ var ListUsersContract = defineQuery({
220
220
  });
221
221
 
222
222
  // src/contracts/organization.ts
223
- import { ScalarTypeEnum as ScalarTypeEnum2, SchemaModel as SchemaModel2 } from "@contractspec/lib.schema";
224
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
225
  var OWNERS2 = ["platform.identity-rbac"];
226
226
  var OrganizationModel = new SchemaModel2({
227
227
  name: "Organization",
@@ -1,6 +1,6 @@
1
1
  // src/contracts/user.ts
2
- import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
3
2
  import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
3
+ import { ScalarTypeEnum, SchemaModel } from "@contractspec/lib.schema";
4
4
  var OWNERS = ["platform.identity-rbac"];
5
5
  var UserProfileModel = new SchemaModel({
6
6
  name: "UserProfile",
@@ -220,8 +220,8 @@ var ListUsersContract = defineQuery({
220
220
  });
221
221
 
222
222
  // src/contracts/rbac.ts
223
- import { SchemaModel as SchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
224
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
225
  var RoleModel = new SchemaModel2({
226
226
  name: "Role",
227
227
  description: "RBAC role definition",
@@ -1,6 +1,6 @@
1
1
  // src/contracts/user.ts
2
- import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
3
2
  import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
3
+ import { ScalarTypeEnum, SchemaModel } from "@contractspec/lib.schema";
4
4
  var OWNERS = ["platform.identity-rbac"];
5
5
  var UserProfileModel = new SchemaModel({
6
6
  name: "UserProfile",