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,366 @@
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 State-Related Type Definitions
18
+ * @description Defines core types for the state management system, including state change events, listeners, etc.
19
+ * @module @brix/runtime-sdk-api-web/types/state
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file, and promoted common contracts from infra-adapter-state-web.
24
+ *
25
+ * [v3.2.0 Phase 1 Contract Layer Fix]
26
+ * Added types required by PluginStateCapabilityImpl:
27
+ * - StatePersistenceOptions: State persistence options
28
+ * - PluginStateChangeEvent: Plugin state change event
29
+ * - PluginStateSubscribeOptions: Plugin state subscribe options
30
+ * - PluginStateCapability interface extension: get/set new method signatures
31
+ *
32
+ * [Design Principles]
33
+ * - Define common state management contracts, state adapters implement specific storage logic
34
+ * - Support namespace isolation (each plugin has independent state space)
35
+ * - Support state change subscription
36
+ */
37
+
38
+ // =========================================
39
+ // Plugin State Storage Structure
40
+ // =========================================
41
+
42
+ /**
43
+ * Plugin State Storage Structure
44
+ *
45
+ * <p>Top level partitioned by plugin ID, each plugin has independent state namespace.</p>
46
+ *
47
+ * <h3>Namespace Isolation Mechanism</h3>
48
+ * <ul>
49
+ * <li>booking plugin: state.booking.*</li>
50
+ * <li>identity plugin: state.identity.*</li>
51
+ * </ul>
52
+ * <p>Plugin A cannot directly read/write Plugin B's state.</p>
53
+ */
54
+ export interface PluginStoreState {
55
+ /** State partitioned by plugin ID */
56
+ [pluginId: string]: Record<string, unknown>;
57
+ }
58
+
59
+ // =========================================
60
+ // State Change Event
61
+ // =========================================
62
+
63
+ /**
64
+ * State Change Event
65
+ *
66
+ * <p>Describes details of state changes, used for observability and debugging.</p>
67
+ */
68
+ export interface StateChangeEvent {
69
+ /** Plugin ID */
70
+ readonly pluginId: string;
71
+ /** State key */
72
+ readonly key: string;
73
+ /** Old value */
74
+ readonly oldValue: unknown;
75
+ /** New value */
76
+ readonly newValue: unknown;
77
+ /** Timestamp */
78
+ readonly timestamp?: number;
79
+ }
80
+
81
+ /**
82
+ * State Change Listener
83
+ */
84
+ export type StateChangeListener = (event: StateChangeEvent) => void;
85
+
86
+ // =========================================
87
+ // State Persistence Options (v3.2.0 Addition)
88
+ // =========================================
89
+
90
+ /**
91
+ * State Persistence Options
92
+ *
93
+ * <p>Controls state persistence behavior.</p>
94
+ *
95
+ * @since 3.2.0
96
+ */
97
+ export interface StatePersistenceOptions {
98
+ /**
99
+ * Whether to Persist to Local Storage
100
+ *
101
+ * @default false
102
+ */
103
+ readonly persist?: boolean;
104
+
105
+ /**
106
+ * Storage Location
107
+ *
108
+ * - 'localStorage': Persistent storage, retained after browser closes
109
+ * - 'sessionStorage': Session storage, cleared after browser closes
110
+ *
111
+ * @default 'localStorage'
112
+ */
113
+ readonly storage?: 'localStorage' | 'sessionStorage';
114
+
115
+ /**
116
+ * Expiration Time (milliseconds)
117
+ *
118
+ * <p>When set, state will be automatically cleared after the specified time.</p>
119
+ */
120
+ readonly ttl?: number;
121
+
122
+ /**
123
+ * Serializer Name
124
+ *
125
+ * <p>Used for custom serialization/deserialization logic.</p>
126
+ */
127
+ readonly serializer?: string;
128
+ }
129
+
130
+ // =========================================
131
+ // Plugin State Change Event (v3.2.0 Addition)
132
+ // =========================================
133
+
134
+ /**
135
+ * Plugin State Change Event
136
+ *
137
+ * <p>Describes details of plugin state changes. Similar to StateChangeEvent,
138
+ * but specifically for plugin state subscription callbacks.</p>
139
+ *
140
+ * @since 3.2.0
141
+ */
142
+ export interface PluginStateChangeEvent<T = unknown> {
143
+ /** State key (without namespace prefix) */
144
+ readonly key: string;
145
+ /** Full state key (with namespace prefix) */
146
+ readonly fullKey: string;
147
+ /** Plugin ID */
148
+ readonly pluginId: string;
149
+ /** New value */
150
+ readonly value: T;
151
+ /** Previous value */
152
+ readonly previousValue?: T;
153
+ /** Change timestamp */
154
+ readonly timestamp: number;
155
+ }
156
+
157
+ // =========================================
158
+ // Plugin State Subscribe Options (v3.2.0 Addition)
159
+ // =========================================
160
+
161
+ /**
162
+ * Plugin State Subscribe Options
163
+ *
164
+ * <p>Configuration parameters controlling state subscription behavior.</p>
165
+ *
166
+ * @since 3.2.0
167
+ */
168
+ export interface PluginStateSubscribeOptions {
169
+ /**
170
+ * Whether to Fire Callback Immediately
171
+ *
172
+ * <p>If true, the callback function will be called immediately on subscription with the current value.</p>
173
+ *
174
+ * @default false
175
+ */
176
+ readonly fireImmediately?: boolean;
177
+
178
+ /**
179
+ * Equality Comparison Function
180
+ *
181
+ * <p>Used to determine if old and new values are equal, returns true if equal (no callback triggered).</p>
182
+ */
183
+ readonly equalityFn?: (a: unknown, b: unknown) => boolean;
184
+ }
185
+
186
+ // =========================================
187
+ // Plugin State Capability
188
+ // =========================================
189
+
190
+ /**
191
+ * Plugin State Capability Type Identifier
192
+ */
193
+ export const PluginStateCapabilityType = Symbol.for('PluginStateCapability');
194
+
195
+ /**
196
+ * Plugin State Capability Contract
197
+ *
198
+ * <p>Provides isolated state management capability for plugins, replacing direct use of localStorage/sessionStorage/zustand.</p>
199
+ *
200
+ * <h3>Usage Example</h3>
201
+ * ```typescript
202
+ * const state = context.getCapability<PluginStateCapability>(PluginStateCapabilityType);
203
+ * state.set('selectedDate', new Date());
204
+ * const date = state.get<Date>('selectedDate');
205
+ *
206
+ * // Subscribe to state changes
207
+ * const unsubscribe = state.subscribe('selectedDate', (value) => {
208
+ * console.log('Date changed:', value);
209
+ * });
210
+ * ```
211
+ *
212
+ * <h3>Architectural Notes</h3>
213
+ * <ul>
214
+ * <li>Each plugin's state is in an independent namespace</li>
215
+ * <li>Cross-plugin state sharing through EventBus</li>
216
+ * <li>Direct access to other plugins' state is prohibited</li>
217
+ * </ul>
218
+ *
219
+ * @since 3.2.0 Extended methods: get/set, delete, has, getOrDefault, update, reset, keys, getAll, setMany
220
+ */
221
+ export interface PluginStateCapability {
222
+ /**
223
+ * Get State Value
224
+ *
225
+ * @param key State key
226
+ * @returns State value, returns undefined if not exists
227
+ */
228
+ get<T>(key: string): T | undefined;
229
+
230
+ /**
231
+ * Set State Value
232
+ *
233
+ * @param key State key
234
+ * @param value State value
235
+ * @param options Persistence options
236
+ */
237
+ set<T>(key: string, value: T, options?: StatePersistenceOptions): void;
238
+
239
+ /**
240
+ * Delete State
241
+ *
242
+ * @param key State key
243
+ * @returns Whether deletion succeeded
244
+ * @since 3.2.0
245
+ */
246
+ delete?(key: string): boolean;
247
+
248
+ /**
249
+ * Check If State Exists
250
+ *
251
+ * @param key State key
252
+ * @returns Whether exists
253
+ * @since 3.2.0
254
+ */
255
+ has?(key: string): boolean;
256
+
257
+ /**
258
+ * Get State Value (With Default)
259
+ *
260
+ * @param key State key
261
+ * @param defaultValue Default value
262
+ * @returns State value or default value
263
+ * @since 3.2.0
264
+ */
265
+ getOrDefault?<T>(key: string, defaultValue: T): T;
266
+
267
+ /**
268
+ * Update State Value
269
+ *
270
+ * @param key State key
271
+ * @param updater Update function
272
+ * @since 3.2.0
273
+ */
274
+ update?<T>(key: string, updater: (currentValue: T | undefined) => T): void;
275
+
276
+ /**
277
+ * Reset All Plugin State
278
+ *
279
+ * @since 3.2.0
280
+ */
281
+ reset?(): void;
282
+
283
+ /**
284
+ * Get All State Keys
285
+ *
286
+ * @returns Array of state keys
287
+ * @since 3.2.0
288
+ */
289
+ keys?(): string[];
290
+
291
+ /**
292
+ * Get All State
293
+ *
294
+ * @returns State object
295
+ * @since 3.2.0
296
+ */
297
+ getAll?<T extends Record<string, unknown> = Record<string, unknown>>(): T;
298
+
299
+ /**
300
+ * Batch Set State
301
+ *
302
+ * @param states State object
303
+ * @since 3.2.0
304
+ */
305
+ setMany?(states: Record<string, unknown>): void;
306
+
307
+ /**
308
+ * Subscribe to State Changes
309
+ *
310
+ * @param key State key
311
+ * @param listener Change listener
312
+ * @param options Subscribe options
313
+ * @returns Unsubscribe function
314
+ */
315
+ subscribe<T>(
316
+ key: string,
317
+ listener: (value: T, event?: PluginStateChangeEvent<T>) => void,
318
+ options?: PluginStateSubscribeOptions
319
+ ): () => void;
320
+
321
+ /**
322
+ * Selective State Change Subscription
323
+ *
324
+ * @param selector Selector function
325
+ * @param listener Change listener
326
+ * @returns Unsubscribe function
327
+ * @since 3.2.0
328
+ */
329
+ select?<T>(
330
+ selector: (state: Record<string, unknown>) => T,
331
+ listener: (value: T, previousValue: T | undefined) => void
332
+ ): () => void;
333
+
334
+ /**
335
+ * Destroy Capability Instance
336
+ *
337
+ * @since 3.2.0
338
+ */
339
+ destroy?(): void;
340
+ }
341
+
342
+ // =========================================
343
+ // Capability Aliases (Unified Frontend/Backend Naming)
344
+ // =========================================
345
+
346
+ /**
347
+ * State Store Capability Type Identifier (Compatibility Alias)
348
+ *
349
+ * <p>Alias aligned with Java StateStoreCapability naming.
350
+ * New code should use PluginStateCapability, this alias is for migration compatibility.</p>
351
+ *
352
+ * @since 3.2.0
353
+ * @see PluginStateCapabilityType
354
+ */
355
+ export const StateStoreCapabilityType = PluginStateCapabilityType;
356
+
357
+ /**
358
+ * State Store Capability (Compatibility Alias)
359
+ *
360
+ * <p>Alias aligned with Java StateStoreCapability naming.
361
+ * New code should use PluginStateCapability, this alias is for migration compatibility.</p>
362
+ *
363
+ * @since 3.2.0
364
+ * @see PluginStateCapability
365
+ */
366
+ export type StateStoreCapability = PluginStateCapability;