@platformatic/globals 3.55.0 → 3.56.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.
- package/README.md +8 -3
- package/lib/index.d.ts +214 -7
- package/lib/index.js +253 -0
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @platformatic/globals
|
|
2
2
|
|
|
3
|
-
Platformatic Globals exports
|
|
3
|
+
Platformatic Globals exports access to Platformatic runtime APIs.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -11,11 +11,16 @@ npm install @platformatic/globals
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
14
|
+
import { getApplicationId, getCapability, getClosing, getMessaging } from '@platformatic/globals'
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const applicationId = getApplicationId()
|
|
17
|
+
const capability = getCapability()
|
|
18
|
+
const closing = getClosing()
|
|
19
|
+
const messaging = getMessaging()
|
|
17
20
|
```
|
|
18
21
|
|
|
22
|
+
Direct access through the legacy global object is still supported for compatibility, but deprecated. Use the typed getters instead.
|
|
23
|
+
|
|
19
24
|
## License
|
|
20
25
|
|
|
21
26
|
Apache 2.0
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,47 @@
|
|
|
1
|
+
import { type TracerProvider } from '@opentelemetry/api'
|
|
2
|
+
import * as Client from '@platformatic/prom-client'
|
|
1
3
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
2
4
|
import { type EventEmitter } from 'node:events'
|
|
3
5
|
import { type Level, type Logger } from 'pino'
|
|
4
|
-
import * as Client from '@platformatic/prom-client'
|
|
5
6
|
|
|
6
|
-
export type Handler = (
|
|
7
|
+
export type Handler = (data: any, context?: Record<string, any>) => any | Promise<any>
|
|
7
8
|
|
|
8
9
|
export interface InvalidateHttpCacheOptions {
|
|
9
10
|
keys?: string[]
|
|
10
11
|
tags?: string[]
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
export interface HealthSignal {
|
|
15
|
+
type: string
|
|
16
|
+
value?: any
|
|
17
|
+
description?: string
|
|
18
|
+
timestamp?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SharedContext {
|
|
22
|
+
get (): any
|
|
23
|
+
update (contextUpdate: object, options?: { overwrite?: boolean }): any
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type Management = Record<string, (...args: any[]) => any>
|
|
27
|
+
|
|
28
|
+
export interface GlobalGetterOptions {
|
|
29
|
+
throwOnMissing?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RequiredGlobalGetterOptions {
|
|
33
|
+
throwOnMissing?: true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface OptionalGlobalGetterOptions {
|
|
37
|
+
throwOnMissing: false
|
|
38
|
+
}
|
|
39
|
+
|
|
13
40
|
// This is purposely a copy of the one in @platformatic/itc to avoid the dependency
|
|
14
41
|
export interface ITC {
|
|
15
42
|
send (message: string, data: any, options?: Record<string, any>): Promise<any>
|
|
16
43
|
notify (message: string, data: any, options?: Record<string, any>): void
|
|
44
|
+
process (message: string, data: any, context?: Record<string, any>): Promise<any>
|
|
17
45
|
handle (message: string, handler: Handler): void
|
|
18
46
|
getHandler (message: string): Handler | undefined
|
|
19
47
|
listen (): void
|
|
@@ -21,26 +49,37 @@ export interface ITC {
|
|
|
21
49
|
}
|
|
22
50
|
|
|
23
51
|
export interface MessagingApi {
|
|
24
|
-
send (name: string, message: string, data
|
|
25
|
-
notify (name: string, message: string, data
|
|
52
|
+
send (name: string, message: string, data?: any, options?: Record<string, any>): Promise<any>
|
|
53
|
+
notify (name: string, message: string, data?: any, options?: Record<string, any>): void
|
|
26
54
|
handle (message: string, handler: Handler): void
|
|
55
|
+
handle (handlers: Record<string, Handler>): void
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface PlatformaticEvents extends EventEmitter {
|
|
59
|
+
emitAndNotify: EventEmitter['emit']
|
|
27
60
|
}
|
|
28
61
|
|
|
29
62
|
export interface PlatformaticGlobal {
|
|
30
63
|
// Runtime
|
|
31
64
|
isBuilding: boolean
|
|
32
65
|
executable: string
|
|
66
|
+
runtimeId: number
|
|
67
|
+
nextVersion: { major: number, minor?: number }
|
|
68
|
+
exitOnUnhandledErrors: boolean
|
|
69
|
+
reuseTcpPorts: boolean
|
|
33
70
|
|
|
34
71
|
// Service configuration
|
|
35
72
|
host: string
|
|
36
73
|
port: number
|
|
74
|
+
additionalServerOptions: object
|
|
75
|
+
telemetryConfig: object
|
|
37
76
|
config: object
|
|
38
77
|
applicationId: string
|
|
39
78
|
workerId: number | string
|
|
40
79
|
root: string
|
|
41
80
|
isEntrypoint: boolean
|
|
42
|
-
basePath: string
|
|
43
|
-
runtimeBasePath: string
|
|
81
|
+
basePath: string | null
|
|
82
|
+
runtimeBasePath: string | null
|
|
44
83
|
wantsAbsoluteUrls: boolean
|
|
45
84
|
|
|
46
85
|
// Logging
|
|
@@ -54,10 +93,20 @@ export interface PlatformaticGlobal {
|
|
|
54
93
|
registry: Client.Registry
|
|
55
94
|
}
|
|
56
95
|
clientSpansAls: InstanceType<typeof AsyncLocalStorage>
|
|
96
|
+
interceptors: Record<string, any>
|
|
97
|
+
valkeyClients: Map<string, any>
|
|
57
98
|
|
|
58
99
|
// Caching
|
|
100
|
+
onHttpCacheRequest (key: string): void
|
|
59
101
|
onHttpCacheHit (key: string): void
|
|
60
102
|
onHttpCacheMiss (key: string): void
|
|
103
|
+
onHttpStatsFree (url: string, value: number): void
|
|
104
|
+
onHttpStatsConnected (url: string, value: number): void
|
|
105
|
+
onHttpStatsPending (url: string, value: number): void
|
|
106
|
+
onHttpStatsQueued (url: string, value: number): void
|
|
107
|
+
onHttpStatsRunning (url: string, value: number): void
|
|
108
|
+
onHttpStatsSize (url: string, value: number): void
|
|
109
|
+
onActiveResourcesEventLoop (value: number): void
|
|
61
110
|
invalidateHttpCache (options: InvalidateHttpCacheOptions): void
|
|
62
111
|
|
|
63
112
|
// Setters
|
|
@@ -80,13 +129,171 @@ export interface PlatformaticGlobal {
|
|
|
80
129
|
| Promise<{ status: boolean; statusCode?: number; body?: string }>
|
|
81
130
|
): void
|
|
82
131
|
|
|
83
|
-
events:
|
|
132
|
+
events: PlatformaticEvents
|
|
84
133
|
itc: ITC
|
|
85
134
|
messaging: MessagingApi
|
|
135
|
+
capability: object
|
|
136
|
+
closing: boolean
|
|
137
|
+
sharedContext: SharedContext
|
|
138
|
+
management: Management
|
|
139
|
+
sendHealthSignal (signal: HealthSignal): Promise<void>
|
|
140
|
+
telemetryReady: Promise<void>
|
|
141
|
+
tracerProvider: TracerProvider
|
|
142
|
+
notifyConfig (config: object): void
|
|
86
143
|
}
|
|
87
144
|
|
|
88
145
|
/** @deprecated Use `PlatformaticGlobal` instead. */
|
|
89
146
|
export type PlatformaticGlobalInterface = PlatformaticGlobal
|
|
90
147
|
|
|
91
148
|
export declare function getGlobal<T extends {}> (): (PlatformaticGlobal & T) | undefined
|
|
149
|
+
export declare function updateGlobals (updates: Partial<PlatformaticGlobal>): PlatformaticGlobal
|
|
150
|
+
export declare function removeGlobals (fields: string[]): PlatformaticGlobal | undefined
|
|
151
|
+
export declare function hasField (name: string): boolean
|
|
152
|
+
export declare function isBuilding (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['isBuilding']
|
|
153
|
+
export declare function isBuilding (options: OptionalGlobalGetterOptions): PlatformaticGlobal['isBuilding'] | undefined
|
|
154
|
+
export declare function isBuilding (options: GlobalGetterOptions): PlatformaticGlobal['isBuilding'] | undefined
|
|
155
|
+
export declare function getExecutable (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['executable']
|
|
156
|
+
export declare function getExecutable (options: OptionalGlobalGetterOptions): PlatformaticGlobal['executable'] | undefined
|
|
157
|
+
export declare function getExecutable (options: GlobalGetterOptions): PlatformaticGlobal['executable'] | undefined
|
|
158
|
+
export declare function getRuntimeId (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['runtimeId']
|
|
159
|
+
export declare function getRuntimeId (options: OptionalGlobalGetterOptions): PlatformaticGlobal['runtimeId'] | undefined
|
|
160
|
+
export declare function getRuntimeId (options: GlobalGetterOptions): PlatformaticGlobal['runtimeId'] | undefined
|
|
161
|
+
export declare function getNextVersion (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['nextVersion']
|
|
162
|
+
export declare function getNextVersion (options: OptionalGlobalGetterOptions): PlatformaticGlobal['nextVersion'] | undefined
|
|
163
|
+
export declare function getNextVersion (options: GlobalGetterOptions): PlatformaticGlobal['nextVersion'] | undefined
|
|
164
|
+
export declare function getExitOnUnhandledErrors (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['exitOnUnhandledErrors']
|
|
165
|
+
export declare function getExitOnUnhandledErrors (options: OptionalGlobalGetterOptions): PlatformaticGlobal['exitOnUnhandledErrors'] | undefined
|
|
166
|
+
export declare function getExitOnUnhandledErrors (options: GlobalGetterOptions): PlatformaticGlobal['exitOnUnhandledErrors'] | undefined
|
|
167
|
+
export declare function getReuseTcpPorts (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['reuseTcpPorts']
|
|
168
|
+
export declare function getReuseTcpPorts (options: OptionalGlobalGetterOptions): PlatformaticGlobal['reuseTcpPorts'] | undefined
|
|
169
|
+
export declare function getReuseTcpPorts (options: GlobalGetterOptions): PlatformaticGlobal['reuseTcpPorts'] | undefined
|
|
170
|
+
export declare function getHost (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['host']
|
|
171
|
+
export declare function getHost (options: OptionalGlobalGetterOptions): PlatformaticGlobal['host'] | undefined
|
|
172
|
+
export declare function getHost (options: GlobalGetterOptions): PlatformaticGlobal['host'] | undefined
|
|
173
|
+
export declare function getPort (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['port']
|
|
174
|
+
export declare function getPort (options: OptionalGlobalGetterOptions): PlatformaticGlobal['port'] | undefined
|
|
175
|
+
export declare function getPort (options: GlobalGetterOptions): PlatformaticGlobal['port'] | undefined
|
|
176
|
+
export declare function getAdditionalServerOptions (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['additionalServerOptions']
|
|
177
|
+
export declare function getAdditionalServerOptions (options: OptionalGlobalGetterOptions): PlatformaticGlobal['additionalServerOptions'] | undefined
|
|
178
|
+
export declare function getAdditionalServerOptions (options: GlobalGetterOptions): PlatformaticGlobal['additionalServerOptions'] | undefined
|
|
179
|
+
export declare function getTelemetryConfig (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['telemetryConfig']
|
|
180
|
+
export declare function getTelemetryConfig (options: OptionalGlobalGetterOptions): PlatformaticGlobal['telemetryConfig'] | undefined
|
|
181
|
+
export declare function getTelemetryConfig (options: GlobalGetterOptions): PlatformaticGlobal['telemetryConfig'] | undefined
|
|
182
|
+
export declare function getConfig (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['config']
|
|
183
|
+
export declare function getConfig (options: OptionalGlobalGetterOptions): PlatformaticGlobal['config'] | undefined
|
|
184
|
+
export declare function getConfig (options: GlobalGetterOptions): PlatformaticGlobal['config'] | undefined
|
|
185
|
+
export declare function getApplicationId (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['applicationId']
|
|
186
|
+
export declare function getApplicationId (options: OptionalGlobalGetterOptions): PlatformaticGlobal['applicationId'] | undefined
|
|
187
|
+
export declare function getApplicationId (options: GlobalGetterOptions): PlatformaticGlobal['applicationId'] | undefined
|
|
188
|
+
export declare function getWorkerId (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['workerId']
|
|
189
|
+
export declare function getWorkerId (options: OptionalGlobalGetterOptions): PlatformaticGlobal['workerId'] | undefined
|
|
190
|
+
export declare function getWorkerId (options: GlobalGetterOptions): PlatformaticGlobal['workerId'] | undefined
|
|
191
|
+
export declare function getRoot (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['root']
|
|
192
|
+
export declare function getRoot (options: OptionalGlobalGetterOptions): PlatformaticGlobal['root'] | undefined
|
|
193
|
+
export declare function getRoot (options: GlobalGetterOptions): PlatformaticGlobal['root'] | undefined
|
|
194
|
+
export declare function isEntrypoint (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['isEntrypoint']
|
|
195
|
+
export declare function isEntrypoint (options: OptionalGlobalGetterOptions): PlatformaticGlobal['isEntrypoint'] | undefined
|
|
196
|
+
export declare function isEntrypoint (options: GlobalGetterOptions): PlatformaticGlobal['isEntrypoint'] | undefined
|
|
197
|
+
export declare function getBasePath (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['basePath']
|
|
198
|
+
export declare function getBasePath (options: OptionalGlobalGetterOptions): PlatformaticGlobal['basePath'] | undefined
|
|
199
|
+
export declare function getBasePath (options: GlobalGetterOptions): PlatformaticGlobal['basePath'] | undefined
|
|
200
|
+
export declare function getRuntimeBasePath (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['runtimeBasePath']
|
|
201
|
+
export declare function getRuntimeBasePath (options: OptionalGlobalGetterOptions): PlatformaticGlobal['runtimeBasePath'] | undefined
|
|
202
|
+
export declare function getRuntimeBasePath (options: GlobalGetterOptions): PlatformaticGlobal['runtimeBasePath'] | undefined
|
|
203
|
+
export declare function getWantsAbsoluteUrls (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['wantsAbsoluteUrls']
|
|
204
|
+
export declare function getWantsAbsoluteUrls (options: OptionalGlobalGetterOptions): PlatformaticGlobal['wantsAbsoluteUrls'] | undefined
|
|
205
|
+
export declare function getWantsAbsoluteUrls (options: GlobalGetterOptions): PlatformaticGlobal['wantsAbsoluteUrls'] | undefined
|
|
206
|
+
export declare function getLogger (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['logger']
|
|
207
|
+
export declare function getLogger (options: OptionalGlobalGetterOptions): PlatformaticGlobal['logger'] | undefined
|
|
208
|
+
export declare function getLogger (options: GlobalGetterOptions): PlatformaticGlobal['logger'] | undefined
|
|
209
|
+
export declare function getLogLevel (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['logLevel']
|
|
210
|
+
export declare function getLogLevel (options: OptionalGlobalGetterOptions): PlatformaticGlobal['logLevel'] | undefined
|
|
211
|
+
export declare function getLogLevel (options: GlobalGetterOptions): PlatformaticGlobal['logLevel'] | undefined
|
|
212
|
+
export declare function getInterceptLogging (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['interceptLogging']
|
|
213
|
+
export declare function getInterceptLogging (options: OptionalGlobalGetterOptions): PlatformaticGlobal['interceptLogging'] | undefined
|
|
214
|
+
export declare function getInterceptLogging (options: GlobalGetterOptions): PlatformaticGlobal['interceptLogging'] | undefined
|
|
215
|
+
export declare function getPrometheus (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['prometheus']
|
|
216
|
+
export declare function getPrometheus (options: OptionalGlobalGetterOptions): PlatformaticGlobal['prometheus'] | undefined
|
|
217
|
+
export declare function getPrometheus (options: GlobalGetterOptions): PlatformaticGlobal['prometheus'] | undefined
|
|
218
|
+
export declare function getClientSpansAls (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['clientSpansAls']
|
|
219
|
+
export declare function getClientSpansAls (options: OptionalGlobalGetterOptions): PlatformaticGlobal['clientSpansAls'] | undefined
|
|
220
|
+
export declare function getClientSpansAls (options: GlobalGetterOptions): PlatformaticGlobal['clientSpansAls'] | undefined
|
|
221
|
+
export declare function getInterceptors (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['interceptors']
|
|
222
|
+
export declare function getInterceptors (options: OptionalGlobalGetterOptions): PlatformaticGlobal['interceptors'] | undefined
|
|
223
|
+
export declare function getInterceptors (options: GlobalGetterOptions): PlatformaticGlobal['interceptors'] | undefined
|
|
224
|
+
export declare function getValkeyClients (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['valkeyClients']
|
|
225
|
+
export declare function getValkeyClients (options: OptionalGlobalGetterOptions): PlatformaticGlobal['valkeyClients'] | undefined
|
|
226
|
+
export declare function getValkeyClients (options: GlobalGetterOptions): PlatformaticGlobal['valkeyClients'] | undefined
|
|
227
|
+
export declare function getOnHttpCacheRequest (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpCacheRequest']
|
|
228
|
+
export declare function getOnHttpCacheRequest (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpCacheRequest'] | undefined
|
|
229
|
+
export declare function getOnHttpCacheRequest (options: GlobalGetterOptions): PlatformaticGlobal['onHttpCacheRequest'] | undefined
|
|
230
|
+
export declare function getOnHttpCacheHit (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpCacheHit']
|
|
231
|
+
export declare function getOnHttpCacheHit (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpCacheHit'] | undefined
|
|
232
|
+
export declare function getOnHttpCacheHit (options: GlobalGetterOptions): PlatformaticGlobal['onHttpCacheHit'] | undefined
|
|
233
|
+
export declare function getOnHttpCacheMiss (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpCacheMiss']
|
|
234
|
+
export declare function getOnHttpCacheMiss (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpCacheMiss'] | undefined
|
|
235
|
+
export declare function getOnHttpCacheMiss (options: GlobalGetterOptions): PlatformaticGlobal['onHttpCacheMiss'] | undefined
|
|
236
|
+
export declare function getOnHttpStatsFree (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpStatsFree']
|
|
237
|
+
export declare function getOnHttpStatsFree (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpStatsFree'] | undefined
|
|
238
|
+
export declare function getOnHttpStatsFree (options: GlobalGetterOptions): PlatformaticGlobal['onHttpStatsFree'] | undefined
|
|
239
|
+
export declare function getOnHttpStatsConnected (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpStatsConnected']
|
|
240
|
+
export declare function getOnHttpStatsConnected (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpStatsConnected'] | undefined
|
|
241
|
+
export declare function getOnHttpStatsConnected (options: GlobalGetterOptions): PlatformaticGlobal['onHttpStatsConnected'] | undefined
|
|
242
|
+
export declare function getOnHttpStatsPending (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpStatsPending']
|
|
243
|
+
export declare function getOnHttpStatsPending (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpStatsPending'] | undefined
|
|
244
|
+
export declare function getOnHttpStatsPending (options: GlobalGetterOptions): PlatformaticGlobal['onHttpStatsPending'] | undefined
|
|
245
|
+
export declare function getOnHttpStatsQueued (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpStatsQueued']
|
|
246
|
+
export declare function getOnHttpStatsQueued (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpStatsQueued'] | undefined
|
|
247
|
+
export declare function getOnHttpStatsQueued (options: GlobalGetterOptions): PlatformaticGlobal['onHttpStatsQueued'] | undefined
|
|
248
|
+
export declare function getOnHttpStatsRunning (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpStatsRunning']
|
|
249
|
+
export declare function getOnHttpStatsRunning (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpStatsRunning'] | undefined
|
|
250
|
+
export declare function getOnHttpStatsRunning (options: GlobalGetterOptions): PlatformaticGlobal['onHttpStatsRunning'] | undefined
|
|
251
|
+
export declare function getOnHttpStatsSize (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onHttpStatsSize']
|
|
252
|
+
export declare function getOnHttpStatsSize (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onHttpStatsSize'] | undefined
|
|
253
|
+
export declare function getOnHttpStatsSize (options: GlobalGetterOptions): PlatformaticGlobal['onHttpStatsSize'] | undefined
|
|
254
|
+
export declare function getOnActiveResourcesEventLoop (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['onActiveResourcesEventLoop']
|
|
255
|
+
export declare function getOnActiveResourcesEventLoop (options: OptionalGlobalGetterOptions): PlatformaticGlobal['onActiveResourcesEventLoop'] | undefined
|
|
256
|
+
export declare function getOnActiveResourcesEventLoop (options: GlobalGetterOptions): PlatformaticGlobal['onActiveResourcesEventLoop'] | undefined
|
|
257
|
+
export declare function getInvalidateHttpCache (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['invalidateHttpCache']
|
|
258
|
+
export declare function getInvalidateHttpCache (options: OptionalGlobalGetterOptions): PlatformaticGlobal['invalidateHttpCache'] | undefined
|
|
259
|
+
export declare function getInvalidateHttpCache (options: GlobalGetterOptions): PlatformaticGlobal['invalidateHttpCache'] | undefined
|
|
260
|
+
export declare const setBasePath: PlatformaticGlobal['setBasePath']
|
|
261
|
+
export declare const setOpenapiSchema: PlatformaticGlobal['setOpenapiSchema']
|
|
262
|
+
export declare const setGraphqlSchema: PlatformaticGlobal['setGraphqlSchema']
|
|
263
|
+
export declare const setConnectionString: PlatformaticGlobal['setConnectionString']
|
|
264
|
+
export declare const setCustomHealthCheck: PlatformaticGlobal['setCustomHealthCheck']
|
|
265
|
+
export declare const setCustomReadinessCheck: PlatformaticGlobal['setCustomReadinessCheck']
|
|
266
|
+
export declare function getEvents (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['events']
|
|
267
|
+
export declare function getEvents (options: OptionalGlobalGetterOptions): PlatformaticGlobal['events'] | undefined
|
|
268
|
+
export declare function getEvents (options: GlobalGetterOptions): PlatformaticGlobal['events'] | undefined
|
|
269
|
+
export declare function getITC (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['itc']
|
|
270
|
+
export declare function getITC (options: OptionalGlobalGetterOptions): PlatformaticGlobal['itc'] | undefined
|
|
271
|
+
export declare function getITC (options: GlobalGetterOptions): PlatformaticGlobal['itc'] | undefined
|
|
272
|
+
export declare function getMessaging (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['messaging']
|
|
273
|
+
export declare function getMessaging (options: OptionalGlobalGetterOptions): PlatformaticGlobal['messaging'] | undefined
|
|
274
|
+
export declare function getMessaging (options: GlobalGetterOptions): PlatformaticGlobal['messaging'] | undefined
|
|
275
|
+
export declare function getCapability (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['capability']
|
|
276
|
+
export declare function getCapability (options: OptionalGlobalGetterOptions): PlatformaticGlobal['capability'] | undefined
|
|
277
|
+
export declare function getCapability (options: GlobalGetterOptions): PlatformaticGlobal['capability'] | undefined
|
|
278
|
+
export declare function getClosing (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['closing']
|
|
279
|
+
export declare function getClosing (options: OptionalGlobalGetterOptions): PlatformaticGlobal['closing'] | undefined
|
|
280
|
+
export declare function getClosing (options: GlobalGetterOptions): PlatformaticGlobal['closing'] | undefined
|
|
281
|
+
export declare function getSharedContext (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['sharedContext']
|
|
282
|
+
export declare function getSharedContext (options: OptionalGlobalGetterOptions): PlatformaticGlobal['sharedContext'] | undefined
|
|
283
|
+
export declare function getSharedContext (options: GlobalGetterOptions): PlatformaticGlobal['sharedContext'] | undefined
|
|
284
|
+
export declare function getManagement (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['management']
|
|
285
|
+
export declare function getManagement (options: OptionalGlobalGetterOptions): PlatformaticGlobal['management'] | undefined
|
|
286
|
+
export declare function getManagement (options: GlobalGetterOptions): PlatformaticGlobal['management'] | undefined
|
|
287
|
+
export declare function getSendHealthSignal (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['sendHealthSignal']
|
|
288
|
+
export declare function getSendHealthSignal (options: OptionalGlobalGetterOptions): PlatformaticGlobal['sendHealthSignal'] | undefined
|
|
289
|
+
export declare function getSendHealthSignal (options: GlobalGetterOptions): PlatformaticGlobal['sendHealthSignal'] | undefined
|
|
290
|
+
export declare function getTelemetryReady (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['telemetryReady']
|
|
291
|
+
export declare function getTelemetryReady (options: OptionalGlobalGetterOptions): PlatformaticGlobal['telemetryReady'] | undefined
|
|
292
|
+
export declare function getTelemetryReady (options: GlobalGetterOptions): PlatformaticGlobal['telemetryReady'] | undefined
|
|
293
|
+
export declare function getTracerProvider (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['tracerProvider']
|
|
294
|
+
export declare function getTracerProvider (options: OptionalGlobalGetterOptions): PlatformaticGlobal['tracerProvider'] | undefined
|
|
295
|
+
export declare function getTracerProvider (options: GlobalGetterOptions): PlatformaticGlobal['tracerProvider'] | undefined
|
|
296
|
+
export declare function getNotifyConfig (options?: RequiredGlobalGetterOptions): PlatformaticGlobal['notifyConfig']
|
|
297
|
+
export declare function getNotifyConfig (options: OptionalGlobalGetterOptions): PlatformaticGlobal['notifyConfig'] | undefined
|
|
298
|
+
export declare function getNotifyConfig (options: GlobalGetterOptions): PlatformaticGlobal['notifyConfig'] | undefined
|
|
92
299
|
export default getGlobal
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,258 @@
|
|
|
1
|
+
export const kFields = Symbol.for('plt.globals.fields')
|
|
2
|
+
|
|
3
|
+
function getField (name, options) {
|
|
4
|
+
const { throwOnMissing = true } = options ?? {}
|
|
5
|
+
|
|
6
|
+
if (throwOnMissing && !globalThis.platformatic?.[kFields]?.has(name)) {
|
|
7
|
+
throw new Error(`globalThis.platformatic.${name} is not available`)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return globalThis.platformatic?.[name]
|
|
11
|
+
}
|
|
12
|
+
|
|
1
13
|
export function getGlobal () {
|
|
2
14
|
return globalThis.platformatic
|
|
3
15
|
}
|
|
4
16
|
|
|
17
|
+
export function updateGlobals (updates) {
|
|
18
|
+
globalThis.platformatic ??= {}
|
|
19
|
+
globalThis.platformatic[kFields] ??= new Set()
|
|
20
|
+
|
|
21
|
+
for (const [key, value] of Object.entries(updates)) {
|
|
22
|
+
globalThis.platformatic[key] = value
|
|
23
|
+
globalThis.platformatic[kFields].add(key)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return globalThis.platformatic
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function removeGlobals (fields) {
|
|
30
|
+
if (!globalThis.platformatic?.[kFields]) {
|
|
31
|
+
return globalThis.platformatic
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const field of fields) {
|
|
35
|
+
delete globalThis.platformatic[field]
|
|
36
|
+
globalThis.platformatic[kFields].delete(field)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return globalThis.platformatic
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function hasField (name) {
|
|
43
|
+
return globalThis.platformatic?.[kFields]?.has(name) ?? false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function isBuilding (options) {
|
|
47
|
+
return getField('isBuilding', options)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function getExecutable (options) {
|
|
51
|
+
return getField('executable', options)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function getRuntimeId (options) {
|
|
55
|
+
return getField('runtimeId', options)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getNextVersion (options) {
|
|
59
|
+
return getField('nextVersion', options)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getExitOnUnhandledErrors (options) {
|
|
63
|
+
return getField('exitOnUnhandledErrors', options)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getReuseTcpPorts (options) {
|
|
67
|
+
return getField('reuseTcpPorts', options)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getHost (options) {
|
|
71
|
+
return getField('host', options)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function getPort (options) {
|
|
75
|
+
return getField('port', options)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function getAdditionalServerOptions (options) {
|
|
79
|
+
return getField('additionalServerOptions', options)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getTelemetryConfig (options) {
|
|
83
|
+
return getField('telemetryConfig', options)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function getConfig (options) {
|
|
87
|
+
return getField('config', options)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function getApplicationId (options) {
|
|
91
|
+
return getField('applicationId', options)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function getWorkerId (options) {
|
|
95
|
+
return getField('workerId', options)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function getRoot (options) {
|
|
99
|
+
return getField('root', options)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function isEntrypoint (options) {
|
|
103
|
+
return getField('isEntrypoint', options)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function getBasePath (options) {
|
|
107
|
+
return getField('basePath', options)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function getRuntimeBasePath (options) {
|
|
111
|
+
return getField('runtimeBasePath', options)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function getWantsAbsoluteUrls (options) {
|
|
115
|
+
return getField('wantsAbsoluteUrls', options)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getLogger (options) {
|
|
119
|
+
return getField('logger', options)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function getLogLevel (options) {
|
|
123
|
+
return getField('logLevel', options)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function getInterceptLogging (options) {
|
|
127
|
+
return getField('interceptLogging', options)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function getPrometheus (options) {
|
|
131
|
+
return getField('prometheus', options)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function getClientSpansAls (options) {
|
|
135
|
+
return getField('clientSpansAls', options)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function getInterceptors (options) {
|
|
139
|
+
return getField('interceptors', options)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function getValkeyClients (options) {
|
|
143
|
+
return getField('valkeyClients', options)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function getOnHttpCacheRequest (options) {
|
|
147
|
+
return getField('onHttpCacheRequest', options)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function getOnHttpCacheHit (options) {
|
|
151
|
+
return getField('onHttpCacheHit', options)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function getOnHttpCacheMiss (options) {
|
|
155
|
+
return getField('onHttpCacheMiss', options)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function getOnHttpStatsFree (options) {
|
|
159
|
+
return getField('onHttpStatsFree', options)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function getOnHttpStatsConnected (options) {
|
|
163
|
+
return getField('onHttpStatsConnected', options)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function getOnHttpStatsPending (options) {
|
|
167
|
+
return getField('onHttpStatsPending', options)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function getOnHttpStatsQueued (options) {
|
|
171
|
+
return getField('onHttpStatsQueued', options)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function getOnHttpStatsRunning (options) {
|
|
175
|
+
return getField('onHttpStatsRunning', options)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function getOnHttpStatsSize (options) {
|
|
179
|
+
return getField('onHttpStatsSize', options)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function getOnActiveResourcesEventLoop (options) {
|
|
183
|
+
return getField('onActiveResourcesEventLoop', options)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function getInvalidateHttpCache (options) {
|
|
187
|
+
return getField('invalidateHttpCache', options)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function setBasePath (...args) {
|
|
191
|
+
return getField('setBasePath')(...args)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function setOpenapiSchema (...args) {
|
|
195
|
+
return getField('setOpenapiSchema')(...args)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function setGraphqlSchema (...args) {
|
|
199
|
+
return getField('setGraphqlSchema')(...args)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function setConnectionString (...args) {
|
|
203
|
+
return getField('setConnectionString')(...args)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function setCustomHealthCheck (...args) {
|
|
207
|
+
return getField('setCustomHealthCheck')(...args)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function setCustomReadinessCheck (...args) {
|
|
211
|
+
return getField('setCustomReadinessCheck')(...args)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function getEvents (options) {
|
|
215
|
+
return getField('events', options)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function getITC (options) {
|
|
219
|
+
return getField('itc', options)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function getMessaging (options) {
|
|
223
|
+
return getField('messaging', options)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function getCapability (options) {
|
|
227
|
+
return getField('capability', options)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function getClosing (options) {
|
|
231
|
+
return getField('closing', options)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function getSharedContext (options) {
|
|
235
|
+
return getField('sharedContext', options)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export function getManagement (options) {
|
|
239
|
+
return getField('management', options)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function getSendHealthSignal (options) {
|
|
243
|
+
return getField('sendHealthSignal', options)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function getTelemetryReady (options) {
|
|
247
|
+
return getField('telemetryReady', options)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function getTracerProvider (options) {
|
|
251
|
+
return getField('tracerProvider', options)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function getNotifyConfig (options) {
|
|
255
|
+
return getField('notifyConfig', options)
|
|
256
|
+
}
|
|
257
|
+
|
|
5
258
|
export default getGlobal
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/globals",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.56.0",
|
|
4
4
|
"description": "Platformatic Global Object Getter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
|
-
"exports":
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./lib/index.d.ts",
|
|
10
|
+
"import": "./lib/index.js",
|
|
11
|
+
"require": "./lib/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
8
14
|
"types": "./lib/index.d.ts",
|
|
9
15
|
"repository": {
|
|
10
16
|
"type": "git",
|
|
@@ -25,6 +31,7 @@
|
|
|
25
31
|
"typescript": "^5.7.3"
|
|
26
32
|
},
|
|
27
33
|
"dependencies": {
|
|
34
|
+
"@opentelemetry/api": "^1.9.0",
|
|
28
35
|
"@platformatic/prom-client": "^1.0.0",
|
|
29
36
|
"pino": "^9.9.0"
|
|
30
37
|
},
|