@wooksjs/event-core 0.5.7 → 0.5.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/dist/index.cjs CHANGED
@@ -30,7 +30,7 @@ const asyncStorage = new node_async_hooks.AsyncLocalStorage();
30
30
  function createAsyncEventContext(data) {
31
31
  const newContext = { ...data };
32
32
  const ci = getContextInjector();
33
- return (cb) => asyncStorage.run(newContext, () => ci.with(`${newContext.event.type} event`, cb));
33
+ return (cb) => asyncStorage.run(newContext, () => ci.with('Event:start', { eventType: newContext.event.type }, cb));
34
34
  }
35
35
  function useAsyncEventContext(expectedTypes) {
36
36
  let cc = asyncStorage.getStore();
package/dist/index.d.ts CHANGED
@@ -286,13 +286,13 @@ declare function useRouteParams<T extends object = Record<string, string | strin
286
286
  * Provides a way to inject context
287
287
  * Usefull when working with opentelemetry spans
288
288
  */
289
- declare class ContextInjector {
290
- with<T>(name: string, attributes: Record<string, string | number | boolean>, cb: TContextInjectorCallback<T>): T;
291
- with<T>(name: string, cb: TContextInjectorCallback<T>): T;
289
+ declare class ContextInjector<N> {
290
+ with<T>(name: N, attributes: Record<string, string | number | boolean>, cb: TContextInjectorCallback<T>): T;
291
+ with<T>(name: N, cb: TContextInjectorCallback<T>): T;
292
292
  }
293
293
  type TContextInjectorCallback<T> = () => T;
294
- declare function getContextInjector(): ContextInjector;
295
- declare function replaceContextInjector(newCi: ContextInjector): void;
294
+ declare function getContextInjector<N = 'Event:start'>(): ContextInjector<N>;
295
+ declare function replaceContextInjector(newCi: ContextInjector<string>): void;
296
296
 
297
297
  declare function attachHook<V = unknown, T extends object | Function = object, P extends PropertyKey = 'value'>(target: T, opts: {
298
298
  get: () => V | undefined;
package/dist/index.mjs CHANGED
@@ -28,7 +28,7 @@ const asyncStorage = new AsyncLocalStorage();
28
28
  function createAsyncEventContext(data) {
29
29
  const newContext = { ...data };
30
30
  const ci = getContextInjector();
31
- return (cb) => asyncStorage.run(newContext, () => ci.with(`${newContext.event.type} event`, cb));
31
+ return (cb) => asyncStorage.run(newContext, () => ci.with('Event:start', { eventType: newContext.event.type }, cb));
32
32
  }
33
33
  function useAsyncEventContext(expectedTypes) {
34
34
  let cc = asyncStorage.getStore();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-core",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "@wooksjs/event-core",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",