@asaidimu/utils-database 3.1.6 → 3.1.8

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QueryFilter, PaginationOptions } from '@asaidimu/query';
2
- import { IndexDefinition, SchemaDefinition, SchemaChange, DataTransform, PredicateMap } from '@asaidimu/anansi';
2
+ import { IndexDefinition, SchemaChange, DataTransform, PredicateMap, SchemaDefinition } from '@asaidimu/anansi';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
 
5
5
  /**
@@ -821,14 +821,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
821
821
  * subscription
822
822
  * @returns A function to unsubscribe from the event.
823
823
  */
824
- subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
824
+ subscribe<TEventName extends keyof TEventMap | "*">(eventName: TEventName, callback: TEventName extends "*" ? (payload: TEventMap[keyof TEventMap] & {
825
+ __event__: keyof TEventMap;
826
+ }) => void : (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions): () => void;
825
827
  /**
826
828
  * Subscribes to an event and automatically unsubscribes after it fires once.
827
829
  * @param eventName - The name of the event to subscribe to.
828
830
  * @param callback - The function to call when the event is emitted.
829
831
  * @returns A function to cancel the one-shot subscription before it fires.
830
832
  */
831
- once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
833
+ once<TEventName extends keyof TEventMap | "*">(eventName: TEventName, callback: TEventName extends "*" ? (payload: TEventMap[keyof TEventMap] & {
834
+ __event__: keyof TEventMap;
835
+ }) => void : (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions): () => void;
832
836
  /**
833
837
  * Emits an event with a payload to all subscribed listeners.
834
838
  * @param event - An object containing the event name and payload.
@@ -844,10 +848,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
844
848
  metrics: () => EventMetrics;
845
849
  /**
846
850
  * Clears all subscriptions and resets metrics.
847
- * After calling clear(), the bus is fully reset and can be reused —
851
+ *
852
+ * After calling `clear()`, the bus is fully reset and can be reused
848
853
  * cross-tab communication is re-established if it was previously enabled.
854
+ *
855
+ * @param options - Optional configuration object.
856
+ * @param options.permanent - If `true`, the bus becomes permanently unusable after clearing.
857
+ * Defaults to `false`.
858
+ * @returns {void}
849
859
  */
850
- clear: () => void;
860
+ clear: (options?: {
861
+ permanent?: boolean;
862
+ }) => void;
851
863
  }
852
864
  /**
853
865
  * Interface defining the metrics tracked by the EventBus.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QueryFilter, PaginationOptions } from '@asaidimu/query';
2
- import { IndexDefinition, SchemaDefinition, SchemaChange, DataTransform, PredicateMap } from '@asaidimu/anansi';
2
+ import { IndexDefinition, SchemaChange, DataTransform, PredicateMap, SchemaDefinition } from '@asaidimu/anansi';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
 
5
5
  /**
@@ -821,14 +821,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
821
821
  * subscription
822
822
  * @returns A function to unsubscribe from the event.
823
823
  */
824
- subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
824
+ subscribe<TEventName extends keyof TEventMap | "*">(eventName: TEventName, callback: TEventName extends "*" ? (payload: TEventMap[keyof TEventMap] & {
825
+ __event__: keyof TEventMap;
826
+ }) => void : (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions): () => void;
825
827
  /**
826
828
  * Subscribes to an event and automatically unsubscribes after it fires once.
827
829
  * @param eventName - The name of the event to subscribe to.
828
830
  * @param callback - The function to call when the event is emitted.
829
831
  * @returns A function to cancel the one-shot subscription before it fires.
830
832
  */
831
- once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
833
+ once<TEventName extends keyof TEventMap | "*">(eventName: TEventName, callback: TEventName extends "*" ? (payload: TEventMap[keyof TEventMap] & {
834
+ __event__: keyof TEventMap;
835
+ }) => void : (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions): () => void;
832
836
  /**
833
837
  * Emits an event with a payload to all subscribed listeners.
834
838
  * @param event - An object containing the event name and payload.
@@ -844,10 +848,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
844
848
  metrics: () => EventMetrics;
845
849
  /**
846
850
  * Clears all subscriptions and resets metrics.
847
- * After calling clear(), the bus is fully reset and can be reused —
851
+ *
852
+ * After calling `clear()`, the bus is fully reset and can be reused
848
853
  * cross-tab communication is re-established if it was previously enabled.
854
+ *
855
+ * @param options - Optional configuration object.
856
+ * @param options.permanent - If `true`, the bus becomes permanently unusable after clearing.
857
+ * Defaults to `false`.
858
+ * @returns {void}
849
859
  */
850
- clear: () => void;
860
+ clear: (options?: {
861
+ permanent?: boolean;
862
+ }) => void;
851
863
  }
852
864
  /**
853
865
  * Interface defining the metrics tracked by the EventBus.