@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.
- package/README.md +160 -0
- package/dist/index.js +190 -0
- package/package.json +44 -0
- package/src/api-exports.test.ts +199 -0
- package/src/context/RuntimeContext.d.ts +69 -0
- package/src/context/RuntimeContext.d.ts.map +1 -0
- package/src/context/RuntimeContext.ts +75 -0
- package/src/context/index.d.ts +23 -0
- package/src/context/index.d.ts.map +1 -0
- package/src/context/index.ts +23 -0
- package/src/index.d.ts +52 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +59 -0
- package/src/types/auth.d.ts +146 -0
- package/src/types/auth.d.ts.map +1 -0
- package/src/types/auth.ts +479 -0
- package/src/types/capability.d.ts +218 -0
- package/src/types/capability.d.ts.map +1 -0
- package/src/types/capability.ts +302 -0
- package/src/types/common.d.ts +99 -0
- package/src/types/common.d.ts.map +1 -0
- package/src/types/common.ts +115 -0
- package/src/types/config.d.ts +64 -0
- package/src/types/config.d.ts.map +1 -0
- package/src/types/config.ts +96 -0
- package/src/types/event.d.ts +206 -0
- package/src/types/event.d.ts.map +1 -0
- package/src/types/event.ts +776 -0
- package/src/types/http.d.ts +132 -0
- package/src/types/http.d.ts.map +1 -0
- package/src/types/http.ts +156 -0
- package/src/types/i18n.ts +420 -0
- package/src/types/index.d.ts +50 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.ts +120 -0
- package/src/types/layout.ts +394 -0
- package/src/types/module.d.ts +78 -0
- package/src/types/module.d.ts.map +1 -0
- package/src/types/module.ts +92 -0
- package/src/types/navigation.d.ts +101 -0
- package/src/types/navigation.d.ts.map +1 -0
- package/src/types/navigation.ts +361 -0
- package/src/types/plugin-loader-capability.ts +159 -0
- package/src/types/plugin.d.ts +250 -0
- package/src/types/plugin.d.ts.map +1 -0
- package/src/types/plugin.ts +344 -0
- package/src/types/state.d.ts +119 -0
- package/src/types/state.d.ts.map +1 -0
- package/src/types/state.ts +366 -0
- package/src/types/theme.ts +378 -0
- package/src/types/ui/adapter.ts +222 -0
- package/src/types/ui/avatar.ts +113 -0
- package/src/types/ui/badge.ts +112 -0
- package/src/types/ui/button.ts +148 -0
- package/src/types/ui/card.ts +116 -0
- package/src/types/ui/common.ts +29 -0
- package/src/types/ui/icon.ts +85 -0
- package/src/types/ui/index.ts +78 -0
- package/src/types/ui/input.ts +225 -0
- package/src/types/ui/menu.ts +237 -0
- package/src/types/ui/message.ts +135 -0
- package/src/types/ui/modal.ts +188 -0
- package/src/types/ui/select.ts +239 -0
- package/src/types/ui/theme-tokens.ts +357 -0
- package/src/types/ui/tooltip.ts +120 -0
- package/src/types/ui.ts +49 -0
|
@@ -0,0 +1,206 @@
|
|
|
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 Event-Related Type Definitions
|
|
18
|
+
* @description Defines core types for the event system, including event messages, handlers, subscription options, etc.
|
|
19
|
+
* @module @brix-sdk/runtime-sdk-api-web/types/event
|
|
20
|
+
* @version 3.2.0
|
|
21
|
+
*
|
|
22
|
+
* [v3.2 Changes]
|
|
23
|
+
* Extracted from index.ts into a standalone type file.
|
|
24
|
+
*
|
|
25
|
+
* [Design Principles]
|
|
26
|
+
* - Supports both simple Event Bus and Governed Event Bus modes
|
|
27
|
+
* - Governed Event Bus provides complete event metadata and audit information
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Event Message
|
|
31
|
+
*
|
|
32
|
+
* <p>Encapsulates complete event information including type, payload, timestamp, and source.</p>
|
|
33
|
+
*/
|
|
34
|
+
export interface EventMessage<T = unknown> {
|
|
35
|
+
/** Event Type */
|
|
36
|
+
readonly eventType: string;
|
|
37
|
+
/** Event Payload */
|
|
38
|
+
readonly payload: T;
|
|
39
|
+
/** Timestamp */
|
|
40
|
+
readonly timestamp: number;
|
|
41
|
+
/** Event Source (Plugin ID) */
|
|
42
|
+
readonly source?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Event Subscription Options
|
|
46
|
+
*/
|
|
47
|
+
export interface SubscriptionOptions {
|
|
48
|
+
/** Whether to trigger only once */
|
|
49
|
+
readonly once?: boolean;
|
|
50
|
+
/** Filter function */
|
|
51
|
+
readonly filter?: (payload: unknown) => boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Event Handler
|
|
55
|
+
*
|
|
56
|
+
* @typeParam T - Event payload type
|
|
57
|
+
*/
|
|
58
|
+
export type EventHandler<T = unknown> = (payload: T) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Unsubscribe Function
|
|
61
|
+
*/
|
|
62
|
+
export type Unsubscribe = () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Event Bus Capability Type Identifier
|
|
65
|
+
*/
|
|
66
|
+
export declare const EventBusCapabilityType: unique symbol;
|
|
67
|
+
/**
|
|
68
|
+
* Event Bus Capability Contract
|
|
69
|
+
*
|
|
70
|
+
* <p>Provides cross-plugin communication capability for plugins.</p>
|
|
71
|
+
*
|
|
72
|
+
* <h3>Usage Example</h3>
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const eventBus = context.getCapability<EventBusCapability>(EventBusCapabilityType);
|
|
75
|
+
*
|
|
76
|
+
* // Emit event
|
|
77
|
+
* eventBus.emit('booking:selected', { bookingId: '123' });
|
|
78
|
+
*
|
|
79
|
+
* // Subscribe to event
|
|
80
|
+
* const unsubscribe = eventBus.on('booking:selected', (payload) => {
|
|
81
|
+
* console.log('Booking selected:', payload);
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export interface EventBusCapability {
|
|
86
|
+
/**
|
|
87
|
+
* Emit event
|
|
88
|
+
*
|
|
89
|
+
* @param eventType Event type
|
|
90
|
+
* @param payload Event payload
|
|
91
|
+
*/
|
|
92
|
+
emit(eventType: string, payload: unknown): void;
|
|
93
|
+
/**
|
|
94
|
+
* Subscribe to event
|
|
95
|
+
*
|
|
96
|
+
* @param eventType Event type
|
|
97
|
+
* @param handler Event handler
|
|
98
|
+
* @returns Unsubscribe function
|
|
99
|
+
*/
|
|
100
|
+
on(eventType: string, handler: EventHandler): () => void;
|
|
101
|
+
/**
|
|
102
|
+
* Unsubscribe from event
|
|
103
|
+
*
|
|
104
|
+
* @param eventType Event type
|
|
105
|
+
* @param handler Event handler
|
|
106
|
+
*/
|
|
107
|
+
off(eventType: string, handler: EventHandler): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Governed Event Bus Capability Type Identifier
|
|
111
|
+
*/
|
|
112
|
+
export declare const GovernedEventBusCapabilityType: unique symbol;
|
|
113
|
+
/**
|
|
114
|
+
* Governed Event
|
|
115
|
+
*
|
|
116
|
+
* <p>Event containing complete metadata for observability and auditing.</p>
|
|
117
|
+
*/
|
|
118
|
+
export interface GovernedEvent<T = unknown> {
|
|
119
|
+
/** Event Type */
|
|
120
|
+
readonly type: string;
|
|
121
|
+
/** Event Payload */
|
|
122
|
+
readonly payload: T;
|
|
123
|
+
/** Event Metadata */
|
|
124
|
+
readonly metadata: GovernedEventMetadata;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Governed Event Metadata
|
|
128
|
+
*/
|
|
129
|
+
export interface GovernedEventMetadata {
|
|
130
|
+
/** Event ID (Unique Identifier) */
|
|
131
|
+
readonly eventId: string;
|
|
132
|
+
/** Emit Timestamp */
|
|
133
|
+
readonly timestamp: number;
|
|
134
|
+
/** Sender (Plugin ID) */
|
|
135
|
+
readonly source: string;
|
|
136
|
+
/** Tenant ID */
|
|
137
|
+
readonly tenantId?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Event Scope
|
|
140
|
+
* - 'plugin': Visible only within the plugin
|
|
141
|
+
* - 'host': Globally visible
|
|
142
|
+
*/
|
|
143
|
+
readonly scope: 'plugin' | 'host';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Governed Event Handler Function
|
|
147
|
+
*/
|
|
148
|
+
export type GovernedEventHandler<T = unknown> = (event: GovernedEvent<T>) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Governed Event Bus Capability Contract
|
|
151
|
+
*
|
|
152
|
+
* <p>Unlike the simple EventBusCapability, GovernedEventBusCapability provides:</p>
|
|
153
|
+
* <ul>
|
|
154
|
+
* <li>Automatic injection of event metadata (eventId, timestamp, source)</li>
|
|
155
|
+
* <li>Event scope control (plugin/host)</li>
|
|
156
|
+
* <li>Complete event audit information</li>
|
|
157
|
+
* </ul>
|
|
158
|
+
*
|
|
159
|
+
* <h3>Usage Example</h3>
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const eventBus = context.getCapability<GovernedEventBusCapability>(GovernedEventBusCapabilityType);
|
|
162
|
+
*
|
|
163
|
+
* // Emit global event
|
|
164
|
+
* eventBus.emit('booking:created', { bookingId: '123' }, 'host');
|
|
165
|
+
*
|
|
166
|
+
* // Subscribe to event (receive complete metadata)
|
|
167
|
+
* eventBus.on('booking:created', (event) => {
|
|
168
|
+
* console.log(`Event ${event.metadata.eventId} from ${event.metadata.source}`);
|
|
169
|
+
* console.log('Payload:', event.payload);
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export interface GovernedEventBusCapability {
|
|
174
|
+
/**
|
|
175
|
+
* Emit Event
|
|
176
|
+
*
|
|
177
|
+
* @param eventType Event type
|
|
178
|
+
* @param payload Event payload
|
|
179
|
+
* @param scope Event scope (default 'host')
|
|
180
|
+
*/
|
|
181
|
+
emit<T = unknown>(eventType: string, payload: T, scope?: 'plugin' | 'host'): void;
|
|
182
|
+
/**
|
|
183
|
+
* Subscribe to Event
|
|
184
|
+
*
|
|
185
|
+
* @param eventType Event type
|
|
186
|
+
* @param handler Event handler function, receives complete GovernedEvent
|
|
187
|
+
* @returns Unsubscribe function
|
|
188
|
+
*/
|
|
189
|
+
on<T = unknown>(eventType: string, handler: GovernedEventHandler<T>): Unsubscribe;
|
|
190
|
+
/**
|
|
191
|
+
* Subscribe to Event Once
|
|
192
|
+
*
|
|
193
|
+
* @param eventType Event type
|
|
194
|
+
* @param handler Event handler function
|
|
195
|
+
* @returns Unsubscribe function
|
|
196
|
+
*/
|
|
197
|
+
once<T = unknown>(eventType: string, handler: GovernedEventHandler<T>): Unsubscribe;
|
|
198
|
+
/**
|
|
199
|
+
* Unsubscribe from Event
|
|
200
|
+
*
|
|
201
|
+
* @param eventType Event type
|
|
202
|
+
* @param handler Event handler function
|
|
203
|
+
*/
|
|
204
|
+
off<T = unknown>(eventType: string, handler: GovernedEventHandler<T>): void;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,WAAW;IACX,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,WAAW;IACX,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,UAAU;IACV,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kBAAkB;IAClB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CA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