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
@@ -0,0 +1,218 @@
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 Capability Related Type Definitions
18
+ * @description Defines core types for the capability system, including capability metadata, status, registry, etc.
19
+ * @module @brix/runtime-sdk-api-web/types/capability
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file to keep the contract layer clean.
24
+ *
25
+ * [Design Principles]
26
+ * - All type definitions use readonly properties
27
+ * - Use Symbol as capability unique identifier (type-safe)
28
+ * - Support lazy initialization and scope control for capabilities
29
+ */
30
+ /**
31
+ * Capability Priority Enum
32
+ *
33
+ * <p>Used to determine which implementation to use when multiple capability providers conflict.</p>
34
+ */
35
+ export declare enum CapabilityPriority {
36
+ /** Low Priority (fallback implementation) */
37
+ LOW = 0,
38
+ /** Normal Priority (default) */
39
+ NORMAL = 50,
40
+ /** High Priority (overrides default implementation) */
41
+ HIGH = 100
42
+ }
43
+ /**
44
+ * Capability Metadata (Simplified)
45
+ */
46
+ export interface CapabilityMetadata {
47
+ /** Capability Name */
48
+ readonly name: string;
49
+ /** Capability Version */
50
+ readonly version: string;
51
+ /** Priority */
52
+ readonly priority: CapabilityPriority;
53
+ /** Whether Required */
54
+ readonly required: boolean;
55
+ }
56
+ /**
57
+ * Capability ID Type
58
+ *
59
+ * <p>Supports string or Symbol, recommend using Symbol.for() to ensure uniqueness.</p>
60
+ */
61
+ export type CapabilityId = string | symbol;
62
+ /**
63
+ * Capability Meta Information (Full Version)
64
+ *
65
+ * <p>Contains complete metadata for capability registration and discovery.</p>
66
+ */
67
+ export interface CapabilityMeta {
68
+ /** Capability Unique Identifier */
69
+ readonly id: CapabilityId;
70
+ /** Capability Name (Human-readable) */
71
+ readonly name: string;
72
+ /** Capability Description */
73
+ readonly description?: string;
74
+ /** Capability Version */
75
+ readonly version?: string;
76
+ /** Dependent Capability ID List */
77
+ readonly dependencies?: CapabilityId[];
78
+ /** Tags (for filtering and categorization) */
79
+ readonly tags?: string[];
80
+ }
81
+ /**
82
+ * Capability Status
83
+ *
84
+ * <p>Describes the current status of a capability in its lifecycle.</p>
85
+ */
86
+ export type CapabilityStatus = 'registered' | 'initializing' | 'ready' | 'error' | 'disposed';
87
+ /**
88
+ * Capability Type Identifier (Generic Interface)
89
+ *
90
+ * <p>Used to identify and create capability instances, containing capability metadata.
91
+ * Uses phantom property `_phantom` for type inference.</p>
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * interface MyCapability {
96
+ * doSomething(): void;
97
+ * }
98
+ *
99
+ * const MyCapabilityType = createCapabilityType<MyCapability>({
100
+ * id: 'my-capability',
101
+ * name: 'My Capability',
102
+ * });
103
+ * ```
104
+ */
105
+ export interface CapabilityType<T = unknown> extends CapabilityMeta {
106
+ /**
107
+ * Phantom property for type inference
108
+ * Does not exist at runtime, only for TypeScript type system
109
+ */
110
+ readonly _phantom?: T;
111
+ }
112
+ /**
113
+ * Create Capability Type Identifier
114
+ *
115
+ * @param meta - Capability meta information
116
+ * @returns Capability type identifier object
117
+ */
118
+ export declare function createCapabilityType<T>(meta: Omit<CapabilityMeta, 'id'> & {
119
+ id: string;
120
+ }): CapabilityType<T>;
121
+ /**
122
+ * Capability Provider Interface
123
+ *
124
+ * <p>Encapsulates the creation and disposal logic of capability instances.</p>
125
+ */
126
+ export interface CapabilityProvider<T = unknown> {
127
+ /** Get capability instance */
128
+ provide(): T;
129
+ /** Dispose capability instance (optional) */
130
+ dispose?(): void;
131
+ }
132
+ /**
133
+ * Simple Capability Provider
134
+ *
135
+ * <p>Can be the capability instance itself, or a factory function that returns the capability instance.</p>
136
+ */
137
+ export type SimpleCapabilityProvider<T> = T | (() => T);
138
+ /**
139
+ * Capability Registration Options
140
+ */
141
+ export interface CapabilityRegisterOptions {
142
+ /**
143
+ * Whether to override existing capability
144
+ */
145
+ override?: boolean;
146
+ /**
147
+ * Capability priority
148
+ */
149
+ priority?: CapabilityPriority;
150
+ /**
151
+ * Capability scope
152
+ * - 'global': Global scope, shared by all modules
153
+ * - 'module': Module scope, only available in current module
154
+ * @default 'global'
155
+ */
156
+ scope?: 'global' | 'module';
157
+ /**
158
+ * Lazy initialization
159
+ * When true, capability is instantiated on first use
160
+ * @default false
161
+ */
162
+ lazy?: boolean;
163
+ }
164
+ /**
165
+ * Capability Runtime Information
166
+ *
167
+ * <p>Describes the detailed status of a capability at runtime.</p>
168
+ */
169
+ export interface CapabilityRuntimeInfo {
170
+ /** Capability Metadata */
171
+ readonly meta: CapabilityMeta;
172
+ /** Current Status */
173
+ readonly status: CapabilityStatus;
174
+ /** Registration Timestamp */
175
+ readonly registeredAt: number;
176
+ /** Initialization Timestamp */
177
+ readonly initializedAt?: number;
178
+ /** Error Information (when status is error) */
179
+ readonly error?: Error;
180
+ /** Invocation Count Statistics */
181
+ readonly invocationCount: number;
182
+ }
183
+ /**
184
+ * Capability Registry Interface
185
+ *
186
+ * <p>Manages registration, retrieval, initialization, and disposal of capabilities.</p>
187
+ */
188
+ export interface CapabilityRegistry {
189
+ /** Get capability instance */
190
+ get<T>(capabilityType: CapabilityType<T>): T | undefined;
191
+ /** Get required capability (throws exception if not found) */
192
+ getRequired<T>(capabilityType: CapabilityType<T>): T;
193
+ /** Register capability */
194
+ register<T>(capabilityType: CapabilityType<T>, provider: CapabilityProvider<T>, options?: CapabilityRegisterOptions): void;
195
+ /** Unregister capability */
196
+ unregister<T>(capabilityType: CapabilityType<T>): boolean;
197
+ /** Check if capability is registered */
198
+ has<T>(capabilityType: CapabilityType<T>): boolean;
199
+ /** Check if capability is ready */
200
+ isReady<T>(capabilityType: CapabilityType<T>): boolean;
201
+ /** Get capability runtime information */
202
+ getInfo<T>(capabilityType: CapabilityType<T>): CapabilityRuntimeInfo | undefined;
203
+ /** Get all registered capability IDs */
204
+ getRegisteredIds(): CapabilityId[];
205
+ /** Get runtime information for all capabilities */
206
+ getAllInfo(): Map<CapabilityId, CapabilityRuntimeInfo>;
207
+ /** Filter capabilities by status */
208
+ getByStatus(status: CapabilityStatus): CapabilityId[];
209
+ /** Filter capabilities by tag */
210
+ getByTag(tag: string): CapabilityId[];
211
+ /** Initialize all registered capabilities */
212
+ initializeAll(): Promise<boolean>;
213
+ /** Dispose all capabilities */
214
+ disposeAll(): Promise<void>;
215
+ /** Reset registry */
216
+ reset(): void;
217
+ }
218
+ //# sourceMappingURL=capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,iBAAiB;IACjB,GAAG,IAAI;IACP,gBAAgB;IAChB,MAAM,KAAK;IACX,mBAAmB;IACnB,IAAI,MAAM;CACX;AAMD;;GAEG;AACH,MAAM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kBAAkB,CAAC,CAAC,CAAC,EAC/B,OAAO,CAAC,EAAE,yBAAyB,GAClC,IAAI,CAAC;IAER,WAAW;IACX,UAAU,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAE1D,gBAAgB;IAChB,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAEnD,eAAe;IACf,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAEvD,gBAAgB;IAChB,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,qBAAqB,GAAG,SAAS,CAAC;IAEjF,oBAAoB;IACpB,gBAAgB,IAAI,YAAY,EAAE,CAAC;IAEnC,mBAAmB;IACnB,UAAU,IAAI,GAAG,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IAEvD,cAAc;IACd,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,EAAE,CAAC;IAEtD,cAAc;IACd,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;IAEtC,kBAAkB;IAClB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAElC,aAAa;IACb,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,YAAY;IACZ,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -0,0 +1,302 @@
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 Capability Related Type Definitions
18
+ * @description Defines core types for the capability system, including capability metadata, status, registry, etc.
19
+ * @module @brix/runtime-sdk-api-web/types/capability
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file to keep the contract layer clean.
24
+ *
25
+ * [Design Principles]
26
+ * - All type definitions use readonly properties
27
+ * - Use Symbol as capability unique identifier (type-safe)
28
+ * - Support lazy initialization and scope control for capabilities
29
+ */
30
+
31
+ // =========================================
32
+ // Capability Priority
33
+ // =========================================
34
+
35
+ /**
36
+ * Capability Priority Enum
37
+ *
38
+ * <p>Used to determine which implementation to use when multiple capability providers conflict.</p>
39
+ */
40
+ export enum CapabilityPriority {
41
+ /** Low Priority (fallback implementation) */
42
+ LOW = 0,
43
+ /** Normal Priority (default) */
44
+ NORMAL = 50,
45
+ /** High Priority (overrides default implementation) */
46
+ HIGH = 100,
47
+ }
48
+
49
+ // =========================================
50
+ // Capability Metadata
51
+ // =========================================
52
+
53
+ /**
54
+ * Capability Metadata (Simplified)
55
+ */
56
+ export interface CapabilityMetadata {
57
+ /** Capability Name */
58
+ readonly name: string;
59
+ /** Capability Version */
60
+ readonly version: string;
61
+ /** Priority */
62
+ readonly priority: CapabilityPriority;
63
+ /** Whether Required */
64
+ readonly required: boolean;
65
+ }
66
+
67
+ /**
68
+ * Capability ID Type
69
+ *
70
+ * <p>Supports string or Symbol, recommend using Symbol.for() to ensure uniqueness.</p>
71
+ */
72
+ export type CapabilityId = string | symbol;
73
+
74
+ /**
75
+ * Capability Meta Information (Full Version)
76
+ *
77
+ * <p>Contains complete metadata for capability registration and discovery.</p>
78
+ */
79
+ export interface CapabilityMeta {
80
+ /** Capability Unique Identifier */
81
+ readonly id: CapabilityId;
82
+
83
+ /** Capability Name (Human-readable) */
84
+ readonly name: string;
85
+
86
+ /** Capability Description */
87
+ readonly description?: string;
88
+
89
+ /** Capability Version */
90
+ readonly version?: string;
91
+
92
+ /** Dependent Capability ID List */
93
+ readonly dependencies?: CapabilityId[];
94
+
95
+ /** Tags (for filtering and categorization) */
96
+ readonly tags?: string[];
97
+ }
98
+
99
+ // =========================================
100
+ // Capability Status
101
+ // =========================================
102
+
103
+ /**
104
+ * Capability Status
105
+ *
106
+ * <p>Describes the current status of a capability in its lifecycle.</p>
107
+ */
108
+ export type CapabilityStatus =
109
+ | 'registered' // Registered, not initialized
110
+ | 'initializing' // Initializing
111
+ | 'ready' // Ready, available for use
112
+ | 'error' // Error state
113
+ | 'disposed'; // Disposed
114
+
115
+ // =========================================
116
+ // Capability Type Identifier
117
+ // =========================================
118
+
119
+ /**
120
+ * Capability Type Identifier (Generic Interface)
121
+ *
122
+ * <p>Used to identify and create capability instances, containing capability metadata.
123
+ * Uses phantom property `_phantom` for type inference.</p>
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * interface MyCapability {
128
+ * doSomething(): void;
129
+ * }
130
+ *
131
+ * const MyCapabilityType = createCapabilityType<MyCapability>({
132
+ * id: 'my-capability',
133
+ * name: 'My Capability',
134
+ * });
135
+ * ```
136
+ */
137
+ export interface CapabilityType<T = unknown> extends CapabilityMeta {
138
+ /**
139
+ * Phantom property for type inference
140
+ * Does not exist at runtime, only for TypeScript type system
141
+ */
142
+ readonly _phantom?: T;
143
+ }
144
+
145
+ /**
146
+ * Create Capability Type Identifier
147
+ *
148
+ * @param meta - Capability meta information
149
+ * @returns Capability type identifier object
150
+ */
151
+ export function createCapabilityType<T>(
152
+ meta: Omit<CapabilityMeta, 'id'> & { id: string }
153
+ ): CapabilityType<T> {
154
+ return {
155
+ ...meta,
156
+ id: Symbol.for(meta.id),
157
+ } as CapabilityType<T>;
158
+ }
159
+
160
+ // =========================================
161
+ // Capability Provider
162
+ // =========================================
163
+
164
+ /**
165
+ * Capability Provider Interface
166
+ *
167
+ * <p>Encapsulates the creation and disposal logic of capability instances.</p>
168
+ */
169
+ export interface CapabilityProvider<T = unknown> {
170
+ /** Get capability instance */
171
+ provide(): T;
172
+
173
+ /** Dispose capability instance (optional) */
174
+ dispose?(): void;
175
+ }
176
+
177
+ /**
178
+ * Simple Capability Provider
179
+ *
180
+ * <p>Can be the capability instance itself, or a factory function that returns the capability instance.</p>
181
+ */
182
+ export type SimpleCapabilityProvider<T> = T | (() => T);
183
+
184
+ // =========================================
185
+ // Capability Registration Options
186
+ // =========================================
187
+
188
+ /**
189
+ * Capability Registration Options
190
+ */
191
+ export interface CapabilityRegisterOptions {
192
+ /**
193
+ * Whether to override existing capability
194
+ */
195
+ override?: boolean;
196
+
197
+ /**
198
+ * Capability priority
199
+ */
200
+ priority?: CapabilityPriority;
201
+
202
+ /**
203
+ * Capability scope
204
+ * - 'global': Global scope, shared by all modules
205
+ * - 'module': Module scope, only available in current module
206
+ * @default 'global'
207
+ */
208
+ scope?: 'global' | 'module';
209
+
210
+ /**
211
+ * Lazy initialization
212
+ * When true, capability is instantiated on first use
213
+ * @default false
214
+ */
215
+ lazy?: boolean;
216
+ }
217
+
218
+ // =========================================
219
+ // Capability Runtime Information
220
+ // =========================================
221
+
222
+ /**
223
+ * Capability Runtime Information
224
+ *
225
+ * <p>Describes the detailed status of a capability at runtime.</p>
226
+ */
227
+ export interface CapabilityRuntimeInfo {
228
+ /** Capability Metadata */
229
+ readonly meta: CapabilityMeta;
230
+
231
+ /** Current Status */
232
+ readonly status: CapabilityStatus;
233
+
234
+ /** Registration Timestamp */
235
+ readonly registeredAt: number;
236
+
237
+ /** Initialization Timestamp */
238
+ readonly initializedAt?: number;
239
+
240
+ /** Error Information (when status is error) */
241
+ readonly error?: Error;
242
+
243
+ /** Invocation Count Statistics */
244
+ readonly invocationCount: number;
245
+ }
246
+
247
+ // =========================================
248
+ // Capability Registry Interface
249
+ // =========================================
250
+
251
+ /**
252
+ * Capability Registry Interface
253
+ *
254
+ * <p>Manages registration, retrieval, initialization, and disposal of capabilities.</p>
255
+ */
256
+ export interface CapabilityRegistry {
257
+ /** Get capability instance */
258
+ get<T>(capabilityType: CapabilityType<T>): T | undefined;
259
+
260
+ /** Get required capability (throws exception if not found) */
261
+ getRequired<T>(capabilityType: CapabilityType<T>): T;
262
+
263
+ /** Register capability */
264
+ register<T>(
265
+ capabilityType: CapabilityType<T>,
266
+ provider: CapabilityProvider<T>,
267
+ options?: CapabilityRegisterOptions
268
+ ): void;
269
+
270
+ /** Unregister capability */
271
+ unregister<T>(capabilityType: CapabilityType<T>): boolean;
272
+
273
+ /** Check if capability is registered */
274
+ has<T>(capabilityType: CapabilityType<T>): boolean;
275
+
276
+ /** Check if capability is ready */
277
+ isReady<T>(capabilityType: CapabilityType<T>): boolean;
278
+
279
+ /** Get capability runtime information */
280
+ getInfo<T>(capabilityType: CapabilityType<T>): CapabilityRuntimeInfo | undefined;
281
+
282
+ /** Get all registered capability IDs */
283
+ getRegisteredIds(): CapabilityId[];
284
+
285
+ /** Get runtime information for all capabilities */
286
+ getAllInfo(): Map<CapabilityId, CapabilityRuntimeInfo>;
287
+
288
+ /** Filter capabilities by status */
289
+ getByStatus(status: CapabilityStatus): CapabilityId[];
290
+
291
+ /** Filter capabilities by tag */
292
+ getByTag(tag: string): CapabilityId[];
293
+
294
+ /** Initialize all registered capabilities */
295
+ initializeAll(): Promise<boolean>;
296
+
297
+ /** Dispose all capabilities */
298
+ disposeAll(): Promise<void>;
299
+
300
+ /** Reset registry */
301
+ reset(): void;
302
+ }
@@ -0,0 +1,99 @@
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 Common Type Definitions
18
+ * @description Defines utility types and API response types
19
+ * @module @brix/runtime-sdk-api-web/types/common
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file.
24
+ */
25
+ /**
26
+ * Optional Fields
27
+ *
28
+ * <p>Makes specified fields optional.</p>
29
+ */
30
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
31
+ /**
32
+ * Required Fields
33
+ *
34
+ * <p>Makes specified fields required. Named to avoid conflict with built-in Required.</p>
35
+ */
36
+ export type RequiredFields<T, K extends keyof T> = T & {
37
+ [P in K]-?: T[P];
38
+ };
39
+ /**
40
+ * Deep Readonly
41
+ *
42
+ * <p>Recursively makes all properties readonly.</p>
43
+ */
44
+ export type DeepReadonly<T> = {
45
+ readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
46
+ };
47
+ /**
48
+ * Standard API Response
49
+ */
50
+ export interface ApiResponse<T = unknown> {
51
+ /** Whether Successful */
52
+ readonly success: boolean;
53
+ /** Response Data */
54
+ readonly data?: T;
55
+ /** Error Information */
56
+ readonly error?: ApiError;
57
+ /** Timestamp */
58
+ readonly timestamp: number;
59
+ }
60
+ /**
61
+ * API Error
62
+ */
63
+ export interface ApiError {
64
+ /** Error Code */
65
+ readonly code: string;
66
+ /** Error Message */
67
+ readonly message: string;
68
+ /** Details */
69
+ readonly details?: Record<string, unknown>;
70
+ }
71
+ /**
72
+ * Paged Response
73
+ */
74
+ export interface PagedResponse<T> {
75
+ /** Data List */
76
+ readonly items: T[];
77
+ /** Total Count */
78
+ readonly total: number;
79
+ /** Current Page */
80
+ readonly page: number;
81
+ /** Page Size */
82
+ readonly pageSize: number;
83
+ /** Total Pages */
84
+ readonly totalPages: number;
85
+ }
86
+ /**
87
+ * Paged Request
88
+ */
89
+ export interface PagedRequest {
90
+ /** Current Page */
91
+ readonly page: number;
92
+ /** Page Size */
93
+ readonly pageSize: number;
94
+ /** Sort Field */
95
+ readonly sort?: string;
96
+ /** Sort Direction */
97
+ readonly order?: 'asc' | 'desc';
98
+ }
99
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,WAAW;IACX,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,WAAW;IACX,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,WAAW;IACX,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;IAC1B,UAAU;IACV,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,WAAW;IACX,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,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