brix-runtime-sdk-api-web 1.0.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.
Files changed (135) hide show
  1. package/dist/index.js +190 -0
  2. package/dist/types/api-exports.test.d.ts +33 -0
  3. package/dist/types/api-exports.test.d.ts.map +1 -0
  4. package/dist/types/context/RuntimeContext.d.ts +69 -0
  5. package/dist/types/context/RuntimeContext.d.ts.map +1 -0
  6. package/dist/types/context/index.d.ts +23 -0
  7. package/dist/types/context/index.d.ts.map +1 -0
  8. package/dist/types/index.d.ts +52 -0
  9. package/dist/types/index.d.ts.map +1 -0
  10. package/dist/types/types/auth.d.ts +405 -0
  11. package/dist/types/types/auth.d.ts.map +1 -0
  12. package/dist/types/types/capability.d.ts +218 -0
  13. package/dist/types/types/capability.d.ts.map +1 -0
  14. package/dist/types/types/common.d.ts +99 -0
  15. package/dist/types/types/common.d.ts.map +1 -0
  16. package/dist/types/types/config.d.ts +85 -0
  17. package/dist/types/types/config.d.ts.map +1 -0
  18. package/dist/types/types/event.d.ts +658 -0
  19. package/dist/types/types/event.d.ts.map +1 -0
  20. package/dist/types/types/http.d.ts +132 -0
  21. package/dist/types/types/http.d.ts.map +1 -0
  22. package/dist/types/types/i18n.d.ts +327 -0
  23. package/dist/types/types/i18n.d.ts.map +1 -0
  24. package/dist/types/types/index.d.ts +61 -0
  25. package/dist/types/types/index.d.ts.map +1 -0
  26. package/dist/types/types/layout.d.ts +301 -0
  27. package/dist/types/types/layout.d.ts.map +1 -0
  28. package/dist/types/types/module.d.ts +78 -0
  29. package/dist/types/types/module.d.ts.map +1 -0
  30. package/dist/types/types/navigation.d.ts +295 -0
  31. package/dist/types/types/navigation.d.ts.map +1 -0
  32. package/dist/types/types/plugin-loader-capability.d.ts +142 -0
  33. package/dist/types/types/plugin-loader-capability.d.ts.map +1 -0
  34. package/dist/types/types/plugin.d.ts +250 -0
  35. package/dist/types/types/plugin.d.ts.map +1 -0
  36. package/dist/types/types/state.d.ts +306 -0
  37. package/dist/types/types/state.d.ts.map +1 -0
  38. package/dist/types/types/theme.d.ts +279 -0
  39. package/dist/types/types/theme.d.ts.map +1 -0
  40. package/dist/types/types/ui/adapter.d.ts +181 -0
  41. package/dist/types/types/ui/adapter.d.ts.map +1 -0
  42. package/dist/types/types/ui/avatar.d.ts +102 -0
  43. package/dist/types/types/ui/avatar.d.ts.map +1 -0
  44. package/dist/types/types/ui/badge.d.ts +101 -0
  45. package/dist/types/types/ui/badge.d.ts.map +1 -0
  46. package/dist/types/types/ui/button.d.ts +135 -0
  47. package/dist/types/types/ui/button.d.ts.map +1 -0
  48. package/dist/types/types/ui/card.d.ts +105 -0
  49. package/dist/types/types/ui/card.d.ts.map +1 -0
  50. package/dist/types/types/ui/common.d.ts +29 -0
  51. package/dist/types/types/ui/common.d.ts.map +1 -0
  52. package/dist/types/types/ui/icon.d.ts +78 -0
  53. package/dist/types/types/ui/icon.d.ts.map +1 -0
  54. package/dist/types/types/ui/index.d.ts +59 -0
  55. package/dist/types/types/ui/index.d.ts.map +1 -0
  56. package/dist/types/types/ui/input.d.ts +200 -0
  57. package/dist/types/types/ui/input.d.ts.map +1 -0
  58. package/dist/types/types/ui/menu.d.ts +211 -0
  59. package/dist/types/types/ui/menu.d.ts.map +1 -0
  60. package/dist/types/types/ui/message.d.ts +121 -0
  61. package/dist/types/types/ui/message.d.ts.map +1 -0
  62. package/dist/types/types/ui/modal.d.ts +167 -0
  63. package/dist/types/types/ui/modal.d.ts.map +1 -0
  64. package/dist/types/types/ui/select.d.ts +213 -0
  65. package/dist/types/types/ui/select.d.ts.map +1 -0
  66. package/dist/types/types/ui/theme-tokens.d.ts +226 -0
  67. package/dist/types/types/ui/theme-tokens.d.ts.map +1 -0
  68. package/dist/types/types/ui/tooltip.d.ts +98 -0
  69. package/dist/types/types/ui/tooltip.d.ts.map +1 -0
  70. package/dist/types/types/ui.d.ts +49 -0
  71. package/dist/types/types/ui.d.ts.map +1 -0
  72. package/package.json +34 -0
  73. package/src/api-exports.test.ts +199 -0
  74. package/src/context/RuntimeContext.d.ts +69 -0
  75. package/src/context/RuntimeContext.d.ts.map +1 -0
  76. package/src/context/RuntimeContext.ts +75 -0
  77. package/src/context/index.d.ts +23 -0
  78. package/src/context/index.d.ts.map +1 -0
  79. package/src/context/index.ts +23 -0
  80. package/src/index.d.ts +52 -0
  81. package/src/index.d.ts.map +1 -0
  82. package/src/index.ts +59 -0
  83. package/src/types/auth.d.ts +146 -0
  84. package/src/types/auth.d.ts.map +1 -0
  85. package/src/types/auth.ts +479 -0
  86. package/src/types/capability.d.ts +218 -0
  87. package/src/types/capability.d.ts.map +1 -0
  88. package/src/types/capability.ts +302 -0
  89. package/src/types/common.d.ts +99 -0
  90. package/src/types/common.d.ts.map +1 -0
  91. package/src/types/common.ts +115 -0
  92. package/src/types/config.d.ts +64 -0
  93. package/src/types/config.d.ts.map +1 -0
  94. package/src/types/config.ts +96 -0
  95. package/src/types/event.d.ts +206 -0
  96. package/src/types/event.d.ts.map +1 -0
  97. package/src/types/event.ts +776 -0
  98. package/src/types/http.d.ts +132 -0
  99. package/src/types/http.d.ts.map +1 -0
  100. package/src/types/http.ts +156 -0
  101. package/src/types/i18n.ts +420 -0
  102. package/src/types/index.d.ts +50 -0
  103. package/src/types/index.d.ts.map +1 -0
  104. package/src/types/index.ts +120 -0
  105. package/src/types/layout.ts +394 -0
  106. package/src/types/module.d.ts +78 -0
  107. package/src/types/module.d.ts.map +1 -0
  108. package/src/types/module.ts +92 -0
  109. package/src/types/navigation.d.ts +101 -0
  110. package/src/types/navigation.d.ts.map +1 -0
  111. package/src/types/navigation.ts +361 -0
  112. package/src/types/plugin-loader-capability.ts +159 -0
  113. package/src/types/plugin.d.ts +250 -0
  114. package/src/types/plugin.d.ts.map +1 -0
  115. package/src/types/plugin.ts +344 -0
  116. package/src/types/state.d.ts +119 -0
  117. package/src/types/state.d.ts.map +1 -0
  118. package/src/types/state.ts +366 -0
  119. package/src/types/theme.ts +378 -0
  120. package/src/types/ui/adapter.ts +222 -0
  121. package/src/types/ui/avatar.ts +113 -0
  122. package/src/types/ui/badge.ts +112 -0
  123. package/src/types/ui/button.ts +148 -0
  124. package/src/types/ui/card.ts +116 -0
  125. package/src/types/ui/common.ts +29 -0
  126. package/src/types/ui/icon.ts +85 -0
  127. package/src/types/ui/index.ts +78 -0
  128. package/src/types/ui/input.ts +225 -0
  129. package/src/types/ui/menu.ts +237 -0
  130. package/src/types/ui/message.ts +135 -0
  131. package/src/types/ui/modal.ts +188 -0
  132. package/src/types/ui/select.ts +239 -0
  133. package/src/types/ui/theme-tokens.ts +357 -0
  134. package/src/types/ui/tooltip.ts +120 -0
  135. package/src/types/ui.ts +49 -0
