@platformatic/globals 3.5.0 → 3.6.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 (2) hide show
  1. package/lib/index.d.ts +14 -9
  2. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type EventEmitter } from 'node:events'
3
3
  import { type Level, type Logger } from 'pino'
4
4
  import * as Client from 'prom-client'
5
5
 
6
- type Optional<T> = T | undefined;
6
+ type Optional<T> = T | undefined
7
7
 
8
8
  export type Handler = ((data: any) => any) | ((data: any) => Promise<any>)
9
9
 
@@ -12,9 +12,17 @@ export interface InvalidateHttpCacheOptions {
12
12
  tags?: string[]
13
13
  }
14
14
 
15
- export interface PlatformaticGlobalInterface {
16
- events: EventEmitter
15
+ // This is purposely a copy of the one in @platformatic/itc to avoid the dependency
16
+ export interface ITC {
17
+ send (name: string, message: any, options?: Record<string, any>): Promise<any>
18
+ notify (name: string, message: any, options?: Record<string, any>): void
19
+ handle (message: string, handler: Handler): void
20
+ getHandler (message: string): Handler | undefined
21
+ listen (): void
22
+ close (): void
23
+ }
17
24
 
25
+ export interface PlatformaticGlobalInterface {
18
26
  // Runtime
19
27
  isBuilding: boolean
20
28
  executable: string
@@ -68,12 +76,9 @@ export interface PlatformaticGlobalInterface {
68
76
  | Promise<{ status: boolean; statusCode?: number; body?: string }>
69
77
  ): void
70
78
 
71
- // Messaging
72
- messaging: {
73
- send (name: string, message: any, options?: Record<string, any>): Promise<any>
74
- handle (message: Record<string, Handler>): void
75
- handle (message: string, handler: Handler): void
76
- }
79
+ events: EventEmitter & { emitAndNotify: EventEmitter['emit'] }
80
+ itc: ITC
81
+ messaging: ITC & { handle (message: Record<string, Handler>): void }
77
82
  }
78
83
 
79
84
  export type PlatformaticGlobal = Optional<PlatformaticGlobalInterface>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/globals",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "Platformatic Global Object Getter",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",