@brix-sdk/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 (66) hide show
  1. package/README.md +160 -0
  2. package/dist/index.js +190 -0
  3. package/package.json +44 -0
  4. package/src/api-exports.test.ts +199 -0
  5. package/src/context/RuntimeContext.d.ts +69 -0
  6. package/src/context/RuntimeContext.d.ts.map +1 -0
  7. package/src/context/RuntimeContext.ts +75 -0
  8. package/src/context/index.d.ts +23 -0
  9. package/src/context/index.d.ts.map +1 -0
  10. package/src/context/index.ts +23 -0
  11. package/src/index.d.ts +52 -0
  12. package/src/index.d.ts.map +1 -0
  13. package/src/index.ts +59 -0
  14. package/src/types/auth.d.ts +146 -0
  15. package/src/types/auth.d.ts.map +1 -0
  16. package/src/types/auth.ts +479 -0
  17. package/src/types/capability.d.ts +218 -0
  18. package/src/types/capability.d.ts.map +1 -0
  19. package/src/types/capability.ts +302 -0
  20. package/src/types/common.d.ts +99 -0
  21. package/src/types/common.d.ts.map +1 -0
  22. package/src/types/common.ts +115 -0
  23. package/src/types/config.d.ts +64 -0
  24. package/src/types/config.d.ts.map +1 -0
  25. package/src/types/config.ts +96 -0
  26. package/src/types/event.d.ts +206 -0
  27. package/src/types/event.d.ts.map +1 -0
  28. package/src/types/event.ts +776 -0
  29. package/src/types/http.d.ts +132 -0
  30. package/src/types/http.d.ts.map +1 -0
  31. package/src/types/http.ts +156 -0
  32. package/src/types/i18n.ts +420 -0
  33. package/src/types/index.d.ts +50 -0
  34. package/src/types/index.d.ts.map +1 -0
  35. package/src/types/index.ts +120 -0
  36. package/src/types/layout.ts +394 -0
  37. package/src/types/module.d.ts +78 -0
  38. package/src/types/module.d.ts.map +1 -0
  39. package/src/types/module.ts +92 -0
  40. package/src/types/navigation.d.ts +101 -0
  41. package/src/types/navigation.d.ts.map +1 -0
  42. package/src/types/navigation.ts +361 -0
  43. package/src/types/plugin-loader-capability.ts +159 -0
  44. package/src/types/plugin.d.ts +250 -0
  45. package/src/types/plugin.d.ts.map +1 -0
  46. package/src/types/plugin.ts +344 -0
  47. package/src/types/state.d.ts +119 -0
  48. package/src/types/state.d.ts.map +1 -0
  49. package/src/types/state.ts +366 -0
  50. package/src/types/theme.ts +378 -0
  51. package/src/types/ui/adapter.ts +222 -0
  52. package/src/types/ui/avatar.ts +113 -0
  53. package/src/types/ui/badge.ts +112 -0
  54. package/src/types/ui/button.ts +148 -0
  55. package/src/types/ui/card.ts +116 -0
  56. package/src/types/ui/common.ts +29 -0
  57. package/src/types/ui/icon.ts +85 -0
  58. package/src/types/ui/index.ts +78 -0
  59. package/src/types/ui/input.ts +225 -0
  60. package/src/types/ui/menu.ts +237 -0
  61. package/src/types/ui/message.ts +135 -0
  62. package/src/types/ui/modal.ts +188 -0
  63. package/src/types/ui/select.ts +239 -0
  64. package/src/types/ui/theme-tokens.ts +357 -0
  65. package/src/types/ui/tooltip.ts +120 -0
  66. package/src/types/ui.ts +49 -0
@@ -0,0 +1,75 @@
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 Runtime Context Abstract Definition
18
+ * @description Defines the core interface for runtime context (no React dependency)
19
+ * @module @brix-sdk/runtime-sdk-api-web/context/RuntimeContext
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Refactoring Notes]
23
+ * Extracted RuntimeContext abstraction from index.ts to keep the contract layer free of React dependencies.
24
+ * React-related Context and Hooks are migrated to @brix-sdk/runtime-sdk-react package.
25
+ *
26
+ * [Design Principles]
27
+ * - Pure abstract interface, no dependency on any UI framework
28
+ * - Can be used in React, Vue, native JS, and other environments
29
+ */
30
+
31
+ // =========================================
32
+ // Runtime Context Interface
33
+ // =========================================
34
+
35
+ /**
36
+ * Runtime Context Interface
37
+ *
38
+ * <p>Provides a unified entry point for plugins to access runtime capabilities.</p>
39
+ *
40
+ * <h3>Responsibilities</h3>
41
+ * <ul>
42
+ * <li>Provides module ID identification</li>
43
+ * <li>Provides tenant ID identification</li>
44
+ * <li>Provides capability retrieval method</li>
45
+ * </ul>
46
+ *
47
+ * <h3>Usage Example</h3>
48
+ * ```typescript
49
+ * const http = context.getCapability<HttpCapability>(HttpCapabilityType);
50
+ * const nav = context.getCapability<NavigationCapability>(NavigationCapabilityType);
51
+ * ```
52
+ */
53
+ export interface RuntimeContext {
54
+ /**
55
+ * Module/Plugin ID
56
+ *
57
+ * <p>Unique identifier for the current plugin.</p>
58
+ */
59
+ readonly moduleId: string;
60
+
61
+ /**
62
+ * Tenant ID
63
+ *
64
+ * <p>Tenant identifier for the current runtime environment.</p>
65
+ */
66
+ readonly tenantId: string;
67
+
68
+ /**
69
+ * Get capability instance
70
+ *
71
+ * @param capabilityType Capability type identifier (Symbol)
72
+ * @returns Capability instance, returns undefined if not found
73
+ */
74
+ getCapability<T>(capabilityType: symbol): T | undefined;
75
+ }
@@ -0,0 +1,23 @@
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 Context Module Unified Export
18
+ * @description Exports runtime context related types
19
+ * @module @brix-sdk/runtime-sdk-api-web/context
20
+ * @version 3.2.0
21
+ */
22
+ export * from './RuntimeContext';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
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 Context Module Unified Export
18
+ * @description Exports runtime context related types
19
+ * @module @brix-sdk/runtime-sdk-api-web/context
20
+ * @version 3.2.0
21
+ */
22
+
23
+ export * from './RuntimeContext';
package/src/index.d.ts ADDED
@@ -0,0 +1,52 @@
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-sdk/runtime-sdk-api-web Unified Entry Point
18
+ * @description UI Capability Contract Definitions - Web Platform (Framework-agnostic)
19
+ * @module @brix-sdk/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-sdk/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-sdk/runtime-sdk-react
48
+ * - RouteContribution.component type changed to framework-agnostic ComponentType
49
+ */
50
+ export * from './types';
51
+ export * from './context';
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAKH,cAAc,SAAS,CAAC;AAKxB,cAAc,WAAW,CAAC"}
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-sdk/runtime-sdk-api-web Unified Entry Point
18
+ * @description UI Capability Contract Definitions - Web Platform (Framework-agnostic)
19
+ * @module @brix-sdk/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-sdk/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-sdk/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-sdk/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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