package/src/index.ts ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright 2026 Brix Platform Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @file @brix/runtime-sdk-api-web Unified Entry Point
18
+ * @description UI Capability Contract Definitions - Web Platform (Framework-agnostic)
19
+ * @module @brix/runtime-sdk-api-web
20
+ * @version 3.2.1
21
+ *
22
+ * [Module Responsibilities]
23
+ * Defines UI runtime capability contracts for plugins to obtain and use via RuntimeContext.
24
+ *
25
+ * [Capability Categories]
26
+ * - Navigation Capability: Page navigation, router management
27
+ * - Auth Capability: User identity, permission verification
28
+ * - State Capability: Plugin state management
29
+ * - EventBus Capability: Cross-plugin communication
30
+ * - Config Capability: Runtime configuration reading
31
+ * - Http Capability: Unified HTTP requests
32
+ *
33
+ * [Design Principles]
34
+ * - This module is a pure contract definition layer, containing no concrete implementations
35
+ * - Framework-agnostic: No dependency on React/Vue/Angular or other UI frameworks
36
+ * - Plugins only need to depend on this module
37
+ * - For React bindings, use @brix/runtime-sdk-react
38
+ *
39
+ * [v3.2.1 Refactoring Notes (v3.0.4 Architectural Constraint Fix)]
40
+ * - Removed all 963 lines of inline type declarations, eliminating duplicate type export issues
41
+ * - All type definitions are now exported uniformly from types/ directory
42
+ * - Context definitions are exported from context/ directory
43
+ * - Removed React dependency, achieving true framework independence
44
+ *
45
+ * [v3.2 Refactoring Notes]
46
+ * - Split into modular type files (types/)
47
+ * - Removed React dependency, React Hooks migrated to @brix/runtime-sdk-react
48
+ * - RouteContribution.component type changed to framework-agnostic ComponentType
49
+ */
50
+
51
+ // =========================================
52
+ // Re-export all type definitions from types/ directory
53
+ // =========================================
54
+ export * from './types';
55
+
56
+ // =========================================
57
+ // Re-export runtime context from context/ directory
58
+ // =========================================
59
+ export * from './context';
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Copyright 2026 Brix Platform Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @file Authentication Capability Type Definitions
18
+ * @description Defines core types for the authentication system, including user info, auth info, permission verification, etc.
19
+ * @module @brix/runtime-sdk-api-web/types/auth
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file.
24
+ */
25
+ /**
26
+ * Authentication Capability Type Identifier
27
+ */
28
+ export declare const AuthCapabilityType: unique symbol;
29
+ /**
30
+ * Basic User Information
31
+ */
32
+ export interface BaseUser {
33
+ /** User ID */
34
+ readonly id: string;
35
+ /** Username */
36
+ readonly username: string;
37
+ /** Email */
38
+ readonly email?: string;
39
+ /** Display Name */
40
+ readonly displayName?: string;
41
+ /** Avatar URL */
42
+ readonly avatar?: string;
43
+ /** Created At */
44
+ readonly createdAt: string;
45
+ /** Updated At */
46
+ readonly updatedAt?: string;
47
+ }
48
+ /**
49
+ * Authenticated User Information
50
+ *
51
+ * <p>User object containing roles and permissions.</p>
52
+ */
53
+ export interface AuthUser {
54
+ /** User ID */
55
+ id: string;
56
+ /** Username */
57
+ username: string;
58
+ /** Email */
59
+ email?: string;
60
+ /** Display Name */
61
+ displayName?: string;
62
+ /** Role List */
63
+ roles: string[];
64
+ /** Permission List */
65
+ permissions: string[];
66
+ }
67
+ /**
68
+ * Authentication Information
69
+ *
70
+ * <p>Contains access token and refresh token.</p>
71
+ */
72
+ export interface AuthInfo {
73
+ /** Access Token */
74
+ readonly accessToken: string;
75
+ /** Refresh Token */
76
+ readonly refreshToken?: string;
77
+ /** Token Expiration Time (seconds) */
78
+ readonly expiresIn: number;
79
+ /** Token Type */
80
+ readonly tokenType: string;
81
+ }
82
+ /**
83
+ * Authentication Capability Contract
84
+ *
85
+ * <p>Provides user identity verification and permission checking capabilities for plugins.</p>
86
+ *
87
+ * <h3>Usage Example</h3>
88
+ * ```typescript
89
+ * const auth = context.getCapability<AuthCapability>(AuthCapabilityType);
90
+ *
91
+ * if (auth.isAuthenticated()) {
92
+ * const user = auth.getCurrentUser();
93
+ * if (auth.hasPermission('booking:create')) {
94
+ * // Create booking
95
+ * }
96
+ * }
97
+ * ```
98
+ */
99
+ export interface AuthCapability {
100
+ /**
101
+ * Get current logged-in user
102
+ *
103
+ * @returns Current user, returns null if not logged in (supports sync/async)
104
+ */
105
+ getCurrentUser(): AuthUser | null | Promise<AuthUser | null>;
106
+ /**
107
+ * Check if authenticated
108
+ *
109
+ * @returns Whether logged in
110
+ */
111
+ isAuthenticated(): boolean;
112
+ /**
113
+ * User login
114
+ *
115
+ * @param credentials Login credentials (optional, depends on auth method)
116
+ * @returns Promise, resolved when login succeeds
117
+ */
118
+ login(credentials?: unknown): Promise<void>;
119
+ /**
120
+ * User logout
121
+ *
122
+ * @returns Promise, resolved when logout succeeds
123
+ */
124
+ logout(): Promise<void>;
125
+ /**
126
+ * Check if has specified permission
127
+ *
128
+ * @param permission Permission identifier
129
+ * @returns Whether has permission
130
+ */
131
+ hasPermission(permission: string): boolean;
132
+ /**
133
+ * Check if has specified role
134
+ *
135
+ * @param role Role identifier
136
+ * @returns Whether has role
137
+ */
138
+ hasRole(role: string): boolean;
139
+ /**
140
+ * Get current access token
141
+ *
142
+ * @returns Access token, returns null if not logged in
143
+ */
144
+ getToken(): string | null;
145
+ }
146
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAM/D;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,YAAY;IACZ,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,UAAU;IACV,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,SAAS;IACT,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW;IACX,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa;IACb,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW;IACX,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,WAAW;IACX,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,UAAU;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAMD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,WAAW;IACX,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,WAAW;IACX,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,eAAe;IACf,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,WAAW;IACX,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,cAAc,IAAI,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAE7D;;;;OAIG;IACH,eAAe,IAAI,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAE3C;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAE/B;;;;OAIG;IACH,QAAQ,IAAI,MAAM,GAAG,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,479 @@
1
+ /**
2
+ * Copyright 2026 Brix Platform Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @file Authentication Capability Type Definitions
18
+ * @description Defines core types for the authentication system, including user info, auth info, permission verification, etc.
19
+ * @module @brix/runtime-sdk-api-web/types/auth
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file.
24
+ *
25
+ * [v3.2.0 Phase 1 Contract Layer Fix]
26
+ * Added types required by AuthCapabilityImpl:
27
+ * - User: Complete user info (including permissions and roles)
28
+ * - Tenant: Tenant info
29
+ * - AuthChangeEvent: Authentication state change event
30
+ * - DataScope: Data scope
31
+ * - LoginCredentials: Login credentials
32
+ * - LoginResult: Login result
33
+ * - AuthState: Authentication state
34
+ */
35
+
36
+ import type { Unsubscribe } from './event';
37
+
38
+ // =========================================
39
+ // Authentication Capability Type Identifier
40
+ // =========================================
41
+
42
+ /**
43
+ * Authentication Capability Type Identifier
44
+ */
45
+ export const AuthCapabilityType = Symbol.for('AuthCapability');
46
+
47
+ // =========================================
48
+ // User Information
49
+ // =========================================
50
+
51
+ /**
52
+ * Basic User Information
53
+ */
54
+ export interface BaseUser {
55
+ /** User ID */
56
+ readonly id: string;
57
+ /** Username */
58
+ readonly username: string;
59
+ /** Email */
60
+ readonly email?: string;
61
+ /** Display Name */
62
+ readonly displayName?: string;
63
+ /** Avatar URL */
64
+ readonly avatar?: string;
65
+ /** Created At */
66
+ readonly createdAt: string;
67
+ /** Updated At */
68
+ readonly updatedAt?: string;
69
+ }
70
+
71
+ /**
72
+ * Authenticated User Information
73
+ *
74
+ * <p>User object containing roles and permissions.</p>
75
+ */
76
+ export interface AuthUser {
77
+ /** User ID */
78
+ id: string;
79
+ /** Username */
80
+ username: string;
81
+ /** Email */
82
+ email?: string;
83
+ /** Display Name */
84
+ displayName?: string;
85
+ /** Role List */
86
+ roles: string[];
87
+ /** Permission List */
88
+ permissions: string[];
89
+ }
90
+
91
+ // =========================================
92
+ // Complete User Information (with permissions and roles)
93
+ // =========================================
94
+
95
+ /**
96
+ * Complete User Information
97
+ *
98
+ * <p>User object containing roles, permissions, and extended attributes.
99
+ * This is the type returned by AuthCapability.getCurrentUser().</p>
100
+ *
101
+ * @since 3.2.0
102
+ */
103
+ export interface User {
104
+ /** User ID */
105
+ readonly id: string;
106
+ /** Username */
107
+ readonly username: string;
108
+ /** Email */
109
+ readonly email?: string;
110
+ /** Display Name */
111
+ readonly displayName?: string;
112
+ /** Avatar URL */
113
+ readonly avatar?: string;
114
+ /** Role List */
115
+ readonly roles: string[];
116
+ /** Permission List */
117
+ readonly permissions: string[];
118
+ /** Created At */
119
+ readonly createdAt?: string;
120
+ /** Updated At */
121
+ readonly updatedAt?: string;
122
+ /** Extended Attributes */
123
+ readonly [key: string]: unknown;
124
+ }
125
+
126
+ // =========================================
127
+ // Tenant Information
128
+ // =========================================
129
+
130
+ /**
131
+ * Tenant Information
132
+ *
133
+ * <p>Tenant object in a multi-tenant system.</p>
134
+ *
135
+ * @since 3.2.0
136
+ */
137
+ export interface Tenant {
138
+ /** Tenant ID */
139
+ readonly id: string;
140
+ /** Tenant Name */
141
+ readonly name: string;
142
+ /** Tenant Code (Unique Identifier) */
143
+ readonly code?: string;
144
+ /** Tenant Type */
145
+ readonly type?: string;
146
+ /** Tenant Status */
147
+ readonly status?: 'active' | 'inactive' | 'suspended';
148
+ /** Tenant Configuration */
149
+ readonly config?: Record<string, unknown>;
150
+ }
151
+
152
+ // =========================================
153
+ // Data Scope
154
+ // =========================================
155
+
156
+ /**
157
+ * Data Scope
158
+ *
159
+ * <p>Describes the scope of user's data access permissions.</p>
160
+ *
161
+ * @since 3.2.0
162
+ */
163
+ export interface DataScope {
164
+ /** Data Scope ID */
165
+ readonly id: string;
166
+ /** Scope Type (e.g., 'org', 'dept', 'self', etc.) */
167
+ readonly type: string;
168
+ /** Scope Value (e.g., organization ID list) */
169
+ readonly value: string | string[];
170
+ /** Resource Type (optional, restricts applicable resources) */
171
+ readonly resource?: string;
172
+ }
173
+
174
+ // =========================================
175
+ // Login Credentials
176
+ // =========================================
177
+
178
+ /**
179
+ * Login Credentials
180
+ *
181
+ * <p>Credential information submitted during user login.</p>
182
+ *
183
+ * @since 3.2.0
184
+ */
185
+ export interface LoginCredentials {
186
+ /** Username or Email */
187
+ readonly username?: string;
188
+ /** Password */
189
+ readonly password?: string;
190
+ /** Captcha */
191
+ readonly captcha?: string;
192
+ /** Remember Login State */
193
+ readonly rememberMe?: boolean;
194
+ /** Third-party Login Provider */
195
+ readonly provider?: string;
196
+ /** Third-party Login Authorization Code */
197
+ readonly authorizationCode?: string;
198
+ /** Extended Fields */
199
+ readonly [key: string]: unknown;
200
+ }
201
+
202
+ // =========================================
203
+ // Login Result
204
+ // =========================================
205
+
206
+ /**
207
+ * Login Result
208
+ *
209
+ * <p>Result returned from a login request.</p>
210
+ *
211
+ * @since 3.2.0
212
+ */
213
+ export interface LoginResult {
214
+ /** Whether Login Succeeded */
215
+ readonly success: boolean;
216
+ /** User Info (on success) */
217
+ readonly user?: User;
218
+ /** Access Token (on success) */
219
+ readonly token?: string;
220
+ /** Refresh Token (on success) */
221
+ readonly refreshToken?: string;
222
+ /** Token Expiration Time (seconds) */
223
+ readonly expiresIn?: number;
224
+ /** Error Code (on failure) */
225
+ readonly errorCode?: string;
226
+ /** Error Message (on failure) */
227
+ readonly errorMessage?: string;
228
+ /** Whether MFA is Required */
229
+ readonly requireMfa?: boolean;
230
+ /** MFA Session Identifier */
231
+ readonly mfaSession?: string;
232
+ }
233
+
234
+ // =========================================
235
+ // Authentication State
236
+ // =========================================
237
+
238
+ /**
239
+ * Authentication State
240
+ *
241
+ * <p>Describes the complete state of the current authentication context.</p>
242
+ *
243
+ * @since 3.2.0
244
+ */
245
+ export interface AuthState {
246
+ /** Whether Authenticated */
247
+ readonly isAuthenticated: boolean;
248
+ /** Current User */
249
+ readonly user: User | null;
250
+ /** Current Tenant */
251
+ readonly tenant: Tenant | null;
252
+ /** Whether Loading */
253
+ readonly loading: boolean;
254
+ /** Data Scope List */
255
+ readonly dataScopes: DataScope[];
256
+ }
257
+
258
+ // =========================================
259
+ // Authentication State Change Event
260
+ // =========================================
261
+
262
+ /**
263
+ * Authentication State Change Event
264
+ *
265
+ * <p>Event triggered when authentication state changes.</p>
266
+ *
267
+ * @since 3.2.0
268
+ */
269
+ export interface AuthChangeEvent {
270
+ /** Event Type */
271
+ readonly type: 'login' | 'logout' | 'token_refresh' | 'user_update' | 'tenant_switch';
272
+ /** Current User (quick access) */
273
+ readonly user?: User | null;
274
+ /** New Authentication State */
275
+ readonly state: AuthState;
276
+ /** Previous Authentication State */
277
+ readonly previousState?: AuthState;
278
+ /** Event Timestamp */
279
+ readonly timestamp: number;
280
+ }
281
+
282
+ // =========================================
283
+ // Authentication Information
284
+ // =========================================
285
+
286
+ /**
287
+ * Authentication Information
288
+ *
289
+ * <p>Contains access token and refresh token.</p>
290
+ */
291
+ export interface AuthInfo {
292
+ /** Access Token */
293
+ readonly accessToken: string;
294
+ /** Refresh Token */
295
+ readonly refreshToken?: string;
296
+ /** Token Expiration Time (seconds) */
297
+ readonly expiresIn: number;
298
+ /** Token Type */
299
+ readonly tokenType: string;
300
+ }
301
+
302
+ // =========================================
303
+ // Authentication Capability Contract
304
+ // =========================================
305
+
306
+ /**
307
+ * Authentication Capability Contract
308
+ *
309
+ * <p>Provides user identity verification and permission checking capabilities for plugins.</p>
310
+ *
311
+ * <h3>Usage Example</h3>
312
+ * ```typescript
313
+ * const auth = context.getCapability<AuthCapability>(AuthCapabilityType);
314
+ *
315
+ * if (auth.isAuthenticated()) {
316
+ * const user = auth.getCurrentUser();
317
+ * if (auth.hasPermission('booking:create')) {
318
+ * // Create booking
319
+ * }
320
+ * }
321
+ * ```
322
+ *
323
+ * @since 3.2.0 Extended methods: getCurrentTenant, getTenantId, getDataScopes, getState, onAuthChange
324
+ */
325
+ export interface AuthCapability {
326
+ /**
327
+ * Get current logged-in user
328
+ *
329
+ * @returns Current user, returns null if not logged in
330
+ */
331
+ getCurrentUser(): User | null;
332
+
333
+ /**
334
+ * Check if authenticated
335
+ *
336
+ * @returns Whether logged in
337
+ */
338
+ isAuthenticated(): boolean;
339
+
340
+ /**
341
+ * User login
342
+ *
343
+ * @param credentials Login credentials
344
+ * @returns Login result
345
+ */
346
+ login(credentials: LoginCredentials): Promise<LoginResult>;
347
+
348
+ /**
349
+ * User logout
350
+ *
351
+ * @returns Promise, resolved when logout succeeds
352
+ */
353
+ logout(): Promise<void>;
354
+
355
+ /**
356
+ * Check if has specified permission
357
+ *
358
+ * @param permission Permission identifier
359
+ * @returns Whether has permission
360
+ */
361
+ hasPermission(permission: string): boolean;
362
+
363
+ /**
364
+ * Check if has any of the specified permissions
365
+ *
366
+ * @param permissions Permission identifier array
367
+ * @returns Whether has any permission
368
+ * @since 3.2.0
369
+ */
370
+ hasAnyPermission?(permissions: string[]): boolean;
371
+
372
+ /**
373
+ * Check if has all specified permissions
374
+ *
375
+ * @param permissions Permission identifier array
376
+ * @returns Whether has all permissions
377
+ * @since 3.2.0
378
+ */
379
+ hasAllPermissions?(permissions: string[]): boolean;
380
+
381
+ /**
382
+ * Check if has specified role
383
+ *
384
+ * @param role Role identifier
385
+ * @returns Whether has role
386
+ */
387
+ hasRole(role: string): boolean;
388
+
389
+ /**
390
+ * Check if has any of the specified roles
391
+ *
392
+ * @param roles Role identifier array
393
+ * @returns Whether has any role
394
+ * @since 3.2.0
395
+ */
396
+ hasAnyRole?(roles: string[]): boolean;
397
+
398
+ /**
399
+ * Check if has all specified roles
400
+ *
401
+ * @param roles Role identifier array
402
+ * @returns Whether has all roles
403
+ * @since 3.2.0
404
+ */
405
+ hasAllRoles?(roles: string[]): boolean;
406
+
407
+ /**
408
+ * Get current access token
409
+ *
410
+ * @returns Access token, returns null if not logged in
411
+ */
412
+ getToken(): string | null;
413
+
414
+ /**
415
+ * Get current tenant
416
+ *
417
+ * @returns Current tenant, returns null if not set
418
+ * @since 3.2.0
419
+ */
420
+ getCurrentTenant?(): Tenant | null;
421
+
422
+ /**
423
+ * Get tenant ID
424
+ *
425
+ * @returns Tenant ID, returns empty string if no tenant
426
+ * @since 3.2.0
427
+ */
428
+ getTenantId?(): string;
429
+
430
+ /**
431
+ * Get data scopes
432
+ *
433
+ * @param resource Resource type (optional)
434
+ * @returns Data scope list
435
+ * @since 3.2.0
436
+ */
437
+ getDataScopes?(resource?: string): DataScope[];
438
+
439
+ /**
440
+ * Get authentication state
441
+ *
442
+ * @returns Current authentication state
443
+ * @since 3.2.0
444
+ */
445
+ getState?(): AuthState;
446
+
447
+ /**
448
+ * Subscribe to authentication state changes
449
+ *
450
+ * @param listener Change listener
451
+ * @returns Unsubscribe function
452
+ * @since 3.2.0
453
+ */
454
+ onAuthChange?(listener: (event: AuthChangeEvent) => void): Unsubscribe;
455
+
456
+ /**
457
+ * Check if Feature Flag is enabled
458
+ *
459
+ * @param featureKey Feature Flag key name
460
+ * @returns Whether enabled
461
+ * @since 3.2.0
462
+ */
463
+ isFeatureEnabled?(featureKey: string): boolean;
464
+
465
+ /**
466
+ * Refresh access token
467
+ *
468
+ * @returns New access token
469
+ * @since 3.2.0
470
+ */
471
+ refreshToken?(): Promise<string>;
472
+
473
+ /**
474
+ * Destroy capability instance
475
+ *
476
+ * @since 3.2.0
477
+ */
478
+ destroy?(): void;
479
+ }