@wirestate/core 0.6.0 → 0.6.3

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 (78) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +173 -230
  3. package/cjs/development/index.js +1 -1
  4. package/cjs/development/index.js.map +1 -1
  5. package/cjs/development/lib.js +9 -9
  6. package/cjs/development/lib.js.map +1 -1
  7. package/cjs/development/test-utils.js.map +1 -1
  8. package/cjs/production/index.js.map +1 -1
  9. package/cjs/production/lib.js.map +1 -1
  10. package/cjs/production/test-utils.js.map +1 -1
  11. package/esm/development/bind/bind-constant.js.map +1 -1
  12. package/esm/development/bind/bind-dynamic-value.js.map +1 -1
  13. package/esm/development/bind/bind-entry.js.map +1 -1
  14. package/esm/development/bind/bind-service.js.map +1 -1
  15. package/esm/development/bind/get-entry-token.js.map +1 -1
  16. package/esm/development/commands/command-bus.js +4 -4
  17. package/esm/development/commands/command-bus.js.map +1 -1
  18. package/esm/development/commands/command-optional.js.map +1 -1
  19. package/esm/development/commands/command.js.map +1 -1
  20. package/esm/development/commands/get-command-handler-metadata.js.map +1 -1
  21. package/esm/development/commands/on-command.js.map +1 -1
  22. package/esm/development/container/create-ioc-container.js +1 -1
  23. package/esm/development/container/create-ioc-container.js.map +1 -1
  24. package/esm/development/container/wire-scope.js.map +1 -1
  25. package/esm/development/events/build-event-dispatcher.js.map +1 -1
  26. package/esm/development/events/emit-event.js.map +1 -1
  27. package/esm/development/events/event-bus.js.map +1 -1
  28. package/esm/development/events/get-event-handler-metadata.js.map +1 -1
  29. package/esm/development/events/on-event.js.map +1 -1
  30. package/esm/development/index.js +1 -1
  31. package/esm/development/queries/get-query-handler-metadata.js.map +1 -1
  32. package/esm/development/queries/on-query.js.map +1 -1
  33. package/esm/development/queries/query-bus.js.map +1 -1
  34. package/esm/development/queries/query-optional.js.map +1 -1
  35. package/esm/development/queries/query.js.map +1 -1
  36. package/esm/development/registry.js.map +1 -1
  37. package/esm/development/seeds/apply-seeds.js.map +1 -1
  38. package/esm/development/seeds/apply-shared-seed.js.map +1 -1
  39. package/esm/development/seeds/unapply-seeds.js.map +1 -1
  40. package/esm/development/test-utils/mock-bind-entry.js.map +1 -1
  41. package/esm/development/test-utils/mock-bind-service.js.map +1 -1
  42. package/esm/development/test-utils/mock-container.js.map +1 -1
  43. package/esm/development/test-utils/mock-service.js.map +1 -1
  44. package/esm/development/types/commands.js +7 -7
  45. package/esm/development/types/commands.js.map +1 -1
  46. package/esm/production/bind/bind-entry.js.map +1 -1
  47. package/esm/production/bind/bind-service.js.map +1 -1
  48. package/esm/production/commands/command-bus.js +1 -1
  49. package/esm/production/commands/command-bus.js.map +1 -1
  50. package/esm/production/commands/command-optional.js.map +1 -1
  51. package/esm/production/commands/command.js.map +1 -1
  52. package/esm/production/commands/get-command-handler-metadata.js.map +1 -1
  53. package/esm/production/commands/on-command.js.map +1 -1
  54. package/esm/production/container/create-ioc-container.js +1 -1
  55. package/esm/production/container/create-ioc-container.js.map +1 -1
  56. package/esm/production/container/wire-scope.js.map +1 -1
  57. package/esm/production/events/build-event-dispatcher.js.map +1 -1
  58. package/esm/production/events/emit-event.js.map +1 -1
  59. package/esm/production/events/event-bus.js.map +1 -1
  60. package/esm/production/events/get-event-handler-metadata.js.map +1 -1
  61. package/esm/production/events/on-event.js.map +1 -1
  62. package/esm/production/index.js +1 -1
  63. package/esm/production/queries/get-query-handler-metadata.js.map +1 -1
  64. package/esm/production/queries/on-query.js.map +1 -1
  65. package/esm/production/queries/query-bus.js.map +1 -1
  66. package/esm/production/queries/query-optional.js.map +1 -1
  67. package/esm/production/queries/query.js.map +1 -1
  68. package/esm/production/registry.js.map +1 -1
  69. package/esm/production/seeds/apply-seeds.js.map +1 -1
  70. package/esm/production/seeds/apply-shared-seed.js.map +1 -1
  71. package/esm/production/seeds/unapply-seeds.js.map +1 -1
  72. package/esm/production/test-utils/mock-container.js.map +1 -1
  73. package/esm/production/types/commands.js +1 -1
  74. package/esm/production/types/commands.js.map +1 -1
  75. package/index.d.ts +56 -88
  76. package/lib.d.ts +6 -6
  77. package/package.json +1 -1
  78. package/test-utils.d.ts +10 -10
