@happyvertical/smrt-types 0.51.31 → 0.51.33

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.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Cross-package identity & tenancy data contracts.
3
+ *
4
+ * These interfaces are the structural shape that the identity model classes
5
+ * expose to *other* packages:
6
+ *
7
+ * - `User`, `Tenant`, `Role`, `Membership` — runtime classes in
8
+ * `@happyvertical/smrt-users`
9
+ *
10
+ * They live here — in the zero-runtime types leaf — so a package that needs only
11
+ * the *type* of an identity record never has to take a package dependency on the
12
+ * implementation package. Importing these upward (e.g. `smrt-tenancy` reaching
13
+ * into `smrt-users`) is what fabricated the peer-dependency cycle the leaf
14
+ * removes. The runtime classes `implements` these interfaces, so the contract
15
+ * stays honest (the class is checked to be a superset of the interface at
16
+ * compile time).
17
+ *
18
+ * Scope: these cover the persisted, cross-package-visible fields only — not the
19
+ * full class surface (methods, relationship accessors). Widen an interface when
20
+ * a genuine cross-package consumer needs more; the `implements` clause guarantees
21
+ * the class already provides it.
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ import type { MembershipStatus, TenantStatus, UserStatus } from './user.js';
26
+ /**
27
+ * Fields every persisted SMRT entity exposes — a subset of `SmrtObject`'s public
28
+ * surface. `id`/`slug` are `null`/`undefined` before the first persist, matching
29
+ * the base getters.
30
+ */
31
+ export interface SmrtEntityFields {
32
+ /** UUID, assigned on first persist. */
33
+ id: string | null | undefined;
34
+ /** URL-safe slug, when the model maintains one. */
35
+ slug: string | null | undefined;
36
+ /** Creation timestamp; `null`/`undefined` before first persist. */
37
+ created_at: Date | null | undefined;
38
+ /** Last-update timestamp; `null`/`undefined` before first persist. */
39
+ updated_at: Date | null | undefined;
40
+ }
41
+ /** Auth identity record. Runtime class: `@happyvertical/smrt-users:User`. */
42
+ export interface User extends SmrtEntityFields {
43
+ /** Plain-string reference to the owning `Profile` (not a DB foreign key). */
44
+ profileId: string;
45
+ /** Lower-cased email; globally unique. */
46
+ email: string;
47
+ status: UserStatus;
48
+ lastLoginAt: Date | null;
49
+ }
50
+ /** Hierarchical tenant. Runtime class: `@happyvertical/smrt-users:Tenant`. */
51
+ export interface Tenant extends SmrtEntityFields {
52
+ name: string;
53
+ status: TenantStatus;
54
+ description: string;
55
+ parentTenantId?: string | null;
56
+ hierarchyLevel: number;
57
+ hierarchyPath: string;
58
+ cascadePermissions: boolean;
59
+ inheritPermissions: boolean;
60
+ }
61
+ /** RBAC role. Runtime class: `@happyvertical/smrt-users:Role`. */
62
+ export interface Role extends SmrtEntityFields {
63
+ /** `null` → system role available to every tenant. */
64
+ tenantId?: string | null;
65
+ name: string;
66
+ description: string;
67
+ isSystem: boolean;
68
+ /**
69
+ * Opt-in hierarchical inheritance: when `true`, an ACTIVE membership holding
70
+ * this role also resolves permissions in descendant tenants where the user
71
+ * has no direct membership. Default `false` (authority is exact-tenant only).
72
+ */
73
+ inheritsToDescendants: boolean;
74
+ }
75
+ /** User↔Tenant↔Role junction. Runtime class: `@happyvertical/smrt-users:Membership`. */
76
+ export interface Membership extends SmrtEntityFields {
77
+ userId?: string;
78
+ tenantId?: string;
79
+ roleId?: string;
80
+ status: MembershipStatus;
81
+ }
82
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5E;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9B,mDAAmD;IACnD,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChC,mEAAmE;IACnE,UAAU,EAAE,IAAI,GAAG,IAAI,GAAG,S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