package/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ServiceIdentifier, LazyServiceIdentifier, Container, Newable } from 'inversify';
2
2
  export { bindingTypeValues as BindingType, Container, ContainerModule, inject as Inject, injectable as Injectable, LazyServiceIdentifier, multiInject as MultiInject, named as Named, Newable, optional as Optional, postConstruct as PostConstruct, preDestroy as PreDestroy, bindingScopeValues as ScopeBindingType, ServiceIdentifier, tagged as Tagged } from 'inversify';
3
- import { I as IInjectableDescriptor } from './lib.js';
3
+ import { I as InjectableDescriptor } from './lib.js';
4
4
 
5
5
  declare function forwardRef<TInstance = unknown>(forward: () => ServiceIdentifier<TInstance>): LazyServiceIdentifier<TInstance>;
6
6
 
7
- interface IBindServiceOptions {
7
+ interface BindServiceOptions {
8
8
  isWithIgnoreLifecycle?: boolean;
9
9
  }
10
10
  /**
@@ -15,12 +15,12 @@ interface IBindServiceOptions {
15
15
  * @param entry - service constructor
16
16
  * @param options - options object to control binding flow
17
17
  */
18
- declare function bindService<T extends object>(container: Container, entry: Newable<T>, options?: IBindServiceOptions): void;
18
+ declare function bindService<T extends object>(container: Container, entry: Newable<T>, options?: BindServiceOptions): void;
19
19
 
20
20
  /**
21
21
  * Options for {@link bindEntry}.
22
22
  */
23
- interface IBindEntryOptions extends IBindServiceOptions {
23
+ interface BindEntryOptions extends BindServiceOptions {
24
24
  isWithIgnoreLifecycle?: boolean;
25
25
  }
26
26
  /**
@@ -38,7 +38,7 @@ interface IBindEntryOptions extends IBindServiceOptions {
38
38
  * @param options - optional binding configuration
39
39
  * @returns void
40
40
  */
41
- declare function bindEntry<T extends object = object>(container: Container, entry: Newable<T> | IInjectableDescriptor, options?: IBindEntryOptions): void;
41
+ declare function bindEntry<T extends object = object>(container: Container, entry: Newable<T> | InjectableDescriptor, options?: BindEntryOptions): void;
42
42
 
43
43
  /**
44
44
  * Binds a constant value to a token in the container.
@@ -46,7 +46,7 @@ declare function bindEntry<T extends object = object>(container: Container, entr
46
46
  * @param container - target Inversify container
47
47
  * @param entry - entry descriptor to bind
48
48
  */
49
- declare function bindConstant<T>(container: Container, entry: IInjectableDescriptor): void;
49
+ declare function bindConstant<T>(container: Container, entry: InjectableDescriptor): void;
50
50
 
51
51
  /**
52
52
  * Returns the container token for a service entry.
@@ -56,36 +56,28 @@ declare function bindConstant<T>(container: Container, entry: IInjectableDescrip
56
56
  * @param entry - entry descriptor to get service identifier for
57
57
  * @returns injectable identifier token
58
58
  */
59
- declare function getEntryToken<T extends object = object>(entry: Newable<T> | IInjectableDescriptor): ServiceIdentifier;
59
+ declare function getEntryToken<T extends object = object>(entry: Newable<T> | InjectableDescriptor): ServiceIdentifier;
60
60
 
61
- type TAnyObject = Record<string, any>;
61
+ type AnyObject = Record<string, any>;
62
62
  type Optional<T> = T | null;
63
63
  type MaybePromise<T> = T | Promise<T>;
64
64
 
65
65
  /**
66
66
  * Command identifier. Use symbols for private commands.
67
67
  */
68
- type TCommandType = string | symbol;
68
+ type CommandType = string | symbol;
69
69
  /**
70
70
  * Command handler signature.
71
71
  */
72
- type TCommandHandler<D = unknown, R = unknown> = (data: D) => MaybePromise<R>;
73
- /**
74
- * Command calling function signature.
75
- */
76
- type TCommandCaller<R = unknown, D = unknown, T extends TCommandType = TCommandType> = (type: T, data?: D) => ICommandDescriptor<R>;
77
- /**
78
- * Command calling function signature.
79
- */
80
- type TOptionalCommandCaller<R = unknown, D = unknown, T extends TCommandType = TCommandType> = (type: T, data?: D) => Optional<ICommandDescriptor<R>>;
72
+ type CommandHandler<D = unknown, R = unknown> = (data: D) => MaybePromise<R>;
81
73
  /**
82
74
  * Removes a command handler.
83
75
  */
84
- type TCommandUnregister = () => void;
76
+ type CommandUnregister = () => void;
85
77
  /**
86
78
  * Command execution status.
87
79
  */
88
- declare enum ECommandStatus {
80
+ declare enum CommandStatus {
89
81
  PENDING = "pending",
90
82
  SETTLED = "settled",
91
83
  ERROR = "error"
@@ -94,9 +86,9 @@ declare enum ECommandStatus {
94
86
  * Descriptor returned by command execution.
95
87
  * Contains the task promise, current status, and responder with result/error.
96
88
  */
97
- interface ICommandDescriptor<R = unknown> {
89
+ interface CommandDescriptor<R = unknown> {
98
90
  readonly task: Promise<R>;
99
- readonly status: ECommandStatus;
91
+ readonly status: CommandStatus;
100
92
  }
101
93
 
102
94
  /**
@@ -107,7 +99,7 @@ interface ICommandDescriptor<R = unknown> {
107
99
  * @param data - command data
108
100
  * @returns command descriptor
109
101
  */
110
- declare function command<R = unknown, D = unknown, T extends TCommandType = TCommandType>(container: Container, type: T, data?: D): ICommandDescriptor<R>;
102
+ declare function command<R = unknown, D = unknown, T extends CommandType = CommandType>(container: Container, type: T, data?: D): CommandDescriptor<R>;
111
103
 
112
104
  /**
113
105
  * Dispatches a command on the provided container, returning null if no handler is registered.
@@ -117,7 +109,7 @@ declare function command<R = unknown, D = unknown, T extends TCommandType = TCom
117
109
  * @param data - command data
118
110
  * @returns command descriptor or null
119
111
  */
120
- declare function commandOptional<R = unknown, D = unknown, T extends TCommandType = TCommandType>(container: Container, type: T, data?: D): Optional<ICommandDescriptor<R>>;
112
+ declare function commandOptional<R = unknown, D = unknown, T extends CommandType = CommandType>(container: Container, type: T, data?: D): Optional<CommandDescriptor<R>>;
121
113
 
122
114
  /**
123
115
  * Decorator for service methods that handle a command.
@@ -125,7 +117,7 @@ declare function commandOptional<R = unknown, D = unknown, T extends TCommandTyp
125
117
  * @param type - command type identifier
126
118
  * @returns decorator function
127
119
  */
128
- declare function OnCommand(type: TCommandType): MethodDecorator;
120
+ declare function OnCommand(type: CommandType): MethodDecorator;
129
121
 
130
122
  /**
131
123
  * Dispatches commands to handlers.
@@ -147,7 +139,7 @@ declare class CommandBus {
147
139
  * @param handler - handler function
148
140
  * @returns unregister function
149
141
  */
150
- register<D = unknown, R = unknown>(type: TCommandType, handler: TCommandHandler<D, R>): TCommandUnregister;
142
+ register<D = unknown, R = unknown>(type: CommandType, handler: CommandHandler<D, R>): CommandUnregister;
151
143
  /**
152
144
  * Dispatches a command to the last registered handler.
153
145
  * Wraps the handler execution in a promise and returns a descriptor.
@@ -158,7 +150,7 @@ declare class CommandBus {
158
150
  *
159
151
  * @throws if no handler is registered
160
152
  */
161
- command<R = unknown, D = unknown>(type: TCommandType, data?: D): ICommandDescriptor<R>;
153
+ command<R = unknown, D = unknown>(type: CommandType, data?: D): CommandDescriptor<R>;
162
154
  /**
163
155
  * Dispatches a command to the last registered handler, returning null if no handler exists.
164
156
  *
@@ -166,21 +158,21 @@ declare class CommandBus {
166
158
  * @param data - command payload
167
159
  * @returns command descriptor or null if no handler is registered
168
160
  */
169
- commandOptional<R = unknown, D = unknown>(type: TCommandType, data?: D): Optional<ICommandDescriptor<R>>;
161
+ commandOptional<R = unknown, D = unknown>(type: CommandType, data?: D): Optional<CommandDescriptor<R>>;
170
162
  /**
171
163
  * Checks if a handler is registered for the given type.
172
164
  *
173
165
  * @param type - command type
174
166
  * @returns true if handler exists
175
167
  */
176
- has(type: TCommandType): boolean;
168
+ has(type: CommandType): boolean;
177
169
  /**
178
170
  * Removes all registered handlers.
179
171
  */
180
172
  clear(): void;
181
173
  }
182
174
 
183
- interface ICreateIocContainerOptions {
175
+ interface CreateIocContainerOptions {
184
176
  /**
185
177
  * Parent container for inheritance.
186
178
  */
@@ -188,7 +180,7 @@ interface ICreateIocContainerOptions {
188
180
  /**
189
181
  * Optional default seed value.
190
182
  */
191
- readonly seed?: TAnyObject;
183
+ readonly seed?: AnyObject;
192
184
  }
193
185
  /**
194
186
  * Creates an IoC container with framework essentials.
@@ -196,16 +188,16 @@ interface ICreateIocContainerOptions {
196
188
  * @param options - container configuration
197
189
  * @returns new IoC container
198
190
  */
199
- declare function createIocContainer(options?: ICreateIocContainerOptions): Container;
191
+ declare function createIocContainer(options?: CreateIocContainerOptions): Container;
200
192
 
201
193
  /**
202
194
  * Event identifier.
203
195
  */
204
- type TEventType = string | symbol;
196
+ type EventType = string | symbol;
205
197
  /**
206
198
  * Event object.
207
199
  */
208
- interface IEvent<P = unknown, T extends TEventType = TEventType, F = unknown> {
200
+ interface Event<P = unknown, T extends EventType = EventType, F = unknown> {
209
201
  readonly type: T;
210
202
  readonly payload?: P;
211
203
  readonly from?: F;
@@ -213,61 +205,37 @@ interface IEvent<P = unknown, T extends TEventType = TEventType, F = unknown> {
213
205
  /**
214
206
  * Event handler signature.
215
207
  */
216
- type TEventHandler<E extends IEvent = IEvent> = (event: E) => void;
208
+ type EventHandler<E extends Event = Event> = (event: E) => void;
217
209
  /**
218
210
  * Unsubscribes from events, part of events subscription lifecycle.
219
211
  */
220
- type TEventUnsubscriber = () => void;
221
- /**
222
- * Event emitter signature.
223
- */
224
- type TEventEmitter<P = unknown, T extends TEventType = TEventType, F = unknown> = (type: T, payload?: P, from?: F) => void;
212
+ type EventUnsubscriber = () => void;
225
213
 
226
214
  /**
227
215
  * Lookup key for service seeds.
228
216
  */
229
- type TSeedKey = Newable | string | symbol;
217
+ type SeedKey = Newable | string | symbol;
230
218
  /**
231
219
  * Service-to-seed mapping entry.
232
220
  */
233
- type TSeedEntry<T = unknown> = readonly [TSeedKey, T];
221
+ type SeedEntry<T = unknown> = readonly [SeedKey, T];
234
222
  /**
235
223
  * Collection of seed entries.
236
224
  */
237
- type TSeedEntries = ReadonlyArray<TSeedEntry>;
225
+ type SeedEntries = ReadonlyArray<SeedEntry>;
238
226
 
239
227
  /**
240
228
  * Query identifier. Use symbols for private queries.
241
229
  */
242
- type TQueryType = string | symbol;
230
+ type QueryType = string | symbol;
243
231
  /**
244
232
  * Query handler signature.
245
233
  */
246
- type TQueryHandler<D = unknown, R = unknown> = (data: D) => MaybePromise<R>;
234
+ type QueryHandler<D = unknown, R = unknown> = (data: D) => MaybePromise<R>;
247
235
  /**
248
236
  * Removes a query handler.
249
237
  */
250
- type TQueryUnregister = () => void;
251
- /**
252
- * Public query responder signature.
253
- */
254
- type TQueryResponder<R = unknown, D = unknown> = (data?: D) => MaybePromise<R>;
255
- /**
256
- * Dispatches queries and returns their result as a value or promise.
257
- */
258
- type TQueryCaller = <R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D) => MaybePromise<R>;
259
- /**
260
- * Dispatches synchronous queries and returns their result directly.
261
- */
262
- type TSyncQueryCaller = <R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D) => R;
263
- /**
264
- * Dispatches optional queries. Returns null when no handler is registered.
265
- */
266
- type TOptionalQueryCaller = <R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D) => Optional<MaybePromise<R>>;
267
- /**
268
- * Dispatches optional synchronous queries. Returns null when no handler is registered.
269
- */
270
- type TOptionalSyncQueryCaller = <R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D) => Optional<R>;
238
+ type QueryUnregister = () => void;
271
239
 
272
240
  /**
273
241
  * Injectable scope providing access to wirestate buses and seeds.
@@ -322,7 +290,7 @@ declare class WireScope {
322
290
  *
323
291
  * @throws WirestateError if scope is not activated
324
292
  */
325
- emitEvent<P, T extends TEventType = TEventType>(type: T, payload?: P, from?: unknown): void;
293
+ emitEvent<P, T extends EventType = EventType>(type: T, payload?: P, from?: unknown): void;
326
294
  /**
327
295
  * Dispatches a query and returns the result.
328
296
  * Available only for activated containers.
@@ -333,7 +301,7 @@ declare class WireScope {
333
301
  *
334
302
  * @throws WirestateError if scope is not activated
335
303
  */
336
- queryData<R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D): MaybePromise<R>;
304
+ queryData<R = unknown, D = unknown, T extends QueryType = QueryType>(type: T, data?: D): MaybePromise<R>;
337
305
  /**
338
306
  * Dispatches a query and returns the result.
339
307
  * Available only for activated containers.
@@ -342,7 +310,7 @@ declare class WireScope {
342
310
  * @param data - query data
343
311
  * @returns query result or null if handler is not registered
344
312
  */
345
- queryOptionalData<R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D): Optional<MaybePromise<R>>;
313
+ queryOptionalData<R = unknown, D = unknown, T extends QueryType = QueryType>(type: T, data?: D): Optional<MaybePromise<R>>;
346
314
  /**
347
315
  * Dispatches a command and returns the descriptor.
348
316
  * Available only for activated containers.
@@ -353,7 +321,7 @@ declare class WireScope {
353
321
  *
354
322
  * @throws WirestateError if scope is not activated
355
323
  */
356
- executeCommand<R = unknown, D = unknown, T extends TCommandType = TCommandType>(type: T, data?: D): ICommandDescriptor<R>;
324
+ executeCommand<R = unknown, D = unknown, T extends CommandType = CommandType>(type: T, data?: D): CommandDescriptor<R>;
357
325
  /**
358
326
  * Dispatches a command and returns the descriptor.
359
327
  * Available only for activated containers.
@@ -362,9 +330,9 @@ declare class WireScope {
362
330
  * @param data - command data
363
331
  * @returns command descriptor or null if handler is not registered
364
332
  */
365
- executeOptionalCommand<R = unknown, D = unknown, T extends TCommandType = TCommandType>(type: T, data?: D): Optional<ICommandDescriptor<R>>;
333
+ executeOptionalCommand<R = unknown, D = unknown, T extends CommandType = CommandType>(type: T, data?: D): Optional<CommandDescriptor<R>>;
366
334
  getSeed<T>(): T;
367
- getSeed<T>(seed?: TSeedKey): Optional<T>;
335
+ getSeed<T>(seed?: SeedKey): Optional<T>;
368
336
  }
369
337
 
370
338
  /**
@@ -397,7 +365,7 @@ declare class WirestateError extends Error {
397
365
  * @param payload - event payload
398
366
  * @param from - optional indicator of the event source
399
367
  */
400
- declare function emitEvent<P, T extends TEventType>(container: Container, type: T, payload?: P, from?: unknown): void;
368
+ declare function emitEvent<P, T extends EventType>(container: Container, type: T, payload?: P, from?: unknown): void;
401
369
 
402
370
  /**
403
371
  * Decorator for service methods that respond to events.
@@ -405,7 +373,7 @@ declare function emitEvent<P, T extends TEventType>(container: Container, type:
405
373
  * @param types - event type(s) to handle. If omitted, handles all events
406
374
  * @returns decorator function
407
375
  */
408
- declare function OnEvent(types?: TEventType | ReadonlyArray<TEventType>): MethodDecorator;
376
+ declare function OnEvent(types?: EventType | ReadonlyArray<EventType>): MethodDecorator;
409
377
 
410
378
  /**
411
379
  * Dispatches events to subscribers.
@@ -417,7 +385,7 @@ declare class EventBus {
417
385
  *
418
386
  * @param event - event to emit
419
387
  */
420
- emit<P = unknown, T extends TEventType = TEventType, F = unknown>(event: IEvent<P, T, F>): void;
388
+ emit<P = unknown, T extends EventType = EventType, F = unknown>(event: Event<P, T, F>): void;
421
389
  /**
422
390
  * Subscribes a handler to all events.
423
391
  * Returns an unsubscribe function.
@@ -425,7 +393,7 @@ declare class EventBus {
425
393
  * @param handler - event handler function
426
394
  * @returns unsubscribe function
427
395
  */
428
- subscribe(handler: TEventHandler): TEventUnsubscriber;
396
+ subscribe(handler: EventHandler): EventUnsubscriber;
429
397
  /**
430
398
  * Removes all registered handlers.
431
399
  *
@@ -442,7 +410,7 @@ declare class EventBus {
442
410
  * @param data - query data
443
411
  * @returns query result
444
412
  */
445
- declare function query<R = unknown, D = unknown>(container: Container, type: TQueryType, data?: D): MaybePromise<R>;
413
+ declare function query<R = unknown, D = unknown>(container: Container, type: QueryType, data?: D): MaybePromise<R>;
446
414
 
447
415
  /**
448
416
  * Dispatches a query on the provided container, returning null if no handler is registered.
@@ -452,7 +420,7 @@ declare function query<R = unknown, D = unknown>(container: Container, type: TQu
452
420
  * @param data - query data
453
421
  * @returns query result or null
454
422
  */
455
- declare function queryOptional<R = unknown, D = unknown>(container: Container, type: TQueryType, data?: D): Optional<MaybePromise<R>>;
423
+ declare function queryOptional<R = unknown, D = unknown>(container: Container, type: QueryType, data?: D): Optional<MaybePromise<R>>;
456
424
 
457
425
  /**
458
426
  * Dispatches queries to handlers.
@@ -471,7 +439,7 @@ declare class QueryBus {
471
439
  * @param handler - handler function
472
440
  * @returns unregister function
473
441
  */
474
- register<D = unknown, R = unknown>(type: TQueryType, handler: TQueryHandler<D, R>): TQueryUnregister;
442
+ register<D = unknown, R = unknown>(type: QueryType, handler: QueryHandler<D, R>): QueryUnregister;
475
443
  /**
476
444
  * Dispatches a query to the last registered handler.
477
445
  *
@@ -481,7 +449,7 @@ declare class QueryBus {
481
449
  *
482
450
  * @throws if no handler is registered
483
451
  */
484
- query<R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D): MaybePromise<R>;
452
+ query<R = unknown, D = unknown, T extends QueryType = QueryType>(type: T, data?: D): MaybePromise<R>;
485
453
  /**
486
454
  * Dispatches a query to the last registered handler, returning null if no handler exists.
487
455
  *
@@ -489,14 +457,14 @@ declare class QueryBus {
489
457
  * @param data - query payload
490
458
  * @returns query result or null if no handler is registered
491
459
  */
492
- queryOptional<R = unknown, D = unknown, T extends TQueryType = TQueryType>(type: T, data?: D): Optional<MaybePromise<R>>;
460
+ queryOptional<R = unknown, D = unknown, T extends QueryType = QueryType>(type: T, data?: D): Optional<MaybePromise<R>>;
493
461
  /**
494
462
  * Checks if a handler is registered for the given type.
495
463
  *
496
464
  * @param type - query type
497
465
  * @returns true if handler exists
498
466
  */
499
- has(type: TQueryType): boolean;
467
+ has(type: QueryType): boolean;
500
468
  /**
501
469
  * Removes all registered handlers.
502
470
  *
@@ -511,7 +479,7 @@ declare class QueryBus {
511
479
  * @param type - query type identifier
512
480
  * @returns decorator function
513
481
  */
514
- declare function OnQuery(type: TQueryType): MethodDecorator;
482
+ declare function OnQuery(type: QueryType): MethodDecorator;
515
483
 
516
484
  /**
517
485
  * Token for the container-scoped seeds map.
@@ -529,7 +497,7 @@ declare const SEED_TOKEN: unique symbol;
529
497
  * @param container - target container
530
498
  * @param seeds - targeted seed entries apply
531
499
  */
532
- declare function applySeeds(container: Container, seeds: TSeedEntries): void;
500
+ declare function applySeeds(container: Container, seeds: SeedEntries): void;
533
501
 
534
502
  /**
535
503
  * Applies shared seed to the container.
@@ -537,7 +505,7 @@ declare function applySeeds(container: Container, seeds: TSeedEntries): void;
537
505
  * @param container - target container
538
506
  * @param seed - shared seed object
539
507
  */
540
- declare function applySharedSeed(container: Container, seed: TAnyObject): void;
508
+ declare function applySharedSeed(container: Container, seed: AnyObject): void;
541
509
 
542
510
  /**
543
511
  * Removes specific seeds from the container.
@@ -546,7 +514,7 @@ declare function applySharedSeed(container: Container, seed: TAnyObject): void;
546
514
  * @param container - target container
547
515
  * @param seeds - targeted seeds to remove
548
516
  */
549
- declare function unapplySeeds(container: Container, seeds: TSeedEntries): void;
517
+ declare function unapplySeeds(container: Container, seeds: SeedEntries): void;
550
518
 
551
519
  /**
552
520
  * Decorator for service methods that run after activation.
@@ -562,5 +530,5 @@ declare function OnActivated(): MethodDecorator;
562
530
  */
563
531
  declare function OnDeactivation(): MethodDecorator;
564
532
 
565
- export { CommandBus, ECommandStatus as CommandStatus, EventBus, IInjectableDescriptor as InjectableDescriptor, OnActivated, OnCommand, OnDeactivation, OnEvent, OnQuery, QueryBus, SEED_TOKEN as SEED, SEEDS_TOKEN as SEEDS, WireScope, WirestateError, applySeeds, applySharedSeed, bindConstant, bindEntry, bindService, command, commandOptional, createIocContainer, emitEvent, forwardRef, getEntryToken, query, queryOptional, unapplySeeds };
566
- export type { TCommandCaller as CommandCaller, ICommandDescriptor as CommandDescriptor, TCommandHandler as CommandHandler, TCommandType as CommandType, TCommandUnregister as CommandUnregister, IEvent as Event, TEventEmitter as EventEmitter, TEventHandler as EventHandler, TEventType as EventType, TEventUnsubscriber as EventUnsubscriber, TOptionalCommandCaller as OptionalCommandCaller, TOptionalQueryCaller as OptionalQueryCaller, TOptionalSyncQueryCaller as OptionalSyncQueryCaller, TQueryCaller as QueryCaller, TQueryHandler as QueryHandler, TQueryResponder as QueryResponder, TQueryType as QueryType, TQueryUnregister as QueryUnregister, TSeedEntries as SeedEntries, TSeedEntry as SeedEntry, TSeedKey as SeedKey, TSyncQueryCaller as SyncQueryCaller };
533
+ export { CommandBus, CommandStatus, EventBus, InjectableDescriptor, OnActivated, OnCommand, OnDeactivation, OnEvent, OnQuery, QueryBus, SEED_TOKEN as SEED, SEEDS_TOKEN as SEEDS, WireScope, WirestateError, applySeeds, applySharedSeed, bindConstant, bindEntry, bindService, command, commandOptional, createIocContainer, emitEvent, forwardRef, getEntryToken, query, queryOptional, unapplySeeds };
534
+ export type { CommandDescriptor, CommandHandler, CommandType, CommandUnregister, Event, EventHandler, EventType, EventUnsubscriber, QueryHandler, QueryType, QueryUnregister, SeedEntries, SeedEntry, SeedKey };
package/lib.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ServiceIdentifier, bindingTypeValues, bindingScopeValues } from 'inversify';
2
2
 
3
- type TBindingType = (typeof bindingTypeValues)[keyof typeof bindingTypeValues];
4
- type TScopeBindingType = (typeof bindingScopeValues)[keyof typeof bindingScopeValues];
5
- interface IInjectableDescriptor<T = unknown, V = unknown> {
3
+ type BindingType = (typeof bindingTypeValues)[keyof typeof bindingTypeValues];
4
+ type ScopeBindingType = (typeof bindingScopeValues)[keyof typeof bindingScopeValues];
5
+ interface InjectableDescriptor<T = unknown, V = unknown> {
6
6
  id: ServiceIdentifier<T>;
7
7
  value?: V;
8
- bindingType?: TBindingType;
9
- scopeBindingType?: TScopeBindingType;
8
+ bindingType?: BindingType;
9
+ scopeBindingType?: ScopeBindingType;
10
10
  /**
11
11
  * Factory function for dynamic value bindings.
12
12
  * Used when type is set to DynamicValue.
@@ -14,4 +14,4 @@ interface IInjectableDescriptor<T = unknown, V = unknown> {
14
14
  factory?: () => T;
15
15
  }
16
16
 
17
- export type { IInjectableDescriptor as I };
17
+ export type { InjectableDescriptor as I };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirestate/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.3",
4
4
  "description": "Store management library core based on inversify",
5
5
  "sideEffects": false,
6
6
  "author": "Syrotenko Igor",
package/test-utils.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Container as Container$1, Newable, ServiceIdentifier } from 'inversify';
2
- import { I as IInjectableDescriptor } from './lib.js';
2
+ import { I as InjectableDescriptor } from './lib.js';
3
3
 
4
4
  /**
5
5
  * Options for {@link mockBindService}.
6
6
  */
7
- interface IMockBindServiceOptions {
7
+ interface MockBindServiceOptions {
8
8
  /**
9
9
  * Whether to skip the activation lifecycle for the service.
10
10
  * If true, `OnActivated` and `OnDeactivation` hooks will not be triggered.
@@ -21,12 +21,12 @@ interface IMockBindServiceOptions {
21
21
  * @param options - optional binding configuration
22
22
  * @returns void
23
23
  */
24
- declare function mockBindService<T extends object>(container: Container$1, ServiceClass: Newable<T>, options?: IMockBindServiceOptions): void;
24
+ declare function mockBindService<T extends object>(container: Container$1, ServiceClass: Newable<T>, options?: MockBindServiceOptions): void;
25
25
 
26
26
  /**
27
27
  * Options for {@link mockBindEntry}.
28
28
  */
29
- interface IMockBindEntryOptions {
29
+ interface MockBindEntryOptions {
30
30
  /**
31
31
  * Whether to skip the activation lifecycle for the entry.
32
32
  * If true, `OnActivated` and `OnDeactivation` hooks will not be triggered.
@@ -44,7 +44,7 @@ interface IMockBindEntryOptions {
44
44
  * @param options - optional binding configuration
45
45
  * @returns void
46
46
  */
47
- declare function mockBindEntry<T extends object>(container: Container$1, entry: Newable<T> | IInjectableDescriptor, options?: IMockBindEntryOptions): void;
47
+ declare function mockBindEntry<T extends object>(container: Container$1, entry: Newable<T> | InjectableDescriptor, options?: MockBindEntryOptions): void;
48
48
 
49
49
  /**
50
50
  * Unbinds a service from the IoC container.
@@ -58,11 +58,11 @@ declare function mockUnbindService<T extends object>(container: Container$1, Ser
58
58
  /**
59
59
  * Options for {@link mockContainer}.
60
60
  */
61
- interface IMockContainerOptions {
61
+ interface MockContainerOptions {
62
62
  /**
63
63
  * List of services or injectable descriptors to bind to the container.
64
64
  */
65
- entries?: Array<Newable<object> | IInjectableDescriptor>;
65
+ entries?: Array<Newable<object> | InjectableDescriptor>;
66
66
  /**
67
67
  * List of injection identifiers to immediately activate after binding.
68
68
  * All identifiers must correspond to entries provided in the `services` list.
@@ -84,12 +84,12 @@ interface IMockContainerOptions {
84
84
  *
85
85
  * @throws {WirestateError} if an identifier in `activate` is not found in `services`
86
86
  */
87
- declare function mockContainer(options?: IMockContainerOptions): Container$1;
87
+ declare function mockContainer(options?: MockContainerOptions): Container$1;
88
88
 
89
89
  /**
90
90
  * Options for {@link mockService}.
91
91
  */
92
- interface IMockServiceOptions {
92
+ interface MockServiceOptions {
93
93
  /**
94
94
  * If true, skips the lifecycle hooks (e.g., OnActivated) during service binding and instantiation.
95
95
  */
@@ -103,6 +103,6 @@ interface IMockServiceOptions {
103
103
  * @param options - additional options for mocking
104
104
  * @returns the instantiated service instance
105
105
  */
106
- declare function mockService<T extends object>(service: Newable<T>, container?: Container, options?: IMockServiceOptions): T;
106
+ declare function mockService<T extends object>(service: Newable<T>, container?: Container, options?: MockServiceOptions): T;
107
107
 
108
108
  export { mockBindEntry, mockBindService, mockContainer, mockService, mockUnbindService };